This file contains hidden or 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 wps_force_ssl( $force_ssl, $post_id = 0, $url = '' ) { | |
if ( $post_id == 25 ) { | |
return true | |
} | |
return $force_ssl; | |
} | |
add_filter('force_ssl' , 'wps_force_ssl', 10, 3); |
This file contains hidden or 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
\Doctrine\Common\Util\Debug::dump($var, $maxDepth) |
This file contains hidden or 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
<?php | |
public function getImageSizeKeepAspectRatio( $imageUrl, $maxWidth, $maxHeight) | |
{ | |
$imageDimensions = getimagesize($imageUrl); | |
$imageWidth = $imageDimensions[0]; | |
$imageHeight = $imageDimensions[1]; | |
$imageSize['width'] = $imageWidth; |
This file contains hidden or 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
<?php | |
function delete_directory($dirname) { | |
if (is_dir($dirname)) | |
$dir_handle = opendir($dirname); | |
if (!$dir_handle) | |
return false; | |
while($file = readdir($dir_handle)) { | |
if ($file != "." && $file != "..") { | |
if (!is_dir($dirname."/".$file)) | |
unlink($dirname."/".$file); |
This file contains hidden or 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
<?php | |
function login_checked_remember_me() { | |
add_filter( 'login_footer', 'rememberme_checked' ); | |
} | |
add_action( 'init', 'login_checked_remember_me' ); | |
function rememberme_checked() { | |
echo "document.getElementById('rememberme').checked = true;"; | |
} |
This file contains hidden or 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
<?php | |
// Replace anything that is not an 'a-z', 'A-Z', or '0-9' from the given $value | |
$value = preg_replace( "/[^a-zA-Z0-9\s]/", "", $value ); | |
?> |
This file contains hidden or 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
<?php | |
add_filter( 'preprocess_comment', 'minimal_comment_length' ); | |
function minimal_comment_length( $commentdata ) { | |
$minimalCommentLength = 20; | |
if ( strlen( trim( $commentdata['comment_content'] ) ) < $minimalCommentLength ) | |
{ | |
wp_die( 'All comments must be at least ' . $minimalCommentLength . ' characters long.' ); | |
} |
This file contains hidden or 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 table SET name='test_name' ORDER BY id DESC LIMIT 1; |
This file contains hidden or 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
<?php | |
/** | |
* Send debug code to the Javascript console | |
*/ | |
function debug_to_console($data) { | |
if(is_array($data) || is_object($data)) | |
{ | |
echo("<script>console.log('PHP: ".json_encode($data)."');</script>"); | |
} else { | |
echo("<script>console.log('PHP: ".$data."');</script>"); |
This file contains hidden or 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
<?php | |
/* | |
* php delete function that deals with directories recursively | |
*/ | |
function delete_files($target) { | |
if(is_dir($target)){ | |
$files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned | |
foreach( $files as $file ) | |
{ |