Plugin Directory

Changeset 2245515


Ignore:
Timestamp:
02/17/2020 11:17:15 AM (6 years ago)
Author:
divpusher
Message:

v2.1.2

  • Update: replaced deprecated get_woocommerce_term_meta() with get_term_meta() function
  • Fix: meta tags for authors and post tags are now appear properly
Location:
meta-tags
Files:
30 added
5 edited

Legend:

Unmodified
Added
Removed
  • meta-tags/trunk/README.md

    r2101869 r2245515  
    22
    33# Meta Tags WordPress Plugin
    4 A powerful plugin to edit meta tags on all your pages, posts, categories, tags and custom post types from one easy-to-use table. WooCommerce is supported as well. Facebook's OpenGraph and Twitter Cards are included.
     4A powerful plugin to edit meta tags on all your pages, posts, categories, tags and (public) Custom Post Types from one easy-to-use table. WooCommerce is supported as well. Facebook’s OpenGraph and Twitter Cards are included.
    55
    66
  • meta-tags/trunk/includes/class-dpmt-frontend.php

    r2101869 r2245515  
    22/**
    33 * Starts frontend processes.
    4  * 
     4 *
    55 * @since 2.0.0
    66 */
     
    1414    /**
    1515     * List of all editable meta tags.
    16      * 
     16     *
    1717     * @var array
    1818     */
     
    2121    /**
    2222     * All meta tags of current page.
    23      * 
     23     *
    2424     * @var array
    2525     */
     
    2828    /**
    2929     * Current page type.
    30      * 
     30     *
    3131     * @var string
    3232     */
     
    3535    /**
    3636     * Current page id.
    37      * 
     37     *
    3838     * @var int
    3939     */
     
    4242    /**
    4343     * Current page info for autopilot tags.
    44      * 
     44     *
    4545     * @var array
    4646     */
     
    4949    /**
    5050     * Is open graph html attribute set?
    51      * 
     51     *
    5252     * @var bool
    5353     */
     
    5656    /**
    5757     * Meta tags to print in head tag.
    58      * 
     58     *
    5959     * @var string
    6060     */
     
    8181    public function includes(){
    8282
    83         include_once 'meta-tag-list.php';       
    84         include_once 'class-dpmt-retrieve-info.php';   
    85         include_once 'class-dpmt-retrieve-tags.php';   
     83        include_once 'meta-tag-list.php';
     84        include_once 'class-dpmt-retrieve-info.php';
     85        include_once 'class-dpmt-retrieve-tags.php';
    8686
    8787        $this->meta_tag_list = $dpmt_meta_tag_list;
     
    9696     * @return string Page type.
    9797     */
    98     public function get_current_page_type(){ 
     98    public function get_current_page_type(){
    9999
    100100        // wp displays blog posts on front page
     
    102102            return 'frontpage';
    103103        }
    104        
     104
    105105        global $wp_query;
    106 
    107 
    108         // post or custom post type
    109         if ( $wp_query->is_single ){   
    110             return get_post_type($this->get_current_page_id());           
    111         }
    112106
    113107
     
    125119
    126120        // custom taxonomy
    127         if ( $wp_query->is_tax ){                       
     121        if ( $wp_query->is_tax ){
    128122            $term_id = get_queried_object()->term_id;
    129123            $term = get_term($term_id);
    130            
     124
    131125            return $term->taxonomy;
    132         }
    133 
    134 
    135         // page
    136         if ( $wp_query->is_page || $wp_query->is_archive ){           
    137             return 'page';           
    138126        }
    139127
     
    143131            return 'author';
    144132        }
     133
     134
     135        // post or custom post type
     136        if ( $wp_query->is_single ){
     137            return get_post_type($this->get_current_page_id());
     138        }
     139
     140
     141        // page
     142        if ( $wp_query->is_page || $wp_query->is_archive ){
     143            return 'page';
     144        }
     145
    145146
    146147    }
     
    176177
    177178        $this->is_og_html_attr_set = true;
    178        
     179
    179180        add_filter( 'language_attributes', 'dpmt_add_og_html_prefix' );
    180181
     
    212213            return $this->page_info->title;
    213214        }
    214        
     215
    215216        if( $tag_to_process == 'dpmt_og_description' ){
    216217            return $this->page_info->description;
     
    224225                return 'article';
    225226
    226             }elseif ( $this->page_type == 'product' ){               
     227            }elseif ( $this->page_type == 'product' ){
    227228
    228229                return 'product';
    229230
    230             }elseif ( $this->page_type == 'product_cat' || $this->page_type == 'product_tag' ){               
     231            }elseif ( $this->page_type == 'product_cat' || $this->page_type == 'product_tag' ){
    231232
    232233                return 'product.group';
     
    237238
    238239            }
    239            
    240         }
    241        
     240
     241        }
     242
    242243        if( $tag_to_process == 'dpmt_og_audio' ){
    243244            return $this->page_info->audio;
    244245        }
    245        
     246
    246247        if( $tag_to_process == 'dpmt_og_image' ){
    247248            return $this->page_info->image;
    248249        }
    249        
     250
    250251        if( $tag_to_process == 'dpmt_og_image_alt' ){
    251252            return $this->page_info->image_alt;
    252253        }
    253        
     254
    254255        if( $tag_to_process == 'dpmt_og_video' ){
    255256            return $this->page_info->video;
    256257        }
    257        
     258
    258259        if( $tag_to_process == 'dpmt_og_url' ){
    259260            return $this->page_info->url;
     
    265266        if( $tag_to_process == 'dpmt_twitter_card' ){
    266267
    267             if ( 
    268                 ! empty( $this->page_info->video ) && 
     268            if (
     269                ! empty( $this->page_info->video ) &&
    269270                ( ! empty( $this->tags['dpmt_twitter_player'] ) || ! empty( $this->tags['dpmt_twitter_player_stream'] ) )
    270271            ){
     
    272273            }
    273274
    274             if ( 
    275                 ! empty( $this->page_info->audio ) && 
     275            if (
     276                ! empty( $this->page_info->audio ) &&
    276277                ( ! empty( $this->tags['dpmt_twitter_player'] ) || ! empty( $this->tags['dpmt_twitter_player_stream'] ) )
    277278            ){
     
    283284            }
    284285
    285             return 'summary';           
    286 
    287         }
    288        
     286            return 'summary';
     287
     288        }
     289
    289290        if( $tag_to_process == 'dpmt_twitter_title' ){
    290291            return $this->page_info->title;
     
    294295            return $this->page_info->description;
    295296        }
    296        
     297
    297298        if( $tag_to_process == 'dpmt_twitter_image' ){
    298299            return $this->page_info->image;
     
    304305
    305306        if( $tag_to_process == 'dpmt_twitter_player_stream' ){
    306            
     307
    307308            if ( ! empty( $this->page_info->video ) ){
    308309                return $this->page_info->video;
    309310            }
    310            
     311
    311312            if ( ! empty( $this->page_info->audio ) ){
    312313                return $this->page_info->audio;
     
    316317
    317318        if( $tag_to_process == 'dpmt_twitter_player_stream_content_type' ){
    318            
     319
    319320            if ( ! empty( $this->page_info->video ) ){
    320321
     
    323324
    324325            }
    325            
     326
    326327            if ( ! empty( $this->page_info->audio ) ){
    327328
     
    332333
    333334        }
    334        
     335
    335336
    336337
     
    344345    public function process_tags(){
    345346
    346         $this->page_type = $this->get_current_page_type();         
     347        $this->page_type = $this->get_current_page_type();
    347348        $this->page_id = ( $this->page_type == 'frontpage' ? 'front' : $this->get_current_page_id() );
    348349
     
    352353
    353354        $taginfo = new DPMT_Retrieve_Tags( $this->meta_tag_list );
    354         $tags = $taginfo->get_tags( $this->page_type, $this->page_id );       
     355        $tags = $taginfo->get_tags( $this->page_type, $this->page_id );
    355356        $this->tags = call_user_func_array('array_merge', $tags);
    356357
     
    367368
    368369        // load autopilot settings array form wp_options
    369         $dpmt_autopilot_settings = get_option('dpmt_autopilot_settings');     
     370        $dpmt_autopilot_settings = get_option('dpmt_autopilot_settings');
    370371        $autopilot_arr = maybe_unserialize($dpmt_autopilot_settings);
    371372        $page_type_for_autopilot = $this->page_type == 'frontpage' ? 'page' : $this->page_type;
     
    377378
    378379            foreach ($values['fields'] as $field => $info) {
    379                
    380                 if ( 
    381                     !empty( $this->tags[$info['variable']] ) || 
     380
     381                if (
     382                    !empty( $this->tags[$info['variable']] ) ||
    382383                    (
    383                         $values['var'] != 'custom' && 
    384                         !empty($autopilot_arr[$page_type_for_autopilot][$values['var']]) && 
     384                        $values['var'] != 'custom' &&
     385                        !empty($autopilot_arr[$page_type_for_autopilot][$values['var']]) &&
    385386                        $autopilot_arr[$page_type_for_autopilot][$values['var']] == 'autopilot')
    386387                ){
     
    395396                        // open graph's extra html attribute
    396397                        if ( ! $this->is_og_html_attr_set && substr($info['variable'], 0, 7) == 'dpmt_og' ){
    397                            
     398
    398399                            $this->set_html_prefix_attribute();
    399400
     
    401402
    402403
    403                         if ( 
     404                        if (
    404405                            !empty($this->tags[$info['variable']]) &&
    405406                            $this->tags[$info['variable']] != 'auto'
    406407                        ){
    407408
    408                             $this->output .= '<meta '. $values['attr'] .'="'. 
    409                                 esc_attr( $field ) . '" content="' . 
     409                            $this->output .= '<meta '. $values['attr'] .'="'.
     410                                esc_attr( $field ) . '" content="' .
    410411                                esc_attr( stripslashes( $this->tags[$info['variable']] ) ) . '" />' .
    411412                                PHP_EOL;
    412413
    413414                        }else{
    414                            
     415
    415416                            if ( $content = $this->process_auto_tags( $info['variable'] ) ){
    416417                                $this->output .= '<meta '. $values['attr'] .'="'.
    417418                                    esc_attr( $field ) . '" content="' .
    418419                                    esc_attr( stripslashes( $content ) ) . '" />' .
    419                                     PHP_EOL;   
    420                             }                           
     420                                    PHP_EOL;
     421                            }
    421422
    422423                        }
     
    425426                }
    426427
    427             }     
     428            }
    428429
    429430        }
  • meta-tags/trunk/includes/class-dpmt-retrieve-info.php

    r2052946 r2245515  
    22/**
    33 * Loads all information of a WordPress item from database.
    4  * 
     4 *
    55 * @since 2.0.0
    66 */
     
    1414    /**
    1515     * WP item type.
    16      * 
     16     *
    1717     * @var string
    1818     */
     
    2121    /**
    2222     * WP item type nice name.
    23      * 
     23     *
    2424     * @var string
    2525     */
     
    2828    /**
    2929     * WP item ID.
    30      * 
     30     *
    3131     * @var string
    3232     */
     
    3535    /**
    3636     * WP item title.
    37      * 
     37     *
    3838     * @var string
    3939     */
     
    4242    /**
    4343     * WP item URL.
    44      * 
     44     *
    4545     * @var string
    4646     */
    4747    public $url;
    48    
     48
    4949    /**
    5050     * WP item description.
    51      * 
     51     *
    5252     * @var string
    5353     */
     
    5656    /**
    5757     * WP item image URL.
    58      * 
     58     *
    5959     * @var string
    6060     */
    6161    public $image;
    62    
     62
    6363    /**
    6464     * WP item image alternate text.
    65      * 
     65     *
    6666     * @var string
    6767     */
     
    7070    /**
    7171     * WP item audio URL.
    72      * 
     72     *
    7373     * @var string
    7474     */
     
    7777    /**
    7878     * WP item video URL.
    79      * 
     79     *
    8080     * @var string
    8181     */
     
    8383
    8484
    85    
     85
    8686    /**
    8787     * Checks parameters and starts the loading process.
    88      * 
     88     *
    8989     * @param string $type WP item type, e.g.: page, post, etc.
    9090     * @param string $id WP item ID or frontpage marker.
    9191     */
    9292    public function __construct( $type, $id ){
    93        
     93
    9494        $this->type = ($id == 'front' ? 'frontpage' : $type);
    9595        $this->id = $id;
     
    116116
    117117
    118                 // label               
     118                // label
    119119                $this->label = $tax->label;
    120120
     
    130130                // description
    131131                $this->description = $item->description;
    132                
     132
    133133
    134134                // woo product categories can have an image
    135135                if ( class_exists('WooCommerce') && $this->type == 'product_cat' ) {
    136                     $thumbnail_id = get_woocommerce_term_meta( intval($this->id), 'thumbnail_id', true );
     136                    $thumbnail_id = get_term_meta( intval($this->id), 'thumbnail_id', true );
    137137                    $image = wp_get_attachment_url( $thumbnail_id );
    138                     $this->image = $image ? $image : null; 
     138                    $this->image = $image ? $image : null;
    139139                }
    140140
     
    145145            case $this->type == 'author':
    146146
    147                 // label               
     147                // label
    148148                $this->label = 'Author';
    149149
     
    166166            case $this->type == 'frontpage':
    167167
    168                 // label               
     168                // label
    169169                $this->label = '';
    170170
     
    187187            case post_type_exists($this->type):
    188188
    189                 $item = get_post( $this->id );               
     189                $item = get_post( $this->id );
    190190
    191191
     
    204204
    205205                // description: excerpt or the first 20 words from the content
    206                 if( !empty($item->post_excerpt) ){               
     206                if( !empty($item->post_excerpt) ){
    207207                    $this->description = wp_strip_all_tags( $item->post_excerpt, true );
    208208                }else{
     
    231231                $dom->loadHTML($item->post_content);
    232232                libxml_clear_errors();
    233                
    234                                    
     233
     234
    235235                if ( ! has_post_thumbnail( $this->id ) ){
    236236
    237                     $images = $dom->getElementsByTagName('img');                   
     237                    $images = $dom->getElementsByTagName('img');
    238238                    if( !empty($images) && is_array($images) ){
    239239                        $this->image = $images[0]->getAttribute('src');
    240                         $this->image_alt = $images[0]->getAttribute('alt');   
     240                        $this->image_alt = $images[0]->getAttribute('alt');
    241241                    }
    242                    
     242
    243243                }
    244244
    245245
    246246                // video
    247                 $videos = $dom->getElementsByTagName('video');               
     247                $videos = $dom->getElementsByTagName('video');
    248248                if( $videos->length != 0 ){
    249249
     
    252252                    if ( $source->length != 0 ){
    253253
    254                         $this->video = $source->item(0)->getAttribute('src');   
     254                        $this->video = $source->item(0)->getAttribute('src');
    255255
    256256                    }elseif( ! empty( $videos->item(0)->getAttribute('src') ) ){
     
    258258                        $this->video = $videos->item(0)->getAttribute('src');
    259259
    260                     }                 
     260                    }
    261261
    262262                }
     
    264264
    265265                // audio
    266                 $audio = $dom->getElementsByTagName('audio');             
     266                $audio = $dom->getElementsByTagName('audio');
    267267                if( $audio->length != 0 ){
    268                    
     268
    269269                    $source = $audio->item(0)->getElementsByTagName('source');
    270270
    271271                    if ( $source->length != 0 ){
    272272
    273                         $this->audio = $source->item(0)->getAttribute('src');                         
     273                        $this->audio = $source->item(0)->getAttribute('src');
    274274
    275275                    }elseif( ! empty( $audio->item(0)->getAttribute('src') ) ){
  • meta-tags/trunk/meta-tags.php

    r2101869 r2245515  
    66Author: DivPusher
    77Author URI: https://divpusher.com/
    8 Version: 2.1.1
     8Version: 2.1.2
    99Text Domain: dp-meta-tags
    1010Domain Path:  /languages
  • meta-tags/trunk/readme.txt

    r2101869 r2245515  
    66Tags: meta tags, seo, edit meta tags, search engine optimization, facebook open graph, twitter cards, schema.org
    77Requires at least: 4.7.0
    8 Tested up to: 5.2.1
    9 Stable tag: 2.1.1
     8Tested up to: 5.3.2
     9Stable tag: 2.1.2
    1010License: GPLv3
    1111License URI: http://www.gnu.org/licenses/gpl-3.0
     
    4747
    4848== Changelog ==
     49
     50= 2.1.2 =
     51* Update: replaced deprecated get_woocommerce_term_meta() with get_term_meta() function
     52* Fix: meta tags for authors and post tags are now appear properly
    4953
    5054= 2.1.1 =
     
    104108= 1.2.1 =
    105109* Fix: some strings were not translation ready
    106 * Fix: support notice on plugin page now appears only once, after activation 
     110* Fix: support notice on plugin page now appears only once, after activation
    107111
    108112= 1.2.0 =
Note: See TracChangeset for help on using the changeset viewer.