WP_Customize_Manager::changeset_post_id PHP Method

changeset_post_id() public method

Get the changeset post id for the loaded changeset.
Since: 4.7.0
public changeset_post_id ( ) : integer | null
return integer | null Post ID on success or null if there is no post yet saved.
    public function changeset_post_id()
    {
        if (!isset($this->_changeset_post_id)) {
            $post_id = $this->find_changeset_post_id($this->_changeset_uuid);
            if (!$post_id) {
                $post_id = false;
            }
            $this->_changeset_post_id = $post_id;
        }
        if (false === $this->_changeset_post_id) {
            return null;
        }
        return $this->_changeset_post_id;
    }

Usage Example

 /**
  * Test WP_Customize_Manager::changeset_post_id().
  *
  * @ticket 30937
  * @covers WP_Customize_Manager::changeset_post_id()
  */
 function test_changeset_post_id()
 {
     $uuid = wp_generate_uuid4();
     $wp_customize = new WP_Customize_Manager(array('changeset_uuid' => $uuid));
     $this->assertNull($wp_customize->changeset_post_id());
     $uuid = wp_generate_uuid4();
     $wp_customize = new WP_Customize_Manager(array('changeset_uuid' => $uuid));
     $post_id = $this->factory()->post->create(array('post_name' => $uuid, 'post_type' => 'customize_changeset', 'post_status' => 'auto-draft', 'post_content' => '{}'));
     $this->assertEquals($post_id, $wp_customize->changeset_post_id());
 }
All Usage Examples Of WP_Customize_Manager::changeset_post_id
WP_Customize_Manager