-
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.
Merge branch 'develop' of https://github.com/Automattic/amp-wp into f…
…eature/709-block-amp-per-page
- Loading branch information
Showing
19 changed files
with
887 additions
and
148 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 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 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,66 @@ | ||
<?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 init() { | ||
add_action( 'after_setup_theme', array( __CLASS__, 'add_post_type_support' ), 5 ); | ||
} | ||
|
||
/** | ||
* Get post types that plugin supports out of the box (which cannot be disabled). | ||
* | ||
* @return string[] Post types. | ||
*/ | ||
public static function get_builtin_supported_post_types() { | ||
return array_filter( array( 'post' ), 'post_type_exists' ); | ||
} | ||
|
||
/** | ||
* Get post types that are eligible for AMP support. | ||
* | ||
* @since 0.6 | ||
* @return string[] Post types eligible for AMP. | ||
*/ | ||
public static function get_eligible_post_types() { | ||
return array_merge( | ||
self::get_builtin_supported_post_types(), | ||
array_values( get_post_types( | ||
array( | ||
'public' => true, | ||
'_builtin' => false, | ||
), | ||
'names' | ||
) ) | ||
); | ||
} | ||
|
||
/** | ||
* Declare support for post types. | ||
* | ||
* 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_post_type_support() { | ||
$post_types = array_merge( | ||
self::get_builtin_supported_post_types(), | ||
AMP_Options_Manager::get_option( 'supported_post_types', array() ) | ||
); | ||
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
Oops, something went wrong.