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 and Pagination $this->admin_base_url = $this->info['siteurl'] . '/wp-admin/admin.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('init', array(&$this, 'ajaxCheck')); add_action('init', array(&$this, 'checkFormMassEdit')); // 12. Embedded Tags if ( $this->options['use_embed_tags'] == 1 ) { add_action('save_post', array(&$this, 'saveEmbedTags')); add_action('publish_post', array(&$this, 'saveEmbedTags')); add_action('post_syndicated_item', array(&$this, 'saveEmbedTags')); } // 13. Auto tags if ( $this->options['use_auto_tags'] == 1 ) { add_action('save_post', array(&$this, 'saveAutoTags')); add_action('publish_post', array(&$this, 'saveAutoTags')); add_action('post_syndicated_item', array(&$this, 'saveAutoTags')); } // 14. Save tags from old input add_action('save_post', array(&$this, 'saveTagsOldInput')); add_action('publish_post', array(&$this, 'saveTagsOldInput')); // 15. Tags helper for page if ( $this->options['use_tag_pages'] == 1 ) { add_action('edit_page_form', array(&$this, 'helperTagsPage'), 1); // Tag input if ( $this->options['use_autocompletion'] == 1 ) { add_action('dbx_page_advanced', array(&$this, 'helperBCompleteJS')); } if ( $this->options['use_click_tags'] == 1 ) { add_action('edit_page_form', array(&$this, 'helperClickTags'), 1); } if ( $this->options['use_suggested_tags'] == 1 ) { add_action('edit_page_form', array(&$this, 'helperSuggestTags'), 1); } } // 16. Tags helper for post if ( $this->options['use_click_tags'] == 1 ) { add_action('edit_form_advanced', array(&$this, 'helperClickTags'), 1); } if ( $this->options['use_suggested_tags'] == 1 ) { add_action('edit_form_advanced', array(&$this, 'helperSuggestTags'), 1); } // 17. Helper JS & jQuery & Prototype global $pagenow; $wp_pages = array('post.php', 'post-new.php', ); if ( $this->options['use_tag_pages'] == 1 ) { $wp_pages[] = 'page.php'; $wp_pages[] = 'page-new.php'; } $st_pages = array('st_manage', 'st_mass_tags', 'st_auto', 'st_options'); if ( in_array($pagenow, $wp_pages) || in_array($_GET['page'], $st_pages) ) { add_action('admin_head', array(&$this, 'helperHeaderST')); wp_enqueue_script('jquery'); wp_enqueue_script('prototype'); if ( $this->options['use_autocompletion'] == 1 ) { if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) { add_action('admin_head', array(&$this, 'remplaceTagsHelper')); } if ( !in_array($_GET['page'], $st_pages) ) { add_action('admin_head', array(&$this, 'helperBCompleteJS')); } } } // 18. Helper Bcomplete JS if ( $_GET['page'] == 'st_mass_tags' && $this->options['use_autocompletion'] == 1 ) { add_action('admin_head', array(&$this, 'helperMassBCompleteJS')); } return; } function initRoles() { if ( function_exists('get_role') ) { $role = get_role('administrator'); if( $role != null && !$role->has_cap('simple_tags') ) { $role->add_cap('simple_tags'); } if( $role != null && !$role->has_cap('admin_simple_tags') ) { $role->add_cap('admin_simple_tags'); } // Clean var unset($role); $role = get_role('editor'); if( $role != null && !$role->has_cap('simple_tags') ) { $role->add_cap('simple_tags'); } // Clean var unset($role); } } /** * Add WP admin menu for Tags * */ function adminMenu() { add_management_page( __('Simple Tags: Manage Tags', 'simpletags'), __('Manage Tags', 'simpletags'), 'simple_tags', 'st_manage', array(&$this, 'pageManageTags')); add_management_page( __('Simple Tags: Mass Edit Tags', 'simpletags'), __('Mass Edit Tags', 'simpletags'), 'simple_tags', 'st_mass_tags', array(&$this, 'pageMassEditTags')); add_management_page( __('Simple Tags: Auto Tags', 'simpletags'), __('Auto Tags', 'simpletags'), 'simple_tags', 'st_auto', array(&$this, 'pageAutoTags')); add_options_page( __('Simple Tags: Options', 'simpletags'), __('Simple Tags', 'simpletags'), 'admin_simple_tags', 'st_options', array(&$this, 'pageOptions')); } /** * WP Page - Auto Tags * */ function pageAutoTags() { $action = false; if ( isset($_POST['update_auto_list']) ) { // Tags list $tags_list = stripslashes($_POST['auto_list']); $tags = explode(',', $tags_list); // Remove empty and duplicate elements $tags = array_filter($tags, array(&$this, 'deleteEmptyElement')); $tags = array_unique($tags); $this->setOption( 'auto_list', maybe_serialize($tags) ); // Active auto tags ? if ( $_POST['use_auto_tags'] == '1' ) { $this->setOption( 'use_auto_tags', '1' ); } else { $this->setOption( 'use_auto_tags', '0' ); } // All tags ? if ( $_POST['at_all'] == '1' ) { $this->setOption( 'at_all', '1' ); } else { $this->setOption( 'at_all', '0' ); } // Empty only ? if ( $_POST['at_empty'] == '1' ) { $this->setOption( 'at_empty', '1' ); } else { $this->setOption( 'at_empty', '0' ); } $this->saveOptions(); $this->message = __('Auto tags options updated !', 'simpletags'); } elseif ( $_GET['action'] == 'auto_tag' ) { $action = true; $n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0; } $tags_list = ''; $tags = maybe_unserialize($this->options['auto_list']); if ( is_array($tags) ) { $tags_list = implode(', ', $tags); } $this->displayMessage(); ?>

plugin\'s homepage for further details. If you find a bug, or have a fantastic idea for this plugin, ask me !', 'simpletags'); ?>

options['use_auto_tags'] == 1 ) ? 'checked="checked"' : ''; ?> />
options['at_all'] == 1 ) ? 'checked="checked"' : ''; ?> />
options['at_empty'] == 1 ) ? 'checked="checked"' : ''; ?> />

helperBCompleteJS( 'auto_list' ); ?>

