wp_count_posts on all post types?

To get the custom post types you would call the get_post_types function.The built-in public post types are post, page, and attachment. By setting ‘_builtin’ to false, we will exclude them and show only the custom public post types. Below is the code. <?php $args = array( ‘public’ => true, ‘_builtin’ => false ); $output=”names”; // … Read more

Use WP_Theme::scandir function to scan a plugin directory. Is there a way?

You can use PHP5 RecursiveDirectoryIterator with RecursiveIteratorIterator $directory = ‘/project_root/wp-content/plugins/your-plugin’; //Your plugin dir $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); while ($it->valid()) { //Check the file exist if (!$it->isDot()) { //if not parent “..” or current “.” if (strpos($it->key(), ‘.php’) !== false || strpos($it->key(), ‘.css’) !== false || strpos($it->key(), ‘.js’) !== false ) { //Do your stuff … Read more

Get the password key when using the wp_new_user_notification_email filter

I found a function to retrieve this key : get_password_reset_key(). So now I have this code in my plugin to customize the email sent to newly registered users: add_filter(‘wp_new_user_notification_email’, ‘change_notification_message’, 10, 3); function change_notification_message( $wp_new_user_notification_email, $user, $blogname ) { // Generate a new key $key = get_password_reset_key( $user ); // Set the subject $wp_new_user_notification_email[‘subject’] = … Read more