| 1 |
( function( $ ) { |
| 2 |
const duplicatePost = function duplicatePost( e ) { |
| 3 |
e.preventDefault(); |
| 4 |
|
| 5 |
const _self = $( this ), |
| 6 |
_id = _self.data( 'post-id' ); |
| 7 |
|
| 8 |
$.ajax( { |
| 9 |
url: '', |
| 10 |
data: { |
| 11 |
'lp-ajax': 'duplicator', |
| 12 |
id: _id, |
| 13 |
}, |
| 14 |
success( response ) { |
| 15 |
response = LP.parseJSON( response ); |
| 16 |
|
| 17 |
if ( response.success ) { |
| 18 |
window.location.href = response.data; |
| 19 |
} else { |
| 20 |
alert( response.data ); |
| 21 |
} |
| 22 |
}, |
| 23 |
} ); |
| 24 |
}; |
| 25 |
|
| 26 |
$( function() { |
| 27 |
$( document ).on( 'click', '.lp-duplicate-row-action .lp-duplicate-post', duplicatePost ); |
| 28 |
} ); |
| 29 |
}( jQuery ) ); |
| 30 |
|