/**
  * Constructor
  */
 public function __construct()
 {
     $this->check_version_update();
     // set meta box page
     $this->meta_box_page = new WP_Meta_Box_Page_01();
     // set ajax forms (also used by front-end)
     $this->form = new WP_Option_Forms_01(WP_EXTERNAL_LINKS_KEY, $this->save_options);
     self::$staticForm = $this->form;
     // init admin
     add_action('admin_init', array($this, 'admin_init'));
     if (is_admin()) {
         // set options for add_page_method
         $menu_pos = $this->form->set_current_option('screen')->value('menu_position');
         // init meta box page
         $this->meta_box_page->init(array('page_title' => $this->__('WP External Links'), 'menu_title' => $this->__('External Links'), 'page_slug' => strtolower(WP_EXTERNAL_LINKS_KEY), 'add_page_method' => (!empty($menu_pos) and $menu_pos != 'admin.php') ? 'add_submenu_page' : 'add_menu_page', 'parent_slug' => (!empty($menu_pos) and $menu_pos != 'admin.php') ? $menu_pos : NULL, 'column_widths' => array(1 => array(99), 2 => array(69, 29)), 'icon_url' => plugins_url('images/icon-wp-external-links-16.png', WP_EXTERNAL_LINKS_FILE)), array($this, 'call_load_meta_box'));
     }
 }
 /**
  * wp callback
  */
 public function call_wp()
 {
     if (!is_admin() && !is_feed()) {
         // add wp_head for setting js vars and css style
         add_action('wp_head', array($this, 'call_wp_head'));
         // set js file
         if ($this->get_opt('use_js')) {
             wp_enqueue_script('wp-external-links', plugins_url('js/wp-external-links.js', WP_EXTERNAL_LINKS_FILE), array('jquery'), WP_EXTERNAL_LINKS_VERSION, (bool) $this->get_opt('load_in_footer'));
         }
         // set ignored
         $ignored = $this->get_opt('ignore');
         $ignored = trim($ignored);
         $ignored = explode("\n", $ignored);
         $ignored = array_map('trim', $ignored);
         $ignored = array_map('strtolower', $ignored);
         $this->ignored = $ignored;
         // filters
         if ($this->get_opt('filter_page')) {
             // filter body
             ob_start(array($this, 'call_filter_content'));
             // set ob flush
             add_action('wp_footer', array($this, 'callback_flush_buffer'), 10000);
         } else {
             // set filter priority
             $priority = 1000000000;
             // content
             if ($this->get_opt('filter_posts')) {
                 add_filter('the_title', array($this, 'call_filter_content'), $priority);
                 add_filter('the_content', array($this, 'call_filter_content'), $priority);
                 add_filter('get_the_excerpt', array($this, 'call_filter_content'), $priority);
                 // redundant:
                 //add_filter( 'the_excerpt', array( $this, 'call_filter_content' ), $priority );
             }
             // comments
             if ($this->get_opt('filter_comments')) {
                 add_filter('get_comment_text', array($this, 'call_filter_content'), $priority);
                 // redundant:
                 //add_filter( 'comment_text', array( $this, 'call_filter_content' ), $priority );
                 add_filter('comment_excerpt', array($this, 'call_filter_content'), $priority);
                 // redundant:
                 //add_filter( 'get_comment_excerpt', array( $this, 'call_filter_content' ), $priority );
                 add_filter('comment_url', array($this, 'call_filter_content'), $priority);
                 add_filter('get_comment_author_url', array($this, 'call_filter_content'), $priority);
                 add_filter('get_comment_author_link', array($this, 'call_filter_content'), $priority);
                 add_filter('get_comment_author_url_link', array($this, 'call_filter_content'), $priority);
             }
             // widgets
             if ($this->get_opt('filter_widgets')) {
                 if ($this->admin->check_widget_content_filter()) {
                     // only if Widget Logic plugin is installed and 'widget_content' option is activated
                     add_filter('widget_content', array($this, 'call_filter_content'), $priority);
                 } else {
                     // filter text widgets
                     add_filter('widget_title', array($this, 'call_filter_content'), $priority);
                     add_filter('widget_text', array($this, 'call_filter_content'), $priority);
                 }
             }
         }
     }
     // hook
     do_action('wpel_ready', array($this, 'call_filter_content'), $this);
 }
	/**
	 * wp callback
	 */
	public function call_wp() {
		if ( ! is_admin() && ! is_feed() ) {
			// Include phpQuery
			if ( ! class_exists( 'phpQuery' ) ) {
				require_once( 'phpQuery.php' );
			}

			// add wp_head for setting js vars and css style
			add_action( 'wp_head', array( $this, 'call_wp_head' ) );

			// add stylesheet
			wp_enqueue_style( 'wp-external-links', plugins_url( 'css/external-links.css', WP_EXTERNAL_LINKS_FILE ), FALSE, WP_EXTERNAL_LINKS_VERSION );

			// set js file
			if ( $this->get_opt( 'use_js' ) )
				wp_enqueue_script( 'wp-external-links', plugins_url( 'js/external-links.js', WP_EXTERNAL_LINKS_FILE ), array( 'jquery' ), WP_EXTERNAL_LINKS_VERSION );

			// filters
			if ( $this->get_opt( 'filter_page' ) ) {
				// filter body
				ob_start( array( $this, 'call_filter_content' ) );

			} else {
				// set filter priority
				$priority = 1000000000;

				// content
				if ( $this->get_opt( 'filter_posts' ) ) {
					add_filter( 'the_title', array( $this, 'call_filter_content' ), $priority );
					add_filter( 'the_content', array( $this, 'call_filter_content' ), $priority );
					add_filter( 'get_the_excerpt', array( $this, 'call_filter_content' ), $priority );
					// redundant:
					//add_filter( 'the_excerpt', array( $this, 'call_filter_content' ), $priority );
				}

				// comments
				if ( $this->get_opt( 'filter_comments' ) ) {
					add_filter( 'get_comment_text', array( $this, 'call_filter_content' ), $priority );
					// redundant:
					//add_filter( 'comment_text', array( $this, 'call_filter_content' ), $priority );

					add_filter( 'comment_excerpt', array( $this, 'call_filter_content' ), $priority );
					// redundant:
					//add_filter( 'get_comment_excerpt', array( $this, 'call_filter_content' ), $priority );

					add_filter( 'comment_url', array( $this, 'call_filter_content' ), $priority );
					add_filter( 'get_comment_author_url', array( $this, 'call_filter_content' ), $priority );
					add_filter( 'get_comment_author_link', array( $this, 'call_filter_content' ), $priority );
					add_filter( 'get_comment_author_url_link', array( $this, 'call_filter_content' ), $priority );
				}

				// widgets
				if ( $this->get_opt( 'filter_widgets' ) ) {
					if ( $this->admin->check_widget_content_filter() ) {
						// only if Widget Logic plugin is installed and 'widget_content' option is activated
						add_filter( 'widget_content', array( $this, 'call_filter_content' ), $priority );
					} else {
						// filter text widgets
						add_filter( 'widget_title', array( $this, 'call_filter_content' ), $priority );
						add_filter( 'widget_text', array( $this, 'call_filter_content' ), $priority );
					}
				}
			}
		}
	}