This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function currentPageURL($includeQueryString = true) { | |
$pageURL = 'http'; | |
$pageURL .= ($_SERVER["HTTPS"] == "on") ? "s" : ""; | |
$pageURL .= "://"; | |
$pageURL .= ($_SERVER["SERVER_PORT"] != "80") ? $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"] : $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; | |
if (!$includeQueryString) { | |
$pageURL = str_replace('?'.$_SERVER["QUERY_STRING"], '', $pageURL); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Force SSL for specific subdomains | |
RewriteEngine On | |
RewriteCond %{HTTPS} off | |
RewriteCond %{HTTP_HOST} ^(secure|login)\. [NC] | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Force www. prefix | |
RewriteCond %{HTTP_HOST} !^$ | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteCond %{HTTPS}s ^on(s)| | |
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// Convert a camel-case or underscore_separated string to Title Case | |
function valueToTitle($string) { | |
$string = preg_replace('/(?!^)([[:upper:]][[:lower:]]+)/', ' $0', $string); | |
$string = preg_replace('/(?!^)([[:lower:]])([[:upper:]])/', '$1 $2', $string); | |
$string = str_replace('_', ' ', $string); | |
$string = ucwords($string); | |
return $string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function camelCaseToTitleCase($string) { | |
return ucwords(preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]/', ' $0', $string)); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/* | |
Description: Place this code at the top of your PHP page to minify all of it's HTML output | |
Dependencies: https://code.google.com/p/minify/ | |
*/ | |
function sanitize_output($buffer) { | |
require_once('min/lib/Minify/HTML.php'); | |
require_once('min/lib/Minify/CSS.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// Ping Facebook with (via a POST request) to refresh the cache (scrape) for a scheduled post as it is published | |
// Relevant docs: https://developers.facebook.com/docs/opengraph/using-objects#selfhosted-update | |
// Place this in your Wordpress functions.php file | |
add_action('transition_post_status', 'purge_future_post', 10, 3); | |
function purge_future_post($new_status, $old_status, $post) { | |
if($new_status == 'publish') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prevent non-numeric entries on number inputs | |
$("input[type=number]").keydown(function (e) { | |
// Allow: backspace, delete, tab, escape, enter and . | |
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || | |
// Allow: Ctrl+A | |
(e.keyCode == 65 && e.ctrlKey === true) || | |
// Allow: home, end, left, right, down, up | |
(e.keyCode >= 35 && e.keyCode <= 40)) { | |
// let it happen | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE `wp_posts` SET `guid` = replace(guid, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_posts` SET `post_content` = replace(post_content, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_postmeta` SET `meta_value` = replace(meta_value, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_options` SET `option_value` = replace(option_value, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_comments` SET `comment_content` = replace(comment_content, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_comments` SET `comment_author_url` = replace(comment_author_url, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_commentmeta` SET `meta_value` = replace(meta_value, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_users` SET `user_url` = replace(user_url, 'http://old.domain.com', 'https://new.domain.com'); |
OlderNewer