deactivated_plugin hook: get the name of the plugin

You can hook into the action ‘deactivate_plugin’ to get the plugin’s base name and (as second parameter) if it was deactivated network wide. See wp-admin/includes/plugin.php function deactivate_plugins(). There seems to be no hook for plugin deletion. Sample logging code: add_action( ‘activated_plugin’, ‘t5_plugin_logger’, 10, 2 ); add_action( ‘deactivated_plugin’, ‘t5_plugin_logger’, 10, 2 ); /** * Log plugin … Read more

Disallow a user to post in certain categories

save_post is too late. Look at the source and you can see that the post has already been saved when that hook fires. You will have to interrupt the process well before that hook if you want to prevent saving. I think I would lean toward something like this: add_filter( ‘post_updated_messages’, function($messages) { $messages[‘post’][11] = … Read more

Send an email when custom post type category is changed

Use the hooks added_term_relationship and deleted_term_relationships. These only fire when the relationship changes, as opposed to set_object_terms which always fires: function wpse_181090_object_terms_updated( $object_id ) { static $did = array(); // This function might fire multiple times for the same object, ensure it only runs once if ( ! isset( $did[ $object_id ] ) ) { … Read more

How can I hook into the post editor title field in order to change the HTML?

There is no hook to change the HTML of the input (only the enter_title_here filter to change the placeholder text). You could pull this off easily with jQuery, though. Try this in your functionality plugin or theme’s functions.php file: // Add to the new post screen for any post type add_action( ‘admin_footer-post-new.php’, ‘wpse_add_required_attr_to_title_field’ ); // … Read more

How can I hide all posts that don’t have a thumbnail?

What filter / hook should I use? You can use the pre_get_posts action hook. Following Tom’s comment on the question about querying for what you want, maybe set meta_query to _thumbnail_id. I would also ( group ) the conditionals to read: “Is both not admin and is main query, AND is either home, category, or … Read more

How to limit the pages displayed for choosing parent page on page attribute’s menu?

This meta box is printed with page_attributes_meta_box and the select field for choosing parent is generated with this code: if ( is_post_type_hierarchical( $post->post_type ) ) : $dropdown_args = array( ‘post_type’ => $post->post_type, ‘exclude_tree’ => $post->ID, ‘selected’ => $post->post_parent, ‘name’ => ‘parent_id’, ‘show_option_none’ => __(‘(no parent)’), ‘sort_column’ => ‘menu_order, post_title’, ‘echo’ => 0, ); $dropdown_args = … Read more

Restrict access to admin but allow admin_post hook

All you need to do is to modify your method of restricting users. add_action( ‘admin_init’, function() { if ( (defined(‘DOING_AJAX’) && DOING_AJAX) || ( strpos($_SERVER[‘SCRIPT_NAME’], ‘admin-post.php’) ) ) { return; } if ( !current_user_can(‘manage_options’) ) { wp_redirect( home_url(‘/meu-perfil’) ); exit(); } }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)