function update_object_content($object_type, $object_ID, $updated_content) { $updated_object = false; if ('post' == $object_type) { o2_Fragment::bump_post($object_ID, $updated_content); $updated_object = get_post($object_ID); } else { $comment_data = array('comment_ID' => $object_ID, 'comment_content' => $updated_content); // purposefully throw away the comment global otherwise get_comment will return // the pre-updated copy from $GLOBALS if (isset($GLOBALS['comment'])) { unset($GLOBALS['comment']); } wp_update_comment($comment_data); update_comment_meta($object_ID, 'o2_comment_gmt_modified', time()); $updated_object = get_comment($object_ID); // update the global $GLOBALS['comment'] = $updated_object; } return $updated_object; }
/** * Main AJAX callback * * @param object The post fragment object */ function callback($post_data) { if (!property_exists($post_data, 'postID') || !property_exists($post_data, 'isSticky')) { self::die_failure('invalid_message', __('Insufficient information provided.', 'o2')); } $post = get_post(absint($post_data->postID)); if (!$post) { self::die_failure('post_not_found', __('Post not found.', 'o2')); } if (!current_user_can('edit_post', $post->ID)) { self::die_failure('cannot_edit_post_sticky', __('You are not allowed to edit this post sticky.', 'o2')); } if ($post_data->isSticky) { stick_post($post->ID); } else { unstick_post($post->ID); } // Bump the post to make it update in polling o2_Fragment::bump_post($post->ID); $retval = array('isSticky' => is_sticky($post->ID)); self::die_success($retval); }
/** * Process a post's state change by updating the post state and adding an audit log * * @param int The post ID * @param string The next state slug */ function change_post_state($post_id, $next_state) { $success = self::set_post_state($post_id, $next_state); if (is_wp_error($success)) { return $success; } // Record change to audit log $args = array('new_state' => $next_state); $args = self::add_audit_log($post_id, $args); // Update post for polling o2_Fragment::bump_post($post_id); return $args; }