PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / libs / forms / forms.php
elementskit-lite / libs / forms Last commit date
assets 3 weeks ago pages 3 weeks ago forms.php 4 years ago
forms.php
144 lines
1 <?php
2 namespace Wpmet\Libs;
3
4 defined( 'ABSPATH' ) || exit;
5
6 if ( ! class_exists( '\Wpmet\Libs\Forms' ) ) :
7
8 class Forms {
9
10 /**
11 * Member Variable
12 *
13 * @var instance
14 */
15 private static $instance;
16
17 /**
18 * Instance.
19 *
20 * Ensures only one instance of the plugin class is loaded or can be loaded.
21 *
22 * @since 2.6.3
23 * @access public
24 * @static
25 *
26 * @return Init An instance of the class.
27 */
28 public static function instance() {
29
30 if ( is_null( self::$instance ) ) {
31
32 self::$instance = new self();
33 }
34
35 return self::$instance;
36 }
37
38 /**
39 * Construct the plugin object.
40 *
41 * @since 2.6.3
42 * @access public
43 */
44 public function __construct() {
45
46 // register admin menus
47 add_action('admin_menu', [$this, 'register_sub_menu'], 999);
48
49 // register js/ css
50 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
51
52 // check for metform plugin is active or not.
53 if(in_array('metform/metform.php', apply_filters('active_plugins', get_option('active_plugins'))) && is_admin()) {
54 add_action('current_screen', [$this, 'redirect_to_metform_page']);
55 }
56 }
57
58 /**
59 * Get forms dir.
60 *
61 * @since 2.6.3
62 * @access public
63 */
64 public static function get_dir() {
65
66 return \ElementsKit_Lite::lib_dir() . 'forms/';
67 }
68
69 /**
70 * Get forms dir url.
71 *
72 * @since 2.6.3
73 * @access public
74 */
75 public static function get_url() {
76
77 return \ElementsKit_Lite::lib_url() . 'forms/';
78 }
79
80 /**
81 * Enqueuing js/ css
82 *
83 * @since 2.6.3
84 * @access public
85 */
86 public function enqueue_scripts() {
87
88 $current_screen = get_current_screen();
89
90 if(!empty($current_screen->id) && $current_screen->id === 'elementskit_page_forms') {
91 wp_enqueue_style( 'elementskit-forms', self::get_url() . 'assets/css/forms.css', [], \ElementsKit_Lite::version() );
92 wp_enqueue_script('elementskit-forms', self::get_url() . 'assets/js/forms.js', ['jquery'], \ElementsKit_Lite::version(), true);
93 }
94 }
95
96 /**
97 * Adds a submenu page under elementskit menu.
98 *
99 * @since 2.6.3
100 * @access public
101 */
102 public function register_sub_menu() {
103
104 add_submenu_page(
105 'elementskit',
106 esc_html__('Forms', 'elementskit-lite'),
107 esc_html__('Forms', 'elementskit-lite'),
108 'manage_options',
109 'forms',
110 [$this, 'form_page_callback']
111 );
112 }
113
114 /**
115 * Display callback for the form submenu page.
116 *
117 * @since 2.6.3
118 * @access public
119 */
120 public function form_page_callback() {
121
122 // Include template file
123 include self::get_dir() . 'pages/template.php';
124 }
125
126 /**
127 * Redirect to metfor plugin page
128 *
129 * @since 2.6.3
130 * @access public
131 */
132 public function redirect_to_metform_page() {
133
134 $current_screen = get_current_screen();
135
136 if(!empty($current_screen->id) && $current_screen->id === 'elementskit_page_forms') {
137 wp_safe_redirect(admin_url('edit.php?post_type=metform-form'));
138 exit;
139 }
140 }
141 }
142
143 endif;
144