autoship_create_menu()

(src/admin.php) Adds the main Autoship Cloud Options page & adds the subpages to WP-Admin. These include the Native Wordpress  Autoship > Settings pages and the following embedded QPilot pages:

  • Products
  • Customers
  • Scheduled Orders
  • Coupons 
  • Shipping Rates 
  • Tax Rates 
  • Payment Integrations 
  • Reports

Function:

function autoship_create_menu() {

  $menu_options = apply_filters(
    'autoship_admin_settings_submenu_pages',
    array(
    'autoship' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Settings', 'autoship' ),
      'menu_title'  => __( 'Settings', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'autoship',
      'function'    => ''
    ),
    'dashboard' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Dashboard', 'autoship' ),
      'menu_title'  => __( 'Dashboard', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'dashboard',
      'function'    => 'autoship_dashboard_page'
    ),
    'products' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Products', 'autoship' ),
      'menu_title'  => __( 'Products', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'products',
      'function'    => 'autoship_products_page'
    ),
    'customers' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Customers', 'autoship' ),
      'menu_title'  => __( 'Customers', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'customers',
      'function'    => 'autoship_customers_page'
    ),
    'scheduled-orders' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Scheduled Orders', 'autoship' ),
      'menu_title'  => __( 'Scheduled Orders', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'scheduled-orders',
      'function'    => 'autoship_scheduled_orders_page'
    ),
    'coupons' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Coupons', 'autoship' ),
      'menu_title'  => __( 'Coupons', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'coupons',
      'function'    => 'autoship_coupons_page'
    ),
    'shipping-rates' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Shipping Rates', 'autoship' ),
      'menu_title'  => __( 'Shipping Rates', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'shipping-rates',
      'function'    => 'autoship_shipping_rates_page'
    ),
    'tax-rates' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Tax Rates', 'autoship' ),
      'menu_title'  => __( 'Tax Rates', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'tax-rates',
      'function'    => 'autoship_tax_rates_page'
    ),
    'payment-integrations' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Payment Integrations', 'autoship' ),
      'menu_title'  => __( 'Payment Integrations', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'payment-integrations',
      'function'    => 'autoship_payment_integrations_page'
    ),
    'reports' => array(
      'parent_slug' => 'autoship',
      'page_title'  => __( 'Reports', 'autoship' ),
      'menu_title'  => __( 'Reports', 'autoship' ),
      'capability'  => 'administrator',
      'menu_slug'   => 'reports',
      'function'    => 'autoship_reports_page'
    ))
  );

  //create new top-level menu
  add_menu_page(
    __( 'Autoship Cloud', 'autoship' ),
    __( 'Autoship Cloud', 'autoship' ),
    apply_filters('autoship_cloud_main_page_security','administrator'),
    'autoship',
    'autoship_settings_page',
    'dashicons-cloud'
  );

  // Setup Sub Menus to the Autoship Main Setting
  foreach ($menu_options as $submenu) {

    add_submenu_page(
    $submenu['parent_slug'],
    $submenu['page_title'],
    $submenu['menu_title'],
    apply_filters( 'autoship_cloud_subpage_security', $submenu['capability'], $submenu['menu_slug'] ),
    $submenu['menu_slug'],
    $submenu['function'] );

  }

  //call register settings function
  add_action( 'admin_init', 'register_autoship_settings' );
}