options['use_tag_pages'] == '1' ) ? "post_type IN('page', 'post')" : "post_type = 'post'"; // Get objects global $wpdb; $objects = (array) $wpdb->get_results("SELECT p.ID, p.post_title, p.post_content FROM {$wpdb->posts} p WHERE {$post_type_sql} ORDER BY ID DESC LIMIT {$n}, 20"); if( !empty($objects) ) { echo ''; ?>

'.sprintf(__('All done! %s tags added.', 'simpletags'), $counter).'

'; } endif; $this->printAdminFooter(); ?>
array( array('use_tag_pages', __('Active tags for page:', 'simpletags'), 'checkbox', '1', __('This feature allow page to be tagged. This option add pages in tags search. Also this feature add tag management in write page.', 'simpletags')), array('allow_embed_tcloud', __('Allow tag cloud in post/page content:', 'simpletags'), 'checkbox', '1', __('Enabling this will allow Wordpress to look for tag cloud marker <!--st_tag_cloud--> when displaying posts. WP replace this marker by a tag cloud.', 'simpletags')), array('auto_link_tags', __('Active auto link tags into post content:', 'simpletags'), 'checkbox', '1', __('Example: You have a tag called "WordPress" and your post content contains "wordpress", this feature will replace "wordpress" by a link to "wordpress" tags page. (http://myblog.net/tag/wordpress/)', 'simpletags')), array('auto_link_min', __('Min usage for auto link tags:', 'simpletags'), 'text', 10, __('This parameter allows to fix a minimal value of use of tags. Default: 1.', 'simpletags')), array('auto_link_case', __('Ignore case for auto link feature ?', 'simpletags'), 'checkbox', '1', __('Example: If you ignore case, auto link feature will replace the word "wordpress" by the tag link "WordPress".', 'simpletags')), array('no_follow', __('Add the rel="nofollow" on each tags link ?', 'simpletags'), 'checkbox', '1', __("Nofollow is a non-standard HTML attribute value used to instruct search engines that a hyperlink should not influence the link target's ranking in the search engine's index.",'simpletags')) ), 'administration' => array( array('use_click_tags', __('Activate click tags feature:', 'simpletags'), 'checkbox', '1', __('This feature add a link allowing you to display all the tags of your database. Once displayed, you can click over to add tags to post.', 'simpletags')), array('use_autocompletion', __('Activate autocompletion feature:', 'simpletags'), 'checkbox', '1', __('This feature displays a visual help allowing to enter tags more easily.', 'simpletags')), array('use_suggested_tags', __('Activate suggested tags feature: (Yahoo! Term Extraction API, Tag The Net, Local DB)', 'simpletags'), 'checkbox', '1', __('This feature add a box allowing you get suggested tags, by comparing post content and various sources of tags. (external and internal)', 'simpletags')) ), 'metakeywords' => array( array('meta_autoheader', __('Automatically include in header:', 'simpletags'), 'checkbox', '1', __('Includes the meta keywords tag automatically in your header (most, but not all, themes support this). These keywords are sometimes used by search engines.
Warning: If the plugin "All in One SEO Pack" is installed and enabled. This feature is automatically disabled.', 'simpletags')), array('meta_always_include', __('Always add these keywords:', 'simpletags'), 'text', 80), array('meta_keywords_qty', __('Max keywords display:', 'simpletags'), 'text', 10, __('You must set zero (0) for display all keywords in HTML header.', 'simpletags')), ), 'embeddedtags' => array( array('use_embed_tags', __('Use embedded tags:', 'simpletags'), 'checkbox', '1', __('Enabling this will allow Wordpress to look for embedded tags when saving and displaying posts. Such set of tags is marked [tags]like this, and this[/tags], and is added to the post when the post is saved, but does not display on the post.', 'simpletags')), array('start_embed_tags', __('Prefix for embedded tags:', 'simpletags'), 'text', 40), array('end_embed_tags', __('Suffix for embedded tags:', 'simpletags'), 'text', 40) ), 'tagspost' => array( array('tt_feed', __('Automatically display tags list into feeds', 'simpletags'), 'checkbox', '1'), array('tt_embedded', __('Automatically display tags list into post content:', 'simpletags'), 'dropdown', 'no/all/blogonly/feedonly/homeonly/singularonly/pageonly/singleonly', ''), array('tt_separator', __('Post tag separator string:', 'simpletags'), 'text', 10), array('tt_before', __('Text to display before tags list:', 'simpletags'), 'text', 40), array('tt_after', __('Text to display after tags list:', 'simpletags'), 'text', 40), array('tt_number', __('Max tags display:', 'simpletags'), 'text', 10, __('You must set zero (0) for display all tags.', 'simpletags')), array('tt_inc_cats', __('Include categories in result ?', 'simpletags'), 'checkbox', '1'), array('tt_xformat', __('Tag link format:', 'simpletags'), 'text', 80, __('You can find markers and explanations in the online documentation.', 'simpletags')), array('tt_notagstext', __('Text to display if no tags found:', 'simpletags'), 'text', 80), array('tt_adv_usage', __('Advanced usage:', 'simpletags'), 'text', 80, __('You can use the same syntax as st_the_tags() function to customize display. See documentation for more details.', 'simpletags')) ), 'relatedposts' => array( array('rp_feed', __('Automatically display related posts into feeds', 'simpletags'), 'checkbox', '1'), array('rp_embedded', __('Automatically display related posts into post content', 'simpletags'), 'dropdown', 'no/all/blogonly/feedonly/homeonly/singularonly/pageonly/singleonly', ''), array('rp_order', __('Related Posts Order:', 'simpletags'), 'dropdown', 'count-asc/count-desc/date-asc/date-desc/name-asc/name-desc/random', ''), array('rp_xformat', __('Post link format:', 'simpletags'), 'text', 80, __('You can find markers and explanations in the online documentation.', 'simpletags')), array('rp_limit_qty', __('Maximum number of related posts to display: (default: 5)', 'simpletags'), 'text', 10), array('rp_notagstext', __('Enter the text to show when there is no related post:', 'simpletags'), 'text', 80), array('rp_title', __('Enter the positioned title before the list, leave blank for no title:', 'simpletags'), 'text', 80), array('rp_adv_usage', __('Advanced usage:', 'simpletags'), 'text', 80, __('You can use the same syntax as st_related_posts()function to customize display. See documentation for more details.', 'simpletags')) ), 'relatedtags' => array( array('rt_number', __('Maximum number of related tags to display: (default: 5)', 'simpletags'), 'text', 10), array('rt_order', __('Order related tags:', 'simpletags'), 'dropdown', 'count-asc/count-desc/name-asc/name-desc/random', ''), array('rt_format', __('Related tags type format:', 'simpletags'), 'dropdown', 'list/flat', ''), array('rt_method', __('Method of tags intersections and unions used to build related tags link:', 'simpletags'), 'dropdown', 'OR/AND', ''), array('rt_xformat', __('Related tags link format:', 'simpletags'), 'text', 80, __('You can find markers and explanations in the online documentation.', 'simpletags')), array('rt_separator', __('Related tags separator:', 'simpletags'), 'text', 10, __('Leave empty for list format.', 'simpletags')), array('rt_notagstext', __('Enter the text to show when there is no related tags:', 'simpletags'), 'text', 80), array('rt_title', __('Enter the positioned title before the list, leave blank for no title:', 'simpletags'), 'text', 80), array('rt_adv_usage', __('Advanced usage:', 'simpletags'), 'text', 80, __('You can use the same syntax as st_related_tags()function to customize display. See documentation for more details.', 'simpletags')), // Remove related tags array('text_helper', 'text_helper', 'helper', '', '

'.__('Remove related Tags', 'simpletags').'

'), array('rt_format', __('Remove related Tags type format:', 'simpletags'), 'dropdown', 'list/flat', ''), array('rt_remove_separator', __('Remove related tags separator:', 'simpletags'), 'text', 10, __('Leave empty for list format.', 'simpletags')), array('rt_remove_notagstext', __('Enter the text to show when there is no remove related tags:', 'simpletags'), 'text', 80), array('rt_remove_xformat', __('Remove related tags link format:', 'simpletags'), 'text', 80, __('You can find markers and explanations in the online documentation.', 'simpletags')), ), 'tagcloud' => array( array('text_helper', 'text_helper', 'helper', '', __('Which difference between ‘Order tags selection’ and ‘Order tags display’ ?
', 'simpletags') . ''. __('Example: You want display randomly the 100 tags most popular.
', 'simpletags'). __('You must set ‘Order tags selection’ to count-desc for retrieve the 100 tags most popular and ‘Order tags display’ to random for randomize cloud.', 'simpletags')), array('cloud_selection', __('Order tags selection:', 'simpletags'), 'dropdown', 'count-asc/count-desc/name-asc/name-desc/random', ''), array('cloud_sort', __('Order tags display:', 'simpletags'), 'dropdown', 'count-asc/count-desc/name-asc/name-desc/random', ''), array('cloud_inc_cats', __('Include categories in tag cloud ?', 'simpletags'), 'checkbox', '1'), array('cloud_format', __('Tags cloud type format:', 'simpletags'), 'dropdown', 'list/flat', ''), array('cloud_xformat', __('Tag link format:', 'simpletags'), 'text', 80, __('You can find markers and explanations in the online documentation.', 'simpletags')), array('cloud_limit_qty', __('Maximum number of tags to display: (default: 45)', 'simpletags'), 'text', 10), array('cloud_notagstext', __('Enter the text to show when there is no tag:', 'simpletags'), 'text', 80), array('cloud_title', __('Enter the positioned title before the list, leave blank for no title:', 'simpletags'), 'text', 80), array('cloud_max_color', __('Most popular color:', 'simpletags'), 'text-color', 10, __("The colours are hexadecimal colours, and need to have the full six digits (#eee is the shorthand version of #eeeeee).", 'simpletags')), array('cloud_min_color', __('Least popular color:', 'simpletags'), 'text-color', 10), array('cloud_max_size', __('Most popular font size:', 'simpletags'), 'text', 10, __("The two font sizes are the size of the largest and smallest tags.", 'simpletags')), array('cloud_min_size', __('Least popular font size:', 'simpletags'), 'text', 10), array('cloud_unit', __('The units to display the font sizes with, on tag clouds:', 'simpletags'), 'dropdown', 'pt/px/em/%', __("The font size units option determines the units that the two font sizes use.", 'simpletags')), array('cloud_adv_usage', __('Advanced usage:', 'simpletags'), 'text', 80, __('You can use the same syntax as st_tag_cloud() function to customize display. See documentation for more details.', 'simpletags')) ), ); // Update or reset options if ( isset($_POST['updateoptions']) ) { foreach((array) $this->options as $key => $value) { $newval = ( isset($_POST[$key]) ) ? stripslashes($_POST[$key]) : '0'; $skipped_options = array('use_auto_tags', 'auto_list'); if ( $newval != $value && !in_array($key, $skipped_options) ) { $this->setOption( $key, $newval ); } } $this->saveOptions(); $this->message = __('Options saved', 'simpletags'); $this->status = 'updated'; } elseif ( isset($_POST['reset_options']) ) { $this->resetToDefaultOptions(); $this->message = __('Simple Tags options resetted to default options!', 'simpletags'); } // Delete all options ? if ( $_POST['delete_all_options'] == 'true' ) { $this->deleteAllOptions(); $this->message = sprintf( __('All Simple Tags options are deleted ! You deactive plugin now !', 'simpletags'), $this->info['siteurl']. '/wp-admin/plugins.php'); } $this->displayMessage(); ?>

plugin\'s homepage for further details. If you find a bug, or have a fantastic idea for this plugin, ask me !', 'simpletags'); ?>

printOptions( $option_data ); ?>

all options before deactivating the plugin.', 'simpletags'); ?>

This is irrevocable! Be careful.', 'simpletags'); ?>

printAdminFooter(); ?>
message = __('Security problem. Try again. If this problem persist, contact plugin author.', 'simpletags'); $this->status = 'error'; } elseif ( $_POST['tag_action'] == 'renametag' ) { $oldtag = (isset($_POST['renametag_old'])) ? $_POST['renametag_old'] : ''; $newtag = (isset($_POST['renametag_new'])) ? $_POST['renametag_new'] : ''; $this->renameTags( $oldtag, $newtag ); } elseif ( $_POST['tag_action'] == 'deletetag' ) { $todelete = (isset($_POST['deletetag_name'])) ? $_POST['deletetag_name'] : ''; $this->deleteTagsByTagList( $todelete ); } elseif ( $_POST['tag_action'] == 'addtag' ) { $matchtag = (isset($_POST['addtag_match'])) ? $_POST['addtag_match'] : ''; $newtag = (isset($_POST['addtag_new'])) ? $_POST['addtag_new'] : ''; $this->addMatchTags( $matchtag, $newtag ); } elseif ( $_POST['tag_action'] == 'editslug' ) { $matchtag = (isset($_POST['tagname_match'])) ? $_POST['tagname_match'] : ''; $newslug = (isset($_POST['tagslug_new'])) ? $_POST['tagslug_new'] : ''; $this->editTagSlug( $matchtag, $newslug ); } elseif ( $_POST['tag_action'] == 'cleandb' ) { $this->cleanDatabase(); } } // Manage URL $sort_order = ( isset($_GET['tag_sortorder']) ) ? attribute_escape(stripslashes($_GET['tag_sortorder'])) : 'desc'; $search_url = ( isset($_GET['search']) ) ? '&search=' . stripslashes($_GET['search']) : ''; $action_url = $this->admin_base_url . attribute_escape(stripslashes($_GET['page'])) . '&tag_sortorder=' . $sort_order. $search_url; // TagsFilters $order_array = array( 'desc' => __('Most popular', 'simpletags'), 'asc' => __('Least used', 'simpletags'), 'natural' => __('Alphabetical', 'simpletags')); // Build Tags Param switch ($sort_order) { case 'natural' : $param = 'number='.$this->nb_tags.'&hide_empty=false&cloud_selection=name-asc'; break; case 'asc' : $param = 'number='.$this->nb_tags.'&hide_empty=false&cloud_selection=count-asc'; break; default : $param = 'number='.$this->nb_tags.'&hide_empty=false&cloud_selection=count-desc'; break; } // Search if ( !empty($_GET['search']) ) { $search = stripslashes($_GET['search']); $param = str_replace('number='.$this->nb_tags, 'number=200&st_name_like='.$search, $param ); } $this->displayMessage(); ?>

