• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Jetpack a2z

Jetpack a2z

Jetpack a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / Files / json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php


Lines:

1 to 100 of 157
<?php

new WPCOM_JSON_API_Update_Post_v1_2_Endpoint( array(
  'description' => 'Create a post.',
  'group'       => 'posts',
  'stat'        => 'posts:new',
  'min_version' => '1.2',
  'max_version' => '1.2',
  'method'      => 'POST',
  'path'        => '/sites/%s/posts/new',
  'path_labels' => array(
    '$site' => '(int|string) Site ID or domain',
  ),
  'query_parameters' => array(
    'autosave' => '(bool) True if the post was saved automatically.',
  ),

  'request_format' => array(
    // explicitly document all input
    'date'      => "(ISO 8601 datetime) The post's creation time.",
    'title'     => '(HTML) The post title.',
    'content'   => '(HTML) The post content.',
    'excerpt'   => '(HTML) An optional post excerpt.',
    'slug'      => '(string) The name (slug) for the post, used in URLs.',
    'author'    => '(string) The username or ID for the user to assign the post to.',
    'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.',
    'publicize_message' => '(string) Custom message to be publicized to external services.',
    'status'    => array(
      'publish' => 'Publish the post.',
      'private' => 'Privately publish the post.',
      'draft'   => 'Save the post as a draft.',
      'pending' => 'Mark the post as pending editorial approval.',
      'future'  => 'Schedule the post (alias for publish; you must also set a future date).',
      'auto-draft' => 'Save a placeholder for a newly created post, with no content.',
    ),
    'sticky'    => array(
      'false'   => 'Post is not marked as sticky.',
      'true'    => 'Stick the post to the front page.',
    ),
    'password'  => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
    'parent'    => "(int) The post ID of the new post's parent.",
    'type'      => "(string) The post type. Defaults to 'post'. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.",
    'terms'      => '(object) Mapping of taxonomy to comma-separated list or array of term names',
    'categories' => "(array|string) Comma-separated list or array of category names",
    'tags'       => "(array|string) Comma-separated list or array of tag names",
    'terms_by_id'      => '(object) Mapping of taxonomy to comma-separated list or array of term IDs',
    'categories_by_id' => "(array|string) Comma-separated list or array of category IDs",
    'tags_by_id'       => "(array|string) Comma-separated list or array of tag IDs",
    'format'     => array_merge( array( 'default' => 'Use default post format' ), get_post_format_strings() ),
    'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.",
    'media'      => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options response of the site endpoint. Errors produced by media uploads, if any, will be in `media_errors` in the response. <br /><br /><strong>Example</strong>:<br />" .
             "<code>curl \<br />--form 'title=Image Post' \<br />--form 'media[0]=@/path/to/file.jpg' \<br />--form 'media_attrs[0][caption]=My Great Photo' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
    'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post. Errors produced by media sideloading, if any, will be in `media_errors` in the response.",
    'media_attrs' => "(array) An array of attributes (`title`, `description` and `caption`) are supported to assign to the media uploaded via the `media` or `media_urls` properties. You must use a numeric index for the keys of `media_attrs` which follow the same sequence as `media` and `media_urls`. <br /><br /><strong>Example</strong>:<br />" .
                     "<code>curl \<br />--form 'title=Gallery Post' \<br />--form 'media[]=@/path/to/file1.jpg' \<br />--form 'media_urls[]=http://exapmple.com/file2.jpg' \<br /> \<br />--form 'media_attrs[0][caption]=This will be the caption for file1.jpg' \<br />--form 'media_attrs[1][title]=This will be the title for file2.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
    'metadata'      => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are avaiable for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.",
    'discussion'    => '(object) A hash containing one or more of the following boolean values, which default to the blog\'s discussion preferences: `comments_open`, `pings_open`',
    'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.",
    'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.",
    'menu_order'    => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.",
    'page_template' => '(string) (Pages Only) The page template this page should use.',
  ),

  'example_request'      => 'https://public-api.wordpress.com/rest/v1.2/sites/82974409/posts/new/',

  'example_request_data' => array(
    'headers' => array(
      'authorization' => 'Bearer YOUR_API_TOKEN'
    ),

    'body' => array(
      'title'      => 'Hello World',
      'content'    => 'Hello. I am a test post. I was created by the API',
      'tags'       => 'tests',
      'categories' => 'API'
    )
  )
) );

new WPCOM_JSON_API_Update_Post_v1_2_Endpoint( array(
  'description' => 'Edit a post.',
  'group'       => 'posts',
  'stat'        => 'posts:1:POST',
  'min_version' => '1.2',
  'max_version' => '1.2',
  'method'      => 'POST',
  'path'        => '/sites/%s/posts/%d',
  'path_labels' => array(
    '$site'    => '(int|string) Site ID or domain',
    '$post_ID' => '(int) The post ID',
  ),
  'query_parameters' => array(
    'autosave' => '(bool) True if the post was saved automatically.',
  ),

  'request_format' => array(
    'date'      => "(ISO 8601 datetime) The post's creation time.",
    'title'     => '(HTML) The post title.',
    'content'   => '(HTML) The post content.',
    'excerpt'   => '(HTML) An optional post excerpt.',
[1] [2] Next »

 View on GitHub View on Trac

Called by

    Invoked by

      Calls

      Call hooks

      File name: json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php
      Plugin ref: Jetpack
      Version: 9.2
      Deprecated?: No
      API Letters: C,E,J,W

      Related

      Published: 27 November 2019 | Last updated: 10 December 2020

      Primary Sidebar

      Information

      File name: json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php
      Plugin ref: Jetpack
      Version: 9.2
      Deprecated?: No
      API Letters: C,E,J,W

      json-endpoints

      Footer

      Jetpack a2z
      Jetpack a2z
      Jetpack a2z
      WordPress 5.6
      WordPress a2z
      WordPress core a2z
      Genesis Theme Framework a2z
      Jetpack a2z
      WordPress develop tests
      Easy Digital Downloads a2z
      WooCommerce a2z
      Yoast SEO a2z
      WordPress Blocks

      Site:  jetpack.wp-a2z.org
      © Copyright Jetpack a2z 2014-2021. All rights reserved.


      Website designed and developed by Herb Miller
      Proudly powered by WordPress and oik plugins

      • Home
      • Blog
      • Sitemap
      • Sites