|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace GFPDF\Api\V1; |
| 4 | + |
| 5 | +use GFPDF\Helper\Helper_Trait_Logger; |
| 6 | + |
| 7 | +/** |
| 8 | + * @package Gravity PDF |
| 9 | + * @copyright Copyright (c) 2019, Blue Liquid Designs |
| 10 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 11 | + * @since 5.2 |
| 12 | + */ |
| 13 | + |
| 14 | +/* Exit if accessed directly */ |
| 15 | +if ( ! defined( 'ABSPATH' ) ) { |
| 16 | + exit; |
| 17 | +} |
| 18 | + |
| 19 | +/* |
| 20 | + This file is part of Gravity PDF. |
| 21 | +
|
| 22 | + Gravity PDF – Copyright (c) 2019, Blue Liquid Designs |
| 23 | +
|
| 24 | + This program is free software; you can redistribute it and/or modify |
| 25 | + it under the terms of the GNU General Public License as published by |
| 26 | + the Free Software Foundation; either version 2 of the License, or |
| 27 | + (at your option) any later version. |
| 28 | +
|
| 29 | + This program is distributed in the hope that it will be useful, |
| 30 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 31 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 32 | + GNU General Public License for more details. |
| 33 | +
|
| 34 | + You should have received a copy of the GNU General Public License |
| 35 | + along with this program; if not, write to the Free Software |
| 36 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 37 | +*/ |
| 38 | + |
| 39 | +/** |
| 40 | + * Class Base_Api |
| 41 | + * |
| 42 | + * @package GFPDF\Api\V1 |
| 43 | + * |
| 44 | + * @since 5.2 |
| 45 | + */ |
| 46 | +abstract class Base_Api { |
| 47 | + |
| 48 | + /** |
| 49 | + * @since 5.2 |
| 50 | + */ |
| 51 | + use Helper_Trait_Logger; |
| 52 | + |
| 53 | + /** |
| 54 | + * @since 5.2 |
| 55 | + */ |
| 56 | + const ENTRYPOINT = 'gravity-pdf'; |
| 57 | + |
| 58 | + /** |
| 59 | + * @since 5.2 |
| 60 | + */ |
| 61 | + const VERSION = 'v1'; |
| 62 | + |
| 63 | + /** |
| 64 | + * Initialise our endpoint |
| 65 | + * |
| 66 | + * @since 5.2 |
| 67 | + */ |
| 68 | + public function init() { |
| 69 | + add_action( 'rest_api_init', [ $this, 'register' ] ); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Simple wrapper to check the current user's capabilities in the context of Gravity Forms |
| 74 | + * |
| 75 | + * @param string $capability |
| 76 | + * |
| 77 | + * @return bool |
| 78 | + * |
| 79 | + * @since 5.2 |
| 80 | + */ |
| 81 | + public function has_capabilities( $capability ) { |
| 82 | + $gform = \GPDFAPI::get_form_class(); |
| 83 | + return $gform->has_capability( $capability ); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Register WordPress REST API endpoint(s) |
| 88 | + * |
| 89 | + * @return void |
| 90 | + * |
| 91 | + * @internal Use `register_rest_route()` to register WordPress REST API endpoint(s) |
| 92 | + * |
| 93 | + * @since 5.2 |
| 94 | + */ |
| 95 | + abstract public function register(); |
| 96 | +} |
0 commit comments