abstract-term-modifier.php
1 year ago
base-term-action.php
1 year ago
insert-action.php
1 year ago
term-id-property.php
1 year ago
term-meta-property.php
1 year ago
term-modifier.php
1 year ago
term-name-property.php
1 year ago
term-parent-id-property.php
1 year ago
term-slug-property.php
1 year ago
term-taxonomy-property.php
1 year ago
update-action.php
6 months ago
base-term-action.php
66 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JFB_Modules\Actions_V2\Insert_Term\Properties; |
| 4 | |
| 5 | use Jet_Form_Builder\Actions\Methods\Base_Modifier_Action; |
| 6 | |
| 7 | // If this file is called directly, abort. |
| 8 | if ( ! defined( 'WPINC' ) ) { |
| 9 | die; |
| 10 | } |
| 11 | |
| 12 | abstract class Base_Term_Action extends Base_Modifier_Action { |
| 13 | |
| 14 | protected $inserted_id = 0; |
| 15 | |
| 16 | /** |
| 17 | * Inserted ID getter. |
| 18 | * |
| 19 | * @return integer |
| 20 | */ |
| 21 | public function get_inserted_id(): int { |
| 22 | return $this->inserted_id; |
| 23 | } |
| 24 | |
| 25 | public function do_after() { |
| 26 | if ( ! $this->inserted_id ) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Perform any actions after term inserted/updated |
| 32 | */ |
| 33 | do_action( |
| 34 | 'jet-form-builder/action/after-term-' . $this->get_id(), |
| 35 | jet_fb_action_handler()->get_current_action(), |
| 36 | jet_fb_action_handler(), |
| 37 | $this |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | public function pre_check(): bool { |
| 42 | return apply_filters( |
| 43 | 'jet-form-builder/action/insert-term/pre-check', |
| 44 | true, |
| 45 | $this->modifier->source_arr, |
| 46 | jet_fb_action_handler()->get_current_action() |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | public function get_inserted(): int { |
| 51 | return $this->inserted_id; |
| 52 | } |
| 53 | |
| 54 | public function user_can_manage_taxonomy_terms( $taxonomy ) { |
| 55 | $taxonomy_object = get_taxonomy( $taxonomy ); |
| 56 | |
| 57 | if ( ! $taxonomy_object ) { |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | $capability = $taxonomy_object->cap->edit_terms; |
| 62 | |
| 63 | return current_user_can( $capability ); |
| 64 | } |
| 65 | } |
| 66 |