Skip to content

Commit

Permalink
Issue #864: Only add AMP widget support if is_amp_endpoint().
Browse files Browse the repository at this point in the history
I had tried to wrap the action hook in this conditional:
add_action( 'init', 'amp_add_widget_support' )
But this produced this notice:
is_amp_endpoint was called <strong>incorrectly</strong>.
 is_amp_endpoint() was called before the &#39;parse_query&#39; hook was called.
  • Loading branch information
Ryan Kienstra committed Jan 22, 2018
1 parent 99dd862 commit 74d727b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions includes/admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ function amp_add_custom_analytics( $analytics ) {
* @since 0.7
*/
function amp_add_widget_support() {
$amp_widgets = new AMP_Widgets();
$amp_widgets->init();
if ( is_amp_endpoint() ) {
$amp_widgets = new AMP_Widgets();
$amp_widgets->init();
}
}

/**
Expand Down

0 comments on commit 74d727b

Please sign in to comment.