plugin\'s homepage for further details. If you find a bug, or have a fantastic idea for this plugin, ask me !', 'simpletags'); ?>


$title ) { $output[] = ($sort == $sort_order) ? ''.$title.'' : ''.$title.''; } echo implode('
', $output); $output = array(); unset($output); ?>
    getTags($param, true); foreach( $tags as $tag ) { echo '
  • '.$tag->name.' ('.$tag->count.')
  • '."\n"; } unset($tags); ?>
$this->nb_tags ) ) : ?>

.

Slug definition', 'simpletags'); ?>

printAdminFooter(); ?>
array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')), 'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')), 'pending' => array(__('Pending Review'), __('Pending posts'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')), 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')), 'private' => array(__('Private'), __('Private posts'), __ngettext_noop('Private (%s)', 'Private (%s)')), ); $post_stati = apply_filters('post_stati', $post_stati); $avail_post_stati = get_available_post_statuses('post'); $post_status_q = ''; if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) { $post_status_q = '&post_status=' . $q['post_status']; $post_status_q .= '&perm=readable'; } if ( 'pending' === $q['post_status'] ) { $order = 'ASC'; $orderby = 'modified'; } elseif ( 'draft' === $q['post_status'] ) { $order = 'DESC'; $orderby = 'modified'; } else { $order = 'DESC'; $orderby = 'date'; } wp("post_type={$q['post_type']}&what_to_show=posts$post_status_q&posts_per_page={$q['posts_per_page']}&order=$order&orderby=$orderby"); return array($post_stati, $avail_post_stati); } /** * WP Page - Mass edit tags * */ function pageMassEditTags() { global $wpdb, $wp_locale, $wp_query; list($post_stati, $avail_post_stati) = $this->edit_data_query(); if ( !isset( $_GET['paged'] ) ) { $_GET['paged'] = 1; } ?>

