Technology sharing

[Wordpress Tutorial] Adde illegalis keyword interclusio ad wordpress blog website

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Aliqua pagina saepe malitiose quaesita est, quae telas magistros valde angebatur. Quomodo igitur malitiosos quaerere keywords impedimus? Hanc quaestionem solvere cum editore laboremus.

Background occasus preview:
image.png
Setup doceo:
1. Adde sequenti codice ad functions.php fasciculi currentis argumenti:

add_action('admin_init', 'ytkah_search_ban_key');
function ytkah_search_ban_key() {
    add_settings_field('ytkah_search_key', '搜索关键词屏蔽', 'ytkah_search_key_callback_function', 'reading');
    register_setting('reading','ytkah_search_key');
}
function ytkah_search_key_callback_function() {
    echo '<textarea name="ytkah_search_key" rows="10" cols="50" id="ytkah_search_key" class="large-text code">' . get_option('ytkah_search_key') . '</textarea>';
}
add_action('template_redirect', 'ytkah_search_ban');
function ytkah_search_ban(){
    if (is_search()) {
        global $wp_query;
        $ytkah_search_key = get_option('ytkah_search_key');
        if($ytkah_search_key){
            $ytkah_search_key = str_replace("rn", "|", $ytkah_search_key);
            $BanKey = explode('|', $ytkah_search_key);
            $S_Key = $wp_query->query_vars;
            foreach($BanKey as $Key){
                if( stristr($S_Key['s'],$Key) != false ){
                    wp_die('请不要搜索非法关键字');
                }
            }
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

2. Tunc vade ad "Optiones-Reading-Quaerere Keywords Clausus-Adde keywords investigationes quas claudere vis" in columna sinistra curriculi.
3. Cum profecti sunt, conemur quaerere et videre! In pictura infra est effectus mei test;
image.png