Plugin Directory

Changeset 1344309


Ignore:
Timestamp:
02/05/2016 09:39:31 PM (10 years ago)
Author:
prettyboymp
Message:

release version 0.6.0

Location:
voce-seo/trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • voce-seo/trunk/admin/admin.php

    r1181889 r1344309  
    44
    55    public static function init() {
    6         require_once(__DIR__ . '/field-callbacks.php');
     6        require_once( __DIR__ . '/field-callbacks.php' );
    77        VSEO_Metabox::init();
    88        VSEO_Taxonomy::init();
     
    1414
    1515    public static function init() {
    16         add_action( 'add_meta_boxes', function($post_type) {
     16        add_action( 'add_meta_boxes', function ( $post_type ) {
    1717            $post_type_object = get_post_type_object( $post_type );
    18             if ( $post_type_object && $post_type_object->publicly_queryable || $post_type === 'page' ) {
     18            if( $post_type_object && $post_type_object->publicly_queryable || $post_type === 'page' ) {
    1919                add_meta_box( 'vseo_meta', 'SEO Settings', array( 'VSEO_Metabox', 'meta_box' ), $post_type, 'advanced' );
    2020            }
     
    3232            <ul class="vseo-metabox-tabs" id="vseo-metabox-tabs">
    3333                <?php
    34                 foreach ( $tabs as $tab_id => $tab ) {
    35                     sprintf( '<li class="vseo-%1$s"><a class="vseo_tablink" href="#vseo_%1$s">%2$s</a></li>', esc_attr( $tab_id ), esc_html( $tab['label'] ) );
     34                foreach( $tabs as $tab_id => $tab ) {
     35                    sprintf( '<li class="vseo-%1$s"><a class="vseo_tablink" href="#vseo_%1$s">%2$s</a></li>', esc_attr( $tab_id ), esc_html( $tab[ 'label' ] ) );
    3636                }
    3737                ?>
    3838            </ul>
    39             <?php foreach ( $tabs as $tab_id => $tab ) : ?>
    40                 <div class="vseotab" id="vseo-<?php echo esc_attr($tab_id); ?>">
    41                     <?php foreach ( self::get_metabox_fields( $tab_id, $post_type ) as $field_id => $field ): ?>
     39            <?php foreach( $tabs as $tab_id => $tab ) : ?>
     40                <div class="vseotab" id="vseo-<?php echo esc_attr( $tab_id ); ?>">
     41                    <?php foreach( self::get_metabox_fields( $tab_id, $post_type ) as $field_id => $field ): ?>
    4242                        <p>
    43                             <label><?php echo esc_html( $field['title'] ); ?></label>
     43                            <label><?php echo esc_html( $field[ 'title' ] ); ?></label>
    4444                            <?php
    45                             echo call_user_func_array( $field['display_callback'], array(
    46                                 'vseo' . $field_id,
    47                                 isset( $vseo_meta[$field_id] ) ? $vseo_meta[$field_id] : null,
    48                                 isset( $field['args'] ) ? $field['args'] : array() )
     45                            echo call_user_func_array( $field[ 'display_callback' ], array(
     46                                            'vseo' . $field_id,
     47                                            isset( $vseo_meta[ $field_id ] ) ? $vseo_meta[ $field_id ] : null,
     48                                            isset( $field[ 'args' ] ) ? $field[ 'args' ] : array() )
    4949                            );
    5050                            ?>
     
    5959
    6060    public static function on_save_post( $post_id ) {
    61         if ( wp_is_post_autosave( $post_id ) || wp_is_post_revision( $post_id ) ) {
     61        if( wp_is_post_autosave( $post_id ) || wp_is_post_revision( $post_id ) ) {
    6262            return $post_id;
    6363        }
    64         if ( isset( $_POST['vseo_nonce'] ) && wp_verify_nonce( $_POST['vseo_nonce'], 'vseo_update_meta' ) ) {
     64        if( isset( $_POST[ 'vseo_nonce' ] ) && wp_verify_nonce( $_POST[ 'vseo_nonce' ], 'vseo_update_meta' ) ) {
    6565            $post_type = get_post_type( $post_id );
    6666            $tabs = self::get_metabox_tabs( $post_type );
    6767            $vseo_meta = ( array ) get_post_meta( $post_id, 'vseo_meta', true );
    6868
    69             foreach ( $tabs as $tab_id => $tab ) {
    70                 foreach ( self::get_metabox_fields( $tab_id, $post_type ) as $field_id => $field ) {
    71                     if ( isset( $field['sanitize_callback'] ) ) {
    72                         $vseo_meta[$field_id] = call_user_func_array( $field['sanitize_callback'], array(
    73                             isset( $_POST['vseo' . $field_id] ) ? $_POST['vseo' . $field_id] : null,
    74                             $field['args']
    75                                 ) );
     69            foreach( $tabs as $tab_id => $tab ) {
     70                foreach( self::get_metabox_fields( $tab_id, $post_type ) as $field_id => $field ) {
     71                    if( isset( $field[ 'sanitize_callback' ] ) ) {
     72                        $vseo_meta[ $field_id ] = call_user_func_array( $field[ 'sanitize_callback' ], array(
     73                                isset( $_POST[ 'vseo' . $field_id ] ) ? $_POST[ 'vseo' . $field_id ] : null,
     74                                $field[ 'args' ]
     75                        ) );
    7676                    }
    7777                }
     
    8383    private static function get_metabox_tabs( $post_type ) {
    8484        $metabox_tabs = array(
    85             'general' => array(
    86                 'label' => 'General'
    87             ),
    88             'advanced' => array(
    89                 'label' => 'Advanced'
    90             ),
    91             'social' => array(
    92                 'label' => 'Social'
    93             )
     85                'general' => array(
     86                        'label' => 'General'
     87                ),
     88                'advanced' => array(
     89                        'label' => 'Advanced'
     90                ),
     91                'social' => array(
     92                        'label' => 'Social'
     93                )
    9494        );
    9595        return apply_filters( 'vseo_metabox_tabs', $metabox_tabs, $post_type );
     
    9898    private static function get_metabox_fields( $tab, $post_type ) {
    9999        $tab_fields = array(
    100             'general' => array(
    101                 'title' => array(
    102                     'display_callback' => 'vseo_field_text',
    103                     'sanitize_callback' => 'sanitize_text_field',
    104                     'args' => array(
    105                         'description' => '<span class="description">Title display in search engines is limited to 70 chars, <span id="vseo_title-length"></span> chars left.</span>',
    106                     ),
    107                     'title' => 'SEO Title',
    108                 ),
    109                 'description' => array(
    110                     'display_callback' => 'vseo_field_textarea',
    111                     'sanitize_callback' => 'sanitize_text_field',
    112                     'args' => array(
    113                         'description' => '<span class="description">The <code>meta</code> description will be limited to 140 chars, <span id="vseo_description-length"></span> chars left</span>',
    114                     ),
    115                     'title' => 'Meta Description',
    116                 ),
    117             ),
    118             'advanced' => array(
    119                 'robots-noindex' => array(
    120                     'display_callback' => 'vseo_field_select',
    121                     'sanitize_callback' => 'vseo_sanitize_select',
    122                     'args' => array(
    123                         'options' => array(
    124                             '0' => 'Default for theme/post type',
    125                             'index' => 'index',
    126                             'noindex' => 'noindex'
    127                         ),
    128                         'default' => '0',
    129                     ),
    130                     'title' => 'Meta Robots Index',
    131                 ),
    132                 'robots-nofollow' => array(
    133                     'display_callback' => 'vseo_field_select',
    134                     'sanitize_callback' => 'vseo_sanitize_select',
    135                     'args' => array(
    136                         'options' => array(
    137                             '0' => 'Default for theme/post type',
    138                             'follow' => 'follow',
    139                             'nofollow' => 'nofollow'
    140                         ),
    141                         'default' => '0',
    142                     ),
    143                     'title' => 'Meta Robots Follow',
    144                 ),
    145                 'canonical' => array(
    146                     'display_callback' => 'vseo_field_text',
    147                     'sanitize_callback' => 'vseo_sanitize_url',
    148                     'args' => array(
    149                         'description' => '<span class="description">The canonical URL that this page should point to, leave empty to default to permalink.</span>',
    150                     ),
    151                     'title' => 'Canonical URL',
    152                 ),
    153             ),
    154             'social' => array(
    155                 'og_title' => array(
    156                     'display_callback' => 'vseo_field_text',
    157                     'sanitize_callback' => 'sanitize_text_field',
    158                     'args' => array(
    159                         'description' => '<span class="description">If you don\'t want to use the post or SEO title for sharing the post on Facebook/Open Graph but want another title there, write it here.</span>',
    160                     ),
    161                     'title' => 'Facebook/Open Graph Title',
    162                 ),
    163                 'og_description' => array(
    164                     'display_callback' => 'vseo_field_textarea',
    165                     'sanitize_callback' => 'sanitize_text_field',
    166                     'args' => array(
    167                         'description' => '<span class="description">If you don\'t want to use the meta description for sharing the post on Facebook/Open Graph but want another description there, write it here.</span>',
    168                     ),
    169                     'title' => 'Facebook/Open Graph Description',
    170                 ),
    171                 'twitter_title' => array(
    172                     'display_callback' => 'vseo_field_text',
    173                     'sanitize_callback' => 'sanitize_text_field',
    174                     'args' => array(
    175                         'description' => '<span class="description">If you don\'t want to use the post or SEO title for sharing the post on Twitter but want another title there, write it here.</span>',
    176                     ),
    177                     'title' => 'Twitter Title',
    178                 ),
    179                 'twitter_description' => array(
    180                     'display_callback' => 'vseo_field_textarea',
    181                     'sanitize_callback' => 'sanitize_text_field',
    182                     'args' => array(
    183                         'description' => '<span class="description">If you don\'t want to use the meta title for sharing the post on Facebook/Open Graph but want another title there, write it here.</span>',
    184                     ),
    185                     'title' => 'Twitter Description',
    186                 ),
    187             ),
     100                'general' => array(
     101                        'title' => array(
     102                                'display_callback' => 'vseo_field_text',
     103                                'sanitize_callback' => 'sanitize_text_field',
     104                                'args' => array(
     105                                        'description' => '<span class="description">Title display in search engines is limited to 70 chars, <span id="vseo_title-length"></span> chars left.</span>',
     106                                ),
     107                                'title' => 'SEO Title',
     108                        ),
     109                        'description' => array(
     110                                'display_callback' => 'vseo_field_textarea',
     111                                'sanitize_callback' => 'sanitize_text_field',
     112                                'args' => array(
     113                                        'description' => '<span class="description">The <code>meta</code> description will be limited to 140 chars, <span id="vseo_description-length"></span> chars left</span>',
     114                                ),
     115                                'title' => 'Meta Description',
     116                        ),
     117                        'keywords' => array(
     118                                'display_callback' => 'vseo_field_text',
     119                                'sanitize_callback' => 'sanitize_text_field',
     120                                'args' => array(
     121                                        'description' => '<span class="description">The comma separated <code>meta</code> key words to help determine the page topics.</span>',
     122                                ),
     123                                'title' => 'Keywords',
     124                        )
     125                ),
     126                'advanced' => array(
     127                        'robots-noindex' => array(
     128                                'display_callback' => 'vseo_field_select',
     129                                'sanitize_callback' => 'vseo_sanitize_select',
     130                                'args' => array(
     131                                        'options' => array(
     132                                                '0' => 'Default for theme/post type',
     133                                                'index' => 'index',
     134                                                'noindex' => 'noindex'
     135                                        ),
     136                                        'default' => '0',
     137                                ),
     138                                'title' => 'Meta Robots Index',
     139                        ),
     140                        'robots-nofollow' => array(
     141                                'display_callback' => 'vseo_field_select',
     142                                'sanitize_callback' => 'vseo_sanitize_select',
     143                                'args' => array(
     144                                        'options' => array(
     145                                                '0' => 'Default for theme/post type',
     146                                                'follow' => 'follow',
     147                                                'nofollow' => 'nofollow'
     148                                        ),
     149                                        'default' => '0',
     150                                ),
     151                                'title' => 'Meta Robots Follow',
     152                        ),
     153                        'canonical' => array(
     154                                'display_callback' => 'vseo_field_text',
     155                                'sanitize_callback' => 'vseo_sanitize_url',
     156                                'args' => array(
     157                                        'description' => '<span class="description">The canonical URL that this page should point to, leave empty to default to permalink.</span>',
     158                                ),
     159                                'title' => 'Canonical URL',
     160                        ),
     161                ),
     162                'social' => array(
     163                        'og_title' => array(
     164                                'display_callback' => 'vseo_field_text',
     165                                'sanitize_callback' => 'sanitize_text_field',
     166                                'args' => array(
     167                                        'description' => '<span class="description">If you don\'t want to use the post or SEO title for sharing the post on Facebook/Open Graph but want another title there, write it here.</span>',
     168                                ),
     169                                'title' => 'Facebook/Open Graph Title',
     170                        ),
     171                        'og_description' => array(
     172                                'display_callback' => 'vseo_field_textarea',
     173                                'sanitize_callback' => 'sanitize_text_field',
     174                                'args' => array(
     175                                        'description' => '<span class="description">If you don\'t want to use the meta description for sharing the post on Facebook/Open Graph but want another description there, write it here.</span>',
     176                                ),
     177                                'title' => 'Facebook/Open Graph Description',
     178                        ),
     179                        'twitter_title' => array(
     180                                'display_callback' => 'vseo_field_text',
     181                                'sanitize_callback' => 'sanitize_text_field',
     182                                'args' => array(
     183                                        'description' => '<span class="description">If you don\'t want to use the post or SEO title for sharing the post on Twitter but want another title there, write it here.</span>',
     184                                ),
     185                                'title' => 'Twitter Title',
     186                        ),
     187                        'twitter_description' => array(
     188                                'display_callback' => 'vseo_field_textarea',
     189                                'sanitize_callback' => 'sanitize_text_field',
     190                                'args' => array(
     191                                        'description' => '<span class="description">If you don\'t want to use the meta title for sharing the post on Facebook/Open Graph but want another title there, write it here.</span>',
     192                                ),
     193                                'title' => 'Twitter Description',
     194                        ),
     195                ),
    188196        );
    189197
    190         if ( !apply_filters( 'vseo_use_facebook_meta', true ) ) {
    191             unset( $tab_fields['social']['og_description'] );
    192         }
    193 
    194         if ( !apply_filters( 'vseo_use_twitter_meta', true ) ) {
    195             unset( $tab_fields['social']['twitter_description'] );
    196         }
    197 
    198 
    199         return apply_filters( 'vseo_metabox_fields', isset( $tab_fields[$tab] ) ?
    200                         $tab_fields[$tab] : array(), $tab, $post_type );
     198        if( ! apply_filters( 'vseo_use_facebook_meta', true ) ) {
     199            unset( $tab_fields[ 'social' ][ 'og_description' ] );
     200        }
     201
     202        if( ! apply_filters( 'vseo_use_twitter_meta', true ) ) {
     203            unset( $tab_fields[ 'social' ][ 'twitter_description' ] );
     204        }
     205
     206
     207        return apply_filters( 'vseo_metabox_fields', isset( $tab_fields[ $tab ] ) ?
     208                $tab_fields[ $tab ] : array(), $tab, $post_type );
    201209    }
    202210
     
    209217    public static function init() {
    210218        $taxonomies = get_taxonomies( '', 'names' );
    211         foreach ( $taxonomies as $taxonomy ) {
     219        foreach( $taxonomies as $taxonomy ) {
    212220            add_action( $taxonomy . '_add_form_fields', array( __CLASS__, 'add_new_meta_field' ), 10, 1 );
    213221            add_action( $taxonomy . '_edit_form_fields', array( __CLASS__, 'edit_meta_field' ), 10, 2 );
     
    235243        ?>
    236244        <tr class="form-field">
    237             <th scope="row" valign="top"><label for="term_meta[title]"><?php esc_html_e( 'SEO Title', 'voce_seo' ); ?></label></th>
     245            <th scope="row" valign="top"><label for="term_meta[title]"><?php esc_html_e( 'SEO Title', 'voce_seo' ); ?></label>
     246            </th>
    238247            <td>
    239                 <input type="text" name="term_meta[title]" id="term_meta[title]" value="<?php echo isset( $term_meta[ $taxonomy . '_' . $term_id ]['title'] ) ? esc_attr( $term_meta[ $taxonomy . '_' . $term_id ]['title'] ) : ''; ?>">
     248                <input type="text" name="term_meta[title]" id="term_meta[title]"
     249                             value="<?php echo isset( $term_meta[ $taxonomy . '_' . $term_id ][ 'title' ] ) ? esc_attr( $term_meta[ $taxonomy . '_' . $term_id ][ 'title' ] ) : ''; ?>">
    240250            </td>
    241251        </tr>
     
    246256
    247257    public static function save_meta( $term_id ) {
    248         if (
    249                 isset( $_POST['term_meta'] ) &&
     258        if(
     259                isset( $_POST[ 'term_meta' ] ) &&
    250260                check_admin_referer( 'voce_seo_term', 'voce_seo_term' )
    251261        ) {
    252262            $_POST = array_map( 'stripslashes_deep', $_POST ); //prevent escaping from option value http://codex.wordpress.org/Function_Reference/stripslashes_deep
    253             $taxonomy = $_POST['voce_seo_taxonomy'];
     263            $taxonomy = $_POST[ 'voce_seo_taxonomy' ];
    254264
    255265            $term_meta = get_option( self::$option_key );
    256             $cat_keys = array_keys( $_POST['term_meta'] );
     266            $cat_keys = array_keys( $_POST[ 'term_meta' ] );
    257267            $meta_data = array();
    258             foreach ( $cat_keys as $key ) {
    259                 if ( isset( $_POST['term_meta'][$key] ) ) {
    260                     $meta_data[$key] = sanitize_text_field( $_POST['term_meta'][$key] );
     268            foreach( $cat_keys as $key ) {
     269                if( isset( $_POST[ 'term_meta' ][ $key ] ) ) {
     270                    $meta_data[ $key ] = sanitize_text_field( $_POST[ 'term_meta' ][ $key ] );
    261271                }
    262272            }
     
    268278    /**
    269279     * Handling the splitting of terms with WordPress 4.2
     280     *
    270281     * @param type $old_term_id
    271282     * @param type $new_term_id
     
    276287        $vseo_term_meta = get_option( self::$option_key );
    277288
    278         if ( isset( $vseo_term_meta[$taxonomy . '_' . $old_term_id] ) ) {
    279             $vseo_term_meta[$taxonomy . '_' . $new_term_id] = $vseo_term_meta[$taxonomy . '_' . $old_term_id];
    280             unset( $vseo_term_meta[$taxonomy . '_' . $old_term_id] );
     289        if( isset( $vseo_term_meta[ $taxonomy . '_' . $old_term_id ] ) ) {
     290            $vseo_term_meta[ $taxonomy . '_' . $new_term_id ] = $vseo_term_meta[ $taxonomy . '_' . $old_term_id ];
     291            unset( $vseo_term_meta[ $taxonomy . '_' . $old_term_id ] );
    281292            update_option( self::$option_key, $vseo_term_meta );
    282293        }
  • voce-seo/trunk/readme.txt

    r1181889 r1344309  
    33Tags: SEO
    44Requires at least: 3.7.0
    5 Tested up to: 4.2.2
    6 Stable tag: 0.5.2
     5Tested up to: 4.2.4
     6Stable tag: 0.6.0
    77License: GPLv2 or later
    88
     
    3232
    3333== Changelog ==
     34= Version 0.6.0 =
     35* Adding more flexible support for other single post types
     36* Adding keywords support.
     37
     38= Version 0.5.4 =
     39* Adding `get_vseo_meta` filter
     40
     41= Version 0.5.3 =
     42* Adding escaping per VIP
     43
    3444= Version 0.5.2 =
    3545* Strict comparisons
  • voce-seo/trunk/vendor/autoload.php

    r1181889 r1344309  
    55require_once __DIR__ . '/composer' . '/autoload_real.php';
    66
    7 return ComposerAutoloaderInit3af71242fe1b43686624cc1ff7b8eccd::getLoader();
     7return ComposerAutoloaderInit37665239d184aaad487429639b869c4c::getLoader();
  • voce-seo/trunk/vendor/composer/ClassLoader.php

    r1179656 r1344309  
    1414
    1515/**
    16  * ClassLoader implements a PSR-0 class loader
    17  *
    18  * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
     16 * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
    1917 *
    2018 *     $loader = new \Composer\Autoload\ClassLoader();
     
    4038 * @author Fabien Potencier <fabien@symfony.com>
    4139 * @author Jordi Boggiano <j.boggiano@seld.be>
     40 * @see    http://www.php-fig.org/psr/psr-0/
     41 * @see    http://www.php-fig.org/psr/psr-4/
    4242 */
    4343class ClassLoader
     
    148148     *
    149149     * @param string       $prefix  The prefix/namespace, with trailing '\\'
    150      * @param array|string $paths   The PSR-0 base directories
     150     * @param array|string $paths   The PSR-4 base directories
    151151     * @param bool         $prepend Whether to prepend the directories
    152152     *
     
    352352                if (0 === strpos($class, $prefix)) {
    353353                    foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
    354                         if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
     354                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
    355355                            return $file;
    356356                        }
     
    362362        // PSR-4 fallback dirs
    363363        foreach ($this->fallbackDirsPsr4 as $dir) {
    364             if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
     364            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
    365365                return $file;
    366366            }
     
    381381                if (0 === strpos($class, $prefix)) {
    382382                    foreach ($dirs as $dir) {
    383                         if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
     383                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
    384384                            return $file;
    385385                        }
     
    391391        // PSR-0 fallback dirs
    392392        foreach ($this->fallbackDirsPsr0 as $dir) {
    393             if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
     393            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
    394394                return $file;
    395395            }
  • voce-seo/trunk/vendor/composer/autoload_files.php

    r839041 r1344309  
    77
    88return array(
    9     $vendorDir . '/voceconnect/voce-settings-api/voce-settings-api.php',
     9    'aecffab7c5c91b3ba12381df2fefa2ed' => $vendorDir . '/voceconnect/voce-settings-api/voce-settings-api.php',
    1010);
  • voce-seo/trunk/vendor/composer/autoload_real.php

    r1181889 r1344309  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit3af71242fe1b43686624cc1ff7b8eccd
     5class ComposerAutoloaderInit37665239d184aaad487429639b869c4c
    66{
    77    private static $loader;
     
    2020        }
    2121
    22         spl_autoload_register(array('ComposerAutoloaderInit3af71242fe1b43686624cc1ff7b8eccd', 'loadClassLoader'), true, true);
     22        spl_autoload_register(array('ComposerAutoloaderInit37665239d184aaad487429639b869c4c', 'loadClassLoader'), true, true);
    2323        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInit3af71242fe1b43686624cc1ff7b8eccd', 'loadClassLoader'));
     24        spl_autoload_unregister(array('ComposerAutoloaderInit37665239d184aaad487429639b869c4c', 'loadClassLoader'));
    2525
    2626        $map = require __DIR__ . '/autoload_namespaces.php';
     
    4242
    4343        $includeFiles = require __DIR__ . '/autoload_files.php';
    44         foreach ($includeFiles as $file) {
    45             composerRequire3af71242fe1b43686624cc1ff7b8eccd($file);
     44        foreach ($includeFiles as $fileIdentifier => $file) {
     45            composerRequire37665239d184aaad487429639b869c4c($fileIdentifier, $file);
    4646        }
    4747
     
    5050}
    5151
    52 function composerRequire3af71242fe1b43686624cc1ff7b8eccd($file)
     52function composerRequire37665239d184aaad487429639b869c4c($fileIdentifier, $file)
    5353{
    54     require $file;
     54    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
     55        require $file;
     56
     57        $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
     58    }
    5559}
  • voce-seo/trunk/voce-seo.php

    r1181889 r1344309  
    11<?php
     2
    23/*
    34  Plugin Name: Voce SEO
    4   Version: 0.5.2
     5  Version: 0.6.0
    56  Plugin URI: http://voceconnect.com/
    67  Description: An SEO plugin taking things from both WP SEO and All in One SEO but leaving out the VIP incompatible pieces.
     
    1516    public static function init() {
    1617
    17         @include( dirname(__FILE__) . '/vendor/autoload.php' );
     18        @include( dirname( __FILE__ ) . '/vendor/autoload.php' );
    1819
    1920        self::upgrade_check();
    2021
    21         if(  is_admin() ) {
    22             require_once (__DIR__ . '/admin/admin.php');
     22        if( is_admin() ) {
     23            require_once( __DIR__ . '/admin/admin.php' );
    2324            VSEO_Admin::init();
    2425        }
    2526
    2627        Voce_Settings_API::GetInstance()
    27             ->add_page('SEO Settings', 'SEO Settings', 'vseo', 'manage_options', '', 'options-general.php')
    28                 ->add_group('General', 'vseo-general')
    29                     ->add_setting('Add nodp', 'nodp', array(
     28                ->add_page( 'SEO Settings', 'SEO Settings', 'vseo', 'manage_options', '', 'options-general.php' )
     29                ->add_group( 'General', 'vseo-general' )
     30                ->add_setting( 'Add nodp', 'nodp', array(
    3031                        'display_callback' => 'vs_display_checkbox',
    31                         'sanitize_callbacks' => array('vs_sanitize_checkbox'),
     32                        'sanitize_callbacks' => array( 'vs_sanitize_checkbox' ),
    3233                        'description' => 'Prevents search engines from using the DMOZ description for pages from this site in the search results.'
    33                         ))->group
    34                     ->add_setting('Add noydir', 'noydir', array(
     34                ) )->group
     35                ->add_setting( 'Add noydir', 'noydir', array(
    3536                        'display_callback' => 'vs_display_checkbox',
    36                         'sanitize_callbacks' => array('vs_sanitize_checkbox'),
     37                        'sanitize_callbacks' => array( 'vs_sanitize_checkbox' ),
    3738                        'description' => 'Prevents search engines from using the Yahoo! directory description for pages from this site in the search results.'
    38                         ));
     39                ) );
    3940
    4041        remove_action( 'wp_head', 'rel_canonical' );
    4142
    4243        //add namespaces
    43         add_filter( 'language_attributes', function($output ) {
    44                 $prefixes = array(
     44        add_filter( 'language_attributes', function ( $output ) {
     45            $prefixes = array(
    4546                    'og' => 'http://ogp.me/ns#',
    4647                    'fb' => 'http://ogp.me/ns/fb#',
    4748                    'article' => 'http://ogp.me/ns/article#'
    48                 );
    49                 $prefixes = apply_filters( 'opengraph_prefixes', $prefixes );
    50 
    51                 $prefix_str = '';
    52                 foreach ( $prefixes as $k => $v ) {
    53                     $prefix_str .= $k . ': ' . $v . ' ';
    54                 }
    55                 $prefix_str = trim( $prefix_str );
    56 
    57                 if ( preg_match( '/(prefix\s*=\s*[\"|\'])/i', $output ) ) {
    58                     $output = preg_replace( '/(prefix\s*=\s*[\"|\'])/i', '${1}' . $prefix_str, $output );
    59                 } else {
    60                     $output .= ' prefix="' . $prefix_str . '"';
    61                 }
    62                 return $output;
    63             } );
    64 
    65         add_filter( 'wp_title', array( __CLASS__, 'seo_title' ), 10, 3);
    66 
    67         add_action('wp_head', array(__CLASS__, 'on_wp_head'));
     49            );
     50            $prefixes = apply_filters( 'opengraph_prefixes', $prefixes );
     51
     52            $prefix_str = '';
     53            foreach( $prefixes as $k => $v ) {
     54                $prefix_str .= $k . ': ' . $v . ' ';
     55            }
     56            $prefix_str = trim( $prefix_str );
     57
     58            if( preg_match( '/(prefix\s*=\s*[\"|\'])/i', $output ) ) {
     59                $output = preg_replace( '/(prefix\s*=\s*[\"|\'])/i', '${1}' . $prefix_str, $output );
     60            } else {
     61                $output .= ' prefix="' . $prefix_str . '"';
     62            }
     63            return $output;
     64        } );
     65
     66        add_filter( 'wp_title', array( __CLASS__, 'seo_title' ), 10, 3 );
     67
     68        add_action( 'wp_head', array( __CLASS__, 'on_wp_head' ) );
    6869    }
    6970
    7071    static function seo_title( $title, $sep, $seplocation ) {
    71         $new_title         = '';
    72         $t_sep             = '%WP_TITILE_SEP%';
    73         $queried_object    = get_queried_object();
     72        $new_title = '';
     73        $t_sep = '%WP_TITILE_SEP%';
     74        $queried_object = get_queried_object();
    7475        $queried_post_type = get_post_type_object( get_post_type( $queried_object ) );
    7576
    76         if (
    77             is_single() &&
    78             $queried_object &&
    79             is_object( $queried_post_type ) &&
    80             $queried_post_type->publicly_queryable
    81         ) {
    82 
    83             $post_id   = get_queried_object_id();
     77        if( self::is_singular_viewable_post_query() ) {
     78
     79            $post_id = get_queried_object_id();
    8480            $vseo_meta = (array) get_post_meta( $post_id, 'vseo_meta', true );
    8581
    86             if ( ! empty( $vseo_meta['title'] ) ) {
    87 
    88                 $new_title = apply_filters( 'single_post_title', $vseo_meta['title'], $queried_object );
    89 
    90             }
    91 
    92         } elseif ( is_tax() || is_category() || is_tag() ) {
    93                     $new_title = self::get_term_seo_title();
    94                 }
    95 
    96         if ( !empty( $new_title ) ) {
     82            if( ! empty( $vseo_meta[ 'title' ] ) ) {
     83
     84                $new_title = apply_filters( 'single_post_title', $vseo_meta[ 'title' ], $queried_object );
     85
     86            }
     87
     88        } elseif( is_tax() || is_category() || is_tag() ) {
     89            $new_title = self::get_term_seo_title();
     90        }
     91
     92        if( ! empty( $new_title ) ) {
    9793            $title = $new_title;
    9894
    99             if ( !empty( $title ) )
     95            if( ! empty( $title ) ) {
    10096                $prefix = " $sep ";
     97            }
    10198
    10299            // Determines position of the separator and direction of the breadcrumb
    103             if ( 'right' === $seplocation ) { // sep on right, so reverse the order
     100            if( 'right' === $seplocation ) { // sep on right, so reverse the order
    104101                $title_array = explode( $t_sep, $title );
    105102                $title_array = array_reverse( $title_array );
     
    114111    }
    115112
    116     private static function get_term_seo_title(){
     113    private static function get_term_seo_title() {
    117114        $queried_object = get_queried_object();
    118115        $term_id = $queried_object->term_id;
     
    120117        $option_key = $taxonomy . '_' . $term_id;
    121118        $term_meta = get_option( 'vseo_term_meta' );
    122         if ( ! isset( $term_meta[ $option_key ]['title'] ) ) {
     119        if( ! isset( $term_meta[ $option_key ][ 'title' ] ) ) {
    123120            return;
    124121        }
    125         $seo_title = $term_meta[ $option_key ]['title'];
     122        $seo_title = $term_meta[ $option_key ][ 'title' ];
    126123        $title_filter = 'single_cat_title';
    127         if ( is_tax() ){
     124        if( is_tax() ) {
    128125            $title_filter = 'single_term_filter';
    129126        } elseif( is_tag() ) {
     
    135132
    136133    private static function upgrade_check() {
    137         $db_version = get_option('VSEO_Version', '0.0');
    138         if($db_version < 0.1) {
    139             Voce_Settings_API::GetInstance()->set_setting('robots-nodp', 'vseo-general', true);
    140             Voce_Settings_API::GetInstance()->set_setting('robots-noydir', 'vseo-general', true);
    141         }
    142 
    143         if ( $db_version < 0.2 && function_exists( 'wp_get_split_term' ) ) {
     134        $db_version = get_option( 'VSEO_Version', '0.0' );
     135        if( $db_version < 0.1 ) {
     136            Voce_Settings_API::GetInstance()->set_setting( 'robots-nodp', 'vseo-general', true );
     137            Voce_Settings_API::GetInstance()->set_setting( 'robots-noydir', 'vseo-general', true );
     138        }
     139
     140        if( $db_version < 0.2 && function_exists( 'wp_get_split_term' ) ) {
    144141            $term_meta = $updated_term_meta = get_option( 'vseo_term_meta' );
    145             if ( is_array( $term_meta ) ) {
     142            if( is_array( $term_meta ) ) {
    146143                foreach( $term_meta as $taxonomy_term => $term_data ) {
    147144                    $tax_term_arr = explode( '_', $taxonomy_term );
    148                     if ( is_array( $tax_term_arr ) && !empty( $tax_term_arr ) ) {
    149                         $term_id  = array_pop( $tax_term_arr );
     145                    if( is_array( $tax_term_arr ) && ! empty( $tax_term_arr ) ) {
     146                        $term_id = array_pop( $tax_term_arr );
    150147                        $taxonomy = implode( '_', $tax_term_arr );
    151148                        $new_term_id = wp_get_split_term( $term_id, $taxonomy );
    152                         if ( $new_term_id !== false ) {
    153                             unset( $updated_term_meta[$taxonomy_term] );
    154                             $updated_term_meta[sprintf( '%s_%s', $taxonomy, $new_term_id )] = $term_data;
     149                        if( $new_term_id !== false ) {
     150                            unset( $updated_term_meta[ $taxonomy_term ] );
     151                            $updated_term_meta[ sprintf( '%s_%s', $taxonomy, $new_term_id ) ] = $term_data;
    155152                        }
    156153                    }
     
    160157        }
    161158
    162         update_option('VSEO_Version', self::DB_VERSION);
     159        update_option( 'VSEO_Version', self::DB_VERSION );
    163160    }
    164161
     
    171168        $meta_objects = self::create_meta_object( 'og:locale', 'meta', array( 'property' => 'og:locale', 'content' => 'en_us' ), $meta_objects );
    172169
    173         $description    = self::get_meta_description();
    174         $queried_object = get_queried_object();
    175         if ( isset( $queried_object->post_type ) || ( is_tax() || is_category() || is_tag() ) || is_home() || is_front_page() ) {
     170        $description = self::get_meta_description();
     171        $queried_object = get_queried_object();
     172        if( isset( $queried_object->post_type ) || ( is_tax() || is_category() || is_tag() ) || is_home() || is_front_page() ) {
    176173            $og_description = self::get_seo_meta( 'og_description', get_queried_object_id() );
    177             if ( ! $og_description ) {
     174            if( ! $og_description ) {
    178175                $og_description = $description;
    179176            }
    180             if ( $og_description ) {
     177            if( $og_description ) {
    181178                $meta_objects = self::create_meta_object( 'og:description', 'meta', array( 'property' => 'og:description', 'content' => esc_attr( $og_description ) ), $meta_objects );
    182179            }
     
    197194        }
    198195
    199         $description    = self::get_meta_description();
    200         $queried_object = get_queried_object();
    201         if ( isset( $queried_object->post_type ) || ( is_tax() || is_category() || is_tag() ) ) {
     196        $description = self::get_meta_description();
     197        $queried_object = get_queried_object();
     198        if( isset( $queried_object->post_type ) || ( is_tax() || is_category() || is_tag() ) ) {
    202199            $twitter_description = self::get_seo_meta( 'twitter_description', get_queried_object_id() );
    203             if ( ! $twitter_description )
     200            if( ! $twitter_description ) {
    204201                $twitter_description = $description;
     202            }
    205203            $meta_objects = self::create_meta_object( 'twitter:description', 'meta', array( 'name' => 'twitter:description', 'content' => esc_attr( $twitter_description ) ), $meta_objects );
    206204        }
     
    218216
    219217    private static function create_meta_object( $key, $type, $attributes = array(), $meta_objects = array() ) {
    220         $meta_objects[$key] = array(
    221             'type'      => $type,
    222             'attributes' => $attributes
     218        $meta_objects[ $key ] = array(
     219                'type' => $type,
     220                'attributes' => $attributes
    223221        );
    224222
     
    229227        $html = '';
    230228        $allowed_tags = array(
    231             'meta' => array(
    232                 'charset' => true,
    233                 'content' => true,
    234                 'http-equiv' => true,
    235                 'name' => true,
    236                 'property' => true
    237             ),
    238             'link' => array(
    239                 'href' => true,
    240                 'rel' => true,
    241                 'media' => true,
    242                 'hreflang' => true,
    243                 'type' => true,
    244                 'sizes' => true
    245             ),
     229                'meta' => array(
     230                        'charset' => true,
     231                        'content' => true,
     232                        'http-equiv' => true,
     233                        'name' => true,
     234                        'property' => true
     235                ),
     236                'link' => array(
     237                        'href' => true,
     238                        'rel' => true,
     239                        'media' => true,
     240                        'hreflang' => true,
     241                        'type' => true,
     242                        'sizes' => true
     243                ),
    246244        );
    247245
    248246        foreach( $meta_objects as $meta_object => $properties ) {
    249247            $atts_string = '';
    250             $element     = !empty($properties['type']) ? $properties['type'] : false;
    251             $attributes  = !empty($properties['attributes']) ? $properties['attributes'] : false;
    252 
    253             if ( $element && $attributes && is_array($attributes) ) {
     248            $element = ! empty( $properties[ 'type' ] ) ? $properties[ 'type' ] : false;
     249            $attributes = ! empty( $properties[ 'attributes' ] ) ? $properties[ 'attributes' ] : false;
     250
     251            if( $element && $attributes && is_array( $attributes ) ) {
    254252
    255253                foreach( $attributes as $att => $value ) {
     
    281279        }
    282280
    283         if ( apply_filters( 'vseo_use_facebook_meta', true ) )
     281        if( $keywords = self::get_meta_keywords() ) {
     282            $meta_objects = self::create_meta_object( 'keywords', 'meta', array( 'name' => 'keywords', 'content' => esc_attr( $keywords ) ), $meta_objects );
     283        }
     284
     285        if( apply_filters( 'vseo_use_facebook_meta', true ) ) {
    284286            $meta_objects = self::generate_facebook_seo_data( $meta_objects );
    285 
    286         if ( apply_filters( 'vseo_use_twitter_meta', true ) )
     287        }
     288
     289        if( apply_filters( 'vseo_use_twitter_meta', true ) ) {
    287290            $meta_objects = self::generate_twitter_seo_data( $meta_objects );
     291        }
    288292
    289293        $meta_objects = apply_filters( 'vseo_meta_objects', $meta_objects );
     
    298302    public static function get_social_title( $meta_key ) {
    299303        $title = '';
    300         if ( is_home() || is_front_page() ) {
     304        if( is_home() || is_front_page() ) {
    301305            $title = get_bloginfo( 'name' );
    302         } else if ( is_author() ) {
    303             $author = get_queried_object();
    304             $title = $author->display_name;
    305         } else if ( is_singular() ) {
    306             global $post;
    307             $title = self::get_seo_meta( $meta_key );
    308             if ( ! $title ) {
    309                 $vseo_meta = (array) get_post_meta( $post->ID, 'vseo_meta', true );;
    310                 if ( array_key_exists( 'title', $vseo_meta ) ) {
    311                     $title = $vseo_meta['title'];
    312                 }
    313                 if ( ! $title ) {
    314                     $title = empty( $post->post_title ) ? ' ' : wp_kses( $post->post_title, array() ) ;
    315                 }
    316             }
    317         } else if ( is_tax() || is_category() || is_tag() ){
    318             $title = self::get_term_seo_title();
    319306        } else {
    320             $title = '';
     307            if( is_author() ) {
     308                $author = get_queried_object();
     309                $title = $author->display_name;
     310            } else {
     311                if( self::is_singular_viewable_post_query() ) {
     312                    $post = get_queried_object();
     313                    $title = self::get_seo_meta( $meta_key, $post->ID );
     314                    if( ! $title ) {
     315                        $vseo_meta = (array) get_post_meta( $post->ID, 'vseo_meta', true );;
     316                        if( array_key_exists( 'title', $vseo_meta ) ) {
     317                            $title = $vseo_meta[ 'title' ];
     318                        }
     319                        if( ! $title ) {
     320                            $title = empty( $post->post_title ) ? ' ' : wp_kses( $post->post_title, array() );
     321                        }
     322                    }
     323                } else {
     324                    if( is_tax() || is_category() || is_tag() ) {
     325                        $title = self::get_term_seo_title();
     326                    } else {
     327                        $title = '';
     328                    }
     329                }
     330            }
    321331        }
    322332
     
    324334    }
    325335
    326     public static function get_seo_meta($key, $post_id = 0) {
    327         if(!$post_id) $post_id = get_the_ID ( );
    328 
    329         $vseo_meta = (array) get_post_meta($post_id, 'vseo_meta', true);
    330 
    331         return isset($vseo_meta[$key]) ? $vseo_meta[$key] : null;
     336    public static function get_seo_meta( $key, $post_id = 0 ) {
     337        if( ! $post_id ) {
     338            $post_id = get_the_ID();
     339        }
     340
     341        $vseo_meta = (array) get_post_meta( $post_id, 'vseo_meta', true );
     342
     343        return isset( $vseo_meta[ $key ] ) ? $vseo_meta[ $key ] : null;
    332344    }
    333345
    334346    public static function get_meta_description() {
    335         if ( get_query_var( 'paged' ) && get_query_var( 'paged' ) > 1 )
     347        if( get_query_var( 'paged' ) && get_query_var( 'paged' ) > 1 ) {
    336348            return '';
     349        }
    337350
    338351        $description = '';
     
    340353        $queried_object = get_queried_object();
    341354
    342         if ( isset($queried_object->post_type) ) {
    343             if(!($description = self::get_seo_meta( 'description', get_queried_object_id()))) {
     355        if( isset( $queried_object->post_type ) ) {
     356            if( ! ( $description = self::get_seo_meta( 'description', get_queried_object_id() ) ) ) {
    344357                //get description from excerpt/content
    345                 $description = empty($queried_object->post_excerpt) ? $queried_object->post_content : $queried_object->post_excerpt;
    346                 $description = str_replace(']]>', ']]&gt;', $description);
     358                $description = empty( $queried_object->post_excerpt ) ? $queried_object->post_content : $queried_object->post_excerpt;
     359                $description = str_replace( ']]>', ']]&gt;', $description );
    347360                $description = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $description );
    348                 $description = strip_tags($description);
     361                $description = strip_tags( $description );
    349362                $max = 250;
    350                 if ($max < strlen($description)) {
    351                     while($description[$max] !== ' ' && $max > 40) {
     363                if( $max < strlen( $description ) ) {
     364                    while( $description[ $max ] !== ' ' && $max > 40 ) {
    352365                        $max--;
    353366                    }
    354367                }
    355                 $description = substr($description, 0, $max);
    356                 $description = trim(stripcslashes($description));
     368                $description = substr( $description, 0, $max );
     369                $description = trim( stripcslashes( $description ) );
    357370
    358371                $description = preg_replace( "/\s\s+/u", " ", $description );
    359372            }
    360373        } else {
    361             if ( is_tax() || is_category() || is_tag() ) {
    362                     $queried_object = get_queried_object();
    363                     $term_id = $queried_object->term_id;
    364                     $taxonomy = $queried_object->taxonomy;
    365                     $description = term_description( $term_id, $taxonomy );
    366 
    367             } elseif ( is_search() ) {
    368                     $description = '';
     374            if( is_tax() || is_category() || is_tag() ) {
     375                $queried_object = get_queried_object();
     376                $term_id = $queried_object->term_id;
     377                $taxonomy = $queried_object->taxonomy;
     378                $description = term_description( $term_id, $taxonomy );
     379
     380            } elseif( is_search() ) {
     381                $description = '';
    369382            } else {
    370                     $description = get_bloginfo( 'description', 'display' );
     383                $description = get_bloginfo( 'description', 'display' );
    371384            }
    372385        }
     
    375388
    376389        return strip_tags( stripslashes( $description ) );
     390    }
     391
     392    public static function get_meta_keywords() {
     393        $keywords = '';
     394        if( self::is_singular_viewable_post_query() ) {
     395            $keywords = self::get_seo_meta( 'keywords', get_queried_object_id() );
     396        }
     397        return apply_filters( 'seo_meta_keywords', trim( $keywords ) );
    377398    }
    378399
     
    383404
    384405        $robots_defaults = array(
    385             'index' => 'index',
    386             'follow' => 'follow',
    387             'other' => array(),
     406                'index' => 'index',
     407                'follow' => 'follow',
     408                'other' => array(),
    388409        );
    389410
    390411        //use this to replace the defaults, these values will be overwritten by post meta if set
    391         $robots = apply_filters('vseo_robots_defaults', $robots_defaults);
    392 
    393         if ( isset($queried_object->post_type) ) {
    394             if ( $follow = self::get_seo_meta('robots-nofollow', get_queried_object_id()) ) {
    395                 $robots['follow'] = $follow;
    396             }
    397             if ( $index = self::get_seo_meta('robots-noindex', get_queried_object_id()) ) {
    398                 $robots['index'] = $index;
     412        $robots = apply_filters( 'vseo_robots_defaults', $robots_defaults );
     413
     414        if( isset( $queried_object->post_type ) ) {
     415            if( $follow = self::get_seo_meta( 'robots-nofollow', get_queried_object_id() ) ) {
     416                $robots[ 'follow' ] = $follow;
     417            }
     418            if( $index = self::get_seo_meta( 'robots-noindex', get_queried_object_id() ) ) {
     419                $robots[ 'index' ] = $index;
    399420            }
    400421        } else {
    401             if ( is_search() || is_archive() ) {
    402                 $robots['index'] = 'noindex';
    403             }
    404         }
    405 
    406         foreach ( array( 'nodp', 'noydir' ) as $robot ) {
    407             if ( Voce_Settings_API::GetInstance()->get_setting( $robot, 'vseo-general' ) ) {
    408                 $robots['other'][] = $robot;
     422            if( is_search() || is_archive() ) {
     423                $robots[ 'index' ] = 'noindex';
     424            }
     425        }
     426
     427        foreach( array( 'nodp', 'noydir' ) as $robot ) {
     428            if( Voce_Settings_API::GetInstance()->get_setting( $robot, 'vseo-general' ) ) {
     429                $robots[ 'other' ][] = $robot;
    409430            }
    410431        }
    411432
    412433        //final filter to force values
    413         $robots = apply_filters('vseo_robots', $robots);
    414         $robots = array_intersect_key($robots, $robots_defaults);
    415 
    416         if ( isset($robots['other']) && is_array($robots['other']) ) {
    417             $other = array_unique( $robots['other'] );
    418             unset( $robots['other'] );
    419             $robots = array_merge($robots, $other);
    420         }
    421 
    422         $robotsstr = implode(',', $robots );
    423 
    424         if ( $robotsstr !== '' ) {
     434        $robots = apply_filters( 'vseo_robots', $robots );
     435        $robots = array_intersect_key( $robots, $robots_defaults );
     436
     437        if( isset( $robots[ 'other' ] ) && is_array( $robots[ 'other' ] ) ) {
     438            $other = array_unique( $robots[ 'other' ] );
     439            unset( $robots[ 'other' ] );
     440            $robots = array_merge( $robots, $other );
     441        }
     442
     443        $robotsstr = implode( ',', $robots );
     444
     445        if( $robotsstr !== '' ) {
    425446            return self::create_meta_object( 'robots', 'meta', array( 'name' => 'robots', 'content' => esc_attr( $robotsstr ) ) );
    426447        } else {
     
    435456        $canonical = '';
    436457
    437         if ( isset($queried_object->post_type) ) {
    438             if ( !($canonical = self::get_seo_meta( 'canonical', get_queried_object_id() ) ) || is_null( $canonical ) ) {
     458        if( isset( $queried_object->post_type ) ) {
     459            if( ! ( $canonical = self::get_seo_meta( 'canonical', get_queried_object_id() ) ) || is_null( $canonical ) ) {
    439460                $canonical = get_permalink( $queried_object->ID );
    440461                // Fix paginated pages
    441                 if ( get_query_var( 'page' ) > 1 ) {
     462                if( get_query_var( 'page' ) > 1 ) {
    442463                    $canonical = user_trailingslashit( trailingslashit( $canonical ) . get_query_var( 'page' ) );
    443464                }
    444465            }
    445466        } else {
    446             if ( is_search() ) {
     467            if( is_search() ) {
    447468                $canonical = get_search_link();
    448             } else if ( is_front_page() ) {
    449                 $canonical = home_url( '/' );
    450             } else if ( is_home() && 'page' === get_option( 'show_on_front' ) ) {
    451                 $canonical = get_permalink( get_option( 'page_for_posts' ) );
    452             } else if ( is_tax() || is_tag() || is_category() ) {
    453                 if ( function_exists('wpcom_vip_get_term_link') ) {
    454                     $canonical = wpcom_vip_get_term_link( $queried_object, $queried_object->taxonomy );
     469            } else {
     470                if( is_front_page() ) {
     471                    $canonical = home_url( '/' );
    455472                } else {
    456                     $canonical = get_term_link( $queried_object, $queried_object->taxonomy );
    457                 }
    458             } else if ( function_exists( 'get_post_type_archive_link' ) && is_post_type_archive() ) {
    459                 $canonical = get_post_type_archive_link( get_post_type() );
    460             } else if ( is_author() ) {
    461                 $canonical = get_author_posts_url( get_query_var( 'author' ), get_query_var( 'author_name' ) );
    462             } else if ( is_archive() ) {
    463                 if ( is_date() ) {
    464                     if ( is_day() ) {
    465                         $canonical = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
    466                     } else if ( is_month() ) {
    467                         $canonical = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
    468                     } else if ( is_year() ) {
    469                         $canonical = get_year_link( get_query_var( 'year' ) );
     473                    if( is_home() && 'page' === get_option( 'show_on_front' ) ) {
     474                        $canonical = get_permalink( get_option( 'page_for_posts' ) );
     475                    } else {
     476                        if( is_tax() || is_tag() || is_category() ) {
     477                            if( function_exists( 'wpcom_vip_get_term_link' ) ) {
     478                                $canonical = wpcom_vip_get_term_link( $queried_object, $queried_object->taxonomy );
     479                            } else {
     480                                $canonical = get_term_link( $queried_object, $queried_object->taxonomy );
     481                            }
     482                        } else {
     483                            if( function_exists( 'get_post_type_archive_link' ) && is_post_type_archive() ) {
     484                                $canonical = get_post_type_archive_link( get_post_type() );
     485                            } else {
     486                                if( is_author() ) {
     487                                    $canonical = get_author_posts_url( get_query_var( 'author' ), get_query_var( 'author_name' ) );
     488                                } else {
     489                                    if( is_archive() ) {
     490                                        if( is_date() ) {
     491                                            if( is_day() ) {
     492                                                $canonical = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
     493                                            } else {
     494                                                if( is_month() ) {
     495                                                    $canonical = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
     496                                                } else {
     497                                                    if( is_year() ) {
     498                                                        $canonical = get_year_link( get_query_var( 'year' ) );
     499                                                    }
     500                                                }
     501                                            }
     502                                        }
     503                                    }
     504                                }
     505                            }
     506                        }
    470507                    }
    471508                }
    472509            }
    473510
    474             if ( $canonical && get_query_var( 'paged' ) > 1 ) {
     511            if( $canonical && get_query_var( 'paged' ) > 1 ) {
    475512                $canonical = user_trailingslashit( trailingslashit( $canonical ) . trailingslashit( $wp_rewrite->pagination_base ) . get_query_var( 'paged' ) );
    476513            }
     
    486523        $img = '';
    487524
    488         if ( isset($queried_object->post_type) ) {
    489             if(  has_post_thumbnail( get_queried_object_id() )) {
    490                 $img = wp_get_attachment_image_src(get_post_thumbnail_id( get_queried_object_id() ), apply_filters( 'vseo_image_size', 'full' ) );
    491                 if( !empty( $img[0] ) )
    492                     $img = $img[0];
    493             }
    494         }
    495 
    496         return apply_filters('vseo_meta_image', $img);
     525        if( isset( $queried_object->post_type ) ) {
     526            if( has_post_thumbnail( get_queried_object_id() ) ) {
     527                $img = wp_get_attachment_image_src( get_post_thumbnail_id( get_queried_object_id() ), apply_filters( 'vseo_image_size', 'full' ) );
     528                if( ! empty( $img[ 0 ] ) ) {
     529                    $img = $img[ 0 ];
     530                }
     531            }
     532        }
     533
     534        return apply_filters( 'vseo_meta_image', $img );
     535    }
     536
     537    private function is_singular_viewable_post_query() {
     538        $queried_object = get_queried_object();
     539        if( is_a( $queried_object, 'WP_Post' ) ) {
     540            $post_type_object = get_post_type_object( get_post_type( $queried_object ) );
     541            return $post_type_object->publicly_queryable || ( $post_type_object->_builtin && $post_type_object->public );
     542        }
     543        return false;
    497544    }
    498545}
    499 add_action('init', array('VSEO', 'init'));
     546
     547add_action( 'init', array( 'VSEO', 'init' ) );
Note: See TracChangeset for help on using the changeset viewer.