add_query_arg( 'paged', '%#%' ), 'format' => '', 'total' => ceil($wp_query->found_posts / $posts_per_page ), 'current' => ((int) $_GET['paged']) )); if ( $page_links ) echo "
$page_links
"; ?>
posts WHERE post_type = 'post' ORDER BY post_date DESC"; $arc_result = $wpdb->get_results( $arc_query ); $month_count = count($arc_result); if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>


all_tags === true ) : ?>

plugin\'s homepage for further details. If you find a bug, or have a fantastic idea for this plugin, ask me !', 'simpletags'); ?>

printAdminFooter(); ?>
post_type ) { clean_page_cache($post_id); } else { clean_post_cache($post_id); } return true; } return false; } /** * 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('/(' . $this->regexEscape($this->options['start_embed_tags']) . '(.*?)' . $this->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; } /** * Check post/page content for auto tags * * @param integer $post_id * @param array $post_data * @return boolean */ function saveAutoTags( $post_id = null, $post_data = null ) { $object = get_post($post_id); if ( $object == false || $object == null ) { return false; } $result = $this->autoTagsPost( $object ); if ( $result == true ) { // Clean cache if ( 'page' == $object->post_type ) { clean_page_cache($post_id); } else { clean_post_cache($post_id); } } return true; } /** * Automatically tag a post/page from the database tags * * @param object $object * @return boolean */ function autoTagsPost( $object ) { if ( get_the_tags($object->ID) != false && $this->options['at_empty'] == 1 ) { return false; // Skip post with tags, if tag only empty post option is checked } $tags_to_add = array(); // Merge title + content + excerpt to compare with tags $content = $object->post_content. ' ' . $object->post_title. ' ' . $object->post_excerpt; $content = trim($content); if ( empty($content) ) { return false; } // Auto tag with specifik auto tags list $tags = (array) maybe_unserialize($this->options['auto_list']); foreach ( $tags as $tag ) { if ( is_string($tag) && !empty($tag) && stristr($content, $tag) ) { $tags_to_add[] = $tag; } } unset($tags, $tag); // Auto tags with all posts if ( $this->options['at_all'] == 1 ) { // Get all terms global $wpdb; $terms = $wpdb->get_col(" SELECT DISTINCT name FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'post_tag' "); $terms = array_unique($terms); foreach ( $terms as $term ) { $term = stripslashes($term); if ( is_string($term) && !empty($term) && stristr($content, $term) ) { $tags_to_add[] = $term; } } // Clean memory $terms = array(); unset($terms, $term); } // Append tags if tags to add if ( !empty($tags_to_add) ) { // Remove empty and duplicate elements $tags_to_add = array_filter($tags_to_add, array(&$this, 'deleteEmptyElement')); $tags_to_add = array_unique($tags_to_add); // Increment counter $counter = ((int) get_option('tmp_auto_tags_st')) + count($tags_to_add); update_option('tmp_auto_tags_st', $counter); // Add tags to posts wp_set_object_terms( $object->ID, $tags_to_add, 'post_tag', true ); // Clean cache if ( 'page' == $object->post_type ) { clean_page_cache($object->ID); } else { clean_post_cache($object->ID); } return true; } return false; } ############## Helper Write Pages ############## /** * Display tags input for page * */ function helperTagsPage() { global $post_ID; ?>

(separate multiple tags with commas: cats, pet food, dogs)', 'simpletags'); ?>

exit ! return; } ?> message = __('No new tag specified!', 'simpletags'); $this->status = 'error'; return; } // String to array $old_tags = explode(',', $old); $new_tags = explode(',', $new); // Remove empty element and trim $old_tags = array_filter($old_tags, array(&$this, 'deleteEmptyElement')); $new_tags = array_filter($new_tags, array(&$this, 'deleteEmptyElement')); // If old/new tag are empty => exit ! if ( empty($old_tags) || empty($new_tags) ) { $this->message = __('No new/old valid tag specified!', 'simpletags'); $this->status = 'error'; return; } $counter = 0; if( count($old_tags) == count($new_tags) ) { // Rename only foreach ( (array) $old_tags as $i => $old_tag ) { $new_name = $new_tags[$i]; // Get term by name $term = get_term_by('name', $old_tag, 'post_tag'); if ( !$term ) { continue; } // Get objects from term ID $objects_id = get_objects_in_term( $term->term_id, 'post_tag', array('fields' => 'all_with_object_id')); // Delete old term wp_delete_term( $term->term_id, 'post_tag' ); // Set objects to new term ! (Append no replace) foreach ( (array) $objects_id as $object_id ) { wp_set_object_terms( $object_id, $new_name, 'post_tag', true ); } // Clean cache clean_object_term_cache( $objects_id, 'post_tag'); clean_term_cache($term->term_id, 'post_tag'); // Increment $counter++; } if ( $counter == 0 ) { $this->message = __('No tag renamed.', 'simpletags'); } else { $this->message = sprintf(__('Renamed tag(s) «%1$s» to «%2$s»', 'simpletags'), $old, $new); } } elseif ( count($new_tags) == 1 ) { // Merge // Set new tag $new_tag = $new_tags[0]; if ( empty($new_tag) ) { $this->message = __('No valid new tag.', 'simpletags'); $this->status = 'error'; return; } // Get terms ID from old terms names $terms_id = array(); foreach ( (array) $old_tags as $old_tag ) { $term = get_term_by('name', addslashes($old_tag), 'post_tag'); $terms_id[] = (int) $term->term_id; } // Get objects from terms ID $objects_id = get_objects_in_term( $terms_id, 'post_tag', array('fields' => 'all_with_object_id')); // No objects ? exit ! if ( !$objects_id ) { $this->message = __('No objects (post/page) found for specified old tags.', 'simpletags'); $this->status = 'error'; return; } // Delete old terms foreach ( (array) $terms_id as $term_id ) { wp_delete_term( $term_id, 'post_tag' ); } // Set objects to new term ! (Append no replace) foreach ( (array) $objects_id as $object_id ) { wp_set_object_terms( $object_id, $new_tag, 'post_tag', true ); $counter++; } // Test if term is also a category if ( is_term($new_tag, 'category') ) { // Edit the slug to use the new term $slug = sanitize_title($new_tag); $this->editTagSlug( $new_tag, $slug ); unset($slug); } // Clean cache clean_object_term_cache( $objects_id, 'post_tag'); clean_term_cache($terms_id, 'post_tag'); if ( $counter == 0 ) { $this->message = __('No tag merged.', 'simpletags'); } else { $this->message = sprintf(__('Merge tag(s) «%1$s» to «%2$s». %3$s objects edited.', 'simpletags'), $old, $new, $counter); } } else { // Error $this->message = sprintf(__('Error. No enough tags for rename. Too for merge. Choose !', 'simpletags'), $old); $this->status = 'error'; } return; } /** * trim and remove empty element * * @param string $element * @return string */ function deleteEmptyElement( &$element ) { $element = stripslashes($element); $element = trim($element); if ( !empty($element) ) { return $element; } } /** * Delete list of tags * * @param string $delete */ function deleteTagsByTagList( $delete ) { if ( trim( str_replace(',', '', stripslashes($delete)) ) == '' ) { $this->message = __('No tag specified!', 'simpletags'); $this->status = 'error'; return; } // In array + filter $delete_tags = explode(',', $delete); $delete_tags = array_filter($delete_tags, array(&$this, 'deleteEmptyElement')); // Delete tags $counter = 0; foreach ( (array) $delete_tags as $tag ) { $term = get_term_by('name', $tag, 'post_tag'); $term_id = (int) $term->term_id; if ( $term_id != 0 ) { wp_delete_term( $term_id, 'post_tag'); clean_term_cache( $term_id, 'post_tag'); $counter++; } } if ( $counter == 0 ) { $this->message = __('No tag deleted.', 'simpletags'); } else { $this->message = sprintf(__('%1s tag(s) deleted.', 'simpletags'), $counter); } } /** * Add tags for all or specified posts * * @param string $match * @param string $new */ function addMatchTags( $match, $new ) { if ( trim( str_replace(',', '', stripslashes($new)) ) == '' ) { $this->message = __('No new tag(s) specified!', 'simpletags'); $this->status = 'error'; return; } $match_tags = explode(',', $match); $new_tags = explode(',', $new); $match_tags = array_filter($match_tags, array(&$this, 'deleteEmptyElement')); $new_tags = array_filter($new_tags, array(&$this, 'deleteEmptyElement')); $counter = 0; if ( !empty($match_tags) ) { // Match and add // Get terms ID from old match names $terms_id = array(); foreach ( (array) $match_tags as $match_tag ) { $term = get_term_by('name', $match_tag, 'post_tag'); $terms_id[] = (int) $term->term_id; } // Get object ID with terms ID $objects_id = get_objects_in_term( $terms_id, 'post_tag', array('fields' => 'all_with_object_id') ); // Add new tags for specified post foreach ( (array) $objects_id as $object_id ) { wp_set_object_terms( $object_id, $new_tags, 'post_tag', true ); // Append tags $counter++; } // Clean cache clean_object_term_cache( $objects_id, 'post_tag'); clean_term_cache($terms_id, 'post_tag'); } else { // Add for all posts // Page or not ? $post_type_sql = ( $this->options['use_tag_pages'] == '1' ) ? "post_type IN('page', 'post')" : "post_type = 'post'"; // Get all posts ID global $wpdb; $objects_id = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE {$post_type_sql}"); // Add new tags for all posts foreach ( (array) $objects_id as $object_id ) { wp_set_object_terms( $object_id, $new_tags, 'post_tag', true ); // Append tags $counter++; } // Clean cache clean_object_term_cache( $objects_id, 'post_tag'); } if ( $counter == 0 ) { $this->message = __('No tag added.', 'simpletags'); } else { $this->message = sprintf(__('Tag(s) added to %1s post(s).', 'simpletags'), $counter); } } /** * Edit one or lots tags slugs * * @param string $names * @param string $slugs */ function editTagSlug( $names = '', $slugs = '') { if ( trim( str_replace(',', '', stripslashes($slugs)) ) == '' ) { $this->message = __('No new slug(s) specified!', 'simpletags'); $this->status = 'error'; return; } $match_names = explode(',', $names); $new_slugs = explode(',', $slugs); $match_names = array_filter($match_names, array(&$this, 'deleteEmptyElement')); $new_slugs = array_filter($new_slugs, array(&$this, 'deleteEmptyElement')); if ( count($match_names) != count($new_slugs) ) { $this->message = __('Tags number and slugs number isn\'t the same!', 'simpletags'); $this->status = 'error'; return; } else { $counter = 0; foreach ( (array) $match_names as $i => $match_name ) { // Sanitize slug + Escape $new_slug = sanitize_title($new_slugs[$i]); // Get term by name $term = get_term_by('name', $match_name, 'post_tag'); if ( !$term ) { continue; } // Increment $counter++; // Update term wp_update_term($term->term_id, 'post_tag', array('slug' => $new_slug)); // Clean cache clean_term_cache($term->term_id, 'post_tag'); } } if ( $counter == 0 ) { $this->message = __('No slug edited.', 'simpletags'); } else { $this->message = sprintf(__('%s slug(s) edited.', 'simpletags'), $counter); } return; } /** * Clean database - Remove empty terms * */ function cleanDatabase() { global $wpdb; // Counter $counter = 0; // Get terms id empty $terms_id = $wpdb->get_col("SELECT term_id FROM {$wpdb->terms} WHERE name IN ('', ' ', ' ', ' ') GROUP BY term_id"); if ( empty($terms_id) ) { $this->message = __('Nothing to muck. Good job !', 'simpletags'); return; } // Prepare terms SQL List $terms_list = "'" . implode("', '", $terms_id) . "'"; // Remove term empty $counter += $wpdb->query("DELETE FROM {$wpdb->terms} WHERE term_id IN ( {$terms_list} )"); // Get term_taxonomy_id from term_id on term_taxonomy table $tts_id = $wpdb->get_col("SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id IN ( {$terms_list} ) GROUP BY term_taxonomy_id"); if ( !empty($tts_id) ) { // Clean term_taxonomy table $counter += $wpdb->query("DELETE FROM {$wpdb->term_taxonomy} WHERE term_id IN ( {$terms_list} )"); // Prepare terms SQL List $tts_list = "'" . implode("', '", $tts_id) . "'"; // Clean term_relationships table $counter += $wpdb->query("DELETE FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN ( {$tts_list} )"); } // Delete cache clean_term_cache($terms_id, array('category', 'post_tag')); clean_object_term_cache($tts_list, 'post'); $this->message = sprintf(__('%s rows deleted. WordPress DB is clean now !', 'simpletags'), $counter); return; } /** * Click tags * */ function helperClickTags() { ?>

     -     -  

