public function __construct()
 {
     global $stt2extat_settings, $stt2extat_sanitize;
     $this->plugin_data = stt2extat_get_plugin_data();
     $this->data = $stt2extat_sanitize->data();
     $this->set = $stt2extat_settings;
     $this->prefix = $this->blog_prefix = '';
     if (function_exists('got_url_rewrite')) {
         if (!got_url_rewrite()) {
             $this->prefix = '/index.php';
         }
     }
     if (is_multisite() && !is_subdomain_install() && is_main_site()) {
         $this->blog_prefix = '/blog';
     }
     add_action('admin_init', array($this, 'page_init'));
     add_filter('admin_head', array($this, 'options_permalink_add_js'));
     add_filter('set-screen-option', array($this, 'term_stats_set_screen_option'), 10, 3);
     add_action('admin_menu', array($this, 'plugin_page'));
     add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
     add_action('wp_ajax_stt2extat_ajax_table', array($this, 'ajax_table'));
     add_action('wp_ajax_stt2extat_delete_all_terms', array($this, 'delete_all_terms'));
     add_action('wp_ajax_stt2extat_migrate_stt2_terms', array($this, 'migrate_stt2_terms'));
     add_action('wp_ajax_stt2extat_check_relevant_terms', array($this, 'check_relevant_terms'));
 }
 /**
  * function filter plugin_action_links
  *
  * @since 1.0
  *
  */
 public function plugin_action_links($actions, $file)
 {
     static $plugin;
     if (!isset($plugin)) {
         $plugin = wp_normalize_path(STT2EXTAT_PLUGIN_BASENAME);
     }
     if ($plugin == $file) {
         $link = sprintf('<a href="%s">%s</a>', admin_url('options-general.php?page=' . stt2extat_get_plugin_data('TextDomain')), __('Manage', 'stt2extat'));
         $settings = array('settings' => $link);
         $actions = array_merge($settings, $actions);
     }
     return $actions;
 }
 public function page()
 {
     $page = isset($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : stt2extat_get_plugin_data()->TextDomain;
     $this->page = sanitize_key($page);
 }
 /**
  * Data for admin plugin interface abd settings
  *
  * @since 1.1
  *
  */
 public function data()
 {
     $data = array();
     $additional_data = apply_filters('stt2extat_data', $data);
     if (!is_array($additional_data)) {
         $additional_data = $data;
     }
     $data['active'] = array('id' => 1, 'parameter' => 'active', 'normal' => 'abstain', 'optional' => array('abstain' => __('Disabled', 'stt2extat'), 'n' => 'PHP', 'y' => 'Ajax'), 'subtitle' => __('Activate Get Referrer', 'stt2extat'), 'description' => __('Method to get terms from referrer.', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'boolean');
     $data['auto'] = array('id' => 2, 'parameter' => 'auto', 'normal' => 'abstain', 'optional' => array('abstain' => __('Disabled', 'stt2extat'), 'n' => 'HTML', 'y' => 'Ajax'), 'subtitle' => __('Auto Add', 'stt2extat'), 'description' => __('Add list automatically right after post content', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'string');
     $data['number'] = array('id' => 3, 'parameter' => 'number', 'normal' => (int) 5, 'optional' => (int) 10, 'subtitle' => __('Number List', 'stt2extat'), 'description' => __('Maximum number of terms on list', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'integer');
     $data['text_header'] = array('id' => 4, 'parameter' => 'text_header', 'normal' => __('Incoming Terms', 'stt2extat'), 'optional' => __('Terms', 'stt2extat'), 'subtitle' => __('Text Header', 'stt2extat'), 'description' => __('Title of terms list', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'string');
     $data['html_heading'] = array('id' => 5, 'parameter' => 'html_heading', 'normal' => 'h3', 'optional' => array('h1' => '&lt;h1&gt;', 'h2' => '&lt;h2&gt;', 'h3' => '&lt;h3&gt;', 'h4' => '&lt;h4&gt;', 'h5' => '&lt;h5&gt;', 'h6' => '&lt;h6&gt;', 'span' => '&lt;span&gt;', 'div' => '&lt;div&gt;', 'p' => '&lt;p&gt;'), 'subtitle' => __('HTML Heading', 'stt2extat'), 'description' => __('HTML heading of text title', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'string');
     $data['display'] = array('id' => 6, 'parameter' => 'display', 'normal' => 'ul', 'optional' => array('ul' => 'Bullet', 'ol' => 'Number', 'span' => 'Inline'), 'subtitle' => __('List Style', 'stt2extat'), 'description' => __('List style of terms', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'string');
     $data['stopwords'] = array('id' => 7, 'parameter' => 'stopwords', 'normal' => array('abortion', 'attack', 'bomb', 'casino', 'cocaine', 'death', 'die', 'erection', 'gamble', 'gambling', 'heroin', 'marijuana', 'masturbation', 'nude', 'pedophile', 'penis', 'poker', 'p**n', 'pussy', 'sex', 'squirt', 'terrorist', 'xxx'), 'optional' => array(), 'subtitle' => __('Filter Words', 'stt2extat'), 'description' => __('Filter word or phrase, add per-line or by comma', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'array');
     $data['convert'] = array('id' => 8, 'parameter' => 'convert', 'normal' => 'n', 'optional' => array('n' => __('Disabled', 'stt2extat'), 'post' => 'Link to post content', 'search' => 'Link to search page'), 'subtitle' => __('Convert Text Link', 'stt2extat'), 'description' => sprintf(wp_kses(__('Convert terms into links. Set custom structure for search link on <a href="%1$s">Permalink Settings</a> page.', 'stt2extat'), array('a' => array('href' => array()))), admin_url('options-permalink.php#stt2extat_permalink')), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'string');
     $data['count'] = array('id' => 9, 'parameter' => 'count', 'normal' => 'n', 'optional' => array('n' => __('Disabled', 'stt2extat'), 'tooltips' => 'Tooltips', 'sup' => 'Sup'), 'subtitle' => __('Hits Count', 'stt2extat'), 'description' => __('Type of terms counts display.', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'string');
     $data['schedule'] = array('id' => 10, 'parameter' => 'schedule', 'normal' => array('post_modified' => (int) 0, 'count' => (int) 1), 'optional' => array('post_modified' => (int) 0, 'count' => (int) 1), 'subtitle' => __('Auto Delete Terms', 'stt2extat'), 'description' => __('Delete unused terms before these days, 0 = disabled. Scheduled once weekly.', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'array');
     $data['useragent'] = array('id' => 11, 'parameter' => 'useragent', 'normal' => array('alhea.com' => 'q', 'ask.com' => 'q', 'baidu.com' => 'wd', 'bing.com' => 'q', 'blogsearch.google.com' => 'q', 'dogpile.com' => 'q', 'duckduckgo.com' => 'q', 'google.com' => 'q', 'hotbot.com' => 'q', 'images.google.com' => 'q', 'info.com' => 'qkw', 'local.google.com' => 'q', 'looksmart.com' => 'q', 'maps.google.com' => 'q', 'msxml.excite.com' => 'q', 'news.google.com' => 'q', 'search.aol.com' => 'q', 'search.earthlink.net' => 'q', 'search.lycos.com' => 'q', 'search.msn.com' => 'q', 'search.yahoo.com' => 'p', 'search.infospace.com' => 'q', 'sogou.com' => 'query', 'uk.ask.com' => 'q', 'qwant.com' => 'q', 'video.google.com' => 'q', 'wow.com' => 'q', 'yandex.kz' => 'text', 'yandex.ru' => 'text', 'zapmeta.com' => 'q'), 'optional' => array(), 'subtitle' => __('User Agents/Referrer', 'stt2extat'), 'description' => __('Manage referrer from these user agents', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'array');
     $data['max_char'] = array('id' => 12, 'parameter' => 'max_char', 'normal' => (int) 55, 'optional' => (int) 70, 'subtitle' => __('Max character length', 'stt2extat'), 'description' => __('Max character length of terms.', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'integer');
     $data['searchexcerpt'] = array('id' => 13, 'parameter' => 'searchexcerpt', 'normal' => 'n', 'optional' => array('y' => __('Enabled', 'stt2extat'), 'n' => __('Disabled', 'stt2extat')), 'subtitle' => __('Excerpt', 'stt2extat'), 'description' => __('Create snippet with highlighted terms of each post on search page via plugin Search Excerpt', 'stt2extat'), 'group' => 'general', 'subgroup' => __('general settings', 'stt2extat'), 'lang' => 'string');
     $data['manual'] = array('id' => 14, 'parameter' => 'manual', 'normal' => '', 'optional' => '', 'subtitle' => '', 'description' => '', 'group' => 'manual', 'subgroup' => __('manual input', 'stt2extat'), 'lang' => 'string');
     $data['stats'] = array('id' => 15, 'parameter' => 'stats', 'normal' => '', 'optional' => '', 'subtitle' => '', 'description' => '', 'group' => 'stats', 'subgroup' => __('term stats', 'stt2extat'), 'lang' => 'string');
     $data['delete'] = array('id' => 16, 'parameter' => 'delete', 'normal' => '', 'optional' => '', 'subtitle' => '', 'description' => '', 'group' => 'delete', 'subgroup' => __('migrate &amp; delete terms', 'stt2extat'), 'lang' => 'string');
     $data['term_name'] = array('id' => 17, 'parameter' => 'term_name', 'normal' => '', 'optional' => '', 'subtitle' => __('Name', 'stt2extat'), 'description' => __('Name', 'stt2extat'), 'group' => 'update_term', 'subgroup' => __('update terms', 'stt2extat'), 'lang' => 'string');
     $data['term_slug'] = array('id' => 18, 'parameter' => 'term_slug', 'normal' => '', 'optional' => '', 'subtitle' => __('Slug', 'stt2extat'), 'description' => __('Slug', 'stt2extat'), 'group' => 'update_term', 'subgroup' => __('update terms', 'stt2extat'), 'lang' => 'string');
     $data['support'] = array('id' => 19, 'parameter' => 'sidebar', 'normal' => '', 'optional' => '', 'subtitle' => '', 'description' => wp_kses(__('<p><i class="%1$s">Remember, if you ever need a helping hand, you will find one at the end of each of your arms. As you grow older, you will discover that you have two hands, one for helping yourself and the other for helping others.</i></p><p class="%2$s"> &#126; Sam Levenson</p><p class="%2$s">Here my support contact &amp; PayPal email <i class="%3$s"></i> <a target="_blank" href="%4$s" title="%5$s">%6$s</a></p>', 'stt2extat'), array('p' => array('class' => array()), 'i' => array('class' => array()), 'a' => array('target' => array(), 'href' => array(), 'title' => array()))), 'group' => 'support', 'subgroup' => __('Help Support, Credit &amp; Donate', 'stt2extat'), 'lang' => 'string');
     $data['features'] = array('id' => 20, 'parameter' => 'sidebar', 'normal' => '', 'optional' => '', 'subtitle' => '', 'description' => __('STT2EXTAT features.', 'stt2extat'), 'group' => 'features', 'subgroup' => __('Features', 'stt2extat'), 'lang' => 'string');
     $data['save'] = array('id' => 21, 'parameter' => 'sidebar', 'normal' => '', 'optional' => '', 'subtitle' => '', 'description' => '', 'group' => 'save', 'subgroup' => __('save your settings', 'stt2extat'), 'lang' => 'string');
     $data['help'] = array('id' => 22, 'parameter' => 'help', 'normal' => array('overview' => array('title' => __('Overview', 'stt2extat'), 'content' => __('Manage your terms better, add terms into single post manually, get terms via referrer, and save them as post meta. Search the terms that relevant of post content as well as WordPress search default algorithm. Abuse with any extension that you made is welcome to support this plugin. Have fun!.', 'stt2extat')), 'troubleshooting' => array('title' => __('Troubleshooting', 'stt2extat'), 'content' => __('Try to deactivated or uninstall, then install this plugin again if you get an error php code. Using caching to make your pages become static and make your website load faster, it also lessens the load on your server&#39;s CPU, Memory and HD.', 'stt2extat')), 'instruction' => array('title' => __('Instructions', 'stt2extat'), 'content' => sprintf('<div class="hint-box"><p><strong>%s</strong></p><ol class="hint"><li>%s</li><li>%s</li><li>%s</li><li>%s</li><li>%s <kbd>"<strong style="font-size:16px">,</strong>"</kbd> %s</li><li>%s</li><li>%s</li></ol></div>', __('Hint:', 'stt2extat'), __('Search the post by your terms, and select the one (required).', 'stt2extat'), __('Populate your terms for the first time then you can type in text box area directly to insert them into database.', 'stt2extat'), __('Three methods to populate your terms - by type, by suggestion and by double click text or text selection in "Full Post" section.', 'stt2extat'), __('Always use "comma" to separate your terms.', 'stt2extat'), __('Comma sign ', 'stt2extat'), __('in populate terms box is a trigger to searching relevant post.', 'stt2extat'), __('Increase or decrease hits number of search term by click the term or number text.', 'stt2extat'), __('Usage populate terms by select texts in full post area; SELECT the text(s) to add into populate box; CLICK each of selected text to remove it from your terms. The selected text(s) will be separated by comma automatically in populate box.', 'stt2extat')))), 'optional' => array(), 'subtitle' => __('Help Tab', 'stt2extat'), 'description' => sprintf('<p><strong>%1$s</strong></p><p><a href="%2$s" target="_blank">%3$s</a></p><p><a href="%4$s" target="_blank">%5$s</a></p>', __('For more information:', 'stt2extat'), esc_url(stt2extat_get_plugin_data('PluginURI')), __('Plugin Page', 'stt2extat'), 'https://github.com/Jevuska/stt2-extension-add-terms', 'GitHub'), 'group' => 'tab', 'subgroup' => __('help tab settings', 'stt2extat'), 'lang' => 'array');
     $data = $data + $additional_data;
     return $data;
 }
/**
 * give notice if browser javascript disable
 *
 * @since 1.0
 *
*/
function stt2extat_nojs()
{
    printf('<noscript><div id="message" class="error notice is-dismissible"><p>%1$s <b>%2$s</b> %3$s<button type="button" class="notice-dismiss"><span class="screen-reader-text">%4$s.</span></button></div></noscript>', __('Enable your browser javascript to load', 'stt2extat'), stt2extat_get_plugin_data('Name'), 'plugin.', __('Dismiss this notice', 'stt2extat'));
}