Collaboration
3 weeks ago
Apps.php
3 weeks ago
Collection.php
1 month ago
Comments.php
2 months ago
DynamicContent.php
1 month ago
ExportImport.php
3 weeks ago
Form.php
3 weeks ago
Media.php
3 weeks ago
Page.php
3 weeks ago
PageSettings.php
3 weeks ago
RBAC.php
3 weeks ago
Symbol.php
3 weeks ago
Taxonomy.php
2 months ago
TemplateExportImport.php
2 months ago
UserData.php
3 weeks ago
Users.php
2 months ago
Walkthrough.php
2 months ago
WordpressData.php
2 months ago
WpAdmin.php
2 months ago
Comments.php
65 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Dynamic content/Collection API |
| 4 | * |
| 5 | * @package kirki |
| 6 | */ |
| 7 | |
| 8 | namespace Kirki\Ajax; |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; // Exit if accessed directly. |
| 12 | } |
| 13 | |
| 14 | use Kirki\HelperFunctions; |
| 15 | |
| 16 | /** |
| 17 | * Comments API Class |
| 18 | */ |
| 19 | class Comments { |
| 20 | |
| 21 | /** |
| 22 | * Get collection return api response |
| 23 | * |
| 24 | * @return void wpjson response |
| 25 | */ |
| 26 | public static function get_comments() { |
| 27 | $sorting_param = HelperFunctions::sanitize_text( isset( $_GET['sorting'] ) ? $_GET['sorting'] : null ); |
| 28 | $filter_param = HelperFunctions::sanitize_text( isset( $_GET['filters'] ) ? $_GET['filters'] : null ); |
| 29 | $post_parent = HelperFunctions::sanitize_text( $_GET['post_parent'] ?? 0 ); |
| 30 | $comment_parent = HelperFunctions::sanitize_text( $_GET['comment_parent'] ?? 0 ); |
| 31 | $comment_type = HelperFunctions::sanitize_text( $_GET['comment_type'] ?? 'comment' ); |
| 32 | $item_per_page = HelperFunctions::sanitize_text( $_GET['items'] ?? 3 ); |
| 33 | $current_page = HelperFunctions::sanitize_text( $_GET['current_page'] ?? 1 ); |
| 34 | $offset = HelperFunctions::sanitize_text( $_GET['offset'] ?? 0 ); |
| 35 | |
| 36 | $sorting = null; |
| 37 | $filters = null; |
| 38 | |
| 39 | if ( isset( $sorting_param ) ) { |
| 40 | $sorting = json_decode( stripslashes( $sorting_param ), true ); |
| 41 | } |
| 42 | |
| 43 | if ( isset( $filter_param ) ) { |
| 44 | $filters = json_decode( stripslashes( $filter_param ), true ); |
| 45 | } |
| 46 | |
| 47 | $comments = HelperFunctions::get_comments( |
| 48 | array( |
| 49 | 'parent' => $comment_parent, |
| 50 | 'post_id' => $post_parent, |
| 51 | 'type' => $comment_type, |
| 52 | 'offset' => $offset, |
| 53 | 'sorting' => $sorting, |
| 54 | 'filters' => $filters, |
| 55 | 'item_per_page' => $item_per_page, |
| 56 | 'current_page' => $current_page, |
| 57 | ) |
| 58 | ); |
| 59 | |
| 60 | wp_send_json( $comments ); |
| 61 | |
| 62 | die(); |
| 63 | } |
| 64 | } |
| 65 |