Exemple #1
0
	/**
	 * PHP4 Constructor - Intialize Admin
	 *
	 * @return SimpleTagsAdmin
	 */
	function SimpleTagsAdmin() {
		parent::initOptions();
		
		// Admin URL for Pagination and target
		$this->posts_base_url 	= admin_url('edit.php')  . '?page=';
		$this->options_base_url = admin_url('options-general.php') . '?page=';
		
		// Admin Capabilities
		add_action('init', array(&$this, 'initRoles'));
		
		// Admin menu
		add_action('admin_menu', array(&$this, 'adminMenu'));
		add_action('admin_notices', array(&$this, 'displayMessage'));
		
		// Ajax action, JS Helper and admin action
		add_action('admin_init', array(&$this, 'ajaxCheck'));
		add_action('admin_init', array(&$this, 'checkFormMassEdit'));
		
		// Embedded Tags
		if ( $this->options['use_embed_tags'] == 1 ) {
			add_actions( array('save_post', 'publish_post', 'post_syndicated_item'), array(&$this, 'saveEmbedTags') );
		}
		
		// Auto tags
		if ( $this->options['use_auto_tags'] == 1 ) {
			add_actions( array('save_post', 'publish_post', 'post_syndicated_item'), array(&$this, 'saveAutoTags') );
		}
		
		// Save tags from advanced input
		if ( $this->options['use_autocompletion'] == 1 ) {
			add_actions( array('save_post', 'publish_post'), array(&$this, 'saveAdvancedTagsInput') );
			add_action('do_meta_boxes', array(&$this, 'removeOldTagsInput'), 1 );
		}
		
		// Box for post
		add_action('admin_menu', array(&$this, 'helperClickTags_Post'), 1);
		add_action('admin_menu', array(&$this, 'helperSuggestTags_Post'), 1);
		add_action('admin_menu', array(&$this, 'helperAdvancedTags_Post'), 1);
		
		// Box for Page
		if ( $this->options['use_tag_pages'] == 1 ) {
			add_action('admin_menu', array(&$this, 'helperClickTags_Page'), 1);
			add_action('admin_menu', array(&$this, 'helperSuggestTags_Page'), 1);
			add_action('admin_menu', array(&$this, 'helperAdvancedTags_Page'), 1);
		}
		
		// Load JavaScript and CSS
		$this->initJavaScript();
	}
Exemple #2
0
 /**
  * Sets up hooks to remove the domain from content before saving to the
  * database. This makes migrations simple as there are much less absolute
  * paths in the database.
  *
  * Not all absolute paths are fixed, some plugins and cached settings could
  * potentially have full URLs still, but we fix the ones that matter most.
  */
 public function __construct()
 {
     // Probably running in CLI mode
     if (!isset($_SERVER['SERVER_NAME'])) {
         return;
     }
     $this->domain = $_SERVER['SERVER_NAME'];
     // Posts
     add_filter('wp_insert_post_data', function ($data, $post) {
         $data['post_content'] = $this->replaceDomain($data['post_content']);
         $data['post_excerpt'] = $this->replaceDomain($data['post_excerpt']);
         $data['guid'] = $this->replaceDomain($data['guid']);
         return $data;
     }, null, 2);
     add_action('wp_insert_post', function ($id, $post, $update) {
         global $wpdb;
         if ($post->post_type !== 'revision' and $post->post_status !== 'auto-draft') {
             return;
         }
         if (strpos($post->guid, $this->domain) !== false) {
             $guid = $this->replaceDomain($post->guid);
             $wpdb->update($wpdb->posts, ['guid' => $guid], ['ID' => $id]);
         }
     }, null, 3);
     // Meta
     add_actions('added_post_meta updated_post_meta', function ($id, $objectId, $key, $value) {
         $this->replaceDomainInMeta('post', $id, $objectId, $key, $value);
     }, null, 4);
     add_actions('added_user_meta updated_user_meta', function ($id, $objectId, $key, $value) {
         $this->replaceDomainInMeta('user', $id, $objectId, $key, $value);
     }, null, 4);
     add_actions('added_comment_meta updated_comment_meta', function ($id, $objectId, $key, $value) {
         $this->replaceDomainInMeta('comment', $id, $objectId, $key, $value);
     }, null, 4);
     // Options
     add_action('added_option', function ($option, $value) {
         $this->replaceDomainInOption($option, $value);
     }, null, 2);
     add_action('updated_option', function ($option, $old_value, $value) {
         $this->replaceDomainInOption($option, $value);
     }, null, 3);
     // Feeds need absolute URLs
     add_filter('the_excerpt_rss', function ($excerpt) {
         return $this->relativeToAbsolute($excerpt);
     });
     add_filter('the_content_feed', function ($content) {
         return $this->relativeToAbsolute($content);
     });
 }
