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 theme colors from Pro and turn them into classes and CSS variables | |
* And now add them to Gutenberg for use in blog posts | |
* | |
* Created Date: Wednesday May 25th 2022 | |
* Author: Michael Bourne | |
* ----- | |
* Last Modified: Wednesday, May 25th 2022, 1:36:28 pm | |
* Modified By: Michael Bourne |
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 | |
// functions.php in a child theme | |
/** | |
* Change Enhanced Slack sharing data labels. | |
* | |
* @param array $data The default Slack labels + data. | |
* @param Indexable_Presentation $presentation The indexable presentation object from Yoast. | |
* | |
* @return array $data The new Slack labels + data. |
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 | |
// functions.php in a child theme | |
/** | |
* Disable Yoast's Enahnced Slack Sharing feature on non-posts | |
*/ | |
function mb_disable_slack_enhancements() { | |
if ( 'post' !== get_post_type() ) { | |
add_filter( 'wpseo_output_enhanced_slack_data', '__return_false' ); | |
} |
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 | |
/** | |
* The following goes in your child theme's functions.php file | |
*/ | |
/** | |
* Generate custom Open Graph images for your blog posts | |
* | |
* @param string $url URL of OG image in HTML Meta. |
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 | |
// The following code goes in your functions.php file of a Child Theme | |
function custom_font_mime_types($mimes = array()) { | |
$mimes['woff'] = 'application/x-font-woff'; | |
$mimes['woff2'] = 'application/x-font-woff2'; | |
// Depending on your server setup, you may need to use these instead: | |
//$mimes['woff'] = 'font/woff'; | |
//$mimes['woff2'] = 'font/woff2'; |
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( 'wp_enqueue_scripts', 'miro_load_script', 99 ); | |
function miro_load_script() { | |
wp_deregister_script( 'vendor-ilightbox' ); | |
wp_register_script( 'vendor-ilightbox', get_stylesheet_directory_uri() . '/new-ilightbox.js', array( 'jquery' ), '2.2.4', true ); | |
} |
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 cart count shortcode [cart_count] | |
// ============================================================================= | |
add_shortcode( 'cart_count', 'mb_cart_count' ); | |
function mb_cart_count() { | |
if ( class_exists( 'WooCommerce' ) && function_exists( 'WC' ) ) { // Check for WooCommerce and WC() function. | |
if ( ! WC()->cart->is_empty() ) { | |
return (string) WC()->cart->get_cart_contents_count(); // Cast to string for consistency. |
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 a body class via the body_class filter in WP | |
// ============================================================================= | |
add_filter( 'body_class', 'mb_body_class_for_cart_items' ); | |
function mb_body_class_for_cart_items( $classes ) { | |
if( ! WC()->cart->is_empty() ){ | |
$classes[] = 'cart-has-items'; | |
} | |
return $classes; |
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 cart count and value to Cart Element text in a Pro header | |
// ============================================================================= | |
add_filter('woocommerce_add_to_cart_fragments', 'mb_cart_count_fragments', 10, 1); | |
function mb_cart_count_fragments($fragments) { | |
$count = WC()->cart->get_cart_contents_count(); | |
$fragments['.cartdropdown .x-anchor-text-primary'] = '<span class="x-anchor-text-primary">' . $count . '</span>'; | |
return $fragments; | |
} |
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 cart count and value to Cart Element text in a Pro header | |
// ============================================================================= | |
add_filter('woocommerce_add_to_cart_fragments', 'mb_cart_count_fragments', 10, 1); | |
function mb_cart_count_fragments($fragments) { | |
$count = WC()->cart->get_cart_contents_count(); | |
$value = ($count == 0) ? '$0.00' : WC()->cart->get_cart_total(); | |
$cart = ($count == 0) ? 'Cart' : 'Items: ' . $count; |
NewerOlder