Changeset 2389074
- Timestamp:
- 09/27/2020 08:38:18 AM (6 years ago)
- Location:
- replybox/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
replybox.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
replybox/trunk/readme.txt
r2332070 r2389074 3 3 Tags: comment, comments 4 4 Requires at least: 4.7 5 Tested up to: 5. 4.25 Tested up to: 5.5.1 6 6 Requires PHP: 5.4 7 Stable tag: 0.4 7 Stable tag: 0.4.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 29 29 == Changelog == 30 30 31 = 0.4.1 = 32 * Don't show the ReplyBox embed on WooCommerce product pages. 33 * Fix "PHP Notice: register_rest_route was called incorrectly". 34 31 35 = 0.4 = 32 36 * Enable linking to individual comments. … … 40 44 = 0.1 = 41 45 * Initial release. 46 47 48 -
replybox/trunk/replybox.php
r2023912 r2389074 3 3 * Plugin Name: ReplyBox 4 4 * Description: A simple, honest comment system which works everywhere. No ads, no dodgy affiliate links, no fluff. 5 * Version: 0.4 5 * Version: 0.4.1 6 6 * Author: ReplyBox 7 7 * Author URI: https://getreplybox.com … … 88 88 * 89 89 * @param string $key 90 * @param mixed $default90 * @param mixed $default 91 91 * 92 92 * @return mixed … … 180 180 public function register_api_endpoints() { 181 181 register_rest_route( 'replybox/v1', '/comments', array( 182 'methods' => 'GET', 183 'callback' => array( $this, 'get_comments_endpoint' ), 184 'args' => array( 182 'methods' => 'GET', 183 'callback' => array( $this, 'get_comments_endpoint' ), 184 'permission_callback' => '__return_true', 185 'args' => array( 185 186 'page' => array( 186 187 'default' => 1, … … 203 204 204 205 register_rest_route( 'replybox/v1', '/comments', array( 205 'methods' => 'POST', 206 'callback' => array( $this, 'post_comments_endpoint' ), 207 'args' => array( 206 'methods' => 'POST', 207 'callback' => array( $this, 'post_comments_endpoint' ), 208 'permission_callback' => '__return_true', 209 'args' => array( 208 210 'token' => array( 209 211 'required' => true, … … 214 216 215 217 register_rest_route( 'replybox/v1', '/comments', array( 216 'methods' => 'PATCH', 217 'callback' => array( $this, 'patch_comments_endpoint' ), 218 'args' => array( 218 'methods' => 'PATCH', 219 'callback' => array( $this, 'patch_comments_endpoint' ), 220 'permission_callback' => '__return_true', 221 'args' => array( 219 222 'token' => array( 220 223 'required' => true, … … 225 228 226 229 register_rest_route( 'replybox/v1', '/comments', array( 227 'methods' => 'DELETE', 228 'callback' => array( $this, 'delete_comments_endpoint' ), 229 'args' => array( 230 'methods' => 'DELETE', 231 'callback' => array( $this, 'delete_comments_endpoint' ), 232 'permission_callback' => '__return_true', 233 'args' => array( 230 234 'token' => array( 231 235 'required' => true, … … 314 318 * 315 319 * @return array|WP_Error 316 */ 320 */ 317 321 public function patch_comments_endpoint( $request ) { 318 322 if ( $this->get_option( 'secure_token' ) !== $request['token'] ) { … … 344 348 * 345 349 * @return array|WP_Error 346 */ 350 */ 347 351 public function delete_comments_endpoint( $request ) { 348 352 if ( $this->get_option( 'secure_token' ) !== $request['token'] ) { … … 392 396 * Replace the default WordPress comments. 393 397 * 398 * @param string $file 399 * 394 400 * @return string 395 401 */ 396 public function comments_template( ) {402 public function comments_template( $file ) { 397 403 global $post; 404 405 if ( ! $this->should_show_comment_embed( $post ) ) { 406 return $file; 407 } 398 408 399 409 wp_enqueue_script( 'replybox-js', $this->get_embed_url(), array(), null, true ); … … 407 417 408 418 /** 419 * Should we show the comment embed? 420 * 421 * @param WP_Post $post 422 * 423 * @return bool 424 */ 425 protected function should_show_comment_embed( $post ) { 426 $show_embed = is_singular() && post_type_supports( $post->post_type, 'comments' ); 427 428 if ( function_exists( 'is_product' ) && is_product() ) { 429 $show_embed = false; 430 } 431 432 return apply_filters( 'replybox_show_embed', $show_embed, $post ); 433 } 434 435 /** 409 436 * Filter a single comment link. 410 437 * 411 438 * @param string $link 439 * 412 440 * @return string 413 441 */ … … 416 444 $id = get_comment_meta( $comment->comment_ID, 'replybox_id', true ); 417 445 418 if ( $id) {446 if ( $id ) { 419 447 $hash = '#comment-' . $id; 420 448 } … … 427 455 * 428 456 * @param string $link 457 * 429 458 * @return string 430 459 */ … … 459 488 * 460 489 * @param array $stats 461 * @param int $post_id490 * @param int $post_id 462 491 * 463 492 * @return bool|mixed|object
Note: See TracChangeset
for help on using the changeset viewer.