AMP for WordPress - Version 0.6.2

Version Description

(2018-02-12) =

  • Reduce frequency of flushing rewrite rules and harden, use escaped translation functions, and make minor changes to improve logic/style. See #953. Props philipjohn, westonruter.
  • Fix AMP preview icon in Firefox. See #920. Props zigasancin.
Download this release

Release Info

Developer westonruter
Plugin Icon 128x128 AMP for WordPress
Version 0.6.2
Comparing to
See all releases

Code changes from version 0.6.1 to 0.6.2

amp.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin URI: https://github.com/automattic/amp-wp
6
  * Author: Automattic
7
  * Author URI: https://automattic.com
8
- * Version: 0.6.1
9
  * Text Domain: amp
10
  * Domain Path: /languages/
11
  * License: GPLv2 or later
@@ -15,7 +15,7 @@
15
 
16
  define( 'AMP__FILE__', __FILE__ );
17
  define( 'AMP__DIR__', dirname( __FILE__ ) );
18
- define( 'AMP__VERSION', '0.6.1' );
19
 
20
  require_once AMP__DIR__ . '/includes/class-amp-autoloader.php';
21
  AMP_Autoloader::register();
5
  * Plugin URI: https://github.com/automattic/amp-wp
6
  * Author: Automattic
7
  * Author URI: https://automattic.com
8
+ * Version: 0.6.2
9
  * Text Domain: amp
10
  * Domain Path: /languages/
11
  * License: GPLv2 or later
15
 
16
  define( 'AMP__FILE__', __FILE__ );
17
  define( 'AMP__DIR__', dirname( __FILE__ ) );
18
+ define( 'AMP__VERSION', '0.6.2' );
19
 
20
  require_once AMP__DIR__ . '/includes/class-amp-autoloader.php';
21
  AMP_Autoloader::register();
assets/css/amp-post-meta-box.css CHANGED
@@ -16,16 +16,21 @@
16
  border-top-left-radius: 0;
17
  border-bottom-left-radius: 0;
18
  text-indent: -9999px;
19
- padding-right: 7px;
20
- padding-left: 7px;
 
21
  }
22
 
23
  .wp-core-ui #amp-post-preview.preview::after {
24
  content: "icon";
25
- width: 14px;
26
- float: left;
27
  background: no-repeat center url( '../images/amp-icon.svg' );
28
  background-size: 14px !important;
 
 
 
 
 
 
29
  }
30
 
31
  .wp-core-ui #amp-post-preview.preview.disabled::after {
16
  border-top-left-radius: 0;
17
  border-bottom-left-radius: 0;
18
  text-indent: -9999px;
19
+ padding-right: 14px;
20
+ padding-left: 14px;
21
+ position: relative;
22
  }
23
 
24
  .wp-core-ui #amp-post-preview.preview::after {
25
  content: "icon";
 
 
26
  background: no-repeat center url( '../images/amp-icon.svg' );
27
  background-size: 14px !important;
28
+ top: 0;
29
+ right: 0;
30
+ bottom: 0;
31
+ left: 0;
32
+ display: block;
33
+ position: absolute;
34
  }
35
 
36
  .wp-core-ui #amp-post-preview.preview.disabled::after {
includes/options/class-amp-options-manager.php CHANGED
@@ -30,7 +30,25 @@ class AMP_Options_Manager {
30
  )
31
  );
32
 
