From 17b4d608ed26a41ce29d7fdbd1b59ce1dfb847ba Mon Sep 17 00:00:00 2001 From: Robert Harm Date: Tue, 25 Mar 2014 13:25:08 +0100 Subject: [PATCH 01/11] expand uninstall.php to also delete transient, options, custom database tables and files --- plugin-name/uninstall.php | 60 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/plugin-name/uninstall.php b/plugin-name/uninstall.php index ac1add1..8227ec2 100644 --- a/plugin-name/uninstall.php +++ b/plugin-name/uninstall.php @@ -13,5 +13,61 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { exit; } - -// @TODO: Define uninstall functionality here +if (is_multisite()) { + global $wpdb; + $blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A); + /* @TODO: delete all transient, options and files you may have added + delete_transient( 'TRANSIENT_NAME' ); + delete_option('OPTION_NAME'); + //info: remove custom file directory for main site + $upload_dir = wp_upload_dir(); + $directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR; + if (is_dir($directory)) { + foreach(glob($directory.'*.*') as $v){ + unlink($v); + } + rmdir($directory); + } + */ + if ($blogs) { + foreach($blogs as $blog) { + switch_to_blog($blog['blog_id']); + /* @TODO: delete all transient, options and files you may have added + delete_transient( 'TRANSIENT_NAME' ); + delete_option('OPTION_NAME'); + //info: remove custom file directory for main site + $upload_dir = wp_upload_dir(); + $directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR; + if (is_dir($directory)) { + foreach(glob($directory.'*.*') as $v){ + unlink($v); + } + rmdir($directory); + } + //info: remove and optimize tables + $GLOBALS['wpdb']->query("DROP TABLE `".$GLOBALS['wpdb']->prefix."TABLE_NAME`"); + $GLOBALS['wpdb']->query("OPTIMIZE TABLE `" .$GLOBALS['wpdb']->prefix."options`"); + */ + restore_current_blog(); + } + } +} +else +{ + /* @TODO: delete all transient, options and files you may have added + delete_transient( 'TRANSIENT_NAME' ); + delete_option('OPTION_NAME'); + //info: remove custom file directory for main site + $upload_dir = wp_upload_dir(); + $directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR; + if (is_dir($directory)) { + foreach(glob($directory.'*.*') as $v){ + unlink($v); + } + rmdir($directory); + } + //info: remove and optimize tables + $GLOBALS['wpdb']->query("DROP TABLE `".$GLOBALS['wpdb']->prefix."TABLE_NAME`"); + $GLOBALS['wpdb']->query("OPTIMIZE TABLE `" .$GLOBALS['wpdb']->prefix."options`"); + */ +} \ No newline at end of file From 96edc6e0b1bf88cb56af753d04db1b8be6ea4895 Mon Sep 17 00:00:00 2001 From: emeraldjava Date: Wed, 26 Mar 2014 15:47:51 +0000 Subject: [PATCH 02/11] Issue#175 Add WordPress-Plugin-Boilerplate version --- plugin-name/plugin-name.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin-name/plugin-name.php b/plugin-name/plugin-name.php index 0309e20..c4ba6a8 100644 --- a/plugin-name/plugin-name.php +++ b/plugin-name/plugin-name.php @@ -23,6 +23,7 @@ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * Domain Path: /languages * GitHub Plugin URI: https://github.com// + * WordPress-Plugin-Boilerplate: v2.6.1 */ // If this file is called directly, abort. From aa38893520cf2f303c22b21bc9ff8230b3fc9eca Mon Sep 17 00:00:00 2001 From: emeraldjava Date: Wed, 26 Mar 2014 15:57:44 +0000 Subject: [PATCH 03/11] Issue#117 - Update the plugin description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c831b4..9063573 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # WordPress Plugin Boilerplate -The WordPress Plugin Boilerplate serves as a foundation and aims to provide a clear and consistent guide for building your WordPress plugins. +The WordPress Plugin Boilerplate serves as a foundation and aims to provide a clear and consistent guide for building your WordPress plugins. Just download, replace a few instances of 'plugin-name' with the name of your own plugin, and you'll get to the meat of coding your plugin in no time!. ## Features From 4a73e7615aef38c8d78e32bd444ca531e970be86 Mon Sep 17 00:00:00 2001 From: emeraldjava Date: Wed, 26 Mar 2014 16:02:27 +0000 Subject: [PATCH 04/11] Issue#132 Add a reference to the WordPress Plugin Boilerplate project in the readme file of the new plugin. --- plugin-name/README.txt | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/plugin-name/README.txt b/plugin-name/README.txt index 86ea210..1a6ec67 100644 --- a/plugin-name/README.txt +++ b/plugin-name/README.txt @@ -109,29 +109,5 @@ plugins where more information needs to be conveyed that doesn't fit into the ca == Updates == +The basic structure of this plugin was cloned from the [WordPress-Plugin-Boilerplate](https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate) project. This plugin supports the [GitHub Updater](https://github.com/afragen/github-updater) plugin, so if you install that, this plugin becomes automatically updateable direct from GitHub. Any submission to WP.org repo will make this redundant. - -== A brief Markdown Example == - -Ordered list: - -1. Some feature -1. Another feature -1. Something else about the plugin - -Unordered list: - -* something -* something else -* third thing - -Here's a link to [WordPress](http://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax]. -Titles are optional, naturally. - -[markdown syntax]: http://daringfireball.net/projects/markdown/syntax - "Markdown is what the parser uses to process much of the readme file" - -Markdown uses email style notation for blockquotes and I've been told: -> Asterisks for *emphasis*. Double it up for **strong**. - -`` From b744549d3beea3ad4295deced845d5defeec1465 Mon Sep 17 00:00:00 2001 From: nextgenthemes Date: Tue, 15 Apr 2014 14:07:41 +0200 Subject: [PATCH 05/11] Support PHP 5.2.x by dropping dir __DIR__ As per https://github.com/nextgenthemes/advanced-responsive-video-embedder/issues/7 I was informed that this would make my plugin work with PHP 5.2.x. I personally have not tested this code yet but I assume @andrejpavlovic did so I thought if this is the only thing that makes the Boilerplate require PHP 5.3 this might be a good change since WordPress itself only requires PHP 5.2.4. --- plugin-name/admin/class-plugin-name-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-name/admin/class-plugin-name-admin.php b/plugin-name/admin/class-plugin-name-admin.php index a9479cb..68c34e1 100644 --- a/plugin-name/admin/class-plugin-name-admin.php +++ b/plugin-name/admin/class-plugin-name-admin.php @@ -77,7 +77,7 @@ class Plugin_Name_Admin { add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) ); // Add an action link pointing to the options page. - $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_slug . '.php' ); + $plugin_basename = plugin_basename( plugin_dir_path( realpath( dirname( __FILE__ ) ) ) . $this->plugin_slug . '.php' ); add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) ); /* From 9555d7bd46f15536c506016ce3d4d6917aa4c66f Mon Sep 17 00:00:00 2001 From: Timo Date: Fri, 2 May 2014 15:58:45 +0200 Subject: [PATCH 06/11] grammar mistake --- plugin-name/public/class-plugin-name.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-name/public/class-plugin-name.php b/plugin-name/public/class-plugin-name.php index ad7fd03..cfc2461 100644 --- a/plugin-name/public/class-plugin-name.php +++ b/plugin-name/public/class-plugin-name.php @@ -33,7 +33,7 @@ class Plugin_Name { const VERSION = '1.0.0'; /** - * @TODO - Rename "plugin-name" to the name your your plugin + * @TODO - Rename "plugin-name" to the name of your plugin * * Unique identifier for your plugin. * From 2c29f1ca041520e9ebfbeb36682884f4631c38f3 Mon Sep 17 00:00:00 2001 From: Tom McFarlin Date: Fri, 9 May 2014 09:35:11 -0400 Subject: [PATCH 07/11] moving $wpdb outside of the conditional so both cases work Fixes #182 --- plugin-name/uninstall.php | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/plugin-name/uninstall.php b/plugin-name/uninstall.php index 8227ec2..83d7c54 100644 --- a/plugin-name/uninstall.php +++ b/plugin-name/uninstall.php @@ -13,13 +13,16 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { exit; } -if (is_multisite()) { - global $wpdb; - $blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A); - /* @TODO: delete all transient, options and files you may have added + +global $wpdb; + +if ( is_multisite() ) { + + $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A ); + /* @TODO: delete all transient, options and files you may have added delete_transient( 'TRANSIENT_NAME' ); delete_option('OPTION_NAME'); - //info: remove custom file directory for main site + //info: remove custom file directory for main site $upload_dir = wp_upload_dir(); $directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR; if (is_dir($directory)) { @@ -29,13 +32,14 @@ if (is_multisite()) { rmdir($directory); } */ - if ($blogs) { - foreach($blogs as $blog) { - switch_to_blog($blog['blog_id']); - /* @TODO: delete all transient, options and files you may have added + if ( $blogs ) { + + foreach ( $blogs as $blog ) { + switch_to_blog( $blog['blog_id'] ); + /* @TODO: delete all transient, options and files you may have added delete_transient( 'TRANSIENT_NAME' ); delete_option('OPTION_NAME'); - //info: remove custom file directory for main site + //info: remove custom file directory for main site $upload_dir = wp_upload_dir(); $directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR; if (is_dir($directory)) { @@ -51,13 +55,12 @@ if (is_multisite()) { restore_current_blog(); } } -} -else -{ - /* @TODO: delete all transient, options and files you may have added + +} else { + /* @TODO: delete all transient, options and files you may have added delete_transient( 'TRANSIENT_NAME' ); delete_option('OPTION_NAME'); - //info: remove custom file directory for main site + //info: remove custom file directory for main site $upload_dir = wp_upload_dir(); $directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR; if (is_dir($directory)) { From 7d71114f81fee9b6ad20c59a47dcf46fad201dde Mon Sep 17 00:00:00 2001 From: Tom McFarlin Date: Fri, 9 May 2014 09:36:06 -0400 Subject: [PATCH 08/11] updating the change log to reflect the latest tag --- ChangeLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 879a733..13bbd48 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ +## 2.6.2 (9 May 2014) + +* Moving `$wpdb` outside of the conditional so both cases work + ## 2.6.1 (20 November 2013) * Updating the localization functions to that `load_textdomain` is called. From e75e6e2c572ff4f185ae45bc81b633a04713216e Mon Sep 17 00:00:00 2001 From: Ulrich Pogson Date: Sun, 1 Jun 2014 00:06:29 +0200 Subject: [PATCH 09/11] Move restore_current_blog in the correct position --- plugin-name/public/class-plugin-name.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin-name/public/class-plugin-name.php b/plugin-name/public/class-plugin-name.php index cfc2461..0474054 100644 --- a/plugin-name/public/class-plugin-name.php +++ b/plugin-name/public/class-plugin-name.php @@ -134,9 +134,9 @@ class Plugin_Name { switch_to_blog( $blog_id ); self::single_activate(); - } - restore_current_blog(); + restore_current_blog(); + } } else { self::single_activate(); @@ -172,9 +172,9 @@ class Plugin_Name { switch_to_blog( $blog_id ); self::single_deactivate(); - } + restore_current_blog(); - restore_current_blog(); + } } else { self::single_deactivate(); From ddc916762b74e87624c3e0e7588c41b075019c9c Mon Sep 17 00:00:00 2001 From: Remkus de Vries Date: Tue, 10 Jun 2014 14:25:26 +0200 Subject: [PATCH 10/11] Added grunt-wp-i18n solution for i18n-ing the plugin --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9063573..3ae2bed 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ there are tools that are recommended for providing correct, translatable files: * [Poedit](http://www.poedit.net/) * [makepot](http://i18n.svn.wordpress.org/tools/trunk/) * [i18n](https://github.com/grappler/i18n) +* [grunt-wp-i18n](https://github.com/blazersix/grunt-wp-i18n) Any of the above tools should provide you with the proper tooling to localize the plugin. From fc2a90f412fdd64289421fbcfeff3409b77bbfa4 Mon Sep 17 00:00:00 2001 From: Michael Beil Date: Thu, 21 Aug 2014 11:30:45 -0500 Subject: [PATCH 11/11] added periods in first list for consistency --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ae2bed..2adad6f 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ The WordPress Plugin Boilerplate serves as a foundation and aims to provide a cl * Example values are given, so you can see what needs to be changed. * Uses a strict file organization scheme to make sure the assets are easily maintainable. * Note that this boilerplate includes a `.pot` as a starting translation file. -* Notes on managing assets prior to deployment are covered below -* Tools used for translation are below +* Notes on managing assets prior to deployment are covered below. +* Tools used for translation are below. ## Contents