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
There are four tables and we need to fetch the data with multiple Inner Joins. There are 14 inner joins which is taking long time to respond. This has been reduced to 3 inner joins with MySql MAX CASE which is quite fast in output with same result. I hope you can find this useful. | |
## Tables ## | |
WP_POSTS | |
WP_POSTMETA | |
WP_WOOCOMMERCE_ORDER_ITEMS | |
WP_WOOCOMMERCE_ORDER_ITEMMETA | |
## Old Query ## |
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 to modify EDD country data */ | |
function modify_edd_countries( $countries ) { | |
/* Change Blank Option with String */ | |
//$countries[''] = 'Select Country'; | |
/* Remove first blank option */ | |
//unset( $countries[''] ); |
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 | |
/** | |
* Apply WooCommerce shipping class based on coupon code applied on a product | |
* 26211 - This is product ID on which coupon code is applied | |
* 28760 - This is coupon code ID | |
* 142 - This is shipping class ID. You can find this when you inspect the shipping class table row | |
*/ | |
function cart_apply_custom_shipping_class( $cart_contents ) { |
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 | |
/** | |
* Display product modified date in [download_history] shortcode. | |
*/ | |
// Function to add extra column | |
function edd_add_download_history_column() { | |
echo '<th class="edd_download_download_name">'.esc_html__( 'Update Date', 'easy-digital-downloads' ).'</th>'; | |
} | |
add_action( 'edd_download_history_header_end', 'edd_add_download_history_column' ); |
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 | |
/** | |
* Display total count of EDD products | |
* Display total count of EDD products with category also | |
* Use this shortcode 'edd_total_downlods' in any page or post where you want to show the EDD product number. | |
*/ | |
function edd_render_total_downlods( $atts, $content ) { | |
$atts = shortcode_atts( array( | |
'category' => '', |
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 to add array after specific key | |
*/ | |
function __edd_add_array(&$array, $value, $index, $from_last = false) { | |
if( is_array($array) && is_array($value) ) { | |
if( $from_last ) { | |
$total_count = count($array); |
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 | |
// Remove EDD schema.org microdata (In case your theme is already adding it) | |
function _edd_add_schema_microdata( $microdata ) { | |
$microdata = false; | |
return $microdata; | |
} | |
add_filter( 'edd_add_schema_microdata', '_edd_add_schema_microdata' ); | |
?> |
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 to add 'Read More' button at EDD [downloads] shortcode. | |
function _add_btn_edd_download_after() { | |
echo '<a class="button blue edd-submit" href="'. esc_url( get_permalink() ) .'" target="_blank">'. __('Read More') .'</a>'; | |
} | |
add_action( 'edd_download_after', '_add_btn_edd_download_after' ); | |
?> |
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
// WP Query Parameters | |
$args = array ( | |
'post_type' => 'download', | |
'post_status' => array( 'publish' ), | |
'order' => 'DESC', | |
'orderby' => 'post_date', | |
'posts_per_page' => 10, | |
'ignore_sticky_posts' => true, | |
'meta_query' => array( | |
array( |
NewerOlder