Skip to content
Browse files

Better handling of disabled widgets, including TinyMCE display

git-svn-id: http://plugins.svn.wordpress.org/amazon-widgets-shortcodes/trunk@360648 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information...
1 parent 912ce05 commit 66727e7884a10a691a6d6138fe90ef027cbb3713 oncletom committed Mar 16, 2011
View
12 admin/view/options.php
@@ -37,7 +37,7 @@
<li><a href="#awshortcode-tools" class="button-secondary"><?php _e('Additional Tools', 'awshortcode') ?></a></li>
<li><a href="#awshortcode-documentation" class="button-secondary"><?php _e('Documentation', 'awshortcode') ?></a></li>
</ul>
-
+
<div id="awshortcode-main">
<h3><?php _e('Main Options', 'awshortcode') ?></h3>
<table class="form-table">
@@ -95,10 +95,14 @@
<?php _e('Disabling a widget will hide it from the Rich Text Editor. Its shortcode will also be disabled.', 'awshortcode') ?>
</span>
+ <ul class="disabled-widgets-list">
<?php foreach ($shortcodes as $key => $shortcode): ?>
+ <li>
<input type="checkbox" name="awshortcode_disabled_widgets[]" value="<?php echo $key ?>" id="awshortcode_disable_widget_<?php echo $key ?>" <?php echo in_array($key, $disabled_widgets) ? 'checked="checked"' : '' ?> />
<label for="awshortcode_disable_widget_<?php echo $key ?>"><?php echo $shortcode['name'] ?></label>
+ </li>
<?php endforeach ?>
+ </ul>
</td>
</tr>
<tr>
@@ -127,7 +131,7 @@
</tr>
</tbody>
</table>
-
+
<h3><?php _e('Layout Options', 'awshortcode') ?></h3>
<table class="form-table">
<tbody>
@@ -201,7 +205,7 @@
</tbody>
</table>
</div>
-
+
<div id="awshortcode-tools">
<h3><?php _e('Additional Tools', 'awshortcode') ?></h3>
<table class="form-table">
@@ -256,7 +260,7 @@
</tbody>
</table>
</div>
-
+
<div id="awshortcode-documentation">
<?php AmazonWidgetsShortcodesAdmin::displayDocumentation() ?>
</div>
View
25 lib/AmazonWidgetsShortcodeConfiguration.class.php
@@ -30,6 +30,31 @@ function getDisabledWidgets()
}
/**
+ * Retrieves enabled widgets list
+ *
+ * @author oncletom
+ * @version 1.0
+ * @since 1.6
+ */
+ function getEnabledWidgets()
+ {
+ static $enabledWidgets;
+
+ if (null === $enabledWidgets)
+ {
+ $enabledWidgets = array_flip(array_keys(AmazonWidgetsShortcodeConfiguration::getShortcodes()));
+ foreach (AmazonWidgetsShortcodeConfiguration::getDisabledWidgets() as $w)
+ {
+ unset($enabledWidgets[$w]);
+ }
+
+ $enabledWidgets = array_flip($enabledWidgets);
+ }
+
+ return $enabledWidgets;
+ }
+
+ /**
* Easy way to get the whole list of registered options
*
* @author oncletom
View
4 lib/AmazonWidgetsShortcodePlugin.class.php
@@ -134,12 +134,10 @@ function executeFilterPluginActionLinks($action_links)
function registerShortcodes()
{
$registered_shortcodes = 0;
- $disabled_widgets = AmazonWidgetsShortcodeConfiguration::getDisabledWidgets();
- $active_widgets = array_intersect(AmazonWidgetsShortcodeConfiguration::getShortcodes(), array_flip($disabled_widgets));
require AWS_PLUGIN_BASEPATH.'/lib/widgets/AmazonWidgetsShortcodeBase.class.php';
- foreach ($active_widgets as $shortcode_id => $shortcode_config)
+ foreach (AmazonWidgetsShortcodeConfiguration::getEnabledWidgets() as $shortcode_id => $shortcode_config)
{
require AWS_PLUGIN_BASEPATH.'/lib/widgets/'.$shortcode_config['class'].'.class.php';
add_shortcode($shortcode_id, array($shortcode_config['class'], 'displayAsHtml'));
View
11 lib/rte/AmazonWidgetsShortcodeRteTinyMce.class.php
@@ -7,7 +7,7 @@ class AmazonWidgetsShortcodeRteTinyMce
{
/**
* Register TinyMCE hooks & filters
- *
+ *
* @author oncletom
* @version 2.0
* @since 1.3
@@ -32,7 +32,7 @@ function bootstrap()
/**
* Pass some more configuration to TinyMCE, essentially WP related options
- *
+ *
* @author oncletom
* @version 1.0
* @since 1.3
@@ -46,13 +46,14 @@ function registerConfig($config)
array(
'awshortcode_region' => get_option('awshortcode_region'),
'awshortcode_tracking_id' => get_option('awshortcode_tracking_id'),
+ 'awshortcode_enabled_widgets' => implode(',', AmazonWidgetsShortcodeConfiguration::getEnabledWidgets()),
)
);
}
/**
* Loads additional buttons into the TinyMCE 3 UI
- *
+ *
* @author oncletom
* @version 2.0
* @since 1.3
@@ -67,7 +68,7 @@ function registerGui($buttons)
/**
* Loads TinyMCE 3 language files
- *
+ *
* @author oncletom
* @version 1.0
* @since 1.1
@@ -82,7 +83,7 @@ function registerI18n($langs)
/**
* Loads TinyMCE 3 external plugins
- *
+ *
* @author oncletom
* @version 2.0
* @since 1.3
View
2 web/javascript/tinymce3/wpAwshortcode/editor_plugin.js
@@ -1 +1 @@
-(
+(function() {

0 comments on commit 66727e7

Please sign in to comment.
Something went wrong with that request. Please try again.