PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.6
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 2 years ago base-form-action.php 2 years ago form-actions-manager.php 2 years ago get-form-data.php 2 years ago import-form-trait.php 2 years ago
base-form-action.php
99 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Form_Actions;
5
6 use Jet_Form_Builder\Classes\Get_Template_Trait;
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 abstract class Base_Form_Action {
14
15 use Get_Template_Trait;
16
17 const NONCE_ACTION = 'jfb_admin_inline';
18
19 public function __construct() {
20 add_action( 'admin_action_' . $this->action_id(), array( $this, 'do_action' ) );
21 }
22
23 abstract public function get_id();
24
25 abstract public function get_title();
26
27 abstract public function do_admin_action();
28
29 public function do_action() {
30 if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ?? '' ), $this->get_id() ) ) {
31 wp_die( 'Your link has expired, please return to the previous page and try again', 'Error' );
32 }
33
34 $this->do_admin_action();
35 }
36
37 public function action_id() {
38 return $this->get_id();
39 }
40
41 public function display_action_link() {
42 return true;
43 }
44
45 public function action_url( $post = null ) {
46 $admin_url = esc_url_raw( admin_url( 'admin.php' ) );
47
48 $args = array(
49 'action' => $this->action_id(),
50 '_wpnonce' => wp_create_nonce( $this->get_id() ),
51 );
52
53 if ( $post instanceof \WP_Post ) {
54 $args['post'] = $post->ID;
55 }
56
57 return add_query_arg( $args, $admin_url );
58 }
59
60 public function action_template() {
61 return '<a href="%1$s" title="%3$s" rel="permalink">%2$s</a>';
62 }
63
64 public function hover_title() {
65 return $this->get_title();
66 }
67
68 public function post_type() {
69 return jet_form_builder()->post_type->slug();
70 }
71
72 final public function register_action( $actions, $post ) {
73 if ( $this->post_type() !== $post->post_type ) {
74 return $actions;
75 }
76
77 if ( ! $this->check_user_access( $post->ID ) ) {
78 return $actions;
79 }
80
81 $actions[ $this->get_id() ] = sprintf(
82 $this->action_template(),
83 $this->action_url( $post ),
84 $this->get_title(),
85 $this->hover_title()
86 );
87
88 return $actions;
89 }
90
91 protected function check_user_access( $post_id = null ) {
92 return (
93 current_user_can( 'edit_posts' ) && current_user_can( 'edit_post', $post_id )
94 );
95 }
96
97
98 }
99