PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 5.6.0
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v5.6.0
6.5.0 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 All 153 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 5.6.0, at includes/class-poll-maker-ays.php

335 lines 13.4 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 <[email protected]>
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
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 is responsible for showing polls in wordpress default WP_LIST_TABLE style
134 */
135 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/lists/class-poll-maker-polls-list-table.php';
136 /*
137 * The class is responsible for showing polls categories in wordpress default WP_LIST_TABLE style
138 */
139 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/lists/class-poll-maker-categories-list-table.php';
140
141 /*
142 * The class is responsible for showing poll results in wordpress default WP_LIST_TABLE style
143 */
144 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/lists/class-poll-maker-results-list-table.php';
145
146 /*
147 * The class is responsible for showing poll each results in wordpress default WP_LIST_TABLE style
148 */
149 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/lists/class-poll-maker-each-results-poll-list-table.php';
150
151 /**
152 * The class responsible for defining all actions that occur in the public-facing
153 * side of the site.
154 */
155 require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-poll-maker-ays-public.php';
156
157 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/partials/class-poll-maker-extra-shortcode.php';
158
159 /**
160 * The class responsible for widget.
161 */
162 require_once plugin_dir_path(dirname(__FILE__)) . 'widgets/poll-maker-ays-widget.php';
163 /**
164 * The class is responsible for showing poll settings
165 */
166 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/settings/poll-maker-settings-actions.php';
167
168 // Answer results actions
169 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/results/poll-maker-ays-answer-results-actions.php';
170
171 $this->loader = new Poll_Maker_Ays_Loader();
172
173 }
174
175 /**
176 * Define the locale for this plugin for internationalization.
177 *
178 * Uses the Poll_Maker_Ays_i18n class in order to set the domain and to register the hook
179 * with WordPress.
180 *
181 * @since 1.0.0
182 * @access private
183 */
184 private function set_locale() {
185
186 $plugin_i18n = new Poll_Maker_Ays_i18n();
187
188 $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
189 //$this->loader->add_action('init', $plugin_i18n, 'load_plugin_textdomain');
190
191 }
192
193 /**
194 * Register all of the hooks related to the admin area functionality
195 * of the plugin.
196 *
197 * @since 1.0.0
198 * @access private
199 */
200 private function define_admin_hooks() {
201
202 $plugin_admin = new Poll_Maker_Ays_Admin($this->get_plugin_name(), $this->get_version());
203
204 $this->loader->add_action( 'admin_head', $plugin_admin, 'admin_menu_styles' );
205 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
206 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
207 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'disable_scripts', 100);
208 $this->loader->add_action('widgets_init', $plugin_admin, 'register_poll_ays_widget');
209
210 //Plugin deactivate
211 $this->loader->add_action('wp_ajax_apm_deactivate_plugin_option_pm', $plugin_admin, 'apm_deactivate_plugin_option');
212 $this->loader->add_action('wp_ajax_nopriv_apm_deactivate_plugin_option_pm', $plugin_admin, 'apm_deactivate_plugin_option');
213
214 //Results modal
215 $this->loader->add_action('wp_ajax_apm_show_results', $plugin_admin, 'apm_show_results');
216 $this->loader->add_action('wp_ajax_nopriv_apm_show_results', $plugin_admin, 'apm_show_results');
217
218 // Add menu item
219 $this->loader->add_action('admin_menu', $plugin_admin, 'add_plugin_admin_menu');
220
221 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_polls_submenu', 90 );
222 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_add_new_poll_submenu', 95 );
223 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_categories_submenu', 100 );
224 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_results_submenu', 105 );
225 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_formfields_submenu', 110 );
226 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_general_settings_submenu', 115 );
227 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_how_to_use_submenu', 120 );
228 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_featured_plugins_submenu', 125 );
229 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_pro_features_submenu', 130 );
230
231 // Add Settings link to the plugin
232 $plugin_basename = plugin_basename(plugin_dir_path(__DIR__) . $this->plugin_name . '.php');
233 $this->loader->add_filter('plugin_action_links_' . $plugin_basename, $plugin_admin, 'add_action_links');
234
235 $this->loader->add_action( 'elementor/widgets/widgets_registered', $plugin_admin, 'poll_maker_el_widgets_registered' );
236
237 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'codemirror_enqueue_scripts');
238
239 // Add footer message
240 $this->loader->add_action( 'in_admin_footer', $plugin_admin, 'poll_maker_admin_footer', 1 );
241
242 // Add aditional links to the plugin
243 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'add_poll_row_meta' , 10 , 2 );
244
245 //Create quick poll
246 $this->loader->add_action( 'wp_ajax_ays_poll_maker_quick_start', $plugin_admin, 'ays_poll_maker_quick_start' );
247 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_maker_quick_start', $plugin_admin, 'ays_poll_maker_quick_start' );
248
249 // Sale Banner
250 $this->loader->add_action( 'admin_notices', $plugin_admin, 'ays_poll_sale_baner', 1 );
251 $this->loader->add_action( 'admin_notices', $plugin_admin, 'display_poll_creation_popup' );
252
253 $this->loader->add_action( 'wp_ajax_ays_poll_dismiss_button', $plugin_admin, 'ays_poll_dismiss_button' );
254 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_dismiss_button', $plugin_admin, 'ays_poll_dismiss_button' );
255
256
257 $this->loader->add_action( 'wp_ajax_ays_poll_create_author', $plugin_admin, 'ays_poll_create_author' );
258 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_create_author', $plugin_admin, 'ays_poll_create_author' );
259 $this->loader->add_action( 'wp_ajax_delete_challenge_box', $plugin_admin, 'delete_challenge_box' );
260 $this->loader->add_action( 'wp_ajax_nopriv_delete_challenge_box', $plugin_admin, 'delete_challenge_box' );
261
262 }
263
264 /**
265 * Register all of the hooks related to the public-facing functionality
266 * of the plugin.
267 *
268 * @since 1.0.0
269 * @access private
270 */
271 private function define_public_hooks() {
272
273 $plugin_public = new Poll_Maker_Ays_Public($this->get_plugin_name(), $this->get_version());
274 $plugin_public_extra_shortcodes = new Ays_Poll_Maker_Extra_Shortcodes_Public( $this->get_plugin_name(), $this->get_version() );
275
276 // $this->loader->add_action('init', $plugin_public, 'ays_poll_initialize_shortcode');
277
278 $this->loader->add_action('wp_ajax_ays_finish_poll', $plugin_public, 'ays_finish_poll');
279 $this->loader->add_action('wp_ajax_nopriv_ays_finish_poll', $plugin_public, 'ays_finish_poll');
280
281 $this->loader->add_action('wp_ajax_ays_poll_get_current_answer_users_pics', $plugin_public, 'ays_poll_get_current_answer_users_pics');
282 $this->loader->add_action('wp_ajax_nopriv_ays_poll_get_current_answer_users_pics', $plugin_public, 'ays_poll_get_current_answer_users_pics');
283
284 $this->loader->add_action('wp_ajax_ays_add_answer_poll', $plugin_public, 'ays_add_answer_poll');
285 $this->loader->add_action('wp_ajax_nopriv_ays_add_answer_poll', $plugin_public, 'ays_add_answer_poll');
286
287 /*$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
288 $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');*/
289 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles_early' );
290
291 $this->loader->add_action( 'wp_ajax_ays_poll_get_user_information', $plugin_public, 'ays_poll_get_user_information' );
292 $this->loader->add_action( 'wp_ajax_nopriv_ays_poll_get_user_information', $plugin_public, 'ays_poll_get_user_information' );
293 }
294
295 /**
296 * Run the loader to execute all of the hooks with WordPress.
297 *
298 * @since 1.0.0
299 */
300 public function run() {
301 $this->loader->run();
302 }
303
304 /**
305 * The name of the plugin used to uniquely identify it within the context of
306 * WordPress and to define internationalization functionality.
307 *
308 * @since 1.0.0
309 * @return string The name of the plugin.
310 */
311 public function get_plugin_name() {
312 return $this->plugin_name;
313 }
314
315 /**
316 * The reference to the class that orchestrates the hooks with the plugin.
317 *
318 * @since 1.0.0
319 * @return Poll_Maker_Ays_Loader Orchestrates the hooks of the plugin.
320 */
321 public function get_loader() {
322 return $this->loader;
323 }
324
325 /**
326 * Retrieve the version number of the plugin.
327 *
328 * @since 1.0.0
329 * @return string The version number of the plugin.
330 */
331 public function get_version() {
332 return $this->version;
333 }
334
335 }