-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-use existing classes; update analytics to use same validation method
- Loading branch information
1 parent
5b0e1cd
commit 1befc79
Showing
18 changed files
with
1,109 additions
and
661 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SYNC_README_MD=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* AMP Post type support. | ||
* | ||
* @package AMP | ||
* @since 0.6 | ||
*/ | ||
|
||
/** | ||
* Class AMP_Post_Type_Support. | ||
*/ | ||
class AMP_Post_Type_Support { | ||
|
||
/** | ||
* Add hooks. | ||
*/ | ||
public static function add_hooks() { | ||
add_action( 'amp_init', array( __CLASS__, 'add_builtin_post_type_support' ) ); | ||
add_action( 'after_setup_theme', array( __CLASS__, 'add_elected_post_type_support' ), 5 ); | ||
} | ||
|
||
/** | ||
* Get post types that plugin supports out of the box (which cannot be disabled). | ||
* | ||
* @return array Post types. | ||
*/ | ||
public static function get_builtin_supported_post_types() { | ||
return array( 'post' ); | ||
} | ||
|
||
/** | ||
* Declare core post types support for built-in post types. | ||
* | ||
* @since 0.6 | ||
*/ | ||
public static function add_builtin_post_type_support() { | ||
foreach ( self::get_builtin_supported_post_types() as $post_type ) { | ||
add_post_type_support( $post_type, AMP_QUERY_VAR ); | ||
} | ||
} | ||
|
||
/** | ||
* Declare custom post types support. | ||
* | ||
* This function should only be invoked through the 'after_setup_theme' action to | ||
* allow plugins/theme to overwrite the post types support. | ||
* | ||
* @since 0.6 | ||
*/ | ||
public static function add_elected_post_type_support() { | ||
$post_types = array_merge( | ||
array_keys( array_filter( AMP_Options_Manager::get_option( 'supported_post_types', array() ) ) ), | ||
self::get_builtin_supported_post_types() | ||
); | ||
foreach ( $post_types as $post_type ) { | ||
add_post_type_support( $post_type, AMP_QUERY_VAR ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.