From a3b03a94058012da2a0f63437a920db27ea2030d Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 21 Apr 2015 17:23:43 +0200 Subject: [PATCH] Complete plugin revamp to use our grunt-wp-plugin boilerplate --- .editorconfig | 21 +++ .gitignore | 16 +- .travis.yml | 23 +++ Gruntfile.js | 10 +- LICENSE.txt | 2 +- README.md | 63 +++----- README.txt | 105 ------------ admin/views/index.php | 1 - assets/README.md | 8 + bin/install-wp-tests.sh | 79 +++++++++ .../plugin.php | 152 ++++++------------ composer.json | 23 +-- grunt/addtextdomain.js | 13 -- grunt/aliases.yaml | 35 +++- grunt/checktextdomain.js | 29 ++++ grunt/clean.js | 9 ++ grunt/compress.js | 12 ++ grunt/copy.js | 28 ++++ grunt/makepot.js | 45 +++--- grunt/phpunit.js | 3 + grunt/replace.js | 52 ++++++ grunt/watch.js | 27 ++++ grunt/wp_deploy.js | 10 ++ grunt/wp_readme_to_markdown.js | 7 - index.php | 1 - languages/index.php | 1 - languages/wp-widget-disable-de_CH.mo | Bin 3623 -> 3515 bytes languages/wp-widget-disable-de_CH.po | 93 +++++------ languages/wp-widget-disable-de_DE.mo | Bin 3623 -> 3515 bytes languages/wp-widget-disable-de_DE.po | 93 +++++------ languages/wp-widget-disable.pot | 61 ++++--- lib/requirements-check.php | 107 ++++++++++++ lib/wp-stack-plugin.php | 125 ++++++++++++++ package.json | 38 +++-- phpunit.xml | 14 ++ public/class-wp-widget-disable.php | 66 -------- tests/bootstrap.php | 27 ++++ tests/test-tests.php | 7 + uninstall.php | 4 +- {admin/views => views}/admin.php | 2 +- wp-widget-disable.php | 74 +++++---- 41 files changed, 916 insertions(+), 570 deletions(-) create mode 100644 .editorconfig create mode 100644 .travis.yml mode change 100755 => 100644 LICENSE.txt delete mode 100755 README.txt delete mode 100755 admin/views/index.php create mode 100644 assets/README.md create mode 100644 bin/install-wp-tests.sh rename admin/class-wp-widget-disable-admin.php => classes/plugin.php (75%) delete mode 100644 grunt/addtextdomain.js create mode 100644 grunt/checktextdomain.js create mode 100644 grunt/clean.js create mode 100644 grunt/compress.js create mode 100644 grunt/copy.js create mode 100644 grunt/phpunit.js create mode 100644 grunt/replace.js create mode 100644 grunt/watch.js create mode 100644 grunt/wp_deploy.js delete mode 100644 grunt/wp_readme_to_markdown.js delete mode 100755 index.php delete mode 100755 languages/index.php mode change 100755 => 100644 languages/wp-widget-disable.pot create mode 100644 lib/requirements-check.php create mode 100644 lib/wp-stack-plugin.php create mode 100644 phpunit.xml delete mode 100755 public/class-wp-widget-disable.php create mode 100644 tests/bootstrap.php create mode 100644 tests/test-tests.php mode change 100755 => 100644 uninstall.php rename {admin/views => views}/admin.php (99%) mode change 100755 => 100644 mode change 100755 => 100644 wp-widget-disable.php diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4c1fef9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# http://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab + +[{.jshintrc,*.json,*.yml}] +indent_style = space +indent_size = 2 + +[{*.txt,wp-config-sample.php}] +end_of_line = crlf diff --git a/.gitignore b/.gitignore index 2e2deb3..d6921c3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,20 @@ .DS_Store # npm -node_modules +/node_modules + +# Release task +/release + +# Build files +/js/*.js +/js/*.map +/css/*.css +/css/*.map + +# Sass +.sass-cache # Vendor (e.g. Composer) vendor/* -!vendor/.gitkeep \ No newline at end of file +!vendor/.gitkeep diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0e00be0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: php + +php: + - 5.2 + - 5.3 + - 5.4 + - 5.5 + - 5.6 + +env: + - WP_VERSION=latest WP_MULTISITE=0 + - WP_VERSION=latest WP_MULTISITE=1 + - WP_VERSION=4.1.1 WP_MULTISITE=0 + - WP_VERSION=4.1.1 WP_MULTISITE=1 + - WP_VERSION=4.0.1 WP_MULTISITE=0 + - WP_VERSION=4.0.1 WP_MULTISITE=1 + - WP_VERSION=3.9.3 WP_MULTISITE=0 + - WP_VERSION=3.9.3 WP_MULTISITE=1 + +before_script: + - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION + +script: phpunit diff --git a/Gruntfile.js b/Gruntfile.js index ba846a0..e3f6c29 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,9 +1,9 @@ module.exports = function (grunt) { - // measures the time each task takes - require('time-grunt')(grunt); + // measures the time each task takes + require('time-grunt')(grunt); - // load grunt config - require('load-grunt-config')(grunt); + // load grunt config + require('load-grunt-config')(grunt); -}; \ No newline at end of file +}; diff --git a/LICENSE.txt b/LICENSE.txt old mode 100755 new mode 100644 index ecbc059..d159169 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -336,4 +336,4 @@ This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. \ No newline at end of file +Public License instead of this License. diff --git a/README.md b/README.md index 3d914d5..403e9e4 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,16 @@ -# WP Team List # -**Contributors:** wearerequired, neverything, swissspidy -**Donate link:** http://required.ch/ -**Tags:** widgets, admin, dashboard, sidebar widgets, dashboard widgets, disable widgets -**Requires at least:** 3.5.1 -**Tested up to:** 4.2 -**Stable tag:** 1.1.2 -**License:** GPLv2 or later -**License URI:** http://www.gnu.org/licenses/gpl-2.0.html - -Disable Sidebar and Dashboard Widgets with an easy to use interface. +# WP Widget Disable # +Contributors: wearerequired +Donate link: http://required.ch +Tags: widgets, admin, dashboard, sidebar widgets, dashboard widgets, disable widgets +Requires at least: 3.5.1 +Tested up to: 4.2 +Stable tag: 1.1.2 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +Disable sidebar and dashboard widgets with an easy to use interface. ## Description ## - This simple plugin allows you to disable any Sidebar and Dashboard Widget for the current WordPress site you are on. It provides a simple user interface available to users with `edit_theme_options` capabilities (usually Administrator role) available under Appearance -> Disable Widgets. After saving the settings, it removes the Sidebar and Dashboard Widgets selected. @@ -19,7 +18,7 @@ After saving the settings, it removes the Sidebar and Dashboard Widgets selected First of all, this plugin is strucuted on the shoulders of the fantastic [WordPress Plugin Boilerplate](https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/) by [Tom McFarlin](http://profiles.wordpress.org/tommcfarlin/), you might could use this too for your next plugin. -Let's have a look at the filters we provide: +Let’s have a look at the filters we provide: * `rplus_wp_widget_disable_capability` change the min. capability to change the settings, defaults to `edit_theme_options`. * `rplus_wp_widget_disable_default_sidebar_filter` gives you back the list (array) of all sidebar widgets before we store them, so you could basically remove sidebar widgets from being disabled. @@ -29,37 +28,25 @@ Let's have a look at the filters we provide: If you would like to contribute to this plugin, report an isse or anything like that, please note that we develop this plugin on [GitHub](https://github.com/wearerequired/WP-Widget-Disable). -Developed by [required+](http://required.ch/ "Team of experienced web professionals from Switzerland & Germany") +Developed by [required+](http://required.ch/ „Team of experienced web professionals from Switzerland & Germany“) ## Installation ## -Here is how you install WP Widget Disable. - -**Using The WordPress Dashboard** - -1. Navigate to the 'Add New' in the plugins dashboard -2. Search for 'WP Widget Disable' -3. Click 'Install Now' -4. Activate the plugin on the Plugin dashboard +### Manual Installation ### -**Uploading in WordPress Dashboard** +1. Upload the entire `/wp-widget-disable` directory to the `/wp-content/plugins/` directory. +2. Activate WP Widget Disable through the Plugins menu in WordPress. +3. Go to Appearance -> Disable Widgets to manage sidebar and dashboard widgets. -1. Navigate to the 'Add New' in the plugins dashboard -2. Navigate to the 'Upload' area -3. Select `rplus-wp-widget-disable.zip` from your computer -4. Click 'Install Now' -5. Activate the plugin in the Plugin dashboard +## Frequently Asked Questions ## -**Using FTP** +### Question ### -1. Download `rplus-wp-widget-disable.zip` -2. Extract the `rplus-wp-widget-disable` directory to your computer -3. Upload the `rplus-wp-widget-disable` directory to the `/wp-content/plugins/` directory -4. Activate the plugin in the Plugin dashboard +Answer ## Screenshots ## -No Screenshots yet. +1. Description of first screenshot ## Changelog ## @@ -69,13 +56,13 @@ No Screenshots yet. ### 1.1.1 ### * New: Repdigit version number. * Fixed: Added correct changelog. -* Fixed: Properly translate "Select all" option. +* Fixed: Properly translate „Select all“ option. ### 1.1.0 ### * New: Get Dashboard Widgets without roundtrip to the dashboard first. -* New: "Select all" option to disable all widgets in one go. +* New: „Select all“ option to disable all widgets in one go. * New: Added German (Switzerland) translation. -* Enhancement: Code cleanup! We're doing more with less code now. +* Enhancement: Code cleanup! We’re doing more with less code now. * Fixed: Lots of bugs and typos. ### 1.0.1 ### @@ -102,4 +89,4 @@ More features with less code! Get Dashboard Widgets without roundtrip to the das I18n improvements ### 1.0.0 ### -Initial Release \ No newline at end of file +Initial Release diff --git a/README.txt b/README.txt deleted file mode 100755 index fca0a57..0000000 --- a/README.txt +++ /dev/null @@ -1,105 +0,0 @@ -=== WP Team List === -Contributors: wearerequired, neverything, swissspidy -Donate link: http://required.ch/ -Tags: widgets, admin, dashboard, sidebar widgets, dashboard widgets, disable widgets -Requires at least: 3.5.1 -Tested up to: 4.2 -Stable tag: 1.1.2 -License: GPLv2 or later -License URI: http://www.gnu.org/licenses/gpl-2.0.html - -Disable Sidebar and Dashboard Widgets with an easy to use interface. - -== Description == - -This simple plugin allows you to disable any Sidebar and Dashboard Widget for the current WordPress site you are on. It provides a simple user interface available to users with `edit_theme_options` capabilities (usually Administrator role) available under Appearance -> Disable Widgets. -After saving the settings, it removes the Sidebar and Dashboard Widgets selected. - -**Developer? Get to know the hooks** - -First of all, this plugin is strucuted on the shoulders of the fantastic [WordPress Plugin Boilerplate](https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/) by [Tom McFarlin](http://profiles.wordpress.org/tommcfarlin/), you might could use this too for your next plugin. - -Let's have a look at the filters we provide: - -* `rplus_wp_widget_disable_capability` change the min. capability to change the settings, defaults to `edit_theme_options`. -* `rplus_wp_widget_disable_default_sidebar_filter` gives you back the list (array) of all sidebar widgets before we store them, so you could basically remove sidebar widgets from being disabled. -* `rplus_wp_widget_disable_default_dashboard_filter` gives you back the list (array) of all dashboard widgets before we sotre them, so you could basically remove dashboard widgets from being disabled. - -**Contributions** - -If you would like to contribute to this plugin, report an isse or anything like that, please note that we develop this plugin on [GitHub](https://github.com/wearerequired/WP-Widget-Disable). - -Developed by [required+](http://required.ch/ "Team of experienced web professionals from Switzerland & Germany") - -== Installation == - -Here is how you install WP Widget Disable. - -**Using The WordPress Dashboard** - -1. Navigate to the 'Add New' in the plugins dashboard -2. Search for 'WP Widget Disable' -3. Click 'Install Now' -4. Activate the plugin on the Plugin dashboard - -**Uploading in WordPress Dashboard** - -1. Navigate to the 'Add New' in the plugins dashboard -2. Navigate to the 'Upload' area -3. Select `rplus-wp-widget-disable.zip` from your computer -4. Click 'Install Now' -5. Activate the plugin in the Plugin dashboard - -**Using FTP** - -1. Download `rplus-wp-widget-disable.zip` -2. Extract the `rplus-wp-widget-disable` directory to your computer -3. Upload the `rplus-wp-widget-disable` directory to the `/wp-content/plugins/` directory -4. Activate the plugin in the Plugin dashboard - -== Screenshots == - -No Screenshots yet. - -== Changelog == - -= 1.1.2 = -* Fixed: Removed obsolote hooks that caused an error on plugin (de)activation. - -= 1.1.1 = -* New: Repdigit version number. -* Fixed: Added correct changelog. -* Fixed: Properly translate "Select all" option. - -= 1.1.0 = -* New: Get Dashboard Widgets without roundtrip to the dashboard first. -* New: "Select all" option to disable all widgets in one go. -* New: Added German (Switzerland) translation. -* Enhancement: Code cleanup! We're doing more with less code now. -* Fixed: Lots of bugs and typos. - -= 1.0.1 = -* Added proper textdomains to strings instead of $this->plugin_slug. -* Added README.md for better readability. -* Fixed an issue that prevented text domain from being loaded. - -= 1.0.0 = -* Initial release of the working plugin. -* German (de_DE) translations added. - -== Upgrade Notice == - -= 1.1.2 = -Removed obsolte code that caused an error on plugin activation. - -= 1.1.1 = -Small changes in this version, only some changelog & translation cleaning. - -= 1.1.0 = -More features with less code! Get Dashboard Widgets without roundtrip to the dashboard first and disable all widgets in one go. - -= 1.0.1 = -I18n improvements - -= 1.0.0 = -Initial Release \ No newline at end of file diff --git a/admin/views/index.php b/admin/views/index.php deleted file mode 100755 index e71af0e..0000000 --- a/admin/views/index.php +++ /dev/null @@ -1 +0,0 @@ - [db-host] [wp-version]" + exit 1 +fi + +DB_NAME=$1 +DB_USER=$2 +DB_PASS=$3 +DB_HOST=${4-localhost} +WP_VERSION=${5-latest} + +WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} +WP_CORE_DIR=/tmp/wordpress/ + +set -ex + +install_wp() { + mkdir -p $WP_CORE_DIR + + if [ $WP_VERSION == 'latest' ]; then + local ARCHIVE_URL='https://github.com/WordPress/WordPress/archive/master.tar.gz' + else + local ARCHIVE_NAME="wordpress-$WP_VERSION" + local ARCHIVE_URL="http://wordpress.org/${ARCHIVE_NAME}.tar.gz" + fi + + wget -nv -O /tmp/wordpress.tar.gz $ARCHIVE_URL + tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR + + wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php +} + +install_test_suite() { + # portable in-place argument for both GNU sed and Mac OSX sed + if [[ $(uname -s) == 'Darwin' ]]; then + local ioption='-i .bak' + else + local ioption='-i' + fi + + # set up testing suite + mkdir -p $WP_TESTS_DIR + cd $WP_TESTS_DIR + svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/ + + wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php + sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php + sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php + sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php + sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php + sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php +} + +install_db() { + # parse DB_HOST for port or socket references + local PARTS=(${DB_HOST//\:/ }) + local DB_HOSTNAME=${PARTS[0]}; + local DB_SOCK_OR_PORT=${PARTS[1]}; + local EXTRA="" + + if ! [ -z $DB_HOSTNAME ] ; then + if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then + EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" + elif ! [ -z $DB_SOCK_OR_PORT ] ; then + EXTRA=" --socket=$DB_SOCK_OR_PORT" + elif ! [ -z $DB_HOSTNAME ] ; then + EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" + fi + fi + + # create database + mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA +} + +install_wp +install_test_suite +install_db diff --git a/admin/class-wp-widget-disable-admin.php b/classes/plugin.php similarity index 75% rename from admin/class-wp-widget-disable-admin.php rename to classes/plugin.php index 3266ae1..1360e0e 100644 --- a/admin/class-wp-widget-disable-admin.php +++ b/classes/plugin.php @@ -1,44 +1,17 @@ - * @license GPL-2.0+ - * @link http://wp.required.ch/plugins/wp-widget-disable - * @copyright 2015 required gmbh - */ - -/** - * Plugin class. This class should ideally be used to work with the - * administrative side of the WordPress site. - * - * If you're interested in introducing public-facing - * functionality, then refer to `class-plugin-name.php` - * - * @package WP_Widget_Disable_Admin - * @author Silvan Hagen - */ -class WP_Widget_Disable_Admin { +defined( 'WPINC' ) or die; + +class WP_Widget_Disable_Plugin extends WP_Stack_Plugin2 { /** - * Instance of this class. - * - * @since 1.0.0 - * - * @var WP_Widget_Disable_Admin + * @var self */ - protected static $instance = null; + protected static $instance; /** - * Slug of the plugin screen. - * - * @since 1.0.0 - * - * @var string + * Plugin version. */ - protected $plugin_screen_hook_suffix = null; - + const VERSION = '1.1.2'; /** * Sidebar Widgets option key. @@ -50,7 +23,7 @@ class WP_Widget_Disable_Admin { * * @var string */ - private $sidebar_widgets_option = 'rplus_wp_widget_disable_sidebar_option'; + protected $sidebar_widgets_option = 'rplus_wp_widget_disable_sidebar_option'; /** * Available Sidebar Widgets. @@ -71,58 +44,53 @@ class WP_Widget_Disable_Admin { * * @var string */ - private $dashboard_widgets_option = 'rplus_wp_widget_disable_dashboard_option'; + protected $dashboard_widgets_option = 'rplus_wp_widget_disable_dashboard_option'; /** - * Initialize the plugin by loading admin scripts & styles and adding a - * settings page and menu. - * - * @since 1.0.0 + * Constructs the object, hooks in to `plugins_loaded`. */ - private function __construct() { + protected function __construct() { + $this->hook( 'plugins_loaded', 'add_hooks' ); + } + + /** + * Adds hooks. + */ + public function add_hooks() { + $this->hook( 'init' ); + // Add the options page and menu item. - add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) ); - add_action( 'admin_init', array( $this, 'register_sidebar_settings' ) ); - add_action( 'admin_init', array( $this, 'register_dashboard_settings' ) ); + $this->hook( 'admin_menu' ); + $this->hook( 'admin_init', 'register_sidebar_settings' ); + $this->hook( 'admin_init', 'register_dashboard_settings' ); // Get and disable the sidebar widgets. - add_action( 'widgets_init', array( $this, 'set_default_sidebar_widgets' ), 100 ); - add_action( 'widgets_init', array( $this, 'disable_sidebar_widgets' ), 100 ); + $this->hook( 'widgets_init', 'set_default_sidebar_widgets', 100 ); + $this->hook( 'widgets_init', 'disable_sidebar_widgets', 100 ); // Get and disable the dashboard widgets. - add_action( 'wp_dashboard_setup', array( $this, 'disable_dashboard_widgets' ), 100 ); + $this->hook( 'wp_dashboard_setup', 'disable_dashboard_widgets', 100 ); // Add an action link pointing to the options page. - $plugin_basename = plugin_basename( plugin_dir_path( dirname( __FILE__ ) ) . 'wp-widget-disable.php' ); - add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) ); - - add_filter( 'admin_footer_text', array( $this, 'add_admin_footer' ) ); + $plugin_basename = plugin_basename( $this->get_path() . 'wp-widget-disable.php' ); + $this->hook( 'plugin_action_links_' . $plugin_basename, 'plugin_action_links' ); + $this->hook( 'admin_footer_text' ); } /** - * Return an instance of this class. - * - * @since 1.0.0 - * - * @return WP_Widget_Disable_Admin A single instance of this class. + * Initializes the plugin, registers textdomain, etc. */ - public static function get_instance() { - // If the single instance hasn't been set, set it now. - if ( null == self::$instance ) { - self::$instance = new self; - } - - return self::$instance; + public function init() { + $this->load_textdomain( 'wp-widget-disable', '/languages' ); } /** - * Register the administration menu for this plugin into the WordPress Dashboard menu. + * Register the administration menu for this plugin. * * @since 1.0.0 */ - public function add_plugin_admin_menu() { - // Add a settings page for this plugin to the Appearances menu. - $this->plugin_screen_hook_suffix = add_theme_page( + public function admin_menu() { + add_theme_page( __( 'Disable Sidebar and Dashboard Widgets', 'wp-widget-disable' ), __( 'Disable Widgets', 'wp-widget-disable' ), apply_filters( 'rplus_wp_widget_disable_capability', 'edit_theme_options' ), @@ -137,8 +105,7 @@ public function add_plugin_admin_menu() { * @since 1.0.0 */ public function display_plugin_admin_page() { - include_once( 'views/admin.php' ); - + $this->include_file( 'views/admin.php' ); } /** @@ -150,16 +117,17 @@ public function display_plugin_admin_page() { * * @return array */ - public function add_action_links( $links ) { - + public function plugin_action_links( array $links ) { return array_merge( array( - 'settings' => '' . __( 'Settings', 'wp-widget-disable' ) . '' + 'settings' => sprintf( + '%s', + admin_url( 'themes.php?page=wp-widget-disable' ), + __( 'Settings', 'wp-widget-disable' ) ) ), $links ); - - } // add_action_links + } /** * Add admin footer text to plugins page. @@ -170,7 +138,7 @@ public function add_action_links( $links ) { * * @return string */ - public function add_admin_footer( $text ) { + public function admin_footer_text( $text ) { $screen = get_current_screen(); if ( 'appearance_page_wp-widget-disable' === $screen->base || 'wp-widget-disable' === $screen->base ) { @@ -190,7 +158,7 @@ public function add_admin_footer( $text ) { */ public function set_default_sidebar_widgets() { if ( ! empty( $GLOBALS['wp_widget_factory'] ) ) { - $this->sidebars_widgets = apply_filters( 'rplus_wp_widget_disable_default_sidebar_filter', $GLOBALS['wp_widget_factory']->widgets ); + $this->sidebar_widgets = apply_filters( 'rplus_wp_widget_disable_default_sidebar_filter', $GLOBALS['wp_widget_factory']->widgets ); } } @@ -203,8 +171,7 @@ public function set_default_sidebar_widgets() { * @since 1.0.0 */ public function disable_sidebar_widgets() { - $widgets = (array) get_option( $this->sidebar_widgets_option ); - + $widgets = (array) get_option( $this->sidebar_widgets_option, array() ); if ( ! empty( $widgets ) ) { foreach ( $widgets as $widget_class => $value ) { unregister_widget( $widget_class ); @@ -222,11 +189,9 @@ public function disable_sidebar_widgets() { */ public function disable_dashboard_widgets() { $widgets = (array) get_option( $this->dashboard_widgets_option ); - if ( ! $widgets ) { return; } - foreach ( $widgets as $widget_id => $meta_box ) { //$meta_box = explode( ',', $meta_box ); remove_meta_box( $id = $widget_id, $screen = 'dashboard', $context = $meta_box ); @@ -245,7 +210,6 @@ public function disable_dashboard_widgets() { public function sanitize_sidebar_widgets( $input ) { // Create our array for storing the validated options $output = array(); - if ( empty( $input ) ) { $message = __( 'All Sidebar Widgets are enabled again.', 'wp-widget-disable' ); } else { @@ -257,10 +221,8 @@ public function sanitize_sidebar_widgets( $input ) { $output[ $key ] = strip_tags( stripslashes( $input[ $key ] ) ); } } - $message = sprintf( _n( 'Settings saved. Disabled %s Sidebar Widget for you.', 'Settings saved. Disabled %s Sidebar Widgets for you.', count( $output ), 'wp-widget-disable' ), count( $output ) ); } - add_settings_error( 'wp-widget-disable', esc_attr( 'settings_updated' ), @@ -283,7 +245,6 @@ public function sanitize_sidebar_widgets( $input ) { public function sanitize_dashboard_widgets( $input ) { // Create our array for storing the validated options $output = array(); - if ( empty( $input ) ) { $message = __( 'All Dashboard Widgets are enabled again.', 'wp-widget-disable' ); } else { @@ -295,10 +256,8 @@ public function sanitize_dashboard_widgets( $input ) { $output[ $key ] = strip_tags( stripslashes( $input[ $key ] ) ); } } - $message = sprintf( _n( 'Settings saved. Disabled %s Dashboard Widget for you.', 'Settings saved. Disabled %s Dashboard Widgets for you.', count( $output ), 'wp-widget-disable' ), count( $output ) ); } - add_settings_error( 'wp-widget-disable', esc_attr( 'settings_updated' ), @@ -320,14 +279,12 @@ public function register_sidebar_settings() { $this->sidebar_widgets_option, array( $this, 'sanitize_sidebar_widgets' ) ); - add_settings_section( 'widget_disable_widget_section', // ID __( 'Disable Sidebar Widgets', 'wp-widget-disable' ), // Title array( $this, 'render_sidebar_description' ), // Callback $this->sidebar_widgets_option // Page ); - add_settings_field( 'sidebar_widgets', __( 'Sidebar Widgets', 'wp-widget-disable' ), @@ -352,21 +309,17 @@ public function render_sidebar_description() { * @since 1.0.0 */ public function render_sidebar_checkboxes() { - $widgets = $this->sidebars_widgets; - + $widgets = $this->sidebar_widgets; if ( ! $widgets ) { - _e( 'Oops, it looks like something is already maniging the Sidebar Widgets for you, because we can\'t get them for you.', 'wp-widget-disable' ); + _e( 'Oops, we could not retrieve the Sidebar Widgets! Maybe there is another plugin already managing theme?', 'wp-widget-disable' ); } - $options = (array) get_option( $this->sidebar_widgets_option ); - ?>

