=' ) && !file_exists(WP_PLUGIN_DIR.'/limit-login-attempts-reloaded') && current_user_can('install_plugins') ) { $alert = (array)get_option( 'wpchefgadget_alert', array() ); if ( empty( $alert['limit-login-attempts'] ) ) { add_action( 'admin_notices', 'widget_logic_alert'); add_action( 'network_admin_notices', 'widget_logic_alert'); add_action( 'wp_ajax_wpchefgadget_dismiss_alert', 'widget_logic_dismiss_alert' ); add_action( 'admin_enqueue_scripts', 'widget_logic_alert_scripts' ); } //enqueue admin/js/updates.js } } */ } if((!$wl_options = get_option('widget_logic')) || !is_array($wl_options) ) $wl_options = array(); if (is_admin()) { add_filter( 'in_widget_form', 'widget_logic_in_widget_form', 10, 3 ); add_filter( 'widget_update_callback', 'widget_logic_update_callback', 10, 4); add_action( 'sidebar_admin_setup', 'widget_logic_expand_control'); // before any HTML output save widget changes and add controls to each widget on the widget admin page add_action( 'sidebar_admin_page', 'widget_logic_options_control'); // add Widget Logic specific options on the widget admin page add_filter( 'plugin_action_links', 'wl_charity', 10, 2);// add my justgiving page link to the plugin admin page add_action( 'widgets_init', 'widget_logic_add_controls', 999 ); } else { $loadpoint = isset($wl_options['widget_logic-options-load_point']) ? (string)@$wl_options['widget_logic-options-load_point'] : ''; if ( 'plugins_loaded' == $loadpoint ) widget_logic_sidebars_widgets_filter_add(); else { if ( !in_array( $loadpoint, array( 'after_setup_theme', 'wp_loaded', 'wp_head' ) ) ) $loadpoint = 'parse_query'; add_action( $loadpoint, 'widget_logic_sidebars_widgets_filter_add' ); } if ( !empty($wl_options['widget_logic-options-filter']) ) add_filter( 'dynamic_sidebar_params', 'widget_logic_widget_display_callback', 10); // redirect the widget callback so the output can be buffered and filtered } function widget_logic_in_customizer() { global $wl_in_customizer; $wl_in_customizer = true; //add_filter( 'widget_display_callback', 'widget_logic_customizer_display_callback', 10, 3 ); add_action( 'dynamic_sidebar', 'widget_logic_customizer_dynamic_sidebar_callback' ); } add_action( 'customize_preview_init', 'widget_logic_in_customizer' ); function widget_logic_sidebars_widgets_filter_add() { // actually remove the widgets from the front end depending on widget logic provided add_filter( 'sidebars_widgets', 'widget_logic_filter_sidebars_widgets', 10); } // wp-admin/widgets.php explicitly checks current_user_can('edit_theme_options') // which is enough security, I believe. If you think otherwise please contact me // CALLED VIA 'widget_update_callback' FILTER (ajax update of a widget) function widget_logic_update_callback( $instance, $new_instance, $old_instance, $this_widget ) { if ( isset( $new_instance['widget_logic'] ) ) $instance['widget_logic'] = $new_instance['widget_logic']; return $instance; } // CALLED VIA 'sidebar_admin_setup' ACTION // adds in the admin control per widget, but also processes import/export function widget_logic_expand_control() { global $wp_registered_widgets, $wp_registered_widget_controls, $wl_options; // EXPORT ALL OPTIONS if (isset($_GET['wl-options-export'])) { header("Content-Disposition: attachment; filename=widget_logic_options.txt"); header('Content-Type: text/plain; charset=utf-8'); echo "[START=WIDGET LOGIC OPTIONS]\n"; foreach ($wl_options as $id => $text) echo "$id\t".json_encode($text)."\n"; echo "[STOP=WIDGET LOGIC OPTIONS]"; exit; } // IMPORT ALL OPTIONS if ( isset($_POST['wl-options-import'])) { if ($_FILES['wl-options-import-file']['tmp_name']) { $import=explode("\n",file_get_contents($_FILES['wl-options-import-file']['tmp_name'], false)); if (array_shift($import)=="[START=WIDGET LOGIC OPTIONS]" && array_pop($import)=="[STOP=WIDGET LOGIC OPTIONS]") { foreach ($import as $import_option) { list($key, $value)=explode("\t",$import_option); $wl_options[$key]=json_decode($value); } $wl_options['msg']= __('Success! Options file imported','widget-logic'); } else { $wl_options['msg']= __('Invalid options file','widget-logic'); } } else $wl_options['msg']= __('No options file provided','widget-logic'); update_option('widget_logic', $wl_options); wp_redirect( admin_url('widgets.php') ); exit; } // UPDATE OTHER WIDGET LOGIC OPTIONS // must update this to use http://codex.wordpress.org/Settings_API if ( isset($_POST['widget_logic-options-submit']) ) { $wl_options['widget_logic-options-filter'] = !empty($_POST['widget_logic-options-filter']); $wl_options['widget_logic-options-wp_reset_query'] = !empty($_POST['widget_logic-options-wp_reset_query']); $wl_options['widget_logic-options-show_errors'] = !empty($_POST['widget_logic-options-show_errors']); $wl_options['widget_logic-options-load_point']=$_POST['widget_logic-options-load_point']; } update_option('widget_logic', $wl_options); } // CALLED VIA 'sidebar_admin_page' ACTION // output extra HTML // to update using http://codex.wordpress.org/Settings_API asap function widget_logic_options_control() { global $wp_registered_widget_controls, $wl_options; if ( isset($wl_options['msg'])) { if (substr($wl_options['msg'],0,2)=="OK") echo '
Widget Logic – '.$wl_options['msg'].'
is_preview() ): ?>
%s', esc_attr(admin_url('widgets.php')), __('widgets') ) ) ?>
id != 'plugin-install' ) echo ' id="plugin-filter"' ?>> Widget Logic team security recommendation only! If your site is currently not protected (check with your admin) against login attacks (the most common reason admin login gets compromised) we highly recommend installing Limit Login Attempts Reloaded plugin to immediately have the protection in place. Install