Changeset 1344309
- Timestamp:
- 02/05/2016 09:39:31 PM (10 years ago)
- Location:
- voce-seo/trunk
- Files:
-
- 1 added
- 7 edited
-
admin/admin.php (modified) (11 diffs)
-
readme.txt (modified) (2 diffs)
-
vendor/autoload.php (modified) (1 diff)
-
vendor/composer/ClassLoader.php (modified) (7 diffs)
-
vendor/composer/LICENSE (added)
-
vendor/composer/autoload_files.php (modified) (1 diff)
-
vendor/composer/autoload_real.php (modified) (4 diffs)
-
voce-seo.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
voce-seo/trunk/admin/admin.php
r1181889 r1344309 4 4 5 5 public static function init() { 6 require_once( __DIR__ . '/field-callbacks.php');6 require_once( __DIR__ . '/field-callbacks.php' ); 7 7 VSEO_Metabox::init(); 8 8 VSEO_Taxonomy::init(); … … 14 14 15 15 public static function init() { 16 add_action( 'add_meta_boxes', function ($post_type) {16 add_action( 'add_meta_boxes', function ( $post_type ) { 17 17 $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' ) { 19 19 add_meta_box( 'vseo_meta', 'SEO Settings', array( 'VSEO_Metabox', 'meta_box' ), $post_type, 'advanced' ); 20 20 } … … 32 32 <ul class="vseo-metabox-tabs" id="vseo-metabox-tabs"> 33 33 <?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' ] ) ); 36 36 } 37 37 ?> 38 38 </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 ): ?> 42 42 <p> 43 <label><?php echo esc_html( $field[ 'title'] ); ?></label>43 <label><?php echo esc_html( $field[ 'title' ] ); ?></label> 44 44 <?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() ) 49 49 ); 50 50 ?> … … 59 59 60 60 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 ) ) { 62 62 return $post_id; 63 63 } 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' ) ) { 65 65 $post_type = get_post_type( $post_id ); 66 66 $tabs = self::get_metabox_tabs( $post_type ); 67 67 $vseo_meta = ( array ) get_post_meta( $post_id, 'vseo_meta', true ); 68 68 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 ) ); 76 76 } 77 77 } … … 83 83 private static function get_metabox_tabs( $post_type ) { 84 84 $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 ) 94 94 ); 95 95 return apply_filters( 'vseo_metabox_tabs', $metabox_tabs, $post_type ); … … 98 98 private static function get_metabox_fields( $tab, $post_type ) { 99 99 $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 ), 188 196 ); 189 197 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 ); 201 209 } 202 210 … … 209 217 public static function init() { 210 218 $taxonomies = get_taxonomies( '', 'names' ); 211 foreach ( $taxonomies as $taxonomy ) {219 foreach( $taxonomies as $taxonomy ) { 212 220 add_action( $taxonomy . '_add_form_fields', array( __CLASS__, 'add_new_meta_field' ), 10, 1 ); 213 221 add_action( $taxonomy . '_edit_form_fields', array( __CLASS__, 'edit_meta_field' ), 10, 2 ); … … 235 243 ?> 236 244 <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> 238 247 <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' ] ) : ''; ?>"> 240 250 </td> 241 251 </tr> … … 246 256 247 257 public static function save_meta( $term_id ) { 248 if (249 isset( $_POST[ 'term_meta'] ) &&258 if( 259 isset( $_POST[ 'term_meta' ] ) && 250 260 check_admin_referer( 'voce_seo_term', 'voce_seo_term' ) 251 261 ) { 252 262 $_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' ]; 254 264 255 265 $term_meta = get_option( self::$option_key ); 256 $cat_keys = array_keys( $_POST[ 'term_meta'] );266 $cat_keys = array_keys( $_POST[ 'term_meta' ] ); 257 267 $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 ] ); 261 271 } 262 272 } … … 268 278 /** 269 279 * Handling the splitting of terms with WordPress 4.2 280 * 270 281 * @param type $old_term_id 271 282 * @param type $new_term_id … … 276 287 $vseo_term_meta = get_option( self::$option_key ); 277 288 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 ] ); 281 292 update_option( self::$option_key, $vseo_term_meta ); 282 293 } -
voce-seo/trunk/readme.txt
r1181889 r1344309 3 3 Tags: SEO 4 4 Requires at least: 3.7.0 5 Tested up to: 4.2. 26 Stable tag: 0. 5.25 Tested up to: 4.2.4 6 Stable tag: 0.6.0 7 7 License: GPLv2 or later 8 8 … … 32 32 33 33 == 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 34 44 = Version 0.5.2 = 35 45 * Strict comparisons -
voce-seo/trunk/vendor/autoload.php
r1181889 r1344309 5 5 require_once __DIR__ . '/composer' . '/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit3 af71242fe1b43686624cc1ff7b8eccd::getLoader();7 return ComposerAutoloaderInit37665239d184aaad487429639b869c4c::getLoader(); -
voce-seo/trunk/vendor/composer/ClassLoader.php
r1179656 r1344309 14 14 15 15 /** 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. 19 17 * 20 18 * $loader = new \Composer\Autoload\ClassLoader(); … … 40 38 * @author Fabien Potencier <fabien@symfony.com> 41 39 * @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/ 42 42 */ 43 43 class ClassLoader … … 148 148 * 149 149 * @param string $prefix The prefix/namespace, with trailing '\\' 150 * @param array|string $paths The PSR- 0base directories150 * @param array|string $paths The PSR-4 base directories 151 151 * @param bool $prepend Whether to prepend the directories 152 152 * … … 352 352 if (0 === strpos($class, $prefix)) { 353 353 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))) { 355 355 return $file; 356 356 } … … 362 362 // PSR-4 fallback dirs 363 363 foreach ($this->fallbackDirsPsr4 as $dir) { 364 if ( is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {364 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { 365 365 return $file; 366 366 } … … 381 381 if (0 === strpos($class, $prefix)) { 382 382 foreach ($dirs as $dir) { 383 if ( is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {383 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 384 384 return $file; 385 385 } … … 391 391 // PSR-0 fallback dirs 392 392 foreach ($this->fallbackDirsPsr0 as $dir) { 393 if ( is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {393 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 394 394 return $file; 395 395 } -
voce-seo/trunk/vendor/composer/autoload_files.php
r839041 r1344309 7 7 8 8 return array( 9 $vendorDir . '/voceconnect/voce-settings-api/voce-settings-api.php',9 'aecffab7c5c91b3ba12381df2fefa2ed' => $vendorDir . '/voceconnect/voce-settings-api/voce-settings-api.php', 10 10 ); -
voce-seo/trunk/vendor/composer/autoload_real.php
r1181889 r1344309 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit3 af71242fe1b43686624cc1ff7b8eccd5 class ComposerAutoloaderInit37665239d184aaad487429639b869c4c 6 6 { 7 7 private static $loader; … … 20 20 } 21 21 22 spl_autoload_register(array('ComposerAutoloaderInit3 af71242fe1b43686624cc1ff7b8eccd', 'loadClassLoader'), true, true);22 spl_autoload_register(array('ComposerAutoloaderInit37665239d184aaad487429639b869c4c', 'loadClassLoader'), true, true); 23 23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 24 spl_autoload_unregister(array('ComposerAutoloaderInit3 af71242fe1b43686624cc1ff7b8eccd', 'loadClassLoader'));24 spl_autoload_unregister(array('ComposerAutoloaderInit37665239d184aaad487429639b869c4c', 'loadClassLoader')); 25 25 26 26 $map = require __DIR__ . '/autoload_namespaces.php'; … … 42 42 43 43 $includeFiles = require __DIR__ . '/autoload_files.php'; 44 foreach ($includeFiles as $file ) {45 composerRequire3 af71242fe1b43686624cc1ff7b8eccd($file);44 foreach ($includeFiles as $fileIdentifier => $file) { 45 composerRequire37665239d184aaad487429639b869c4c($fileIdentifier, $file); 46 46 } 47 47 … … 50 50 } 51 51 52 function composerRequire3 af71242fe1b43686624cc1ff7b8eccd($file)52 function composerRequire37665239d184aaad487429639b869c4c($fileIdentifier, $file) 53 53 { 54 require $file; 54 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { 55 require $file; 56 57 $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; 58 } 55 59 } -
voce-seo/trunk/voce-seo.php
r1181889 r1344309 1 1 <?php 2 2 3 /* 3 4 Plugin Name: Voce SEO 4 Version: 0. 5.25 Version: 0.6.0 5 6 Plugin URI: http://voceconnect.com/ 6 7 Description: An SEO plugin taking things from both WP SEO and All in One SEO but leaving out the VIP incompatible pieces. … … 15 16 public static function init() { 16 17 17 @include( dirname( __FILE__) . '/vendor/autoload.php' );18 @include( dirname( __FILE__ ) . '/vendor/autoload.php' ); 18 19 19 20 self::upgrade_check(); 20 21 21 if( is_admin() ) {22 require_once (__DIR__ . '/admin/admin.php');22 if( is_admin() ) { 23 require_once( __DIR__ . '/admin/admin.php' ); 23 24 VSEO_Admin::init(); 24 25 } 25 26 26 27 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( 30 31 'display_callback' => 'vs_display_checkbox', 31 'sanitize_callbacks' => array( 'vs_sanitize_checkbox'),32 'sanitize_callbacks' => array( 'vs_sanitize_checkbox' ), 32 33 'description' => 'Prevents search engines from using the DMOZ description for pages from this site in the search results.' 33 ))->group34 ->add_setting('Add noydir', 'noydir', array(34 ) )->group 35 ->add_setting( 'Add noydir', 'noydir', array( 35 36 'display_callback' => 'vs_display_checkbox', 36 'sanitize_callbacks' => array( 'vs_sanitize_checkbox'),37 'sanitize_callbacks' => array( 'vs_sanitize_checkbox' ), 37 38 'description' => 'Prevents search engines from using the Yahoo! directory description for pages from this site in the search results.' 38 ));39 ) ); 39 40 40 41 remove_action( 'wp_head', 'rel_canonical' ); 41 42 42 43 //add namespaces 43 add_filter( 'language_attributes', function ($output ) {44 $prefixes = array(44 add_filter( 'language_attributes', function ( $output ) { 45 $prefixes = array( 45 46 'og' => 'http://ogp.me/ns#', 46 47 'fb' => 'http://ogp.me/ns/fb#', 47 48 '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' ) ); 68 69 } 69 70 70 71 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(); 74 75 $queried_post_type = get_post_type_object( get_post_type( $queried_object ) ); 75 76 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(); 84 80 $vseo_meta = (array) get_post_meta( $post_id, 'vseo_meta', true ); 85 81 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 ) ) { 97 93 $title = $new_title; 98 94 99 if ( !empty( $title ) )95 if( ! empty( $title ) ) { 100 96 $prefix = " $sep "; 97 } 101 98 102 99 // Determines position of the separator and direction of the breadcrumb 103 if ( 'right' === $seplocation ) { // sep on right, so reverse the order100 if( 'right' === $seplocation ) { // sep on right, so reverse the order 104 101 $title_array = explode( $t_sep, $title ); 105 102 $title_array = array_reverse( $title_array ); … … 114 111 } 115 112 116 private static function get_term_seo_title() {113 private static function get_term_seo_title() { 117 114 $queried_object = get_queried_object(); 118 115 $term_id = $queried_object->term_id; … … 120 117 $option_key = $taxonomy . '_' . $term_id; 121 118 $term_meta = get_option( 'vseo_term_meta' ); 122 if ( ! isset( $term_meta[ $option_key ]['title'] ) ) {119 if( ! isset( $term_meta[ $option_key ][ 'title' ] ) ) { 123 120 return; 124 121 } 125 $seo_title = $term_meta[ $option_key ][ 'title'];122 $seo_title = $term_meta[ $option_key ][ 'title' ]; 126 123 $title_filter = 'single_cat_title'; 127 if ( is_tax() ){124 if( is_tax() ) { 128 125 $title_filter = 'single_term_filter'; 129 126 } elseif( is_tag() ) { … … 135 132 136 133 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' ) ) { 144 141 $term_meta = $updated_term_meta = get_option( 'vseo_term_meta' ); 145 if ( is_array( $term_meta ) ) {142 if( is_array( $term_meta ) ) { 146 143 foreach( $term_meta as $taxonomy_term => $term_data ) { 147 144 $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 ); 150 147 $taxonomy = implode( '_', $tax_term_arr ); 151 148 $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; 155 152 } 156 153 } … … 160 157 } 161 158 162 update_option( 'VSEO_Version', self::DB_VERSION);159 update_option( 'VSEO_Version', self::DB_VERSION ); 163 160 } 164 161 … … 171 168 $meta_objects = self::create_meta_object( 'og:locale', 'meta', array( 'property' => 'og:locale', 'content' => 'en_us' ), $meta_objects ); 172 169 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() ) { 176 173 $og_description = self::get_seo_meta( 'og_description', get_queried_object_id() ); 177 if ( ! $og_description ) {174 if( ! $og_description ) { 178 175 $og_description = $description; 179 176 } 180 if ( $og_description ) {177 if( $og_description ) { 181 178 $meta_objects = self::create_meta_object( 'og:description', 'meta', array( 'property' => 'og:description', 'content' => esc_attr( $og_description ) ), $meta_objects ); 182 179 } … … 197 194 } 198 195 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() ) ) { 202 199 $twitter_description = self::get_seo_meta( 'twitter_description', get_queried_object_id() ); 203 if ( ! $twitter_description )200 if( ! $twitter_description ) { 204 201 $twitter_description = $description; 202 } 205 203 $meta_objects = self::create_meta_object( 'twitter:description', 'meta', array( 'name' => 'twitter:description', 'content' => esc_attr( $twitter_description ) ), $meta_objects ); 206 204 } … … 218 216 219 217 private static function create_meta_object( $key, $type, $attributes = array(), $meta_objects = array() ) { 220 $meta_objects[ $key] = array(221 'type'=> $type,222 'attributes' => $attributes218 $meta_objects[ $key ] = array( 219 'type' => $type, 220 'attributes' => $attributes 223 221 ); 224 222 … … 229 227 $html = ''; 230 228 $allowed_tags = array( 231 'meta' => array(232 'charset' => true,233 'content' => true,234 'http-equiv' => true,235 'name' => true,236 'property' => true237 ),238 'link' => array(239 'href' => true,240 'rel' => true,241 'media' => true,242 'hreflang' => true,243 'type' => true,244 'sizes' => true245 ),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 ), 246 244 ); 247 245 248 246 foreach( $meta_objects as $meta_object => $properties ) { 249 247 $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 ) ) { 254 252 255 253 foreach( $attributes as $att => $value ) { … … 281 279 } 282 280 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 ) ) { 284 286 $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 ) ) { 287 290 $meta_objects = self::generate_twitter_seo_data( $meta_objects ); 291 } 288 292 289 293 $meta_objects = apply_filters( 'vseo_meta_objects', $meta_objects ); … … 298 302 public static function get_social_title( $meta_key ) { 299 303 $title = ''; 300 if ( is_home() || is_front_page() ) {304 if( is_home() || is_front_page() ) { 301 305 $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();319 306 } 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 } 321 331 } 322 332 … … 324 334 } 325 335 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; 332 344 } 333 345 334 346 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 ) { 336 348 return ''; 349 } 337 350 338 351 $description = ''; … … 340 353 $queried_object = get_queried_object(); 341 354 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() ) ) ) { 344 357 //get description from excerpt/content 345 $description = empty( $queried_object->post_excerpt) ? $queried_object->post_content : $queried_object->post_excerpt;346 $description = str_replace( ']]>', ']]>', $description);358 $description = empty( $queried_object->post_excerpt ) ? $queried_object->post_content : $queried_object->post_excerpt; 359 $description = str_replace( ']]>', ']]>', $description ); 347 360 $description = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $description ); 348 $description = strip_tags( $description);361 $description = strip_tags( $description ); 349 362 $max = 250; 350 if ($max < strlen($description)) {351 while( $description[$max] !== ' ' && $max > 40) {363 if( $max < strlen( $description ) ) { 364 while( $description[ $max ] !== ' ' && $max > 40 ) { 352 365 $max--; 353 366 } 354 367 } 355 $description = substr( $description, 0, $max);356 $description = trim( stripcslashes($description));368 $description = substr( $description, 0, $max ); 369 $description = trim( stripcslashes( $description ) ); 357 370 358 371 $description = preg_replace( "/\s\s+/u", " ", $description ); 359 372 } 360 373 } 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 = ''; 369 382 } else { 370 $description = get_bloginfo( 'description', 'display' );383 $description = get_bloginfo( 'description', 'display' ); 371 384 } 372 385 } … … 375 388 376 389 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 ) ); 377 398 } 378 399 … … 383 404 384 405 $robots_defaults = array( 385 'index'=> 'index',386 'follow' => 'follow',387 'other' => array(),406 'index' => 'index', 407 'follow' => 'follow', 408 'other' => array(), 388 409 ); 389 410 390 411 //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; 399 420 } 400 421 } 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; 409 430 } 410 431 } 411 432 412 433 //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 !== '' ) { 425 446 return self::create_meta_object( 'robots', 'meta', array( 'name' => 'robots', 'content' => esc_attr( $robotsstr ) ) ); 426 447 } else { … … 435 456 $canonical = ''; 436 457 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 ) ) { 439 460 $canonical = get_permalink( $queried_object->ID ); 440 461 // Fix paginated pages 441 if ( get_query_var( 'page' ) > 1 ) {462 if( get_query_var( 'page' ) > 1 ) { 442 463 $canonical = user_trailingslashit( trailingslashit( $canonical ) . get_query_var( 'page' ) ); 443 464 } 444 465 } 445 466 } else { 446 if ( is_search() ) {467 if( is_search() ) { 447 468 $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( '/' ); 455 472 } 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 } 470 507 } 471 508 } 472 509 } 473 510 474 if ( $canonical && get_query_var( 'paged' ) > 1 ) {511 if( $canonical && get_query_var( 'paged' ) > 1 ) { 475 512 $canonical = user_trailingslashit( trailingslashit( $canonical ) . trailingslashit( $wp_rewrite->pagination_base ) . get_query_var( 'paged' ) ); 476 513 } … … 486 523 $img = ''; 487 524 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; 497 544 } 498 545 } 499 add_action('init', array('VSEO', 'init')); 546 547 add_action( 'init', array( 'VSEO', 'init' ) );
Note: See TracChangeset
for help on using the changeset viewer.