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 | |
/** | |
* Gets the current global post type if one is set | |
*/ | |
function x_get_current_post_type() { | |
global $post, $typenow, $current_screen; | |
if( $post && $post->post_type ) | |
$post_type = $post->post_type; | |
elseif( $typenow ) |
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 | |
// Edit these to match your environment settings | |
define( 'BASE_PATH', '/home/username/webapps' ); | |
// This is the path to the git executable | |
define( 'GIT_PATH', get_full_path( '/git/bin/git' ) ); | |
// Edit this array so the key matches the github repo name and the value is path of the repo relative to the BASE_PATH | |
$repository_paths = array( | |
'test' => '/git-test' |
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 | |
/** | |
* Saves post meta value | |
* | |
* @param int ID of the post | |
* @param string Name of the post_meta key (same as the $_POST key and nonce name) | |
* @param string Name of the nonce key | |
* @param mixed The default value to be assigned if not set | |
* | |
* @return string Value that was saved |
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 debug_get_functions_for_hook( $hook ) { | |
global $wp_filter; | |
if( ! isset( $wp_filter[$hook] ) ) | |
return; | |
$functions = array(); | |
foreach( (array) $wp_filter[$hook] as $key => $actions ) { | |
//$functions = array_merge( $functions, $actions ); |
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 | |
/** | |
* Generates a domain-mapping safe URL on WordPress.com | |
* Core's ajaxurl uses admin_url() which returns *.wordpress.com which doesn't work for the front-end on domain-mapped sites. | |
* This works around that and generates the correct URL based on context. | |
*/ | |
function my_admin_ajax_url( $path = '' ) { | |
if ( is_admin() ) | |
$url = admin_url( 'admin-ajax.php' ); | |
else |
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 dump_rewrite_rules() { | |
$tmp_file = '/tmp/rewrite_rule_dump.txt'; // define filename here if needed | |
if ( !touch( $tmp_file ) || !is_writeable( $tmp_file ) ) { | |
error_log( 'dump_rewrite_rules: The file ' . $tmp_file . ' is not writable. Please check the permissions.' ); | |
return; | |
} | |
global $wp_rewrite; | |
$rules = var_export( $wp_rewrite, 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
add_filter( 'pre_post_link', 'make__permalink', 10, 2 ); | |
function make_new_permalink( $permalink, $post ) { | |
if ( 'page' == $post->post_type && in_array( $post->page_name, array( 'home-page', 'home-page-include' ) ) ) { | |
$permalink = 'http://makezine.com'; | |
} | |
return $permalink; | |
} |
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 | |
// Register our custom rule | |
add_action( 'init', 'qz_add_custom_permalink_rule' ); | |
function qz_add_custom_permalink_rule() { | |
add_rewrite_rule( '/(\d+)/(^/)/' => 'index.php?p=$matches[1]&name=$matches[2]' ); | |
} | |
add_filter( 'post_link', 'qz_custom_permalink', 99, 2 ); |
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 $query = new WP_Query( array( 'posts_per_page' => 100, 'fields' => 'ids' ) ); ?> | |
<?php if ( $query->have_posts() ) : | |
$post_ids = $query->posts; | |
shuffle( $post_ids ); | |
$post_ids = array_splice( $post_ids, 0, 12 ); | |
foreach ( $post_ids as $post_id ) : | |
$post = get_post( $post_id ); | |
setup_postdata( $post ); | |
?> |
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
jQuery( function( $ ) { | |
if ( 'undefined' === typeof FB ) | |
return; | |
if ( $( 'body' ).hasClass( 'single-post' ) || $( 'body' ).hasClass( 'page' ) ) { | |
var $comments_div = $( '<div/>' ); | |
$comments_div.addClass( 'fb-comments' ); | |
$comments_div.attr( 'data-href', document.location ); | |
$comments_div.appendTo( $( '.primary-content' ) ); |