-
Notifications
You must be signed in to change notification settings - Fork 38
Add postmeta setting and framework #89
Conversation
Includes WP_Customize_Page_Template_Postmeta_Setting
…-dev-lib#164 from branch bugfix/linting-failures xwp/wp-dev-lib@12991a3...05bc18b 59fc96e Let JSHint know about pre-defined global variables of Browserify and Qunit. 0f110d4 Merge pull request xwp/wp-dev-lib#163 from branch feature/jshint-browserify-qunit f88ac9c Gracefully handle npm install failures e8af3c0 Ensure JSHINT_IGNORE is relative to linting directory 05bc18b Merge pull request xwp/wp-dev-lib#164 from branch bugfix/linting-failures
|
Changes Unknown when pulling e9085a9 on feature/postmeta into * on develop*. |
[ci skip]
|
Changes Unknown when pulling 7dbf83c on feature/postmeta into * on develop*. |
|
@westonruter I'm a little confused about how function test_sanitize_page_template_setting() {
switch_theme( 'twentytwelve' );
$post_id = $this->factory()->post->create( array( 'post_type' => 'post') );
$meta_key = '_wp_page_template';
register_meta( 'post', $meta_key, array( $this->plugin->page_template_controller, 'sanitize_value' ) );
$setting_id = WP_Customize_Postmeta_Setting::get_post_meta_setting_id( get_post( $post_id ), $meta_key );
$setting = new WP_Customize_Postmeta_Setting( $this->manager, $setting_id, array(
'sanitize_callback' => array( $this->plugin->page_template_controller, 'sanitize_setting' )
) );
$this->assertEquals( 'default', $setting->sanitize( 'default' ) );
$this->assertNull( $setting->sanitize( 'bad-template.php' ) );
$page_template = 'page-templates/front-page.php';
$this->assertEquals( $page_template, $setting->sanitize( $page_template ) );
} |
You can see committed right now that the test is skipped: $this->markTestSkipped( 'Class is gone: WP_Customize_Page_Template_Postmeta_Setting' );So it wasn't up to date. Now, it is expected that it would fail without the
There are actually two separate sanitizers that can apply to a postmeta setting. There is the only sanitizer that is added via register_meta( 'post', $meta_key, array( $this->plugin->page_template_controller, 'sanitize_value' ) );This sanitizer is called when $page_templates = wp_get_theme()->get_page_templates( $post );So yeah, I think what you found is expected behavior! |
| $meta_values = get_post_meta( $object_id, '', $single ); | ||
| $is_recursing = false; | ||
|
|
||
| foreach ( $this->previewed_postmeta_settings[ $object_id ] as $postmeta_setting ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@westonruter
When testing I got this notice, and it was related to this line.
array(1) { ["postmeta[page][10][_wp_page_template]"]=> string(31) "template-page-sidebar-right.php" } string(37) "postmeta[page][10][_wp_page_template]"
Warning: array_key_exists() expects parameter 2 to be array, string given in /srv/www/strathcomcms.com/wp-content/plugins/wp-customize-posts/php/class-wp-customize-posts-preview.php on line 228
I checked http://php.net/manual/ro/function.array-key-exists.php
and this was mentioning to turn those things - they key first, the array after, like from this:
array_key_exists( $post_values, $postmeta_setting->id )
into this:
array_key_exists( $postmeta_setting->id, $post_values )
Fixed it here: 9cc9fe8
|
Changes Unknown when pulling 9cc9fe8 on feature/postmeta into * on develop*. |
js/customize-page-template.js
Outdated
| setting.bind( function( pageTemplate ) { | ||
| var settings = {}; | ||
| settings[ settingId ] = pageTemplate; | ||
| EditPostPreviewCustomize.sendSettingsToEditPostScreen( settings ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@westonruter
This EditPostPreviewCustomize global yielded an invalid reference. I've updated Wordpress to 4.5 in our test environment and didn't get an improvement.
I've searched for this variable and since it's not in the current branch of the repository I'm not sure where it originates from.
I've just commented this out (locally) and that yielded a fully functional page template adjustment without JS errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
I had brought this into a client project, since it worked. We'll be coming back if we find anything not to be working correctly. |
|
Changes Unknown when pulling 562c068 on feature/postmeta into * on develop*. |
…ve WP_Customize_Posts_Preview logic for returning non-single values
|
Changes Unknown when pulling 09077f7 on feature/postmeta into * on develop*. |
|
Changes Unknown when pulling 87bd48b on feature/postmeta into * on develop*. |
|
@valendesigns this epic PR I believe is now ready to merge! |
|
Changes Unknown when pulling f17aecb on feature/postmeta into * on develop*. |
Still needed:
Fixes #1.
Fixes #85.
Fixes #62.