diff --git a/class/class-widget-context.php b/class/class-widget-context.php index bda8083..a6105c3 100644 --- a/class/class-widget-context.php +++ b/class/class-widget-context.php @@ -37,7 +37,7 @@ static function instance() { * Use widget_context::instance() instead. */ private function __construct() { - // Not used. + $this->plugin_path = dirname( dirname( __FILE__ ) ); } /** @@ -92,11 +92,8 @@ function define_widget_contexts() { ) ); - // Initialize core modules - $include_path = plugin_dir_path( __FILE__ ); - foreach ( $this->core_modules as $module ) { - $module_file = sprintf( '%smodules/%s/module.php', $include_path, $module ); + $module_file = sprintf( '%s/class/modules/%s/module.php', $this->plugin_path, $module ); if ( file_exists( $module_file ) ) { include $module_file; @@ -201,7 +198,7 @@ function set_widget_contexts_frontend() { function init_l10n() { - load_plugin_textdomain( 'widget-context', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); + load_plugin_textdomain( 'widget-context', false, basename( $this->plugin_path ) . '/languages' ); } @@ -209,19 +206,20 @@ function init_l10n() { function admin_scripts( $page ) { // Enqueue only on widgets and customizer view - if ( ! in_array( $page, array( 'widgets.php', 'settings_page_widget_context_settings' ) ) ) + if ( ! in_array( $page, array( 'widgets.php', 'settings_page_widget_context_settings' ), true ) ) { return; + } wp_enqueue_style( 'widget-context-css', - plugins_url( '../css/admin.css', plugin_basename( __FILE__ ) ), + $this->asset_url( '/css/admin.css' ), null, $this->asset_version ); wp_enqueue_script( 'widget-context-js', - plugins_url( '../js/widget-context.js', plugin_basename( __FILE__ ) ), + $this->asset_url( '/js/widget-context.js' ), array( 'jquery' ), $this->asset_version ); @@ -1013,7 +1011,7 @@ public function get_sidebars_widgets_copy() { function widget_context_debug_bar_init( $panels ) { - include plugin_dir_path( __FILE__ ) . 'debug/debug-bar.php'; + include $this->plugin_path . '/debug/debug-bar.php'; if ( class_exists( 'Debug_Widget_Context' ) ) $panels[] = new Debug_Widget_Context(); @@ -1027,11 +1025,22 @@ function widget_context_debug_bar_scripts() { wp_enqueue_script( 'widget-context-debug-js', - plugins_url( 'debug/debug.js', plugin_basename( __FILE__ ) ), + $this->asset_url( '/debug/debug.js' ), array( 'jquery' ) ); } + /** + * Return the public URL of a plugin asset file. + * + * @param string $asset_relative_path Relative path to the asset file. + * + * @return string + */ + function asset_url( $asset_relative_path ) { + return plugins_url( plugin_basename( $this->plugin_path ) . $asset_relative_path ); + } + } diff --git a/class/debug/debug-bar.php b/debug/debug-bar.php similarity index 100% rename from class/debug/debug-bar.php rename to debug/debug-bar.php diff --git a/class/debug/debug.js b/debug/debug.js similarity index 100% rename from class/debug/debug.js rename to debug/debug.js diff --git a/readme.md b/readme.md index dc3b161..da19438 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ Contributors: kasparsd, jamescollins Tags: widget, widget context, context, logic, widget logic, cms Requires at least: 3.0 -Tested up to: 4.9.1 +Tested up to: 4.9.2 Stable tag: trunk License: GPLv2 or later @@ -29,6 +29,10 @@ Widget Context allows you to show or hide widgets on certain sections of your si ## Changelog +### 1.0.6 (January 20, 2018) +* Fix path to admin scripts and styles, props [@tedgeving](https://github.com/kasparsd/widget-context-wporg/pull/32). +* Mark as tested with WordPress 4.9.2. + ### 1.0.5 (May 8, 2017) * Confirm the plugin works with the latest version of WordPress. * Add support for continuous testing via [wp-dev-lib](https://github.com/xwp/wp-dev-lib). diff --git a/widget-context.php b/widget-context.php index 531194d..d3f16ae 100644 --- a/widget-context.php +++ b/widget-context.php @@ -3,7 +3,7 @@ * Plugin Name: Widget Context * Plugin URI: https://widgetcontext.com * Description: Show or hide widgets depending on the section of the site that is being viewed. - * Version: 1.0.5 + * Version: 1.0.6 * Author: Kaspars Dambis * Author URI: https://kaspars.net * Text Domain: widget-context