Changeset 2245515
- Timestamp:
- 02/17/2020 11:17:15 AM (6 years ago)
- Location:
- meta-tags
- Files:
-
- 30 added
- 5 edited
-
tags/2.1.2 (added)
-
tags/2.1.2/LICENSE (added)
-
tags/2.1.2/README.md (added)
-
tags/2.1.2/assets (added)
-
tags/2.1.2/assets/css (added)
-
tags/2.1.2/assets/css/admin.css (added)
-
tags/2.1.2/assets/js (added)
-
tags/2.1.2/assets/js/admin.js (added)
-
tags/2.1.2/includes (added)
-
tags/2.1.2/includes/admin (added)
-
tags/2.1.2/includes/admin/class-dpmt-admin.php (added)
-
tags/2.1.2/includes/admin/class-dpmt-migration.php (added)
-
tags/2.1.2/includes/admin/class-dpmt-retrieve-list.php (added)
-
tags/2.1.2/includes/admin/class-dpmt-save-tags.php (added)
-
tags/2.1.2/includes/admin/views (added)
-
tags/2.1.2/includes/admin/views/html-meta-tag-editor.php (added)
-
tags/2.1.2/includes/admin/views/html-meta-tag-table.php (added)
-
tags/2.1.2/includes/class-dpmt-frontend.php (added)
-
tags/2.1.2/includes/class-dpmt-meta-tags.php (added)
-
tags/2.1.2/includes/class-dpmt-retrieve-info.php (added)
-
tags/2.1.2/includes/class-dpmt-retrieve-tags.php (added)
-
tags/2.1.2/includes/meta-tag-list.php (added)
-
tags/2.1.2/index.php (added)
-
tags/2.1.2/languages (added)
-
tags/2.1.2/languages/meta-tags.mo (added)
-
tags/2.1.2/languages/meta-tags.pot (added)
-
tags/2.1.2/languages/readme.md (added)
-
tags/2.1.2/meta-tags.php (added)
-
tags/2.1.2/readme.txt (added)
-
tags/2.1.2/uninstall.php (added)
-
trunk/README.md (modified) (1 diff)
-
trunk/includes/class-dpmt-frontend.php (modified) (32 diffs)
-
trunk/includes/class-dpmt-retrieve-info.php (modified) (20 diffs)
-
trunk/meta-tags.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
meta-tags/trunk/README.md
r2101869 r2245515 2 2 3 3 # 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.4 A 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. 5 5 6 6 -
meta-tags/trunk/includes/class-dpmt-frontend.php
r2101869 r2245515 2 2 /** 3 3 * Starts frontend processes. 4 * 4 * 5 5 * @since 2.0.0 6 6 */ … … 14 14 /** 15 15 * List of all editable meta tags. 16 * 16 * 17 17 * @var array 18 18 */ … … 21 21 /** 22 22 * All meta tags of current page. 23 * 23 * 24 24 * @var array 25 25 */ … … 28 28 /** 29 29 * Current page type. 30 * 30 * 31 31 * @var string 32 32 */ … … 35 35 /** 36 36 * Current page id. 37 * 37 * 38 38 * @var int 39 39 */ … … 42 42 /** 43 43 * Current page info for autopilot tags. 44 * 44 * 45 45 * @var array 46 46 */ … … 49 49 /** 50 50 * Is open graph html attribute set? 51 * 51 * 52 52 * @var bool 53 53 */ … … 56 56 /** 57 57 * Meta tags to print in head tag. 58 * 58 * 59 59 * @var string 60 60 */ … … 81 81 public function includes(){ 82 82 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'; 86 86 87 87 $this->meta_tag_list = $dpmt_meta_tag_list; … … 96 96 * @return string Page type. 97 97 */ 98 public function get_current_page_type(){ 98 public function get_current_page_type(){ 99 99 100 100 // wp displays blog posts on front page … … 102 102 return 'frontpage'; 103 103 } 104 104 105 105 global $wp_query; 106 107 108 // post or custom post type109 if ( $wp_query->is_single ){110 return get_post_type($this->get_current_page_id());111 }112 106 113 107 … … 125 119 126 120 // custom taxonomy 127 if ( $wp_query->is_tax ){ 121 if ( $wp_query->is_tax ){ 128 122 $term_id = get_queried_object()->term_id; 129 123 $term = get_term($term_id); 130 124 131 125 return $term->taxonomy; 132 }133 134 135 // page136 if ( $wp_query->is_page || $wp_query->is_archive ){137 return 'page';138 126 } 139 127 … … 143 131 return 'author'; 144 132 } 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 145 146 146 147 } … … 176 177 177 178 $this->is_og_html_attr_set = true; 178 179 179 180 add_filter( 'language_attributes', 'dpmt_add_og_html_prefix' ); 180 181 … … 212 213 return $this->page_info->title; 213 214 } 214 215 215 216 if( $tag_to_process == 'dpmt_og_description' ){ 216 217 return $this->page_info->description; … … 224 225 return 'article'; 225 226 226 }elseif ( $this->page_type == 'product' ){ 227 }elseif ( $this->page_type == 'product' ){ 227 228 228 229 return 'product'; 229 230 230 }elseif ( $this->page_type == 'product_cat' || $this->page_type == 'product_tag' ){ 231 }elseif ( $this->page_type == 'product_cat' || $this->page_type == 'product_tag' ){ 231 232 232 233 return 'product.group'; … … 237 238 238 239 } 239 240 } 241 240 241 } 242 242 243 if( $tag_to_process == 'dpmt_og_audio' ){ 243 244 return $this->page_info->audio; 244 245 } 245 246 246 247 if( $tag_to_process == 'dpmt_og_image' ){ 247 248 return $this->page_info->image; 248 249 } 249 250 250 251 if( $tag_to_process == 'dpmt_og_image_alt' ){ 251 252 return $this->page_info->image_alt; 252 253 } 253 254 254 255 if( $tag_to_process == 'dpmt_og_video' ){ 255 256 return $this->page_info->video; 256 257 } 257 258 258 259 if( $tag_to_process == 'dpmt_og_url' ){ 259 260 return $this->page_info->url; … … 265 266 if( $tag_to_process == 'dpmt_twitter_card' ){ 266 267 267 if ( 268 ! empty( $this->page_info->video ) && 268 if ( 269 ! empty( $this->page_info->video ) && 269 270 ( ! empty( $this->tags['dpmt_twitter_player'] ) || ! empty( $this->tags['dpmt_twitter_player_stream'] ) ) 270 271 ){ … … 272 273 } 273 274 274 if ( 275 ! empty( $this->page_info->audio ) && 275 if ( 276 ! empty( $this->page_info->audio ) && 276 277 ( ! empty( $this->tags['dpmt_twitter_player'] ) || ! empty( $this->tags['dpmt_twitter_player_stream'] ) ) 277 278 ){ … … 283 284 } 284 285 285 return 'summary'; 286 287 } 288 286 return 'summary'; 287 288 } 289 289 290 if( $tag_to_process == 'dpmt_twitter_title' ){ 290 291 return $this->page_info->title; … … 294 295 return $this->page_info->description; 295 296 } 296 297 297 298 if( $tag_to_process == 'dpmt_twitter_image' ){ 298 299 return $this->page_info->image; … … 304 305 305 306 if( $tag_to_process == 'dpmt_twitter_player_stream' ){ 306 307 307 308 if ( ! empty( $this->page_info->video ) ){ 308 309 return $this->page_info->video; 309 310 } 310 311 311 312 if ( ! empty( $this->page_info->audio ) ){ 312 313 return $this->page_info->audio; … … 316 317 317 318 if( $tag_to_process == 'dpmt_twitter_player_stream_content_type' ){ 318 319 319 320 if ( ! empty( $this->page_info->video ) ){ 320 321 … … 323 324 324 325 } 325 326 326 327 if ( ! empty( $this->page_info->audio ) ){ 327 328 … … 332 333 333 334 } 334 335 335 336 336 337 … … 344 345 public function process_tags(){ 345 346 346 $this->page_type = $this->get_current_page_type(); 347 $this->page_type = $this->get_current_page_type(); 347 348 $this->page_id = ( $this->page_type == 'frontpage' ? 'front' : $this->get_current_page_id() ); 348 349 … … 352 353 353 354 $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 ); 355 356 $this->tags = call_user_func_array('array_merge', $tags); 356 357 … … 367 368 368 369 // 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'); 370 371 $autopilot_arr = maybe_unserialize($dpmt_autopilot_settings); 371 372 $page_type_for_autopilot = $this->page_type == 'frontpage' ? 'page' : $this->page_type; … … 377 378 378 379 foreach ($values['fields'] as $field => $info) { 379 380 if ( 381 !empty( $this->tags[$info['variable']] ) || 380 381 if ( 382 !empty( $this->tags[$info['variable']] ) || 382 383 ( 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']]) && 385 386 $autopilot_arr[$page_type_for_autopilot][$values['var']] == 'autopilot') 386 387 ){ … … 395 396 // open graph's extra html attribute 396 397 if ( ! $this->is_og_html_attr_set && substr($info['variable'], 0, 7) == 'dpmt_og' ){ 397 398 398 399 $this->set_html_prefix_attribute(); 399 400 … … 401 402 402 403 403 if ( 404 if ( 404 405 !empty($this->tags[$info['variable']]) && 405 406 $this->tags[$info['variable']] != 'auto' 406 407 ){ 407 408 408 $this->output .= '<meta '. $values['attr'] .'="'. 409 esc_attr( $field ) . '" content="' . 409 $this->output .= '<meta '. $values['attr'] .'="'. 410 esc_attr( $field ) . '" content="' . 410 411 esc_attr( stripslashes( $this->tags[$info['variable']] ) ) . '" />' . 411 412 PHP_EOL; 412 413 413 414 }else{ 414 415 415 416 if ( $content = $this->process_auto_tags( $info['variable'] ) ){ 416 417 $this->output .= '<meta '. $values['attr'] .'="'. 417 418 esc_attr( $field ) . '" content="' . 418 419 esc_attr( stripslashes( $content ) ) . '" />' . 419 PHP_EOL; 420 } 420 PHP_EOL; 421 } 421 422 422 423 } … … 425 426 } 426 427 427 } 428 } 428 429 429 430 } -
meta-tags/trunk/includes/class-dpmt-retrieve-info.php
r2052946 r2245515 2 2 /** 3 3 * Loads all information of a WordPress item from database. 4 * 4 * 5 5 * @since 2.0.0 6 6 */ … … 14 14 /** 15 15 * WP item type. 16 * 16 * 17 17 * @var string 18 18 */ … … 21 21 /** 22 22 * WP item type nice name. 23 * 23 * 24 24 * @var string 25 25 */ … … 28 28 /** 29 29 * WP item ID. 30 * 30 * 31 31 * @var string 32 32 */ … … 35 35 /** 36 36 * WP item title. 37 * 37 * 38 38 * @var string 39 39 */ … … 42 42 /** 43 43 * WP item URL. 44 * 44 * 45 45 * @var string 46 46 */ 47 47 public $url; 48 48 49 49 /** 50 50 * WP item description. 51 * 51 * 52 52 * @var string 53 53 */ … … 56 56 /** 57 57 * WP item image URL. 58 * 58 * 59 59 * @var string 60 60 */ 61 61 public $image; 62 62 63 63 /** 64 64 * WP item image alternate text. 65 * 65 * 66 66 * @var string 67 67 */ … … 70 70 /** 71 71 * WP item audio URL. 72 * 72 * 73 73 * @var string 74 74 */ … … 77 77 /** 78 78 * WP item video URL. 79 * 79 * 80 80 * @var string 81 81 */ … … 83 83 84 84 85 85 86 86 /** 87 87 * Checks parameters and starts the loading process. 88 * 88 * 89 89 * @param string $type WP item type, e.g.: page, post, etc. 90 90 * @param string $id WP item ID or frontpage marker. 91 91 */ 92 92 public function __construct( $type, $id ){ 93 93 94 94 $this->type = ($id == 'front' ? 'frontpage' : $type); 95 95 $this->id = $id; … … 116 116 117 117 118 // label 118 // label 119 119 $this->label = $tax->label; 120 120 … … 130 130 // description 131 131 $this->description = $item->description; 132 132 133 133 134 134 // woo product categories can have an image 135 135 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 ); 137 137 $image = wp_get_attachment_url( $thumbnail_id ); 138 $this->image = $image ? $image : null; 138 $this->image = $image ? $image : null; 139 139 } 140 140 … … 145 145 case $this->type == 'author': 146 146 147 // label 147 // label 148 148 $this->label = 'Author'; 149 149 … … 166 166 case $this->type == 'frontpage': 167 167 168 // label 168 // label 169 169 $this->label = ''; 170 170 … … 187 187 case post_type_exists($this->type): 188 188 189 $item = get_post( $this->id ); 189 $item = get_post( $this->id ); 190 190 191 191 … … 204 204 205 205 // description: excerpt or the first 20 words from the content 206 if( !empty($item->post_excerpt) ){ 206 if( !empty($item->post_excerpt) ){ 207 207 $this->description = wp_strip_all_tags( $item->post_excerpt, true ); 208 208 }else{ … … 231 231 $dom->loadHTML($item->post_content); 232 232 libxml_clear_errors(); 233 234 233 234 235 235 if ( ! has_post_thumbnail( $this->id ) ){ 236 236 237 $images = $dom->getElementsByTagName('img'); 237 $images = $dom->getElementsByTagName('img'); 238 238 if( !empty($images) && is_array($images) ){ 239 239 $this->image = $images[0]->getAttribute('src'); 240 $this->image_alt = $images[0]->getAttribute('alt'); 240 $this->image_alt = $images[0]->getAttribute('alt'); 241 241 } 242 242 243 243 } 244 244 245 245 246 246 // video 247 $videos = $dom->getElementsByTagName('video'); 247 $videos = $dom->getElementsByTagName('video'); 248 248 if( $videos->length != 0 ){ 249 249 … … 252 252 if ( $source->length != 0 ){ 253 253 254 $this->video = $source->item(0)->getAttribute('src'); 254 $this->video = $source->item(0)->getAttribute('src'); 255 255 256 256 }elseif( ! empty( $videos->item(0)->getAttribute('src') ) ){ … … 258 258 $this->video = $videos->item(0)->getAttribute('src'); 259 259 260 } 260 } 261 261 262 262 } … … 264 264 265 265 // audio 266 $audio = $dom->getElementsByTagName('audio'); 266 $audio = $dom->getElementsByTagName('audio'); 267 267 if( $audio->length != 0 ){ 268 268 269 269 $source = $audio->item(0)->getElementsByTagName('source'); 270 270 271 271 if ( $source->length != 0 ){ 272 272 273 $this->audio = $source->item(0)->getAttribute('src'); 273 $this->audio = $source->item(0)->getAttribute('src'); 274 274 275 275 }elseif( ! empty( $audio->item(0)->getAttribute('src') ) ){ -
meta-tags/trunk/meta-tags.php
r2101869 r2245515 6 6 Author: DivPusher 7 7 Author URI: https://divpusher.com/ 8 Version: 2.1. 18 Version: 2.1.2 9 9 Text Domain: dp-meta-tags 10 10 Domain Path: /languages -
meta-tags/trunk/readme.txt
r2101869 r2245515 6 6 Tags: meta tags, seo, edit meta tags, search engine optimization, facebook open graph, twitter cards, schema.org 7 7 Requires at least: 4.7.0 8 Tested up to: 5. 2.19 Stable tag: 2.1. 18 Tested up to: 5.3.2 9 Stable tag: 2.1.2 10 10 License: GPLv3 11 11 License URI: http://www.gnu.org/licenses/gpl-3.0 … … 47 47 48 48 == 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 49 53 50 54 = 2.1.1 = … … 104 108 = 1.2.1 = 105 109 * 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 107 111 108 112 = 1.2.0 =
Note: See TracChangeset
for help on using the changeset viewer.