exit ! if ( ((int) wp_count_terms('post_tag', 'ignore_empty=true')) == 0 ) { return; } $this->all_tags = true; ?> message = __('Security problem. Try again. If this problem persist, contact plugin author.', 'simpletags'); $this->status = 'error'; return false; } if ( isset($_POST['tags']) ) { $counter = 0; foreach ( (array) $_POST['tags'] as $object_id => $tag_list ) { // Trim data $tag_list = trim(stripslashes($tag_list)); // String to array $tags = explode( ',', $tag_list ); // Remove empty and trim tag $tags = array_filter($tags, array(&$this, 'deleteEmptyElement')); // Add new tag (no append ! replace !) wp_set_object_terms( $object_id, $tags, 'post_tag' ); $counter++; // Clean cache if ( 'page' == $type ) { clean_page_cache($object_id); } else { clean_post_cache($object_id); } } if ( $type == 'page' ) { $this->message = sprintf(__('%s page(s) tags updated with success !', 'simpletags'), (int) $counter); } else { $this->message = sprintf(__('%s post(s) tags updated with success !', 'simpletags'), (int) $counter); } return true; } } return false; } ############## WP Options ############## /** * Update an option value -- note that this will NOT save the options. * * @param string $optname * @param string $optval */ function setOption($optname, $optval) { $this->options[$optname] = $optval; } /** * Save all current options * */ function saveOptions() { update_option($this->db_options, $this->options); } /** * Reset to default options * */ function resetToDefaultOptions() { update_option($this->db_options, $this->default_options); $this->options = $this->default_options; } /** * Delete Simple Tags options from DB. * */ function deleteAllOptions() { delete_option($this->db_options, $this->default_options); delete_option('widget_stags_cloud'); } ############## Ajax ############## /** * Ajax Dispatcher * */ function ajaxCheck() { if ( $_GET['st_ajax_action'] == 'get_tags' ) { $this->ajaxListTags(); } elseif ( $_GET['st_ajax_action'] == 'tags_from_yahoo' ) { $this->ajaxYahooTermExtraction(); } elseif ( $_GET['st_ajax_action'] == 'tags_from_tagthenet' ) { $this->ajaxTagTheNet(); } elseif ( $_GET['st_ajax_action'] == 'helper_js_collection' ) { $this->ajaxLocalTags( 'js_collection' ); } elseif ( $_GET['st_ajax_action'] == 'tags_from_local_db' ) { $this->ajaxSuggestLocal(); } elseif ( $_GET['st_ajax_action'] == 'click_tags' ) { $this->ajaxLocalTags( 'html_span' ); } } /** * Get tags list for manage tags page. * */ function ajaxListTags() { status_header( 200 ); header("Content-Type: text/javascript; charset=" . get_bloginfo('charset')); // Build param for tags $sort_order = attribute_escape(stripslashes($_GET['order'])); switch ($sort_order) { case 'natural' : $param = 'hide_empty=false&cloud_selection=name-asc'; break; case 'asc' : $param = 'hide_empty=false&cloud_selection=count-asc'; break; default : $param = 'hide_empty=false&cloud_selection=count-desc'; break; } $current_page = (int) $_GET['pagination']; $param .= '&number=LIMIT '. $current_page * $this->nb_tags . ', '.$this->nb_tags; // Get tags global $simple_tags; $tags = (array) $simple_tags->getTags($param, true, 'post_tag', true); // Build output echo ''; // Build pagination $ajax_url = $this->info['siteurl']. '/wp-admin/admin.php?st_ajax_action=get_tags'; // Order if ( isset($_GET['order']) ) { $ajax_url = $ajax_url . '&order='.$sort_order ; } ?> http://code.google.com/p/simple-tags/ // Yahoo ID : h4c6gyLV34Fs7nHCrHUew7XDAU8YeQ_PpZVrzgAGih2mU12F0cI.ezr6e7FMvskR7Vu.AA-- $yahoo_id = 'h4c6gyLV34Fs7nHCrHUew7XDAU8YeQ_PpZVrzgAGih2mU12F0cI.ezr6e7FMvskR7Vu.AA--'; $yahoo_api_host = 'search.yahooapis.com'; // Api URL $yahoo_api_path = '/ContentAnalysisService/V1/termExtraction'; // Api URL $tags = stripslashes($_POST['tags']); // Build params $param = 'appid='.$yahoo_id; // Yahoo ID $param .= '&context='.urlencode($content); // Post content if ( !empty($tags) ) { $param .= '&query='.urlencode($tags); // Existing tags } $param .= '&output=php'; // Get PHP Array ! $data = ''; // Only use fsockopen ! if ( function_exists('curl_init') && 1 == 0 ) { // Curl exist ? $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://'.$yahoo_api_host.$yahoo_api_path.'?'.$param); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); $data = curl_exec($curl); curl_close($curl); $data = unserialize($data); } else { // Fsocket $request = 'appid='.$yahoo_id.$param; $http_request = "POST $yahoo_api_path HTTP/1.0\r\n"; $http_request .= "Host: $yahoo_api_host\r\n"; $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; $http_request .= "Content-Length: " . strlen($request) . "\r\n"; $http_request .= "\r\n"; $http_request .= $request; if( false != ( $fs = @fsockopen( $yahoo_api_host, 80, $errno, $errstr, 3) ) && is_resource($fs) ) { fwrite($fs, $http_request); while ( !feof($fs) ) $data .= fgets($fs, 1160); // One TCP-IP packet fclose($fs); $data = explode("\r\n\r\n", $data, 2); } $data = unserialize($data[1]); } $data = (array) $data['ResultSet']['Result']; // Remove empty terms $data = array_filter($data, array(&$this, 'deleteEmptyElement')); $data = array_unique($data); foreach ( $data as $term ) { echo ''.$term.''."\n"; } echo '
'; exit(); } /** * Suggest tags from Tag The Net * */ function ajaxTagTheNet() { // Get data $content = stripslashes($_POST['content']) .' '. stripslashes($_POST['title']); $content = trim($content); if ( empty($content) ) { exit(); } // Send good header HTTP status_header( 200 ); header("Content-Type: text/javascript; charset=" . get_bloginfo('charset')); // Build params $api_host = 'tagthe.net'; // Api URL $api_path = '/api/'; // Api URL $param .= 'text='.urlencode($content); // Post content $param .= '&view=xml&count=50'; $data = ''; $request = $param; $http_request = "POST $api_path HTTP/1.0\r\n"; $http_request .= "Host: $api_host\r\n"; $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; $http_request .= "Content-Length: " . strlen($request) . "\r\n"; $http_request .= "\r\n"; $http_request .= $request; if( false != ( $fs = @fsockopen( $api_host, 80, $errno, $errstr, 3) ) && is_resource($fs) ) { fwrite($fs, $http_request); while ( !feof($fs) ) $data .= fgets($fs, 1160); // One TCP-IP packet fclose($fs); $data = explode("\r\n\r\n", $data, 2); } $data = $data[1]; $terms = $all_topics = $all_locations = $all_persons = $persons = $topics = $locations = array(); // Get all topics preg_match_all("/(.*?)(.*?)<\/dim>(.*?)/s", $data, $all_topics ); $all_topics = $all_topics[2][0]; preg_match_all("/(.*?)(.*?)<\/item>(.*?)/s", $all_topics, $topics ); $topics = $topics[2]; foreach ( (array) $topics as $topic ) { $terms[] = ''.$topic.''; } // Get all locations preg_match_all("/(.*?)(.*?)<\/dim>(.*?)/s", $data, $all_locations ); $all_locations = $all_locations[2][0]; preg_match_all("/(.*?)(.*?)<\/item>(.*?)/s", $all_locations, $locations ); $locations = $locations[2]; foreach ( (array) $locations as $location ) { $terms[] = ''.$location.''; } // Get all persons preg_match_all("/(.*?)(.*?)<\/dim>(.*?)/s", $data, $all_persons ); $all_persons = $all_persons[2][0]; preg_match_all("/(.*?)(.*?)<\/item>(.*?)/s", $all_persons, $persons ); $persons = $persons[2]; foreach ( (array) $persons as $person ) { $terms[] = ''.$person.''; } // Remove empty terms $terms = array_filter($terms, array(&$this, 'deleteEmptyElement')); $terms = array_unique($terms); echo implode("\n", $terms); echo '
'; exit(); } /** * Suggest tags from local database * */ function ajaxSuggestLocal() { if ( ((int) wp_count_terms('post_tag', 'ignore_empty=true')) == 0) { // No tags to suggest exit(); } // Get data $content = stripslashes($_POST['content']) .' '. stripslashes($_POST['title']); $content = trim($content); if ( empty($content) ) { exit(); } // Send good header HTTP status_header( 200 ); header("Content-Type: text/javascript; charset=" . get_bloginfo('charset')); // Get all terms global $wpdb; $terms = $wpdb->get_col(" SELECT DISTINCT name FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'post_tag' "); $terms = array_unique($terms); foreach ( (array) $terms as $term ) { $term = stripslashes($term); if ( is_string($term) && !empty($term) && stristr($content, $term) ) { echo ''.$term.''."\n"; } } // Clean memory $terms = array(); unset($terms, $term); echo '
'; exit(); } /** * Display a span list for click tags or a javascript collection for autocompletion script ! * * @param string $format */ function ajaxLocalTags( $format = 'span' ) { if ((int) wp_count_terms('post_tag', 'ignore_empty=true') == 0 ) { // No tags to suggest exit(); } // Send good header HTTP status_header( 200 ); header("Content-Type: text/javascript; charset=" . get_bloginfo('charset')); if ( $format == 'js_collection' ) { echo 'collection = ['; } // Get all terms global $wpdb; $terms = $wpdb->get_col(" SELECT DISTINCT name FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'post_tag' "); $terms = array_unique($terms); switch ($format) { case 'html_span' : foreach ( (array) $terms as $term ) { $term = stripslashes($term); echo ''.$term.''."\n"; } break; case 'js_collection' : default: $flag = false; foreach ( (array) $terms as $term ) { $term = stripslashes($term); if ( $flag === false) { echo '"'.str_replace('"', '\"', $term).'"'; $flag = true; } else { echo ', "'.str_replace('"', '\"', $term).'"'; } } break; } // Clean memory $terms = array(); unset($terms, $term); if ( $format == 'js_collection' ) { echo '];'; } else { echo '
'; } exit(); } ############## Admin WP Helper ############## /** * Display plugin Copyright * */ function printAdminFooter() { ?> message != '') { $message = $this->message; $status = $this->status; $this->message = $this->status = ''; // Reset } if ( $message ) { ?>

info['install_url'].'/inc/css/simple-tags.admin.css?ver='.$this->version.'" type="text/css" />'; echo ''; } /** * Ouput formatted options * * @param array $option_data * @return string */ function printOptions( $option_data ) { // Get actual options $option_actual = (array) $this->options; // Generate output $output = ''; foreach( $option_data as $section => $options) { $output .= "\n" . '
' . $this->getNiceTitleOptions($section) . '' . "\n"; foreach((array) $options as $option) { // Helper if ( $option[2] == 'helper' ) { $output .= '' . "\n"; continue; } switch ( $option[2] ) { case 'checkbox': $input_type = '' . "\n"; break; case 'dropdown': $selopts = explode('/', $option[3]); $seldata = ''; foreach( (array) $selopts as $sel) { $seldata .= '' . "\n"; } $input_type = '' . "\n"; break; case 'text-color': $input_type = '50) ? ' style="width: 95%" ' : '') . 'id="' . $option[0] . '" name="' . $option[0] . '" value="' . htmlspecialchars($option_actual[ $option[0] ]) . '" size="' . $option[3] .'" />
' . "\n"; break; case 'text': default: $input_type = '50) ? ' style="width: 95%" ' : '') . 'id="' . $option[0] . '" name="' . $option[0] . '" value="' . htmlspecialchars($option_actual[ $option[0] ]) . '" size="' . $option[3] .'" />' . "\n"; break; } // Additional Information $extra = ''; if( !empty($option[4]) ) { $extra = '
' . __($option[4]) . '
' . "\n"; } // Output $output .= '' . "\n"; } $output .= '
' . $option[4] . '
' . $input_type . ' ' . $extra . '
' . "\n"; $output .= '
' . "\n"; } return $output; } /** * Get nice title for tabs title option * * @param string $id * @return string */ function getNiceTitleOptions( $id = '' ) { switch ( $id ) { case 'general': return __('General', 'simpletags'); break; case 'administration': return __('Administration', 'simpletags'); break; case 'metakeywords': return __('Meta Keyword', 'simpletags'); break; case 'embeddedtags': return __('Embedded Tags', 'simpletags'); break; case 'tagspost': return __('Tags for Current Post', 'simpletags'); break; case 'relatedposts': return __('Related Posts', 'simpletags'); break; case 'relatedtags': return __('Related Tags', 'simpletags'); break; case 'tagcloud': return __('Tag cloud', 'simpletags'); break; } return ''; } /** * Escape string so that it can used in Regex. E.g. used for [tags]...[/tags] * * @param string $content * @return string */ function regexEscape( $content ) { return strtr($content, array("\\" => "\\\\", "/" => "\\/", "[" => "\\[", "]" => "\\]")); } /** * Add initial ST options in DB * */ function installSimpleTags() { $options_from_table = get_option( $this->db_options ); if ( !$options_from_table ) { $this->resetToDefaultOptions(); } } } ?>