merge refactor/22762 into master

This commit is contained in:
Mike Jolley 2019-03-12 13:49:10 +00:00
commit f8dded8b49
5 changed files with 50 additions and 66 deletions

View File

@ -20,7 +20,6 @@ class WC_Admin {
* Constructor.
*/
public function __construct() {
add_action( 'plugins_loaded', array( $this, 'preload_helper' ), 9 );
add_action( 'init', array( $this, 'includes' ) );
add_action( 'current_screen', array( $this, 'conditional_includes' ) );
add_action( 'admin_init', array( $this, 'buffer' ), 1 );
@ -84,11 +83,6 @@ class WC_Admin {
}
// Helper.
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-options.php';
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-api.php';
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-updater.php';
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-plugin-info.php';
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-compat.php';
include_once dirname( __FILE__ ) . '/helper/class-wc-helper.php';
// Marketplace suggestions & related REST API.
@ -96,13 +90,6 @@ class WC_Admin {
include_once dirname( __FILE__ ) . '/marketplace-suggestions/class-wc-marketplace-updater.php';
}
/**
* Preloads some functionality of the Helper to be loaded on the `plugins_loaded` hook.
*/
public function preload_helper() {
include_once dirname( __FILE__ ) . '/helper/class-wc-helper-file-headers.php';
}
/**
* Include admin files conditionally.
*/

View File

@ -1,44 +0,0 @@
<?php
/**
* WooCommerce Admin
*
* @class WC_Admin
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 3.5.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WC_Helper_File_Headers Class
*
* Adds some filters to be able to parse the `Woo` header from locally
* installed Woo plugins and themes
*/
class WC_Helper_File_Headers {
/**
* Load functions adds the `extra_headers` filter on the `extra_plugin_headers`
* and `extra_theme_headers` hooks.
*/
public static function load() {
add_filter( 'extra_plugin_headers', array( __CLASS__, 'extra_headers' ) );
add_filter( 'extra_theme_headers', array( __CLASS__, 'extra_headers' ) );
}
/**
* Additional theme style.css and plugin file headers.
*
* Format: Woo: product_id:file_id
*/
public static function extra_headers( $headers ) {
$headers[] = 'Woo';
return $headers;
}
}
WC_Helper_File_Headers::load();

View File

@ -31,27 +31,34 @@ class WC_Helper {
* @return string The absolute path to the view file.
*/
public static function get_view_filename( $view ) {
return __DIR__ . "/views/$view";
return dirname( __FILE__ ) . "/views/$view";
}
/**
* Loads the helper class, runs on init.
*/
public static function load() {
self::includes();
add_action( 'current_screen', array( __CLASS__, 'current_screen' ) );
add_action( 'woocommerce_helper_output', array( __CLASS__, 'render_helper_output' ) );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
// Attempt to toggle subscription state upon plugin activation/deactivation.
add_action( 'activated_plugin', array( __CLASS__, 'activated_plugin' ) );
add_action( 'deactivated_plugin', array( __CLASS__, 'deactivated_plugin' ) );
// Add some nags about extension updates.
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
do_action( 'woocommerce_helper_loaded' );
}
/**
* Include supporting helper classes.
*/
protected static function includes() {
include_once dirname( __FILE__ ) . '/class-wc-helper-options.php';
include_once dirname( __FILE__ ) . '/class-wc-helper-api.php';
include_once dirname( __FILE__ ) . '/class-wc-helper-updater.php';
include_once dirname( __FILE__ ) . '/class-wc-helper-plugin-info.php';
include_once dirname( __FILE__ ) . '/class-wc-helper-compat.php';
}
/**
* Render the helper section content based on context.
*/

View File

@ -187,6 +187,8 @@ final class WooCommerce {
add_action( 'init', array( $this, 'wpdb_table_fix' ), 0 );
add_action( 'init', array( $this, 'add_image_sizes' ) );
add_action( 'switch_blog', array( $this, 'wpdb_table_fix' ), 0 );
add_action( 'activated_plugin', array( $this, 'activated_plugin' ) );
add_action( 'deactivated_plugin', array( $this, 'deactivated_plugin' ) );
}
/**
@ -723,6 +725,30 @@ final class WooCommerce {
$wpdb->tables[] = 'wc_product_meta_lookup';
}
/**
* Ran when any plugin is activated.
*
* @since 3.6.0
* @param string $filename The filename of the activated plugin.
*/
public function activated_plugin( $filename ) {
include_once dirname( __FILE__ ) . '/admin/helper/class-wc-helper.php';
WC_Helper::activated_plugin( $filename );
}
/**
* Ran when any plugin is deactivated.
*
* @since 3.6.0
* @param string $filename The filename of the deactivated plugin.
*/
public function deactivated_plugin( $filename ) {
include_once dirname( __FILE__ ) . '/admin/helper/class-wc-helper.php';
WC_Helper::deactivated_plugin( $filename );
}
/**
* Get queue instance.
*

View File

@ -2015,10 +2015,18 @@ function wc_enable_wc_plugin_headers( $headers ) {
include_once dirname( __FILE__ ) . '/admin/plugin-updates/class-wc-plugin-updates.php';
}
$headers['WCRequires'] = WC_Plugin_Updates::VERSION_REQUIRED_HEADER;
$headers['WCTested'] = WC_Plugin_Updates::VERSION_TESTED_HEADER;
// WC requires at least - allows developers to define which version of WooCommerce the plugin requires to run.
$headers[] = WC_Plugin_Updates::VERSION_REQUIRED_HEADER;
// WC tested up to - allows developers to define which version of WooCommerce they have tested up to.
$headers[] = WC_Plugin_Updates::VERSION_TESTED_HEADER;
// Woo - This is used in WooCommerce extensions and is picked up by the helper.
$headers[] = 'Woo';
return $headers;
}
add_filter( 'extra_theme_headers', 'wc_enable_wc_plugin_headers' );
add_filter( 'extra_plugin_headers', 'wc_enable_wc_plugin_headers' );
/**