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 oembed_utils( $html ) { | |
| // set the default youtube url to youtube-nocookie.com | |
| $html = str_replace("www.youtube.com/embed","www.youtube-nocookie.com/embed", $html); | |
| // remove youtube random related videos | |
| $html = str_replace( "feature=oembed", "feature=oembed&rel=0", $html ); |
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
| /* | |
| * Erik Codekraft - 2022 | |
| */ | |
| /// Output the value for the property | |
| /// @param {number or string} $val - the base value | |
| /// @param {number} $val2 - the value to sum | |
| /// @output the result or the css string calc(val1 + val2) | |
| @function set_value($val, $val2) { | |
| @if (type-of($val) == string) { |
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 webp_uploads_filter_image_copy( $image_meta, $attachment_id ) { | |
| $file = wp_get_original_image_path( $attachment_id ); | |
| $image_mime = wp_getimagesize( $file )['mime']; | |
| if ( 'image/jpeg' === $image_mime ) { |
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 | |
| // Preload the Wordpress post featured image (works both with src and srcset) | |
| // ref. https://web.dev/preload-responsive-images/ | |
| add_action('wp_head', function () { | |
| if (has_post_thumbnail()) { | |
| $thumb_id = get_post_thumbnail_id( get_the_ID() ); | |
| $featured_img_src = wp_get_attachment_image_src( $thumb_id, 'large' )[0]; | |
| $featured_img_srcset = wp_get_attachment_image_srcset( $thumb_id ); | |
| printf('<link rel="preload" as="image" importance="high" href="%s" srcset="%s" />', $featured_img_src, $featured_img_srcset ); |
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 | |
| // A php fast and time-effective minification function for css and html files | |
| // I don't pretend to perform a complete minification but this will reduce the file size considerably | |
| // and without consuming many resources. | |
| function toKB( $bytes ) { | |
| return number_format( $bytes / 1024, 2 ); | |
| } | |
| function compress_notice( $raw, $compressed ) { |
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 | |
| // README: you need GD installed | |
| function myprefix_explode_filepath( $filepath, $attachment_id ) { | |
| $uploads = wp_upload_dir(); | |
| if ( strpos( $filepath, "/" ) == false ) { | |
| return array( $uploads['basedir'], "", $filepath ); | |
| } else { | |
| list( $year, $month, $filename ) = explode( '/', $filepath ); |
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 | |
| // a modified version of https://stackoverflow.com/a/33748742/5735847 | |
| function get_accept_language_array( $languages ) { | |
| return array_values( | |
| array_reduce( | |
| explode(',', str_replace(' ', '', $languages) ), | |
| function ($res, $el) { | |
| if (strlen($el) === 5) { | |
| $l = explode('-', $el); |
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 | |
| /** | |
| * Dequeue global wordpress style | |
| */ | |
| if ( ! function_exists( 'my_remove_global_style' ) ) : | |
| function my_remove_global_style() { | |
| wp_deregister_style( 'global-styles' ); | |
| wp_dequeue_style( 'global-styles' ); | |
| } | |
| endif; |
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
| // the default palette | |
| $wpcf7-white: #fff !default; // Blue | |
| $wpcf7-light-gray: #505b66 !default; // Light Gray | |
| $wpcf7-dark-gray: #23282d !default; // Dark Gray | |
| $wpcf7-blue: #00a0d2 !default; // Blue | |
| $wpcf7-green: #46b450 !default; // Green | |
| $wpcf7-red: #dc3232 !default; // Red | |
| $wpcf7-orange: #f56e28 !default; // Orange | |
| $wpcf7-yellow: #ffb900 !default; // Yellow |
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 | |
| /** | |
| * wc_direct_link_to_product_tabs | |
| * | |
| * Allows you to create custom URLs to activate product tabs by default, directly from the URL. | |
| * ex: http://mysite.com/my-product-name#reviews | |
| * this fork add history.pushState and each tab will be treated as a page | |
| * so you can use browser history back / forward to move along tabs | |
| */ | |
| add_action( 'wp_footer', function () { |