Skip to content

Commit

Permalink
Merge pull request #1114 from 10up/fix/141-post-status-follow-up
Browse files Browse the repository at this point in the history
Store and update post status in `dt` object.
  • Loading branch information
peterwilsoncc authored Jul 16, 2023
2 parents 0839663 + 278d126 commit 3eac2c8
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 6 deletions.
3 changes: 2 additions & 1 deletion assets/js/gutenberg-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ const DistributorPlugin = () => {
const post = useSelect( ( select ) =>
select( 'core/editor' ).getCurrentPost()
);
// Make the post title available to the top menu.
// Make the post title and status available to the top menu.
dt.postTitle = post.title;
dt.postStatus = post.status;

// If we are on a non-supported post status, change what we show
if (
Expand Down
4 changes: 1 addition & 3 deletions assets/js/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jQuery( window ).on( 'load', () => {
let selectAllConnections = '';
let selectNoConnections = '';
let connectionsSearchInput = '';
let postStatusInput = '';
let asDraftInput = '';
let errorDetails = '';

Expand Down Expand Up @@ -91,7 +90,6 @@ jQuery( window ).on( 'load', () => {
connectionsSearchInput = document.getElementById(
'dt-connection-search'
);
postStatusInput = document.getElementById( 'dt-post-status' );
asDraftInput = document.getElementById( 'dt-as-draft' );
errorDetails = document.querySelector( '.dt-error ul.details' );

Expand Down Expand Up @@ -516,7 +514,7 @@ jQuery( window ).on( 'load', () => {
data.postStatus =
null !== asDraftInput && asDraftInput.checked
? 'draft'
: postStatusInput.value;
: dt.postStatus;

const xhr = dt.usexhr ? { withCredentials: true } : false;

Expand Down
1 change: 1 addition & 0 deletions includes/push-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ function enqueue_scripts( $hook ) {
'loadConnectionsNonce' => wp_create_nonce( 'dt-load-connections' ),
'postId' => (int) get_the_ID(),
'postTitle' => get_the_title(),
'postStatus' => get_post_status(),
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),

/**
Expand Down
1 change: 0 additions & 1 deletion templates/show-connections-amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class="add-connection{{#syndicated}} syndicated{{/syndicated}}"
<div class="selected-connections-list"></div>

<div class="action-wrapper">
<input type="hidden" id="dt-post-status" value="<?php echo esc_attr( $post->post_status ); ?>">
<?php
$as_draft = ( 'draft' !== $post->post_status ) ? true : false;
/**
Expand Down
1 change: 0 additions & 1 deletion templates/show-connections.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class="add-connection<# if ( ! _.isEmpty( connections[ key ]['syndicated'] ) ) {
<div class="selected-connections-list"></div>

<div class="action-wrapper">
<input type="hidden" id="dt-post-status" value="<?php echo esc_attr( $post->post_status ); ?>">
<?php
$as_draft = ( 'draft' !== $post->post_status ) ? true : false;
/**
Expand Down

0 comments on commit 3eac2c8

Please sign in to comment.