views
3 weeks ago
FileList.php
5 years ago
Hooks.php
3 years ago
Package.php
1 year ago
PackageController.php
4 days ago
PackageLocks.php
2 weeks ago
PackageTemplate.php
5 years ago
RestAPI.php
4 days ago
Shortcodes.php
1 week ago
RestAPI.php
45 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace WPDM\Package; |
| 5 | |
| 6 | |
| 7 | class RestAPI |
| 8 | { |
| 9 | |
| 10 | function __construct() |
| 11 | { |
| 12 | add_action('rest_api_init', array($this, 'introduceEndpoints')); |
| 13 | } |
| 14 | |
| 15 | function introduceEndpoints() |
| 16 | { |
| 17 | |
| 18 | register_rest_route('wpdm', '/validate-captcha', array( |
| 19 | 'methods' => 'POST', |
| 20 | 'callback' => [new PackageLocks(), 'validateCaptcha'], |
| 21 | 'permission_callback' => '__return_true' |
| 22 | )); |
| 23 | |
| 24 | register_rest_route('wpdm', '/validate-password', array( |
| 25 | 'methods' => 'POST', |
| 26 | 'callback' => [new PackageLocks(), 'validatePassword'], |
| 27 | 'permission_callback' => '__return_true' |
| 28 | )); |
| 29 | |
| 30 | register_rest_route('wpdm', '/search', array( |
| 31 | 'methods' => 'GET', |
| 32 | 'callback' => [new PackageController(), 'search'], |
| 33 | 'permission_callback' => '__return_true' |
| 34 | )); |
| 35 | |
| 36 | // NOTE: The POST /wpdm/view-count route was removed. It exposed a |
| 37 | // state-changing write (__wpdm_view_count post meta, on any post ID) |
| 38 | // to unauthenticated callers via permission_callback => '__return_true'. |
| 39 | // Nothing in the plugin ever called it - view counts are recorded |
| 40 | // through the 'wpdm_view_count' admin-ajax action (see addViewCount()), |
| 41 | // which verifies a nonce and constrains the ID to the wpdmpro type. |
| 42 | |
| 43 | } |
| 44 | } |
| 45 |