Plugin Directory

Changeset 1495269


Ignore:
Timestamp:
09/13/2016 04:12:18 PM (10 years ago)
Author:
smartware.cc
Message:

Version 3.5

Location:
hashtagger
Files:
16 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • hashtagger/trunk/hashtagger.php

    r1477619 r1495269  
    88Author URI: http://petersplugins.com
    99Text Domain: hashtagger
    10 License: GPL2
    11 */
    12 
    13 /*  Copyright 2016 Peter Raschendorfer (email : [email protected])
    14 
    15     This program is free software; you can redistribute it and/or modify
    16     it under the terms of the GNU General Public License, version 2, as
    17     published by the Free Software Foundation.
    18 
    19     This program is distributed in the hope that it will be useful,
    20     but WITHOUT ANY WARRANTY; without even the implied warranty of
    21     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    22     GNU General Public License for more details.
    23 
    24     You should have received a copy of the GNU General Public License
    25     along with this program; if not, write to the Free Software
    26     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     10License: GPL2+
     11License URI: http://www.gnu.org/licenses/gpl-2.0.txt
    2712*/
    2813
     
    3116}
    3217
    33 class Hashtagger {
    34   public $plugin_name;
    35   public $plugin_slug;
    36   public $version;
    37   public $wp_url;
    38   public $my_url;
    39   public $dc_url;
    40   public $settings;
    41   protected $regex_general;
    42   protected $regex_notag;
    43   protected $regex_users;
    44   protected $regex_cash;
    45   protected $admin;
    46  
    47     public function __construct() {
    48         $this->plugin_name = 'hashtagger';
    49     $this->plugin_slug = 'hashtagger';
    50         $this->version = '3.4';
    51     $this->get_settings();
    52     $this->init();
    53     $this->init_admin();
    54     }
    55  
    56   private function init() {
    57    
    58     $this->wp_url = 'https://wordpress.org/plugins/' . $this->plugin_slug;
    59     $this->my_url = 'http://petersplugins.com/free-wordpress-plugins/' . $this->plugin_slug;
    60     $this->dc_url = 'http://petersplugins.com/docs/' . $this->plugin_slug;
    61    
    62     $this->regex_general = '/(^|[\s!\.:;\?(>])#([\p{L}][\p{L}0-9_]+)(?=[^<>]*(?:<|$))/u';
    63     $this->regex_notag = '/(^|[\s!\.:;\?(>])\+#([\p{L}][\p{L}0-9_]+)(?=[^<>]*(?:<|$))/u';
    64     if ( true === $this->settings['tags_allow_numeric'] ) {
    65       // Allow Tags to start with numbers
    66       $this->regex_general = '/(^|[\s!\.:;\?(>])#([\p{L}0-9][\p{L}0-9_]+)(?=[^<>]*(?:<|$))/u';
    67       $this->regex_notag = '/(^|[\s!\.:;\?(>])\+#([\p{L}0-9][\p{L}0-9_]+)(?=[^<>]*(?:<|$))/u';
    68     }
    69     $this->regex_users = '/(^|[\s!\.:;\?(>])\@([\p{L}][\p{L}0-9_]+)(?=[^<>]*(?:<|$))/u';
    70     $this->regex_cash = '/(^|[\s!\.:;\?(>])\$([A-Z][A-Z\-]+)(?=[^<>]*(?:<|$))/u';
    71    
    72     add_action( 'init', array( $this, 'add_text_domains' ) );
     18require_once( plugin_dir_path( __FILE__ ) . '/inc/class-hashtagger.php' );
    7319
    74     add_action( 'save_post', array( $this, 'generate_tags' ), 19 );
    75    
    76     // *** For Plugin User Submitted Posts https://wordpress.org/plugins/user-submitted-posts/ (since v 3.2)
    77     //     had to use filter usp_new_post insetad of action usp_insert_after because tags are created AFTER usp_insert_after
    78     add_filter( 'usp_new_post', array( $this, 'process_content_for_user_submitted_posts' ), 9999 );
    79    
    80     // *** For Barley - Inline Editing Plugin for WordPress (since v 3.2)
    81     //     had to override their save function...
    82     add_action( 'wp_ajax_barley_update_post',  array( $this, 'process_content_for_barely' ), 0 );
    83    
    84    
    85     if ( ! is_admin() ) {
    86       add_filter( 'the_content', array( $this, 'process_content' ), 9999 );
    87      
    88       if ( $this->settings['sectiontype_title'] ) {
    89         add_filter( 'the_title', array( $this, 'process_title' ), 9999 );
    90       }
    91      
    92       if ( $this->settings['sectiontype_excerpt'] ) {
    93         add_filter( 'the_excerpt', array( $this, 'process_excerpt' ), 9999 );
    94       }
    95     }
    96    
    97     add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_settings_link' ) );
    98    
    99   }
    100  
    101   private function init_admin() {
    102     if ( is_admin() ) {
    103       $this->admin = new Hashtagger_Admin( $this );
    104     }
    105   }
    106  
    107   // addd text domains
    108   function add_text_domains() { 
    109     load_plugin_textdomain( 'hashtagger' );
    110   }
    111  
    112   // get all settings
    113   private function get_settings() {
    114     $this->settings = array();
    115     $this->settings['posttype_page'] = ( get_option( 'swcc_htg_posttype_page', '1' ) == 1 ) ?  true : false;
    116     $this->settings['posttype_custom'] = ( get_option( 'swcc_htg_posttype_custom', '1' ) == 1 ) ?  true : false;
    117     $this->settings['sectiontype_title'] = ( get_option( 'swcc_htg_sectiontype_title', '0' ) == 1 ) ?  true : false;
    118     $this->settings['sectiontype_excerpt'] = ( get_option( 'swcc_htg_sectiontype_excerpt', '0' ) == 1 ) ?  true : false;
    119     $this->settings['advanced_nodelete'] = ( get_option( 'swcc_htg_advanced_nodelete', '0' ) == 0 ) ?  false : true;
    120     $this->settings['usernames'] = get_option( 'swcc_htg_usernames', 'NONE' );
    121     if ( ! in_array( $this->settings['usernames'], array( 'NONE', 'PROFILE', 'WEBSITE-SAME', 'WEBSITE-NEW' ) ) ) {
    122       $this->settings['usernames'] = 'NONE';
    123     }
    124     $this->settings['cashtags'] = get_option( 'swcc_htg_cashtags', 'NONE' );
    125     if ( ! in_array( $this->settings['cashtags'], array( 'NONE', 'MARKETWATCH-SAME', 'MARKETWATCH-NEW', 'GOOGLE-SAME', 'GOOGLE-NEW', 'YAHOO-SAME', 'YAHOO-NEW' ) ) ) {
    126       $this->settings['cashtags'] = 'NONE';
    127     }
    128     $this->settings['usernamesnick'] = ( get_option( 'swcc_htg_usernamesnick', '0' ) == 0 ) ?  false : true;
    129     $this->settings['cssclass'] = get_option( 'swcc_htg_cssclass', '' );
    130     $this->settings['cssclass_notag'] = get_option( 'swcc_htg_cssclass_notag', '' );
    131     $this->settings['usernamescssclass'] = get_option( 'swcc_htg_usernamescssclass', '' );
    132     $this->settings['cashtagcssclass'] = get_option( 'swcc_htg_cashtagcssclass', '' );
    133     $this->settings['display_nosymbols'] = ( get_option( 'swcc_htg_display_nosymbols', '0' ) == 0 ) ?  false : true;
    134     $this->settings['tags_allow_numeric'] = ( get_option( 'swcc_htg_tags_allow_numeric', '0' ) == 0 ) ?  false : true;
    135     $tagbase = get_option( 'tag_base' );
    136     if ( $tagbase != '' ) {
    137       $tagbase .= '/';
    138     }
    139     $this->settings['tagbase'] = $tagbase;
    140   }
    141  
    142   // this function extracts the hashtags from content and adds them as tags to the post
    143   // since v 3.0 option to not delete unused tags
    144   function generate_tags( $postid ) {
    145     $post_type = get_post_type( $postid );
    146     $custom = get_post_types( array( 'public' => true, '_builtin' => false ), 'names', 'and' );
    147     if ( ( 'post' == $post_type ) || ( 'page' == $post_type && $this->settings['posttype_page'] ) || ( in_array( $post_type, $custom ) && $this->settings['posttype_custom'] ) ) {
    148       $content = get_post_field('post_content', $postid);
    149       if ( $this->settings['sectiontype_title'] ) {
    150         $content = $content . ' ' . get_post_field('post_title', $postid);
    151       }
    152       if ( $this->settings['sectiontype_excerpt'] ) {
    153         $content = $content . ' ' . get_post_field('post_excerpt', $postid);
    154       }
    155       wp_set_post_tags( $postid, $this->get_hashtags_from_content( strip_tags( $content ) ), $this->settings['advanced_nodelete'] );
    156     }
    157   }
    158  
    159   // this function returns an array of hashtags from a given content - used by generate_tags()
    160   function get_hashtags_from_content( $content ) {
    161     preg_match_all( $this->regex_general, $content, $matches );
    162     return implode( ', ', $matches[2] );
    163   }
    164  
    165   // general function to process content
    166   function work( $content ) {
    167     $content = str_replace( '##', '#', preg_replace_callback( $this->regex_notag, array( $this, 'make_link_notag' ), preg_replace_callback( $this->regex_general, array( $this, 'make_link_tag' ), $content ) ) );
    168     if ( $this->settings['usernames'] != 'NONE' ) {
    169       $content = str_replace( '@@', '@', preg_replace_callback( $this->regex_users, array( $this, 'make_link_usernames' ), $content ) );
    170     }
    171     if ( $this->settings['cashtags'] != 'NONE' ) {
    172       $content = str_replace( '$$', '$', preg_replace_callback( $this->regex_cash, array( $this, 'make_link_cashtags' ), $content ) );
    173     }
    174     return $content;
    175   }
    176  
    177   // replace hashtags with links when displaying content
    178   // since v 3.0 post type depending
    179   function process_content( $content ) {
    180     global $post;
    181     $post_type = get_post_type();
    182     $custom = get_post_types( array( 'public' => true, '_builtin' => false ), 'names', 'and' );
    183     if ( ( 'post' == $post_type ) || ( 'page' == $post_type && $this->settings['posttype_page'] ) || ( in_array( $post_type, $custom ) && $this->settings['posttype_custom'] ) ) {
    184       $content = $this->work( $content );
    185     }
    186     return $content;
    187   }
    188  
    189   // function to process title (since v 3.0) - calls process_content
    190   function process_title( $title, $id = null ) {
    191     return $this->process_content( $title );
    192   }
    193  
    194   // function to process excerpt (since v 3.0) - calls process_content
    195   function process_excerpt( $excerpt ) {
    196     return $this->process_content( $excerpt );
    197   }
    198  
    199   // callback functions for preg_replace_callback used in content()
    200   function make_link_tag( $match ) {
    201     return $this->make_link( $match, true );
    202   }
    203   function make_link_notag( $match ) {
    204     return $this->make_link( $match, false );
    205   }
    206   function make_link_usernames( $match ) {
    207     return $this->make_link_users( $match, $this->settings['usernames'] );
    208   }
    209   function make_link_cashtags( $match ) {
    210     return $this->make_link_cash( $match, $this->settings['cashtags'] );
    211   }
    212  
    213   // function to generate tag link
    214   private function make_link( $match, $mktag ) {
    215     // $term = get_term_by( 'name', $match[2], 'post_tag' );
    216     // get_term_by does not work if Polylang is active, because it always returns us the tag of any language - this may be the right language or not...
    217     // get_terms works also if Polylang is active - and it does not return the tag in all languages but only in the needed one - thats perfect, so we need no extra solition for Polylang
    218     if ( $match[2] != strip_tags( $match[2] )  ) {
    219       $content = $match[0];
    220     } else {
    221       $terms = get_terms( array( 'taxonomy' => 'post_tag', 'name' => $match[2], 'number' => 1 ) );
    222       if ( ! $terms ) {
    223         $content = $match[0];
    224       } else {
    225         $term = $terms[0];
    226         $termid = $term->term_id;
    227         $slug = $term->slug;
    228         if ( $mktag ) {
    229           $css = $this->settings['cssclass'];
    230         } else {
    231           $css = $this->settings['cssclass_notag'];
    232         }
    233         if ( $css != '' ) {
    234           $css = ' class="' . $css . '"';
    235         }
    236         if ( ! $this->settings['display_nosymbols'] ) {
    237           $symbol = '#';
    238         } else {
    239           $symbol = '';
    240         }
    241         $content = $match[1] . '<a' . $css . ' href="' . get_tag_link( $termid ) . '">' . $symbol . $match[2] . '</a>';
    242       }
    243     }
    244     return $content;
    245   }
    246 
    247   // function to generate user link
    248   private function make_link_users( $match, $link ) {
    249     $user = false;
    250     $username = $match[2];
    251     // get by nickname or by login name
    252     if ( ! $this->settings['usernamesnick'] ) {
    253       // get by login name - default
    254       $user = get_user_by( 'login', $username );
    255     } else {
    256       // get by nickname
    257       $users = get_users( array( 'meta_key' => 'nickname', 'meta_value' => $username ) );
    258       if ( count( $users ) == 1 ) {
    259         // should result in one user
    260         $user = $users[0];
    261       }
    262     }
    263     if ( !$user ) {
    264       $content = $match[0];
    265     } else {
    266       if ( $link != 'PROFILE' ) {
    267         $linkto = $user->user_url;
    268       } else {
    269         $linkto = '';
    270       }
    271       if ( $linkto == '' ) {
    272         $linkto = get_author_posts_url( $user->ID );
    273       }
    274       if ( $link == 'WEBSITE-NEW' ) {
    275         $target = ' target="_blank"';
    276       } else {
    277         $target = '';
    278       }
    279       $css = $this->settings['usernamescssclass'];
    280       if ( $css != '' ) {
    281         $css = ' class="' . $css . '"';
    282       }
    283       if ( ! $this->settings['display_nosymbols'] ) {
    284         $symbol = '@';
    285       } else {
    286         $symbol = '';
    287       }
    288       $content = $match[1] . '<a' . $css . ' href="' . $linkto . '"'. $target . '>' . $symbol . $match[2] . '</a>';
    289     }
    290     return $content;
    291   }
    292  
    293   // function to generate cashtag link
    294   private function make_link_cash( $match, $link ) {
    295     $user = false;
    296     if ( $link == 'MARKETWATCH-SAME' || $link == 'MARKETWATCH-NEW' ) {
    297       $linkto = 'http://www.marketwatch.com/investing/Stock/' . $match[2];
    298     } elseif ( $link == 'GOOGLE-SAME' || $link == 'GOOGLE-NEW' ) {
    299       $linkto = 'https://www.google.com/finance?q=' . $match[2];
    300     } else {
    301       $linkto = 'http://finance.yahoo.com/q?s=' . $match[2];
    302     }
    303     if ( $link == 'MARKETWATCH-NEW' || $link == 'GOOGLE-NEW' || $link == 'YAHOO-NEW' ) {
    304       $target = ' target="_blank"';
    305     } else {
    306       $target = '';
    307     }
    308     $css = $this->settings['cashtagcssclass'];
    309     if ( $css != '' ) {
    310       $css = ' class="' . $css . '"';
    311     }
    312     if ( ! $this->settings['display_nosymbols'] ) {
    313         $symbol = '$';
    314       } else {
    315         $symbol = '';
    316       }
    317     $content = $match[1] . '<a' . $css . ' href="' . $linkto . '"'. $target . '>' . $symbol . $match[2] . '</a>';
    318     return $content;
    319   }
    320  
    321  
    322   // *** For Plugin User Submitted Posts https://wordpress.org/plugins/user-submitted-posts/ (since v 3.2)
    323   function process_content_for_user_submitted_posts( $new_user_post ) {
    324     $this->generate_tags( $new_user_post['id'] );
    325     return $new_user_post;
    326   }
    327  
    328   // *** For Barley - Inline Editing Plugin for WordPress (since v 3.2)
    329   function process_content_for_barely() {
    330     // this function overrides barley_update_post in functions_posts.php of the Barely plugin
    331    
    332     // -- Taken from Barely
    333     $json            = array();
    334     $json['success'] = false;
    335     $columns         = array(
    336                       'the_title'   => 'post_title',
    337                       'the_content' => 'post_content');
    338 
    339     // Only proceed if we have a post_id
    340     if ( isset($_POST['p']) && ! empty($_POST['p']) ) {
    341       $k               = trim(urldecode($_POST['k']));
    342       $v               = trim(urldecode($_POST['v']));
    343       $pid             = trim(urldecode($_POST['p']));
    344 
    345       // Strip trailing BR tag in FireFox
    346       if ( $k === 'the_title' ) {
    347         $v = preg_replace('/(.*)<br[^>]*>/i', '$1', $v);
    348       }
    349 
    350       // For the_title and the_content only
    351       if (array_key_exists($k, $columns)) {
    352           $res = wp_update_post(array(
    353               'ID'         => $pid,
    354               $columns[$k] => $v
    355           ));
    356       }
    357 
    358       // Save an Advanced Custom Field
    359       if ( strpos($k, 'field_') !== false ) {
    360         $res = update_field($k,$v,$pid);
    361       }
    362 
    363       // Save a WordPress Custom Field
    364       if ( strpos($k, 'field_') === false && !array_key_exists($k, $columns) ) {
    365         $res = update_post_meta($pid,$k,$v);
    366       }
    367      
    368       // -- ** added for hashtagger **
    369       if ( $k === 'the_content' ) {
    370         $this->generate_tags( $pid );
    371       }
    372       // -- ** added for hashtagger **
    373 
    374       // Good? No? Yes?
    375       $json['success'] = ($res > 0) ? true : false;
    376 
    377     } // end post_id
    378 
    379     header('Content-Type: application/json');
    380     print json_encode($json);
    381     exit();
    382     // -- Taken from Barely
    383    
    384   }
    385 
    386   // uninstall plugin
    387   function uninstall() {
    388     if( is_multisite() ) {
    389       $this->uninstall_network();
    390     } else {
    391       $this->uninstall_single();
    392     }
    393   }
    394  
    395   // uninstall network wide
    396   function uninstall_network() {
    397     global $wpdb;
    398     $activeblog = $wpdb->blogid;
    399     $blogids = $wpdb->get_col( esc_sql( 'SELECT blog_id FROM ' . $wpdb->blogs ) );
    400     foreach ($blogids as $blogid) {
    401       switch_to_blog( $blogid );
    402       $this->uninstall_single();
    403     }
    404     switch_to_blog( $activeblog );
    405   }
    406  
    407   // uninstall single blog
    408   function uninstall_single() {
    409     foreach ( $this->settings as $key => $value) {
    410       if ( $key != 'tagbase' ) {
    411         delete_option( 'swcc_htg_' . $key );
    412       }
    413     }
    414   }
    415  
    416   // add a link to settings page in plugin list
    417   function add_settings_link( $links ) {
    418     return array_merge( $links, array( '<a href="' . admin_url( 'options-general.php?page=hashtaggersettings' ) . '">' . __( 'Settings' ) . '</a>') );
    419   }
    420  
    421 }
    422 
    423 class Hashtagger_Admin {
    424 
    425   protected $version;
    426   protected $settings;
    427   protected $caller;
    428   protected $regnonce;
    429  
    430   public function __construct( Hashtagger $caller ) {
    431     $this->caller = $caller;
    432     $this->version = $caller->version;
    433     $this->settings = $caller->settings;
    434     $this->regnonce = 'hashtagger_regenerate';
    435     $this->init();
    436   }
    437  
    438   private function init() {
    439     add_action( 'admin_head', array( $this, 'admin_style' ) );
    440     add_action( 'admin_menu', array( $this, 'admin_menu' ) );
    441     add_action( 'admin_init', array( $this, 'admin_init' ) );
    442     add_action( 'wp_ajax_hashtagger_regenerate', array( &$this, 'admin_hashtagger_regenerate' ) );
    443   }
    444  
    445   // adds the options page to admin menu
    446   function admin_menu() {
    447     add_options_page( 'hashtagger ' . __( 'Settings' ), '#hashtagger', 'manage_options', 'hashtaggersettings', array( $this, 'admin_page' ) );
    448   }
    449  
    450   // add css
    451   function admin_style() {
    452     if ( get_current_screen()->id == 'settings_page_hashtaggersettings' ) {
    453       ?>
    454       <style type="text/css">
    455         .hashtagger_settings_form input[type="text"], .hashtagger_settings_form select {
    456           border-width:2px;
    457           padding:10px;
    458           border-style:solid;
    459           border-radius:5px;
    460           height: auto !important;
    461         }
    462         .hashtagger_settings_form input[type="text"]:not(:focus), .hashtagger_settings_form select:not(:focus) {
    463           box-shadow: 0px 0px 5px 0px rgba(42,42,42,.75);
    464         }
    465         .hashtagger_settings_form input[type="checkbox"], #hashtagger_ajax_area input[type="checkbox"] {
    466             display: none;
    467         }
    468         .hashtagger_settings_form input[type="checkbox"] + label.check, #hashtagger_ajax_area input[type="checkbox"] + label.check {
    469           display: inline-block; 
    470           border: 2px solid #DDD;
    471           box-shadow: 0px 0px 5px 0px rgba(42,42,42,.75);
    472           border-style:solid;
    473           border-radius:5px;
    474           width: 30px;
    475           height: 30px;
    476           line-height: 30px;
    477           text-align: center;
    478           font-family: dashicons;
    479           font-size: 2em;
    480           margin-right: 10px;
    481         }
    482         .hashtagger_settings_form input[type="checkbox"]:disabled + label.check, #hashtagger_ajax_area input[type="checkbox"]:disabled + label.check {
    483           background-color: #DDD;
    484         }
    485         .hashtagger_settings_form input[type="checkbox"] + label.check:before, #hashtagger_ajax_area input[type="checkbox"] + label.check:before {
    486           content: ""; 
    487         }
    488         .hashtagger_settings_form input[type="checkbox"]:checked + label.check:before, #hashtagger_ajax_area input[type="checkbox"]:checked + label.check:before {
    489           content: "\f147";
    490         }
    491       </style>
    492       <?php
    493     }
    494   }
    495  
    496 // creates the options page
    497   function admin_page() {
    498     $url = admin_url( 'options-general.php?page=' . $_GET['page'] . '&tab=' );
    499     $current_tab = 'general';
    500     if ( isset( $_GET['tab'] ) ) {
    501       $current_tab = $_GET['tab'];
    502     }
    503     if ( ! in_array( $current_tab, array('general', 'tags', 'usernames', 'cashtags', 'advanced', 'posttype', 'sectiontype', 'css', 'display', 'regenerate') ) ) {
    504       $current_tab = 'general';
    505     }
    506     ?>
    507     <div class="wrap">
    508       <?php screen_icon(); ?>
    509       <h2 style="min-height: 32px; line-height: 32px; padding-left: 40px; background-image: url(<?php echo plugins_url( 'pluginicon.png', __FILE__ ); ?>); background-repeat: no-repeat; background-position: left center"><a href="<?php echo $this->caller->my_url; ?>"><?php echo $this->caller->plugin_name; ?></a> <?php echo __( 'Settings', 'hashtagger' ); ?></h2>
    510       <hr />
    511       <p>Plugin Version: <?php echo $this->version; ?> <a class="dashicons dashicons-editor-help" href="<?php echo $this->caller->wp_url; ?>/changelog/"></a></p>
    512       <h2 class="nav-tab-wrapper">
    513         <a href="<?php echo $url . 'general'; ?>" class="nav-tab<?php if ( 'general' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Information' ); ?></a>
    514         <a href="<?php echo $url . 'tags'; ?>" class="nav-tab<?php if ( 'tags' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Tags' ); ?></a>
    515         <a href="<?php echo $url . 'usernames'; ?>" class="nav-tab<?php if ( 'usernames' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Usernames' ); ?></a>
    516         <a href="<?php echo $url . 'cashtags'; ?>" class="nav-tab<?php if ( 'cashtags' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Cashtags' ); ?></a>
    517         <a href="<?php echo $url . 'advanced'; ?>" class="nav-tab<?php if ( 'advanced' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Advanced' ); ?></a>
    518         <a href="<?php echo $url . 'posttype'; ?>" class="nav-tab<?php if ( 'posttype' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Post Types', 'hashtagger' ); ?></a>
    519         <a href="<?php echo $url . 'sectiontype'; ?>" class="nav-tab<?php if ( 'sectiontype' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Section Types', 'hashtagger' ); ?></a>
    520         <a href="<?php echo $url . 'css'; ?>" class="nav-tab<?php if ( 'css' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'CSS Style', 'hashtagger' ); ?></a>
    521         <a href="<?php echo $url . 'display'; ?>" class="nav-tab<?php if ( 'display' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Display', 'hashtagger' ); ?></a>
    522         <a href="<?php echo $url . 'regenerate'; ?>" class="nav-tab<?php if ( 'regenerate' == $current_tab ) { echo ' nav-tab-active'; } ?>"><?php _e( 'Regnerate', 'hashtagger' ); ?></a>
    523       </h2>
    524       <div id="poststuff">
    525         <div id="post-body" class="metabox-holder<?php if ( 'regenerate' != $current_tab ) { echo ' columns-2'; } ?>">
    526           <div id="post-body-content">
    527             <div class="meta-box-sortables ui-sortable">
    528               <?php if ( 'regenerate' == $current_tab ) { ?>
    529                 <?php
    530                   $objects = $this->get_objects();
    531                 ?>
    532                 <div class="postbox">
    533                   <div class="inside">
    534                     <p><strong><?php _e( 'Process all existing objects using the current settings', 'hashtagger' ); ?></strong></p><hr />
    535                     <?php
    536                       if ( count( $objects ) == 0 ) {
    537                         echo '<p>' . __( 'No objects to process!', 'hashtagger' ) . '</p>';
    538                       } else {
    539                         echo '<div id="hashtagger_ajax_area"><p><span class="form-invalid">' . __( 'JavaScript must be enabled to use this feature.' ) . '</span></p></div>';
    540                         add_action( 'admin_print_footer_scripts', array( $this, 'add_regenerate_js' ) );
    541                       }
    542                     ?>
    543                   </div>
    544                 </div>
    545               <?php } else { ?>
    546                 <form method="post" action="options.php" class="hashtagger_settings_form">
    547                   <div class="postbox">
    548                     <div class="inside">
    549                       <?php if ( 'general' == $current_tab ) { ?>
    550                         <p><strong>#hashtag <?php _e( 'Permalinks' ); ?></strong></p>
    551                         <hr />
    552                         <p>#hashtags <?php _e( 'currently link to', 'hashtagger'); ?> <code style="white-space: nowrap"><?php echo $this->tag_base_url() . '[hashtag]'; ?></code>.</p>
    553                         <p><?php printf( __( 'The <b>Tag base</b> for the Archive URL can be changed on %s page', 'hashtagger' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_general_tagbase"></a>', '<a href="'. admin_url( 'options-permalink.php' ) .'">' . __( 'Permalink Settings' ) . '</a>' ); ?>.</p>
    554                       <?php } else {
    555                         settings_fields( 'hashtagger_settings_' . $current_tab );   
    556                         do_settings_sections( 'hashtagger_settings_section_' . $current_tab );
    557                         submit_button();
    558                       } ?>
    559                     </div>
    560                   </div>
    561                 </form>
    562               <?php } ?>
    563             </div>
    564           </div>
    565           <?php if ( 'regenerate' != $current_tab ) { $this->show_meta_boxes(); } ?>
    566         </div>
    567         <br class="clear">
    568       </div>   
    569     </div>
    570     <?php
    571   }
    572  
    573   // funtion to get the base directory for tags
    574   private function tag_base_url() {
    575     return trailingslashit( get_site_url() . '/' . $this->settings['tagbase'] );
    576   }
    577  
    578   // init the admin section
    579   function admin_init() {
    580    
    581     add_settings_section( 'hashtagger-settings-tags', '', array( $this, 'admin_section_tags_title' ), 'hashtagger_settings_section_tags' );
    582     register_setting( 'hashtagger_settings_tags', 'swcc_htg_tags_allow_numeric' ) ;
    583     add_settings_field( 'swcc_htg_settings_tags_numeric', __( 'Allow numeric', 'hashtagger') . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_tags_allow_numeric"></a>' , array( $this, 'admin_tags_allow_numeric' ), 'hashtagger_settings_section_tags', 'hashtagger-settings-tags', array( 'label_for' => 'swcc_htg_tags_allow_numeric' ) );
    584    
    585     add_settings_section( 'hashtagger-settings-usernames', '', array( $this, 'admin_section_usernames_title' ), 'hashtagger_settings_section_usernames' );
    586     register_setting( 'hashtagger_settings_usernames', 'swcc_htg_usernames' ) ;
    587     register_setting( 'hashtagger_settings_usernames', 'swcc_htg_usernamesnick' );
    588     add_settings_field( 'swcc_htg_settings_usernames', __( 'Link @usernames', 'hashtagger' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_usernames_usernames"></a>', array( $this, 'admin_usernames' ), 'hashtagger_settings_section_usernames', 'hashtagger-settings-usernames', array( 'label_for' => 'swcc_htg_usernames' ) );
    589     add_settings_field( 'swcc_htg_settings_usernamesnick', __( '@nicknames', 'hashtagger' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_usernames_nicknames"></a>', array( $this, 'admin_usernamesnick' ), 'hashtagger_settings_section_usernames', 'hashtagger-settings-usernames', array( 'label_for' => 'swcc_htg_usernamesnick' ) );   
    590    
    591     add_settings_section( 'hashtagger-settings-cashtags', '', array( $this, 'admin_section_cashtag_title' ), 'hashtagger_settings_section_cashtags' );
    592     register_setting( 'hashtagger_settings_cashtags', 'swcc_htg_cashtags' ) ;
    593     add_settings_field( 'swcc_htg_settings_cashtags', __( '$cashtags', 'hashtagger' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_cashtags"></a>', array( $this, 'admin_cashtags' ), 'hashtagger_settings_section_cashtags', 'hashtagger-settings-cashtags', array( 'label_for' => 'swcc_htg_cashtags' ) );
    594    
    595     add_settings_section( 'hashtagger-settings-advanced', '', array( $this, 'admin_section_advanced_title' ), 'hashtagger_settings_section_advanced' );
    596     register_setting( 'hashtagger_settings_advanced', 'swcc_htg_advanced_nodelete' );
    597     add_settings_field( 'swcc_htg_settings_advanced_nodelete', __( 'Do not delete unused Tags', 'hashtagger') . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_advanced_nodelete"></a>' , array( $this, 'admin_advanced_nodelete' ), 'hashtagger_settings_section_advanced', 'hashtagger-settings-advanced', array( 'label_for' => 'swcc_htg_advanced_nodelete' ) );
    598    
    599     add_settings_section( 'hashtagger-settings-posttype', '', array( $this, 'admin_section_posttype_title' ), 'hashtagger_settings_section_posttype' );
    600     register_setting( 'hashtagger_settings_posttype', 'swcc_htg_posttype_page' );
    601     register_setting( 'hashtagger_settings_posttype', 'swcc_htg_posttype_custom' );
    602     add_settings_field( 'swcc_htg_settings_posttype_post', __( 'Posts' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_posttypes_posts"></a>', array( $this, 'admin_posttype_post' ), 'hashtagger_settings_section_posttype', 'hashtagger-settings-posttype', array( 'label_for' => 'swcc_htg_posttype_post' ) );
    603     add_settings_field( 'swcc_htg_settings_posttype_page', __( 'Pages' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_posttypes_pages"></a>', array( $this, 'admin_posttype_page' ), 'hashtagger_settings_section_posttype', 'hashtagger-settings-posttype', array( 'label_for' => 'swcc_htg_posttype_page' ) );
    604     add_settings_field( 'swcc_htg_settings_posttype_custom', __( 'Custom Post Types', 'hashtagger' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_posttypes_custom"></a>', array( $this, 'admin_posttype_custom' ), 'hashtagger_settings_section_posttype', 'hashtagger-settings-posttype', array( 'label_for' => 'swcc_htg_posttype_custom' ) );
    605    
    606     add_settings_section( 'hashtagger-settings-sectiontype', '', array( $this, 'admin_section_sectiontype_title' ), 'hashtagger_settings_section_sectiontype' );
    607     register_setting( 'hashtagger_settings_sectiontype', 'swcc_htg_sectiontype_title' );
    608     register_setting( 'hashtagger_settings_sectiontype', 'swcc_htg_sectiontype_excerpt' );
    609     add_settings_field( 'swcc_htg_sectiontype_title', __( 'Title' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_sectiontypes_title"></a>', array( $this, 'admin_sectiontype_title' ), 'hashtagger_settings_section_sectiontype', 'hashtagger-settings-sectiontype', array( 'label_for' => 'swcc_htg_sectiontype_title' ) );
    610     add_settings_field( 'swcc_htg_sectiontype_excerpt', __( 'Excerpt' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_sectiontypes_excerpt"></a>', array( $this, 'admin_sectiontype_excerpt' ), 'hashtagger_settings_section_sectiontype', 'hashtagger-settings-sectiontype', array( 'label_for' => 'swcc_htg_sectiontype_excerpt' ) );
    611     add_settings_field( 'swcc_htg_sectiontype_content', __( 'Content' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_sectiontypes_content"></a>', array( $this, 'admin_sectiontype_content' ), 'hashtagger_settings_section_sectiontype', 'hashtagger-settings-sectiontype', array( 'label_for' => 'swcc_htg_sectiontype_content' ) );
    612    
    613     add_settings_section( 'hashtagger-settings-css', '', array( $this, 'admin_section_css_title' ), 'hashtagger_settings_section_css' );
    614     register_setting( 'hashtagger_settings_css', 'swcc_htg_cssclass', array( $this, 'admin_cssclass_validate' ) );
    615     register_setting( 'hashtagger_settings_css', 'swcc_htg_cssclass_notag', array( $this, 'admin_cssclass_validate' ) );
    616     register_setting( 'hashtagger_settings_css', 'swcc_htg_usernamescssclass', array( $this, 'admin_cssclass_validate' ) );
    617     register_setting( 'hashtagger_settings_css', 'swcc_htg_cashtagcssclass', array( $this, 'admin_cssclass_validate' ) );
    618     add_settings_field( 'swcc_htg_settings_cssclass', __( 'CSS class name(s) for #hashtags', 'hashtagger' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_css_hashtags"></a>', array( $this, 'admin_cssclass' ), 'hashtagger_settings_section_css', 'hashtagger-settings-css', array( 'label_for' => 'swcc_htg_cssclass' ) );
    619     add_settings_field( 'swcc_htg_settings_cssclass_notag', __( 'CSS class name(s) for +#hashtag links', 'hashtagger' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_css_hashtaglinks"></a>', array( $this, 'admin_cssclass_notag' ), 'hashtagger_settings_section_css', 'hashtagger-settings-css', array( 'label_for' => 'swcc_htg_cssclass_notag' ) );
    620     add_settings_field( 'swcc_htg_settings_usernamescssclass', __( 'CSS class name(s) for @usernames', 'hashtagger' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_css_usernames"></a>', array( $this, 'admin_usernamescssclass' ), 'hashtagger_settings_section_css', 'hashtagger-settings-css', array( 'label_for' => 'swcc_htg_usernamescssclass' ) );
    621     add_settings_field( 'swcc_htg_settings_cashtagcssclass', __( 'CSS class name(s) for $cashtags', 'hashtagger' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_css_usernames"></a>', array( $this, 'admin_cashtagcssclass' ), 'hashtagger_settings_section_css', 'hashtagger-settings-css', array( 'label_for' => 'swcc_htg_cashtagcssclass' ) );
    622    
    623     add_settings_section( 'hashtagger-settings-display', '', array( $this, 'admin_section_display_title' ), 'hashtagger_settings_section_display' );
    624     register_setting( 'hashtagger_settings_display', 'swcc_htg_display_nosymbols' );
    625     add_settings_field( 'swcc_htg_display_nosymbols', __( 'Remove symbols from links', 'hashtagger') . ' <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_display"></a>' , array( $this, 'admin_display_nosymbols' ), 'hashtagger_settings_section_display', 'hashtagger-settings-display', array( 'label_for' => 'swcc_htg_display_nosymbols' ) );
    626   }
    627  
    628   // *
    629   // * ADMIN SECTIONS
    630   // *
    631  
    632   // * Tags Section
    633  
    634   // echo title for tags settings section
    635   function admin_section_tags_title() {
    636     echo '<p><strong>' . __( 'Tag-Syntax', 'hashtagger' ) . ':</strong></p><hr />';
    637   }
    638  
    639   // handle the settings field : allow numeric
    640   function admin_tags_allow_numeric() {
    641     echo '<input type="checkbox" name="swcc_htg_tags_allow_numeric" id="swcc_htg_tags_allow_numeric" value="1"' . ( ( $this->settings['tags_allow_numeric'] == true ) ?  'checked="checked"' : '' ) . ' /><label for="swcc_htg_tags_allow_numeric" class="check"></label>' . __( 'Enable tags starting with numbers', 'hashtagger' ) . '<br /><span class="dashicons dashicons-warning"></span><strong>' . __( 'Please note that this is not commonly used. Twitter, Instagram, YouTube, Pinterest, Google+ and other platforms do not support hashtags starting with or using only numbers.', 'hashtagger');
    642   }
    643  
    644   // * Usernames Section
    645 
    646   // echo title for usernames settings section
    647   function admin_section_usernames_title() {
    648     echo '<p><strong>' . __( 'Handling of @usernames', 'hashtagger' ) . ':</strong></p><hr />';
    649   }
    650  
    651   // handle the settings field : user names
    652   function admin_usernames() {
    653     $curvalue = $this->settings['usernames'];
    654     echo '<select name="swcc_htg_usernames" id="swcc_htg_usernames">';
    655     echo '<option value="NONE"' . ( ( $curvalue == 'NONE' ) ? ' selected="selected"' : '' ) . '>' . __('Ignore @usernames', 'hashtagger' ) . '</option>';
    656     echo '<option value="PROFILE"' . ( ( $curvalue == 'PROFILE' ) ? ' selected="selected"' : '' ) . '>' . __( 'Link @usernames to users profile page', 'hashtagger' ) . '</option>';
    657     echo '<option value="WEBSITE-SAME"' . ( ( $curvalue == 'WEBSITE-SAME' ) ? ' selected="selected"' : '' ) . '>' . __( 'Link @usernames to users website in same browser tab', 'hashtagger') . '</option>';
    658     echo '<option value="WEBSITE-NEW"' . ( ( $curvalue == 'WEBSITE-NEW' ) ? ' selected="selected"' : '' ) . '>' . __( 'Link @usernames to users website in new browser tab', 'hashtagger') . '</option>';
    659     echo '</select>';
    660   }
    661  
    662   // handle the settings field : use nicknames instead of usernames
    663   function admin_usernamesnick() {
    664     echo '<input type="checkbox" name="swcc_htg_usernamesnick" id="swcc_htg_usernamesnick" value="1"' . ( ( $this->settings['usernamesnick'] == true ) ?  'checked="checked"' : '' ) . ' /><label for="swcc_htg_usernamesnick" class="check"></label>' . __( 'Use @nicknames instead of @usernames', 'hashtagger' ) . '<br /><div class="dashicons dashicons-shield"></div><strong>' . __( 'Highly recommended to enhance WordPress security!', 'hashtagger') . ' <a href="http://petersplugins.com/wp-hashtagger/hashtagger-plugin-why-you-should-use-nicknames-instead-of-usernames/">' . __( 'Read more', 'hashtagger' ) . '</a>';
    665   }
    666  
    667   // echo title for cashtags settings section
    668   function admin_section_cashtag_title() {
    669     echo '<p><strong>' . __( 'Handling of $cashtags', 'hashtagger' ) . ':</strong></p><hr />';
    670   }
    671  
    672   // handle the settings field : cashtags
    673   function admin_cashtags() {
    674     $curvalue = $this->settings['cashtags'];
    675     echo '<select name="swcc_htg_cashtags" id="swcc_htg_cashtags">';
    676     echo '<option value="NONE"' . ( ( $curvalue == 'NONE' ) ? ' selected="selected"' : '' ) . '>' . __('Ignore $cashtags', 'hashtagger' ) . '</option>';
    677     echo '<option value="MARKETWATCH-SAME"' . ( ( $curvalue == 'MARKETWATCH-SAME' ) ? ' selected="selected"' : '' ) . '>' . __( 'Link $cashtags to MarketWatch in same browser tab', 'hashtagger' ) . '</option>';
    678     echo '<option value="MARKETWATCH-NEW"' . ( ( $curvalue == 'MARKETWATCH-NEW' ) ? ' selected="selected"' : '' ) . '>' . __( 'Link $cashtags to MarketWatch in new browser tab', 'hashtagger' ) . '</option>';
    679     echo '<option value="GOOGLE-SAME"' . ( ( $curvalue == 'GOOGLE-SAME' ) ? ' selected="selected"' : '' ) . '>' . __( 'Link $cashtags to Google Finance in same browser tab', 'hashtagger') . '</option>';
    680     echo '<option value="GOOGLE-NEW"' . ( ( $curvalue == 'GOOGLE-NEW' ) ? ' selected="selected"' : '' ) . '>' . __( 'Link $cashtags to Google Finance in new browser tab', 'hashtagger') . '</option>';
    681     echo '<option value="YAHOO-SAME"' . ( ( $curvalue == 'YAHOO-SAME' ) ? ' selected="selected"' : '' ) . '>' . __( 'Link $cashtags to Yahoo Finance in same browser tab', 'hashtagger') . '</option>';
    682     echo '<option value="YAHOO-NEW"' . ( ( $curvalue == 'YAHOO-NEW' ) ? ' selected="selected"' : '' ) . '>' . __( 'Link $cashtags to Yahoo Finance in new browser tab', 'hashtagger') . '</option>';
    683     echo '</select>';
    684   }
    685 
    686   // * Advanced Section
    687  
    688   // echo title for advanced settings section
    689   function admin_section_advanced_title() {
    690     echo '<p><strong>' . __( 'Handling of existing Tags', 'hashtagger' ) . ':</strong></p><hr />';
    691   }
    692  
    693   // handle the settings field : no delete
    694   function admin_advanced_nodelete() {
    695     echo '<input type="checkbox" name="swcc_htg_advanced_nodelete" id="swcc_htg_advanced_nodelete" value="1"' . ( ( $this->settings['advanced_nodelete'] == true ) ?  'checked="checked"' : '' ) . ' /><label for="swcc_htg_advanced_nodelete" class="check"></label>';
    696   }
    697  
    698   // * Post Type Section
    699  
    700   // echo title for posttype settings section
    701   function admin_section_posttype_title() {
    702     echo '<p><strong>' . __( 'Post Types to process', 'hashtagger' ) . ':</strong></p><hr />';
    703   }
    704  
    705   // handle the settings field : posttype 'post' - this is only a dummy, maybe for future use, currently posts are always on
    706   function admin_posttype_post() {
    707     echo '<input type="checkbox" name="swcc_htg_posttype_post" id="swcc_htg_posttype_post" value="1" checked="checked" disabled="disabled" /><label for="swcc_htg_posttype_post" class="check"></label>';
    708   }
    709  
    710   // handle the settings field : posttype 'page'
    711   function admin_posttype_page() {
    712     echo '<input type="checkbox" name="swcc_htg_posttype_page" id="swcc_htg_posttype_page" value="1"' . ( ( $this->settings['posttype_page'] == true ) ?  'checked="checked"' : '' ) . ' /><label for="swcc_htg_posttype_page" class="check"></label>';
    713   }
    714  
    715   // handle the settings field : posttype 'custom post types'
    716   function admin_posttype_custom() {
    717     echo '<input type="checkbox" name="swcc_htg_posttype_custom" id="swcc_htg_posttype_custom" value="1"' . ( ( $this->settings['posttype_custom'] == true ) ?  'checked="checked"' : '' ) . ' /><label for="swcc_htg_posttype_custom" class="check"></label>';
    718   }
    719  
    720   // * Section Type Section
    721  
    722   // echo title for sectiontype settings section
    723   function admin_section_sectiontype_title() {
    724     echo '<p><strong>' . __( 'Section Types to process', 'hashtagger' ) . ':</strong></p><hr />';
    725   }
    726  
    727   // handle the settings field : sectiontype 'title'
    728   function admin_sectiontype_title() {
    729     echo '<input type="checkbox" name="swcc_htg_sectiontype_title" id="swcc_htg_sectiontype_title" value="1"' . ( ( $this->settings['sectiontype_title'] == true ) ?  'checked="checked"' : '' ) . ' /><label for="swcc_htg_sectiontype_title" class="check"></label>';
    730   }
    731  
    732   // handle the settings field : sectiontype 'excerpt'
    733   function admin_sectiontype_excerpt() {
    734     echo '<input type="checkbox" name="swcc_htg_sectiontype_excerpt" id="swcc_htg_sectiontype_excerpt" value="1"' . ( ( $this->settings['sectiontype_excerpt'] == true ) ?  'checked="checked"' : '' ) . ' /><label for="swcc_htg_sectiontype_excerpt" class="check"></label>';
    735   }
    736  
    737   // handle the settings field : sectiontype 'content' ' - this is only a dummy, maybe for future use, currently content is always on
    738   function admin_sectiontype_content() {
    739     echo '<input type="checkbox" name="swcc_htg_sectiontype_content" id="swcc_htg_sectiontype_content" value="1" checked="checked" disabled="disabled" /><label for="swcc_htg_sectiontype_content" class="check"></label>';
    740   }
    741  
    742   // * CSS Style Section
    743 
    744   // echo title for css settings section
    745   function admin_section_css_title() {
    746     echo '<p><strong>' . __( 'CSS Classes to style links', 'hashtagger' ) .':</strong></p><hr />';
    747   }
    748  
    749   // handle the settings field : css class
    750   function admin_cssclass() {
    751     echo '<input class="regular-text" type="text" name="swcc_htg_cssclass" id="swcc_htg_cssclass" value="' . $this->settings['cssclass'] . '" />';
    752   }
    753 
    754   // handle the settings field : css class notag
    755   function admin_cssclass_notag() {
    756     echo '<input class="regular-text" type="text" name="swcc_htg_cssclass_notag" id="swcc_htg_cssclass_notag" value="' . $this->settings['cssclass_notag'] . '" />';
    757   }
    758  
    759   // handle the settings field : css class for usernames
    760   function admin_usernamescssclass() {
    761     echo '<input class="regular-text" type="text" name="swcc_htg_usernamescssclass" id="swcc_htg_usernamescssclass" value="' . $this->settings['usernamescssclass'] . '" />';
    762   }
    763  
    764   // handle the settings field : css class for cashtags
    765   function admin_cashtagcssclass() {
    766     echo '<input class="regular-text" type="text" name="swcc_htg_cashtagcssclass" id="swcc_htg_cashtagcssclass" value="' . $this->settings['cashtagcssclass'] . '" />';
    767   }
    768  
    769   // validate input : css class
    770   function admin_cssclass_validate( $input ) {
    771     $classes = explode(' ', $input);
    772     $css = '';
    773     foreach( $classes as $class ) {
    774       $css = $css . sanitize_html_class( $class ) . ' ';
    775     }
    776     return rtrim( $css );
    777   }
    778  
    779   // * Display Section
    780  
    781   // echo title for display settings section
    782   function admin_section_display_title() {
    783     echo '<p><strong>' . __( 'Link display', 'hashtagger' ) . ':</strong></p><hr />';
    784   }
    785  
    786   // handle the settings field : do not display symbols
    787   function admin_display_nosymbols() {
    788     echo '<input type="checkbox" name="swcc_htg_display_nosymbols" id="swcc_htg_display_nosymbols" value="1"' . ( ( $this->settings['display_nosymbols'] == true ) ?  'checked="checked"' : '' ) . ' /><label for="swcc_htg_display_nosymbols" class="check"></label>';
    789   }
    790  
    791   // this function returns an array of all objects to process depending on settings
    792   function get_objects() {
    793     $post_types = array();
    794     if ( $this->settings['posttype_custom'] ) {
    795       $post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'names', 'and' );
    796     }
    797     if ( $this->settings['posttype_page'] ) {
    798       $post_types[] = 'page';
    799     }
    800     $post_types[] = 'post';
    801     return get_posts( array( 'post_type' => $post_types, 'posts_per_page' => -1 ) );
    802   }
    803    
    804   // add JS to regenerate all objets to footer
    805   function add_regenerate_js() {
    806     $objects = $this->get_objects();
    807     $ids = array();
    808     foreach( $objects as $object ) {
    809       $ids[] = $object->ID;
    810     }
    811     $ids = implode( ',', $ids );
    812     ?>
    813       <script type='text/javascript'>
    814         var object_ids = [<?php echo $ids; ?>];
    815         var objects = <?php echo count( $objects ); ?>;
    816         var counter = 0;
    817         var abort = false;
    818         jQuery( '#hashtagger_ajax_area' ).html( '<p><input type="checkbox" name="hashtagger_regenerate_confirmation" id="hashtagger_regenerate_confirmation" value="ok" /><label for="hashtagger_regenerate_confirmation" class="check"></label><span id="hashtagger_regenerate_confirmation_hint"><?php _e( 'Please confirm to regenerate', 'hashtagger' ); ?> <a class="dashicons dashicons-editor-help" href="' . $this->caller->dc_url . '/#settings_regeneration"></a></span></p><p><input type="button" name="sumbit_regnerate" id="sumbit_regnerate" class="button button-primary button-large" value="<?php _e( 'Process all objects', 'hashtagger' ); ?> (<?php echo count( $objects ); ?>)"  /></p>' );
    819         jQuery( '#sumbit_regnerate' ).click( function() {
    820           if ( jQuery( '#hashtagger_regenerate_confirmation' ).prop( 'checked' ) ) {
    821             jQuery( '#hashtagger_ajax_area' ).html( '<p><?php _e( 'Please be patient while objects are processed. Do not close or leave this page.', 'hashtagger' ); ?></p><p><div style="width: 100%; height: 40px; border: 2px solid #222; border-radius: 5px; background-color: #FFF"><div id="hashtagger_regnerate_progressbar" style="width: 0; height: 100%; background-image: url(<?php echo plugins_url( 'progress.png', __FILE__ ); ?>); background-repeat: repeat-x" ></div></div></p><p id="hashtagger_abort_area"><input type="button" name="cancel_regnerate" id="cancel_regnerate" class="button button-secondary button-large" value="<?php _e( 'Abort regeneration', 'hashtagger' ); ?>" /></p>' );
    822             jQuery( '#cancel_regnerate' ).click( function() {
    823               abort = true;
    824               jQuery( '#hashtagger_abort_area' ).html( '<strong><?php _e( 'Aborting process...', 'hashtagger' ); ?></strong>' );
    825             });
    826             regenerate_object();
    827           } else {
    828             jQuery( '#hashtagger_regenerate_confirmation_hint' ).addClass( 'form-invalid' );
    829           }
    830         });
    831         function regenerate_object() {
    832           var object_id = object_ids[0];
    833           jQuery.ajax( {
    834             type: 'POST',
    835             url: ajaxurl,
    836             data: { 'action': 'hashtagger_regenerate', 'id': object_id },
    837             success: function(response) { 
    838               counter++;
    839               jQuery( '#hashtagger_regnerate_progressbar' ).width( ( counter * 100 / objects ) + '%' );
    840               if ( abort ) {
    841                 abortstring = '<?php _e( 'Process aborted. {COUNTER} of {OBJECTS} objects have been processed.', 'hashtagger'); ?>';
    842                 abortstring = abortstring.replace( '{COUNTER}', counter );
    843                 abortstring = abortstring.replace( '{OBJECTS}', objects );
    844                 jQuery( '#hashtagger_abort_area' ).html( abortstring );
    845               } else {
    846                 object_ids.shift();
    847                 if ( object_ids.length > 0 ) {
    848                   regenerate_object();
    849                 } else {
    850                   donestring = '<?php _e( 'All done. {OBJECTS} objects have been processed.', 'hashtagger' ); ?>';
    851                   donestring = donestring.replace( '{OBJECTS}', objects );
    852                   jQuery( '#hashtagger_abort_area' ).html( donestring );
    853                 }
    854               }
    855             }
    856           } );
    857         }
    858       </script>
    859     <?php
    860   }
    861  
    862   // handle ajax call for one object
    863   function admin_hashtagger_regenerate() {
    864     $id = (int) $_REQUEST['id'];
    865     $this->caller->generate_tags( $id );
    866     echo $id;
    867     die();
    868   }
    869  
    870   // *
    871   // * ADMIN SECTIONS END
    872   // *
    873  
    874   // *
    875   // * META BOXES
    876   // *
    877  
    878   // show meta boxes
    879   function show_meta_boxes() {
    880     ?>
    881     <div id="postbox-container-1" class="postbox-container">
    882       <div class="meta-box-sortables">
    883         <div class="postbox">
    884           <h3><span><?php _e( 'Like this Plugin?', 'hashtagger' ); ?></span></h3>
    885           <div class="inside">
    886             <ul>
    887               <li><div class="dashicons dashicons-wordpress"></div>&nbsp;&nbsp;<a href="<?php echo $this->caller->wp_url; ?>/"><?php _e( 'Please rate the plugin', 'hashtagger' ); ?></a></li>
    888               <li><div class="dashicons dashicons-admin-home"></div>&nbsp;&nbsp;<a href="<?php echo $this->caller->my_url; ?>/"><?php _e( 'Plugin homepage', 'hashtagger'); ?></a></li>
    889               <li><div class="dashicons dashicons-admin-home"></div>&nbsp;&nbsp;<a href="http://petersplugins.com/"><?php _e( 'Author homepage', 'hashtagger' );?></a></li>
    890               <li><div class="dashicons dashicons-googleplus"></div>&nbsp;&nbsp;<a href="http://g.petersplugins.com"><?php _e( 'Authors Google+ Page', 'hashtagger' ); ?></a></li>
    891               <li><div class="dashicons dashicons-facebook-alt"></div>&nbsp;&nbsp;<a href="http://f.petersplugins.com"><?php _e( 'Authors facebook Page', 'hashtagger' ); ?></a></li>
    892             </ul>
    893           </div>
    894         </div>
    895         <div class="postbox">
    896           <h3><span><?php _e( 'Need help?', 'hashtagger' ); ?></span></h3>
    897           <div class="inside">
    898             <ul>
    899               <li><div class="dashicons dashicons-book-alt"></div>&nbsp;&nbsp;<a href="<?php echo $this->caller->dc_url; ?>"><?php _e( 'Take a look at the Plugin Doc', 'hashtagger' ); ?></a></li>
    900               <li><div class="dashicons dashicons-wordpress"></div>&nbsp;&nbsp;<a href="<?php echo $this->caller->wp_url; ?>/faq/"><?php _e( 'Take a look at the FAQ section', 'hashtagger' ); ?></a></li>
    901               <li><div class="dashicons dashicons-wordpress"></div>&nbsp;&nbsp;<a href="http://wordpress.org/support/plugin/<?php echo $this->caller->plugin_slug; ?>/"><?php _e( 'Take a look at the Support section', 'hashtagger'); ?></a></li>
    902               <li><div class="dashicons dashicons-admin-comments"></div>&nbsp;&nbsp;<a href="http://petersplugins.com/contact/"><?php _e( 'Feel free to contact the Author', 'hashtagger' ); ?></a></li>
    903             </ul>
    904           </div>
    905         </div>
    906         <div class="postbox">
    907           <h3><span><?php _e( 'Translate this Plugin', 'hashtagger' ); ?></span></h3>
    908           <div class="inside">
    909             <p><?php _e( 'It would be great if you\'d support the hashtagger Plugin by adding a new translation or keeping an existing one up to date!', 'hashtagger' ); ?></p>
    910             <p><a href="https://translate.wordpress.org/projects/wp-plugins/<?php echo $this->caller->plugin_slug; ?>"><?php _e( 'Translate online', 'hashtagger' ); ?></a></p>
    911           </div>
    912         </div>
    913       </div>
    914     </div>
    915     <?php
    916   }
    917 
    918 }
    919 
    920 $hashtagger = new Hashtagger();
     20$hashtagger = new Hashtagger( __FILE__ );
    92121
    92222// this function can be used in theme
     
    92626  return $htg->work( $content );
    92727}
     28?>
  • hashtagger/trunk/readme.txt

    r1477628 r1495269  
    55Requires at least: 3.0
    66Tested up to: 4.6
    7 Stable tag: 3.4
     7Stable tag: 3.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Tag your posts by using #hashtags
     11Use hashtags in WordPress. #hashtags are automatically added to the post as tags. Supports @usernames and $cashtags. Highly customizable!
    1212
    1313== Description ==
    1414
    15 > Use #hashtags and @usernames in your posts.
     15> Use #hashtags, @usernames and $cashtags in your posts.
    1616
    1717**See also [Plugin Homepage](http://petersplugins.com/free-wordpress-plugins/hashtagger/) and [Plugin Doc](http://petersplugins.com/docs/hashtagger/)**
     
    1919https://www.youtube.com/watch?v=cNNn1VLz4zs
    2020
    21 = New in Version 3.4 =
    22 
    23 hashtagger now supports usage of the same hashtag in different languages in combination wit Polylang.
     21= New in Version 3.5 =
     22
     23hashtagger now optionally allows to only generate tags from #hashtags without showing links.
    2424
    2525= #hashtags =
     
    2727This plugin uses the [WordPress Tag system](http://codex.wordpress.org/Posts_Tags_Screen) to field your post under the desired tags. When saving a post each [#hashtag](http://en.wikipedia.org/wiki/Hashtag) is added as a "normal" tag (without leading hash) to the post, so it is fully compatible with existing tags.
    2828
    29 When showing a post all #hashtags are automatically converted to links leading to the corresponding tag archive page.
     29When showing a post all #hashtags are automatically converted to links leading to the corresponding tag archive page. **Creating links can be disabled to use this plugin only for automatic tag creation**.
    3030
    3131**Caution:** It is not necessary to generally adapt existing posts, because their tags stay unchanged. But keep in mind that on saving a post all existing tas are **removed** and replaced by the tags found in your post! **This behavior can be changed in the Plugin Settings Area.**
     
    154154
    1551551. hashtagger Settings General Section: This section shows the current Tag base setting
    156 2. hashtagger Settings Tags Section: Option to allow hashtags starting with numbers
     1562. hashtagger Settings Tags Section: Options to allow hashtags starting with numbers and disable link creation (screenshot is outdated)
    1571573. hashtagger Settings Usernames Section: Handling of @usernames respectively @nicknames can be changed here
    1581584. hashtagger Settings Cashtags Section: Handling of $cashtags can be changed here
     
    166166== Changelog ==
    167167
     168= 3.5 (2016-09-13) =
     169* Option to only create tags from #hashtags, but do not show links
     170* Bug fix Tag Regeneration
     171
    168172= 3.4 (2016-08-18) =
    169173* Enhanced Polylang support to allow same hashtag in several languages
     
    212216== Upgrade Notice ==
    213217
     218= 3.5 =
     219* Option to only create tags from #hashtags, but do not show links
     220
    214221= 3.4 =
    215222* Enhanced Polylang support to allow same hashtag in several languages, option to allow hashtags starting with numbers
Note: See TracChangeset for help on using the changeset viewer.