Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active August 6, 2019 17:39
Show Gist options
  • Save westonruter/4e4ee2b5790c6218fab40a7b3f90331f to your computer and use it in GitHub Desktop.
Save westonruter/4e4ee2b5790c6218fab40a7b3f90331f to your computer and use it in GitHub Desktop.
Enable landscape (desktop) support for stories that have the 'landscape' tag. Requires AMP plugin 1.2+.
<?php
/**
* Plugin Name: AMP Story Supports Landscape
*
* @package AMP_Story_Supports_Landscape
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
* Plugin Name: AMP Story Supports Landscape
* Description: Enable landscape (desktop) support for stories that have the 'landscape' tag.
* Plugin URI: https://gist.github.com/westonruter/2ea25735be279b88c6f0946629d0240c
* Version: 0.1.0
* Author: Weston Ruter, Google
* Author URI: https://weston.ruter.net/
* License: GNU General Public License v2 (or later)
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
add_filter(
'amp_story_supports_landscape',
function ( $supports, $post ) {
if ( has_tag( 'landscape', $post ) ) {
$supports = true;
}
return $supports;
},
10,
2
);
@jdelia
Copy link

jdelia commented Aug 6, 2019

Thank you. This provides a useful feature in our testing of AMP Stories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment