Plugin Directory

Changeset 1772290


Ignore:
Timestamp:
11/21/2017 12:38:31 PM (8 years ago)
Author:
makong
Message:

v.3.5

Location:
internal-links-generator/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • internal-links-generator/trunk/internal-links-generator.php

    r1772120 r1772290  
    44Plugin URI: https://makong.kiev.ua/plugins/internal-links-generator/
    55Description: Simple way to automatically link a certain word or phrase in your post/page/custom content to a URL you specify.
    6 Version: 3.4
     6Version: 3.5
    77Author: Makong
    88Author URI: http://makong.kiev.ua/
  • internal-links-generator/trunk/settings.php

    r1772141 r1772290  
    771771            else return $row->id;
    772772        }
     773       
     774        public function ilgen_check_entry($column, $value, $type, $pid){
     775
     776            if( $rows = $this->wpdb->get_results( $this->wpdb->prepare(
     777                "SELECT `{$type}` FROM `{$this->wpdb->prefix}internalinks` " .
     778                "WHERE `{$column}` = '%s'", $value
     779            )) ){
     780                foreach($rows as $row){
     781                    if(in_array($pid, (array)unserialize($row->{$type}))){
     782                        return true;
     783                    }
     784                }
     785            }
     786            return false;
     787        }
    773788       
    774789        public function ilgen_insert_keyword($keyword, $target = '', $limit = 1, $tag = '', $id = null, $count = null){
     
    900915                            if($p->post_content && preg_match_all("/{$this->urlPattern}/siU", $p->post_content, $matches, PREG_SET_ORDER)){
    901916                                foreach($matches as $match){
    902                                     if(strpos($match[0], 'class="ilgen"')) continue;
    903                                     if(preg_match('/<\s?(img|div|span)[^>]+\>/siU', $match[3], $unmatch)) continue;
    904                                     if(preg_match('/^#.*/', $match[2], $unmatch)) continue;
     917                                   
     918                                    if( ( preg_match('/<\s?(img|div|span)[^>]+\>/siU', $match[3], $unmatch) ) ||
     919                                        ( preg_match('/^#.*/', $match[2], $unmatch) ) ||
     920                                        ( strpos($match[0], 'class="ilgen"') && $this->ilgen_check_entry('target', esc_url_raw($match[2]), 'posts', $p->ID) )
     921                                    ) continue;
     922                                   
    905923                                    $data['posts'][$p->ID . $this->termDelimiter . $post_type][] = array(esc_url_raw($match[2]), sanitize_text_field($match[3]));
    906924                                }
     
    918936                            if($t->description && preg_match_all("/{$this->urlPattern}/siU", $t->description, $matches, PREG_SET_ORDER)){
    919937                                foreach($matches as $match){
    920                                     if(strpos($match[0], 'class="ilgen"')) continue;
    921                                     if(preg_match('/<\s?(img|div|span)[^>]+\>/siU', $match[3], $unmatch)) continue;
    922                                     if(preg_match('/^#.*/', $match[2], $unmatch)) continue;
     938                                   
     939                                    if( ( preg_match('/<\s?(img|div|span)[^>]+\>/siU', $match[3], $unmatch) ) ||
     940                                        ( preg_match('/^#.*/', $match[2], $unmatch) ) ||
     941                                        ( strpos($match[0], 'class="ilgen"') && $this->ilgen_check_entry('target', esc_url_raw($match[2]), 'terms', $t->term_id . $this->termDelimiter . $t->taxonomy) )
     942                                    ) continue;
     943                                   
    923944                                    $data['terms'][$t->term_id . $this->termDelimiter . $t->taxonomy][] = array(esc_url_raw($match[2]), sanitize_text_field($match[3]));
    924945                                }
Note: See TracChangeset for help on using the changeset viewer.