Ticket #1229: improved.diff
| File improved.diff, 2.1 KB (added by misterbisson, 3 years ago) |
|---|
-
opengraph.php
82 82 */ 83 83 function opengraph_default_title( $title ) { 84 84 if ( is_singular() && empty($title) ) { 85 global $ post;86 $title = $ post->post_title;85 global $wp_query; 86 $title = $wp_query->queried_object->post_title; 87 87 } 88 88 89 89 return $title; … … 103 103 * Default image property, using the post-thumbnail. 104 104 */ 105 105 function opengraph_default_image( $image ) { 106 global $ post;107 if ( is_singular() && empty($image) && has_post_thumbnail($post->ID) ) {108 $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $ post->ID), 'post-thumbnail');106 global $wp_query; 107 if ( is_singular() && empty($image) && current_theme_supports('post-thumbnails') && has_post_thumbnail($wp_query->queried_object_id) ) { 108 $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $wp_query->queried_object_id ), 'post-thumbnail'); 109 109 if ($thumbnail) { 110 110 $image = $thumbnail[0]; 111 111 } … … 119 119 * Default url property, using the permalink for the page. 120 120 */ 121 121 function opengraph_default_url( $url ) { 122 if ( empty($url) ) $url = get_permalink(); 122 if ( ! empty( $url )) return $url; 123 124 if ( is_singular() ) { 125 global $wp_query; 126 $url = get_permalink($wp_query->queried_object_id); 127 }else{ 128 $url = trailingslashit( get_bloginfo('url' )); 129 } 130 123 131 return $url; 124 132 } 125 133 … … 137 145 * Default description property, using the bloginfo description. 138 146 */ 139 147 function opengraph_default_description( $description ) { 140 if ( empty($description) ) $description = get_bloginfo('description'); 141 return $description; 148 if ( !empty($description) ) return $description; 149 150 // get blog description as default 151 $description = get_bloginfo('description'); 152 153 // replace the description with a more specific one if available 154 global $wp_query; 155 if ( is_singular() && ! empty($wp_query->queried_object->post_excerpt) ) 156 $description = $wp_query->queried_object->post_excerpt; 157 158 return $description; 142 159 } 143 160 144 161
