add_action(
'admin_head',
function() {
remove_action( 'admin_notices', 'update_nag', 3 );
}
);
turn off admin email check
// turn off admin email check
add_filter( 'admin_email_check_interval', '__return_false' );
change recovery mode email address
// change recovery mode email address.
add_filter( 'recovery_mode_email', function( $email_data ) {
$email_data['to'] = 'your_email@yoursite.com';
return $email_data;
});
Stop WordPress from wrapping images in paragraph tags
// Stop WordPress from wrapping images in paragraph tags.
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
first image as featured image if unset
// first image as featured image if unset
function auto_featured_image() {
global $post;
if (!has_post_thumbnail($post->ID)) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}
}
}
}
// Use it temporary to generate all featured images
add_action('the_post', 'auto_featured_image');
// Used for new posts
add_action('save_post', 'auto_featured_image');
add_action('draft_to_publish', 'auto_featured_image');
add_action('new_to_publish', 'auto_featured_image');
add_action('pending_to_publish', 'auto_featured_image');
add_action('future_to_publish', 'auto_featured_image');
enqueue font awesome
/**
* Enqueue Font Awesome.
*/
add_action( 'wp_enqueue_scripts', 'tu_load_font_awesome' );
function tu_load_font_awesome() {
wp_enqueue_style( 'font-awesome', '//use.fontawesome.com/releases/v5.5.0/css/all.css', array(), '5.5.0' );
}
enqueue google fonts
/**
* Add Google Fonts to Generate Press
*/
add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
function tu_add_google_fonts( $fonts ) {
$fonts[ 'Livvic' ] = array(
'name' => 'Livvic',
'variants' => array( '100', '100i', '200', '200i','300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i' ),
'category' => 'sans-serif'
);
$fonts[ 'Barlow Condensed' ] = array(
'name' => 'Barlow Condensed',
'variants' => array( '100', '100i', '200', '200i','300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i' ),
'category' => 'sans-serif'
);
$fonts[ 'Barlow Semi Condensed' ] = array(
'name' => 'Barlow Semi Condensed',
'variants' => array( '100', '100i', '200', '200i','300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i' ),
'category' => 'sans-serif'
);
return $fonts;
}
google analytics
// Include the Google Analytics Tracking Code (ga.js)
// @ https://developers.google.com/analytics/devguides/collection/gajs/
function google_analytics_tracking_code(){
$propertyID = 'UA-XXXXXX-1'; // GA Property ID ADD THIS FOR EVERY SITE
if ($options['ga_enable']) { ?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<?php echo $propertyID; ?>']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php }
}
// include GA tracking code before the closing head tag
//add_action('wp_head', 'google_analytics_tracking_code');
// OR include GA tracking code before the closing body tag
add_action('wp_footer', 'google_analytics_tracking_code');
change admin email from name
// change email sender name for admin posts
function ec_mail_name( $email ){
return 'form robot fontaholic.biz'; // new email name from sender.
}
add_filter( 'wp_mail_from_name', 'ec_mail_name' );
enqueue parent styles
// enqueue parent styles
wp_enqueue_style('parent-theme', get_template_directory_uri() .'/style.css');
}
add_action('wp_enqueue_scripts', 'example_enqueue_styles');