Exclude Everywhere but Admin Area?

Note that there’s no is_admin() method for the WP_Query class. But the interesting part is that PHP will not complain about this: $query->is_admin() where $query is an instance of WP_Query. It will just always return false. This is the reason why (#src): /** * Make private/protected methods readable for backwards compatibility. * * @since 4.0.0 … Read more

Query comments with non-empty ‘author_url’ value on Admin Comments Screen

We can set the author_url argument of WP_Comment_Query as null (empty string will not work) to search for comments that don’t have an author url. Currently (ver 4.8.1) the has_author_url isn’t supported. Using a sub-query to exclude those comments, with no author_url, using comment__not_in, should work, but wouldn’t probably scale well. Setting fields as ids … Read more

Mixed language in admin backend

Ok I resolved the problem. It turns out I have mistakenly copied the .po files (fr_FR) of my theme into the /language folder and not /language/themes, so WordPress was picking the .po of my theme and not the one from wordpress. I moved the po file to the themes folder and hit refresh on my … Read more

Allow direct access to files/folders within WordPress to replace wp-admin

Since you asked for recommended approaches… Why code your own custom dashboard? What is WordPress not doing that yours would? WordPress is 15 years old with contributions from hundreds of developers. Are you sure that your dashboard is going to be better, and worth your time (or your clients’ time) to code? I don’t mean … Read more

How to enforce authentication for all resources?

You should define which resources you want to protect. I think you have such choices: 1) Protect whole site 2) Protect only posts (without resources) 3) Protect posts & all resources (but only uploads, not wp-content! otherwise you will break your themes/plugins) So, as you say you need 3rd way. In such case, you should … Read more

Add custom css class to wp-list-table row for custom post type

Finally got a solution. Founded in WordPress Documentation add_filter(‘post_class’, ‘set_row_post_class’, 10,3); function set_row_post_class($classes, $class, $post_id){ if (!is_admin()) { //make sure we are in the dashboard return $classes; } $screen = get_current_screen(); //verify which page we’re on if (‘my-custom-type’ != $screen->post_type && ‘edit’ != $screen->base) { return $classes; } //check if some meta field is set … Read more