'http://wordpress.org/extend/plugins/advanced-text-widget/', //plugin page on wp.org 'official_url' => 'http://wordpress.org/extend/plugins/advanced-text-widget/', //plugin page on author's website 'author_url' => 'http://wordpress.org/extend/plugins/profile/maxchirkov', 'sponsored_by' => 'SimpleRealtyTheme.com', 'forums_url' => 'http://wordpress.org/tags/advanced-text-widget?forum_id=10', ); var $default_options = array( 'condition' => array( array( 'name' => 'All', 'code' => 'true', ), array( 'name' => 'Home Page', 'code' => 'is_home()', ), array( 'name' => 'Front Page', 'code' => 'is_front_page()', ), array( 'name' => 'Page', 'code' => 'is_page($arg)', ), array( 'name' => 'Single Post', 'code' => 'is_single($arg)', ), array( 'name' => 'Post in Category', 'code' => 'in_category($arg)', ), array( 'name' => 'Category', 'code' => 'is_category($arg)', ), array( 'name' => 'Blog', 'code' => 'is_home() || is_single() || is_archive()', ), array( 'name' => 'Search Results Page', 'code' => 'is_search()', ), array( 'name' => 'Child of Page ID', 'code' => '(int)$arg == $post->post_parent', ), ) ); function __construct() { if (isset($_POST['reset-atw-settings']) && $_POST['reset-atw-settings'] == 1) { update_option($this->optionname, $this->default_options); } parent::__construct(); } function localize(){ $this->set_longname(__('Advanced Text Widget Options', $this->hook)); $this->set_shortname(__('ATW Plugin', $this->hook)); //$this->set_var( 'longname', __('Advanced Text Widget Options', $this->hook) ); } //update from old widgets to new function auto_update(){ if($widgets = get_option('widget_advanced_text')){ $convert = array( 'all' => 0, 'home' => 1, 'post' => 4, 'post_in_category' => 5, 'page' => 3, 'category' => 6, 'blog' => 7, 'search' => 8, ); $new_widgets = $widgets; //check is any 'show' keys have numeric values $update = false; foreach($new_widgets as $key => $widget){ if(isset($widget['show']) && !is_numeric($widget['show'])){ $new_widgets[$key]['show'] = $convert[$widget['show']]; $update = true; } } if($update){ update_option('widget_advanced_text', $new_widgets); add_option('widget_advanced_text_old'); update_option('widget_advanced_text_old', $widgets); } } } function settings($key = null){ $add_button = array( //'label' => __('Add New Condition'), 'id' => 'condition-add-new', 'type' => 'input', 'attr' => array('type' => 'button', 'value' => __('Add New Condition', $this->hook), 'class' => 'button'), ); $conditions = array( array( 'label' => sprintf(__('Name %d', $this->hook), 1), 'id' => array('condition', 0, 'name'), 'type' => 'text', 'attr' => array('size' => 30), ), array( 'label' => sprintf(__('Code %d', $this->hook), 1), 'id' => array('condition', 0, 'code'), 'type' => 'text', 'attr' => array('size' => 60), ), $add_button ); $options = $this->options; if(!empty($options)) { if(isset($options['condition'][0])) { $conditions = array(); foreach($options['condition'] as $k => $item) { $n = $k + 1; $conditions[] = array( 'label' => sprintf(__('Name %d', $this->hook), $n), 'id' => array('condition', $k, 'name'), 'type' => 'text', 'attr' => array('size' => 30), 'default' => $item['name'], ); $conditions[] = array( 'label' => sprintf(__('Code %d', $this->hook), $n), 'id' => array('condition', $k, 'code'), 'type' => 'text', 'attr' => array('size' => 60), 'default' => $item['code'], ); } $conditions[] = $add_button; } } $settings = array( 'Widget Visibility Conditions' => $conditions, ); $settings = apply_filters('atw_settings_array', $settings); if($key){ return $settings[$key]; } //settings have to return a regular array of fields - no section foreach($settings as $section => $fields){ foreach($fields as $field){ $settings_array[] = $field; } } return $settings_array; } function validate_input($input){ foreach($input['condition'] as $k => $v){ if(empty($v['name']) && empty($v['code'])) unset($input['condition'][$k]); } return $input; } function config_page(){ $this->add_column(1, '69%'); $this->add_box(__('Widget Visibility Conditions', $this->hook), $this->settings('Widget Visibility Conditions'), 1); do_action('atw_add_boxes'); //$this->add_box('Misc. Settings', $this->settings('Misc. Settings'), 1); //Generate Config Page $this->_config_page_template(); $this->resetForm(); } function resetForm() { ?>
'; $content .= sprintf(__('Check out Advanced Text Widget PRO! - it\'s inexpensive and comes with great features.', $this->hook), 'http://simplerealtytheme.com/plugins/atw-pro/'); $content .= ''; $buy_pro = $this->postbox(__('Get Advanced Text Widget PRO!', $this->hook), $content, $this->hook.'donate'); $buy_pro = apply_filters('atw_get_pro_version', $buy_pro); return $buy_pro; } function credits_column(){ $output = $this->plugin_like(); $output .= $this->plugin_donate(); $output .= $this->plugin_support(); $output .= $this->plugin_credits(); return $output; } function contextual_help() { $contextual_help = '

Advanced Text Widget Help

All code is executed inside this condition: IF( YOUR CODE ){ return TRUE; }else{ return FALSE; }. So make sure your code doesn\'t break the IF section.

If your condition supports arguments (page id, slug, title), then use variable $arg for a single function, and $argN for multiple functions, where N is a number.
Example 1: is_single($arg). Example 2: is_single($arg1) && !in_category($arg2). When using multiple arguments that are assigned to different functions, you can divide their values with pipe symbol "|" when entering into the Slug/Title/ID filed on the widgets page. Multiple arguments that belong to the same function should be delimited by comma.

Please note that each $arg is exploded and executed as an array.
For example: is_single($arg) is executed as is_single(explode(",", $arg)).

For mor details on functions that you can use read WP Codex on Conditional Tags

'; return $contextual_help; } }