One instance of ATW Plugin is already active. Please de-activate it before activating current version.

'; deactivate_plugins( plugin_basename( __FILE__ ) ); } add_action('admin_notices', 'atw_plugin_exists_notice'); } else { define("ATW_BASENAME", plugin_basename(dirname(__FILE__))); define("ATW_DIR", WP_PLUGIN_DIR . '/' . ATW_BASENAME); define("ATW_URL", WP_PLUGIN_URL . '/' . ATW_BASENAME); define("ATW_LIB", ATW_DIR . '/lib'); require_once('options/options.php'); $atw = new atw_Admin(); // $atw->auto_update(); register_activation_hook( __FILE__, array($atw, 'plugin_activate')); if( defined('ATW_PRO') ){ include_once ATW_PRO . '/init.php'; } class advanced_text extends WP_Widget { function __construct() { global $atw; /* Widget settings. */ $widget_ops = array( 'classname' => 'advanced_text', 'description' => __("Advanced text widget with PHP code support.", $atw->hook) ); /* Widget control settings. */ $control_ops = array( 'width' => 400, 'height' => 450, 'id_base' => 'advanced_text' ); /* Create the widget. */ parent::__construct('advanced_text', __("Advanced Text", $atw->hook), $widget_ops, $control_ops ); } function form($instance) { global $atw; $title = ( isset($instance['title']) ) ? esc_attr( $instance['title'] ) : false; $title = apply_filters('widget_title', $title); $text = ( isset($instance['text']) ) ? $instance['text'] : false; ?>

hook);?>

run_shortcode($text); $text = apply_filters( 'atw_widget_content', $text, $instance ); echo $before_widget; echo "
"; $title ? print($before_title . $title . $after_title) : null; eval('?>'.$text); echo "
"; echo $after_widget."\n"; } } function advanced_text_do_shortcode(){ if (!is_admin()){ add_filter('widget_text', 'do_shortcode', 12); add_filter('atw_widget_content', 'shortcode_unautop'); add_filter('atw_widget_content', 'do_shortcode', 12); } } // Tell Dynamic Sidebar about our new widget and its control add_action('widgets_init', create_function('', 'return register_widget("advanced_text");')); add_action('widgets_init', 'advanced_text_do_shortcode'); function atw_admin_scripts(){ $page = (isset($_GET['page'])) ? esc_attr($_GET['page']) : false; if ( 'atw' == $page ){ wp_enqueue_script('postbox'); wp_enqueue_script('dashboard'); wp_enqueue_style('dashboard'); wp_enqueue_style('global'); wp_enqueue_style('wp-admin'); wp_register_script( 'atw', ATW_URL . '/js/scripts.js'); wp_enqueue_script( 'atw' ); } } add_action('admin_init', 'atw_admin_scripts'); add_action('atw_condition_fields', 'atw_add_condition_fields', 10, 2); function atw_add_condition_fields($widget, $instance = false){ global $atw; $output = false; //check if conditions should apply to ATW only if( defined('ATW_PRO') && atw_only() ){ if( 'advanced_text' !== get_class($widget) ) return; } if(!$instance && is_numeric($widget->number)){ $widget_settings = get_option($widget->option_name); $instance = $widget_settings[$widget->number]; } $instance['action'] = (isset($instance['action'])) ? $instance['action'] : 1; $instance['slug'] = (isset($instance['slug'])) ? $instance['slug'] : false; $instance['suppress_title'] = (isset($instance['suppress_title'])) ? $instance['suppress_title'] : false; $allSelected = $dontshowSelected = $showSelected = $homeSelected = $postSelected = $postInCategorySelected = $pageSelected = $categorySelected = $blogSelected = $searchSelected = false; switch ($instance['action']) { case "1": $showSelected = true; break; case "0": $dontshowSelected = true; break; } ?>
hook); ?>

In Post In Category add one or more cat. IDs (not Slug or Title) comma separated!

", $atw->hook); ?>
options['condition'][$show]['code']; } $num = count($arg); $i = 1; foreach($arg as $k => $v){ $ids = explode(",", $v); $str = ''; $values = array(); //wrap each value into quotation marks foreach($ids as $val){ if($val !="") $values[] = '"' . $val . '"'; } $str = ( 1 == count($values) ) ? $values[0] : "array(" . implode(',', $values) . ")"; //if multiple values, then put them into an array if( 1 < $num ){ $code = str_replace('$arg' . $i, $str, $code); }else{ $code = str_replace('$arg', $str, $code); } $i++; } if($code != false && $action == "1"){ $code = "if($code){ return true; }else{ return false; }"; if(eval($code)){ return $instance; } }elseif($code != false){ $code = "if($code){ return false; }else{ return true; }"; if(eval($code)){ return $instance; } } return false; } /** * Print styles in the admin header */ function atw_print_styles(){ echo ' '; } add_action('admin_print_styles', 'atw_print_styles'); //backward compatibility - returns new value // $item = key or code function atw_back_compat($key, $item){ $old_values = array( 'all' => array( 'key' => '0', 'code' => 'true' ), 'home' => array( 'key' => '1', 'code' => 'is_home()' ), 'post' => array( 'key' => '4', 'code' => 'is_single($arg)' ), 'post_in_category' => array( 'key' => '5', 'code' => 'in_category($arg)' ), 'page' => array( 'key' => '3', 'code' => 'is_page($arg)' ), 'category' => array( 'key' => '6', 'code' => 'is_category($arg)' ), 'blog' => array( 'key' => '7', 'code' => 'is_home($arg) || is_single() || is_archive()' ), 'search' => array( 'key' => '8', 'code' => 'is_search()' ), ); if( $key != '' && !is_numeric($key) ) return $old_values[$key][$item]; return $key; } add_action('admin_notices', 'atw_admin_notice', 1); function atw_admin_notice(){ //show to non PRO users if( defined('ATW_PRO') ) return; //check if it's been dismissed if ( get_option('atw-pro-notice') ) return; $url = 'http://simplerealtytheme.com/plugins/atw-pro/?utm_source=wordpress&utm_medium=plugin&utm_content=admin_notice&utm_campaign=atw'; $text = <<Check out Advanced Text Widget PRO

PRO Features:
- Visibility conditions on ALL widgets.
- Define custom CSS IDs/Classes for ANY widget.
- Import/Export your visibility conditions to re-use on other sites.

HTML; $content = sprintf( $text, $url ); printf( '
'. $content .'

Dismiss

', add_query_arg( 'atw-dismiss-notice', 'true' ) ); } add_action('admin_init', 'atw_dismiss_admin_notice'); function atw_dismiss_admin_notice(){ if ( !isset($_REQUEST['atw-dismiss-notice']) || $_REQUEST['atw-dismiss-notice'] !== 'true' ) return; update_option( 'atw-pro-notice', 1 ); } }