From d0c02da69572e80188d46b802084496b0f270916 Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Sun, 15 May 2016 21:04:35 +1000 Subject: [PATCH 01/20] Move customize_url into own function --- php/class-edit-post-preview.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 389151c..80a15c8 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -101,6 +101,19 @@ public function enqueue_admin_scripts() { return; } wp_enqueue_script( 'edit-post-preview-admin' ); + + $data = array( + 'customize_url' => self::get_customize_url(), + ); + wp_scripts()->add_data( 'edit-post-preview-admin', 'data', sprintf( 'var _editPostPreviewAdminExports = %s;', wp_json_encode( $data ) ) ); + wp_enqueue_script( 'customize-loader' ); + wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( function() { EditPostPreviewAdmin.init(); } );', 'after' ); + } + + /** + * Get Post customize link + */ + public function get_customize_url() { $post = $this->get_previewed_post(); $id_param = ( 'page' === $post->post_type ) ? 'page_id' : 'p'; @@ -114,12 +127,8 @@ public function enqueue_admin_scripts() { ), wp_customize_url() ); - $data = array( - 'customize_url' => $customize_url, - ); - wp_scripts()->add_data( 'edit-post-preview-admin', 'data', sprintf( 'var _editPostPreviewAdminExports = %s;', wp_json_encode( $data ) ) ); - wp_enqueue_script( 'customize-loader' ); - wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( function() { EditPostPreviewAdmin.init(); } );', 'after' ); + + return $customize_url; } /** From d35ffc665facbfa71108d316ed80d15a920e8e16 Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Wed, 18 May 2016 20:39:29 +1000 Subject: [PATCH 02/20] feature/addeditincustomizerbuttons Initial concept --- php/class-edit-post-preview.php | 44 ++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 80a15c8..2a8360e 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -36,6 +36,8 @@ public function __construct( Customize_Posts_Plugin $plugin ) { add_action( 'customize_controls_init', array( $this, 'remove_static_controls_and_sections' ), 100 ); add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_customize_scripts' ) ); add_action( 'customize_preview_init', array( $this, 'make_auto_draft_status_previewable' ) ); + add_filter( 'post_row_actions', array( $this, 'add_edit_customizer_to_row_actions' ), 10, 2 ); + add_filter( 'page_row_actions', array( $this, 'add_edit_customizer_to_row_actions' ), 10, 2 ); } /** @@ -101,20 +103,54 @@ public function enqueue_admin_scripts() { return; } wp_enqueue_script( 'edit-post-preview-admin' ); + $customize_url = self::get_customize_url(); $data = array( - 'customize_url' => self::get_customize_url(), + 'customize_url' => $customize_url, ); + wp_scripts()->add_data( 'edit-post-preview-admin', 'data', sprintf( 'var _editPostPreviewAdminExports = %s;', wp_json_encode( $data ) ) ); wp_enqueue_script( 'customize-loader' ); wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( function() { EditPostPreviewAdmin.init(); } );', 'after' ); + + if ( 'add' !== get_current_screen()->action ) { + wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( \'.wrap h1\' ).append( \'Edit in Customizer\' )', 'after' ); + } } /** - * Get Post customize link + * Add the edit customizer to row actions for Posts/Pages + * + * @param array $actions + * @param object $post + * @return array $rebuild_actions */ - public function get_customize_url() { - $post = $this->get_previewed_post(); + public function add_edit_customizer_to_row_actions( $actions, $post ) { + if ( ! is_a( $post, 'WP_Post' ) ) { + return false; + } + + // Let's rebuild the order of $actions + $rebuild_actions = array(); + $rebuild_actions['edit'] = $actions['edit']; + $rebuild_actions['edit_customizer'] = 'Edit in Customizer'; + $rebuild_actions['inline hide-if-no-js'] = $actions['inline hide-if-no-js']; + $rebuild_actions['trash'] = $actions['trash']; + $rebuild_actions['view'] = $actions['view']; + + return $rebuild_actions; + } + + /** + * Get the customize link + * + * @param array $post + * @return string $customize_url + */ + public function get_customize_url( $post = null ) { + if ( ! is_a( $post, 'WP_Post' ) ) { + $post = $this->get_previewed_post(); + } $id_param = ( 'page' === $post->post_type ) ? 'page_id' : 'p'; $url = get_preview_post_link( $post, array(), home_url( '?preview=true&' . $id_param . '=' . $post->ID ) ); From 984b7cda7c81e735b69a2a1bc0ed7cbc243a336a Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Wed, 18 May 2016 20:52:01 +1000 Subject: [PATCH 03/20] feature/addeditincustomizerbuttons Fix travis build issues --- php/class-edit-post-preview.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 2a8360e..57cc269 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -114,15 +114,15 @@ public function enqueue_admin_scripts() { wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( function() { EditPostPreviewAdmin.init(); } );', 'after' ); if ( 'add' !== get_current_screen()->action ) { - wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( \'.wrap h1\' ).append( \'Edit in Customizer\' )', 'after' ); + wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( \'.wrap h1\' ).append( \'Edit in Customizer\' )', 'after' ); } } /** * Add the edit customizer to row actions for Posts/Pages * - * @param array $actions - * @param object $post + * @param array $actions Actions. + * @param object $post Post. * @return array $rebuild_actions */ public function add_edit_customizer_to_row_actions( $actions, $post ) { @@ -130,7 +130,7 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { return false; } - // Let's rebuild the order of $actions + // Let's rebuild the order of $actions. $rebuild_actions = array(); $rebuild_actions['edit'] = $actions['edit']; $rebuild_actions['edit_customizer'] = 'Edit in Customizer'; @@ -142,9 +142,9 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { } /** - * Get the customize link - * - * @param array $post + * Get the customize line + * + * @param array $post Post. * @return string $customize_url */ public function get_customize_url( $post = null ) { From dca990b4fc71f810f178514eaa2d47d1aae1ab65 Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Wed, 18 May 2016 21:00:23 +1000 Subject: [PATCH 04/20] feature/addeditincustomizerbuttons Fix last travis issue --- php/class-edit-post-preview.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 57cc269..aea77ae 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -119,9 +119,9 @@ public function enqueue_admin_scripts() { } /** - * Add the edit customizer to row actions for Posts/Pages + * Add the edit customizer to row actions for Posts/Pages. * - * @param array $actions Actions. + * @param array $actions Actions. * @param object $post Post. * @return array $rebuild_actions */ From 3bb99498f317e76097ef6bca08a84ce86c6233af Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Fri, 20 May 2016 11:05:37 +1000 Subject: [PATCH 05/20] feature/addeditincustomizerbuttons Start refactoring code --- php/class-edit-post-preview.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index aea77ae..11e7527 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -36,8 +36,10 @@ public function __construct( Customize_Posts_Plugin $plugin ) { add_action( 'customize_controls_init', array( $this, 'remove_static_controls_and_sections' ), 100 ); add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_customize_scripts' ) ); add_action( 'customize_preview_init', array( $this, 'make_auto_draft_status_previewable' ) ); + add_action( 'admin_footer', array( $this, 'add_edit_customizer_button_posts' ) ); add_filter( 'post_row_actions', array( $this, 'add_edit_customizer_to_row_actions' ), 10, 2 ); add_filter( 'page_row_actions', array( $this, 'add_edit_customizer_to_row_actions' ), 10, 2 ); + } /** @@ -112,10 +114,6 @@ public function enqueue_admin_scripts() { wp_scripts()->add_data( 'edit-post-preview-admin', 'data', sprintf( 'var _editPostPreviewAdminExports = %s;', wp_json_encode( $data ) ) ); wp_enqueue_script( 'customize-loader' ); wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( function() { EditPostPreviewAdmin.init(); } );', 'after' ); - - if ( 'add' !== get_current_screen()->action ) { - wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( \'.wrap h1\' ).append( \'Edit in Customizer\' )', 'after' ); - } } /** @@ -130,15 +128,24 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { return false; } - // Let's rebuild the order of $actions. + $post_type_object = get_post_types( array(), 'objects' ); + if ( ! isset( $post_type_object[ get_post_type() ]->show_in_customizer ) && 'post' !== get_post_type() && 'page' !== get_post_type() ) { + return $actions; + } + + // Let's rebuild the start of our array. $rebuild_actions = array(); $rebuild_actions['edit'] = $actions['edit']; - $rebuild_actions['edit_customizer'] = 'Edit in Customizer'; - $rebuild_actions['inline hide-if-no-js'] = $actions['inline hide-if-no-js']; - $rebuild_actions['trash'] = $actions['trash']; - $rebuild_actions['view'] = $actions['view']; + $rebuild_actions['edit_customizer'] = sprintf( '%2$s', esc_url( self::get_customize_url() ), esc_html__( 'Edit in Customizer', 'customize-posts' ) ); + + return array_merge( $rebuild_actions, $actions ); + } - return $rebuild_actions; + public function add_edit_customizer_button_posts() { + if ( 'add' !== get_current_screen()->action ) { + printf( '%4$s', esc_html__( 'customize-button', 'customize-posts' ), esc_html__( 'page-title-action hide-if-no-customize', 'customize-posts' ), esc_url( self::get_customize_url() ), esc_html__( 'Edit in Customizer', 'customize-posts' ) ); + wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( \'#customize-button\' ).appendTo( \'.wrap h1\' )', 'after' ); + } } /** From d18fb24ce6c5c68ad2df7af15a59bd58c7231937 Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Fri, 20 May 2016 11:14:11 +1000 Subject: [PATCH 06/20] feature/addeditincustomizerbuttons Check if is defined --- php/class-edit-post-preview.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 11e7527..b699f73 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -128,6 +128,7 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { return false; } + // We need to make sure the current post type has show_in_customizer to true or if it's default post type is post or page. $post_type_object = get_post_types( array(), 'objects' ); if ( ! isset( $post_type_object[ get_post_type() ]->show_in_customizer ) && 'post' !== get_post_type() && 'page' !== get_post_type() ) { return $actions; @@ -141,6 +142,11 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { return array_merge( $rebuild_actions, $actions ); } + /** + * Add the Edit in Customizer button to the edit post screen. + * + * @return string Edit in Customizer button. + */ public function add_edit_customizer_button_posts() { if ( 'add' !== get_current_screen()->action ) { printf( '%4$s', esc_html__( 'customize-button', 'customize-posts' ), esc_html__( 'page-title-action hide-if-no-customize', 'customize-posts' ), esc_url( self::get_customize_url() ), esc_html__( 'Edit in Customizer', 'customize-posts' ) ); @@ -149,7 +155,7 @@ public function add_edit_customizer_button_posts() { } /** - * Get the customize line + * Get the customize line. * * @param array $post Post. * @return string $customize_url @@ -159,6 +165,10 @@ public function get_customize_url( $post = null ) { $post = $this->get_previewed_post(); } + if ( ! $post ) { + return false; + } + $id_param = ( 'page' === $post->post_type ) ? 'page_id' : 'p'; $url = get_preview_post_link( $post, array(), home_url( '?preview=true&' . $id_param . '=' . $post->ID ) ); $customize_url = add_query_arg( From 8011d979beabe9057f2f2199a177518a42fb08ac Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Fri, 20 May 2016 11:18:02 +1000 Subject: [PATCH 07/20] feature/addeditincustomizerbuttons Fix travis issue with comment --- php/class-edit-post-preview.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index b699f73..64e3562 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -144,8 +144,6 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { /** * Add the Edit in Customizer button to the edit post screen. - * - * @return string Edit in Customizer button. */ public function add_edit_customizer_button_posts() { if ( 'add' !== get_current_screen()->action ) { From b54051e740b54b1375673c7a47ec0ada5ede185b Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Fri, 20 May 2016 19:47:30 +1000 Subject: [PATCH 08/20] feature/addeditincustomizerbuttons Add to get_customize_url on posts action --- php/class-edit-post-preview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 64e3562..14a290f 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -137,7 +137,7 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { // Let's rebuild the start of our array. $rebuild_actions = array(); $rebuild_actions['edit'] = $actions['edit']; - $rebuild_actions['edit_customizer'] = sprintf( '%2$s', esc_url( self::get_customize_url() ), esc_html__( 'Edit in Customizer', 'customize-posts' ) ); + $rebuild_actions['edit_customizer'] = sprintf( '%2$s', esc_url( self::get_customize_url( $post ) ), esc_html__( 'Edit in Customizer', 'customize-posts' ) ); return array_merge( $rebuild_actions, $actions ); } From 1ae51868160fdfdd615f8330549f240157dee48c Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Fri, 20 May 2016 20:13:24 +1000 Subject: [PATCH 09/20] feature/addeditincustomizerbuttons Restrict button to certain sections --- php/class-edit-post-preview.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 14a290f..66d9818 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -130,7 +130,7 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { // We need to make sure the current post type has show_in_customizer to true or if it's default post type is post or page. $post_type_object = get_post_types( array(), 'objects' ); - if ( ! isset( $post_type_object[ get_post_type() ]->show_in_customizer ) && 'post' !== get_post_type() && 'page' !== get_post_type() ) { + if ( ! isset( $post_type_object[ get_post_type() ]->show_in_customizer ) && 'post' !== get_post_type() && 'page' !== get_post_type() || ! current_user_can( 'edit_post', $post->ID ) ) { return $actions; } @@ -146,10 +146,13 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { * Add the Edit in Customizer button to the edit post screen. */ public function add_edit_customizer_button_posts() { - if ( 'add' !== get_current_screen()->action ) { - printf( '%4$s', esc_html__( 'customize-button', 'customize-posts' ), esc_html__( 'page-title-action hide-if-no-customize', 'customize-posts' ), esc_url( self::get_customize_url() ), esc_html__( 'Edit in Customizer', 'customize-posts' ) ); - wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( \'#customize-button\' ).appendTo( \'.wrap h1\' )', 'after' ); + $post_type_object = get_post_types( array(), 'objects' ); + if ( ! isset( $post_type_object[ get_post_type() ]->show_in_customizer ) || '' !== get_current_screen()->action ) { + return false; } + + printf( '%4$s', esc_html__( 'customize-button', 'customize-posts' ), esc_html__( 'page-title-action hide-if-no-customize', 'customize-posts' ), esc_url( self::get_customize_url() ), esc_html__( 'Edit in Customizer', 'customize-posts' ) ); + wp_add_inline_script( 'edit-post-preview-admin', 'jQuery( \'#customize-button\' ).appendTo( \'.wrap h1\' )', 'after' ); } /** @@ -166,7 +169,7 @@ public function get_customize_url( $post = null ) { if ( ! $post ) { return false; } - + $id_param = ( 'page' === $post->post_type ) ? 'page_id' : 'p'; $url = get_preview_post_link( $post, array(), home_url( '?preview=true&' . $id_param . '=' . $post->ID ) ); $customize_url = add_query_arg( From ddeb2ff7624cc9cd21575bf7d48b8b25ef833e16 Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Fri, 20 May 2016 20:45:07 +1000 Subject: [PATCH 10/20] feature/addeditincustomizerbuttons Check if Post or Page --- php/class-edit-post-preview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 66d9818..62456cb 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -147,7 +147,7 @@ public function add_edit_customizer_to_row_actions( $actions, $post ) { */ public function add_edit_customizer_button_posts() { $post_type_object = get_post_types( array(), 'objects' ); - if ( ! isset( $post_type_object[ get_post_type() ]->show_in_customizer ) || '' !== get_current_screen()->action ) { + if ( ! isset( $post_type_object[ get_post_type() ]->show_in_customizer ) && 'post' !== get_post_type() && 'page' !== get_post_type() || '' !== get_current_screen()->action ) { return false; } From b0e2f201850da73ed84d8ab146f9692dc5c6c82b Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Wed, 25 May 2016 20:25:37 +1000 Subject: [PATCH 11/20] feature/addeditincustomizerbuttons Remove previewed_post from URL --- php/class-edit-post-preview.php | 1 - 1 file changed, 1 deletion(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 62456cb..ab67d60 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -175,7 +175,6 @@ public function get_customize_url( $post = null ) { $customize_url = add_query_arg( array( 'url' => urlencode( $url ), - 'previewed_post' => $post->ID, 'autofocus[section]' => sprintf( 'post[%s][%d]', $post->post_type, $post->ID ), self::PREVIEW_POST_NONCE_QUERY_VAR => wp_create_nonce( self::PREVIEW_POST_NONCE_ACTION ), ), From d39dfd17d469d380a88ef502b57780f3f1345387 Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Thu, 26 May 2016 14:42:38 +1000 Subject: [PATCH 12/20] feature/addeditincustomizerbuttons Add permalink to get_preview_post_link --- php/class-edit-post-preview.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index ab67d60..01bd653 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -169,9 +169,10 @@ public function get_customize_url( $post = null ) { if ( ! $post ) { return false; } - + $id_param = ( 'page' === $post->post_type ) ? 'page_id' : 'p'; - $url = get_preview_post_link( $post, array(), home_url( '?preview=true&' . $id_param . '=' . $post->ID ) ); + + $url = get_preview_post_link( $post, array(), get_permalink( $post->ID ) . '?preview=true&' . $id_param . '=' . $post->ID ); $customize_url = add_query_arg( array( 'url' => urlencode( $url ), From a335d324459b87c4d0545a1a55d9d195da5a607c Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Thu, 26 May 2016 14:43:41 +1000 Subject: [PATCH 13/20] feature/addeditincustomizerbuttons Be more consistant with code --- php/class-edit-post-preview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 01bd653..27a8704 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -124,7 +124,7 @@ public function enqueue_admin_scripts() { * @return array $rebuild_actions */ public function add_edit_customizer_to_row_actions( $actions, $post ) { - if ( ! is_a( $post, 'WP_Post' ) ) { + if ( ! ( $post instanceof WP_Post ) ) { return false; } From e5357800639141e1f89f3247c0b9724c2d2bc50f Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Thu, 26 May 2016 15:48:39 +1000 Subject: [PATCH 14/20] feature/addeditincustomizerbuttons Use get_preview_post_link with post only --- php/class-edit-post-preview.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 27a8704..add3d00 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -170,9 +170,7 @@ public function get_customize_url( $post = null ) { return false; } - $id_param = ( 'page' === $post->post_type ) ? 'page_id' : 'p'; - - $url = get_preview_post_link( $post, array(), get_permalink( $post->ID ) . '?preview=true&' . $id_param . '=' . $post->ID ); + $url = get_preview_post_link( $post ); $customize_url = add_query_arg( array( 'url' => urlencode( $url ), From 9cb8cb6d9821609036aa69859fb8f90c754f5afd Mon Sep 17 00:00:00 2001 From: Stuart Shields Date: Thu, 26 May 2016 19:57:02 +1000 Subject: [PATCH 15/20] feature/addeditincustomizerbuttons Add instanceof to get_customize_url --- php/class-edit-post-preview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index add3d00..2125ee3 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -162,7 +162,7 @@ public function add_edit_customizer_button_posts() { * @return string $customize_url */ public function get_customize_url( $post = null ) { - if ( ! is_a( $post, 'WP_Post' ) ) { + if ( ! ( $post instanceof WP_Post ) ) { $post = $this->get_previewed_post(); } From 986c7f434c2459938f29d6795eedc5e2ed954b46 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 18 Jun 2016 08:23:08 +0200 Subject: [PATCH 16/20] Ensure that plugin-support and theme-support are included in build --- Gruntfile.js | 2 +- readme.md | 1 + readme.txt | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 2769468..773f183 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -62,7 +62,7 @@ module.exports = function( grunt ) { '*.php', 'css/*', 'js/*', - 'php/*', + 'php/**', 'readme.txt' ], dest: 'build', diff --git a/readme.md b/readme.md index ced0a35..0a53728 100644 --- a/readme.md +++ b/readme.md @@ -103,6 +103,7 @@ Fixed: * Improve compatibility with the WP REST API plugin. * Supply a default (no title) placeholder to the post title control for new posts. * Filter post and page links in the Customizer to return the preview URL. + * Included plugin-support and theme-support PHP files that were inadvertantly omitted from the 0.6.0 build. See full commit log: [`0.5.0...0.6.0`](https://github.com/xwp/wp-customize-posts/compare/0.5.0...0.6.0) diff --git a/readme.txt b/readme.txt index 2843185..633e266 100644 --- a/readme.txt +++ b/readme.txt @@ -102,6 +102,7 @@ Fixed: * Improve compatibility with the WP REST API plugin. * Supply a default (no title) placeholder to the post title control for new posts. * Filter post and page links in the Customizer to return the preview URL. + * Included plugin-support and theme-support PHP files that were inadvertantly omitted from the 0.6.0 build. See full commit log: [`0.5.0...0.6.0`](https://github.com/xwp/wp-customize-posts/compare/0.5.0...0.6.0) From d41a4f6a9137c62ccf94320ecc229bf4cafc7edd Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 18 Jun 2016 08:23:36 +0200 Subject: [PATCH 17/20] Remove unrecognized Text Domain readme meta --- readme.md | 1 - readme.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/readme.md b/readme.md index 0a53728..1f01b5a 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,6 @@ Edit posts and postmeta in the Customizer. Stop editing your posts/postmeta blin **Tested up to:** 4.6-alpha **Stable tag:** 0.6.1 **License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html) -**Text Domain:** customize-posts [![Build Status](https://travis-ci.org/xwp/wp-customize-posts.svg?branch=master)](https://travis-ci.org/xwp/wp-customize-posts) [![Coverage Status](https://coveralls.io/repos/xwp/wp-customize-posts/badge.svg?branch=master)](https://coveralls.io/github/xwp/wp-customize-posts) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.svg)](http://gruntjs.com) [![devDependency Status](https://david-dm.org/xwp/wp-customize-posts/dev-status.svg)](https://david-dm.org/xwp/wp-customize-posts#info=devDependencies) diff --git a/readme.txt b/readme.txt index 633e266..8620f5b 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,6 @@ Tested up to: 4.6-alpha Stable tag: 0.6.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html -Text Domain: customize-posts Edit posts and postmeta in the Customizer. Stop editing your posts/postmeta blind! From 1ba5017c10136e4780071510faf452b40fbbf7e5 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 18 Jun 2016 08:35:26 +0200 Subject: [PATCH 18/20] Fix location of readme change --- readme.md | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 1f01b5a..f5bbfa0 100644 --- a/readme.md +++ b/readme.md @@ -74,6 +74,7 @@ The following are listed in reverse chronological order. The first, more recent * Add support for focusing on controls for setting properties when those properties are invalid * Prevent `customized-posts` messages sent via `selective-refresh` from effecting `post-navigation` state * Improve feature detection for including customize-controls patched for trac-36521 +* Included plugin-support and theme-support PHP files that were inadvertantly omitted from the 0.6.0 build. See full commit log: [`0.6.0...0.6.1`](https://github.com/xwp/wp-customize-posts/compare/0.6.0...0.6.1) @@ -102,7 +103,6 @@ Fixed: * Improve compatibility with the WP REST API plugin. * Supply a default (no title) placeholder to the post title control for new posts. * Filter post and page links in the Customizer to return the preview URL. - * Included plugin-support and theme-support PHP files that were inadvertantly omitted from the 0.6.0 build. See full commit log: [`0.5.0...0.6.0`](https://github.com/xwp/wp-customize-posts/compare/0.5.0...0.6.0) diff --git a/readme.txt b/readme.txt index 8620f5b..824cad0 100644 --- a/readme.txt +++ b/readme.txt @@ -72,6 +72,7 @@ The following are listed in reverse chronological order. The first, more recent * Add support for focusing on controls for setting properties when those properties are invalid * Prevent `customized-posts` messages sent via `selective-refresh` from effecting `post-navigation` state * Improve feature detection for including customize-controls patched for trac-36521 +* Included plugin-support and theme-support PHP files that were inadvertantly omitted from the 0.6.0 build. See full commit log: [`0.6.0...0.6.1`](https://github.com/xwp/wp-customize-posts/compare/0.6.0...0.6.1) @@ -101,7 +102,6 @@ Fixed: * Improve compatibility with the WP REST API plugin. * Supply a default (no title) placeholder to the post title control for new posts. * Filter post and page links in the Customizer to return the preview URL. - * Included plugin-support and theme-support PHP files that were inadvertantly omitted from the 0.6.0 build. See full commit log: [`0.5.0...0.6.0`](https://github.com/xwp/wp-customize-posts/compare/0.5.0...0.6.0) From 3ab205aef404f71c8013a9111a6fa302bf02bf48 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 18 Jun 2016 22:09:57 -0700 Subject: [PATCH 19/20] This plugin is not namespaced --- php/class-edit-post-preview.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index 89510f5..a4cd560 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -145,8 +145,8 @@ public function enqueue_admin_scripts() { * @param object $post Post. * @return array $rebuild_actions */ - public function add_edit_customizer_to_row_actions( $actions, \WP_Post $post ) { - if ( ! ( $post instanceof \WP_Post ) ) { + public function add_edit_customizer_to_row_actions( $actions, WP_Post $post ) { + if ( ! ( $post instanceof WP_Post ) ) { return false; } From 3e5b3f9baa81bfae3ed161d7a57cb3a3c749c82a Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 18 Jun 2016 22:13:19 -0700 Subject: [PATCH 20/20] Remove type hint --- php/class-edit-post-preview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/class-edit-post-preview.php b/php/class-edit-post-preview.php index a4cd560..3df32fd 100644 --- a/php/class-edit-post-preview.php +++ b/php/class-edit-post-preview.php @@ -145,7 +145,7 @@ public function enqueue_admin_scripts() { * @param object $post Post. * @return array $rebuild_actions */ - public function add_edit_customizer_to_row_actions( $actions, WP_Post $post ) { + public function add_edit_customizer_to_row_actions( $actions, $post ) { if ( ! ( $post instanceof WP_Post ) ) { return false; }