Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cptr_save() {
- global $post_ID;
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
- if (!isset($_POST['myplugin_noncename'])) return;
- if (!wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__))) return;
- if (!current_user_can( 'edit_post', $post_ID ) ) return;
- $id = $_POST['post_ID'];
- $related = isset($_POST['reladded']) ? $_POST['reladded'] : array();
- update_post_meta($id, CI_CPTR_POST_RELATED, $related);
- $update_later = get_option('ci_cptr_temp_update_later');
- if($update_later===false) $update_later = array();
- $update_later[$post_ID] = $related;
- update_option('ci_cptr_temp_update_later', $update_later);
- }
- add_action('init', 'ci_cptr_update_later');
- function ci_cptr_update_later()
- {
- if(!is_admin()) return;
- $update_later = get_option('ci_cptr_temp_update_later');
- if($update_later===false) $update_later = array();
- foreach($update_later as $key=>$value)
- {
- // You can use $key as the ID of the post that the $rel_id's were associated from.
- foreach ($value as $rel_id) {
- $my_post = array( 'id' => $rel_id, 'post_status' => 'publish');
- wp_update_post( $my_post );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement