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
// Run function only when the export is initiated | |
add_action( 'export_wp', 'zdt_unlimited_script_time' ); | |
/** | |
* Sets script execution time to unlimited. | |
* | |
* @return void | |
*/ | |
function zdt_unlimited_script_time() { | |
set_time_limit( 0 ); |
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
/** | |
* Used in front end requests to get the latest Tweet. | |
* | |
* @return bool|string | |
*/ | |
function get_latest_tweet() { | |
// Attempt to get the transient | |
if ( $tweet = get_transient( 'my_latest_tweet' ) ) { | |
return $tweet; |
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 if ( $image = zdt_get_social_image( $post ) ) : ?> | |
<div class="pin_share"> | |
<a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode( esc_url( get_the_permalink( get_the_ID() ) ); ?>&media=<?php echo urlencode( esc_url( $image ) ); ?>&description=<?php echo urlencode( esc_html( get_the_excerpt( get_the_ID() ) ); ?>" class="pin-it-button" count-layout="none">Pin It</a> | |
</div> | |
<?php endif; ?> |
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
/** | |
* 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 admin_ajax_url( $path = '' ) { | |
if ( is_admin() ) | |
$url = admin_url( 'admin-ajax.php' ); | |
else | |
$url = home_url( 'wp-admin/admin-ajax.php' ); |
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_action( 'init', 'test' ); | |
function test() { | |
// Returns bool( false ) | |
set_transient( 'test-trans-false', false, 5 ); | |
get_transient( 'test-trans-false' ); | |
// Return bool( false ) | |
set_transient( 'test-trans-true', true, 5 ); | |
get_transient( 'test-trans-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 | |
function zt_add_enctype { | |
echo ' enctype="multipart/form-data"'; | |
} | |
add_action( 'post_edit_form_tag', 'zt_add_enctype' ); |
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 test_race() { | |
if ( wp_cache_get( 'lock' ) ) | |
return false; | |
wp_cache_add( 'lock', 1 ); | |
$key = time(); | |
wp_cache_add( $key, 0 ); |
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 test_race() { | |
$key = date( 'YdmH', time() ); | |
wp_cache_add( $key, 0 ); | |
if ( 1 !== wp_cache_incr( $key ) ) | |
return false; | |
// Do the things | |
} |
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 meta_box_callback( $post_local ) { | |
global $post; | |
$post_global_copy = $post; | |
$my_query = new WP_Query( array( | |
'posts_per_page' => 10 | |
) ); | |
if ( $my_query->have_posts() ) { |
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 | |
class MostDiscussed_Widget extends WP_Widget { | |
private $excluded_posts; | |
function __construct() { | |
} | |
function widget( $args, $instance ) { |
OlderNewer