Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #375 from xwp/fix/scheduled-postmeta
Browse files Browse the repository at this point in the history
Fix saving of postmeta in scheduled changesets
  • Loading branch information
westonruter authored Nov 14, 2017
2 parents 112d942 + d2c09e3 commit be5f816
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xwp/wp-customize-posts",
"description": "Manage posts and postmeta via the Customizer.",
"version": "0.9.0",
"version": "0.9.1",
"type": "wordpress-plugin",
"keywords": [ "customizer", "customize", "posts", "postmeta", "preview", "featured-image", "page-template" ],
"homepage": "https://github.com/xwp/wp-customize-posts/",
Expand Down
2 changes: 1 addition & 1 deletion customize-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Customize Posts
* Description: Manage posts and postmeta via the Customizer.
* Plugin URI: https://github.com/xwp/wp-customize-posts/
* Version: 0.9.0
* Version: 0.9.1
* Author: XWP
* Author URI: https://make.xwp.co/
* License: GPLv2+
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/xwp/wp-customize-posts.git"
},
"version": "0.9.0",
"version": "0.9.1",
"license": "GPL-2.0+",
"private": true,
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions php/class-wp-customize-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public function __construct( WP_Customize_Manager $manager ) {
add_action( 'customize_register', array( $this, 'register_constructs' ), 20 );
add_filter( 'map_meta_cap', array( $this, 'filter_map_meta_cap' ), 10, 4 );
add_action( 'init', array( $this, 'register_meta' ), 100 );
if ( did_action( 'init' ) ) {
$this->register_meta(); // The init action will have already done in WP-CLI or WP Cron.
}
add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 );
add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_customize_dynamic_setting_class' ), 5, 3 );
add_filter( 'customize_sanitize_nav_menus_created_posts', array( $this, 'filter_out_nav_menus_created_posts_for_customized_posts' ), 20 );
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ The following are listed in reverse chronological order. The first, more recent

## Changelog ##

### [0.9.1] - [2017-11-13] ###
Fix saving of postmeta in scheduled changesets. See [#375](https://github.com/xwp/wp-customize-posts/pull/375).

### [0.9.0] - [2017-11-11] ###
* Bump minimum required WP version to 4.7; update compatibility for 4.9. See [#371](https://github.com/xwp/wp-customize-posts/pull/371).
* Update wrapper around `notifications.add` for new params accepted in 4.9. See [#369](https://github.com/xwp/wp-customize-posts/pull/369).
Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ The following are listed in reverse chronological order. The first, more recent

== Changelog ==

= [0.9.1] - [2017-11-13] =

Fix saving of postmeta in scheduled changesets. See [#375](https://github.com/xwp/wp-customize-posts/pull/375).

= [0.9.0] - [2017-11-11] =

* Bump minimum required WP version to 4.7; update compatibility for 4.9. See [#371](https://github.com/xwp/wp-customize-posts/pull/371).
Expand Down
4 changes: 2 additions & 2 deletions tests/php/test-class-wp-customize-postmeta-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public function test_register_meta_without_theme_support() {
);
/** @var WP_Customize_Postmeta_Controller $stub */
$stub = $this->getMockForAbstractClass( 'WP_Customize_Postmeta_Controller', array( $args ) );
$this->assertEmpty( $this->wp_customize->posts->registered_post_meta );
$this->assertEquals( 0, $stub->register_meta( $this->wp_customize->posts ) );
}

Expand All @@ -167,7 +166,7 @@ public function test_register_meta_for_post_types() {
);
/** @var WP_Customize_Postmeta_Controller $stub */
$stub = $this->getMockForAbstractClass( 'WP_Customize_Postmeta_Controller', array( $args ) );
$this->assertEmpty( $customize_posts->registered_post_meta );
$customize_posts->registered_post_meta = array();
$this->assertEquals( count( $args['post_types'] ), $stub->register_meta( $this->wp_customize->posts ) );
$this->assertEquals( 10, has_filter( "sanitize_post_meta_{$args['meta_key']}", array( $stub, 'sanitize_value' ) ) );
$this->assertArrayHasKey( 'post', $customize_posts->registered_post_meta );
Expand All @@ -191,6 +190,7 @@ public function test_register_meta_for_post_type_supports() {
);
/** @var WP_Customize_Postmeta_Controller $stub */
$stub = $this->getMockForAbstractClass( 'WP_Customize_Postmeta_Controller', array( $args ) );
$customize_posts->registered_post_meta = array();
$this->assertEquals( count( get_post_types_by_support( 'page-attributes' ) ), $stub->register_meta( $this->wp_customize->posts ) );
$this->assertEquals( 10, has_filter( "sanitize_post_meta_{$args['meta_key']}", array( $stub, 'sanitize_value' ) ) );
$this->assertArrayNotHasKey( 'post', $customize_posts->registered_post_meta );
Expand Down
21 changes: 11 additions & 10 deletions tests/php/test-class-wp-customize-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,17 +757,18 @@ public function test_get_settings() {
wp_trash_post( $trashed_post_id );

$settings_params = $this->posts->get_settings( array( $published_post_id, $trashed_post_id, $draft_page_id, $nav_menu_item_id ) );
$this->assertEqualSets(
array(
WP_Customize_Post_Setting::get_post_setting_id( get_post( $published_post_id ) ),
WP_Customize_Post_Setting::get_post_setting_id( get_post( $trashed_post_id ) ),
WP_Customize_Post_Setting::get_post_setting_id( get_post( $draft_page_id ) ),
sprintf( 'nav_menu_item[%s]', $nav_menu_item_id ),
WP_Customize_Postmeta_Setting::get_post_meta_setting_id( get_post( $published_post_id ), 'baz' ),
WP_Customize_Postmeta_Setting::get_post_meta_setting_id( get_post( $trashed_post_id ), 'baz' )
),
array_keys( $settings_params )
$actual_setting_ids = array_keys( $settings_params );
$expected_setting_ids = array(
WP_Customize_Post_Setting::get_post_setting_id( get_post( $published_post_id ) ),
WP_Customize_Post_Setting::get_post_setting_id( get_post( $trashed_post_id ) ),
WP_Customize_Post_Setting::get_post_setting_id( get_post( $draft_page_id ) ),
sprintf( 'nav_menu_item[%s]', $nav_menu_item_id ),
WP_Customize_Postmeta_Setting::get_post_meta_setting_id( get_post( $published_post_id ), 'baz' ),
WP_Customize_Postmeta_Setting::get_post_meta_setting_id( get_post( $trashed_post_id ), 'baz' )
);
foreach ( $expected_setting_ids as $expected_setting_id ) {
$this->assertContains( $expected_setting_id, $actual_setting_ids );
}
}

/**
Expand Down

0 comments on commit be5f816

Please sign in to comment.