PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 6.4.9
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v6.4.9
6.4.9 6.4.8 6.4.7 6.4.6 6.4.5 6.4.4 6.4.3 6.4.2 6.4.1 6.4.0 6.3.9 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 All 152 releases
poll-maker / includes / class-poll-maker-ays.php

class-poll-maker-ays.php in Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls 6.4.9, at includes/class-poll-maker-ays.php

371 lines 15.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 Poll_Maker_Ays
13 * @subpackage Poll_Maker_Ays/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 Poll_Maker_Ays
27 * @subpackage Poll_Maker_Ays/includes
28 * @author Poll Maker Team <info@ays-pro.com>
29 */
30 class Poll_Maker_Ays {
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 Poll_Maker_Ays_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('POLL_MAKER_AYS_VERSION')) {
71 $this->version = POLL_MAKER_AYS_VERSION;
72 } else {
73 $this->version = '1.0.0';
74 }
75 $this->plugin_name = 'poll-maker-ays';
76
77 $this->load_dependencies();
78 $this->set_locale();
79 $this->define_admin_hooks();
80 $this->define_public_hooks();
81 $this->define_custom_post_type_hooks();
82 }
83
84 /**
85 * Load the required dependencies for this plugin.
86 *
87 * Include the following files that make up the plugin:
88 *
89 * - Poll_Maker_Ays_Loader. Orchestrates the hooks of the plugin.
90 * - Poll_Maker_Ays_i18n. Defines internationalization functionality.
91 * - Poll_Maker_Ays_Admin. Defines all hooks for the admin area.
92 * - Poll_Maker_Ays_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 if (!class_exists('WP_List_Table')) {
102 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
103 }
104
105 /**
106 * The class responsible for defining all functions for getting all survey data
107 */
108 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-poll-maker-ays-data.php';
109
110 /**
111 * The class responsible for orchestrating the actions and filters of the
112 * core plugin.
113 */
114 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-poll-maker-ays-loader.php';
115
116 /**
117 * The class responsible for defining internationalization functionality
118 * of the plugin.
119 */
120 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-poll-maker-ays-i18n.php';
121
122 /**
123 * The class responsible for defining all actions that occur in the admin area.
124 */
125 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-poll-maker-ays-admin.php';
126
127 /**
128 * The class responsible for showing Poll Maker Welcome page.
129 */
130 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-poll-maker-ays-welcome.php';
131
132 /**
133 * The class responsible for showing Poll Maker Feedback popup.
134 */
135 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-poll-maker-feedback.php';
136
137 /*
138 * The class is responsible for showing polls in wordpress default WP_LIST_TABLE style
139 */
140 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/lists/class-poll-maker-polls-list-table.php';
141 /*
142 * The class is responsible for showing polls categories in wordpress default WP_LIST_TABLE style
143 */
144 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/lists/class-poll-maker-categories-list-table.php';
145
146 /*
147 * The class is responsible for showing poll results in wordpress default WP_LIST_TABLE style
148 */
149 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/lists/class-poll-maker-results-list-table.php';
150
151 /*
152 * The class is responsible for showing poll each results in wordpress default WP_LIST_TABLE style
153 */
154 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/lists/class-poll-maker-each-results-poll-list-table.php';
155
156 /**
157 * The class responsible for defining all actions that occur in the public-facing
158 * side of the site.
159 */
160 require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-poll-maker-ays-public.php';
161
162 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/partials/class-poll-maker-extra-shortcode.php';
163
164 /**
165 * The class responsible for widget.
166 */
167 require_once plugin_dir_path(dirname(__FILE__)) . 'widgets/poll-maker-ays-widget.php';
168 /**
169 * The class is responsible for showing poll settings
170 */
171 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/settings/poll-maker-settings-actions.php';
172
173 /**
174 * The class responsible for defining all functions for getting all custom post type functions
175 */
176 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-poll-maker-custom-post-type.php';
177
178 // Answer results actions
179 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/results/poll-maker-ays-answer-results-actions.php';
180
181 $this->loader = new Poll_Maker_Ays_Loader();
182
183 }
184
185 /**
186 * Define the locale for this plugin for internationalization.
187 *
188 * Uses the Poll_Maker_Ays_i18n class in order to set the domain and to register the hook
189 * with WordPress.
190 *
191 * @since 1.0.0
192 * @access private
193 */
194 private function set_locale() {
195
196 $plugin_i18n = new Poll_Maker_Ays_i18n();
197
198 $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
199 //$this->loader->add_action('init', $plugin_i18n, 'load_plugin_textdomain');
200
201 }
202
203 /**
204 * Register all of the hooks related to the admin area functionality
205 * of the plugin.
206 *
207 * @since 1.0.0
208 * @access private
209 */
210 private function define_admin_hooks() {
211
212 $plugin_admin = new Poll_Maker_Ays_Admin($this->get_plugin_name(), $this->get_version());
213
214 $this->loader->add_action( 'admin_head', $plugin_admin, 'admin_menu_styles' );
215 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
216 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
217 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'disable_scripts', 100);
218 $this->loader->add_action('current_screen', $plugin_admin, 'ays_poll_disable_all_notice_from_plugin', 200, 1);
219 $this->loader->add_filter( 'admin_body_class', $plugin_admin, 'ays_poll_add_body_class' );
220
221 $this->loader->add_action('widgets_init', $plugin_admin, 'register_poll_ays_widget');
222
223 //Plugin deactivate
224 $this->loader->add_action('wp_ajax_apm_deactivate_plugin_option_pm', $plugin_admin, 'apm_deactivate_plugin_option');
225 $this->loader->add_action('wp_ajax_nopriv_apm_deactivate_plugin_option_pm', $plugin_admin, 'apm_deactivate_plugin_option');
226
227 //Results modal
228 $this->loader->add_action('wp_ajax_apm_show_results', $plugin_admin, 'apm_show_results');
229 $this->loader->add_action('wp_ajax_nopriv_apm_show_results', $plugin_admin, 'apm_show_results');
230
231 // Add menu item
232 $this->loader->add_action('admin_menu', $plugin_admin, 'add_plugin_admin_menu');
233
234 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_dashboard_submenu', 80 );
235 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_polls_submenu', 85 );
236 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_add_new_poll_submenu', 95 );
237 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_categories_submenu', 100 );
238 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_results_submenu', 105 );
239 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_formfields_submenu', 110 );
240 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_general_settings_submenu', 115 );
241 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_how_to_use_submenu', 120 );
242 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_featured_plugins_submenu', 125 );
243 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_pro_features_submenu', 130 );
244
245 // Add Settings link to the plugin
246 $plugin_basename = plugin_basename(plugin_dir_path(__DIR__) . $this->plugin_name . '.php');
247 $this->loader->add_filter('plugin_action_links_' . $plugin_basename, $plugin_admin, 'add_action_links');
248
249 $this->loader->add_action( 'elementor/widgets/widgets_registered', $plugin_admin, 'poll_maker_el_widgets_registered' );
250
251 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'codemirror_enqueue_scripts');
252
253 // Add footer message
254 $this->loader->add_action( 'in_admin_footer', $plugin_admin, 'poll_maker_admin_footer', 1 );
255 $this->loader->add_action( 'in_admin_footer', $plugin_admin, 'ays_poll_add_checklist_guide', 10 );
256 // $this->loader->add_action( 'in_admin_footer', $plugin_admin, 'ays_poll_black_friady_popup_box', 10 );
257
258 // Add aditional links to the plugin
259 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'add_poll_row_meta' , 10 , 2 );
260
261 //Create quick poll
262 $this->loader->add_action( 'wp_ajax_ays_poll_maker_quick_start', $plugin_admin, 'ays_poll_maker_quick_start' );
263 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_maker_quick_start', $plugin_admin, 'ays_poll_maker_quick_start' );
264
265 // Sale Banner
266 $this->loader->add_action( 'admin_notices', $plugin_admin, 'ays_poll_sale_baner', 10 );
267
268 $this->loader->add_action( 'wp_ajax_ays_poll_dismiss_button', $plugin_admin, 'ays_poll_dismiss_button' );
269 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_dismiss_button', $plugin_admin, 'ays_poll_dismiss_button' );
270
271 $this->loader->add_action( 'wp_ajax_ays_poll_install_plugin', $plugin_admin, 'ays_poll_install_plugin' );
272 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_install_plugin', $plugin_admin, 'ays_poll_install_plugin' );
273
274 $this->loader->add_action( 'wp_ajax_ays_poll_activate_plugin', $plugin_admin, 'ays_poll_activate_plugin' );
275 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_activate_plugin', $plugin_admin, 'ays_poll_activate_plugin' );
276
277 $this->loader->add_action( 'wp_ajax_ays_poll_create_author', $plugin_admin, 'ays_poll_create_author' );
278 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_create_author', $plugin_admin, 'ays_poll_create_author' );
279
280 $this->loader->add_action( 'wp_ajax_ays_poll_save_checklist_progress', $plugin_admin, 'ays_poll_save_checklist_progress' );
281 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_save_checklist_progress', $plugin_admin, 'ays_poll_save_checklist_progress' );
282
283 $this->loader->add_action( 'wp_ajax_ays_poll_checklist_close_popup', $plugin_admin, 'ays_poll_checklist_close_popup' );
284 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_checklist_close_popup', $plugin_admin, 'ays_poll_checklist_close_popup' );
285
286 $this->loader->add_action( 'wp_ajax_ays_poll_checklist_reopen_callback', $plugin_admin, 'ays_poll_checklist_reopen_callback' );
287 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_checklist_reopen_callback', $plugin_admin, 'ays_poll_checklist_reopen_callback' );
288
289 }
290
291 /**
292 * Register all of the hooks related to the public-facing functionality
293 * of the plugin.
294 *
295 * @since 1.0.0
296 * @access private
297 */
298 private function define_public_hooks() {
299
300 $plugin_public = new Poll_Maker_Ays_Public($this->get_plugin_name(), $this->get_version());
301 $plugin_public_extra_shortcodes = new Ays_Poll_Maker_Extra_Shortcodes_Public( $this->get_plugin_name(), $this->get_version() );
302
303 // $this->loader->add_action('init', $plugin_public, 'ays_poll_initialize_shortcode');
304
305 $this->loader->add_action('wp_ajax_ays_finish_poll', $plugin_public, 'ays_finish_poll');
306 $this->loader->add_action('wp_ajax_nopriv_ays_finish_poll', $plugin_public, 'ays_finish_poll');
307
308 $this->loader->add_action('wp_ajax_ays_poll_get_current_answer_users_pics', $plugin_public, 'ays_poll_get_current_answer_users_pics');
309 $this->loader->add_action('wp_ajax_nopriv_ays_poll_get_current_answer_users_pics', $plugin_public, 'ays_poll_get_current_answer_users_pics');
310
311 $this->loader->add_action('wp_ajax_ays_add_answer_poll', $plugin_public, 'ays_add_answer_poll');
312 $this->loader->add_action('wp_ajax_nopriv_ays_add_answer_poll', $plugin_public, 'ays_add_answer_poll');
313
314 /*$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
315 $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');*/
316 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles_early' );
317
318 $this->loader->add_action( 'wp_ajax_ays_poll_get_user_information', $plugin_public, 'ays_poll_get_user_information' );
319 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_get_user_information', $plugin_public, 'ays_poll_get_user_information' );
320 }
321
322 /**
323 * Run the loader to execute all of the hooks with WordPress.
324 *
325 * @since 1.0.0
326 */
327 private function define_custom_post_type_hooks(){
328 $plugin_custom_post_type = new Poll_Maker_Custom_Post_Type( $this->get_plugin_name(), $this->get_version() );
329 }
330
331 /**
332 * Run the loader to execute all of the hooks with WordPress.
333 *
334 * @since 1.0.0
335 */
336 public function run() {
337 $this->loader->run();
338 }
339
340 /**
341 * The name of the plugin used to uniquely identify it within the context of
342 * WordPress and to define internationalization functionality.
343 *
344 * @since 1.0.0
345 * @return string The name of the plugin.
346 */
347 public function get_plugin_name() {
348 return $this->plugin_name;
349 }
350
351 /**
352 * The reference to the class that orchestrates the hooks with the plugin.
353 *
354 * @since 1.0.0
355 * @return Poll_Maker_Ays_Loader Orchestrates the hooks of the plugin.
356 */
357 public function get_loader() {
358 return $this->loader;
359 }
360
361 /**
362 * Retrieve the version number of the plugin.
363 *
364 * @since 1.0.0
365 * @return string The version number of the plugin.
366 */
367 public function get_version() {
368 return $this->version;
369 }
370
371 }