“Warning: count()” error on php 7.2

Yes, I already knew the cause of what you’re experiencing: The $page and $pages global variable have not been set up and a call to get_the_content or get_the_excerpt would return that error: count(pages) That said, pages global variable is set to null, calling count(pages) triggers that error because a null value cannot be counted. To … Read more

How to set custom cookies before output

Depends on whether or not you need to check against WordPress’ user authentication. If you need to know whether they’re a logged in user, hook onto ‘init’. Otherwise, the sooner the better. If it’s something that should fire on every page load, and only checks for existence of the cookie and doesn’t need to tap … Read more

How do I override the Message-ID header of wp_mail function?

You can filter the $phpmailer object. Something like this should do the trick (not tested): add_action( ‘phpmailer_init’, ‘wpse_52555_msg_id’ ); function wpse_52555_msg_id( &$phpmailer ) { $msg_id = get_post_meta( get_the_ID(), ‘messageID’, TRUE ); ” !== $msg_id and $phpmailer->MessageID = $msg_id . ‘@test.com’; }

Set media upload attachment link to none and hide it in WP v3.5

Include this small plugin, activate and test. A tested version in 3.6-alpha, works only on click on a thumbnail. <?php /** * Plugin Name: Remove Attachment Link-To and set to value ‘none’ */ add_action( ‘admin_footer-post-new.php’, ‘wpse_76214_script’ ); add_action( ‘admin_footer-post.php’, ‘wpse_76214_script’ ); function wpse_76214_script() { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { $( ‘li.attachment’ ).live( ‘click’, function( … Read more

wp_delete_auto_drafts() deletes links in menus

This is what normal query run by wp_get_associated_nav_menu_items() looks like: SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id ) WHERE 1 = 1 AND wp_posts.post_type=”nav_menu_item” AND (( wp_posts.post_status <> ‘trash’ AND wp_posts.post_status <> ‘auto-draft’ )) AND (( wp_postmeta.meta_key = ‘_menu_item_object_id’ AND Cast(wp_postmeta.meta_value AS CHAR) = ‘3111’ )) GROUP BY wp_posts.id ORDER … Read more

Genesis – Customize search form

I’m not sure why you’re getting a 500 error. Likely because you’re trying to use a function before it’s been defined. But I think you’re going about the problem the wrong way. Genesis does provide a filter before returning the search form. Why not just add a filter to the genesis_search_form hook? You can add … Read more

add_filter the_content str_replace after shortcode

You can change the priority of actions and filters, it’s the third argument of add_filter (and add_action) and it defaults to 10. So change it to a high number and have your filter fire way after the shortcodes and other stuff are inserted. <?php add_filter(‘the_content’, ‘disable_autocomplete’, 99); function disable_autocomplete( $content ) { return str_replace(‘<form’, ‘<form … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş