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/php/class-edit-post-preview.php b/php/class-edit-post-preview.php
index 07fd783..3df32fd 100644
--- a/php/class-edit-post-preview.php
+++ b/php/class-edit-post-preview.php
@@ -36,6 +36,9 @@ 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 );
}
/**
@@ -126,7 +129,84 @@ public function enqueue_admin_scripts() {
return;
}
wp_enqueue_script( 'edit-post-preview-admin' );
- $post = $this->get_previewed_post();
+
+ $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' );
+ }
+
+ /**
+ * Add the edit customizer to row actions for Posts/Pages.
+ *
+ * @param array $actions Actions.
+ * @param object $post Post.
+ * @return array $rebuild_actions
+ */
+ public function add_edit_customizer_to_row_actions( $actions, $post ) {
+ if ( ! ( $post instanceof WP_Post ) ) {
+ return false;
+ }
+
+ $post_type_object = get_post_type_object( $post->post_type );
+
+ $can_preview = (
+ (
+ ! empty( $post_type_object->show_in_customizer )
+ ||
+ in_array( $post->post_type, array( 'post', 'page' ), true )
+ )
+ &&
+ current_user_can( 'edit_post', $post->ID )
+ );
+
+ if ( $can_preview ) {
+ $actions = array_merge( array( sprintf( '%2$s', esc_url( self::get_customize_url( $post ) ), esc_html__( 'Customize', 'customize-posts' ) ) ), $actions );
+ }
+
+ return $actions;
+ }
+
+ /**
+ * Add the Edit in Customizer button to the edit post screen.
+ */
+ public function add_edit_customizer_button_posts() {
+ $post_type_object = get_post_type_object( get_post_type() );
+
+ $can_preview = (
+ ! empty( $post_type_object->show_in_customizer )
+ ||
+ in_array( get_post_type(), array( 'post', 'page' ), true )
+ );
+
+ if ( $can_preview ) {
+ 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' );
+ }
+ }
+
+ /**
+ * Get the customize line.
+ *
+ * @param array $post Post.
+ * @return string $customize_url
+ */
+ public function get_customize_url( $post = null ) {
+ if ( ! ( $post instanceof WP_Post ) ) {
+ $post = $this->get_previewed_post();
+ }
+
+ if ( ! $post ) {
+ return false;
+ }
$customize_url = add_query_arg(
array(
@@ -137,12 +217,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;
}
/**
diff --git a/readme.md b/readme.md
index ced0a35..f5bbfa0 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
[](https://travis-ci.org/xwp/wp-customize-posts) [](https://coveralls.io/github/xwp/wp-customize-posts) [](http://gruntjs.com) [](https://david-dm.org/xwp/wp-customize-posts#info=devDependencies)
@@ -75,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)
diff --git a/readme.txt b/readme.txt
index 2843185..824cad0 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!
@@ -73,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)