chrisblakley / Nebula

Nebula is a WordPress theme framework that focuses on enhancing development. The core features of Nebula make it a powerful tool for designing, developing, and analyzing WordPress websites consistently, yet its deliberately uncomplicated code syntax also serves as a learning resource for programmers themselves.
https://nebula.gearside.com
GNU General Public License v3.0
144 stars 36 forks source link

Find a way to show the "Submission" status of the CF7 Submissions submenu by default (instead of "All") #2281

Open chrisblakley opened 8 months ago

chrisblakley commented 8 months ago

I want to find a way to make this the default when viewing CF7 form submissions:

Screenshot 2024-03-26 at 9 08 57 PM

This code works to modify the submenu slug to link to the Submissions status:

add_action('admin_menu', function(){
  global $submenu;
  if ( isset($submenu) && !empty($submenu) ){ //Check if $submenu is set and not empty
      foreach ( $submenu as $parent_slug => &$submenus ){ //Loop through each top-level menu item by reference
          if ( is_array($submenus) && !empty($submenus) ){ //Check if there are submenus for the current top-level menu item
              foreach ($submenus as &$submenu_item){ //Loop through each submenu item by reference
                  if ( $submenu_item[2] == 'edit.php?post_type=nebula_cf7_submits' ){
                      $submenu_item[2] = 'edit.php?post_status=submission&post_type=nebula_cf7_submits'; //Modify the reference to it updates globally
                  }
              }
          }
      }
  }
});

However, the Contact Form 7 parent menu does not stay open when this is modified this way and I can't find a way to keep it open...

JavaScript is not an acceptable solution to this.

If I find a way to do that, I would then modify the custom post statuses of "Invalid" and "Spam" to allow them to appear in the "All" list (via /libs/Functions.php).