Merge pull request #29 from kristianwind/menu-assert-and-bump
Assert the page really lands under the Nolimit menu, and bump to 1.5.0
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ Tags: woocommerce, discount, email, shipping, coupon
|
|||||||
Requires at least: 5.8
|
Requires at least: 5.8
|
||||||
Tested up to: 7.1
|
Tested up to: 7.1
|
||||||
Requires PHP: 7.4
|
Requires PHP: 7.4
|
||||||
Stable tag: 1.4.6
|
Stable tag: 1.5.0
|
||||||
WC requires at least: 6.0
|
WC requires at least: 6.0
|
||||||
WC tested up to: 11.1.0
|
WC tested up to: 11.1.0
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
|
|||||||
@@ -238,6 +238,55 @@ wc_edm_is(
|
|||||||
apply_filters( 'wpmgr_menu_title', 'Manager' )
|
apply_filters( 'wpmgr_menu_title', 'Manager' )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// The filter above proves this plugin CLAIMS the label. It does not prove the
|
||||||
|
// page is registered under that parent, and those are different failures: the
|
||||||
|
// menu said Nolimit while this plugin was still absent from it.
|
||||||
|
//
|
||||||
|
// Loaded and invoked by hand because the admin menu is only built in an admin
|
||||||
|
// request and these run under WP-CLI, where is_admin() is false and
|
||||||
|
// class-admin.php is therefore never included. That makes this a reduced
|
||||||
|
// repro, so it asserts the loading half separately below rather than trusting
|
||||||
|
// that the by-hand path matches the real one.
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
require_once WC_EDM_PLUGIN_DIR . 'includes/shared-menu.php';
|
||||||
|
require_once WC_EDM_PLUGIN_DIR . 'includes/class-admin.php';
|
||||||
|
|
||||||
|
wp_set_current_user( 1 );
|
||||||
|
global $menu, $submenu, $admin_page_hooks;
|
||||||
|
$menu = array();
|
||||||
|
$submenu = array();
|
||||||
|
$admin_page_hooks = array();
|
||||||
|
|
||||||
|
$wc_edm_admin = new WC_EDM_Admin();
|
||||||
|
$wc_edm_admin->register_menu();
|
||||||
|
|
||||||
|
wc_edm_ok(
|
||||||
|
'the parent Nolimit menu exists',
|
||||||
|
isset( $admin_page_hooks[ WPMGR_MENU_SLUG ] ),
|
||||||
|
'wpmgr_ensure_menu() did not register it'
|
||||||
|
);
|
||||||
|
|
||||||
|
$wc_edm_pages = isset( $submenu[ WPMGR_MENU_SLUG ] )
|
||||||
|
? wp_list_pluck( $submenu[ WPMGR_MENU_SLUG ], 2 )
|
||||||
|
: array();
|
||||||
|
wc_edm_ok(
|
||||||
|
'and this plugin has a page under it',
|
||||||
|
in_array( WC_EDM_Admin::PAGE_SLUG, $wc_edm_pages, true ),
|
||||||
|
'pages found: ' . ( $wc_edm_pages ? implode( ', ', $wc_edm_pages ) : 'none' )
|
||||||
|
);
|
||||||
|
|
||||||
|
// The other half: the by-hand require above would pass even if the plugin
|
||||||
|
// never loaded the file in a real admin request. This is the assertion that
|
||||||
|
// covers that, and it is the half a reduced repro always omits.
|
||||||
|
wc_edm_ok(
|
||||||
|
'and the plugin itself loads the shared menu file in admin',
|
||||||
|
false !== strpos(
|
||||||
|
file_get_contents( WC_EDM_PLUGIN_FILE ),
|
||||||
|
"'includes/shared-menu.php',"
|
||||||
|
),
|
||||||
|
'it is not in the is_admin() branch of includes(), so nothing would define wpmgr_ensure_menu()'
|
||||||
|
);
|
||||||
|
|
||||||
// includes/shared-menu.php is byte-identical in all five plugins, and which
|
// includes/shared-menu.php is byte-identical in all five plugins, and which
|
||||||
// copy a site loads is decided by activation order. Editing it here would make
|
// copy a site loads is decided by activation order. Editing it here would make
|
||||||
// a site with three of five updated show one label or another depending on who
|
// a site with three of five updated show one label or another depending on who
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* Plugin URI: https://gitea.nolimit.dk/kw/woo-discount-manager
|
* Plugin URI: https://gitea.nolimit.dk/kw/woo-discount-manager
|
||||||
* Update URI: https://gitea.nolimit.dk/kw/nolimit-discounts-dist
|
* Update URI: https://gitea.nolimit.dk/kw/nolimit-discounts-dist
|
||||||
* Description: Apply discounts and show/hide shipping methods based on the customer's email address (full address, domain or partial match).
|
* Description: Apply discounts and show/hide shipping methods based on the customer's email address (full address, domain or partial match).
|
||||||
* Version: 1.4.6
|
* Version: 1.5.0
|
||||||
* Author: Kristian Wind
|
* Author: Kristian Wind
|
||||||
* Author URI: https://gitea.nolimit.dk/kw
|
* Author URI: https://gitea.nolimit.dk/kw
|
||||||
* License: GPL-2.0-or-later
|
* License: GPL-2.0-or-later
|
||||||
@@ -28,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
define( 'WC_EDM_VERSION', '1.4.6' );
|
define( 'WC_EDM_VERSION', '1.5.0' );
|
||||||
define( 'WC_EDM_PLUGIN_FILE', __FILE__ );
|
define( 'WC_EDM_PLUGIN_FILE', __FILE__ );
|
||||||
define( 'WC_EDM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
define( 'WC_EDM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
define( 'WC_EDM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'WC_EDM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user