post_password ) {
$desc = $post->post_excerpt ? $post->post_excerpt : wp_trim_words( wp_strip_all_tags( strip_shortcodes( $post->post_content ) ), 30, '' );
}
return Aeoora_Util::trim_chars( $desc, 160 );
}
if ( is_category() || is_tag() || is_tax() ) {
return Aeoora_Util::trim_chars( term_description(), 160 );
}
if ( is_front_page() || is_home() ) {
return Aeoora_Util::trim_chars( get_bloginfo( 'description' ), 160 );
}
return '';
}
/**
* Print tags.
*/
public static function print_tags() {
$desc = self::description();
echo "\n\n";
if ( '' !== $desc ) {
printf( '' . "\n", esc_attr( $desc ) );
}
// Core prints rel=canonical only on singular pages.
if ( ( is_front_page() || is_home() ) && ! is_singular() && ! is_paged() ) {
$canonical = is_front_page() ? home_url( '/' ) : get_permalink( (int) get_option( 'page_for_posts' ) );
if ( $canonical ) {
printf( '' . "\n", esc_url( $canonical ) );
}
} elseif ( ( is_category() || is_tag() || is_tax() ) && ! is_paged() ) {
$link = get_term_link( get_queried_object() );
if ( ! is_wp_error( $link ) ) {
printf( '' . "\n", esc_url( $link ) );
}
}
if ( ! Aeoora_Settings::get( 'meta', 'og', true ) ) {
return;
}
$title = wp_get_document_title();
$url = self::current_url();
add_filter( 'jetpack_enable_open_graph', '__return_false', 99 ); // Avoid duplicate OG tags with Jetpack.
$type = is_singular( 'post' ) ? 'article' : 'website';
$image = '';
if ( is_singular() && has_post_thumbnail() ) {
$image = get_the_post_thumbnail_url( null, 'large' );
}
if ( ! $image ) {
$image = get_site_icon_url( 512 );
}
$tags = array(
'og:type' => $type,
'og:title' => $title,
'og:description' => $desc,
'og:url' => $url,
'og:site_name' => get_bloginfo( 'name' ),
'og:locale' => get_locale(),
'og:image' => $image,
);
foreach ( $tags as $prop => $val ) {
if ( '' !== (string) $val ) {
printf( '' . "\n", esc_attr( $prop ), esc_attr( $val ) );
}
}
if ( is_singular( 'post' ) ) {
printf( '' . "\n", esc_attr( get_post_time( 'c', true ) ) );
printf( '' . "\n", esc_attr( get_post_modified_time( 'c', true ) ) );
}
printf( '' . "\n", $image ? 'summary_large_image' : 'summary' );
printf( '' . "\n", esc_attr( $title ) );
if ( '' !== $desc ) {
printf( '' . "\n", esc_attr( $desc ) );
}
}
}