function bluet_kw_render_settings_page() { ?> <div id="bluet-general" class="wrap" > <?php $kttg_infos = get_plugin_data(dirname(__FILE__) . '/index.php'); $kttg_name = $kttg_infos['Name']; $kttg_version = $kttg_infos['Version']; ?> <h2><?php _e('KeyWords Settings', 'bluet-kw'); ?> </h2><span><?php echo '<b>' . $kttg_name . '</b> (v' . $kttg_version . ')'; ?> </span> <?php settings_errors(); ?> <h2 class="nav-tab-wrapper"> <a class="nav-tab" id="bluet_style_tab" data-tab="bluet-section-style"><?php _e('Style', 'bluet-kw'); ?> </a> <a class="nav-tab" id="bluet_settings_tab" data-tab="bluet-section-settings"><?php _e('Settings', 'bluet-kw'); ?> </a> <a class="nav-tab" id="bluet_glossary_tab" data-tab="bluet-section-glossary"><?php _e('Glossary', 'bluet-kw'); ?> </a> <a class="nav-tab" id="bluet_excluded_tab" data-tab="bluet-section-excluded"><?php _e('Excluded posts', 'bluet-kw'); ?> </a> <a class="nav-tab" target="_blank" style="background-color: antiquewhite;" href="https://wordpress.org/support/plugin/bluet-keywords-tooltip-generator" ><?php _e('Help ?', 'bluet-kw'); ?> </a> <a class="nav-tab" target="_blank" style="background-color: antiquewhite;" href="http://www.blueskills.net/pricing/" ><?php _e('Get the Pro AddOn', 'bluet-kw'); ?> </a> <a class="nav-tab" target="_blank" style="background-color: aliceblue;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LPKWCDNECSVWJ" ><?php _e('Donate', 'bluet-kw'); ?> </a> </h2> <form method="post" action="options.php"> <?php // Render the settings for the settings section identified as 'Footer Section' settings_fields('settings_group'); //render sections here echo '<div id="bluet-sections-div">'; //glossary settings echo '<div class="bluet-section" id="bluet-section-glossary" >'; do_settings_sections('my_keywords_glossary_settings'); echo '</div>'; echo '<div class="bluet-section" id="bluet-section-settings" >'; do_settings_sections('my_keywords_settings'); echo '</div>'; echo '<div class="bluet-section" id="bluet-section-style" >'; //the tooltip display //tooltip content vars $test_name = 'Keywords ToolTip Generator'; $test_dfn = __('this plugin allows you easely create tooltips for your technical keywords.', 'bluet-kw') . '<br>' . __('Click', 'bluet-kw') . '<a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/bluet-keywords-tooltip-generator">' . __('Here', 'bluet-kw') . '</a>' . __('to rate our plugin if you appreciate it', 'bluet-kw') . ';) ..'; $test_img = '<img height="auto !important" width="300" src="http://plugins.svn.wordpress.org/bluet-keywords-tooltip-generator/assets/banner-772x250.png" onError="this.src=\'http://plugins.svn.wordpress.org/bluet-keywords-tooltip-generator/assets/banner-772x250.jpg\'" class="attachment-medium wp-post-image" alt="wp-hooks-guide">'; $test_id = 111; //displaying the tooltip echo '<div id="tooltip_blocks_to_show">'; echo bluet_kttg_tooltip_layout($test_name, $test_dfn, $test_img, $test_id); echo '</div>'; //tooltip settings echo '<div id="tooltip_settings_sections">'; do_settings_sections('my_keywords_style'); echo '</div>'; ?> <div id="bluet_kw_preview" style="background-color: rgb(211, 211, 211); width: 75%; padding: 15px; border-radius: 10px;"> <h3 style="margin-bottom: 12px; margin-top: 0px;"><?php _e('Preview', 'bluet-kw'); ?> :</h3> <?php _e('Pass your mouse over the word', 'bluet-kw'); ?> <span class="bluet_tooltip" data-tooltip="111">KTTG</span> <?php _e('to test the tooltip layout.', 'bluet-kw'); ?> </div> <?php echo '</div>'; echo '<div class="bluet-section" id="bluet-section-excluded" >'; ?> <div id="bluet_kw_excluded_posts"> <h3><?php _e('Excluded posts', 'bluet-kw'); ?> </h3> <p><?php _e('Posts which are excluded from being matched', 'bluet-kw'); ?> </p> <?php $excluded_posts = bluet_kw_fetch_excluded_posts(); if (empty($excluded_posts)) { echo '<p style="color:red;">'; _e('No posts or pages are excluded', 'bluet-kw'); echo '</p>'; } echo '<ul style="list-style: initial; padding-left: 25px;">'; foreach ($excluded_posts as $k => $excluded_post) { ?> <li><a href="<?php echo $excluded_post['permalink']; ?> "><?php echo $excluded_post['title']; ?> </a></li> <?php } echo "</ul>"; ?> </div> <?php echo '</div>'; ?> </div> <!-- end bluet-sections-div --> <?php submit_button(__('Save Settings', 'bluet-kw'), 'primary'); ?> </form> </div> <?php }
function kttg_filter_posttype($cont) { /*28-05-2015*/ //specific modification so it can work for "WooCommerce Product Addons" and other addons if (is_array($cont)) { $cont = kttg_specific_plugins($cont); return $cont; } /*28-05-2015 end*/ $my_post_id = get_the_id(); $exclude_me = get_post_meta($my_post_id, 'bluet_exclude_post_from_matching', true); if ($exclude_me) { return $cont; } //glossary settings $bluet_kttg_show_glossary_link = get_option('bluet_kw_settings'); if (!empty($bluet_kttg_show_glossary_link['bluet_kttg_show_glossary_link'])) { $bluet_kttg_show_glossary_link = $bluet_kttg_show_glossary_link['bluet_kttg_show_glossary_link']; } else { $bluet_kttg_show_glossary_link = false; } $bluet_kttg_glossary_page = get_option('bluet_kttg_glossary_page'); $option_settings = get_option('bluet_kw_settings'); //var dans la quelle on cache les tooltips a afficher $html_tooltips_to_add = '<div class="my_tooltips_in_block">'; $my_keywords_ids = kttg_get_related_keywords($my_post_id); //if user specifies keywords to match $bluet_matching_keywords_field = get_post_meta($my_post_id, 'bluet_matching_keywords_field', true); if (!empty($bluet_matching_keywords_field)) { $my_keywords_ids = $bluet_matching_keywords_field; } global $is_kttg_glossary_page; $kttg_fetch_all_keywords = get_option('kttg_fetch_all_keywords'); if (empty($kttg_fetch_all_keywords)) { $kttg_fetch_all_keywords = false; } else { if ($kttg_fetch_all_keywords == "false") { $kttg_fetch_all_keywords = false; } else { if ($kttg_fetch_all_keywords == "true") { $kttg_fetch_all_keywords = true; } } } if (!empty($my_keywords_ids) or $is_kttg_glossary_page or $kttg_fetch_all_keywords) { $my_keywords_terms = array(); //looking in all occurences if glossary page if ($is_kttg_glossary_page) { $post_in = array(); } else { $post_in = $my_keywords_ids; } if ($kttg_fetch_all_keywords) { $post_in = null; } // The Query $wk_args = array('post__in' => $post_in, 'post_type' => 'my_keywords', 'posts_per_page' => -1); $the_wk_query = new WP_Query($wk_args); // The Loop if ($the_wk_query->have_posts()) { while ($the_wk_query->have_posts()) { $the_wk_query->the_post(); if (get_the_title() != "") { //to prevent untitled keywords $tmp_array_kw = array('kw_id' => get_the_id(), 'term' => get_the_title(), 'case' => false, 'pref' => false, 'syns' => get_post_meta(get_the_id(), 'bluet_synonyms_keywords', true), 'youtube' => get_post_meta(get_the_id(), 'bluet_youtube_video_id', true), 'dfn' => get_the_content(), 'img' => get_the_post_thumbnail(get_the_id(), 'medium')); if (get_post_meta(get_the_id(), 'bluet_case_sensitive_word', true) == "on") { $tmp_array_kw['case'] = true; } //if prefix addon activated if (function_exists('bluet_prefix_metabox')) { if (get_post_meta(get_the_id(), 'bluet_prefix_keywords', true) == "on") { $tmp_array_kw['pref'] = true; } } $my_keywords_terms[] = $tmp_array_kw; } } } /* Restore original Post Data */ wp_reset_postdata(); // first preg replace to eliminate html tags $regex = '<\\/?\\w+((\\s+\\w+(\\s*=\\s*(?:".*?"|\'.*?\'|[^\'">\\s]+))?)+\\s*|\\s*)\\/?>'; $out = array(); preg_match_all('#(' . $regex . ')#iu', $cont, $out); $cont = preg_replace('#(' . $regex . ')#i', '**T_A_G**', $cont); //replace tags by **T_A_G** //end $limit_match = $option_settings['bt_kw_match_all'] == 'on' ? -1 : 1; /*tow loops montioned here to avoid overlapping (chevauchement) */ foreach ($my_keywords_terms as $id => $arr) { $term = $arr['term']; //concat synonyms if they are not empty if ($arr['syns'] != "") { $term .= '|' . $arr['syns']; } $is_prefix = $arr['pref']; if (function_exists('bluet_prefix_metabox') and $is_prefix) { $kw_after = '\\w*'; } else { $kw_after = ''; } $term_and_syns_array = explode('|', $term); //sort keywords by string length in the array (to match them properly) usort($term_and_syns_array, 'kttg_length_compare'); //verify if case sensitive if ($arr['case']) { $kttg_case_sensitive = ''; } else { $kttg_case_sensitive = 'i'; } foreach ($term_and_syns_array as $temr_occ) { $temr_occ = elim_apostrophes($temr_occ); $cont = elim_apostrophes($cont); $cont = preg_replace('#((\\W)(' . $temr_occ . '' . $kw_after . ')(\\W))#u' . $kttg_case_sensitive, '$2__$3__$4', $cont, $limit_match); } } foreach ($my_keywords_terms as $id => $arr) { $term = $arr['term']; //concat synonyms if they are not empty if ($arr['syns'] != "") { $term .= '|' . $arr['syns']; } $img = $arr['img']; $dfn = $arr['dfn']; $is_prefix = $arr['pref']; $video = $arr['youtube']; if (function_exists('bluet_prefix_metabox') and $is_prefix) { $kw_after = '\\w*'; } else { $kw_after = ''; } if ($dfn != "") { $dfn = $arr['dfn']; } $html_to_replace = '<span class="bluet_tooltip" data-tooltip="' . $arr["kw_id"] . '">$2</span>'; $term_and_syns_array = explode('|', $term); $kttg_term_title = $term_and_syns_array[0]; if ($video != "" and function_exists('bluet_kttg_all_tooltips_layout')) { $html_tooltips_to_add .= bluet_kttg_all_tooltips_layout($dfn, '', $video, $arr["kw_id"]); } else { $html_tooltips_to_add .= bluet_kttg_tooltip_layout($kttg_term_title, $dfn, $img, $arr["kw_id"], $bluet_kttg_show_glossary_link, $bluet_kttg_glossary_page); } //verify if case sensitive if ($arr['case']) { $kttg_case_sensitive = ''; } else { $kttg_case_sensitive = 'i'; } foreach ($term_and_syns_array as $temr_occ) { $temr_occ = elim_apostrophes($temr_occ); $cont = elim_apostrophes($cont); $cont = preg_replace('#(__(' . $temr_occ . '' . $kw_after . ')__)#u' . $kttg_case_sensitive, $html_to_replace, $cont, -1); } } //Reinsert tag HTML elements foreach ($out[0] as $id => $tag) { $cont = preg_replace('#(\\*\\*T_A_G\\*\\*)#', $tag, $cont, 1); } //prevent HTML Headings (h1 h2 h3) to be matched $regH = '(<h[1-3]+>.*)(class="bluet_tooltip")(.*<\\/h[1-3]+>)'; $cont = preg_replace('#(' . $regH . ')#iu', '$2$4', $cont); } $html_tooltips_to_add = apply_filters('kttg_another_tooltip_in_block', $html_tooltips_to_add); $html_tooltips_to_add .= "</div>"; $cont = $html_tooltips_to_add . $cont; return do_shortcode($cont); //do_shortcode to return content after executing shortcodes }