Changeset 1887826
- Timestamp:
- 06/05/2018 09:35:49 PM (8 years ago)
- Location:
- minimum-viable-sharing-meta
- Files:
-
- 23 added
- 9 edited
-
tags/0.0.5 (added)
-
tags/0.0.5/CHANGES.md (added)
-
tags/0.0.5/LICENSE (added)
-
tags/0.0.5/README.md (added)
-
tags/0.0.5/assets (added)
-
tags/0.0.5/assets/css (added)
-
tags/0.0.5/assets/css/minshare-meta-admin.css (added)
-
tags/0.0.5/assets/css/minshare-meta-admin.min.css (added)
-
tags/0.0.5/assets/js (added)
-
tags/0.0.5/assets/js/minshare-meta-admin.js (added)
-
tags/0.0.5/assets/js/minshare-meta-admin.min.js (added)
-
tags/0.0.5/includes (added)
-
tags/0.0.5/includes/class-admin.php (added)
-
tags/0.0.5/includes/class-display.php (added)
-
tags/0.0.5/includes/class-fields.php (added)
-
tags/0.0.5/includes/class-helper.php (added)
-
tags/0.0.5/includes/class-post-meta.php (added)
-
tags/0.0.5/includes/class-settings.php (added)
-
tags/0.0.5/includes/install.php (added)
-
tags/0.0.5/includes/uninstall.php (added)
-
tags/0.0.5/index.php (added)
-
tags/0.0.5/minimum-viable-sharing-meta.php (added)
-
tags/0.0.5/readme.txt (added)
-
trunk/CHANGES.md (modified) (1 diff)
-
trunk/includes/class-display.php (modified) (2 diffs)
-
trunk/includes/class-fields.php (modified) (8 diffs)
-
trunk/includes/class-helper.php (modified) (2 diffs)
-
trunk/includes/class-post-meta.php (modified) (2 diffs)
-
trunk/includes/class-settings.php (modified) (2 diffs)
-
trunk/includes/install.php (modified) (1 diff)
-
trunk/minimum-viable-sharing-meta.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
minimum-viable-sharing-meta/trunk/CHANGES.md
r1799137 r1887826 1 #### Version 0.0.5 - 2018/06/05 2 * added canonical URL field. props @dryan for the suggestion. 3 * included image meta tags from Yoast SEO in conversion function. 1 4 2 5 #### Version 0.0.4 - 2018/01/08 -
minimum-viable-sharing-meta/trunk/includes/class-display.php
r1795465 r1887826 21 21 public function init() { 22 22 add_action( 'wp_head', array( $this, 'load_meta_tags' ) ); 23 add_filter( 'get_canonical_url', array( $this, 'filter_canonical_url' ), 10, 2 ); 23 24 add_filter( 'document_title_parts', array( $this, 'load_title_tag' ), 88 ); 24 25 } … … 94 95 95 96 /** 97 * Check for a custom canonical URL and use that. 98 * 99 * @param string $canonical The post's canonical URL. 100 * @param WP_Post $post Post object. 101 * 102 * @return string 103 */ 104 public function filter_canonical_url( $canonical, $post ) { 105 106 // Check we're on a singular output. 107 if ( ! is_singular( minshare_meta()->supported_types() ) ) { 108 return $canonical; 109 } 110 111 // Check for a stored canonical tag. 112 $stored = MinimumViableMeta_Helper::get_single_tags( $post->ID, 'canonical' ); 113 114 // Return a value if we have one, otherwise return what we were passed. 115 return ! empty( $stored ) ? $stored : $canonical; 116 } 117 118 /** 96 119 * Filter our title text. 97 120 * -
minimum-viable-sharing-meta/trunk/includes/class-fields.php
r1796510 r1887826 17 17 * Get our array of fields for the settings. 18 18 * 19 * @param boolean $canonical Whether or not to show the canonical field. 20 * 19 21 * @return array 20 22 */ 21 public static function get_fields_group( ) {23 public static function get_fields_group( $canonical = true ) { 22 24 23 25 // Our field groupings. … … 33 35 'class' => 'minshare-meta-title-field', 34 36 'more' => 'https://moz.com/learn/seo/title-tag', 37 'count' => true, 35 38 ), 36 39 … … 44 47 'class' => 'minshare-meta-desc-field', 45 48 'more' => 'https://moz.com/learn/seo/meta-description', 49 'count' => true, 46 50 ), 47 51 … … 70 74 'class' => 'minshare-meta-card-field', 71 75 ), 76 77 // The canonical field. 78 'canonical' => array( 79 'type' => 'url', 80 'key' => 'canonical', 81 'id' => 'minshare-meta-canonical', 82 'name' => 'minshare_meta_defaults[canonical]', 83 'fname' => __( 'Canonical URL', 'minimum-viable-sharing-meta' ), 84 'class' => 'minshare-meta-canonical-field', 85 'help' => sprintf( __( '<a href="%s">Click here</a> to learn more about canonical tags and duplicate content.', 'minimum-viable-sharing-meta' ), 'https://moz.com/learn/seo/duplicate-content' ) 86 ), 72 87 ); 88 89 // Unset the canonical if requested. 90 if ( ! $canonical ) { 91 unset( $fields['canonical'] ); 92 } 73 93 74 94 // Return our array. … … 93 113 'name' => '', 94 114 'label' => '', 115 'count' => false 95 116 ); 96 117 … … 137 158 } 138 159 139 // If this is a title field, output the character counter.140 if ( ! empty( $args[' key'] ) && 'title' === esc_attr( $args['key'] ) ) {160 // If we called it, output the character counter. 161 if ( ! empty( $args['count'] ) ) { 141 162 142 163 // Check for the "more" item. … … 145 166 // Show the field. 146 167 $field .= self::show_character_count( $value, 'title', $more ); 168 } 169 170 // Output our help text if we have one. 171 if ( ! empty( $args['help'] ) ) { 172 $field .= '<p class="description">' . wp_kses_post( $args['help'] ) . '</p>'; 147 173 } 148 174 … … 208 234 } 209 235 210 // If this is a desc field, output the character counter.211 if ( ! empty( $args[' key'] ) && 'desc' === esc_attr( $args['key'] ) ) {236 // If we called it, output the character counter. 237 if ( ! empty( $args['count'] ) ) { 212 238 213 239 // Check for the "more" item. -
minimum-viable-sharing-meta/trunk/includes/class-helper.php
r1795465 r1887826 111 111 112 112 case 'title' : 113 case 'card' : 113 114 $output[ $k ] = ! empty( $v ) ? sanitize_text_field( $v ) : ''; 114 115 break; … … 119 120 120 121 case 'image' : 122 case 'canonical' : 121 123 $output[ $k ] = ! empty( $v ) ? esc_url( $v ) : ''; 122 break;123 124 case 'card' :125 $output[ $k ] = ! empty( $v ) ? sanitize_text_field( $v ) : '';126 124 break; 127 125 -
minimum-viable-sharing-meta/trunk/includes/class-post-meta.php
r1795465 r1887826 81 81 82 82 // Check for a value. 83 $value = ! empty( $meta[ $fkey ] ) ? $meta[ $fkey ] : false;83 $value = ! empty( $meta[ $fkey ] ) ? $meta[ $fkey ] : ''; 84 84 85 85 // And echo out our field. … … 125 125 126 126 case 'text' : 127 case 'url' : 127 128 return MinimumViableMeta_Fields::text_field( $field, $value ); 128 129 break; -
minimum-viable-sharing-meta/trunk/includes/class-settings.php
r1796510 r1887826 37 37 38 38 // Fetch my group of fields, and bail without them. 39 if ( false === $fields = MinimumViableMeta_Fields::get_fields_group( ) ) {39 if ( false === $fields = MinimumViableMeta_Fields::get_fields_group( false ) ) { 40 40 return; 41 41 } … … 156 156 157 157 case 'text' : 158 case 'url' : 158 159 echo MinimumViableMeta_Fields::text_field( $args, $value ); 159 160 break; -
minimum-viable-sharing-meta/trunk/includes/install.php
r1795465 r1887826 10 10 // Set our initial default values. 11 11 $setup = array( 12 'title' => get_bloginfo( 'name' ), 13 'desc' => get_bloginfo( 'description' ), 14 'card' => 'summary', 15 'image' => '', 12 'title' => get_bloginfo( 'name' ), 13 'desc' => get_bloginfo( 'description' ), 14 'card' => 'summary', 15 'image' => '', 16 'canonical' => '', 16 17 ); 17 18 -
minimum-viable-sharing-meta/trunk/minimum-viable-sharing-meta.php
r1799137 r1887826 39 39 * @var string 40 40 */ 41 private $version = '0.0. 4';41 private $version = '0.0.5'; 42 42 43 43 /** … … 288 288 SELECT post_id 289 289 FROM $table 290 WHERE meta_key = %s", 291 esc_sql( $metakey ) 292 ); 290 WHERE meta_key = %s 291 ", esc_sql( $metakey ) ); 293 292 294 293 // Run SQL query. … … 348 347 $setup = $wpdb->prepare(" 349 348 DELETE FROM $table 350 WHERE meta_key = %s", 351 esc_sql( MINSHARE_META_POSTKEY ) 352 ); 349 WHERE meta_key = %s 350 ", esc_sql( MINSHARE_META_POSTKEY ) ); 353 351 354 352 // Run SQL query. … … 431 429 $items = array( 432 430 'yoast' => array( 433 'name' => __( 'Yoast SEO', 'minimum-viable-sharing-meta' ), 434 'title' => '_yoast_wpseo_title', 435 'desc' => '_yoast_wpseo_metadesc', 431 'name' => __( 'Yoast SEO', 'minimum-viable-sharing-meta' ), 432 'title' => '_yoast_wpseo_title', 433 'desc' => '_yoast_wpseo_metadesc', 434 'canonical' => '_yoast_wpseo_canonical', 435 'image' => '_yoast_wpseo_opengraph-image', 436 436 ), 437 437 'aioseo' => array( 438 'name' => __( 'All In One SEO Pack', 'minimum-viable-sharing-meta' ), 439 'title' => '_aioseop_title', 440 'desc' => '_aioseop_description', 438 'name' => __( 'All In One SEO Pack', 'minimum-viable-sharing-meta' ), 439 'title' => '_aioseop_title', 440 'desc' => '_aioseop_description', 441 'canonical' => '_aioseop_custom_link', 441 442 ), 442 443 'genesis' => array( 443 'name' => __( 'Genesis Theme Framework', 'minimum-viable-sharing-meta' ), 444 'title' => '_genesis_title', 445 'desc' => '_genesis_description', 444 'name' => __( 'Genesis Theme Framework', 'minimum-viable-sharing-meta' ), 445 'title' => '_genesis_title', 446 'desc' => '_genesis_description', 447 'canonical' => '_genesis_canonical_uri', 446 448 ), 447 449 ); -
minimum-viable-sharing-meta/trunk/readme.txt
r1799137 r1887826 5 5 Tags: meta tags, sharing tags 6 6 Requires at least: 4.9 7 Tested up to: 4.9 8 Stable tag: 0.0. 47 Tested up to: 4.9.6 8 Stable tag: 0.0.5 9 9 Requires PHP: 5.6 10 10 License: MIT … … 41 41 = Is this really all of them? = 42 42 43 Yes, really. 44 43 45 I would suggest reading [this blog post](http://www.phpied.com/minimum-viable-sharing-meta-tags/) written by [Stoyan Stefanov](http://www.phpied.com/bio/) if you're curious. 44 46 … … 54 56 55 57 == Changelog == 58 59 = 0.0.5 - 2018/06/05 = 60 * added canonical URL field. props @dryan for the suggestion. 61 * included image meta tags from Yoast SEO in conversion function. 56 62 57 63 = 0.0.4 - 2018/01/08 =
Note: See TracChangeset
for help on using the changeset viewer.