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
\Doctrine\Common\Util\Debug::dump($var, $maxDepth) |
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
<?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 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 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 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 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 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 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 ) | |
{ |
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
<?php | |
echo '<pre>'; | |
print_r($debug_array); | |
echo '</pre>'; | |
exit; |
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
<?php | |
//cache file | |
$cachefile = 'cached/'.date('M-d-Y').'.php'; | |
//Total time the file will be cached in seconds set to 10 hours | |
$cachetime = 36000; | |
//If the cache file already exists and the cache file is over 10hours old then display the cache file | |
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) { | |
include($cachefile); |