|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YIKES Inc. Easy Mailchimp Forms Plugin. |
|
4
|
|
|
* |
|
5
|
|
|
* @package Yikes\EasyForms |
|
6
|
|
|
* @author Freddie Mixell |
|
7
|
|
|
* @license GPL2 |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace YIKES\EasyForms; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Trait PluginHelper. |
|
14
|
|
|
* |
|
15
|
|
|
* Handle basic WordPress plugin variables like the plugin's path and URL. |
|
16
|
|
|
* |
|
17
|
|
|
* @since %VERSION% |
|
18
|
|
|
* @package Yikes\EasyForms |
|
19
|
|
|
*/ |
|
20
|
|
|
trait PluginHelper { |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Get the main plugin file. |
|
24
|
|
|
* |
|
25
|
|
|
* @since %VERSION% |
|
26
|
|
|
* @return string |
|
27
|
|
|
*/ |
|
28
|
|
|
protected function get_main_file() { |
|
29
|
|
|
return "{$this->get_root_dir()}/{$this->get_main_filename()}"; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Get the root directory for the plugin. |
|
34
|
|
|
* |
|
35
|
|
|
* @since %VERSION% |
|
36
|
|
|
* @return string |
|
37
|
|
|
*/ |
|
38
|
|
|
protected function get_root_dir() { |
|
39
|
|
|
return dirname( __DIR__ ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Get the version of the plugin. |
|
44
|
|
|
* |
|
45
|
|
|
* @since %VERSION% |
|
46
|
|
|
* @return string |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function get_version() { |
|
49
|
|
|
return '1.0.0'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Get the url for the plugin. |
|
54
|
|
|
* |
|
55
|
|
|
* @since %VERSION% |
|
56
|
|
|
* |
|
57
|
|
|
* @param string $path The URL path. |
|
58
|
|
|
* |
|
59
|
|
|
* @return string |
|
60
|
|
|
*/ |
|
61
|
|
|
protected function get_plugin_url( $path = '' ) { |
|
62
|
|
|
return plugins_url( $path, $this->get_main_file() ); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Get the filename for the plugin. |
|
67
|
|
|
* |
|
68
|
|
|
* @since %VERSION% |
|
69
|
|
|
* @return string |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function get_main_filename() { |
|
72
|
|
|
return 'easy-mailchimp-forms.php'; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Get the WordPress plugin name for this plugin. |
|
77
|
|
|
* |
|
78
|
|
|
* @since %VERSION% |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
protected function get_basename() { |
|
82
|
|
|
return plugin_basename( $this->get_main_file() ); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Is the new editor is enabled? |
|
87
|
|
|
* |
|
88
|
|
|
* Check if the register_block_type function exists to see if the new editor is available. Then check if the classic editor plugin is enabled to see if the editor is being disabled. |
|
89
|
|
|
* |
|
90
|
|
|
* @since %VERSION% |
|
91
|
|
|
* @return bool |
|
92
|
|
|
*/ |
|
93
|
|
|
protected function is_new_editor_enabled() { |
|
94
|
|
|
/** |
|
95
|
|
|
* Filter whether the new editor is enabled. |
|
96
|
|
|
* |
|
97
|
|
|
* There are situations where the new editor is disabled even though our check returns true. This filter allows you to turn on/off our new editor functionality. |
|
98
|
|
|
* |
|
99
|
|
|
* @param bool $is_enabled. |
|
100
|
|
|
* |
|
101
|
|
|
* @return bool True if the new editor is enabled. |
|
102
|
|
|
*/ |
|
103
|
|
|
return apply_filters( |
|
104
|
|
|
'emf_is_new_editor_enabled', |
|
105
|
|
|
function_exists( 'register_block_type' ) && ! class_exists( 'Classic_Editor' ) |
|
106
|
|
|
); |
|
107
|
|
|
} |
|
108
|
|
|
} |