Version Description
Removed a WP 3.1+ function call, hopefully making it 2.8 compatible again.
A little 'trim' of WL code to stop "syntax error, unexpected ')'" errors, which could occur if your WL was just a single space. Thanks to https://twitter.com/chrisjean for pointing this out.
Translation support! Thanks to Foe Services Labs http://wordpress.org/support/profile/cfoellmann for the work on this and the German translation files.
Added a 'widget_logic_eval_override' filter. This allows advanced users to bypass EVAL with a function of their own.
Download this release
Release Info
Developer | alanft |
Plugin | Widget Logic |
Version | 0.54 |
Comparing to | |
See all releases |
Code changes from version 0.52 to 0.54
- languages/widget-logic-de_DE.mo +0 -0
- languages/widget-logic-de_DE.po +95 -0
- languages/widget-logic.pot +101 -0
- readme.txt +23 -3
- widget_logic.php +50 -36
languages/widget-logic-de_DE.mo
ADDED
Binary file
|
languages/widget-logic-de_DE.po
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Translation of Widget Logic in German
|
2 |
+
# This file is distributed under the same license as the Widget Logic package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"PO-Revision-Date: 2012-12-17 22:14:30+0000\n"
|
6 |
+
"MIME-Version: 1.0\n"
|
7 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
+
"Content-Transfer-Encoding: 8bit\n"
|
9 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
10 |
+
"X-Generator: GlotPress/0.1\n"
|
11 |
+
"Project-Id-Version: Widget Logic\n"
|
12 |
+
|
13 |
+
#: widget_logic.php:96
|
14 |
+
msgid "Success! Options file imported"
|
15 |
+
msgstr "Erfolg! Options-Datei importiert"
|
16 |
+
|
17 |
+
#: widget_logic.php:99
|
18 |
+
msgid "Invalid options file"
|
19 |
+
msgstr "Ungültige Options-Datei"
|
20 |
+
|
21 |
+
#: widget_logic.php:104
|
22 |
+
msgid "No options file provided"
|
23 |
+
msgstr "Keine Options-Datei aufgewählt"
|
24 |
+
|
25 |
+
#: widget_logic.php:5
|
26 |
+
msgid "Control widgets with WP's conditional tags is_home etc"
|
27 |
+
msgstr "Steuere Widgets mit WP's Bedingungs-Tags. Wie etwa is_home, etc."
|
28 |
+
|
29 |
+
#: widget_logic.php:204
|
30 |
+
msgid "Load all WL options from a plain text config file"
|
31 |
+
msgstr "WL Optionen aus einer Textdatei importieren"
|
32 |
+
|
33 |
+
#: widget_logic.php:20
|
34 |
+
msgid "when all PHP loaded"
|
35 |
+
msgstr "wenn PHP geladen ist"
|
36 |
+
|
37 |
+
#: widget_logic.php:21
|
38 |
+
msgid "during page header"
|
39 |
+
msgstr "im Seiten HEADER"
|
40 |
+
|
41 |
+
#: widget_logic.php:178
|
42 |
+
msgid "Add 'widget_content' filter"
|
43 |
+
msgstr "'widget_content' Filter hinzufügen"
|
44 |
+
|
45 |
+
#: widget_logic.php:183
|
46 |
+
msgid "Use 'wp_reset_query' fix"
|
47 |
+
msgstr "Nutze 'wp_reset_query' Fix"
|
48 |
+
|
49 |
+
#: widget_logic.php:18
|
50 |
+
msgid "when plugin starts (default)"
|
51 |
+
msgstr "wenn Plugin startet (Standard)"
|
52 |
+
|
53 |
+
#: widget_logic.php:19
|
54 |
+
msgid "after theme loads"
|
55 |
+
msgstr "nachdem Theme geladen wurde"
|
56 |
+
|
57 |
+
#: widget_logic.php:173
|
58 |
+
msgid "Widget Logic options"
|
59 |
+
msgstr "Widget Logic Optionen"
|
60 |
+
|
61 |
+
#: widget_logic.php:176
|
62 |
+
msgid "Adds a new WP filter you can use in your own code. Not needed for main Widget Logic functionality."
|
63 |
+
msgstr "Fügt einen neuen WP Filter hinzu den du in deinem eigenen Code nutzen kannst. Keine Widget Logic Nutzung nötig."
|
64 |
+
|
65 |
+
#: widget_logic.php:181
|
66 |
+
msgid "Resets a theme's custom queries before your Widget Logic is checked"
|
67 |
+
msgstr "Setzt die Custom Queries eines Themes zurück bevor deine Widget Logic ausgeführt wird"
|
68 |
+
|
69 |
+
#: widget_logic.php:186
|
70 |
+
msgid "Delays widget logic code being evaluated til various points in the WP loading process"
|
71 |
+
msgstr "Verzögert die Bearbeitung durch die Widget Logic bis an verschiedene Punkte des WP Ladevorgangs"
|
72 |
+
|
73 |
+
#: widget_logic.php:186
|
74 |
+
msgid "Load logic"
|
75 |
+
msgstr "Logik laden"
|
76 |
+
|
77 |
+
#: widget_logic.php:199
|
78 |
+
msgid "Save WL options"
|
79 |
+
msgstr "WL Optionen speichern"
|
80 |
+
|
81 |
+
#: widget_logic.php:203
|
82 |
+
msgid "Export options"
|
83 |
+
msgstr "Optionen exportieren"
|
84 |
+
|
85 |
+
#: widget_logic.php:203
|
86 |
+
msgid "Save all WL options to a plain text config file"
|
87 |
+
msgstr "WL Optionen in einer Textdatei speichern"
|
88 |
+
|
89 |
+
#: widget_logic.php:204
|
90 |
+
msgid "Import options"
|
91 |
+
msgstr "Optionen importieren"
|
92 |
+
|
93 |
+
#: widget_logic.php:205
|
94 |
+
msgid "Select file for importing"
|
95 |
+
msgstr "Wähle eine Datei für den Import"
|
languages/widget-logic.pot
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2012
|
2 |
+
# This file is distributed under the same license as the package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: \n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/wp\n"
|
7 |
+
"POT-Creation-Date: 2012-12-17 22:12:06+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2012-MO-DA HO:MI+ZONE\n"
|
12 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
+
|
15 |
+
#: widget_logic.php:5
|
16 |
+
msgid "Control widgets with WP's conditional tags is_home etc"
|
17 |
+
msgstr ""
|
18 |
+
|
19 |
+
#: widget_logic.php:18
|
20 |
+
msgid "when plugin starts (default)"
|
21 |
+
msgstr ""
|
22 |
+
|
23 |
+
#: widget_logic.php:19
|
24 |
+
msgid "after theme loads"
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: widget_logic.php:20
|
28 |
+
msgid "when all PHP loaded"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: widget_logic.php:21
|
32 |
+
msgid "during page header"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: widget_logic.php:96
|
36 |
+
msgid "Success! Options file imported"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: widget_logic.php:99
|
40 |
+
msgid "Invalid options file"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: widget_logic.php:104
|
44 |
+
msgid "No options file provided"
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: widget_logic.php:173
|
48 |
+
msgid "Widget Logic options"
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: widget_logic.php:176
|
52 |
+
msgid ""
|
53 |
+
"Adds a new WP filter you can use in your own code. Not needed for main "
|
54 |
+
"Widget Logic functionality."
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: widget_logic.php:178
|
58 |
+
msgid "Add 'widget_content' filter"
|
59 |
+
msgstr ""
|
60 |
+
|
61 |
+
#: widget_logic.php:181
|
62 |
+
msgid "Resets a theme's custom queries before your Widget Logic is checked"
|
63 |
+
msgstr ""
|
64 |
+
|
65 |
+
#: widget_logic.php:183
|
66 |
+
msgid "Use 'wp_reset_query' fix"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: widget_logic.php:186
|
70 |
+
msgid ""
|
71 |
+
"Delays widget logic code being evaluated til various points in the WP "
|
72 |
+
"loading process"
|
73 |
+
msgstr ""
|
74 |
+
|
75 |
+
#: widget_logic.php:186
|
76 |
+
msgid "Load logic"
|
77 |
+
msgstr ""
|
78 |
+
|
79 |
+
#: widget_logic.php:199
|
80 |
+
msgid "Save WL options"
|
81 |
+
msgstr ""
|
82 |
+
|
83 |
+
#: widget_logic.php:203
|
84 |
+
msgid "Save all WL options to a plain text config file"
|
85 |
+
msgstr ""
|
86 |
+
|
87 |
+
#: widget_logic.php:203
|
88 |
+
msgid "Export options"
|
89 |
+
msgstr ""
|
90 |
+
|
91 |
+
#: widget_logic.php:204
|
92 |
+
msgid "Import options"
|
93 |
+
msgstr ""
|
94 |
+
|
95 |
+
#: widget_logic.php:204
|
96 |
+
msgid "Load all WL options from a plain text config file"
|
97 |
+
msgstr ""
|
98 |
+
|
99 |
+
#: widget_logic.php:205
|
100 |
+
msgid "Select file for importing"
|
101 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -3,15 +3,16 @@ Contributors: alanft
|
|
3 |
Donate link: http://www.justgiving.com/widgetlogic_cancerresearchuk
|
4 |
Tags: widget, admin, conditional tags, filter, context
|
5 |
Requires at least: 2.8
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 0.
|
|
|
8 |
|
9 |
Widget Logic lets you control on which pages widgets appear using WP's conditional tags. It also adds a 'widget_content' filter.
|
10 |
|
11 |
== Description ==
|
12 |
This plugin gives every widget an extra control field called "Widget logic" that lets you control the pages that the widget will appear on. The text field lets you use WP's [Conditional Tags](http://codex.wordpress.org/Conditional_Tags), or any general PHP code.
|
13 |
|
14 |
-
PLEASE NOTE The widget logic you introduce is EVAL'd directly. Anyone who has access to edit widget appearance will have the right to add any code, including malicious and possibly destructive functions.
|
15 |
|
16 |
There is also an option to add a wordpress 'widget_content' filter -- this lets you tweak any widget's HTML to suit your theme without editing plugins and core code.
|
17 |
|
@@ -19,6 +20,10 @@ There is also an option to add a wordpress 'widget_content' filter -- this lets
|
|
19 |
|
20 |
If you like and use Widget Logic you could consider a small donation to Cancer Research UK. I have a [JustGiving.com donation link](http://www.justgiving.com/widgetlogic_cancerresearchuk). As of December 2011 we have raised 440 UKP. I'm going to aim to have upped that to 750 UKP by the end of 2012.
|
21 |
|
|
|
|
|
|
|
|
|
22 |
== Installation ==
|
23 |
|
24 |
1. Upload `widget-logic.php` to the `/wp-content/plugins/` directory
|
@@ -130,6 +135,9 @@ There are lots of great code examples on the WP forums, and on WP sites across t
|
|
130 |
|
131 |
Note the extra ';' on the end where there is an explicit 'return'.
|
132 |
|
|
|
|
|
|
|
133 |
== The 'widget_content' filter ==
|
134 |
|
135 |
When this option is active (tick the option tickbox at the foot of the widget admin page) you can modify the text displayed by ANY widget from your own theme's functions.php file. Hook into the filter with:
|
@@ -174,6 +182,18 @@ function make_alternating_widget_styles($content='')
|
|
174 |
|
175 |
== Changelog ==
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
= 0.52 =
|
178 |
Two new features: optional delayed loading of logic (see Configuration under [Installation](../installation/)), and the ability to save out and reload all your site's widget logic into a config file
|
179 |
|
3 |
Donate link: http://www.justgiving.com/widgetlogic_cancerresearchuk
|
4 |
Tags: widget, admin, conditional tags, filter, context
|
5 |
Requires at least: 2.8
|
6 |
+
Tested up to: 3.5
|
7 |
+
Stable tag: 0.54
|
8 |
+
License: GPLv2 or later
|
9 |
|
10 |
Widget Logic lets you control on which pages widgets appear using WP's conditional tags. It also adds a 'widget_content' filter.
|
11 |
|
12 |
== Description ==
|
13 |
This plugin gives every widget an extra control field called "Widget logic" that lets you control the pages that the widget will appear on. The text field lets you use WP's [Conditional Tags](http://codex.wordpress.org/Conditional_Tags), or any general PHP code.
|
14 |
|
15 |
+
PLEASE NOTE The widget logic you introduce is EVAL'd directly. Anyone who has access to edit widget appearance will have the right to add any code, including malicious and possibly destructive functions. There is an optional filter 'widget_logic_eval_override' which you can use to bypass the EVAL with your own code if needed. (See [Other Notes](../other_notes/)).
|
16 |
|
17 |
There is also an option to add a wordpress 'widget_content' filter -- this lets you tweak any widget's HTML to suit your theme without editing plugins and core code.
|
18 |
|
20 |
|
21 |
If you like and use Widget Logic you could consider a small donation to Cancer Research UK. I have a [JustGiving.com donation link](http://www.justgiving.com/widgetlogic_cancerresearchuk). As of December 2011 we have raised 440 UKP. I'm going to aim to have upped that to 750 UKP by the end of 2012.
|
22 |
|
23 |
+
= Translate =
|
24 |
+
|
25 |
+
Social Translation: [https://translate.foe-services.de](https://translate.foe-services.de)
|
26 |
+
|
27 |
== Installation ==
|
28 |
|
29 |
1. Upload `widget-logic.php` to the `/wp-content/plugins/` directory
|
135 |
|
136 |
Note the extra ';' on the end where there is an explicit 'return'.
|
137 |
|
138 |
+
== The 'widget_logic_eval_override' filter ==
|
139 |
+
Before the Widget Logic code is evaluated for each widget, the text of the Widget Logic code is passed through this filter. If the filter returns a BOOLEAN result, this is used instead to determine if the widget is visible. Return TRUE for visible.
|
140 |
+
|
141 |
== The 'widget_content' filter ==
|
142 |
|
143 |
When this option is active (tick the option tickbox at the foot of the widget admin page) you can modify the text displayed by ANY widget from your own theme's functions.php file. Hook into the filter with:
|
182 |
|
183 |
== Changelog ==
|
184 |
|
185 |
+
= 0.54 =
|
186 |
+
Removed a WP 3.1+ function call, hopefully making it 2.8 compatible again.
|
187 |
+
|
188 |
+
A little 'trim' of WL code to stop "syntax error, unexpected ')'" errors, which could occur if your WL was just a single space. Thanks to https://twitter.com/chrisjean for pointing this out.
|
189 |
+
|
190 |
+
Translation support! Thanks to Foe Services Labs http://wordpress.org/support/profile/cfoellmann for the work on this and the German translation files.
|
191 |
+
|
192 |
+
Added a 'widget_logic_eval_override' filter. This allows advanced users to bypass EVAL with a function of their own.
|
193 |
+
|
194 |
+
= 0.53 =
|
195 |
+
Accidentally released code with a terrible bug in it :-(
|
196 |
+
|
197 |
= 0.52 =
|
198 |
Two new features: optional delayed loading of logic (see Configuration under [Installation](../installation/)), and the ability to save out and reload all your site's widget logic into a config file
|
199 |
|
widget_logic.php
CHANGED
@@ -1,18 +1,24 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name:
|
4 |
-
Plugin URI:
|
5 |
-
Description:
|
6 |
-
|
7 |
-
|
8 |
-
Author URI:
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
|
|
|
|
|
|
11 |
global $wl_options;
|
12 |
-
$wl_load_points=array( 'plugins_loaded'
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
);
|
17 |
|
18 |
if((!$wl_options = get_option('widget_logic')) || !is_array($wl_options) ) $wl_options = array();
|
@@ -51,7 +57,7 @@ function widget_logic_ajax_update_callback($instance, $new_instance, $this_widge
|
|
51 |
{ global $wl_options;
|
52 |
$widget_id=$this_widget->id;
|
53 |
if ( isset($_POST[$widget_id.'-widget_logic']))
|
54 |
-
{ $wl_options[$widget_id]
|
55 |
update_option('widget_logic', $wl_options);
|
56 |
}
|
57 |
return $instance;
|
@@ -87,15 +93,15 @@ function widget_logic_expand_control()
|
|
87 |
{ list($key, $value)=split("\t",$import_option);
|
88 |
$wl_options[$key]=json_decode($value);
|
89 |
}
|
90 |
-
$wl_options['msg']=
|
91 |
}
|
92 |
else
|
93 |
-
{ $wl_options['msg']=
|
94 |
}
|
95 |
|
96 |
}
|
97 |
else
|
98 |
-
$wl_options['msg']=
|
99 |
|
100 |
update_option('widget_logic', $wl_options);
|
101 |
wp_redirect( admin_url('widgets.php') );
|
@@ -119,7 +125,7 @@ function widget_logic_expand_control()
|
|
119 |
if ( 'post' == strtolower($_SERVER['REQUEST_METHOD']) )
|
120 |
{ foreach ( (array) $_POST['widget-id'] as $widget_number => $widget_id )
|
121 |
if (isset($_POST[$widget_id.'-widget_logic']))
|
122 |
-
$wl_options[$widget_id]
|
123 |
|
124 |
// clean up empty options (in PHP5 use array_intersect_key)
|
125 |
$regd_plus_new=array_merge(array_keys($wp_registered_widgets),array_values((array) $_POST['widget-id']),
|
@@ -164,24 +170,24 @@ function widget_logic_options_control()
|
|
164 |
|
165 |
?><div class="wrap">
|
166 |
|
167 |
-
<h2
|
168 |
<form method="POST" style="float:left; width:45%">
|
169 |
<ul>
|
170 |
-
<li><label for="widget_logic-options-filter" title="Adds a new WP filter you can use in your own code. Not needed for main Widget Logic functionality.">
|
171 |
-
<input id="widget_logic-options-filter" name="widget_logic-options-filter" type="checkbox" value="checked" class="checkbox" <?php
|
172 |
-
Add 'widget_content' filter
|
173 |
</label>
|
174 |
</li>
|
175 |
-
<li><label for="widget_logic-options-wp_reset_query" title="Resets a theme's custom queries before your Widget Logic is checked">
|
176 |
-
<input id="widget_logic-options-wp_reset_query" name="widget_logic-options-wp_reset_query" type="checkbox" value="checked" class="checkbox" <?php
|
177 |
-
Use 'wp_reset_query' fix
|
178 |
</label>
|
179 |
</li>
|
180 |
-
<li><label for="widget_logic-options-load_point" title="Delays widget logic code being evaluated til various points in the WP loading process"
|
181 |
<select id="widget_logic-options-load_point" name="widget_logic-options-load_point" ><?php
|
182 |
foreach($wl_load_points as $action => $action_desc)
|
183 |
{ echo "<option value='".$action."'";
|
184 |
-
if ($action==$wl_options['widget_logic-options-load_point'])
|
185 |
echo " selected ";
|
186 |
echo ">".$action_desc."</option>"; //
|
187 |
}
|
@@ -190,16 +196,13 @@ function widget_logic_options_control()
|
|
190 |
</label>
|
191 |
</li>
|
192 |
</ul>
|
193 |
-
|
194 |
-
<?php submit_button( __( 'Save WL options' ), 'button-primary', 'widget_logic-options-submit', false ); ?>
|
195 |
|
196 |
</form>
|
197 |
<form method="POST" enctype="multipart/form-data" style="float:left; width:45%">
|
198 |
-
<a class="submit button" href="?wl-options-export" title="Save all WL options to a plain text config file"
|
199 |
-
<?php submit_button( __( 'Import options' ), 'button', 'wl-options-import', false,
|
200 |
-
|
201 |
-
) ); ?>
|
202 |
-
<input type="file" name="wl-options-import-file" id="wl-options-import-file" title="Select file for importing" /></p>
|
203 |
</form>
|
204 |
|
205 |
</div>
|
@@ -228,12 +231,12 @@ function widget_logic_extra_control()
|
|
228 |
|
229 |
// dealing with multiple widgets - get the number. if -1 this is the 'template' for the admin interface
|
230 |
$number=$params[0]['number'];
|
231 |
-
if ($number==-1) {$number="
|
232 |
$id_disp=$id;
|
233 |
if (isset($number)) $id_disp=$wp_registered_widget_controls[$id]['id_base'].'-'.$number;
|
234 |
|
235 |
// output our extra widget logic field
|
236 |
-
echo "<p><label for='".$id_disp."-widget_logic'>Widget logic <textarea class='widefat' type='text' name='".$id_disp."-widget_logic' id='".$id_disp."-widget_logic' >".$value."</textarea></label></p>";
|
237 |
}
|
238 |
|
239 |
|
@@ -264,9 +267,20 @@ function widget_logic_filter_sidebars_widgets($sidebars_widgets)
|
|
264 |
{ if ($widget_area=='wp_inactive_widgets' || empty($widget_list)) continue;
|
265 |
|
266 |
foreach($widget_list as $pos => $widget_id)
|
267 |
-
{
|
268 |
-
$wl_value=(
|
269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
if (!eval($wl_value))
|
271 |
unset($sidebars_widgets[$widget_area][$pos]);
|
272 |
}
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: Widget Logic
|
4 |
+
Plugin URI: http://wordpress.org/extend/plugins/widget-logic/
|
5 |
+
Description: Control widgets with WP's conditional tags is_home etc
|
6 |
+
Version: 0.54
|
7 |
+
Author: Alan Trewartha
|
8 |
+
Author URI: http://freakytrigger.co.uk/author/alan/
|
9 |
+
|
10 |
+
Text Domain: widget-logic
|
11 |
+
Domain Path: /languages/
|
12 |
*/
|
13 |
|
14 |
+
$plugin_dir = basename(dirname(__FILE__));
|
15 |
+
load_plugin_textdomain( 'widget-logic', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
16 |
+
|
17 |
global $wl_options;
|
18 |
+
$wl_load_points=array( 'plugins_loaded' => __( 'when plugin starts (default)', 'widget-logic' ),
|
19 |
+
'after_setup_theme' => __( 'after theme loads', 'widget-logic' ),
|
20 |
+
'wp_loaded' => __( 'when all PHP loaded', 'widget-logic' ),
|
21 |
+
'wp_head' => __( 'during page header', 'widget-logic' )
|
22 |
);
|
23 |
|
24 |
if((!$wl_options = get_option('widget_logic')) || !is_array($wl_options) ) $wl_options = array();
|
57 |
{ global $wl_options;
|
58 |
$widget_id=$this_widget->id;
|
59 |
if ( isset($_POST[$widget_id.'-widget_logic']))
|
60 |
+
{ $wl_options[$widget_id]=trim($_POST[$widget_id.'-widget_logic']);
|
61 |
update_option('widget_logic', $wl_options);
|
62 |
}
|
63 |
return $instance;
|
93 |
{ list($key, $value)=split("\t",$import_option);
|
94 |
$wl_options[$key]=json_decode($value);
|
95 |
}
|
96 |
+
$wl_options['msg']= __('Success! Options file imported','widget-logic');
|
97 |
}
|
98 |
else
|
99 |
+
{ $wl_options['msg']= __('Invalid options file','widget-logic');
|
100 |
}
|
101 |
|
102 |
}
|
103 |
else
|
104 |
+
$wl_options['msg']= __('No options file provided','widget-logic');
|
105 |
|
106 |
update_option('widget_logic', $wl_options);
|
107 |
wp_redirect( admin_url('widgets.php') );
|
125 |
if ( 'post' == strtolower($_SERVER['REQUEST_METHOD']) )
|
126 |
{ foreach ( (array) $_POST['widget-id'] as $widget_number => $widget_id )
|
127 |
if (isset($_POST[$widget_id.'-widget_logic']))
|
128 |
+
$wl_options[$widget_id]=trim($_POST[$widget_id.'-widget_logic']);
|
129 |
|
130 |
// clean up empty options (in PHP5 use array_intersect_key)
|
131 |
$regd_plus_new=array_merge(array_keys($wp_registered_widgets),array_values((array) $_POST['widget-id']),
|
170 |
|
171 |
?><div class="wrap">
|
172 |
|
173 |
+
<h2><?php _e('Widget Logic options', 'widget-logic'); ?></h2>
|
174 |
<form method="POST" style="float:left; width:45%">
|
175 |
<ul>
|
176 |
+
<li><label for="widget_logic-options-filter" title="<?php _e('Adds a new WP filter you can use in your own code. Not needed for main Widget Logic functionality.', 'widget-logic'); ?>">
|
177 |
+
<input id="widget_logic-options-filter" name="widget_logic-options-filter" type="checkbox" value="checked" class="checkbox" <?php if (isset($wl_options['widget_logic-options-filter'])) echo "checked" ?>/>
|
178 |
+
<?php _e('Add \'widget_content\' filter', 'widget-logic'); ?>
|
179 |
</label>
|
180 |
</li>
|
181 |
+
<li><label for="widget_logic-options-wp_reset_query" title="<?php _e('Resets a theme\'s custom queries before your Widget Logic is checked', 'widget-logic'); ?>">
|
182 |
+
<input id="widget_logic-options-wp_reset_query" name="widget_logic-options-wp_reset_query" type="checkbox" value="checked" class="checkbox" <?php if (isset($wl_options['widget_logic-options-wp_reset_query'])) echo "checked" ?> />
|
183 |
+
<?php _e('Use \'wp_reset_query\' fix', 'widget-logic'); ?>
|
184 |
</label>
|
185 |
</li>
|
186 |
+
<li><label for="widget_logic-options-load_point" title="<?php _e('Delays widget logic code being evaluated til various points in the WP loading process', 'widget-logic'); ?>"><?php _e('Load logic', 'widget-logic'); ?>
|
187 |
<select id="widget_logic-options-load_point" name="widget_logic-options-load_point" ><?php
|
188 |
foreach($wl_load_points as $action => $action_desc)
|
189 |
{ echo "<option value='".$action."'";
|
190 |
+
if (isset($wl_options['widget_logic-options-load_point']) && $action==$wl_options['widget_logic-options-load_point'])
|
191 |
echo " selected ";
|
192 |
echo ">".$action_desc."</option>"; //
|
193 |
}
|
196 |
</label>
|
197 |
</li>
|
198 |
</ul>
|
199 |
+
<?php submit_button( __( 'Save WL options', 'widget-logic' ), 'button-primary', 'widget_logic-options-submit', false ); ?>
|
|
|
200 |
|
201 |
</form>
|
202 |
<form method="POST" enctype="multipart/form-data" style="float:left; width:45%">
|
203 |
+
<a class="submit button" href="?wl-options-export" title="<?php _e('Save all WL options to a plain text config file', 'widget-logic'); ?>"><?php _e('Export options', 'widget-logic'); ?></a><p>
|
204 |
+
<?php submit_button( __( 'Import options', 'widget-logic' ), 'button', 'wl-options-import', false, array('title'=> __( 'Load all WL options from a plain text config file', 'widget-logic' ) ) ); ?>
|
205 |
+
<input type="file" name="wl-options-import-file" id="wl-options-import-file" title="<?php _e('Select file for importing', 'widget-logic'); ?>" /></p>
|
|
|
|
|
206 |
</form>
|
207 |
|
208 |
</div>
|
231 |
|
232 |
// dealing with multiple widgets - get the number. if -1 this is the 'template' for the admin interface
|
233 |
$number=$params[0]['number'];
|
234 |
+
if ($number==-1) {$number="XXX"; $value="";}
|
235 |
$id_disp=$id;
|
236 |
if (isset($number)) $id_disp=$wp_registered_widget_controls[$id]['id_base'].'-'.$number;
|
237 |
|
238 |
// output our extra widget logic field
|
239 |
+
echo "<p><label for='".$id_disp."-widget_logic'>Widget logic: <textarea class='widefat' type='text' name='".$id_disp."-widget_logic' id='".$id_disp."-widget_logic' >".$value."</textarea></label></p>";
|
240 |
}
|
241 |
|
242 |
|
267 |
{ if ($widget_area=='wp_inactive_widgets' || empty($widget_list)) continue;
|
268 |
|
269 |
foreach($widget_list as $pos => $widget_id)
|
270 |
+
{ if (empty($wl_options[$widget_id])) continue;
|
271 |
+
$wl_value=stripslashes(trim($wl_options[$widget_id]));
|
272 |
+
if (empty($wl_value)) continue;
|
273 |
+
|
274 |
+
$wl_value=apply_filters( "widget_logic_eval_override", $wl_value );
|
275 |
+
if ($wl_value===false)
|
276 |
+
{ unset($sidebars_widgets[$widget_area][$pos]);
|
277 |
+
continue;
|
278 |
+
}
|
279 |
+
if ($wl_value===true) continue;
|
280 |
+
|
281 |
+
if (stristr($wl_value,"return")===false)
|
282 |
+
$wl_value="return (" . $wl_value . ");";
|
283 |
+
|
284 |
if (!eval($wl_value))
|
285 |
unset($sidebars_widgets[$widget_area][$pos]);
|
286 |
}
|