This is a list of useful WordPress functions that I often reference to enhance or clean up my sites. Please be careful and make backups.
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 | |
// have to add that opening tag to get syntax highlighting... ¯\_(ツ)_/¯ | |
/** | |
* Prevent update notification for plugin | |
* http://www.thecreativedev.com/disable-updates-for-specific-plugin-in-wordpress/ | |
* Place in theme functions.php or at bottom of wp-config.php | |
*/ | |
function disable_plugin_updates( $value ) { |
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 | |
/* | |
Localizations: | |
- [Spanish](https://gist.github.com/MatthewEppelsheimer/1498955#gistcomment-3317461) props @chdgp | |
UPDATED: 2020-03-09 |
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( 'script_loader_tag', 'cameronjonesweb_add_script_handle', 10, 3 ); | |
function cameronjonesweb_add_script_handle( $tag, $handle, $src ) { | |
return str_replace( '<script', sprintf( | |
'<script data-handle="%1$s"', | |
esc_attr( $handle ) | |
), $tag ); | |
} |
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( 'script_loader_tag', 'wsds_defer_scripts', 10, 3 ); | |
function wsds_defer_scripts( $tag, $handle, $src ) { | |
// The handles of the enqueued scripts we want to defer | |
$defer_scripts = array( | |
'prismjs', | |
'admin-bar', | |
'et_monarch-ouibounce', | |
'et_monarch-custom-js', |
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 | |
/** | |
* Exclude body_class for front page - Remove CSS class : page | |
*/ | |
function mp_remove_body_classes($classes, $class){ | |
foreach($classes as &$str){ | |
if(strpos($str, "page") > -1 && is_front_page()){ | |
$str = ""; | |
} |
Getting Jekyll installed on Windows can be more complicated than on, say, OSX and Ubuntu, but not by much. This outlines the steps I use.
I have similar guidance (plus extra steps for my publishing tools) for OSX written up here.
Because each of the pieces that make Jekyll work is fussy, especially on Windows, which the developers of those pieces rarely use.
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
//Default WordPress | |
the_post_thumbnail( 'thumbnail' ); // Thumbnail (150 x 150 hard cropped) | |
the_post_thumbnail( 'medium' ); // Medium resolution (300 x 300 max height 300px) | |
the_post_thumbnail( 'medium_large' ); // Medium Large (added in WP 4.4) resolution (768 x 0 infinite height) | |
the_post_thumbnail( 'large' ); // Large resolution (1024 x 1024 max height 1024px) | |
the_post_thumbnail( 'full' ); // Full resolution (original size uploaded) | |
//With WooCommerce | |
the_post_thumbnail( 'shop_thumbnail' ); // Shop thumbnail (180 x 180 hard cropped) | |
the_post_thumbnail( 'shop_catalog' ); // Shop catalog (300 x 300 hard cropped) |
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 | |
/* vars for export */ | |
// database record to be exported | |
$db_record = 'XXX_TABLE_NAME_XXX'; | |
// optional where query | |
$where = 'WHERE 1 ORDER BY 1'; | |
// filename for export | |
$csv_filename = 'db_export_'.$db_record.'_'.date('Y-m-d').'.csv'; | |
// database variables |