Update post status

@param int $post_id
@param string $status
967565
protected function updatePost( $post_id, $status ) {

		$post = get_post( $post_id, 'ARRAY_A' );
		if ( empty( $post ) ) {
			return;
		}

		global $wpdb;
		$menu_order = $wpdb->get_var(
			$wpdb->prepare(
				"SELECT MAX(menu_order) FROM {$wpdb->posts} WHERE post_type = %s AND post_parent = %d AND ID != %d ",
				$post['post_type'],
				$post['post_parent'],
				$post_id
			)
		);
		if ( $menu_order !== null ) {
			$post['menu_order'] = $menu_order + 1;
		}

		$post['post_status'] = $status;

		wp_update_post( $post );
	}
79916
protected function update_the_post( array $post_data ) {
		global $wpdb;

		if ( ! $this->exists() || empty( $post_data ) ) {
			return;
		}

		if ( doing_action( 'save_post' ) || 0 === strpos( current_action(), 'save_post' ) ) {
			$updated = $wpdb->update( $wpdb->posts, $post_data, [ 'ID' => $this->get_id() ] );
		} else {
			$updated = wp_update_post( array_merge( [ 'ID' => $this->get_id() ], $post_data ) );
		}

		clean_post_cache( $this->get_id() );

		return ( 0 !== $updated && false !== $updated );
	}
686201
public function save_post($post_id, \WP_Post $post ){
        // Skip auto save
        if( wp_is_post_revision($post) || wp_is_post_autosave($post) ){
            return;
        }
        // Check Nonce
        if( !$this->verify_nonce() ){
            return;
        }
        // O.K., let's save
        foreach( $this->loop_fields() as $field ){
            try{
                if( is_wp_error($field) ){
                    /** @var \WP_Error $field */
                    throw new \Exception($field->get_error_message(), $field->get_error_code());
                }
                if( !$this->is_override_field($field->name) ){
                    /** @var \WPametu\UI\Field\Base $field */
                    $field->update($this->input->post($field->name), $post);
                }
            }catch ( \Exception $e ){
                $this->prg->addErrorMessage($e->getMessage());
            }

        }
    }
1173982
public static function updateOrderStatus($orderId, $status, $comments) {
        $body = array("status" => $status, "comments" => $comments);
        $response = self::requestApi("put", $body, $orderId);
        return $response->isOk();
    }
207934
protected function updatePage($page_id)
    {
        if (!$this->isError() && !$this->page->update($page_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
175116
def update_status(status)
      if status.present?
        RRRSpec.redis.hset(key, 'status', status)
      else
        RRRSpec.redis.hdel(key, 'status')
      end
    end
492136
public function setOrderStatus($orderId, $status, $subStatus = null)
    {
        $resource = 'campaigns/' . $this->campaignId . '/orders/' . $orderId . '/status.json';

        $data = [
            "order" => [
                "status" => $status
            ]
        ];
        if ($subStatus) {
            $data['order']['substatus'] = $subStatus;
        }

        $response = $this->sendRequest(
            'PUT',
            $this->getServiceUrl($resource),
            [
                'json' => $data
            ]
        );

        $decodedResponseBody = $this->getDecodedBody($response->getBody());

        $updateOrderStatusResponse = new UpdateOrderStatusResponse($decodedResponseBody);
        return $updateOrderStatusResponse->getOrder();
    }
1314093
protected function handle_status_param( $post_status, $post_type ) {

		switch ( $post_status ) {
			case 'draft':
			case 'pending':
				break;
			case 'private':
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
					return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to create private posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
				}
				break;
			case 'publish':
			case 'future':
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
					return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to publish posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
				}
				break;
			default:
				if ( ! get_post_status_object( $post_status ) ) {
					$post_status = 'draft';
				}
				break;
		}

		return $post_status;
	}
751734
public function postupdateNotExist($post_id)
    {
        if ($this->countPostUpdates($post_id) == 0)
        {
            DB::table('posts')
                ->where('id', '=', $post_id)
                ->update(['postupdate' => 0])
            ;
        }
    }
1195055
def update_status(self, callback_function_param=False):
        
        self.logger.debug("Receiver:Updating status")
        self.send_message({MESSAGE_TYPE: TYPE_GET_STATUS},
                          callback_function=callback_function_param)
482569
def update_status(self, new_status):
        """"""
        timestamp = time.time()
        self.status_history[-1]["end"] = timestamp
        self.status_history.append(
            {"start": timestamp, "end": None, "status": new_status}
        )
1282458
public function setStatus($status)
    {
        if ($status == PageStatus::PUBLISHED && $this->publishedAt === null) {
            $this->setPublishedAt(new \DateTime());
        }
        $this->status = $status;
    }
52188
public function setNearByPoiShowStatus($poi_id, $status)
    {
        $url = "https://api.weixin.qq.com/wxa/setnearbypoishowstatus?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, ['poi_id' => $poi_id, 'status' => $status], true);
    }
686073
protected function setStatusReview($status)
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

        if (!isset($id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        if (isset($id) && (empty($id) || !is_numeric($id))) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $options = null;

        if (isset($id)) {

            if ($this->getParam('user')) {
                $options = array('user_id' => $id);
            } else if ($this->getParam('product')) {
                $options = array('product_id' => $id);
            }

        } else if (!empty($all)) {
            $options = array();
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->review->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->review->update($item['review_id'], array('status' => $status));
            }

            $result = $count && $count == $deleted;

        } else if (!empty($id)) {
            $result = $this->review->update($id, array('status' => $status));
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
257068
public function updateStatus(Job $job, int $status): void
    {
        $id = sprintf('job:%s:status', $job->getId());
        $packet = [
            'status' => $status,
            'updated' => time(),
        ];

        $this->client->set($id, json_encode($packet));

        if (in_array($status, JobManager::COMPLETED_STATUSES, false)) {
            $this->client->expire($id, 86400);
        }
    }
506282
public function setStatus($id, $status)
    {
        if (!is_numeric($status)) {
            throw new Exception('Status argument must be an integer');
        }

        $entity = $this->findById($id)->firstOrFail();
        $entity->status = $status;
        $this->save($entity);

        return $entity;
    }
584778
public function update($post_id, string $key, $value, $where = '')
    {
        $post_id = (int) ($post_id ?? get_the_ID());

        if (!$post_id || !$key) {
            return; // Not possible.
        }
        update_post_meta($post_id, $this->key($key), $value, $where);
    }