Plugin Directory

Changeset 1887826


Ignore:
Timestamp:
06/05/2018 09:35:49 PM (8 years ago)
Author:
norcross
Message:
  • added canonical URL field. props @dryan for the suggestion.
  • included image meta tags from Yoast SEO in conversion function.
Location:
minimum-viable-sharing-meta
Files:
23 added
9 edited

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.
    14
    25#### Version 0.0.4 - 2018/01/08
  • minimum-viable-sharing-meta/trunk/includes/class-display.php

    r1795465 r1887826  
    2121    public function init() {
    2222        add_action( 'wp_head',                      array( $this, 'load_meta_tags'          )           );
     23        add_filter( 'get_canonical_url',            array( $this, 'filter_canonical_url'    ),  10, 2   );
    2324        add_filter( 'document_title_parts',         array( $this, 'load_title_tag'          ),  88      );
    2425    }
     
    9495
    9596    /**
     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    /**
    96119     * Filter our title text.
    97120     *
  • minimum-viable-sharing-meta/trunk/includes/class-fields.php

    r1796510 r1887826  
    1717     * Get our array of fields for the settings.
    1818     *
     19     * @param  boolean $canonical  Whether or not to show the canonical field.
     20     *
    1921     * @return array
    2022     */
    21     public static function get_fields_group() {
     23    public static function get_fields_group( $canonical = true ) {
    2224
    2325        // Our field groupings.
     
    3335                'class' => 'minshare-meta-title-field',
    3436                'more'  => 'https://moz.com/learn/seo/title-tag',
     37                'count' => true,
    3538            ),
    3639
     
    4447                'class' => 'minshare-meta-desc-field',
    4548                'more'  => 'https://moz.com/learn/seo/meta-description',
     49                'count' => true,
    4650            ),
    4751
     
    7074                'class' => 'minshare-meta-card-field',
    7175            ),
     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            ),
    7287        );
     88
     89        // Unset the canonical if requested.
     90        if ( ! $canonical ) {
     91            unset( $fields['canonical'] );
     92        }
    7393
    7494        // Return our array.
     
    93113            'name'  => '',
    94114            'label' => '',
     115            'count' => false
    95116        );
    96117
     
    137158        }
    138159
    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'] ) ) {
    141162
    142163            // Check for the "more" item.
     
    145166            // Show the field.
    146167            $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>';
    147173        }
    148174
     
    208234        }
    209235
    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'] ) ) {
    212238
    213239            // Check for the "more" item.
  • minimum-viable-sharing-meta/trunk/includes/class-helper.php

    r1795465 r1887826  
    111111
    112112                case 'title' :
     113                case 'card' :
    113114                    $output[ $k ] = ! empty( $v ) ? sanitize_text_field( $v ) : '';
    114115                    break;
     
    119120
    120121                case 'image' :
     122                case 'canonical' :
    121123                    $output[ $k ] = ! empty( $v ) ? esc_url( $v ) : '';
    122                     break;
    123 
    124                 case 'card' :
    125                     $output[ $k ] = ! empty( $v ) ? sanitize_text_field( $v ) : '';
    126124                    break;
    127125
  • minimum-viable-sharing-meta/trunk/includes/class-post-meta.php

    r1795465 r1887826  
    8181
    8282            // Check for a value.
    83             $value  = ! empty( $meta[ $fkey ] ) ? $meta[ $fkey ] : false;
     83            $value  = ! empty( $meta[ $fkey ] ) ? $meta[ $fkey ] : '';
    8484
    8585            // And echo out our field.
     
    125125
    126126            case 'text' :
     127            case 'url' :
    127128                return MinimumViableMeta_Fields::text_field( $field, $value );
    128129                break;
  • minimum-viable-sharing-meta/trunk/includes/class-settings.php

    r1796510 r1887826  
    3737
    3838        // 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 ) ) {
    4040            return;
    4141        }
     
    156156
    157157            case 'text' :
     158            case 'url' :
    158159                echo MinimumViableMeta_Fields::text_field( $args, $value );
    159160                break;
  • minimum-viable-sharing-meta/trunk/includes/install.php

    r1795465 r1887826  
    1010    // Set our initial default values.
    1111    $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' => '',
    1617    );
    1718
  • minimum-viable-sharing-meta/trunk/minimum-viable-sharing-meta.php

    r1799137 r1887826  
    3939     * @var    string
    4040     */
    41     private $version = '0.0.4';
     41    private $version = '0.0.5';
    4242
    4343    /**
     
    288288                SELECT post_id
    289289                FROM $table
    290                 WHERE meta_key = %s",
    291                 esc_sql( $metakey )
    292             );
     290                WHERE meta_key = %s
     291            ", esc_sql( $metakey ) );
    293292
    294293            // Run SQL query.
     
    348347        $setup  = $wpdb->prepare("
    349348            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 ) );
    353351
    354352        // Run SQL query.
     
    431429        $items  = array(
    432430            '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',
    436436            ),
    437437            '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',
    441442            ),
    442443            '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',
    446448            ),
    447449        );
  • minimum-viable-sharing-meta/trunk/readme.txt

    r1799137 r1887826  
    55Tags: meta tags, sharing tags
    66Requires at least: 4.9
    7 Tested up to: 4.9
    8 Stable tag: 0.0.4
     7Tested up to: 4.9.6
     8Stable tag: 0.0.5
    99Requires PHP: 5.6
    1010License: MIT
     
    4141= Is this really all of them? =
    4242
     43Yes, really.
     44
    4345I 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.
    4446
     
    5456
    5557== 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.
    5662
    5763= 0.0.4 - 2018/01/08 =
Note: See TracChangeset for help on using the changeset viewer.