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 ching_disable_block_widget() { | |
remove_theme_support(‘widgets-block-editor’); | |
} | |
add_action(‘after_setup_theme’, ‘ching_disable_block_widget’); |
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_action( 'init', 'ching_shortcode' ); | |
function ching_shortcode() { | |
// Usage: [ching-shortcode text="Hello World!"] | |
add_shortcode( 'ching-shortcode', 'ching_test_shortcode' ); | |
function ching_test_shortcode( $atts ) { | |
$atts = shortcode_atts( array( | |
'text' => 'Hello World!', |
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('gform_custom_merge_tags', 'ching_custom_merge_tags', 10, 4); | |
function ching_custom_merge_tags( $merge_tags, $form_id, $fields, $element_id ) { | |
$merge_tags[] = array('label' => 'Open Present', 'tag' => '{open_present}'); | |
return $merge_tags; | |
} | |
add_filter('gform_replace_merge_tags', 'ching_replace_merge_tags', 10, 3); | |
function ching_replace_merge_tags( $text, $form, $entry ) { | |
if ( strpos( $text, '{open_present}' ) ) { | |
$text = str_replace( '{open_present}', 'Here it is!', $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
<?php | |
// Allow shortcode in nav items | |
add_filter('wp_nav_menu_items', 'do_shortcode'); | |
// [cart-total] | |
add_shortcode( 'cart-total', 'ching_shortcode_woo_cart_total' ); | |
function ching_shortcode_woo_cart_total(){ | |
$total = WC()->cart->total; | |
return '<span>'.wc_price($subtotal).'</span>'; | |
} |
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 | |
// hide toolset trash button for relationship CPT | |
add_action('admin_head', 'ching_admin_css'); | |
function ching_admin_css() { | |
echo '<style> | |
.wp-admin.post-type-recipe .toolset-listing-wrapper .wp-list-table .row-actions .delete { | |
display: none; | |
} | |
</style>'; | |
} |
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 continue shopping | |
// add_action( 'woocommerce_before_checkout_form', 'ching_back_to_store' ); | |
add_action('woocommerce_cart_coupon', 'ching_back_to_store'); | |
// add_action( 'woocommerce_cart_actions', 'ching_back_to_store' ); | |
function ching_back_to_store() { ?> | |
<a class="button wc-backward" href="<?php echo esc_url( wc_get_page_permalink( 'shop' ) ); ?>"> <?php _e( '繼續購物', 'woocommerce' ) ?> </a> | |
<?php | |
} |
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 product tabs | |
add_filter( 'woocommerce_product_tabs', 'ching_woo_new_tab' ); | |
function ching_woo_new_tab( $tabs ) { | |
// rename description tab title | |
$tabs['description']['title'] = __( '商品特色' ); | |
// add the new tab - specs | |
$tabs['specs'] = array( | |
'title' => __( '商品規格', 'woocommerce' ), |
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 wishlist endpoint | |
function ching_add_wishlist_endpoint() { | |
add_rewrite_endpoint( 'wishlist', EP_ROOT | EP_PAGES ); | |
} | |
add_action( 'init', 'ching_add_wishlist_endpoint' ); | |
function ching_wishlist_query_vars( $vars ) { | |
$vars[] = 'wishlist'; |
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 ching_add_google_fonts() { | |
wp_enqueue_style( 'ching-google-fonts', 'fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&family=Noto+Serif+TC:wght@300;400;500;600;700&display=swap', false ); | |
} | |
add_action( 'wp_enqueue_scripts', 'ching_add_google_fonts' ); |
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
//maps.googleapis.com | |
//maps.gstatic.com | |
//fonts.googleapis.com | |
//fonts.gstatic.com | |
//ajax.googleapis.com | |
//apis.google.com | |
//google-analytics.com | |
//www.google-analytics.com | |
//ssl.google-analytics.com | |
//youtube.com |