/** * PHP4 constructor - Initialize ST * * @return SimpleTags */ function SimpleTags() { parent::initOptions(); // Set date for class $this->dateformat = get_option('date_format'); // Add pages in WP_Query if ( $this->options['use_tag_pages'] == 1 ) { remove_action( 'init', 'create_initial_taxonomies' ); // highest priority add_action( 'init', array(&$this, 'createInitialTaxonomies'), 0 ); // Load this function instead initial register taxnomy add_filter('posts_where', array(&$this, 'prepareQuery')); } // Remove embedded tags in posts display if ( $this->options['use_embed_tags'] == 1 ) { add_filter('the_content', array(&$this, 'filterEmbedTags'), 0); } // Add related posts in post ( all / feedonly / blogonly / homeonly / singularonly / singleonly / pageonly /no ) if ( $this->options['tt_embedded'] != 'no' || $this->options['tt_feed'] == 1 ) { add_filter('the_content', array(&$this, 'inlinePostTags'), 999992); } // Add post tags in post ( all / feedonly / blogonly / homeonly / singularonly / singleonly / pageonly /no ) if ( $this->options['rp_embedded'] != 'no' || $this->options['rp_feed'] == 1 ) { add_filter('the_content', array(&$this, 'inlineRelatedPosts'), 999993); } // Embedded tag cloud if ( $this->options['allow_embed_tcloud'] == 1 ) { add_shortcode( 'st_tag_cloud', array(&$this, 'inlineTagCloud') ); add_shortcode( 'st-tag-cloud', array(&$this, 'inlineTagCloud') ); add_filter( 'the_content' , array(&$this, 'old_inlineTagCloud')); } // Stock Posts ID (useful for autolink and metakeywords) add_filter( 'the_posts', array(&$this, 'getPostIds') ); // Add keywords to header if ( ( $this->options['meta_autoheader'] == 1 && !class_exists('Platinum_SEO_Pack') && !class_exists('All_in_One_SEO_Pack') && apply_filters('st_meta_header', true) ) ) { add_action('wp_head', array(&$this, 'outputMetaKeywords')); } // Auto link tags if ( $this->options['auto_link_tags'] == '1' ) { add_filter('the_content', array(&$this, 'autoLinkTags'), 12); } return true; }
/** * Save embedded tags * * @param integer $post_id * @param array $post_data */ function saveEmbedTags( $post_id = null, $post_data = null ) { $object = get_post($post_id); if ( $object == false || $object == null ) { return false; } // Return Tags $matches = $tags = array(); preg_match_all('/(' . parent::regexEscape($this->options['start_embed_tags']) . '(.*?)' . parent::regexEscape($this->options['end_embed_tags']) . ')/is', $object->post_content, $matches); foreach ( $matches[2] as $match) { foreach( (array) explode(',', $match) as $tag) { $tags[] = $tag; } } if( !empty($tags) ) { // Remove empty and duplicate elements $tags = array_filter($tags, array(&$this, 'deleteEmptyElement')); $tags = array_unique($tags); wp_set_post_tags( $post_id, $tags, true ); // Append tags // Clean cache if ( 'page' == $object->post_type ) { clean_page_cache($post_id); } else { clean_post_cache($post_id); } return true; } return false; }