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

Remove sessionStorage and use changeset to save post editor screen data. #350

Merged
merged 24 commits into from
Apr 25, 2017

Conversation

mohdsayed
Copy link
Contributor

Fixes #338


wp.customize.Loader.open( component.data.customize_url );
wp.customize.Loader.settings.browser.mobile = wasMobile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be put right after each of the wp.customize.Loader.open calls, especially the second since it is async.

global $wp_customize;

$previewed_post_id = absint( wp_unslash( $_POST['previewed_post'] ) );
$changeset_uuid = get_post_meta( $previewed_post_id, '_changeset_uuid', true );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe _preview_changeset_uuid would be better.

@mohdsayed mohdsayed changed the title [WIP] Remove sessionStorage and use changeset to save post editor screen data. Remove sessionStorage and use changeset to save post editor screen data. Apr 12, 2017
wp_unslash( $_POST['customize_url'] )
);

$wp_customize_posts = new WP_Customize_Posts( $wp_customize );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't we be able to use $wp_customize->posts here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, that's what I had done first but then phpStorm was not able to recognize $wp_customize->posts, so.. that's probably a weird reason.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right. It's because Customize Posts is adding the posts property without it being declared. So I added a workaround here by adding an explicit type declaration.

wp_send_json_error( 'missing_input_data' );
}

$previewed_post_id = intval( wp_unslash( $_POST['previewed_post'] ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this was previously absint. The use of this is function to sanitize integers is being discouraged in core now in favor of intval so that negative numbers won't get silently converted into something that could be a real post.

Copy link
Contributor

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sayedtaqui The experience here when previewing a post in the customizer is way better with your changes here. 🎉

Check out my changes and if they get your 👍 feel free to merge.

@westonruter
Copy link
Contributor

Oh, adding a unit test for Edit_Post_Preview::update_post_changeset() wouldn't be a bad idea.

@mohdsayed
Copy link
Contributor Author

@westonruter Please review my changes, ( Dont have merge access )

@westonruter westonruter merged commit 538d6f8 into develop Apr 25, 2017
@westonruter westonruter deleted the enhancements/issue-338 branch April 25, 2017 18:12
@westonruter westonruter added this to the 0.8.6 milestone Jun 7, 2017
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants