Skip to content

Commit

Permalink
Moved AMP_QUERY_VAR definition to amp_init and filtered it.
Browse files Browse the repository at this point in the history
Checking if the constant is defined might not be enought for some environments, where the plugins are loaded much earlier than the theme.
Using a filter when defining the constant allows to change the value on the theme.
  • Loading branch information
vaurdan committed Feb 23, 2016
1 parent 9777ad0 commit c486a1c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
* License: GPLv2 or later
*/

// Let users define their own feed slug
if ( ! defined( 'AMP_QUERY_VAR' ) ) {
define( 'AMP_QUERY_VAR', 'amp' );
}

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );

Expand All @@ -38,6 +33,8 @@ function amp_init() {
return;
}

define( 'AMP_QUERY_VAR', apply_filters('amp_query_var', 'amp' ) );

do_action( 'amp_init' );

load_plugin_textdomain( 'amp', false, plugin_basename( AMP__DIR__ ) . '/languages' );
Expand Down

0 comments on commit c486a1c

Please sign in to comment.