PluginProbe
Chartify – WordPress Chart Plugin / 1.0.0
Chartify – WordPress Chart Plugin v1.0.0
3.8.0 3.7.9 3.7.8 3.7.7 3.7.6 3.7.5 trunk 1.0.0 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.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 All 83 releases
chart-builder / includes / class-chart-builder.php

class-chart-builder.php in Chartify – WordPress Chart Plugin 1.0.0, at includes/class-chart-builder.php

273 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link https://ays-pro.com/
10 * @since 1.0.0
11 *
12 * @package Chart_Builder
13 * @subpackage Chart_Builder/includes
14 */
15
16 /**
17 * The core plugin class.
18 *
19 * This is used to define internationalization, admin-specific hooks, and
20 * public-facing site hooks.
21 *
22 * Also maintains the unique identifier of this plugin as well as the current
23 * version of the plugin.
24 *
25 * @since 1.0.0
26 * @package Chart_Builder
27 * @subpackage Chart_Builder/includes
28 * @author Chart Builder Team <info@ays-pro.com>
29 */
30 class Chart_Builder {
31
32 /**
33 * The loader that's responsible for maintaining and registering all hooks that power
34 * the plugin.
35 *
36 * @since 1.0.0
37 * @access protected
38 * @var Chart_Builder_Loader $loader Maintains and registers all hooks for the plugin.
39 */
40 protected $loader;
41
42 /**
43 * The unique identifier of this plugin.
44 *
45 * @since 1.0.0
46 * @access protected
47 * @var string $plugin_name The string used to uniquely identify this plugin.
48 */
49 protected $plugin_name;
50
51 /**
52 * The current version of the plugin.
53 *
54 * @since 1.0.0
55 * @access protected
56 * @var string $version The current version of the plugin.
57 */
58 protected $version;
59
60 /**
61 * Define the core functionality of the plugin.
62 *
63 * Set the plugin name and the plugin version that can be used throughout the plugin.
64 * Load the dependencies, define the locale, and set the hooks for the admin area and
65 * the public-facing side of the site.
66 *
67 * @since 1.0.0
68 */
69 public function __construct() {
70 if ( defined( 'CHART_BUILDER_VERSION' ) ) {
71 $this->version = CHART_BUILDER_VERSION;
72 } else {
73 $this->version = '1.0.0';
74 }
75 $this->plugin_name = "chart-builder";
76
77 $this->load_dependencies();
78 $this->set_locale();
79 $this->define_admin_hooks();
80 $this->define_public_hooks();
81
82 }
83
84 /**
85 * Load the required dependencies for this plugin.
86 *
87 * Include the following files that make up the plugin:
88 *
89 * - Chart_Builder_Loader. Orchestrates the hooks of the plugin.
90 * - Chart_Builder_i18n. Defines internationalization functionality.
91 * - Chart_Builder_Admin. Defines all hooks for the admin area.
92 * - Chart_Builder_Public. Defines all hooks for the public side of the site.
93 *
94 * Create an instance of the loader which will be used to register the hooks
95 * with WordPress.
96 *
97 * @since 1.0.0
98 * @access private
99 */
100 private function load_dependencies() {
101
102 if ( ! class_exists( 'WP_List_Table' ) ) {
103 require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
104 }
105
106 /**
107 * The classes responsible for defining all actions including db that occur in the plugin area.
108 */
109 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-chart-builder-functions.php';
110 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-chart-builder-db-actions.php';
111 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-chart-builder-actions.php';
112
113 /**
114 * The class responsible for defining all functions for getting all form integrations
115 */
116 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-chart-builder-integrations.php';
117
118 /**
119 * The class responsible for orchestrating the actions and filters of the
120 * core plugin.
121 */
122 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-chart-builder-loader.php';
123
124 /**
125 * The class responsible for defining internationalization functionality
126 * of the plugin.
127 */
128 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-chart-builder-i18n.php';
129
130 /**
131 * The class responsible for defining all actions that occur in the admin area.
132 */
133 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-chart-builder-admin.php';
134
135 /**
136 * The class responsible for defining all actions that occur in the public-facing
137 * side of the site.
138 */
139 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-chart-builder-public.php';
140
141 $this->loader = new Chart_Builder_Loader();
142
143 }
144
145 /**
146 * Define the locale for this plugin for internationalization.
147 *
148 * Uses the Chart_Builder_i18n class in order to set the domain and to register the hook
149 * with WordPress.
150 *
151 * @since 1.0.0
152 * @access private
153 */
154 private function set_locale() {
155
156 $plugin_i18n = new Chart_Builder_i18n();
157
158 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
159
160 }
161
162 /**
163 * Register all of the hooks related to the admin area functionality
164 * of the plugin.
165 *
166 * @since 1.0.0
167 * @access private
168 */
169 private function define_admin_hooks() {
170
171 $plugin_admin = new Chart_Builder_Admin( $this->get_plugin_name(), $this->get_version() );
172
173 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
174 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
175
176
177 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_admin_menu' );
178
179 // $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_general_settings_submenu', 120 );
180
181
182 // Add Chart page sources contents
183 $this->loader->add_action( 'ays_cb_chart_page_sources_contents', $plugin_admin, 'ays_chart_page_source_contents', 10, 3 );
184 // $this->loader->add_filter( 'ays_cb_chart_page_sources_contents_settings', $plugin_admin, 'source_contents_import_from_wordpress_settings', 50, 2 );
185 $this->loader->add_filter( 'ays_cb_chart_page_sources_contents_settings', $plugin_admin, 'source_contents_manual_settings', 70, 2 );
186
187 // Add Chart page settings contents
188 $this->loader->add_action( 'ays_cb_chart_page_settings_contents', $plugin_admin, 'ays_chart_page_settings_contents', 10, 3 );
189 $this->loader->add_filter( 'ays_cb_chart_page_settings_contents_settings', $plugin_admin, 'settings_contents_general_settings', 50, 2 );
190 $this->loader->add_filter( 'ays_cb_chart_page_settings_contents_settings', $plugin_admin, 'settings_contents_styles_settings', 60, 2 );
191 $this->loader->add_filter( 'ays_cb_chart_page_settings_contents_settings', $plugin_admin, 'settings_contents_tooltip_settings', 70, 2 );
192
193
194 // Add Settings link to the plugin
195 $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' );
196 $this->loader->add_filter( 'plugin_action_links_' . $plugin_basename, $plugin_admin, 'add_action_links' );
197
198
199 // Admin AJAX action
200 $this->loader->add_action( 'wp_ajax_ays_chart_admin_ajax', $plugin_admin, 'ays_admin_ajax' );
201 $this->loader->add_action( 'wp_ajax_nopriv_ays_chart_admin_ajax', $plugin_admin, 'ays_admin_ajax' );
202 $this->loader->add_action( 'wp_ajax_deactivate_plugin_option_cb', $plugin_admin, 'deactivate_plugin_option');
203 $this->loader->add_action( 'wp_ajax_nopriv_deactivate_plugin_option_cb', $plugin_admin, 'deactivate_plugin_option');
204
205 }
206
207 /**
208 * Register all of the hooks related to the public-facing functionality
209 * of the plugin.
210 *
211 * @since 1.0.0
212 * @access private
213 */
214 private function define_public_hooks() {
215
216 $plugin_public = new Chart_Builder_Public( $this->get_plugin_name(), $this->get_version() );
217
218 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
219 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
220
221 }
222
223 /**
224 * Register all of the hooks related to the integrations functionality
225 * of the plugin.
226 *
227 * @since 1.0.0
228 * @access private
229 */
230
231
232 /**
233 * Run the loader to execute all of the hooks with WordPress.
234 *
235 * @since 1.0.0
236 */
237 public function run() {
238 $this->loader->run();
239 }
240
241 /**
242 * The name of the plugin used to uniquely identify it within the context of
243 * WordPress and to define internationalization functionality.
244 *
245 * @since 1.0.0
246 * @return string The name of the plugin.
247 */
248 public function get_plugin_name() {
249 return $this->plugin_name;
250 }
251
252 /**
253 * The reference to the class that orchestrates the hooks with the plugin.
254 *
255 * @since 1.0.0
256 * @return Chart_Builder_Loader Orchestrates the hooks of the plugin.
257 */
258 public function get_loader() {
259 return $this->loader;
260 }
261
262 /**
263 * Retrieve the version number of the plugin.
264 *
265 * @since 1.0.0
266 * @return string The version number of the plugin.
267 */
268 public function get_version() {
269 return $this->version;
270 }
271
272 }
273