Exemple #3
0
	/**
	 * PHP4 Constructor - Intialize Admin
	 *
	 * @return void
	 * @author Amaury Balmer
	 */
	function SimpleTagsAdmin() {
		// Get options
		$this->options = (array) include( dirname(__FILE__) . '/default.options.php' );
		
		// Get options from WP options
		$options_from_table = get_option( STAGS_OPTIONS_NAME );
		
		// Update default options by getting not empty values from options table
		foreach( (array) $this->options as $key => $value ) {
			if ( isset($options_from_table[$key]) && !is_null($options_from_table[$key]) ) {
				$this->options[$key] = $options_from_table[$key];
			}
		}
		
		// Clean memory
		$options_from_table = array();
		unset($options_from_table, $value);
		
		// Admin URL for Pagination and target
		$this->posts_base_url 	= admin_url('edit.php')  . '?page=';
		$this->options_base_url = admin_url('options-general.php') . '?page=';
		
		// Admin Capabilities
		add_action('init', array(&$this, 'initRoles'));
		
		// Init taxonomy class variable, load this action after all actions on init !
		add_action( 'init', array(&$this, 'determineTaxonomy'), 99999999 );
		
		// Admin menu
		add_action('admin_menu', array(&$this, 'adminMenu'));
		add_action('admin_notices', array(&$this, 'displayMessage'));
		
		// Ajax action, JS Helper and admin action
		add_action('admin_init', array(&$this, 'ajaxCheck'));
		add_action('admin_init', array(&$this, 'checkFormMassEdit'));
		
		// Embedded Tags
		if ( $this->options['use_embed_tags'] == 1 ) {
			add_actions( array('save_post', 'publish_post', 'post_syndicated_item'), array(&$this, 'saveEmbedTags'), 10, 2 );
		}
		
		// Auto tags
		if ( $this->options['use_auto_tags'] == 1 ) {
			add_actions( array('save_post', 'publish_post', 'post_syndicated_item'), array(&$this, 'saveAutoTags'), 10, 2 );
		}
		
		// Save tags from advanced input
		if ( $this->options['use_autocompletion'] == 1 ) {
			add_actions( array('save_post', 'publish_post'), array(&$this, 'saveAdvancedTagsInput'), 10, 2 );
			add_action('do_meta_boxes', array(&$this, 'removeOldTagsInput'), 1 );
		}
		
		// Box for post
		add_action('admin_menu', array(&$this, 'helperClickTags_Post'), 1);
		add_action('admin_menu', array(&$this, 'helperSuggestTags_Post'), 1);
		add_action('admin_menu', array(&$this, 'helperAdvancedTags_Post'), 1);
		
		// Box for Page
		if ( $this->options['use_tag_pages'] == 1 ) {
			add_action('admin_menu', array(&$this, 'helperClickTags_Page'), 1);
			add_action('admin_menu', array(&$this, 'helperSuggestTags_Page'), 1);
			add_action('admin_menu', array(&$this, 'helperAdvancedTags_Page'), 1);
		}
		
		// Load JavaScript and CSS
		$this->initJavaScript();
	}
	/**
	 * PHP4 Constructor - Intialize Admin
	 *
	 * @return SimpleTagsAdmin
	 */
	function SimpleTagsAdmin( $default_options = array(), $version = '', $info = array() ) {		
		// 1. load version number
		$this->version = $version;
		unset($version);

		// 2. Set class property for default options
		$this->default_options = $default_options;

		// 3. Get options from WP
		$options_from_table = get_option( $this->db_options );

		// 4. Update default options by getting not empty values from options table
		foreach( (array) $default_options as $default_options_name => $default_options_value ) {
			if ( !is_null($options_from_table[$default_options_name]) ) {
				if ( is_int($default_options_value) ) {
					$default_options[$default_options_name] = (int) $options_from_table[$default_options_name];
				} else {
					$default_options[$default_options_name] = $options_from_table[$default_options_name];
				}
			}
		}

		// 5. Set the class property and unset no used variable
		$this->options = $default_options;
		unset($default_options);
		unset($options_from_table);
		unset($default_options_value);

		// 6. Get info data from constructor
		$this->info = $info;
		unset($info);

		// 8. Admin URL for Pagination and target
		$this->posts_base_url = $this->info['siteurl'] . '/wp-admin/edit.php?page=';
		$this->options_base_url = $this->info['siteurl'] . '/wp-admin/options-general.php?page=';

		// 9. Admin Capabilities
		add_action('init', array(&$this, 'initRoles'));

		// 10. Admin menu
		add_action('admin_menu', array(&$this, 'adminMenu'));
		add_action('admin_notices', array(&$this, 'displayMessage'));		

		// 11. Ajax action, JS Helper and admin action
		add_action('admin_init', array(&$this, 'ajaxCheck'));
		add_action('admin_init', array(&$this, 'checkFormMassEdit'));

		// 12. Embedded Tags
		if ( $this->options['use_embed_tags'] == 1 ) {
			add_actions( array('save_post', 'publish_post', 'post_syndicated_item'), array(&$this, 'saveEmbedTags') );
		}

		// 13. Auto tags
		if ( $this->options['use_auto_tags'] == 1 ) {
			add_actions( array('save_post', 'publish_post', 'post_syndicated_item'), array(&$this, 'saveAutoTags') );		
		}
	
		// 14. Save tags from advanced input
		if ( $this->options['use_autocompletion'] == 1 ) {
			add_actions( array('save_post', 'publish_post'), array(&$this, 'saveAdvancedTagsInput') );
			add_action('do_meta_boxes', array(&$this, 'removeOldTagsInput'), 1 );
		}

		// 15. Box for post
		add_action('admin_menu', array(&$this, 'helperClickTags_Post'), 1);
		add_action('admin_menu', array(&$this, 'helperSuggestTags_Post'), 1);
		add_action('admin_menu', array(&$this, 'helperAdvancedTags_Post'), 1);
		
		// 16. Box for Page
		if ( $this->options['use_tag_pages'] == 1 ) {
			add_action('admin_menu', array(&$this, 'helperClickTags_Page'), 1);
			add_action('admin_menu', array(&$this, 'helperSuggestTags_Page'), 1);
			add_action('admin_menu', array(&$this, 'helperAdvancedTags_Page'), 1);
		}

		// 17. Load JavaScript and CSS
		$this->initJavaScript();
	}