Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store and update post status in dt object. #1114

Merged
merged 5 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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