Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ function( $callable ) {
* They check for external files or plugins, so they need to run as late as possible.
*/
add_action( 'wp_head', array( $this, 'check_open_graph' ), 1 );
add_action( 'amp_story_head', array( $this, 'check_open_graph' ), 1 );
add_action( 'plugins_loaded', array( $this, 'check_twitter_tags' ), 999 );
add_action( 'plugins_loaded', array( $this, 'check_rest_api_compat' ), 1000 );

Expand Down
16 changes: 13 additions & 3 deletions functions.opengraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

add_action( 'wp_head', 'jetpack_og_tags' );
add_action( 'amp_story_head', 'jetpack_og_tags' );

/**
* Outputs Open Graph tags generated by Jetpack.
Expand All @@ -32,11 +33,16 @@ function jetpack_og_tags() {
return;
}

$is_amp_response = ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() );

// Disable the widont filter on WP.com to avoid stray &nbsps.
$disable_widont = remove_filter( 'the_title', 'widont' );

$og_output = "\n<!-- Jetpack Open Graph Tags -->\n";
$tags = array();
$og_output = "\n";
if ( ! $is_amp_response ) { // Because AMP optimizes the order or the nodes in the head.
$og_output .= "<!-- Jetpack Open Graph Tags -->\n";
}
$tags = array();

/**
* Filter the minimum width of the images used in Jetpack Open Graph Meta Tags.
Expand Down Expand Up @@ -287,7 +293,11 @@ function jetpack_og_tags() {
}
}
}
$og_output .= "\n<!-- End Jetpack Open Graph Tags -->\n";

if ( ! $is_amp_response ) { // Because AMP optimizes the order or the nodes in the head.
$og_output .= "\n<!-- End Jetpack Open Graph Tags -->";
}
$og_output .= "\n";
// This is trusted output or added by a filter.
echo $og_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
Expand Down