Permalink
Browse files

Fixed annoying warning bug

git-svn-id: http://plugins.svn.wordpress.org/amazon-widgets-shortcodes/trunk@361347 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information...
1 parent 8ce5e39 commit 2b153fd15379d9ab121d92049bf27519a176e942 oncletom committed Mar 17, 2011
@@ -3,7 +3,7 @@
Plugin Name: Amazon Widgets Shortcodes
Description: Easy management of Amazon Links & Widgets on your blog. Preserve your post consistency, use copy/paste Amazon code or build your links with an easy to use interface. <em>µ compatible</em>.
Author: Oncle Tom
-Version: 1.6
+Version: 1.6.1
Author URI: http://oncle-tom.net/
Plugin URI: http://case.oncle-tom.net/code/wordpress/
@@ -9,7 +9,7 @@ class AmazonWidgetsShortcodeConfiguration
* Retrieves disabled widgets list
*
* @author oncletom
- * @version 1.0
+ * @version 1.0.1
* @since 1.6
*/
function getDisabledWidgets()
@@ -18,7 +18,12 @@ function getDisabledWidgets()
if (null === $disabledWidgets)
{
- $disabledWidgets = ('' === $disabledWidgets) ? array() : get_option('awshortcode_disabled_widgets');
+ $disabledWidgets = get_option('awshortcode_disabled_widgets', array());
+
+ if (!$disabledWidgets || $disabledWidgets = 'a:0:{}')
+ {
+ $disabledWidgets = array();
+ }
if (is_string($disabledWidgets))
{
@@ -127,21 +127,39 @@ function executeFilterPluginActionLinks($action_links)
* Register shortcode class & syntax
*
* @author oncletom
- * @version 1.1
+ * @version 1.2
* @since 1.3
* @return $registered_shortcodes Integer Number of registered shortcodes
*/
function registerShortcodes()
{
- $registered_shortcodes = 0;
+ $disabled_widgets = AmazonWidgetsShortcodeConfiguration::getDisabledWidgets();
require AWS_PLUGIN_BASEPATH.'/lib/widgets/AmazonWidgetsShortcodeBase.class.php';
- foreach (AmazonWidgetsShortcodeConfiguration::getEnabledWidgets() as $shortcode_id => $shortcode_config)
+ foreach (AmazonWidgetsShortcodeConfiguration::getShortcodes() as $shortcode_id => $shortcode_config)
{
- require AWS_PLUGIN_BASEPATH.'/lib/widgets/'.$shortcode_config['class'].'.class.php';
+ /*
+ * Standard HTML generator
+ */
+ if (empty($disabled_widgets) || !in_array($shortcode_id, $disabled_widgets))
+ {
+ require AWS_PLUGIN_BASEPATH.'/lib/widgets/'.$shortcode_config['class'].'.class.php';
+ }
+ /*
+ * Load dummy HTML generator, in case you don't want to display disabled widgets
+ */
+ else
+ {
+ $shortcode_config['class'] = 'AmazonWidgetsShortcodeDummy';
+
+ if (!class_exists($shortcode_config['class']))
+ {
+ require AWS_PLUGIN_BASEPATH.'/lib/widgets/'.$shortcode_config['class'].'.class.php';
+ }
+ }
+
add_shortcode($shortcode_id, array($shortcode_config['class'], 'displayAsHtml'));
- $registered_shortcodes++;
}
return $registered_shortcodes;
@@ -0,0 +1,24 @@
+<?php
+/**
+ * @author oncletom
+ */
+
+class AmazonWidgetsShortcodeDummy extends AmazonWidgetsShortcodeBase
+{
+ /**
+ * @see AmazonWidgetsShortcode::displayAsHtml()
+ * @see AmazonWidgetsShortcodeBase::displayAsHtml()
+ */
+ function displayAsHtml($attributes, $value = null)
+ {
+ return '';
+ }
+
+ /**
+ * @see AmazonWidgetsShortcode::shortcodeToHtml()
+ */
+ function shortcodeToHtml($attributes, $value = null)
+ {
+ return '';
+ }
+}
View
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: amazon, affiliate, shortcode, shortcodes, monetization, context, links, product, preview, carrousel, documentation, plugin, slideshow, admin, post, page, tinymce, wysiwyg, wpmu
Requires at least: 2.5
Tested up to: 3.1
-Stable tag: 1.6
+Stable tag: 1.6.1
Keep your time and save your money with these Amazon widgets shortcodes. Standard compliants, easy to use and so on !
@@ -86,6 +86,9 @@ Please notice that this forthcoming version **will require at least**:
* PHP 5.1.2 (so that the `spl_autoload` function is available)
* WordPress 3.0
+= Version 1.6.1 =
+ * fix: disabled widgets messed up things when none set (as said, always...)
+
= Version 1.6 =
* added support for Amazon Italia (restricted to Products so far)
* admin: you can now enable/disable some widgets

0 comments on commit 2b153fd

Please sign in to comment.