public function update_rc_reserved_content($post_id) { $component = new Class_Rucy_Component(); $post_metas = $component->get_post_rc_meta((int) $post_id); if ($post_metas->accept != "1") { return; } // rollback $rollback_data = array(); if ($post_metas->accept_rollback == "1") { $rollback_data = $this->get_rollback_post((int) $post_id, $post_metas->accept_rollback_date, $post_metas->accept_rollback_feature_img); } // set update content $updates = array('ID' => (int) $post_id, 'post_content' => $post_metas->content); // set update post date if ($post_metas->accept_update == "1") { $updates['post_date'] = $post_metas->date; $updates['post_date_gmt'] = get_gmt_from_date($post_metas->date); } // update post remove_filter('content_save_pre', 'wp_filter_post_kses'); remove_filter('content_filtered_save_pre', 'wp_filter_post_kses'); add_filter('content_save_pre', array($this, 'rc_content_allow_iframe')); wp_update_post($updates, true); remove_filter('content_save_pre', array($this, 'rc_content_allow_iframe')); add_filter('content_save_pre', 'wp_filter_post_kses'); add_filter('content_filtered_save_pre', 'wp_filter_post_kses'); // update feature image if ($post_metas->accept_feature_img == "1" && $post_metas->feature_img != "") { $this->update_post_thumbnail($post_id, $post_metas->feature_img); } // delete post metas $post_meta_keys = $component->get_post_meta_keys(); foreach ($post_meta_keys as $key => $value) { delete_post_meta($post_id, $value); } // clear schedule on wp_cron wp_clear_scheduled_hook(RC_CRON_HOOK, array($post_id)); // save post meta for rollback if ($post_metas->accept_rollback == "1") { $reserve_date = strtotime(get_gmt_from_date($post_metas->rollback_date) . "GMT"); $this->set_rollback_setting($post_id, $reserve_date, $rollback_data); } }
public function add_rucy_col($column_name, $post_id) { $component = new Class_Rucy_Component(); $post_metas = $component->get_post_rc_meta($post_id); if ($column_name == 'rucy_reservation_date') { if ($post_metas->accept == "1") { echo $post_metas->date; } else { _e('None'); } } if ($column_name == 'rucy_rollback_date') { if ($post_metas->accept_rollback == "1") { echo $post_metas->rollback_date; } else { _e('None'); } } }
public function add_reservation_message($messages) { global $post, $post_ID; $component = new Class_Rucy_Component(); $accept_post_types = $component->get_support_post_type(); $post_type = get_post_type($post); if (!in_array($post_type, $accept_post_types)) { return $messages; } $post_metas = $component->get_post_rc_meta($post_ID); if ($post_metas->accept != "1") { return $messages; } $add_message_date = date_i18n('Y/m/d @ H:i', strtotime($post_metas->date)); $base_str = __('registered reservation update content _RC_DATETIME_', RC_TXT_DOMAIN); $add_message = '<br>' . strtr($base_str, array('_RC_DATETIME_' => $add_message_date)); if ($post_metas->accept_rollback == "1") { $rollback_date = date_i18n('Y/m/d @ H:i', strtotime($post_metas->rollback_date)); $rollback_base_str = __('registered rollback content _RC_ROLLBACK_DATETIME_ ', RC_TXT_DOMAIN); $add_message .= '<br>' . strtr($rollback_base_str, array('_RC_ROLLBACK_DATETIME_' => $rollback_date)); } // published $messages[$post_type][1] .= $add_message; $messages[$post_type][4] .= $add_message; $messages[$post_type][6] .= $add_message; // saved $messages[$post_type][7] .= $add_message; // submited $messages[$post_type][8] .= $add_message; // scheduled $messages[$post_type][9] .= $add_message; return $messages; }