PHP Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered

Before you can use, those two lines : wp_enqueue_style( ‘wp-auth-check’ ); wp_enqueue_script( ‘wp-auth-check’ ); you should register those assets, inside wp_enqueue_scripts or admin_enqueue_scripts, like the following : function my_assets() { wp_register_style( ‘wp-auth-check’, ‘path/to/style’, $deps = array, $ver = false, $media=”all” ) wp_register_script( ‘wp-auth-check’, ‘path/to/your-script’, $deps = array, $ver = false, $in_footer = false ) } … Read more

How To Apply Different Styles To All Blocks Based on Post Meta Value?

I was able to solve this problem by using the admin_body_class filter to add a class name to the <body> element of the admin page, and writing selectors for that class in my stylesheet. add_filter( ‘admin_body_class’, ‘add_status_classes’ ); function add_status_classes( $classes ) { $post_meta = get_post_meta( get_the_ID() ); $is_darkmode = $post_meta[‘_is_post_dark_mode’]; if ( $is_darkmode ) … Read more

How to change Akismet commenter privacy notice?

Aha, I finally got it working: <?php /* Plugin Name: Akismet Better Privacy Notice Description: Inform users about what’s actually happening with their data */ add_filter ( ‘akismet_comment_form_privacy_notice_markup’, ‘better_display_comment_form_privacy_notice’ ); function better_display_comment_form_privacy_notice() { echo sprintf( ‘<p class=”akismet_comment_form_privacy_notice”>’ . ‘Warning: This site uses Akismet to filter spam.’ . ‘ Until or unless I can find a … Read more

Change Title Type

as this is a default field, i don’t think it is possible to achieve what you want with the help function hooks, however you can do this by editing edit-form-advanced.php file inside wp-admin folder, the code you may want to edit is located in line # 291, this is the input type for title field … Read more

Fire a hook programmatically

To fire a hook you can use following functions: do_action – executes a hook created by add_action. do_action_ref_array – execute functions hooked on a specific action hook, specifying arguments in an array. This function is identical to do_action, but the arguments passed to the functions hooked to $tag are supplied using an array. If you … Read more

Redirect back to origin page after using get_delete_post_link()

Theres a filter you can hook on to. apply_filters( ‘get_delete_post_link’, wp_nonce_url( $delete_link, “$action-{$post->post_type}_{$post->ID}” ), $post->ID, $force_delete ); Check the raw function here: http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/link-template.php#L954 Can’t advise much else without seeing your code. Edit: its nasty buy you can do add_filter( ‘get_delete_post_link’, ‘some_function’, 20 ); function some_function() { wp_redirect( home_url(“https://wordpress.stackexchange.com/”) ); exit; }

Query author’s posts & posts that have author’s id as meta value

Instead of a new WP_Query, use the pre_get_posts filter add_filter(‘pre_get_posts’, ‘custom_query’); function custom_query($query) { if($query->is_main_query() && $query->is_author() && $_GET[‘eco’]==’somemetakey’) { $query->set(‘meta_query’, array( array( ‘key’ => ‘somemetakey’, ‘value’ => $query->get(‘author’) ) )); } }