Created
November 2, 2017 19:19
-
-
Save westonruter/eafb9954821d4849aedfc5aa61a049c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/functions.php b/functions.php | |
index 53a8d2a..e554773 100644 | |
--- a/functions.php | |
+++ b/functions.php | |
@@ -152,40 +152,40 @@ function picard_get_json( $_post ) { | |
add_filter( 'json_prepare_post', 'picard_get_json' ); | |
-function picard_api_init() { | |
- global $picard_api_comments; | |
- | |
- $picard_api_comments = new Picard_API_Comments(); | |
- add_filter( 'json_endpoints', array( $picard_api_comments, 'register_routes' ) ); | |
-} | |
-add_action( 'wp_json_server_before_serve', 'picard_api_init' ); | |
- | |
-class Picard_API_Comments extends WP_JSON_Comments { | |
- public function register_routes( $routes ) { | |
- $routes['/picard/comments'] = array( | |
- array( array( $this, 'new_post' ), WP_JSON_Server::CREATABLE ), | |
- ); | |
- | |
- return $routes; | |
- } | |
- | |
- public function new_post() { | |
- | |
- $commentdata = array( | |
- 'comment_post_ID' => $_POST['comment_post_ID'], | |
- 'comment_author' => $_POST['comment_author'], | |
- 'comment_author_email' => $_POST['comment_author_email'], | |
- 'comment_author_url' => $_POST['comment_author_url'], | |
- 'comment_content' => $_POST['content'], | |
- 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], | |
- 'comment_type' => '', | |
- ); | |
- $comment_id = wp_new_comment( $commentdata ); | |
- | |
- $new_comment = get_comment( $comment_id ); | |
- | |
- $prepared_comment = $this->prepare_comment( $new_comment ); | |
- | |
- return ( $comment_id ) ? $prepared_comment : array(); | |
- } | |
-} | |
+//function picard_api_init() { | |
+// global $picard_api_comments; | |
+// | |
+// $picard_api_comments = new Picard_API_Comments(); | |
+// add_filter( 'json_endpoints', array( $picard_api_comments, 'register_routes' ) ); | |
+//} | |
+//add_action( 'wp_json_server_before_serve', 'picard_api_init' ); | |
+// | |
+//class Picard_API_Comments extends WP_REST_Comments_Controller { | |
+// public function register_routes( $routes ) { | |
+// $routes['/picard/comments'] = array( | |
+// array( array( $this, 'new_post' ), WP_REST_Server::CREATABLE ), | |
+// ); | |
+// | |
+// return $routes; | |
+// } | |
+// | |
+// public function new_post( ) { | |
+// | |
+// $commentdata = array( | |
+// 'comment_post_ID' => $_POST['comment_post_ID'], | |
+// 'comment_author' => $_POST['comment_author'], | |
+// 'comment_author_email' => $_POST['comment_author_email'], | |
+// 'comment_author_url' => $_POST['comment_author_url'], | |
+// 'comment_content' => $_POST['content'], | |
+// 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], | |
+// 'comment_type' => '', | |
+// ); | |
+// $comment_id = wp_new_comment( $commentdata ); | |
+// | |
+// $new_comment = get_comment( $comment_id ); | |
+// | |
+// $prepared_comment = $this->prepare_item_for_response( $new_comment ); | |
+// | |
+// return ( $comment_id ) ? $prepared_comment : array(); | |
+// } | |
+//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment