codeSnippets(All);

Access folder as root

sudo -i
cd /path/folder
exit

Showing 3 lines of 4 total lines in this snippet.

Include Google Web Fonts

<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">

Showing 1 lines of 9 total lines in this snippet.

Return short text snippet function

function textSnippet($string,$length=200){
  return preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
}

Showing 3 lines of 3 total lines in this snippet.

SQL queries to move WordPress

UPDATE wp_options SET option_value = replace(option_value, 'http://www.sitename.com', 'https://www.sitename.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.sitename.com','https://www.sitename.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.sitename.com', 'https://www.sitename.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.sitename.com','https://www.sitename.com');

Showing 4 lines of 5 total lines in this snippet.

Simple JSON array

{"array":[{
"date": "01 Dec 2016",
"title": "Title 1",
"description": "Lorem amet ipsum dolor sit."
},{
"date": "02 Dec 2016",
"title": "Title 2",
"description": "Lorem ipsum amet dolor sit."
},{
"date": "03 Dec 2016",
"title": "Title 3",
"description": "Lorem ipsum sit dolor amet."
},{
"date": "04 Dec 2016",
"title": "Title 4",
"description": "Lorem ipsum dolor amet sit."
},{
"date": "05 Dec 2016",
"title": "Title 5",
"description": "Lorem dolor ipsum sit amet."
}]}

Showing 21 lines of 21 total lines in this snippet.

Single item JSON

{"text":"<p>Here's some text in html tags in a json element also using \"quotes\"</p>"}

Showing 1 lines of 1 total lines in this snippet.

Rewrite http to https in .htaccess

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Showing 9 lines of 14 total lines in this snippet.