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
// memory friendly alternative to get_posts( array( 'posts_per_page' => '-1' ) ); | |
$product_page = 1; | |
$product_per_page = 10; | |
$product_query = new WP_Query( array( | |
'posts_per_page' => $product_per_page, | |
'paged' => $product_page, | |
'post_type' => array( 'product', 'product_variation' ), | |
) ); | |
$product_ids = 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
<?php | |
// this sample widget will show how many jobs were started in the last 7 days: | |
if(class_exists('module_job',false) && module_job::can_i('view','Jobs')){ | |
$jobs = module_job::get_jobs(array( | |
'date_start_after'=>date('Y-m-d',strtotime('-7 days')) | |
),array('columns'=>'u.job_id')); | |
ob_start(); | |
// icons from http://ionicons.com/ | |
?> |
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
$possibleTemplates = array( | |
plugin_dir_path( __FILE__ ).'/template_file_name.php', // default template | |
TEMPLATEPATH.'/my_plugin_name/template_file_name.php', // user can override default with this template | |
STYLESHEETPATH.'/my_plugin_name/template_file_name.php', // or user can override default with this template | |
); | |
$tempalteToUse = false; | |
foreach($possibleTemplates as $possibleTemplate){ | |
if(is_readable($possibleTemplate)){ | |
$tempalteToUse = $possibleTemplate; | |
} |
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
add_shortcode('bbp-unread-topic-index','dtbaker_bbq_unread_topics'); | |
function dtbaker_bbq_unread_topics(){ | |
if(is_user_logged_in()){ | |
$result = ''; | |
// filter the bbPress query args that are run when [bbp-topic-index] is executed. | |
add_filter('bbp_after_has_topics_parse_args','unread_bbp_after_has_topics_parse_args',3,1); | |
// adjust the generated 'where' SQL to perform a table comparison | |
add_filter('get_meta_sql','dtbaker_get_meta_sql',3,6); | |
// run the built in bbpress shortcode which does everything nicely |
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
// work out if we're doing a letter or parcel delivery | |
// Letter max is 26cm x 36cm x 2cm / 0.5kg | |
// everything larger will be parcel. | |
$max_dimensions = array(2,26,36); | |
if($calculate_product['weight']<=0.5){ | |
$product_dimensions = array($calculate_product['length'],$calculate_product['width'],$calculate_product['height']); | |
sort($product_dimensions); | |
$is_letter = ( | |
$product_dimensions[0]<=$max_dimensions[0] && | |
$product_dimensions[1]<=$max_dimensions[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 | |
// get_page_by_path called in query.php 2119 ! | |
//remove_action('template_redirect', 'redirect_canonical'); | |
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
public function register_custom_post_type() { | |
$labels = array( | |
'name' => 'Wiki Pages', | |
'singular_name' => 'Wiki Page', | |
'menu_name' => 'Wiki Pages', | |
'parent_item_colon' => 'Parent Wiki Page:', | |
'all_items' => 'All Wiki Pages', | |
'view_item' => 'View Wiki Page', | |
'add_new_item' => 'Add New Wiki Page', | |
'add_new' => 'New Wiki Page', |
NewerOlder