-
Notifications
You must be signed in to change notification settings - Fork 12
Allow snapshot posts to publish and be scheduled #62
Conversation
Do we need to check for theme change and change theme before publishing snapshot data and revert back after done? @valendesigns |
* @param int $post_id Post id. | ||
* @param \WP_Post $post Post object. | ||
*/ | ||
public function publish_snapshot( $post_id, $post ) { |
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.
@PatelUtkarsh warning that when doing Publish in the Customizer, any existing snapshot will be transitioned to publish
. See:
'status' => 'publish', |
So it is important that this should short-circuit if did_action( 'customize_save' )
, because this would indicate that the customize_save
Ajax request is being made.
I don't think we need to worry about the theme change. The publish metabox and publish actions should be disabled if the current theme doesn't match the theme associated with the snapshot. |
@PatelUtkarsh the changes here will directly resolve #15. Please refer to the comments there for what other considerations will be needed. |
foreach ( $snapshot_values as $setting_id => $setting_params ) { | ||
$this->snapshot_manager->customize_manager->set_post_value( $setting_id, $setting_params ); | ||
$this->snapshot_manager->customize_manager->add_setting( $setting_id, $setting_params ); | ||
$setting = $this->snapshot_manager->customize_manager->get_setting( $setting_id ); |
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.
@PatelUtkarsh you'll need to make sure that $setting
is not null
. Also, as noted in #15, you'll need to make sure you do: $setting->capability = 'exist'
to ensure that the setting save will always be allowed. This is safe because a setting only be written to the snapshot by a user who has the capability to begin with, so we know at this point it will be safe to save.
@westonruter Which post_status transition should we allow?
|
@PatelUtkarsh any transition to |
remove_action( 'customize_save', array( $this->snapshot_manager, 'check_customize_publish_authorization' ), 10 ); | ||
/** This action is documented in wp-includes/class-wp-customize-manager.php */ | ||
do_action( 'customize_save', $this->snapshot_manager->customize_manager ); | ||
add_action( 'customize_save', array( $this, 'check_customize_publish_authorization' ), 10, 0 ); |
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.
Looks like the wrong customize_save
handler is being re-added. There is no check_customize_publish_authorization
method on this class.
I suggest doing:
$action = 'customize_save';
$callback = array( $this->snapshot_manager, 'check_customize_publish_authorization' );
$priority = has_action( $action, $callback );
if ( false !== $priority ) {
remove_action( $action, $callback, $priority );
}
/** This action is documented in wp-includes/class-wp-customize-manager.php */
do_action( 'customize_save', $this->snapshot_manager->customize_manager );
if ( false !== $priority ) {
add_action( $action, $callback, $priority );
}
@PatelUtkarsh this commit may be especially relevant to you, specifically the See #63 |
if ( false !== $priority ) { | ||
remove_action( $action, $callback, $priority ); | ||
} | ||
$this->snapshot_manager->customize_manager->doing_ajax( 'customize_save' ); |
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.
The doing_ajax
method doesn't do anything other than return a bool
to say whether this Ajax action is happening. So I don't think this block is doing anything. I'm revising.
* Remove bulk actions filter * Replace publish filter with transition filter. * Remove hiding of publish metabox if not current theme. Allow publishing if not current theme. * Remove hiding of author metabox. * Remove extraneous info now that publish metabox is restored. * Move Post_Type logic to Customize_Snapshot_Manager
…endnecy; fix tests
…ed_publishing_actions
@westonruter In a case of null as setting value before publishing snapshot, it is not showing setting name, and after publishing it shows setting name with an error. |
This allows snapshot changes to be published, On publish it will save snapshot changes in database.
Fixes #15.