Commit 07385115 authored by lucha's avatar lucha Committed by lechuck

Widget Logic 0.56

parent 5052c45a
# Translation of Widget Logic in German
# This file is distributed under the same license as the Widget Logic package.
msgid ""
msgstr ""
"PO-Revision-Date: 2012-12-17 22:14:30+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: GlotPress/0.1\n"
"Project-Id-Version: Widget Logic\n"
#: widget_logic.php:96
msgid "Success! Options file imported"
msgstr "Erfolg! Options-Datei importiert"
#: widget_logic.php:99
msgid "Invalid options file"
msgstr "Ungültige Options-Datei"
#: widget_logic.php:104
msgid "No options file provided"
msgstr "Keine Options-Datei aufgewählt"
#: widget_logic.php:5
msgid "Control widgets with WP's conditional tags is_home etc"
msgstr "Steuere Widgets mit WP's Bedingungs-Tags. Wie etwa is_home, etc."
#: widget_logic.php:204
msgid "Load all WL options from a plain text config file"
msgstr "WL Optionen aus einer Textdatei importieren"
#: widget_logic.php:20
msgid "when all PHP loaded"
msgstr "wenn PHP geladen ist"
#: widget_logic.php:21
msgid "during page header"
msgstr "im Seiten HEADER"
#: widget_logic.php:178
msgid "Add 'widget_content' filter"
msgstr "'widget_content' Filter hinzufügen"
#: widget_logic.php:183
msgid "Use 'wp_reset_query' fix"
msgstr "Nutze 'wp_reset_query' Fix"
#: widget_logic.php:18
msgid "when plugin starts (default)"
msgstr "wenn Plugin startet (Standard)"
#: widget_logic.php:19
msgid "after theme loads"
msgstr "nachdem Theme geladen wurde"
#: widget_logic.php:173
msgid "Widget Logic options"
msgstr "Widget Logic Optionen"
#: widget_logic.php:176
msgid "Adds a new WP filter you can use in your own code. Not needed for main Widget Logic functionality."
msgstr "Fügt einen neuen WP Filter hinzu den du in deinem eigenen Code nutzen kannst. Keine Widget Logic Nutzung nötig."
#: widget_logic.php:181
msgid "Resets a theme's custom queries before your Widget Logic is checked"
msgstr "Setzt die Custom Queries eines Themes zurück bevor deine Widget Logic ausgeführt wird"
#: widget_logic.php:186
msgid "Delays widget logic code being evaluated til various points in the WP loading process"
msgstr "Verzögert die Bearbeitung durch die Widget Logic bis an verschiedene Punkte des WP Ladevorgangs"
#: widget_logic.php:186
msgid "Load logic"
msgstr "Logik laden"
#: widget_logic.php:199
msgid "Save WL options"
msgstr "WL Optionen speichern"
#: widget_logic.php:203
msgid "Export options"
msgstr "Optionen exportieren"
#: widget_logic.php:203
msgid "Save all WL options to a plain text config file"
msgstr "WL Optionen in einer Textdatei speichern"
#: widget_logic.php:204
msgid "Import options"
msgstr "Optionen importieren"
#: widget_logic.php:205
msgid "Select file for importing"
msgstr "Wähle eine Datei für den Import"
\ No newline at end of file
msgid ""
msgstr ""
"Project-Id-Version: Widget Logic en español\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-12-20 11:32+0100\n"
"PO-Revision-Date: 2012-12-20 11:32+0100\n"
"Last-Translator: Eduardo Larequi <elarequi@gmail.com>\n"
"Language-Team: PNTE <blogs@educacion.navarra.es>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_c;_n:1,2;esc_html__;esc_html_e;esc_attr__;esc_attr_e\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-Language: Spanish\n"
"X-Poedit-Country: Spain\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Poedit-SearchPath-0: .\n"
#: widget_logic.php:18
msgid "when plugin starts (default)"
msgstr "Cuando se inicia el plugin (por defecto)"
#: widget_logic.php:19
msgid "after theme loads"
msgstr "Cuando se carga el tema"
#: widget_logic.php:20
msgid "when all PHP loaded"
msgstr "Cuando se ha cargado todo el código PHP"
#: widget_logic.php:21
msgid "during page header"
msgstr "Durante la carga de la cabecera de la página"
#: widget_logic.php:96
msgid "Success! Options file imported"
msgstr "El fichero de opciones se ha importado con éxito"
#: widget_logic.php:99
msgid "Invalid options file"
msgstr "Fichero de opciones no válido"
#: widget_logic.php:104
msgid "No options file provided"
msgstr "No se ha proporcionado un fichero de opciones"
#: widget_logic.php:173
msgid "Widget Logic options"
msgstr "Opciones de Widget Logic"
#: widget_logic.php:176
msgid "Adds a new WP filter you can use in your own code. Not needed for main Widget Logic functionality."
msgstr "Añade un nuevo filtro de WordPress que puedes utilizar en tu propio código. No es necesario para conseguir la funcionalidad básica de Widget Logic."
#: widget_logic.php:178
msgid "Add 'widget_content' filter"
msgstr "Añadir el filtro 'widget_content'"
#: widget_logic.php:181
msgid "Resets a theme's custom queries before your Widget Logic is checked"
msgstr "Reinicia las consultas personalizadas de un tema antes de que se verifique la lógica del widget."
#: widget_logic.php:183
msgid "Use 'wp_reset_query' fix"
msgstr "Utilizar 'wp_reset_query'"
#: widget_logic.php:186
msgid "Delays widget logic code being evaluated til various points in the WP loading process"
msgstr "Retarda la evaluación del código de Widget Logic hasta determinados puntos del proceso de carga de WordPress"
#: widget_logic.php:186
msgid "Load logic"
msgstr "Cargar las condiciones"
#: widget_logic.php:199
msgid "Save WL options"
msgstr "Guardar opciones de Widget Logic"
#: widget_logic.php:203
msgid "Save all WL options to a plain text config file"
msgstr "Permite guardar todas las opciones del plugin Widget Logic en un fichero de configuración en texto plano"
#: widget_logic.php:203
msgid "Export options"
msgstr "Exportar opciones"
#: widget_logic.php:204
msgid "Import options"
msgstr "Importar opciones"
#: widget_logic.php:204
msgid "Load all WL options from a plain text config file"
msgstr "Permite cargar todas las opciones del plugin Widget Logic desde un fichero de configuración en texto plano"
#: widget_logic.php:205
msgid "Select file for importing"
msgstr "Seleccionar fichero para importar"
#~ msgid "Widget logic"
#~ msgstr "Condiciones del widget"
#~ msgid "Save"
#~ msgstr "Guardar"
# Copyright (C) 2012
# This file is distributed under the same license as the package.
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: http://wordpress.org/tag/wp\n"
"POT-Creation-Date: 2012-12-17 22:12:06+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2012-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
#: widget_logic.php:5
msgid "Control widgets with WP's conditional tags is_home etc"
msgstr ""
#: widget_logic.php:18
msgid "when plugin starts (default)"
msgstr ""
#: widget_logic.php:19
msgid "after theme loads"
msgstr ""
#: widget_logic.php:20
msgid "when all PHP loaded"
msgstr ""
#: widget_logic.php:21
msgid "during page header"
msgstr ""
#: widget_logic.php:96
msgid "Success! Options file imported"
msgstr ""
#: widget_logic.php:99
msgid "Invalid options file"
msgstr ""
#: widget_logic.php:104
msgid "No options file provided"
msgstr ""
#: widget_logic.php:173
msgid "Widget Logic options"
msgstr ""
#: widget_logic.php:176
msgid ""
"Adds a new WP filter you can use in your own code. Not needed for main "
"Widget Logic functionality."
msgstr ""
#: widget_logic.php:178
msgid "Add 'widget_content' filter"
msgstr ""
#: widget_logic.php:181
msgid "Resets a theme's custom queries before your Widget Logic is checked"
msgstr ""
#: widget_logic.php:183
msgid "Use 'wp_reset_query' fix"
msgstr ""
#: widget_logic.php:186
msgid ""
"Delays widget logic code being evaluated til various points in the WP "
"loading process"
msgstr ""
#: widget_logic.php:186
msgid "Load logic"
msgstr ""
#: widget_logic.php:199
msgid "Save WL options"
msgstr ""
#: widget_logic.php:203
msgid "Save all WL options to a plain text config file"
msgstr ""
#: widget_logic.php:203
msgid "Export options"
msgstr ""
#: widget_logic.php:204
msgid "Import options"
msgstr ""
#: widget_logic.php:204
msgid "Load all WL options from a plain text config file"
msgstr ""
#: widget_logic.php:205
msgid "Select file for importing"
msgstr ""
......@@ -3,15 +3,16 @@ Contributors: alanft
Donate link: http://www.justgiving.com/widgetlogic_cancerresearchuk
Tags: widget, admin, conditional tags, filter, context
Requires at least: 2.8
Tested up to: 3.3.2
Stable tag: 0.52
Tested up to: 3.5
Stable tag: 0.56
License: GPLv2 or later
Widget Logic lets you control on which pages widgets appear using WP's conditional tags. It also adds a 'widget_content' filter.
== Description ==
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.
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. If you are worried about the security implications, please let me know how you think I could guard against this without compromising the general power and flexibility of Widget Logic too much.
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/)).
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.
......@@ -19,6 +20,10 @@ There is also an option to add a wordpress 'widget_content' filter -- this lets
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.
= Translate =
Social Translation: [https://translate.foe-services.de](https://translate.foe-services.de)
== Installation ==
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
Note the extra ';' on the end where there is an explicit 'return'.
== The 'widget_logic_eval_override' filter ==
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.
== The 'widget_content' filter ==
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,26 @@ function make_alternating_widget_styles($content='')
== Changelog ==
= 0.56 =
Small fix to the original WP3.5 fix in 0.54 that had the side effect of failing to save logic text on newly added widgets.
= 0.55 =
Restored a striplashes that vanished in 0.54 causing much grief.
Translation: Spanish by Eduardo Larequi http://wordpress.org/support/profile/elarequi
= 0.54 =
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.
= 0.53 =
Accidentally released code with a terrible bug in it :-(
= 0.52 =
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
......
<?php
/*
Plugin Name: Widget Logic
Plugin URI: http://freakytrigger.co.uk/wordpress-setup/
Description: Control widgets with WP's conditional tags is_home etc
Author: Alan Trewartha
Version: 0.52
Author URI: http://freakytrigger.co.uk/author/alan/
Plugin Name: Widget Logic
Plugin URI: http://wordpress.org/extend/plugins/widget-logic/
Description: Control widgets with WP's conditional tags is_home etc
Version: 0.56
Author: Alan Trewartha
Author URI: http://freakytrigger.co.uk/author/alan/
Text Domain: widget-logic
Domain Path: /languages/
*/
$plugin_dir = basename(dirname(__FILE__));
load_plugin_textdomain( 'widget-logic', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
global $wl_options;
$wl_load_points=array( 'plugins_loaded' => 'when plugin starts (default)',
'after_setup_theme'=> 'after theme loads',
'wp_loaded' => 'when all PHP loaded',
'wp_head'=> 'during page header'
$wl_load_points=array( 'plugins_loaded' => __( 'when plugin starts (default)', 'widget-logic' ),
'after_setup_theme' => __( 'after theme loads', 'widget-logic' ),
'wp_loaded' => __( 'when all PHP loaded', 'widget-logic' ),
'wp_head' => __( 'during page header', 'widget-logic' )
);
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
{ global $wl_options;
$widget_id=$this_widget->id;
if ( isset($_POST[$widget_id.'-widget_logic']))
{ $wl_options[$widget_id]=$_POST[$widget_id.'-widget_logic'];
{ $wl_options[$widget_id]=trim($_POST[$widget_id.'-widget_logic']);
update_option('widget_logic', $wl_options);
}
return $instance;
......@@ -87,15 +93,15 @@ function widget_logic_expand_control()
{ list($key, $value)=split("\t",$import_option);
$wl_options[$key]=json_decode($value);
}
$wl_options['msg']="OK – options file imported";
$wl_options['msg']= __('Success! Options file imported','widget-logic');
}
else
{ $wl_options['msg']="Invalid options file";
{ $wl_options['msg']= __('Invalid options file','widget-logic');
}
}
else
$wl_options['msg']="No options file provided";
$wl_options['msg']= __('No options file provided','widget-logic');
update_option('widget_logic', $wl_options);
wp_redirect( admin_url('widgets.php') );
......@@ -119,7 +125,7 @@ function widget_logic_expand_control()
if ( 'post' == strtolower($_SERVER['REQUEST_METHOD']) )
{ foreach ( (array) $_POST['widget-id'] as $widget_number => $widget_id )
if (isset($_POST[$widget_id.'-widget_logic']))
$wl_options[$widget_id]=$_POST[$widget_id.'-widget_logic'];
$wl_options[$widget_id]=trim($_POST[$widget_id.'-widget_logic']);
// clean up empty options (in PHP5 use array_intersect_key)
$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()
?><div class="wrap">
<h2>Widget Logic options</h2>
<h2><?php _e('Widget Logic options', 'widget-logic'); ?></h2>
<form method="POST" style="float:left; width:45%">
<ul>
<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.">
<input id="widget_logic-options-filter" name="widget_logic-options-filter" type="checkbox" value="checked" class="checkbox" <?php echo $wl_options['widget_logic-options-filter'] ?>/>
Add 'widget_content' filter
<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'); ?>">
<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" ?>/>
<?php _e('Add \'widget_content\' filter', 'widget-logic'); ?>
</label>
</li>
<li><label for="widget_logic-options-wp_reset_query" title="Resets a theme's custom queries before your Widget Logic is checked">
<input id="widget_logic-options-wp_reset_query" name="widget_logic-options-wp_reset_query" type="checkbox" value="checked" class="checkbox" <?php echo $wl_options['widget_logic-options-wp_reset_query'] ?> />
Use 'wp_reset_query' fix
<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'); ?>">
<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" ?> />
<?php _e('Use \'wp_reset_query\' fix', 'widget-logic'); ?>
</label>
</li>
<li><label for="widget_logic-options-load_point" title="Delays widget logic code being evaluated til various points in the WP loading process">Load logic
<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'); ?>
<select id="widget_logic-options-load_point" name="widget_logic-options-load_point" ><?php
foreach($wl_load_points as $action => $action_desc)
{ echo "<option value='".$action."'";
if ($action==$wl_options['widget_logic-options-load_point'])
if (isset($wl_options['widget_logic-options-load_point']) && $action==$wl_options['widget_logic-options-load_point'])
echo " selected ";
echo ">".$action_desc."</option>"; //
}
......@@ -190,16 +196,13 @@ function widget_logic_options_control()
</label>
</li>
</ul>
<?php submit_button( __( 'Save WL options' ), 'button-primary', 'widget_logic-options-submit', false ); ?>
<?php submit_button( __( 'Save WL options', 'widget-logic' ), 'button-primary', 'widget_logic-options-submit', false ); ?>
</form>
<form method="POST" enctype="multipart/form-data" style="float:left; width:45%">
<a class="submit button" href="?wl-options-export" title="Save all WL options to a plain text config file">Export options</a><p>
<?php submit_button( __( 'Import options' ), 'button', 'wl-options-import', false,
array( 'title'=>'Load all WL options from a plain text config file'
) ); ?>
<input type="file" name="wl-options-import-file" id="wl-options-import-file" title="Select file for importing" /></p>
<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>
<?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' ) ) ); ?>
<input type="file" name="wl-options-import-file" id="wl-options-import-file" title="<?php _e('Select file for importing', 'widget-logic'); ?>" /></p>
</form>
</div>
......@@ -228,12 +231,12 @@ function widget_logic_extra_control()
// dealing with multiple widgets - get the number. if -1 this is the 'template' for the admin interface
$number=$params[0]['number'];
if ($number==-1) {$number="%i%"; $value="";}
if ($number==-1) {$number="__i__"; $value="";}
$id_disp=$id;
if (isset($number)) $id_disp=$wp_registered_widget_controls[$id]['id_base'].'-'.$number;
// output our extra widget logic field
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>";
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>";
}
......@@ -264,9 +267,20 @@ function widget_logic_filter_sidebars_widgets($sidebars_widgets)
{ if ($widget_area=='wp_inactive_widgets' || empty($widget_list)) continue;
foreach($widget_list as $pos => $widget_id)
{
$wl_value=(!empty($wl_options[$widget_id]))? stripslashes($wl_options[$widget_id]) : "true";
$wl_value =(stristr($wl_value,"return"))? $wl_value: "return (" . $wl_value . ");";
{ if (empty($wl_options[$widget_id])) continue;
$wl_value=stripslashes(trim($wl_options[$widget_id]));
if (empty($wl_value)) continue;
$wl_value=apply_filters( "widget_logic_eval_override", $wl_value );
if ($wl_value===false)
{ unset($sidebars_widgets[$widget_area][$pos]);
continue;
}
if ($wl_value===true) continue;
if (stristr($wl_value,"return")===false)
$wl_value="return (" . $wl_value . ");";
if (!eval($wl_value))
unset($sidebars_widgets[$widget_area][$pos]);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment