Skip to content

Commit

Permalink
Updates to 6.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Woo committed Sep 6, 2024
1 parent 128d38e commit 9b48a49
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 201 deletions.
15 changes: 0 additions & 15 deletions admin/WCAdminConnectPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@ class WCAdminConnectPages {
*/
const BREADCRUMB_ROOT = 'automatewoo-dashboard';

/**
* Display the page in WooCommerce Admin nav menu, and show WooCommerce Admin bar, breadcrumbs, etc. on the page
*/
const PAGE_DISPLAY_FULL = 'full';

/**
* Hide the page in WC admin nav menu but still show WooCommerce Admin bar, breadcrumbs, etc. on the page
*/
const PAGE_DISPLAY_HIDDEN = 'hidden';

/**
* Hide the page in WC admin nav menu and do not display WooCommerce Admin bar, breadcrumbs, etc. on the page
*/
const PAGE_DISPLAY_STANDALONE = 'standalone';

/**
* Initialize the class and add hook callbacks.
*/
Expand Down
91 changes: 6 additions & 85 deletions admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use AutomateWoo\Admin\AssetData;
use AutomateWoo\Admin\WCAdminConnectPages;
use AutomateWoo\HPOS_Helper;
use Automattic\WooCommerce\Admin\Features\Navigation\Menu;
use Automattic\WooCommerce\Admin\Features\Navigation\Screen;
use Automattic\WooCommerce\Admin\PageController;
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;
use Automattic\WooCommerce\Blocks\Package as BlocksPackage;
Expand Down Expand Up @@ -139,10 +137,9 @@ public static function handle_save_screen_option( $keep, $option, $value ) {
* Add menu entries.
*/
public static function admin_menu() {
$sub_menu = [];
$position = '55.6324'; // fix for rare position clash bug
$workflows_group = 'automatewoo-workflows-group';
$icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8v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g9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgNTEyIDUxMiIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PGc+PHBvbHlnb24gZmlsbD0iIzlFQTNBOCIgcG9pbnRzPSIxMTcuNiwyNzIuNyAxNjYuOSwyNzIuNyAxNDIuMywyMDUuNCAiLz48cGF0aCBmaWxsPSIjOUVBM0E4IiBkPSJNNDY0LDU0LjRINDhDMjUuMSw1NC40LDYuNCw3My4xLDYuNCw5NnYzMjBjMCwyMi45LDE4LjcsNDEuNiw0MS42LDQxLjZoNDE2YzIyLjksMCw0MS42LTE4LjcsNDEuNi00MS42Vjk2QzUwNS42LDczLjEsNDg2LjksNTQuNCw0NjQsNTQuNHogTTE5My4zLDM0NS4xbC0xNC45LTQwLjdIMTA2bC0xNC44LDQwLjdINTQuNkwxMjMsMTY2LjloNDAuMkwyMzEsMzQ1LjFIMTkzLjN6IE00MDguMSwzNDUuMWgtMzUuN2wtNDAuNy0xMjYuOUwyOTEsMzQ1LjFoLTM2LjJsLTQ5LjUtMTc4LjJIMjQybDMyLjcsMTIyLjZsMzkuNS0xMjIuNmgzNS45TDM4OS45LDI5MEw0MjIsMTY2LjloMzUuNEw0MDguMSwzNDUuMXoiLz48L2c+PC9zdmc+';

add_menu_page(
__( 'AutomateWoo', 'automatewoo' ),
Expand All @@ -154,123 +151,67 @@ public static function admin_menu() {
$position
);

if ( class_exists( Menu::class ) ) {
Menu::add_plugin_category(
array(
'id' => 'automatewoo',
'title' => __( 'AutomateWoo', 'automatewoo' ),
'capability' => 'manage_woocommerce',
'url' => 'automatewoo',
)
);
Menu::add_plugin_category(
[
'id' => $workflows_group,
'title' => __( 'Workflows', 'automatewoo' ),
'capability' => 'manage_woocommerce',
'url' => $workflows_group,
'parent' => 'automatewoo',
'order' => 1,
]
);
}

$sub_menu['dashboard'] = [
'title' => __( 'Dashboard', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'order' => 0,
];

// Workflows menu group
$sub_menu['workflows'] = [
'title' => __( 'Workflows', 'automatewoo' ),
'slug' => 'edit.php?post_type=aw_workflow',
// Hide in new nav and use `\Automattic\WooCommerce\Admin\Features\Navigation\Menu::get_post_type_items` instead
'display' => WCAdminConnectPages::PAGE_DISPLAY_HIDDEN,
'title' => __( 'Workflows', 'automatewoo' ),
'slug' => 'edit.php?post_type=aw_workflow',
];

if ( class_exists( Screen::class ) ) {
$menu_post_type_items = Menu::get_post_type_items(
'aw_workflow',
[
'title' => __( 'Workflows', 'automatewoo' ),
'parent' => $workflows_group,
'order' => 0,
]
);

if ( isset( $menu_post_type_items['all'] ) ) {
Menu::add_plugin_item( $menu_post_type_items['all'] );
}
if ( isset( $menu_post_type_items['new'] ) ) {
$menu_post_type_items['new']['title'] = __( 'Add workflow', 'automatewoo' );
$menu_post_type_items['new']['order'] = 1;
Menu::add_plugin_item( $menu_post_type_items['new'] );
}
}

$sub_menu['logs'] = [
'title' => __( 'Logs', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'parent' => $workflows_group,
'order' => 2,
];
$sub_menu['queue'] = [
'title' => __( 'Queue', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'parent' => $workflows_group,
'order' => 3,
];

if ( Options::abandoned_cart_enabled() ) {
$sub_menu['carts'] = [
'title' => __( 'Carts', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'order' => 2,
];
}

$sub_menu['guests'] = [
'title' => __( 'Guests', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'order' => 3,
];

$sub_menu['opt-ins'] = [
'title' => Options::optin_enabled() ? __( 'Opt-ins', 'automatewoo' ) : __( 'Opt-outs', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'order' => 4,
];

$sub_menu['reports'] = [
'title' => __( 'Reports', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'order' => 5,
'enabled' => ! HPOS_Helper::is_HPOS_enabled(),
];

$sub_menu['tools'] = [
'title' => __( 'Tools', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'order' => 6,
];

$sub_menu['settings'] = [
'title' => __( 'Settings', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'order' => 7,
];

$sub_menu['preview'] = [
'title' => __( 'Preview', 'automatewoo' ),
'function' => [ __CLASS__, 'load_controller' ],
'display' => WCAdminConnectPages::PAGE_DISPLAY_STANDALONE,
];

$sub_menu['data-upgrade'] = [
'title' => __( 'AutomateWoo Data Update', 'automatewoo' ),
'function' => [ __CLASS__, 'page_data_upgrade' ],
'display' => WCAdminConnectPages::PAGE_DISPLAY_HIDDEN,
];

foreach ( $sub_menu as $key => $item ) {
Expand All @@ -286,31 +227,11 @@ public static function admin_menu() {
if ( empty( $item['page_title'] ) ) {
$item['page_title'] = $item['title'];
}
if ( ! isset( $item['parent'] ) ) {
$item['parent'] = 'automatewoo';
}

$is_enabled = $item['enabled'] ?? true;

add_submenu_page( $is_enabled ? 'automatewoo' : 'automatewoo_disabled', $item['page_title'], $item['title'], $item['capability'], $item['slug'], $item['function'] );

if ( class_exists( Menu::class ) ) {
if ( ! isset( $item['display'] ) || WCAdminConnectPages::PAGE_DISPLAY_FULL === $item['display'] ) {
Menu::add_plugin_item(
array(
'id' => 'automatewoo-' . $key,
'parent' => $item['parent'],
'title' => $item['title'],
'capability' => $item['capability'],
'url' => $item['slug'],
'order' => isset( $item['order'] ) ? $item['order'] : 99,
)
);
} elseif ( WCAdminConnectPages::PAGE_DISPLAY_HIDDEN === $item['display'] ) {
Screen::add_screen( $item['slug'] );
}
}

if ( $key === 'workflows' ) {
do_action( 'automatewoo/admin/submenu_pages', 'automatewoo' );
}
Expand All @@ -333,7 +254,7 @@ public static function admin_menu() {
* This is because we need to add .hide-if-js classname in the submenu for hide them in Calypso for wp.com
* The classes are usually loaded in position 4 in the submenu.
*
* @see Menu::migrate_menu_items for a reference of how WC Admin loads this class.
* @see Menu::migrate_menu_items for a reference of how WC Admin loads this class. (https://github.com/woocommerce/woocommerce/blob/47e4d918c91ea980c41f4567e823256acbac4317/plugins/woocommerce/src/Admin/Features/Navigation/Menu.php#L636)
* @param array $menu Menu items
* @return array Menu items
*/
Expand Down
6 changes: 3 additions & 3 deletions automatewoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: AutomateWoo
* Plugin URI: https://automatewoo.com
* Description: Powerful marketing automation for your WooCommerce store.
* Version: 6.0.33
* Version: 6.1.0
* Author: WooCommerce
* Author URI: https://woocommerce.com
* License: GPLv3
Expand All @@ -13,7 +13,7 @@
* Tested up to: 6.6
* Requires Plugins: woocommerce
* WC requires at least: 7.9
* WC tested up to: 9.2.0
* WC tested up to: 9.3.0
* Woo: 4652610:f6f1f8a56a16a3715b30b21fb557e78f
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -37,7 +37,7 @@
defined( 'ABSPATH' ) || exit;

define( 'AUTOMATEWOO_SLUG', 'automatewoo' );
define( 'AUTOMATEWOO_VERSION', '6.0.33' ); // WRCS: DEFINED_VERSION.
define( 'AUTOMATEWOO_VERSION', '6.1.0' ); // WRCS: DEFINED_VERSION.
define( 'AUTOMATEWOO_FILE', __FILE__ );
define( 'AUTOMATEWOO_PATH', __DIR__ );
define( 'AUTOMATEWOO_MIN_PHP_VER', '7.4.0' );
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*** AutomateWoo Changelog ***

2024-09-05 - version 6.1.0
* Break - Remove WooCommerce Navigation integration.
* Tweak - WC 9.3.0 compatibility.

2024-08-28 - version 6.0.33
* Bump min WC version to 7.9, reuse upstreamed classes.

Expand Down
5 changes: 0 additions & 5 deletions includes/Post_Types.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace AutomateWoo;

use Automattic\WooCommerce\Admin\Features\Features as WCAdminFeatures;
use Automattic\WooCommerce\Admin\Features\Navigation\Screen;

/**
* @class Post_Types
Expand Down Expand Up @@ -59,10 +58,6 @@ static function register_post_types() {
)
);

if ( class_exists( Screen::class ) ) {
Screen::register_post_type( 'aw_workflow' );
}

do_action('automatewoo_after_register_post_types');
}

Expand Down
Loading

0 comments on commit 9b48a49

Please sign in to comment.