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 get_book_detail( $book_id ) { | |
| $cache_key = 'book_' . $book_id; | |
| $data = get_transient( $cache_key ); | |
| if ( false === $data ) { | |
| $data = get_post( $book_id ); |
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('save_post_{post_type}', 'fn_delete_transient', 10, 3); | |
| function fn_delete_transient( $post_id, $post, $update ) { | |
| delete_transient( 'cache_key' . $post_id ); | |
| } | |
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 | |
| // check for role | |
| function wp_check_user_role($role_slug) { | |
| $user = wp_get_current_user(); | |
| return is_user_logged_in() && isset( $user->roles ) && is_array( $user->roles ) && in_array( $role_slug, $user->roles ); | |
| } | |
| // modify the url or title |
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('woocommerce_product_meta_end', 'show_cross_sell_in_single_product', 30); | |
| function show_cross_sell_in_single_product(){ | |
| $crosssells = get_post_meta( get_the_ID(), '_crosssell_ids',true); | |
| if(empty($crosssells)){ | |
| return; |
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 | |
| // change Billing details to Personal Information | |
| function wc_billing_field_strings( $translated_text, $text, $domain ) { | |
| switch ( $translated_text ) { | |
| case 'Billing details' : | |
| $translated_text = __( 'Personal Information', 'woocommerce' ); | |
| break; | |
| } | |
| return $translated_text; |
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_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' ); | |
| function hide_coupon_field_on_cart( $enabled ) { | |
| if ( is_cart() ) { | |
| $enabled = false; | |
| } |
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', 'register_awaiting_shipment_order_status' ); | |
| function register_awaiting_shipment_order_status() { | |
| register_post_status( 'wc-awaiting-shipment', array( | |
| 'label' => _x('Ready for Delivery', 'Order status', 'woocommerce'), | |
| 'public' => true, | |
| 'exclude_from_search' => false, | |
| 'show_in_admin_all_list' => 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 | |
| /** | |
| * Required plugin: | |
| * https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/ | |
| */ | |
| add_filter('wf_pklist_alter_admin_print_role_access','wt_pklist_add_print_role'); | |
| function wt_pklist_add_print_role($role_arr) | |
| { |
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 a new custom column to admin order list | |
| add_filter( 'manage_edit-shop_order_columns', 'add_payment_shop_order_column',11); | |
| function add_payment_shop_order_column($columns) { | |
| $reordered_columns = array(); | |
| foreach( $columns as $key => $column){ | |
| $reordered_columns[$key] = $column; | |
| if( $key == 'order_total' ){ |
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 | |
| $trp = TRP_Translate_Press::get_trp_instance(); | |
| $render = $trp->get_component( 'translation_render' ); | |
| $setting = $trp->get_component( 'settings' ); | |
| // List of strings to translate | |
| $strings = array( | |
| 'home' => 'Home', | |
| 'about' => 'About Us', |