$widget_object ) { ?>

/> @@ -386,14 +339,12 @@ public function register_dashboard_settings() { $this->dashboard_widgets_option, array( $this, 'sanitize_dashboard_widgets' ) ); - add_settings_section( 'widget_disable_dashboard_section', // ID __( 'Disable Dashboard Widgets', 'wp-widget-disable' ), // Title array( $this, 'render_dashboard_description' ), // Callback $this->dashboard_widgets_option // Page ); - add_settings_field( 'dashboard_widgets', __( 'Dashboard Widgets', 'wp-widget-disable' ), @@ -410,7 +361,7 @@ public function register_dashboard_settings() { */ public function render_dashboard_description() { echo '

' . __( 'Check the boxes with the Dashboard Widgets you would like to disable for this site.', 'wp-widget-disable' ) . '

'; - } // render_dashboard_description + } /** * Render setting fields @@ -419,7 +370,6 @@ public function render_dashboard_description() { */ public function render_dashboard_checkboxes() { global $wp_meta_boxes; - if ( ! is_array( $wp_meta_boxes['dashboard'] ) ) { require_once( ABSPATH . '/wp-admin/includes/dashboard.php' ); set_current_screen( 'dashboard' ); @@ -428,20 +378,16 @@ public function render_dashboard_checkboxes() { add_action( 'wp_dashboard_setup', array( $this, 'disable_dashboard_widgets' ), 100 ); set_current_screen( 'wp-widget-disable' ); } - if ( isset( $wp_meta_boxes['dashboard'][0] ) ) { unset( $wp_meta_boxes['dashboard'][0] ); } - $options = (array) get_option( $this->dashboard_widgets_option ); - ?>

$data ) { foreach ( $data as $priority => $data ) { foreach ( $data as $widget => $data ) { @@ -454,4 +400,4 @@ public function render_dashboard_checkboxes() { } } } -} \ No newline at end of file +} diff --git a/composer.json b/composer.json index 5d7c71d..4db4a32 100644 --- a/composer.json +++ b/composer.json @@ -1,24 +1,17 @@ { "name": "wearerequired/wp-widget-disable", - "description": "Disable Sidebar and Dashboard Widgets with an easy to use interface.", - "version": "1.1.1", + "description": "Disable sidebar and dashboard widgets with an easy to use interface.", + "version": "1.1.2", "type": "wordpress-plugin", "license": "GPL-2.0+", "authors": [ - { - "name": "Silvan Hagen", - "email": "silvan@required.ch", - "homepage": "http://required.ch", - "role": "Developer" - }, - { - "name": "Pascal Birchler", - "email": "pascal@required.ch", - "homepage": "http://required.ch", - "role": "Developer" - } + { + "name": "required+", + "email": "support@required.ch", + "homepage": "http://required.ch", + "role": "Developer" + } ], "require": { } } - diff --git a/grunt/addtextdomain.js b/grunt/addtextdomain.js deleted file mode 100644 index 7dbf88d..0000000 --- a/grunt/addtextdomain.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - dist: { - options: { - textdomain : 'wp-widget-disable', - updateDomains: [] - }, - target : { - files: { - src: ['*.php', '**/*.php', '!node_modules/**', '!tests/**'] - } - } - } -}; \ No newline at end of file diff --git a/grunt/aliases.yaml b/grunt/aliases.yaml index c45ab00..b0b299a 100644 --- a/grunt/aliases.yaml +++ b/grunt/aliases.yaml @@ -1,8 +1,29 @@ +# Default task default: - - 'i18n' - - 'readme' -i18n: - - 'addtextdomain' - - 'makepot' -readme: - - 'wp_readme_to_markdown' \ No newline at end of file +- 'checktextdomain' +- 'makepot' +- 'replace:header' +- 'replace:plugin' + +# Build task +build: +- 'default' +- 'clean' +- 'copy:main' +- 'compress' # Can comment this out for WordPress.org plugins + +# Prepare a WordPress.org release +release:prepare: +- 'build' +- 'copy:svn' +- 'replace:svn_readme' +- 'clean:svn_readme_md' + +# Deploy out a WordPress.org release +release:deploy: +- 'wp_deploy' + +# WordPress.org release task +release: +- 'release:prepare' +- 'release:deploy' diff --git a/grunt/checktextdomain.js b/grunt/checktextdomain.js new file mode 100644 index 0000000..2281839 --- /dev/null +++ b/grunt/checktextdomain.js @@ -0,0 +1,29 @@ +module.exports = { + dist: { + options: { + text_domain : 'wp-widget-disable', + report_missing: true, + correct_domain: true, + keywords : [ + '__:1,2d', + '_e:1,2d', + '_x:1,2c,3d', + 'esc_html__:1,2d', + 'esc_html_e:1,2d', + 'esc_html_x:1,2c,3d', + 'esc_attr__:1,2d', + 'esc_attr_e:1,2d', + 'esc_attr_x:1,2c,3d', + '_ex:1,2c,3d', + '_n:1,2,4d', + '_nx:1,2,4c,5d', + '_n_noop:1,2,3d', + '_nx_noop:1,2,3c,4d' + ] + }, + files : [{ + src : ['*.php', '**/*.php', '!node_modules/**', '!tests/**', '!release/**'], + expand: true + }] + } +} diff --git a/grunt/clean.js b/grunt/clean.js new file mode 100644 index 0000000..d273701 --- /dev/null +++ b/grunt/clean.js @@ -0,0 +1,9 @@ +module.exports = { + release : [ + 'release/<%= package.version %>/', + 'release/svn/' + ], + svn_readme_md: [ + 'release/svn/readme.md' + ] +} diff --git a/grunt/compress.js b/grunt/compress.js new file mode 100644 index 0000000..73f87cd --- /dev/null +++ b/grunt/compress.js @@ -0,0 +1,12 @@ +module.exports = { + main: { + options: { + mode : 'zip', + archive: './release/<%= package.name %>.<%= package.version %>.zip' + }, + expand : true, + cwd : 'release/<%= package.version %>/', + src : ['**/*'], + dest : '<%= package.name %>/' + } +} diff --git a/grunt/copy.js b/grunt/copy.js new file mode 100644 index 0000000..ef6ceb2 --- /dev/null +++ b/grunt/copy.js @@ -0,0 +1,28 @@ +module.exports = { + main: { + src : [ + '**', + '!node_modules/**', + '!release/**', + '!assets/**', + '!.git/**', + '!img/src/**', + '!Gruntfile.*', + '!package.json', + '!.gitignore', + '!.gitmodules', + '!tests/**', + '!bin/**', + '!.travis.yml', + '!phpunit.xml', + '!composer.lock' + ], + dest: 'release/<%= package.version %>/' + }, + svn : { + cwd : 'release/<%= package.version %>/', + expand: true, + src : '**', + dest : 'release/svn/' + } +} diff --git a/grunt/makepot.js b/grunt/makepot.js index b9f707c..a037edc 100644 --- a/grunt/makepot.js +++ b/grunt/makepot.js @@ -1,23 +1,24 @@ module.exports = { - dist: { - options: { - cwd : '', - domainPath : '/languages', - exclude : [], - include : [], - mainFile : '', - potComments : '', - potFilename : 'wp-widget-disable.pot', - potHeaders : { - poedit : true, - 'x-poedit-keywordslist': true, - 'report-msgid-bugs-to' : 'http://required.ch', - 'last-translator' : 'required+', - 'language-team' : 'required+' - }, - processPot : null, - type : 'wp-plugin', - updateTimestamp: true - } - } -}; \ No newline at end of file + dist: { + options: { + cwd : '', + domainPath : '/languages', + exclude : [], + include : [], + mainFile : 'wp-widget-disable.php', + potComments : '', + potFilename : 'wp-widget-disable.pot', + potHeaders : { + poedit : true, + 'x-poedit-keywordslist': true, + 'report-msgid-bugs-to' : 'http://required.ch', + 'last-translator' : 'required+', + 'language-team' : 'required+ ', + 'x-poedit-country' : 'Switzerland' + }, + processPot : null, + type : 'wp-plugin', + updateTimestamp: false + } + } +} diff --git a/grunt/phpunit.js b/grunt/phpunit.js new file mode 100644 index 0000000..0ee32f7 --- /dev/null +++ b/grunt/phpunit.js @@ -0,0 +1,3 @@ +module.exports = { + default: {} +} diff --git a/grunt/replace.js b/grunt/replace.js new file mode 100644 index 0000000..afdf21a --- /dev/null +++ b/grunt/replace.js @@ -0,0 +1,52 @@ +module.exports = { + header : { + src : ['<%= package.name %>.php'], + overwrite : true, + replacements: [{ + from: /\* Version:(\s*?)[\w.-]+$/m, + to : '* Version:$1<%= package.version %>' + }] + }, + plugin : { + src : ['classes/plugin.php'], + overwrite : true, + replacements: [ + { + from: /^(\s*?)const(\s+?)VERSION(\s*?)=(\s+?)'[^']+';/m, + to : "$1const$2VERSION$3=$4'<%= package.version %>';" + } + ] + }, + composer : { + src : ['composer.json'], + overwrite : true, + replacements: [ // "version": "1.0.0", + { + from: /^(\s*?)"version":(\s*?)"[^"]+",/m, + to : '$1"version":$2"<%= package.version %>",' + } + ] + }, + svn_readme: { + src : ['release/svn/readme.md'], + dest : 'release/svn/readme.txt', + replacements: [ + { + from: /^# (.*?)( #+)?$/mg, + to : '=== $1 ===' + }, + { + from: /^## (.*?)( #+)?$/mg, + to : '== $1 ==' + }, + { + from: /^### (.*?)( #+)?$/mg, + to : '= $1 =' + }, + { + from: /^Stable tag:(\s*?)[\w.-]+(\s*?)$/mi, + to : 'Stable tag:$1<%= package.version %>$2' + } + ] + } +} diff --git a/grunt/watch.js b/grunt/watch.js new file mode 100644 index 0000000..a15c2f4 --- /dev/null +++ b/grunt/watch.js @@ -0,0 +1,27 @@ +module.exports = { + options: { + livereload: true + }, + + config: { + files: 'grunt/watch.js' + }, + + sass: { + files: ['css/src/*.scss'], + tasks: ['sass', 'autoprefixer', 'cssmin'] + }, + + php: { + files : ['**/*.php'], + tasks : ['checktextdomain', 'phpunit'], + options: { + debounceDelay: 5000 + } + }, + + scripts: { + files: 'js/src/**/*.*', + tasks: ['jshint', 'concat', 'uglify', 'clean:js'] + } +} diff --git a/grunt/wp_deploy.js b/grunt/wp_deploy.js new file mode 100644 index 0000000..6dc7938 --- /dev/null +++ b/grunt/wp_deploy.js @@ -0,0 +1,10 @@ +module.exports = { + dist: { + options: { + plugin_slug: 'wp-widget-disable', + svn_user : 'wearerequired', + build_dir : 'release/svn/', + assets_dir : 'assets/' + } + } +} diff --git a/grunt/wp_readme_to_markdown.js b/grunt/wp_readme_to_markdown.js deleted file mode 100644 index 4963614..0000000 --- a/grunt/wp_readme_to_markdown.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - dist: { - files: { - 'README.md': 'readme.txt' - } - } -}; \ No newline at end of file diff --git a/index.php b/index.php deleted file mode 100755 index e71af0e..0000000 --- a/index.php +++ /dev/null @@ -1 +0,0 @@ -m9-iFbFpD;?0P6*KgdteF ziOJ~u4HzX@hEbub5IMyT4A)H_OyrVT1RSEZ5V#k zS~XGG)Z#nBwOD=lKGq&~);%mwNYBXIOqZoO!@egjxFzo}%`+9;z&6QoeNyZz$#YD; z#WX2R&Ks)se=nUk7V_0kib;B8V1>nsN_H?K9WrdihPgnqhGSqn6UCV2aWTm@7kn}* zN8=q@xRl7oGK1OhdE#u-h@KgxOeQySEH`{Sj3@V{M)YikGNZYnP)}akO((seRC1Mn zTJg0&DmDiT)~WDj@|Jd_lBoZtX?pl8b*1_q4p$nchV5cC-WHH+G}!WdHyG delta 1013 zcmb8sO=uHA6bJCxq)E+}wvF}!TYZJ9EzL)h+Cu|^wFPbXFJ$UxNsjX*+y!>`vcJki7eR}d?@5-l+ zmb(nA6VZ#a!2HIEBP_=uIFRVQdHv!Q*fi?m!(b!fbTEp>-I;eiJUi z7tnLf_GWLVa` zLxz~=cT9Oa7Z<5u4>CvQB6_ya<0zhUZ8s*K?Pn^YYwM6r=n_}a|w04pDR?d zY+ANzsYY9Xl&tQ$RVSBDmxZg>3aO%1N!Ph*bDJ;Jgw3_|+)Q%6%jDlCWjZ+OA4z2- z4^GBLli4vE8PDM}mX#a9)1hW2Gm^{5kHM>Qs`ZwVY3#QCR^%ODyL=tWDcgPW3cQHD`NH8>qtO99*)2z^VLA4Kh!O(0jT!%{ATXyq? zMQ+zs!^P<8+}606pt`VWe*3X$a+3^>^Vo7>aw-WEH>B8vf%k|yjiqQrk-lK+!vBw$ J9ZY|i{Q>ie>n8vJ diff --git a/languages/wp-widget-disable-de_CH.po b/languages/wp-widget-disable-de_CH.po index c91ddb4..0e33dfa 100644 --- a/languages/wp-widget-disable-de_CH.po +++ b/languages/wp-widget-disable-de_CH.po @@ -1,18 +1,18 @@ -# Copyright (C) 2015 required+ (Silvan Hagen) -# This file is distributed under the GPL-2.0+. +# Copyright (C) 2015 required+ +# This file is distributed under the GPLv2+. msgid "" msgstr "" -"Project-Id-Version: WP Widget Disable 1.0.1\n" +"Project-Id-Version: WP Widget Disable 1.1.2\n" "Report-Msgid-Bugs-To: http://required.ch\n" -"POT-Creation-Date: 2015-03-25 09:09:52+00:00\n" -"PO-Revision-Date: 2015-03-25 10:10+0100\n" +"POT-Creation-Date: 2015-04-17 11:48:39+00:00\n" +"PO-Revision-Date: 2015-04-21 17:00+0100\n" "Last-Translator: Pascal Birchler \n" -"Language-Team: required+\n" +"Language-Team: required+ \n" "Language: de_CH\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.7.1\n" +"X-Generator: Poedit 1.7.5\n" "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" "esc_html_x:1,2c\n" @@ -22,114 +22,109 @@ msgstr "" "X-Textdomain-Support: yes\n" "X-Poedit-SearchPath-0: .\n" -#: admin/class-wp-widget-disable-admin.php:126 +#: classes/plugin.php:94 msgid "Disable Sidebar and Dashboard Widgets" -msgstr "Deaktiviere Sidebar und Dashboard Widgets" +msgstr "Deaktiviere Sidebar- und Dashboard-Widgets" -#: admin/class-wp-widget-disable-admin.php:127 +#: classes/plugin.php:95 msgid "Disable Widgets" msgstr "Widgets deaktivieren" -#: admin/class-wp-widget-disable-admin.php:157 +#: classes/plugin.php:126 msgid "Settings" msgstr "Einstellungen" -#: admin/class-wp-widget-disable-admin.php:177 +#: classes/plugin.php:145 msgid "%s is brought to you by %s. We ♥ WordPress." msgstr "%s wurde entwickelt von %s. Wir ♥ WordPress." -#: admin/class-wp-widget-disable-admin.php:250 +#: classes/plugin.php:214 msgid "All Sidebar Widgets are enabled again." msgstr "Alle Sidebar Widgets sind wieder aktiviert." -#: admin/class-wp-widget-disable-admin.php:261 +#: classes/plugin.php:224 msgid "Settings saved. Disabled %s Sidebar Widget for you." msgid_plural "Settings saved. Disabled %s Sidebar Widgets for you." msgstr[0] "Einstellungen gespeichert. %s Sidebar Widget deaktiviert." msgstr[1] "Einstellungen gespeichert. %s Sidebar Widgets deaktiviert." -#: admin/class-wp-widget-disable-admin.php:288 +#: classes/plugin.php:249 msgid "All Dashboard Widgets are enabled again." msgstr "Alle Dashboard Widgets sind wieder aktiviert." -#: admin/class-wp-widget-disable-admin.php:299 +#: classes/plugin.php:259 msgid "Settings saved. Disabled %s Dashboard Widget for you." msgid_plural "Settings saved. Disabled %s Dashboard Widgets for you." msgstr[0] "Einstellungen gespeichert. %s Dashboard Widget deaktiviert." msgstr[1] "Einstellungen gespeichert. %s Dashboard Widgets deaktiviert." -#: admin/class-wp-widget-disable-admin.php:326 +#: classes/plugin.php:284 msgid "Disable Sidebar Widgets" -msgstr "Sidebar Widgets deaktivieren" +msgstr "Sidebar-Widgets deaktivieren" -#: admin/class-wp-widget-disable-admin.php:333 admin/views/admin.php:28 +#: classes/plugin.php:290 views/admin.php:28 msgid "Sidebar Widgets" -msgstr "Sidebar Widgets" +msgstr "Sidebar-Widgets" -#: admin/class-wp-widget-disable-admin.php:346 +#: classes/plugin.php:303 msgid "" "Check the boxes with the Sidebar Widgets you would like to " "disable for this site. Please note that a widget could still be called using " "code." msgstr "" -"Wähle die Checkboxen der Sidebar Widgets, welche du " +"Wähle die Checkboxen der Sidebar-Widgets, welche du " "deaktivieren möchtest. Bitte beachte, dass ein Widget immer noch via Code " "instanziert werden kann." -#: admin/class-wp-widget-disable-admin.php:358 +#: classes/plugin.php:314 msgid "" -"Oops, it looks like something is already maniging the Sidebar Widgets for " -"you, because we can't get them for you." +"Oops, we could not retrieve the Sidebar Widgets! Maybe there is another " +"plugin already managing theme?" msgstr "" -"Hoppla, es sieht so aus als ob die Sidebar Widgets bereits für die verwaltet " -"werden, wir können leider keine finden." +"Hoppla, wir konnten keine Sidebar-Widgets finden! Vielleicht werden diese " +"bereits durch ein anderes Plugin verwaltet?" -#: admin/class-wp-widget-disable-admin.php:366 -#: admin/class-wp-widget-disable-admin.php:441 +#: classes/plugin.php:320 classes/plugin.php:388 msgid "Select all" msgstr "Alle auswählen" -#: admin/class-wp-widget-disable-admin.php:392 +#: classes/plugin.php:344 msgid "Disable Dashboard Widgets" -msgstr "Dashboard Widgets deaktivieren" +msgstr "Dashboard-Widgets deaktivieren" -#: admin/class-wp-widget-disable-admin.php:399 admin/views/admin.php:29 +#: classes/plugin.php:350 views/admin.php:29 msgid "Dashboard Widgets" -msgstr "Dashboard Widgets" +msgstr "Dashboard-Widgets" -#: admin/class-wp-widget-disable-admin.php:412 +#: classes/plugin.php:363 msgid "" "Check the boxes with the Dashboard Widgets you would like " "to disable for this site." msgstr "" -"Wähle die Checkboxen der Dashboard Widgets, welche du " +"Wähle die Checkboxen der Dashboard-Widgets, welche du " "deaktivieren möchtest." #. Plugin Name of the plugin/theme msgid "WP Widget Disable" msgstr "WP Widget Disable" -#. Plugin URI of the plugin/theme -msgid "https://github.com/wearerequired/WP-Widget-Disable" -msgstr "https://github.com/wearerequired/WP-Widget-Disable" +#. Author URI of the plugin/theme +msgid "http://required.ch" +msgstr "http://required.ch" #. Description of the plugin/theme msgid "" -"Disable WordPress and Dashboard Widgets with an easy to use interface. " -"Simply use the checkboxes provided under Appearance -> Disable " -"Widgets and select the Widgets you'd like to hide." +"Disable Sidebar and Dashboard Widgets with an easy to use interface. Simply " +"use the checkboxes provided under Appearance -> Disable Widgets and select the Widgets you'd like to hide." msgstr "" -"Deaktiviere WordPress und Dashboard Widgets über eine einfache Oberfläche im " -"WordPress Admin. Verwende die Checkboxen unter Design -> Widgets " +"Deaktiviere Sidebar- und Dashboard-Widgets über eine einfach zu bedienende " +"Benutzeroberfläche. Verwende die Checkboxen unter Design -> Widgets " "deaktivieren um Widgets zu deaktivieren." #. Author of the plugin/theme msgid "required+" msgstr "required+" -#. Author URI of the plugin/theme -msgid "http://required.ch" -msgstr "http://required.ch" - -#~ msgid "is brought to you by %s. We ♥ WordPress." -#~ msgstr "entwickelt von %s. Wir ♥ WordPress." +#~ msgid "http://required.ch/" +#~ msgstr "http://required.ch/" diff --git a/languages/wp-widget-disable-de_DE.mo b/languages/wp-widget-disable-de_DE.mo index e49fd5383e0a2ed2b359a4a4a8530b5487569373..61513afa135f6308ea9ddde1bfa7208a4f77a095 100644 GIT binary patch delta 1007 zcmZY6&r1|x7zgloT6foVmGW1jX+1`UWFzisSzBh5hb~bd*(qXn=h1oDab|mGMpJ^7 zx{8OU2s#K+&=0)G(y3!n6cOYf5Owg}t)K|{&f*%?z&oG!eP`b1dEWPZ-2Gxt`BO{X zU4f?^tsCtXS`V77;f3cj%)&3QAGYlf;vgJ@CN$wHd<&bQ6%(QpF2W9Y2ll}=_y%sk zo$!905Ys}G#WQpoFwqm9-iFbFpD;?0P6*KgdteF ziOJ~u4HzX@hEbub5IMyT4A)H_OyrVT1RSEZ5V#k zS~XGG)Z#nBwOD=lKGq&~);%mwNYBXIOqZoO!@egjxFzo}%`+9;z&6QoeNyZz$#YD; z#WX2R&Ks)se=nUk7V_0kib;B8V1>nsN_H?K9WrdihPgnqhGSqn6UCV2aWTm@7kn}* zN8=q@xRl7oGK1OhdE#u-h@KgxOeQySEH`{Sj3@V{M)YikGNZYnP)}akO((seRC1Mn zTJg0&DmDiT)~WDj@|Jd_lBoZtX?pl8b*1_q4p$nchV5cC-WHH+G}!WdHyG delta 1013 zcmb8sO=uHA6bJCxq)E+}wvF}!TYZJ9EzL)h+Cu|^wFPbXFJ$UxNsjX*+y!>`vcJki7eR}d?@5-l+ zmb(nA6VZ#a!2HIEBP_=uIFRVQdHv!Q*fi?m!(b!fbTEp>-I;eiJUi z7tnLf_GWLVa` zLxz~=cT9Oa7Z<5u4>CvQB6_ya<0zhUZ8s*K?Pn^YYwM6r=n_}a|w04pDR?d zY+ANzsYY9Xl&tQ$RVSBDmxZg>3aO%1N!Ph*bDJ;Jgw3_|+)Q%6%jDlCWjZ+OA4z2- z4^GBLli4vE8PDM}mX#a9)1hW2Gm^{5kHM>Qs`ZwVY3#QCR^%ODyL=tWDcgPW3cQHD`NH8>qtO99*)2z^VLA4Kh!O(0jT!%{ATXyq? zMQ+zs!^P<8+}606pt`VWe*3X$a+3^>^Vo7>aw-WEH>B8vf%k|yjiqQrk-lK+!vBw$ J9ZY|i{Q>ie>n8vJ diff --git a/languages/wp-widget-disable-de_DE.po b/languages/wp-widget-disable-de_DE.po index 700af81..10f29a2 100644 --- a/languages/wp-widget-disable-de_DE.po +++ b/languages/wp-widget-disable-de_DE.po @@ -1,18 +1,18 @@ -# Copyright (C) 2015 required+ (Silvan Hagen) -# This file is distributed under the GPL-2.0+. +# Copyright (C) 2015 required+ +# This file is distributed under the GPLv2+. msgid "" msgstr "" -"Project-Id-Version: WP Widget Disable 1.0.1\n" +"Project-Id-Version: WP Widget Disable 1.1.2\n" "Report-Msgid-Bugs-To: http://required.ch\n" -"POT-Creation-Date: 2015-03-25 09:09:52+00:00\n" -"PO-Revision-Date: 2015-03-25 10:10+0100\n" +"POT-Creation-Date: 2015-04-17 11:48:39+00:00\n" +"PO-Revision-Date: 2015-04-21 17:00+0100\n" "Last-Translator: Pascal Birchler \n" -"Language-Team: required+\n" +"Language-Team: required+ \n" "Language: de_DE\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.7.1\n" +"X-Generator: Poedit 1.7.5\n" "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" "esc_html_x:1,2c\n" @@ -22,114 +22,109 @@ msgstr "" "X-Textdomain-Support: yes\n" "X-Poedit-SearchPath-0: .\n" -#: admin/class-wp-widget-disable-admin.php:126 +#: classes/plugin.php:94 msgid "Disable Sidebar and Dashboard Widgets" -msgstr "Deaktiviere Sidebar und Dashboard Widgets" +msgstr "Deaktiviere Sidebar- und Dashboard-Widgets" -#: admin/class-wp-widget-disable-admin.php:127 +#: classes/plugin.php:95 msgid "Disable Widgets" msgstr "Widgets deaktivieren" -#: admin/class-wp-widget-disable-admin.php:157 +#: classes/plugin.php:126 msgid "Settings" msgstr "Einstellungen" -#: admin/class-wp-widget-disable-admin.php:177 +#: classes/plugin.php:145 msgid "%s is brought to you by %s. We ♥ WordPress." msgstr "%s wurde entwickelt von %s. Wir ♥ WordPress." -#: admin/class-wp-widget-disable-admin.php:250 +#: classes/plugin.php:214 msgid "All Sidebar Widgets are enabled again." msgstr "Alle Sidebar Widgets sind wieder aktiviert." -#: admin/class-wp-widget-disable-admin.php:261 +#: classes/plugin.php:224 msgid "Settings saved. Disabled %s Sidebar Widget for you." msgid_plural "Settings saved. Disabled %s Sidebar Widgets for you." msgstr[0] "Einstellungen gespeichert. %s Sidebar Widget deaktiviert." msgstr[1] "Einstellungen gespeichert. %s Sidebar Widgets deaktiviert." -#: admin/class-wp-widget-disable-admin.php:288 +#: classes/plugin.php:249 msgid "All Dashboard Widgets are enabled again." msgstr "Alle Dashboard Widgets sind wieder aktiviert." -#: admin/class-wp-widget-disable-admin.php:299 +#: classes/plugin.php:259 msgid "Settings saved. Disabled %s Dashboard Widget for you." msgid_plural "Settings saved. Disabled %s Dashboard Widgets for you." msgstr[0] "Einstellungen gespeichert. %s Dashboard Widget deaktiviert." msgstr[1] "Einstellungen gespeichert. %s Dashboard Widgets deaktiviert." -#: admin/class-wp-widget-disable-admin.php:326 +#: classes/plugin.php:284 msgid "Disable Sidebar Widgets" -msgstr "Sidebar Widgets deaktivieren" +msgstr "Sidebar-Widgets deaktivieren" -#: admin/class-wp-widget-disable-admin.php:333 admin/views/admin.php:28 +#: classes/plugin.php:290 views/admin.php:28 msgid "Sidebar Widgets" -msgstr "Sidebar Widgets" +msgstr "Sidebar-Widgets" -#: admin/class-wp-widget-disable-admin.php:346 +#: classes/plugin.php:303 msgid "" "Check the boxes with the Sidebar Widgets you would like to " "disable for this site. Please note that a widget could still be called using " "code." msgstr "" -"Wähle die Checkboxen der Sidebar Widgets, welche du " +"Wähle die Checkboxen der Sidebar-Widgets, welche du " "deaktivieren möchtest. Bitte beachte, dass ein Widget immer noch via Code " "instanziert werden kann." -#: admin/class-wp-widget-disable-admin.php:358 +#: classes/plugin.php:314 msgid "" -"Oops, it looks like something is already maniging the Sidebar Widgets for " -"you, because we can't get them for you." +"Oops, we could not retrieve the Sidebar Widgets! Maybe there is another " +"plugin already managing theme?" msgstr "" -"Hoppla, es sieht so aus als ob die Sidebar Widgets bereits für die verwaltet " -"werden, wir können leider keine finden." +"Hoppla, wir konnten keine Sidebar-Widgets finden! Vielleicht werden diese " +"bereits durch ein anderes Plugin verwaltet?" -#: admin/class-wp-widget-disable-admin.php:366 -#: admin/class-wp-widget-disable-admin.php:441 +#: classes/plugin.php:320 classes/plugin.php:388 msgid "Select all" msgstr "Alle auswählen" -#: admin/class-wp-widget-disable-admin.php:392 +#: classes/plugin.php:344 msgid "Disable Dashboard Widgets" -msgstr "Dashboard Widgets deaktivieren" +msgstr "Dashboard-Widgets deaktivieren" -#: admin/class-wp-widget-disable-admin.php:399 admin/views/admin.php:29 +#: classes/plugin.php:350 views/admin.php:29 msgid "Dashboard Widgets" -msgstr "Dashboard Widgets" +msgstr "Dashboard-Widgets" -#: admin/class-wp-widget-disable-admin.php:412 +#: classes/plugin.php:363 msgid "" "Check the boxes with the Dashboard Widgets you would like " "to disable for this site." msgstr "" -"Wähle die Checkboxen der Dashboard Widgets, welche du " +"Wähle die Checkboxen der Dashboard-Widgets, welche du " "deaktivieren möchtest." #. Plugin Name of the plugin/theme msgid "WP Widget Disable" msgstr "WP Widget Disable" -#. Plugin URI of the plugin/theme -msgid "https://github.com/wearerequired/WP-Widget-Disable" -msgstr "https://github.com/wearerequired/WP-Widget-Disable" +#. Author URI of the plugin/theme +msgid "http://required.ch" +msgstr "http://required.ch" #. Description of the plugin/theme msgid "" -"Disable WordPress and Dashboard Widgets with an easy to use interface. " -"Simply use the checkboxes provided under Appearance -> Disable " -"Widgets and select the Widgets you'd like to hide." +"Disable Sidebar and Dashboard Widgets with an easy to use interface. Simply " +"use the checkboxes provided under Appearance -> Disable Widgets and select the Widgets you'd like to hide." msgstr "" -"Deaktiviere WordPress und Dashboard Widgets über eine einfache Oberfläche im " -"WordPress Admin. Verwende die Checkboxen unter Design -> Widgets " +"Deaktiviere Sidebar- und Dashboard-Widgets über eine einfach zu bedienende " +"Benutzeroberfläche. Verwende die Checkboxen unter Design -> Widgets " "deaktivieren um Widgets zu deaktivieren." #. Author of the plugin/theme msgid "required+" msgstr "required+" -#. Author URI of the plugin/theme -msgid "http://required.ch" -msgstr "http://required.ch" - -#~ msgid "is brought to you by %s. We ♥ WordPress." -#~ msgstr "entwickelt von %s. Wir ♥ WordPress." +#~ msgid "http://required.ch/" +#~ msgstr "http://required.ch/" diff --git a/languages/wp-widget-disable.pot b/languages/wp-widget-disable.pot old mode 100755 new mode 100644 index b8b4d75..7aa7bd8 --- a/languages/wp-widget-disable.pot +++ b/languages/wp-widget-disable.pot @@ -1,100 +1,99 @@ # Copyright (C) 2015 required+ -# This file is distributed under the GPL-2.0+. +# This file is distributed under the GPLv2+. msgid "" msgstr "" -"Project-Id-Version: WP Widget Disable 1.1.1\n" +"Project-Id-Version: WP Widget Disable 1.1.2\n" "Report-Msgid-Bugs-To: http://required.ch\n" -"POT-Creation-Date: 2015-03-25 09:09:52+00:00\n" +"POT-Creation-Date: 2015-04-17 11:48:39+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n" "Last-Translator: required+\n" -"Language-Team: required+\n" -"X-Generator: grunt-wp-i18n 0.5.0\n" +"Language-Team: required+ \n" +"X-Generator: grunt-wp-i18n 0.5.1\n" "X-Poedit-KeywordsList: " "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_" "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" "Language: en\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Poedit-Country: United States\n" +"X-Poedit-Country: Switzerland\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-Basepath: ../\n" "X-Poedit-SearchPath-0: .\n" "X-Poedit-Bookmarks: \n" "X-Textdomain-Support: yes\n" -#: admin/class-wp-widget-disable-admin.php:126 +#: classes/plugin.php:94 msgid "Disable Sidebar and Dashboard Widgets" msgstr "" -#: admin/class-wp-widget-disable-admin.php:127 +#: classes/plugin.php:95 msgid "Disable Widgets" msgstr "" -#: admin/class-wp-widget-disable-admin.php:157 +#: classes/plugin.php:126 msgid "Settings" msgstr "" -#: admin/class-wp-widget-disable-admin.php:177 +#: classes/plugin.php:145 msgid "%s is brought to you by %s. We ♥ WordPress." msgstr "" -#: admin/class-wp-widget-disable-admin.php:250 +#: classes/plugin.php:214 msgid "All Sidebar Widgets are enabled again." msgstr "" -#: admin/class-wp-widget-disable-admin.php:261 +#: classes/plugin.php:224 msgid "Settings saved. Disabled %s Sidebar Widget for you." msgid_plural "Settings saved. Disabled %s Sidebar Widgets for you." msgstr[0] "" msgstr[1] "" -#: admin/class-wp-widget-disable-admin.php:288 +#: classes/plugin.php:249 msgid "All Dashboard Widgets are enabled again." msgstr "" -#: admin/class-wp-widget-disable-admin.php:299 +#: classes/plugin.php:259 msgid "Settings saved. Disabled %s Dashboard Widget for you." msgid_plural "Settings saved. Disabled %s Dashboard Widgets for you." msgstr[0] "" msgstr[1] "" -#: admin/class-wp-widget-disable-admin.php:326 +#: classes/plugin.php:284 msgid "Disable Sidebar Widgets" msgstr "" -#: admin/class-wp-widget-disable-admin.php:333 admin/views/admin.php:28 +#: classes/plugin.php:290 views/admin.php:28 msgid "Sidebar Widgets" msgstr "" -#: admin/class-wp-widget-disable-admin.php:346 +#: classes/plugin.php:303 msgid "" "Check the boxes with the Sidebar Widgets you would like to " "disable for this site. Please note that a widget could still be called " "using code." msgstr "" -#: admin/class-wp-widget-disable-admin.php:358 +#: classes/plugin.php:314 msgid "" -"Oops, it looks like something is already maniging the Sidebar Widgets for " -"you, because we can't get them for you." +"Oops, we could not retrieve the Sidebar Widgets! Maybe there is another " +"plugin already managing theme?" msgstr "" -#: admin/class-wp-widget-disable-admin.php:366 -#: admin/class-wp-widget-disable-admin.php:441 +#: classes/plugin.php:320 classes/plugin.php:388 msgid "Select all" msgstr "" -#: admin/class-wp-widget-disable-admin.php:392 +#: classes/plugin.php:344 msgid "Disable Dashboard Widgets" msgstr "" -#: admin/class-wp-widget-disable-admin.php:399 admin/views/admin.php:29 +#: classes/plugin.php:350 views/admin.php:29 msgid "Dashboard Widgets" msgstr "" -#: admin/class-wp-widget-disable-admin.php:412 +#: classes/plugin.php:363 msgid "" "Check the boxes with the Dashboard Widgets you would like " "to disable for this site." @@ -104,21 +103,17 @@ msgstr "" msgid "WP Widget Disable" msgstr "" -#. Plugin URI of the plugin/theme -msgid "https://github.com/wearerequired/WP-Widget-Disable" +#. Author URI of the plugin/theme +msgid "http://required.ch" msgstr "" #. Description of the plugin/theme msgid "" -"Disable WordPress and Dashboard Widgets with an easy to use interface. " -"Simply use the checkboxes provided under Appearance -> Disable " +"Disable Sidebar and Dashboard Widgets with an easy to use interface. Simply " +"use the checkboxes provided under Appearance -> Disable " "Widgets and select the Widgets you'd like to hide." msgstr "" #. Author of the plugin/theme msgid "required+" -msgstr "" - -#. Author URI of the plugin/theme -msgid "http://required.ch" msgstr "" \ No newline at end of file diff --git a/lib/requirements-check.php b/lib/requirements-check.php new file mode 100644 index 0000000..cb6e72f --- /dev/null +++ b/lib/requirements-check.php @@ -0,0 +1,107 @@ +$setting = $args[ $setting ]; + } + } + } + + /** + * @return bool True if the install passes the requirements, false otherwise. + */ + public function passes() { + $passes = $this->php_passes() && $this->wp_passes(); + if ( ! $passes ) { + add_action( 'admin_notices', array( $this, 'deactivate' ) ); + } + + return $passes; + } + + /** + * Deactivate the plugin again. + */ + public function deactivate() { + if ( isset( $this->file ) ) { + deactivate_plugins( plugin_basename( $this->file ) ); + } + } + + /** + * @return bool True if the PHP version is high enough, false otherwise. + */ + private function php_passes() { + if ( $this->__php_at_least( $this->php ) ) { + return true; + } else { + add_action( 'admin_notices', array( $this, 'php_version_notice' ) ); + + return false; + } + } + + /** + * Compare the current PHP version with the minimum required version. + */ + private static function __php_at_least( $min_version ) { + return version_compare( phpversion(), $min_version, '>=' ); + } + + /** + * Show the PHP version notice. + */ + public function php_version_notice() { + ?> +
+

