Skip to content

Commit

Permalink
Issue 848 : Change 'AMP Settings' page with canonical AMP.
Browse files Browse the repository at this point in the history
If the theme registers support for canonical AMP,
Check all of the post types in the 'AMP Settings' page.
And disable their <input>, as the theme will render the post types.
Also, change the description at the bottom.
And don't output the 'submit' button in canonical mode.
  • Loading branch information
Ryan Kienstra committed Jan 10, 2018
1 parent a1112c9 commit 4a1f621
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions includes/options/class-amp-options-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function render_post_types_support() {
<?php foreach ( array_map( 'get_post_type_object', AMP_Post_Type_Support::get_eligible_post_types() ) as $post_type ) : ?>
<?php
$element_id = AMP_Options_Manager::OPTION_NAME . "-supported_post_types-{$post_type->name}";
$is_builtin = in_array( $post_type->name, $builtin_support, true );
$is_builtin = amp_is_canonical() || in_array( $post_type->name, $builtin_support, true );
?>
<?php if ( $is_builtin ) : ?>
<input type="hidden" name="<?php echo esc_attr( $element_name ); ?>" value="<?php echo esc_attr( $post_type->name ); ?>">
Expand All @@ -94,15 +94,23 @@ public function render_post_types_support() {
id="<?php echo esc_attr( $element_id ); ?>"
name="<?php echo esc_attr( $element_name ); ?>"
value="<?php echo esc_attr( $post_type->name ); ?>"
<?php checked( true, post_type_supports( $post_type->name, AMP_QUERY_VAR ) ); ?>
<?php checked( true, amp_is_canonical() || post_type_supports( $post_type->name, AMP_QUERY_VAR ) ); ?>
<?php disabled( $is_builtin ); ?>
>
<label for="<?php echo esc_attr( $element_id ); ?>">
<?php echo esc_html( $post_type->label ); ?>
</label>
<br>
<?php endforeach; ?>
<p class="description"><?php esc_html_e( 'Enable/disable AMP post type(s) support', 'amp' ); ?></p>
<p class="description">
<?php
if ( ! amp_is_canonical() ) :
esc_html_e( 'Enable/disable AMP post type(s) support', 'amp' );
else :
esc_html_e( 'Canonical AMP is enabled in your theme, so all post types will render.', 'amp' );
endif;
?>
</p>
</fieldset>
<?php
}
Expand All @@ -124,7 +132,9 @@ public function render_screen() {
<?php
settings_fields( AMP_Options_Manager::OPTION_NAME );
do_settings_sections( AMP_Options_Manager::OPTION_NAME );
submit_button();
if ( ! amp_is_canonical() ) {
submit_button();
}
?>
</form>
</div>
Expand Down

0 comments on commit 4a1f621

Please sign in to comment.