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

Pull contents via ajax #1104

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
22 changes: 22 additions & 0 deletions assets/css/admin-pull-table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@
padding-left: 10px;
}
}

#distributor-pull-modal{
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: rgba(0, 0, 0, 50%);
display: flex;
align-items: center;
z-index: 9999;

&>div{
margin: 0 auto;
display: block;
width: 300px;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 1px 2px 15px rgba(0, 0, 0, 30%);
}
}
}

.wp-list-table .disabled {
Expand Down
138 changes: 131 additions & 7 deletions assets/js/admin-pull.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../css/admin-pull-table.scss';

import jQuery from 'jquery';
import { addQueryArgs } from '@wordpress/url';

Check failure on line 4 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L4

[no-unused-vars] 'addQueryArgs' is defined but never used.
import { __ } from '@wordpress/i18n';

const { document } = window;
Expand All @@ -15,6 +15,7 @@
const asDraftCheckboxes = document.querySelectorAll( '[name=dt_as_draft]' );
const pullLinks = document.querySelectorAll( '.distributor_page_pull .pull a' );

// Change target website to pull contents from
jQuery( chooseConnection ).on( 'change', ( event ) => {
document.location =
event.currentTarget.options[
Expand All @@ -25,55 +26,178 @@
} );

if ( chooseConnection && choosePostType && form ) {
// Handle post type selection
if ( choosePostTypeBtn ) {
jQuery( choosePostTypeBtn ).on( 'click', ( event ) => {
event.preventDefault();

document.location = getURL();

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.

document.body.className += ' ' + 'dt-loading';
} );
}

// Handle search button click
if ( searchField && searchBtn ) {
jQuery( searchBtn ).on( 'click', ( event ) => {
event.preventDefault();

const search = searchField.value;

document.location = `${ getURL() }&s=${ search }`;

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.

document.body.className += ' dt-loading';
} );
}

if ( asDraftCheckboxes && pullLinks ) {
// Handle pull mode checkbox event
if ( asDraftCheckboxes ) {
jQuery( asDraftCheckboxes ).on( 'change', ( event ) => {
if ( event.currentTarget.checked ) {
// Check all pull mode checkbox as there are multiple. Ideally before and after post list.
for ( let i = 0; i < asDraftCheckboxes.length; ++i ) {
asDraftCheckboxes[ i ].checked = true;
}

for ( let i = 0; i < pullLinks.length; ++i ) {
pullLinks[ i ].href = addQueryArgs( pullLinks[ i ].href, {
dt_as_draft: 'draft' /*eslint camelcase: 0*/,
} );
pullLinks[ i ].text = __( 'Pull as draft', 'distributor' );
}
} else {
// Uncheck all pull mode checkbox as there are multiple. Ideally before and after post list.
for ( let i = 0; i < asDraftCheckboxes.length; ++i ) {
asDraftCheckboxes[ i ].checked = false;
}

for ( let i = 0; i < pullLinks.length; ++i ) {
pullLinks[ i ].href = addQueryArgs( pullLinks[ i ].href, {
dt_as_draft: '' /*eslint camelcase: 0*/,
} );
pullLinks[ i ].text = __( 'Pull', 'distributor' );
}
}
} );
}

// Pull content via ajax
jQuery( '#doaction, #doaction2' ).on( 'click', e => {

Check failure on line 79 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L79

[prettier/prettier] Replace `e` with `(·e·)`
// Check action
var action = jQuery( '[name="action"]' ).val();

Check failure on line 81 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L81

[no-var] Unexpected var, use let or const instead.
if ( action != 'bulk-syndicate' ) {

Check failure on line 82 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L82

[eqeqeq] Expected '!==' and instead saw '!='.
return;
}
e.preventDefault();
openModal();
});

Check failure on line 87 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L87

[prettier/prettier] Insert `·`

jQuery( '.distributor_page_pull .pull a' ).on( 'click', function( e ) {

Check failure on line 89 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L89

[prettier/prettier] Insert `·`
e.preventDefault();
jQuery( this ).closest( 'tr' ).find( '.check-column input[type="checkbox"]' ).prop( 'checked', true );

Check failure on line 91 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L91

[prettier/prettier] Replace `.closest(·'tr'·).find(·'.check-column·input[type="checkbox"]'·)` with `⏎↹↹↹.closest(·'tr'·)⏎↹↹↹.find(·'.check-column·input[type="checkbox"]'·)⏎↹↹↹`
openModal();
});

Check failure on line 93 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L93

[prettier/prettier] Insert `·`

Check failure on line 94 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L94

[prettier/prettier] Delete `↹`
function openModal() {
// Prepare data
var aborted = false;

Check failure on line 97 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L97

[no-var] Unexpected var, use let or const instead.

Check failure on line 97 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L97

[prettier/prettier] Delete `·······`
var post_ids = [];

Check failure on line 98 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L98

[no-var] Unexpected var, use let or const instead.

Check failure on line 98 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L98

[camelcase] Identifier 'post_ids' is not in camel case.

Check failure on line 98 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L98

[prettier/prettier] Delete `······`
var source_label = jQuery('#pull_connections option:selected').text();

Check failure on line 99 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L99

[no-var] Unexpected var, use let or const instead.

Check failure on line 99 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L99

[camelcase] Identifier 'source_label' is not in camel case.

Check failure on line 99 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L99

[@wordpress/no-unused-vars-before-return] Variables should not be assigned until just prior its first reference. An early return statement may leave this variable unused.

Check failure on line 99 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L99

[prettier/prettier] Replace `···=·jQuery('#pull_connections·option:selected'` with `·=·jQuery(·'#pull_connections·option:selected'·`

jQuery( '#the-list .check-column input[type="checkbox"]:checked' ).each( function() {

Check failure on line 101 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L101

[prettier/prettier] Replace `·function` with `⏎↹↹↹function·`
var id = parseInt( jQuery( this ).val() );

Check failure on line 102 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L102

[prettier/prettier] Insert `↹`

Check failure on line 102 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L102

[no-var] Unexpected var, use let or const instead.
if ( id && post_ids.indexOf( id ) === -1 ) {

Check failure on line 103 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L103

[prettier/prettier] Insert `↹`

Check failure on line 103 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L103

[camelcase] Identifier 'post_ids' is not in camel case.
post_ids.push( id );

Check failure on line 104 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L104

[prettier/prettier] Insert `↹`

Check failure on line 104 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L104

[camelcase] Identifier 'post_ids' is not in camel case.
}

Check failure on line 105 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L105

[prettier/prettier] Insert `↹`
} );

Check failure on line 106 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L106

[prettier/prettier] Replace `↹↹}·` with `↹↹↹}⏎↹↹`

var post_ids_count = post_ids.length;

Check failure on line 108 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L108

[no-var] Unexpected var, use let or const instead.

Check failure on line 108 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L108

[camelcase] Identifier 'post_ids_count' is not in camel case.

Check failure on line 108 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L108

[camelcase] Identifier 'post_ids' is not in camel case.
if ( ! post_ids_count ) {

Check failure on line 109 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L109

[camelcase] Identifier 'post_ids_count' is not in camel case.
alert( 'Please select posts to pull' );

Check failure on line 110 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L110

[no-alert] Unexpected alert.

Check failure on line 110 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L110

[no-undef] 'alert' is not defined.
return;
}

function log( custom_content ) {

Check failure on line 114 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L114

[camelcase] Identifier 'custom_content' is not in camel case.
jQuery( '#distributor-pull-modal .pull-progress' ).html( custom_content || `Pulled: ${post_ids_count-post_ids.length}/${post_ids_count}` );

Check failure on line 115 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L115

[prettier/prettier] Replace `·custom_content·||·`Pulled:·${post_ids_count-post_ids.length}/${post_ids_count}`·` with `⏎↹↹↹↹custom_content·||⏎↹↹↹↹↹`Pulled:·${⏎↹↹↹↹↹↹post_ids_count·-·post_ids.length⏎↹↹↹↹↹}/${·post_ids_count·}`⏎↹↹↹`

Check failure on line 115 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L115

[camelcase] Identifier 'custom_content' is not in camel case.

Check failure on line 115 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L115

[camelcase] Identifier 'post_ids_count' is not in camel case.

Check failure on line 115 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L115

[camelcase] Identifier 'post_ids' is not in camel case.

Check failure on line 115 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L115

[camelcase] Identifier 'post_ids_count' is not in camel case.
}

// Create modal for pulling via ajax
jQuery( '#distributor-pull-modal' ).remove();
jQuery( 'body' ).append(
`
<div id="distributor-pull-modal">
<div>
<div class="pull-head-section">
<h3>Pulling from <b>${source_label}</b></h3>

Check failure on line 125 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L125

[prettier/prettier] Replace `source_label` with `·source_label·`

Check failure on line 125 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L125

[camelcase] Identifier 'source_label' is not in camel case.
<div class="pull-progress">Selected: ${post_ids_count}</div>

Check failure on line 126 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L126

[prettier/prettier] Replace `post_ids_count` with `·post_ids_count·`

Check failure on line 126 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L126

[camelcase] Identifier 'post_ids_count' is not in camel case.
</div>
<br/>
<div id="pull-button-container">
<button class="button button-secondary" data-action="cancel">Cancel</button>
<button class="button button-primary" data-action="start">Start</button>
</div>
</div>
</div>
`
Fixed Show fixed Hide fixed
);

jQuery( '#distributor-pull-modal' ).on( 'click', '[data-action="start"]', function() {

Check failure on line 138 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L138

[prettier/prettier] Replace `.on(·'click',·'[data-action="start"]',·function` with `⏎↹↹↹.on(·'click',·'[data-action="start"]',·function·`
jQuery( this ).prop( 'disabled', true );

Check failure on line 139 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L139

[prettier/prettier] Insert `↹`

var excludes = [ 'post[]', 'action2', 'page', 'paged' ];

Check failure on line 141 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L140-L141

[prettier/prettier] Replace `↹↹↹⏎↹↹↹var·excludes·` with `⏎↹↹↹↹var·excludes`

Check failure on line 141 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L141

[no-var] Unexpected var, use let or const instead.
var form_data = {};

Check failure on line 142 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L142

[prettier/prettier] Insert `↹`

Check failure on line 142 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L142

[no-var] Unexpected var, use let or const instead.

Check failure on line 142 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L142

[camelcase] Identifier 'form_data' is not in camel case.
jQuery( '#posts-filter' ).serializeArray().forEach( field => {

Check failure on line 143 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L143

[prettier/prettier] Replace `↹↹↹jQuery(·'#posts-filter'·).serializeArray().forEach(·field·` with `↹↹↹↹jQuery(·'#posts-filter'·)⏎↹↹↹↹↹.serializeArray()⏎↹↹↹↹↹.forEach(·(·field·)·`
if ( excludes.indexOf( field.name ) == -1 ) {

Check failure on line 144 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L144

[prettier/prettier] Insert `↹↹`

Check failure on line 144 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L144

[eqeqeq] Expected '===' and instead saw '=='.
form_data[ field.name ] = field.value;

Check failure on line 145 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L145

[prettier/prettier] Insert `↹↹`

Check failure on line 145 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L145

[camelcase] Identifier 'form_data' is not in camel case.
}

Check failure on line 146 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L146

[prettier/prettier] Replace `↹↹↹↹` with `↹↹↹↹↹↹`
});

Check failure on line 147 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L147

[prettier/prettier] Replace `}` with `↹↹}·`
form_data.action = 'distributor_pull_content';

Check failure on line 148 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L148

[prettier/prettier] Insert `↹`

Check failure on line 148 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L148

[camelcase] Identifier 'form_data' is not in camel case.

function looper() {

Check failure on line 150 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L150

[prettier/prettier] Insert `↹`
if ( aborted ) {

Check failure on line 151 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L151

[prettier/prettier] Insert `↹`
jQuery('#distributor-pull-modal').remove()

Check failure on line 152 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L152

[prettier/prettier] Replace `↹↹↹↹↹jQuery('#distributor-pull-modal').remove()` with `↹↹↹↹↹↹jQuery(·'#distributor-pull-modal'·).remove();`
}

Check failure on line 153 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L153

[prettier/prettier] Insert `↹`

log();

Check failure on line 155 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L155

[prettier/prettier] Insert `↹`

form_data.post_id = post_ids.shift();

Check failure on line 157 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L157

[prettier/prettier] Insert `↹`

Check failure on line 157 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L157

[camelcase] Identifier 'form_data' is not in camel case.

Check failure on line 157 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L157

[camelcase] Identifier 'post_ids' is not in camel case.
var xhr = new XMLHttpRequest();

Check failure on line 158 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L158

[prettier/prettier] Insert `↹`

Check failure on line 158 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L158

[no-var] Unexpected var, use let or const instead.

Check failure on line 158 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L158

[no-undef] 'XMLHttpRequest' is not defined.

jQuery.ajax({

Check failure on line 160 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L160

[prettier/prettier] Replace `↹↹↹↹jQuery.ajax(` with `↹↹↹↹↹jQuery.ajax(·`
url: window.ajaxurl,

Check failure on line 161 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L161

[prettier/prettier] Insert `↹`
type: 'POST',

Check failure on line 162 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L162

[prettier/prettier] Insert `↹`
data: form_data,

Check failure on line 163 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L163

[prettier/prettier] Insert `↹`

Check failure on line 163 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L163

[camelcase] Identifier 'form_data' is not in camel case.
xhr: function() {

Check failure on line 164 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L164

[prettier/prettier] Replace `xhr:·function` with `↹xhr:·function·`
return xhr;

Check failure on line 165 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L165

[prettier/prettier] Insert `↹`
},

Check failure on line 166 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L164-L166

[object-shorthand] Expected method shorthand.

Check failure on line 166 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L166

[prettier/prettier] Insert `↹`
success: function (resp) {

Check failure on line 167 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L167

[prettier/prettier] Replace `success:·function·(resp` with `↹success:·function·(·resp·`
if ( aborted ) {

Check failure on line 168 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L168

[prettier/prettier] Insert `↹`
return;

Check failure on line 169 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L169

[prettier/prettier] Insert `↹`
}

Check failure on line 170 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L170

[prettier/prettier] Replace `}` with `↹}⏎`

if ( ! resp.success || ! resp.data?.redirect_to ) {

Check failure on line 172 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L171-L172

[prettier/prettier] Delete `⏎↹↹↹↹↹`
log( `<span style="color:#a00;">${resp.data?.message || 'Something went wrong!'}</span>`);

Check failure on line 173 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L173

[prettier/prettier] Replace `log(·`<span·style="color:#a00;">${resp.data?.message·||·'Something·went·wrong!'}</span>`` with `↹log(⏎↹↹↹↹↹↹↹↹↹`<span·style="color:#a00;">${⏎↹↹↹↹↹↹↹↹↹↹resp.data?.message·||⏎↹↹↹↹↹↹↹↹↹↹'Something·went·wrong!'⏎↹↹↹↹↹↹↹↹↹}</span>`⏎↹↹↹↹↹↹↹↹`
return;

Check failure on line 174 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L174

[prettier/prettier] Insert `↹`
}

Check failure on line 175 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L175

[prettier/prettier] Insert `↹`

log();

Check failure on line 177 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L177

[prettier/prettier] Insert `↹`

if ( post_ids.length ) {

Check failure on line 179 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L179

[prettier/prettier] Insert `↹`

Check failure on line 179 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L179

[camelcase] Identifier 'post_ids' is not in camel case.
// Call the pull again for remaing post

Check failure on line 180 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L180

[prettier/prettier] Insert `↹`
looper();

Check failure on line 181 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L181

[prettier/prettier] Insert `↹`
} else {

Check failure on line 182 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L182

[prettier/prettier] Insert `↹`
// Redirect to where it asks to

Check failure on line 183 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L183

[prettier/prettier] Insert `↹`
window.location.assign( resp.data.redirect_to );

Check failure on line 184 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L184

[prettier/prettier] Insert `↹`
}

Check failure on line 185 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L185

[prettier/prettier] Insert `↹`
}

Check failure on line 186 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L167-L186

[object-shorthand] Expected method shorthand.

Check failure on line 186 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L186

[prettier/prettier] Replace `↹↹↹↹↹}` with `↹↹↹↹↹↹},`
});

Check failure on line 187 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L187

[prettier/prettier] Replace `↹↹↹↹}` with `↹↹↹↹↹}·`
}

Check failure on line 188 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L188

[prettier/prettier] Insert `↹`

looper();

Check failure on line 190 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L190

[prettier/prettier] Insert `↹`
}).on( 'click', '[data-action="cancel"]', function() {

Check failure on line 191 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L191

[prettier/prettier] Replace `}).on(·'click',·'[data-action="cancel"]',·function` with `↹}·)⏎↹↹↹.on(·'click',·'[data-action="cancel"]',·function·`
aborted = true;

Check failure on line 192 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L192

[prettier/prettier] Insert `↹`
jQuery( '#distributor-pull-modal' ).remove();

Check failure on line 193 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L193

[prettier/prettier] Insert `↹`

// Refresh the page if any post already pulled.

Check failure on line 195 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L194-L195

[prettier/prettier] Replace `↹↹↹⏎↹↹` with `⏎↹↹↹`
if ( post_ids_count > post_ids.length ) {

Check failure on line 196 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L196

[prettier/prettier] Insert `↹`

Check failure on line 196 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L196

[camelcase] Identifier 'post_ids_count' is not in camel case.

Check failure on line 196 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L196

[camelcase] Identifier 'post_ids' is not in camel case.
window.location.reload();

Check failure on line 197 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L197

[prettier/prettier] Insert `↹`
}

Check failure on line 198 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L198

[prettier/prettier] Insert `↹`
} );

Check failure on line 199 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L199

[prettier/prettier] Insert `↹`
};

Check failure on line 200 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L200

[prettier/prettier] Delete `;`
}

/**
Expand Down
4 changes: 2 additions & 2 deletions includes/classes/PullListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function column_name( $item ) {

$actions = [
//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- see `wp_fix_server_vars()`.
'pull' => sprintf( '<a href="%s">%s</a>', esc_url( wp_nonce_url( admin_url( 'admin.php?page=pull&action=syndicate&_wp_http_referer=' . rawurlencode( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) . '&post=' . $item->ID . '&connection_type=' . $connection_type . '&connection_id=' . $connection_id . '&pull_post_type=' . $item->post_type . '&dt_as_draft=' . $draft ), 'bulk-distributor_page_pull' ) ), $draft ? esc_html__( 'Pull as draft', 'distributor' ) : esc_html__( 'Pull', 'distributor' ) ),
'pull' => sprintf( '<a href="#">%s</a>', $draft ? esc_html__( 'Pull as draft', 'distributor' ) : esc_html__( 'Pull', 'distributor' ) ),
'view' => '<a href="' . esc_url( $item->link ) . '">' . esc_html__( 'View', 'distributor' ) . '</a>',
//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- see `wp_fix_server_vars()`.
'skip' => sprintf( '<a href="%s">%s</a>', esc_url( wp_nonce_url( admin_url( 'admin.php?page=pull&action=skip&_wp_http_referer=' . rawurlencode( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) . '&post=' . $item->ID . '&connection_type=' . $connection_type . '&connection_id=' . $connection_id ), 'dt_skip' ) ), esc_html__( 'Skip', 'distributor' ) ),
Expand All @@ -355,7 +355,7 @@ public function column_name( $item ) {

$actions = [
//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- see `wp_fix_server_vars()`.
'pull' => sprintf( '<a href="%s">%s</a>', esc_url( wp_nonce_url( admin_url( 'admin.php?page=pull&action=syndicate&_wp_http_referer=' . rawurlencode( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) . '&post=' . $item->ID . '&connection_type=' . $connection_type . '&connection_id=' . $connection_id . '&pull_post_type=' . $item->post_type . '&dt_as_draft=' . $draft ), 'bulk-distributor_page_pull' ) ), $draft ? esc_html__( 'Pull as draft', 'distributor' ) : esc_html__( 'Pull', 'distributor' ) ),
'pull' => sprintf( '<a href="#">%s</a>', $draft ? esc_html__( 'Pull as draft', 'distributor' ) : esc_html__( 'Pull', 'distributor' ) ),
//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- see `wp_fix_server_vars()`.
'unskip' => sprintf( '<a href="%s">%s</a>', esc_url( wp_nonce_url( admin_url( 'admin.php?page=pull&action=unskip&_wp_http_referer=' . rawurlencode( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) . '&post=' . $item->ID . '&connection_type=' . $connection_type . '&connection_id=' . $connection_id ), 'dt_unskip' ) ), esc_html__( 'Unskip', 'distributor' ) ),
'view' => '<a href="' . esc_url( $item->link ) . '">' . esc_html__( 'View', 'distributor' ) . '</a>',
Expand Down
Loading
Loading