title ), $this->php ); ?>

+
+ __wp_at_least( $this->wp ) ) { + return true; + } else { + add_action( 'admin_notices', array( $this, 'wp_version_notice' ) ); + + return false; + } + } + + /** + * Compare the current WordPress version with the minimum required version. + */ + private static function __wp_at_least( $min_version ) { + return version_compare( get_bloginfo( 'version' ), $min_version, '>=' ); + } + + /** + * SHow the WordPress version notice. + */ + public function wp_version_notice() { + ?> +
+

title ), $this->wp ); ?>

+
+ __FILE__ = $__FILE__; + } + + return static::get_instance(); + } + + /** + * Returns the plugin's object instance. + * + * @return object The plugin object instance. + */ + public static function get_instance() { + if ( isset( static::$instance ) ) { + return static::$instance; + } + } + + /** + * Add a WordPress hook (action/filter). + * + * @param mixed $hook,... first parameter is the name of the hook. + * If second or third parameters are included, + * they will be used as a priority (if an integer) + * or as a class method callback name (if a string). + * + * @return bool Always returns true. + */ + public function hook( $hook ) { + $priority = 10; + $method = $this->sanitize_method( $hook ); + $args = func_get_args(); + unset( $args[0] ); + foreach ( (array) $args as $arg ) { + if ( is_int( $arg ) ) { + $priority = $arg; + } else { + $method = $arg; + } + } + + return add_action( $hook, array( $this, $method ), $priority, 999 ); + } + + /** + * Sanitize a method name by replacing dots and dashes. + * + * @param string $method The method name to sanitize. + * + * @return string The sanitized method name. + */ + private function sanitize_method( $method ) { + return str_replace( array( '.', '-' ), array( '_DOT_', '_DASH_' ), $method ); + } + + /** + * Includes a file (relative to the plugin base path) + * and optionally globalizes a named array passed in + * + * @param string $file the file to include + * @param array $data a named array of data to globalize + */ + protected function include_file( $file, $data = array() ) { + extract( $data, EXTR_SKIP ); + include( $this->get_path() . $file ); + } + + /** + * Returns the URL to the plugin directory + * + * @return string The URL to the plugin directory. + */ + public function get_url() { + return plugin_dir_url( $this->__FILE__ ); + } + + /** + * Returns the path to the plugin directory. + * + * @return string The absolute path to the plugin directory. + */ + public function get_path() { + return plugin_dir_path( $this->__FILE__ ); + } + + /** + * @param string $domain The plugin textdomain. + * @param string $path Relative path to the `languages` folder. + * + * @return bool Returns true if the textdomain was loaded successfully, false otherwise. + */ + public function load_textdomain( $domain, $path ) { + return load_plugin_textdomain( $domain, false, basename( dirname( $this->__FILE__ ) ) . $path ); + } + } + +} diff --git a/package.json b/package.json index 59ef3e7..ba53c49 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,31 @@ { "name": "wp-widget-disable", - "version": "1.1.1", - "description": "Disable Sidebar and Dashboard Widgets with an easy to use interface.", - "private": true, + "title": "WP Widget Disable", + "description": "Disable sidebar and dashboard widgets with an easy to use interface.", + "version": "1.1.2", + "homepage": "http://required.ch", + "author": { + "name": "required+", + "email": "support@required.ch", + "url": "http://required.ch" + }, "repository": { "type": "git", - "url": "git@github.com:wearerequired/wp-widget-disable.git" + "url": "https://github.com/wearerequired/WP-Widget-Disable" }, "devDependencies": { - "grunt": "*", - "grunt-contrib-watch": "*", - "grunt-wp-i18n": "*", - "grunt-wp-readme-to-markdown": "*", - "load-grunt-config": "*", - "time-grunt": "*" + "grunt": "~0.4.5", + "grunt-checktextdomain": "~1.0.0", + "grunt-contrib-clean": "~0.6.0", + "grunt-contrib-compress": "~0.13.0", + "grunt-contrib-copy": "~0.7.0", + "grunt-contrib-watch": "~0.6.1", + "grunt-phpunit": "~0.3.6", + "grunt-text-replace": "~0.4.0", + "grunt-wp-i18n": "~0.5.1", + "grunt-wp-deploy": "~1.0.3", + "load-grunt-config": "~0.16.0", + "time-grunt": "~1.1.0" }, - "dependencies": { - "time-grunt": "*" - } -} \ No newline at end of file + "keywords": [] +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..44f0fdb --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,14 @@ + + + + ./tests/ + + + diff --git a/public/class-wp-widget-disable.php b/public/class-wp-widget-disable.php deleted file mode 100755 index 95228f4..0000000 --- a/public/class-wp-widget-disable.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @license GPL-2.0+ - * @link http://wp.required.ch/plugins/wp-widget-disable - * @copyright 2015 required gmbh - */ - -/** - * Main plugin class to load the textdomain. - * - * @package WP_Widget_Disable - * @author Silvan Hagen - */ -class WP_Widget_Disable { - /** - * Instance of this class. - * - * @since 1.0.0 - * - * @var WP_Widget_Disable - */ - protected static $instance = null; - - /** - * Initialize the plugin by setting localization and loading public scripts - * and styles. - * - * @since 1.0.0 - */ - private function __construct() { - // Load plugin text domain - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); - } - - /** - * Return an instance of this class. - * - * @since 1.0.0 - * - * @return WP_Widget_Disable A single instance of this class. - */ - public static function get_instance() { - // If the single instance hasn't been set, set it now. - if ( null == self::$instance ) { - self::$instance = new self; - } - - return self::$instance; - } - - /** - * Load the plugin text domain for translation. - * - * @since 1.0.0 - */ - public function load_plugin_textdomain() { - $locale = apply_filters( 'plugin_locale', get_locale(), 'wp-widget-disable' ); - - load_textdomain( 'wp-widget-disable', trailingslashit( WP_LANG_DIR ) . 'wp-widget-disable/wp-widget-disable' . '-' . $locale . '.mo' ); - load_plugin_textdomain( 'wp-widget-disable', false, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages/' ); - } -} \ No newline at end of file diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..0c81792 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,27 @@ +assertTrue( true ); + } +} diff --git a/uninstall.php b/uninstall.php old mode 100755 new mode 100644 index 04a3ef2..2127385 --- a/uninstall.php +++ b/uninstall.php @@ -19,11 +19,9 @@ // For Single site if ( ! is_multisite() ) { - foreach ( $options as $option ) { delete_option( $option ); } - } // For Multisite else { global $wpdb; @@ -40,4 +38,4 @@ } switch_to_blog( $original_blog_id ); -} \ No newline at end of file +} diff --git a/admin/views/admin.php b/views/admin.php old mode 100755 new mode 100644 similarity index 99% rename from admin/views/admin.php rename to views/admin.php index 7378773..6f5b75c --- a/admin/views/admin.php +++ b/views/admin.php @@ -47,4 +47,4 @@ submit_button(); ?> - \ No newline at end of file + diff --git a/wp-widget-disable.php b/wp-widget-disable.php old mode 100755 new mode 100644 index 4fdc81d..9af1df4 --- a/wp-widget-disable.php +++ b/wp-widget-disable.php @@ -1,44 +1,50 @@ Appearance -> Disable Widgets
and select the Widgets you'd like to hide. + * Version: 1.1.2 + * Author: required+ + * Author URI: http://required.ch + * License: GPLv2+ + * Text Domain: wp-widget-disable + * Domain Path: /languages + */ + +/** + * Copyright (c) 2015 required+ (email : support@required.ch) * - * A plugin that allows you to disable WordPress and Dashboard Widgets in an easy to use fashion. - * Simply go to the admin page under Settings. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2 or, at + * your discretion, any later version, as published by the Free + * Software Foundation. * - * @package WP_Widget_Disable - * @author Silvan Hagen - * @license GPL-2.0+ - * @link http://wp.required.ch/plugins/wp-widget-disable/ - * @copyright 2015 required gmbh + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * @wordpress-plugin - * Plugin Name: WP Widget Disable - * Plugin URI: https://github.com/wearerequired/WP-Widget-Disable - * Description: Disable WordPress and Dashboard Widgets with an easy to use interface. Simply use the checkboxes provided under Appearance -> Disable Widgets and select the Widgets you'd like to hide. - * Version: 1.1.2 - * Author: required+ - * Author URI: http://required.ch - * Text Domain: wp-widget-disable - * License: GPL-2.0+ - * License URI: http://www.gnu.org/licenses/gpl-2.0.txt - * Domain Path: /languages - * GitHub Plugin URI: https://github.com/wearerequired/wp-widget-disable-plugin + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -// If this file is called directly, abort. -defined ( 'ABSPATH' ) or die; +defined( 'WPINC' ) or die; + +include( dirname( __FILE__ ) . '/lib/requirements-check.php' ); -/*----------------------------------------------------------------------------* - * Public-Facing Functionality - *----------------------------------------------------------------------------*/ -require_once( plugin_dir_path( __FILE__ ) . '/public/class-wp-widget-disable.php' ); +$wp_widget_disable_requirements_check = new WP_Widget_Disable_Requirements_Check( array( + 'title' => 'WP Widget Disable', + 'php' => '5.2', + 'wp' => '3.5.1', + 'file' => __FILE__, +) ); -add_action( 'plugins_loaded', array( 'WP_Widget_Disable', 'get_instance' ) ); +if ( $wp_widget_disable_requirements_check->passes() ) { + // Pull in the plugin classes and initialize + include( dirname( __FILE__ ) . '/lib/wp-stack-plugin.php' ); + include( dirname( __FILE__ ) . '/classes/plugin.php' ); + WP_Widget_Disable_Plugin::start( __FILE__ ); +} -/*----------------------------------------------------------------------------* - * Dashboard and Administrative Functionality - *----------------------------------------------------------------------------*/ -if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { - require_once( plugin_dir_path( __FILE__ ) . '/admin/class-wp-widget-disable-admin.php' ); - add_action( 'plugins_loaded', array( 'WP_Widget_Disable_Admin', 'get_instance' ) ); -} \ No newline at end of file +unset( $wp_widget_disable_requirements_check );