Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function update_date_job() {
- if( ! isset( $_POST ) || empty( $_POST ) || !current_user_can('administrator') ) {
- // If we don't - return custom error message and exit
- header( 'HTTP/1.1 400 Empty POST Values' );
- echo 'Could Not Verify POST Values.';
- exit;
- }
- $post_id = sanitize_text_field($_POST['post_id']);
- $date = sanitize_text_field($_POST['new_date']);
- $gmtdate = sanitize_text_field($_POST['gmt_date']);
- $my_args = array(
- 'ID' => $post_id,
- 'post_date' => $date,
- 'post_date_gmt' => $gmtdate
- );
- $lan = ICL_LANGUAGE_CODE=='pl'? 'en':'pl';
- $id = icl_object_id($post_id, 'job_listing', false,$lan);
- if(current_user_can('administrator')){
- wp_update_post( $my_args );
- wp_publish_post( $post_id );
- $GLOBALS['wp_fastest_cache']->singleDeleteCache(false, $post_id);
- if(!empty($id)){
- $GLOBALS['wp_fastest_cache']->singleDeleteCache(false, $id);
- // wp_update_post(array(
- // 'ID' => $id,
- // 'post_date' => $date,
- // 'post_date_gmt' => $gmtdate
- // ));
- }
- }
- wp_die();
- }
- add_action( 'wp_ajax_update_date_job', 'update_date_job' );
- $my_args = array(
- 'ID' => $post_id,
- 'post_date' => $date,
- 'post_date_gmt' => $gmtdate,
- 'post_status' => 'publish'
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement