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( 'manage_posts_columns', 'your_custom_cols' ); //Filter out Post Columns with 2 custom columns | |
function your_custom_cols($defaults) { | |
$defaults['language'] = __('Language'); //Language and Films is name of column | |
$defaults['film'] = __('Films'); | |
return $defaults; | |
} |
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 | |
//We can add a field as follows: | |
function add_comment_fields($fields) { | |
$fields['age'] = '<p class="comment-form-age"><label for="age">' . __( 'Age' ) . '</label>' . | |
'<input id="age" name="age" type="text" size="30" /></p>'; | |
return $fields; | |
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 | |
/* | |
Plugin Name: Authenticate Users Remotely | |
Author: Christopher Davis | |
Author URI: http://www.christopherguitar.net/ | |
License: GPL2 | |
*/ | |
add_filter('xmlrpc_methods', 'wpse39662_add_login_method' ); | |
/** |
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 wpa47153_run_once(){ | |
$posts = get_posts(array('numberposts' => -1) ); | |
foreach($posts as $p) : | |
$meta = get_post_meta($p->ID, 'meta_key',true); | |
if($meta) : |
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 generateSlug($phrase, $maxLength) { | |
$result = strtolower($phrase); | |
$result = preg_replace("/[^a-z0-9\s-]/", "", $result); | |
$result = trim(preg_replace("/[\s-]+/", " ", $result)); | |
$result = trim(substr($result, 0, $maxLength)); | |
$result = preg_replace("/\s/", "-", $result); | |
return $result; | |
} |
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 | |
/** | |
* API Request Caching | |
* | |
* Use server-side caching to store API request's as JSON at a set | |
* interval, rather than each pageload. | |
* | |
* @arg Argument description and usage info | |
*/ |
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
jQuery.fn.extend( { | |
outerHtml: function( replacement ) { | |
// We just want to replace the entire node and contents with | |
// some new html value | |
if (replacement) { | |
return this.each(function (){ $(this).replaceWith(replacement); }); | |
} | |
/* | |
* Now, clone the node, we want a duplicate so we don't remove |
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 wpa47153_run_once(){ | |
$posts = get_posts(array('numberposts' => -1) ); | |
foreach($posts as $p) : | |
$meta = get_post_meta($p->ID, 'meta_key',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 | |
function cache_image($image_url){ | |
//replace with your cache directory | |
$image_path = 'path/to/cache/dir/'; | |
//get the name of the file | |
$exploded_image_url = explode("/",$image_url); | |
$image_filename = end($exploded_image_url); | |
$exploded_image_filename = explode(".",$image_filename); | |
$extension = end($exploded_image_filename); | |
//make sure its an image |
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 crawl_page($url, $depth = 5) | |
{ | |
static $seen = array(); | |
if (isset($seen[$url]) || $depth === 0) { | |
return; | |
} | |
$seen[$url] = true; |