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
// Enable preview / thumbnail for webp image files. | |
function display_webp($result, $path) { | |
if ($result === false) { | |
$webp_image_types = array( IMAGETYPE_WEBP ); | |
$info = @getimagesize( $path ); | |
if (empty($info)) { | |
$result = false; | |
} elseif (!in_array($info[2], $webp_image_types)) { | |
$result = 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
// Enable upload for webp image files. | |
function mb_webp_upload($addmimetype) { | |
$addmimetype['webp'] = 'image/webp'; | |
return $addmimetype; | |
} | |
add_filter('mime_types', 'mb_webp_upload'); |
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
/* | |
* Remove Gutenberg welcome popup | |
* @link https://marcobrughi.com | |
* | |
* @author Marco Brughi <[email protected]> | |
* | |
*/ | |
function mb_enqueue_admin_script() { | |
if ( is_admin() ) { | |
wp_add_inline_script( |
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
/* | |
* Insert Google Tag Manager right after body open tag | |
* @link https://marcobrughi.com | |
* | |
* @author Marco Brughi <[email protected]> | |
* | |
* NB: Change Code with your's | |
*/ | |
function mb_add_after_body_code() { | |
echo '<!-- Google Tag Manager (noscript) --> |
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
/* | |
* Insert Google Analytics Code | |
* @link https://marcobrughi.com | |
* | |
* @author Marco Brughi <[email protected]> | |
* | |
* NB: Change Analytics Code with your's | |
*/ | |
function mb_analytics_code() { | |
?> |
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
function hook_css() { | |
?> | |
<style> | |
.wp_head_example { | |
background-color : #f1f1f1; | |
} | |
</style> | |
<?php | |
} | |
add_action('wp_head', 'hook_css'); |
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
/* Add code to WP Head */ | |
function hook_javascript() { | |
?> | |
<script> | |
alert('Page is loading...'); | |
</script> | |
<?php | |
} | |
add_action('wp_head', 'hook_javascript'); |
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
/** | |
* Custom Image Size for blog. | |
*/ | |
add_image_size( 'home-blog', 1000, 536, true ); // 1000 pixels wide by 536 pixels tall, hard crop mode |
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
function cf7_add_post_id(){ | |
global $post; | |
return $post->ID; | |
} | |
add_shortcode('CF7_ADD_POST_ID', 'cf7_add_post_id'); |