33
- add_action( 'update_option_' . self::OPTION_NAME, 'flush_rewrite_rules' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
  /**
30
  )
31
  );
32
 
33
+ add_action( 'update_option_' . self::OPTION_NAME, array( __CLASS__, 'maybe_flush_rewrite_rules' ), 10, 2 );
34
+ }
35
+
36
+ /**
37
+ * Flush rewrite rules if the supported_post_types have changed.
38
+ *
39
+ * @since 0.6.2
40
+ *
41
+ * @param array $old_options Old options.
42
+ * @param array $new_options New options.
43
+ */
44
+ public static function maybe_flush_rewrite_rules( $old_options, $new_options ) {
45
+ $old_post_types = isset( $old_options['supported_post_types'] ) ? $old_options['supported_post_types'] : array();
46
+ $new_post_types = isset( $new_options['supported_post_types'] ) ? $new_options['supported_post_types'] : array();
47
+ sort( $old_post_types );
48
+ sort( $new_post_types );
49
+ if ( $old_post_types !== $new_post_types ) {
50
+ flush_rewrite_rules();
51
+ }
52
  }
53
 
54
  /**
includes/options/views/class-amp-analytics-options-submenu-page.php CHANGED
@@ -10,18 +10,23 @@
10
  */
11
  class AMP_Analytics_Options_Submenu_Page {
12
 
 
 
 
 
 
 
 
13
  private function render_entry( $id = '', $type = '', $config = '' ) {
14
  $is_existing_entry = ! empty( $id );
15
 
16
  if ( $is_existing_entry ) {
17
- $entry_slug = sprintf( '%s%s', ( $type ? $type . '-' : '' ), substr( $id, -6 ) );
 
18
  $analytics_title = sprintf( __( 'Analytics: %s', 'amp' ), $entry_slug );
19
  } else {
20
  $analytics_title = __( 'Add new entry:', 'amp' );
21
- }
22
-
23
- if ( ! $is_existing_entry ) {
24
- $id = '__new__';
25
  }
26
 
27
  $id_base = sprintf( '%s[analytics][%s]', AMP_Options_Manager::OPTION_NAME, $id );
@@ -55,9 +60,9 @@ class AMP_Analytics_Options_Submenu_Page {
55
  <p>
56
  <?php
57
  wp_nonce_field( 'analytics-options', 'analytics-options' );
58
- submit_button( __( 'Save', 'amp' ), 'primary', 'save', false );
59
  if ( $is_existing_entry ) {
60
- submit_button( __( 'Delete', 'amp' ), 'delete button-primary', $id_base . '[delete]', false );
61
  }
62
  ?>
63
  </p>
@@ -78,6 +83,9 @@ class AMP_Analytics_Options_Submenu_Page {
78
  <?php
79
  }
80
 
 
 
 
81
  public function render() {
82
  $analytics_entries = AMP_Options_Manager::get_option( 'analytics', array() );
83
 
10
  */
11
  class AMP_Analytics_Options_Submenu_Page {
12
 
13
+ /**
14
+ * Render entry.
15
+ *
16
+ * @param string $id Entry ID.
17
+ * @param string $type Entry type.
18
+ * @param string $config Entry config as serialized JSON.
19
+ */
20
  private function render_entry( $id = '', $type = '', $config = '' ) {
21
  $is_existing_entry = ! empty( $id );
22
 
23
  if ( $is_existing_entry ) {
24
+ $entry_slug = sprintf( '%s%s', ( $type ? $type . '-' : '' ), substr( $id, - 6 ) );
25
+ /* translators: %s is the entry slug */
26
  $analytics_title = sprintf( __( 'Analytics: %s', 'amp' ), $entry_slug );
27
  } else {
28
  $analytics_title = __( 'Add new entry:', 'amp' );
29
+ $id = '__new__';
 
 
 
30
  }
31
 
32
  $id_base = sprintf( '%s[analytics][%s]', AMP_Options_Manager::OPTION_NAME, $id );
60
  <p>
61
  <?php
62
  wp_nonce_field( 'analytics-options', 'analytics-options' );
63
+ submit_button( esc_html__( 'Save', 'amp' ), 'primary', 'save', false );
64
  if ( $is_existing_entry ) {
65
+ submit_button( esc_html__( 'Delete', 'amp' ), 'delete button-primary', esc_attr( $id_base . '[delete]' ), false );
66
  }
67
  ?>
68
  </p>
83
  <?php
84
  }
85
 
86
+ /**
87
+ * Render.
88
+ */
89
  public function render() {
90
  $analytics_entries = AMP_Options_Manager::get_option( 'analytics', array() );
91
 
includes/templates/class-amp-post-template.php CHANGED
@@ -94,7 +94,13 @@ class AMP_Post_Template {
94
  } else {
95
  $this->post = get_post( $post );
96
  }
97
- $this->ID = $this->post->ID;
 
 
 
 
 
 
98
 
99
  $content_max_width = self::CONTENT_MAX_WIDTH;
100
  if ( isset( $GLOBALS['content_width'] ) && $GLOBALS['content_width'] > 0 ) {
94
  } else {
95
  $this->post = get_post( $post );
96
  }
97
+
98
+ // Make sure we have a post, or bail if not.
99
+ if ( is_a( $this->post, 'WP_Post' ) ) {
100
+ $this->ID = $this->post->ID;
101
+ } else {
102
+ return;
103
+ }
104
 
105
  $content_max_width = self::CONTENT_MAX_WIDTH;
106
  if ( isset( $GLOBALS['content_width'] ) && $GLOBALS['content_width'] > 0 ) {
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: batmoo, joen, automattic, potatomaster, albertomedina, google, xwp
3
  Tags: amp, mobile
4
  Requires at least: 4.7
5
  Tested up to: 4.9
6
- Stable tag: 0.6.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires PHP: 5.2
@@ -38,6 +38,11 @@ Follow along with or [contribute](https://github.com/Automattic/amp-wp/blob/deve
38
 
39
  == Changelog ==
40
 
 
 
 
 
 
41
  = 0.6.1 (2018-02-09) =
42
 
43
  Bump version to re-release to ensure temporarily-broken 0.6.0 ZIP build is permanently fixed, without requiring a site to re-install the plugin.
3
  Tags: amp, mobile
4
  Requires at least: 4.7
5
  Tested up to: 4.9
6
+ Stable tag: 0.6.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Requires PHP: 5.2
38
 
39
  == Changelog ==
40
 
41
+ = 0.6.2 (2018-02-12) =
42
+
43
+ - Reduce frequency of flushing rewrite rules and harden, use escaped translation functions, and make minor changes to improve logic/style. See [#953](https://github.com/Automattic/amp-wp/pull/953). Props philipjohn, westonruter.
44
+ - Fix AMP preview icon in Firefox. See [#920](https://github.com/Automattic/amp-wp/pull/920). Props zigasancin.
45
+
46
  = 0.6.1 (2018-02-09) =
47
 
48
  Bump version to re-release to ensure temporarily-broken 0.6.0 ZIP build is permanently fixed, without requiring a site to re-install the plugin.