PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.4
JetFormBuilder — Dynamic Blocks Form Builder v2.1.4
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / form-actions / base-form-action.php
jetformbuilder / includes / form-actions Last commit date
types 3 years ago base-form-action.php 3 years ago form-actions-manager.php 3 years ago get-form-data.php 3 years ago import-form-trait.php 3 years ago
base-form-action.php
91 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Form_Actions;
5
6 use Jet_Form_Builder\Classes\Get_Template_Trait;
7
8 abstract class Base_Form_Action {
9
10 use Get_Template_Trait;
11
12 public function __construct() {
13 add_action( 'admin_action_' . $this->action_id(), array( $this, 'do_admin_action' ) );
14 }
15
16 abstract public function get_id();
17
18 abstract public function get_title();
19
20 abstract public function do_admin_action();
21
22 public function action_id() {
23 return $this->get_id();
24 }
25
26 public function display_action_link() {
27 return true;
28 }
29
30 public function action_url( $post = null ) {
31 $admin_url = esc_url_raw( admin_url( 'admin.php' ) );
32
33 $args = array(
34 'action' => $this->action_id(),
35 );
36
37 if ( $post instanceof \WP_Post ) {
38 $args['post'] = $post->ID;
39 }
40
41 return add_query_arg( $args, $admin_url );
42 }
43
44 public function action_template() {
45 return '<a href="%1$s" title="%3$s" rel="permalink">%2$s</a>';
46 }
47
48 public function hover_title() {
49 return $this->get_title();
50 }
51
52 public function post_type() {
53 return jet_form_builder()->post_type->slug();
54 }
55
56 final public function register_action( $actions, $post ) {
57 if ( $this->post_type() !== $post->post_type ) {
58 return $actions;
59 }
60
61 if ( ! $this->check_user_access( $post->ID ) ) {
62 return $actions;
63 }
64
65 $actions[ $this->get_id() ] = sprintf(
66 $this->action_template(),
67 $this->action_url( $post ),
68 $this->get_title(),
69 $this->hover_title()
70 );
71
72 return $actions;
73 }
74
75 protected function check_user_access( $post_id = null ) {
76 $res = true;
77
78 if ( ! current_user_can( 'edit_posts' ) ) {
79 $res = false;
80 }
81
82 if ( ! current_user_can( 'edit_post', $post_id ) ) {
83 $res = false;
84 }
85
86 return $res;
87 }
88
89
90 }
91