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
| $css_timestamp = filemtime( get_stylesheet_directory() . '/assets/css/app.css' ); | |
| wp_enqueue_style( 'child_app', get_stylesheet_directory_uri() . '/assets/css/app.css', null, $css_timestamp ); |
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
| /** | |
| * minimize unnecessary revision storage (based on post type) | |
| */ | |
| add_filter( 'wp_revisions_to_keep', function ( $nr_revisions, $post ) { | |
| switch ( $post->post_type ) { | |
| case 'page': | |
| case 'movie': | |
| case 'article': | |
| case 'story': | |
| $nr_revisions = 3; |
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 | |
| // get rid of junk <p> and <br> tags TinyMCE inserts around shortcodes | |
| add_filter( 'the_content', function ( $content ) { | |
| $array = [ | |
| '<p>[' => '[', | |
| ']</p>' => ']', | |
| ']<br />' => ']', | |
| ']<br>' => ']', | |
| '<p> </p>' => '', | |
| ]; |
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
| /** | |
| * First Leaf | |
| * - returns the first non-array element (singular or object). | |
| * - handy when you're not sure whether information has been stored | |
| * as a singular value ('item') or 1-element array (0=>'item'). | |
| * - the key() function gives us the first key in the array. | |
| * - uses recursion to go deeper if necessary; if that's not | |
| * what you want, you may need a different solution. | |
| */ | |
| public static function first_leaf ( $value ) { |
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 | |
| /** | |
| * Phone Number Format | |
| * - used to display phone numbers from a WooCommerce database | |
| * - assumes local US numbers | |
| * - very basic: removes non-digit characters, +1, adds dashes | |
| * - props for base function to https://arjunphp.com/format-phone-number-using-php/ | |
| * - props for "+1" to https://simplysmartmedia.com/2013/11/php-phone-number-formatting-function/ | |
| */ | |
| private static function phone_number_format ( $number ) { |
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
| /* Generated by Google's AI in response to search for | |
| "woocommerce trim customer name with trailing space site:stackoverflow.com". | |
| Not yet tested. | |
| StackOverflow had several pieces of the solution but no single post addressed this | |
| specific issue. I'm not a big AI fan so I was both surprised and impressed that | |
| Google AI seems to have merged several pieces of code into a woocommerce hook. | |
| */ | |
| add_action('woocommerce_checkout_update_order_meta', 'trim_customer_name_on_checkout'); | |
| function trim_customer_name_on_checkout($order_id) { |
OlderNewer