-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
179 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* WP Admin Menu Class. | ||
* | ||
* @author Paul Kilmurray <[email protected]> | ||
* | ||
* @see http://wcpos.com | ||
* @package WCPOS\WooCommercePOS | ||
*/ | ||
|
||
namespace WCPOS\WooCommercePOS\Admin; | ||
|
||
use const HOUR_IN_SECONDS; | ||
use const WCPOS\WooCommercePOS\PLUGIN_NAME; | ||
|
||
/** | ||
* | ||
*/ | ||
class Menu { | ||
/** | ||
* @vars string Unique top level menu identifier | ||
* Unique top level menu identifier. | ||
* | ||
* @var string | ||
*/ | ||
public $toplevel_screen_id; | ||
|
||
/** | ||
* @vars string Unique top level menu identifier | ||
* Unique top level menu identifier. | ||
* | ||
* @var string | ||
*/ | ||
public $settings_screen_id; | ||
|
||
|
@@ -34,7 +41,7 @@ public function __construct() { | |
add_filter( 'menu_order', array( $this, 'menu_order' ), 9, 1 ); | ||
} | ||
|
||
// add_filter( 'woocommerce_analytics_report_menu_items', array( $this, 'analytics_menu_items' ) ); | ||
// add_filter( 'woocommerce_analytics_report_menu_items', array( $this, 'analytics_menu_items' ) ); | ||
} | ||
|
||
/** | ||
|
@@ -56,7 +63,7 @@ public function menu_order( array $menu_order ): array { | |
if ( false !== $woo && false !== $pos ) { | ||
// rearrange menu | ||
unset( $menu_order[ $pos ] ); | ||
array_splice( $menu_order, ++ $woo, 0, PLUGIN_NAME ); | ||
array_splice( $menu_order, ++$woo, 0, PLUGIN_NAME ); | ||
|
||
// rearrange submenu | ||
global $submenu; | ||
|
@@ -98,22 +105,27 @@ public function display_upgrade_page(): void { | |
* Add POS submenu to WooCommerce Analytics menu. | ||
*/ | ||
public function analytics_menu_items( array $report_pages ): array { | ||
// Find the position of the 'Orders' item | ||
// Find the position of the 'Orders' item. | ||
$position = array_search( 'Orders', array_column( $report_pages, 'title' ), true ); | ||
|
||
// Use array_splice to add the new item | ||
array_splice($report_pages, $position + 1, 0, array( | ||
// Use array_splice to add the new item. | ||
array_splice( | ||
$report_pages, | ||
$position + 1, | ||
0, | ||
array( | ||
'id' => 'woocommerce-analytics-pos', | ||
'title' => __( 'POS', 'woocommerce-pos' ), | ||
'parent' => 'woocommerce-analytics', | ||
'path' => '/analytics/pos', | ||
'nav_args' => array( | ||
'order' => 45, | ||
'parent' => 'woocommerce-analytics', | ||
array( | ||
'id' => 'woocommerce-analytics-pos', | ||
'title' => __( 'POS', 'woocommerce-pos' ), | ||
'parent' => 'woocommerce-analytics', | ||
'path' => '/analytics/pos', | ||
'nav_args' => array( | ||
'order' => 45, | ||
'parent' => 'woocommerce-analytics', | ||
), | ||
), | ||
), | ||
)); | ||
) | ||
); | ||
|
||
return $report_pages; | ||
} | ||
|
@@ -172,9 +184,12 @@ private function register_pos_admin(): void { | |
* @type string $settings The settings submenu ID. | ||
* } | ||
*/ | ||
do_action( 'woocommerce_pos_register_pos_admin', array( | ||
'toplevel' => $this->toplevel_screen_id, | ||
'settings' => $this->settings_screen_id, | ||
) ); | ||
do_action( | ||
'woocommerce_pos_register_pos_admin', | ||
array( | ||
'toplevel' => $this->toplevel_screen_id, | ||
'settings' => $this->settings_screen_id, | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ | |
use WP_REST_Request; | ||
use WP_REST_Server; | ||
|
||
/** | ||
* | ||
*/ | ||
class Init { | ||
/** | ||
* Constructor. | ||
|
Oops, something went wrong.