PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.2.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.2.1
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.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 All 134 releases
jetformbuilder / includes / blocks / action-buttons-manager.php

action-buttons-manager.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.2.1, at includes/blocks/action-buttons-manager.php

83 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace Jet_Form_Builder\Blocks;
5
6 use Jet_Form_Builder\Blocks\Button_Types\Button_Type_Base;
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 /**
14 * CRUD
15 *
16 * Trait Action_Buttons_Manager
17 *
18 * @package Jet_Form_Builder\Blocks
19 */
20 trait Action_Buttons_Manager {
21
22 /**
23 * @var Button_Type_Base[]
24 */
25 private $button_types = array();
26
27 public function get_button_types() {
28 return $this->button_types;
29 }
30
31 public function get_button_types_for_js() {
32 $prepared = array();
33
34 foreach ( $this->get_button_types() as $type ) {
35 $prepared[] = array(
36 'value' => $type->slug(),
37 'button_class' => $type->get_class( 'button' ),
38 'wrapper_class' => $type->get_class( 'wrapper' ),
39 );
40 }
41
42 return $prepared;
43 }
44
45 /**
46 * @param Button_Type_Base $button
47 * @param bool $update
48 */
49 public function set_button_type( Button_Type_Base $button, $update = false ) {
50 if ( ! $update && $this->isset_button_type( $button->slug() ) ) {
51 return;
52 }
53 $this->button_types[ $button->slug() ] = $button;
54 }
55
56 public function update_button_type( Button_Type_Base $button ) {
57 $this->set_button_type( $button, true );
58 }
59
60 public function isset_button_type( string $slug ) {
61 return isset( $this->button_types[ $slug ] );
62 }
63
64 /**
65 * @param $slug
66 *
67 * @return Button_Type_Base
68 */
69 public function get_button_type( $slug ) {
70 return $this->button_types[ $slug ];
71 }
72
73 public function delete_button_type( $slug ) {
74 if ( ! $this->isset_button_type( $slug ) ) {
75 return false;
76 }
77 unset( $this->button_types[ $slug ] );
78
79 return true;
80 }
81
82 }
83