Skip to content

Instantly share code, notes, and snippets.

@satouriko
Last active November 10, 2018 19:24
Show Gist options
  • Select an option

  • Save satouriko/ec905d5378fbfbdd585ab63dfd39c609 to your computer and use it in GitHub Desktop.

Select an option

Save satouriko/ec905d5378fbfbdd585ab63dfd39c609 to your computer and use it in GitHub Desktop.

Revisions

  1. satouriko revised this gist Nov 10, 2018. 1 changed file with 22 additions and 4 deletions.
    26 changes: 22 additions & 4 deletions enable-rest-comment.php
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,31 @@
    <?php
    /*
    Plugin Name: Enable Anonymous Rest Comment
    Plugin Name: Activate REST API
    Plugin URI: https://wordpress.org/plugins/enable-anonymous-rest-comment/
    Description: Enable comments via rest api without login.
    Version: 0.1
    Description: Enable comments via rest api without login. Give front-end raw HTML via REST API.
    Version: 0.2
    Author: Cooler
    Author URI: https://gist.github.com/rikakomoe/ec905d5378fbfbdd585ab63dfd39c609
    License: Unlicense
    License URI: https://unlicense.org/
    */

    add_filter( 'rest_allow_anonymous_comments', '__return_true' );
    add_filter( 'rest_allow_anonymous_comments', '__return_true' );
    add_action( 'rest_api_init', function () {
    register_rest_field(
    'page',
    'content',
    array(
    'get_callback' => 'compasshb_do_shortcodes',
    'update_callback' => null,
    'schema' => null,
    )
    );
    });
    function compasshb_do_shortcodes( $object, $field_name, $request ) {
    WPBMap::addAllMappedShortcodes(); // This does all the work
    global $post;
    $post = get_post ($object['id']);
    $output['rendered'] = apply_filters( 'the_content', $post->post_content );
    return $output;
    }
  2. satouriko revised this gist Jun 17, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions enable-rest-comment.php
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    <?php
    /*
    Plugin Name: Enable Anonymous Rest Comment
    Plugin URI: https://developer.wordpress.org/plugins/the-basics/
    Plugin URI: https://wordpress.org/plugins/enable-anonymous-rest-comment/
    Description: Enable comments via rest api without login.
    Version: 0.1
    Author: Cooler
    Author URI: https://developer.wordpress.org/
    Author URI: https://gist.github.com/rikakomoe/ec905d5378fbfbdd585ab63dfd39c609
    License: Unlicense
    License URI: https://unlicense.org/
    */
  3. satouriko created this gist Jun 17, 2018.
    13 changes: 13 additions & 0 deletions enable-rest-comment.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <?php
    /*
    Plugin Name: Enable Anonymous Rest Comment
    Plugin URI: https://developer.wordpress.org/plugins/the-basics/
    Description: Enable comments via rest api without login.
    Version: 0.1
    Author: Cooler
    Author URI: https://developer.wordpress.org/
    License: Unlicense
    License URI: https://unlicense.org/
    */

    add_filter( 'rest_allow_anonymous_comments', '__return_true' );