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 | |
public static function getEventCounts( $args = array() ){ | |
global $wpdb; | |
$date = date( 'Y-m-d' ); | |
$defaults = array( | |
'post_type' => TribeEvents::POSTTYPE, | |
'start_date' => tribe_event_beginning_of_day( $date ), | |
'end_date' => tribe_event_end_of_day( $date ), |
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 sprintf_assoc( $string = '', $replacement_vars = array(), $prefix_character = '%' ) { | |
if ( ! $string ) return ''; | |
if ( is_array( $replacement_vars ) && count( $replacement_vars ) > 0 ) { | |
foreach ( $replacement_vars as $key => $value ) { | |
$string = str_replace( $prefix_character . $key, $value, $string ); | |
} | |
} | |
return $string; |
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( 'image_size_names_choose', 'custom_image_size_names_choose' ); | |
function custom_image_size_names_choose( $sizes ) { | |
global $_wp_additional_image_sizes; | |
// exit gracefully if there are no custom sizes | |
if ( empty($_wp_additional_image_sizes) ) | |
return $sizes; |
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 | |
/** | |
* Insert another array into an associative array after the supplied key | |
* | |
* @param string $key | |
* The key of the array you want to pivot around | |
* @param array $source_array | |
* The 'original' source array | |
* @param array $insert_array |
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
/** | |
* Escape the .attr() method in jQuery | |
* | |
* Creates an empty element using jQuery, set it's HTML to the text you want then return the value as "text" | |
* | |
* @param string | |
* @return string | |
*/ | |
function attr_unescape( x ){ | |
return jQuery('<div />').html( x ).text(); |
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
.truncate { | |
/* add max-width if you wish to make the cutoff text consistent vs variable width of container */ | |
display:inline-block; | |
overflow:hidden; | |
text-overflow: ellipsis; /* limited browser support for anything but clip/ellipsis */ | |
white-space:nowrap; | |
} |
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 | |
/** | |
* wp_convert_to_timezone useful for adjusting an imported DateTime to your site GMT/UTC offset | |
* | |
* @link http://www.php.net/manual/en/timezones.php Accepted $timezone strings | |
* @link http://www.cs.tut.fi/~jkorpela/iso8601.html Reason for default return as ISO 8601 | |
* | |
* @param string $datetime | |
* @param string $timezone default GMT |
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 | |
// fix for http://tri.be/support/forums/topic/maybe-usefull-code-for-timezones-fix/ | |
// remove this once you're using any version of Tribe's Facebook Events greater than version 1.0.4 | |
add_filter( 'tribe_fb_parse_facebook_event', 'tribe_patch_facebook_timezone'); | |
function tribe_patch_facebook_timezone( $event_params ){ | |
// build date string | |
$start_date = $event_params['EventStartDate'] . ' ' . str_pad($event_params['EventStartHour'], 2, '0', STR_PAD_LEFT) . ':' . str_pad($event_params['EventStartMinute'], 2, '0', STR_PAD_LEFT) . ' ' . $event_params['EventStartMeridian']; |
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 debug_registered_associations(){ | |
global $wp_post_types; | |
global $wp_taxonomies; | |
$header = '<tr><th colspan="2">%s</th></tr><tr><th>Post Type</th><th>Taxonomy</th></tr>'; | |
?> | |
<style> | |
.debug_registered_associations{border:1px solid #eee;margin:10px;} | |
.debug_registered_associations th{text-align: left;} |
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 | |
/** | |
* Places the sticky post at the top of the list of posts for the category that is being displayed. | |
* | |
* @param $posts The lists of posts to be displayed for the given category | |
* @return The updated list of posts with the sticky post set as the first titem | |
*/ | |
function reorder_category_posts( $posts ) { |