PluginProbe
Ultimate FAQ Accordion Plugin / 2.4.14
Ultimate FAQ Accordion Plugin v2.4.14
2.4.14 2.4.13 2.4.12 2.4.11 2.4.10 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 241 releases
ultimate-faqs / ultimate-faqs.php

ultimate-faqs.php in Ultimate FAQ Accordion Plugin 2.4.14, at ultimate-faqs.php

818 lines 25.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Ultimate FAQ Accordion Plugin
4 * Plugin URI: https://www.etoilewebdesign.com/plugins/ultimate-faq/
5 * Description: Full-featured FAQ and accordion plugin with advanced search, simple UI and easy-to-use Gutenberg blocks and shortcodes.
6 * Version: 2.4.14
7 * Author: Etoile Web Design
8 * Author URI: https://www.etoilewebdesign.com/
9 * Text Domain: ultimate-faqs
10 * Domain Path: /languages
11 * Requires at least: 6.0
12 * Requires PHP: 7.4
13 * WC requires at least: 7.1
14 * WC tested up to: 11.0
15 */
16
17 if ( ! defined( 'ABSPATH' ) )
18 exit;
19
20 if ( ! class_exists( 'ewdufaqInit' ) ) {
21 class ewdufaqInit {
22
23 // pointers to classes used by the plugin, where needed
24 public $cpts;
25 public $notifications;
26 public $permissions;
27 public $settings;
28 public $woocommerce;
29 public $wpforms;
30
31 // Any data that needs to be passed from PHP to our JS files
32 public $front_end_php_js_data = array();
33
34 public $schema_faq_data = array();
35
36 // whether a shortcode is currently outputting content
37 public $shortcode_printing = false;
38
39 // whether a single FAQ page is being displayed
40 public $single_page_print = false;
41
42 /**
43 * Initialize the plugin and register hooks
44 */
45 public function __construct() {
46
47 self::constants();
48 self::includes();
49 self::instantiate();
50 self::wp_hooks();
51 }
52
53 /**
54 * Define plugin constants.
55 *
56 * @since 2.0.0
57 * @access protected
58 * @return void
59 */
60 protected function constants() {
61
62 define( 'EWD_UFAQ_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
63 define( 'EWD_UFAQ_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
64 define( 'EWD_UFAQ_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
65 define( 'EWD_UFAQ_TEMPLATE_DIR', 'ewd-ufaq-templates' );
66 define( 'EWD_UFAQ_VERSION', '2.4.14' );
67
68 define( 'EWD_UFAQ_FAQ_POST_TYPE', 'ufaq' );
69 define( 'EWD_UFAQ_FAQ_CATEGORY_TAXONOMY', 'ufaq-category' );
70 define( 'EWD_UFAQ_FAQ_TAG_TAXONOMY', 'ufaq-tag' );
71 }
72
73 /**
74 * Include necessary classes.
75 *
76 * @since 2.0.0
77 * @access protected
78 * @return void
79 */
80 protected function includes() {
81
82 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/AboutUs.class.php' );
83 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/AIAssist.class.php' );
84 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Ajax.class.php' );
85 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Blocks.class.php' );
86 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Patterns.class.php' );
87 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/CustomPostTypes.class.php' );
88 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Dashboard.class.php' );
89 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/DeactivationSurvey.class.php' );
90 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/FAQ.class.php' );
91 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Helper.class.php' );
92 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/InstallationWalkthrough.class.php' );
93 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Notifications.class.php' );
94 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/OrderingTable.class.php' );
95 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Permissions.class.php' );
96 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Query.class.php' );
97 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/ReviewAsk.class.php' );
98 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Settings.class.php' );
99 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/template-functions.php' );
100 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/UltimateWPMail.class.php' );
101 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/Widgets.class.php' );
102 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/WooCommerce.class.php' );
103 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/WPForms.class.php' );
104 }
105
106 /**
107 * Spin up instances of our plugin classes.
108 *
109 * @since 2.0.0
110 * @access protected
111 * @return void
112 */
113 protected function instantiate() {
114
115 new ewdufaqDashboard();
116 new ewdufaqDeactivationSurvey();
117 new ewdufaqInstallationWalkthrough();
118 new ewdufaqReviewAsk();
119
120 $this->cpts = new ewdufaqCustomPostTypes();
121 $this->notifications = new ewdufaqNotifications();
122 $this->permissions = new ewdufaqPermissions();
123 $this->settings = new ewdufaqSettings();
124
125 if ( $this->settings->get_setting( 'woocommerce-faqs' ) ) {
126
127 $this->woocommerce = new ewdufaqWooCommerce();
128 }
129
130 if ( $this->settings->get_setting( 'wpforms-integration' ) ) {
131
132 $this->wpforms = new ewdufaqWPForms();
133 }
134
135 new ewdufaqAJAX();
136 new ewdufaqAIAssist();
137 new ewdufaqBlocks();
138 if ( function_exists( 'register_block_pattern' ) ) { new ewdufaqPatterns(); }
139 new ewdufaqOrderingTable();
140 new ewdufaqUltimateWPMail();
141 new ewdufaqWidgetManager();
142
143 new ewdufaqAboutUs();
144 }
145
146 /**
147 * Run walk-through, load assets, add links to plugin listing, etc.
148 *
149 * @since 2.0.0
150 * @access protected
151 * @return void
152 */
153 protected function wp_hooks() {
154
155 register_activation_hook( __FILE__, array( $this, 'run_walkthrough' ) );
156 register_activation_hook( __FILE__, array( $this, 'convert_options' ) );
157
158 add_filter( 'ewd_ufaq_admin_menu', array( $this, 'admin_menu_optional' ) );
159
160 add_filter( 'init', array( $this, 'rewrite_rules' ) );
161 add_filter( 'query_vars', array( $this, 'add_query_vars' ) );
162 add_filter( 'redirect_canonical', array( $this, 'disable_canonical_redirect_for_front_page' ) );
163
164 add_filter( 'the_content', array( $this, 'alter_faq_content' ) );
165 add_filter( 'the_content', array( $this, 'add_faqs_content' ) );
166 add_action( 'wp_footer', array( $this, 'output_ld_json_content' ) );
167
168 add_action( 'init', array( $this, 'load_view_files' ) );
169
170 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
171
172 add_action( 'admin_notices', array( $this, 'display_header_area' ), 99 );
173 add_action( 'admin_notices', array( $this, 'maybe_display_helper_notice' ) );
174 add_action( 'admin_notices', array( $this, 'maybe_display_shortcode_notice' ) );
175 add_action( 'admin_notices', array( $this, 'maybe_display_new_plugin_notice' ) );
176
177 add_action( 'admin_footer', array( $this, 'display_help_bubble' ) );
178
179 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 10, 1 );
180 add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) );
181 add_action( 'wp_head', 'ewd_add_frontend_ajax_url' );
182 add_action( 'wp_footer', array( $this, 'assets_footer' ), 2 );
183 add_action( 'wp_footer', array( $this, 'ensure_assets_enqueued' ), 1 );
184
185 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2);
186
187 add_action( 'wp_ajax_ewd_ufaq_hide_helper_notice', array( $this, 'hide_helper_notice' ) );
188 add_action( 'wp_ajax_ewd_ufaq_hide_new_plugin_notice', array( $this, 'hide_new_plugin_notice' ) );
189
190 add_action( 'before_woocommerce_init', array( $this, 'declare_wc_hpos' ) );
191 }
192
193 /**
194 * Run the options conversion function on update if necessary
195 *
196 * @since 2.0.0
197 * @access public
198 * @return void
199 */
200 public function convert_options() {
201
202 require_once( EWD_UFAQ_PLUGIN_DIR . '/includes/BackwardsCompatibility.class.php' );
203 new ewdufaqBackwardsCompatibility();
204 }
205
206 /**
207 * Adds in the rewrite rules used by the plugin and flushes rules if necessary
208 *
209 * @since 2.0.0
210 * @access public
211 * @return void
212 */
213 public function rewrite_rules() {
214
215 $review_rules = get_option( 'rewrite_rules' );
216 $frontpage_id = get_option( 'page_on_front' );
217
218 add_rewrite_tag( '%single_faq%', '([^&]+)' );
219 add_rewrite_tag( '%ufaq_category_slug%', '([^+]+)' );
220 add_rewrite_tag( '%ufaq_tag_slug%', '([^?]+)' );
221
222 add_rewrite_rule( "single-faq/([^&]*)/?$", "index.php?page_id=". $frontpage_id . "&single_faq=\$matches[1]", 'top' );
223 add_rewrite_rule( "(.?.+?)/single-faq/([^&]*)/?$", "index.php?pagename=\$matches[1]&single_faq=\$matches[2]", 'top' );
224 add_rewrite_rule( "faq-category/([^+]*)/?$", "index.php?page_id=". $frontpage_id . "&ufaq_category_slug=\$matches[1]", 'top' );
225 add_rewrite_rule( "(.?.+?)/faq-category/([^+]*)/?$", "index.php?pagename=\$matches[1]&ufaq_category_slug=\$matches[2]", 'top' );
226 add_rewrite_rule( "faq-tag/([^?]*)/?$", "index.php?page_id=". $frontpage_id . "&ufaq_tag_slug=\$matches[1]", 'top' );
227 add_rewrite_rule( "(.?.+?)/faq-tag/([^?]*)/?$", "index.php?pagename=\$matches[1]&ufaq_tag_slug=\$matches[2]", 'top' );
228
229 if ( ! isset( $review_rules['(.?.+?)/single-faq/([^&]*)/?$'] ) ) { flush_rewrite_rules(); }
230 }
231
232 /**
233 * Adds in the query vars used by the plugin
234 *
235 * @since 2.0.0
236 * @access public
237 * @return array
238 */
239 public function add_query_vars( $vars ) {
240
241 $vars[] = 'single_faq';
242 $vars[] = 'ufaq_category_slug';
243 $vars[] = 'ufaq_tag_slug';
244
245 return $vars;
246 }
247
248 /**
249 * Disables the automatic redirect that happens on the front-page
250 *
251 * @since 2.0.0
252 * @access public
253 * @return array
254 */
255 public function disable_canonical_redirect_for_front_page( $redirect ) {
256 global $ewd_ufaq_controller;
257
258 if ( empty( $ewd_ufaq_controller->settings->get_setting( 'disable-homepage-canoncial-redirect' ) ) ) { return $redirect; }
259
260 if ( ! is_page() ) { return $redirect; }
261
262 $front_page = get_option( 'page_on_front' );
263
264 if ( ! is_page( $front_page ) ) { return $redirect; }
265
266 return false;
267 }
268
269 /**
270 * Load files needed for views
271 * @since 2.0.0
272 * @note Can be filtered to add new classes as needed
273 */
274 public function load_view_files() {
275
276 $files = array(
277 EWD_UFAQ_PLUGIN_DIR . '/views/Base.class.php' // This will load all default classes
278 );
279
280 $files = apply_filters( 'ewd_ufaq_load_view_files', $files );
281
282 foreach( $files as $file ) {
283 require_once( $file );
284 }
285
286 }
287
288 /**
289 * Load the plugin textdomain for localisation
290 * @since 2.0.0
291 */
292 public function load_textdomain() {
293
294 load_plugin_textdomain( 'ultimate-faqs', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
295 }
296
297 /**
298 * Set a transient so that the walk-through gets run
299 * @since 2.0.0
300 */
301 public function run_walkthrough() {
302
303 set_transient( 'ewd-ufaq-getting-started', true, 30 );
304 }
305
306 /**
307 * Enqueue the admin-only CSS and Javascript
308 * @since 2.0.0
309 */
310 public function enqueue_admin_assets( $hook ) {
311
312 wp_enqueue_script( 'ewd-ufaq-helper-notice', EWD_UFAQ_PLUGIN_URL . '/assets/js/ewd-ufaq-helper-install-notice.js', array( 'jquery' ), EWD_UFAQ_VERSION, true );
313 wp_localize_script(
314 'ewd-ufaq-helper-notice',
315 'ewd_ufaq_helper_notice',
316 array( 'nonce' => wp_create_nonce( 'ewd-ufaq-helper-notice' ) )
317 );
318
319 wp_enqueue_style( 'ewd-ufaq-helper-notice', EWD_UFAQ_PLUGIN_URL . '/assets/css/ewd-ufaq-helper-install-notice.css', array(), EWD_UFAQ_VERSION );
320
321 $screen = get_current_screen();
322
323 $hooks = array(
324 'widgets.php',
325 'ufaq_page_ewd-ufaq-ordering-table',
326 'ufaq_page_ewd-ufaq-settings'
327 );
328
329 $screen_ids = array(
330 'ufaq',
331 'ufaq_page_ewd-ufaq-dashboard',
332 'edit-ufaq',
333 'edit-ufaq-category',
334 'edit-ufaq-tag',
335 'ufaq_page_ewd-ufaq-about-us',
336 'ufaq_page_ewd-ufaq-export',
337 'ufaq_page_ewd-ufaq-import'
338 );
339
340 if ( ! in_array( $hook, $hooks ) and ! in_array( $screen->id, $screen_ids ) ) { return; }
341
342 wp_enqueue_style( 'ewd-ufaq-admin-css', EWD_UFAQ_PLUGIN_URL . '/assets/css/ewd-ufaq-admin.css', array(), EWD_UFAQ_VERSION );
343
344 wp_enqueue_script( 'jquery-ui-core' );
345 wp_enqueue_script( 'jquery-ui-sortable' );
346
347 wp_register_script( 'ewd-ufaq-admin-js', EWD_UFAQ_PLUGIN_URL . '/assets/js/ewd-ufaq-admin.js', array( 'jquery', 'jquery-ui-sortable' ), EWD_UFAQ_VERSION, true );
348
349 $args = array(
350 'nonce' => wp_create_nonce( 'ewd-ufaq-admin-js' ),
351 'ordering' => $this->permissions->check_permission( 'ordering' )
352 );
353
354 wp_localize_script( 'ewd-ufaq-admin-js', 'ewd_ufaq_php_data', $args );
355
356 wp_enqueue_script( 'ewd-ufaq-admin-js' );
357 }
358
359 /**
360 * Register the front-end CSS and Javascript for the FAQs
361 * @since 2.0.0
362 */
363 public function register_assets() {
364
365 wp_register_style( 'ewd-ufaq-rrssb', EWD_UFAQ_PLUGIN_URL . '/assets/css/rrssb-min.css', array(), EWD_UFAQ_VERSION );
366 wp_register_style( 'ewd-ufaq-jquery-ui', EWD_UFAQ_PLUGIN_URL . '/assets/css/jquery-ui.min.css', array(), EWD_UFAQ_VERSION );
367
368 wp_register_style( 'ewd-ufaq-css', EWD_UFAQ_PLUGIN_URL . '/assets/css/ewd-ufaq.css', array(), EWD_UFAQ_VERSION );
369 wp_register_style( 'ewd-ufaq-minimalist', EWD_UFAQ_PLUGIN_URL . '/assets/css/ewd-ufaq-minimalist.css', array(), EWD_UFAQ_VERSION );
370
371 wp_register_script( 'ewd-ufaq-js', EWD_UFAQ_PLUGIN_URL . '/assets/js/ewd-ufaq.js', array( 'jquery', 'jquery-ui-core' ), EWD_UFAQ_VERSION, true );
372 }
373
374 /**
375 * Print out any PHP data needed for our JS to work correctly
376 * @since 2.1.0
377 */
378 public function assets_footer() {
379
380 if ( empty( $this->front_end_php_js_data ) ) { return; }
381
382 $print_variables = array();
383
384 foreach ( (array) $this->front_end_php_js_data as $variable => $values ) {
385
386 if ( empty( $values ) ) { continue; }
387
388 $print_variables[ $variable ] = ewdufaqHelper::escape_js_recursive( $values );
389 }
390
391 foreach ( $print_variables as $variable => $values ) {
392
393 echo "<script type='text/javascript'>\n";
394 echo "/* <![CDATA[ */\n";
395 echo 'var ' . esc_attr( $variable ) . ' = ' . wp_json_encode( $values ) . "\n";
396 echo "/* ]]> */\n";
397 echo "</script>\n";
398 }
399 }
400
401 /**
402 * Adds a variable to be passed to our front-end JS
403 * @since 2.1.0
404 */
405 public function add_front_end_php_data( $handle, $variable, $data ) {
406
407 $this->front_end_php_js_data[ $variable ] = $data;
408 }
409
410 /**
411 * Returns the corresponding front-end JS variable if it exists, otherwise an empty array
412 * @since 2.1.0
413 */
414 public function get_front_end_php_data( $handle, $variable ) {
415
416 return ! empty( $this->front_end_php_js_data[ $variable ] ) ? $this->front_end_php_js_data[ $variable ] : array();
417 }
418
419 /**
420 * Make sure styles were enqueued
421 * @since 2.4.12
422 */
423 public function ensure_assets_enqueued() {
424
425 if ( wp_style_is( 'ewd-ufaq-rrssb', 'enqueued' ) && ! wp_style_is( 'ewd-ufaq-rrssb', 'done' ) ) { wp_print_styles( 'ewd-ufaq-rrssb' ); }
426 if ( wp_style_is( 'ewd-ufaq-jquery-ui', 'enqueued' ) && ! wp_style_is( 'ewd-ufaq-jquery-ui', 'done' ) ) { wp_print_styles( 'ewd-ufaq-jquery-ui' ); }
427 if ( wp_style_is( 'ewd-ufaq-css', 'enqueued' ) && ! wp_style_is( 'ewd-ufaq-css', 'done' ) ) { wp_print_styles( 'ewd-ufaq-css' ); }
428 if ( wp_style_is( 'ewd-ufaq-minimalist', 'enqueued' ) && ! wp_style_is( 'ewd-ufaq-minimalist', 'done' ) ) { wp_print_styles( 'ewd-ufaq-minimalist' ); }
429 }
430
431 /**
432 * Add links to the plugin listing on the installed plugins page
433 * @since 2.0.0
434 */
435 public function plugin_action_links( $links, $plugin ) {
436 global $ewd_ufaq_controller;
437
438 if ( $plugin == EWD_UFAQ_PLUGIN_FNAME ) {
439
440 if ( ! $ewd_ufaq_controller->permissions->check_permission( 'premium' ) ) {
441
442 array_unshift( $links, '<a class="ewd-ufaq-plugin-page-upgrade-link" href="https://www.etoilewebdesign.com/license-payment/?Selected=UFAQ&Quantity=1&utm_source=wp_admin_plugins_page" title="' . __( 'Try Premium', 'ultimate-faqs' ) . '" target="_blank">' . __( 'Try Premium', 'ultimate-faqs' ) . '</a>' );
443 }
444
445 $links['settings'] = '<a href="admin.php?page=ewd-ufaq-settings" title="' . __( 'Head to the settings page for Ultimate FAQs', 'ultimate-faqs' ) . '">' . __( 'Settings', 'ultimate-faqs' ) . '</a>';
446 }
447
448 return $links;
449
450 }
451
452 /**
453 * Replace the content of the single FAQ page with the FAQ shortcode
454 * @since 2.0.0
455 */
456 public function alter_faq_content( $content ) {
457 global $post, $ewd_ufaq_controller;
458
459 if ( empty( $post ) ) { return $content; }
460
461 if ( $post->post_type != EWD_UFAQ_FAQ_POST_TYPE ) { return $content; }
462
463 if ( ! empty( $ewd_ufaq_controller->shortcode_printing ) ) { return $content; }
464
465 if ( is_archive() ) { return $content; }
466
467 $ewd_ufaq_controller->single_page_print = true;
468
469 $content = do_shortcode( '[select-faq faq_id="' . $post->ID . '"]' );
470
471 $ewd_ufaq_controller->single_page_print = false;
472
473 return $content;
474 }
475
476 /**
477 * Append the ultimate-faqs shortcode to a post's $content variable
478 * @since 2.1.12
479 */
480 function add_faqs_content( $content ) {
481 global $post;
482
483 if ( ! is_main_query() || ! in_the_loop() ) {
484
485 return $content;
486 }
487
488 if ( $this->settings->get_setting( 'faq-page' ) === $post->ID ) {
489
490 return $content . do_shortcode( '[ultimate-faqs]' );
491 }
492
493 return $content;
494 }
495
496 /**
497 * Output any FAQ schema data, if enabled
498 *
499 * @since 2.0.0
500 */
501 public function output_ld_json_content() {
502 global $ewd_ufaq_controller;
503
504 if ( empty( $this->schema_faq_data ) ) { return; }
505
506 if ( $ewd_ufaq_controller->settings->get_setting( 'disable-microdata' ) ) { return; }
507
508 $ewd_ufaq_schema_data = array(
509 '@context' => 'https://schema.org',
510 '@type' => 'FAQPage',
511 'mainEntity' => $this->schema_faq_data
512 );
513
514 $ld_json_ouptut = apply_filters( 'ewd_ufaq_ld_json_output', $ewd_ufaq_schema_data );
515
516 echo '<script type="application/ld+json" class="ewd-ufaq-ld-json-data">';
517 echo wp_json_encode( $ld_json_ouptut );
518 echo '</script>';
519 }
520
521 /**
522 * Adds in a menu bar for the plugin
523 * @since 2.0.0
524 */
525 public function display_header_area() {
526 global $ewd_ufaq_controller;
527
528 $screen = get_current_screen();
529
530 if ( empty( $screen->parent_file ) or $screen->parent_file != 'edit.php?post_type=ufaq' ) { return; }
531
532 if ( ! $ewd_ufaq_controller->permissions->check_permission( 'styling' ) or get_option( 'EWD_UFAQ_Trial_Happening' ) == 'Yes' ) {
533 ?>
534 <div class="ewd-ufaq-dashboard-new-upgrade-banner">
535 <div class="ewd-ufaq-dashboard-banner-icon"></div>
536 <div class="ewd-ufaq-dashboard-banner-buttons">
537 <a class="ewd-ufaq-dashboard-new-upgrade-button" href="https://www.etoilewebdesign.com/license-payment/?Selected=UFAQ&Quantity=1&utm_source=ufaq_admin&utm_content=banner" target="_blank">UPGRADE NOW</a>
538 </div>
539 <div class="ewd-ufaq-dashboard-banner-text">
540 <div class="ewd-ufaq-dashboard-banner-title">
541 GET FULL ACCESS WITH OUR PREMIUM VERSION
542 </div>
543 <div class="ewd-ufaq-dashboard-banner-brief">
544 WooCommerce Integration, Advanced styling options, Advanced control options and more!
545 </div>
546 </div>
547 </div>
548 <?php
549 }
550
551 $menu_list = apply_filters(
552 'ewd_ufaq_admin_menu',
553 array(
554 array(
555 'id' => 'dashboard-menu',
556 'label' => __("Dashboard", 'ultimate-faqs'),
557 'url' => 'admin.php?page=ewd-ufaq-dashboard',
558 'screen-id' => 'ufaq_ewd-ufaq-dashboard',
559 ),
560 array(
561 'id' => 'faqs-menu',
562 'label' => __("FAQs", 'ultimate-faqs'),
563 'url' => 'edit.php?post_type=ufaq',
564 'screen-id' => 'edit-ufaq',
565 ),
566 array(
567 'id' => 'add-faq-menu',
568 'label' => __("Add New", 'ultimate-faqs'),
569 'url' => 'post-new.php?post_type=ufaq',
570 'screen-id' => 'not-required',
571 ),
572 array(
573 'id' => 'categories-menu',
574 'label' => __("Categories", 'ultimate-faqs'),
575 'url' => 'edit-tags.php?taxonomy=ufaq-category&post_type=ufaq',
576 'screen-id' => 'edit-ufaq-category',
577 ),
578 array(
579 'id' => 'tags-menu',
580 'label' => __("Tags", 'ultimate-faqs'),
581 'url' => 'edit-tags.php?taxonomy=ufaq-tag&post_type=ufaq',
582 'screen-id' => 'edit-ufaq-tag',
583 ),
584 array(
585 'id' => 'options-menu',
586 'label' => __("Settings", 'ultimate-faqs'),
587 'url' => 'edit.php?post_type=ufaq&page=ewd-ufaq-settings',
588 'screen-id' => 'ufaq_page_ewd-ufaq-settings',
589 )
590 )
591 );
592
593 ?>
594 <div class="ewd-ufaq-admin-header-menu">
595 <h2 class="nav-tab-wrapper">
596 <a
597 id="ewd-ufaq-dash-mobile-menu-open"
598 href="#"
599 class="menu-tab nav-tab">
600 <?php _e("MENU", 'ultimate-faqs'); ?>
601 <span id="ewd-ufaq-dash-mobile-menu-down-caret">&nbsp;&nbsp;&#9660;</span>
602 <span id="ewd-ufaq-dash-mobile-menu-up-caret">&nbsp;&nbsp;&#9650;</span>
603 </a>
604
605 <?php
606 foreach ($menu_list as $menu) {
607 $active = $screen->id == $menu['screen-id'] ? 'nav-tab-active' : '';
608 ?>
609 <a
610 id='<?php echo esc_attr( $menu['id'] ); ?>'
611 href='<?php echo esc_attr( $menu['url'] ); ?>'
612 class='menu-tab nav-tab <?php echo esc_attr( $active ); ?>'>
613 <?php echo esc_html( $menu['label'] ); ?>
614 </a>
615 <?php
616 }
617 ?>
618
619 </h2>
620 </div>
621 <?php
622 }
623
624 public function maybe_display_helper_notice() {
625 global $ewd_ufaq_controller;
626
627 if ( empty( $ewd_ufaq_controller->permissions->check_permission( 'premium' ) ) ) { return; }
628
629 if ( is_plugin_active( 'ewd-premium-helper/ewd-premium-helper.php' ) ) { return; }
630
631 if ( get_transient( 'ewd-helper-notice-dismissed' ) ) { return; }
632
633 ?>
634
635 <div class='notice notice-error is-dismissible ewd-ufaq-helper-install-notice'>
636
637 <div class='ewd-ufaq-helper-install-notice-img'>
638 <img src='<?php echo EWD_UFAQ_PLUGIN_URL . '/lib/simple-admin-pages/img/options-asset-exclamation.png' ; ?>' />
639 </div>
640
641 <div class='ewd-ufaq-helper-install-notice-txt'>
642 <?php _e( 'You\'re using the Ultimate FAQs premium version, but the premium helper plugin is not active.', 'ultimate-faqs' ); ?>
643 <br />
644 <?php echo sprintf( __( 'Please re-activate the helper plugin, or <a target=\'_blank\' href=\'%s\'>download and install it</a> if the plugin is no longer installed to ensure continued access to the premium features of the plugin.', 'ultimate-faqs' ), 'https://www.etoilewebdesign.com/2021/12/11/requiring-premium-helper-plugin/' ); ?>
645 </div>
646
647 <div class='ewd-ufaq-clear'></div>
648
649 </div>
650
651 <?php
652 }
653
654 public function hide_helper_notice() {
655 global $ewd_ufaq_controller;
656
657 // Authenticate request
658 if (
659 ! check_ajax_referer( 'ewd-ufaq-helper-notice', 'nonce' )
660 ||
661 ! current_user_can( $ewd_ufaq_controller->settings->get_setting( 'access-role' ) )
662 ) {
663 ewdufaqHelper::admin_nopriv_ajax();
664
665 }
666
667 set_transient( 'ewd-helper-notice-dismissed', true, 3600*24*7 );
668
669 die();
670 }
671
672 public function maybe_display_shortcode_notice() {
673
674 $screen = get_current_screen();
675 if ( empty( $screen->parent_file ) or $screen->parent_file != 'edit.php?post_type=ufaq' ) { return; }
676
677 $counts = wp_count_posts( EWD_UFAQ_FAQ_POST_TYPE );
678 $faq_count = isset( $counts->publish ) ? (int) $counts->publish : 0;
679
680 if ( $faq_count > 3 ) { return; }
681
682 ?>
683
684 <div class='notice notice-info is-dismissible'>
685
686 <div class='ewd-ufaq-shortcode-helper'>
687 <p><?php _e( 'Thanks for installing! Add FAQs to your site using the [ultimate-faqs] shortcode or the Display FAQs block.', 'ultimate-faqs' ); ?></p>
688 </div>
689
690 <div class='ewd-ufaq-clear'></div>
691
692 </div>
693
694 <?php
695 }
696
697 public function maybe_display_new_plugin_notice() {
698
699 if ( ! current_user_can( 'activate_plugins' ) ) { return; }
700
701 $screen = get_current_screen();
702
703 if ( ! isset( $screen->id ) ) { return; }
704
705 $allowed_screens = array(
706 'plugins',
707 'update-core',
708 'dashboard',
709 'options-general',
710 'options-writing',
711 'options-reading',
712 'options-discussion',
713 'options-media',
714 'options-permalink',
715 'options-privacy'
716 );
717
718 if ( strpos( $screen->id, 'ufaq_page_' ) === false and
719 ! in_array( $screen->id, $allowed_screens ) ) {
720 return;
721 }
722
723 if ( get_transient( 'ait-aiaa-plugin-notice-dismissed' ) ) { return; }
724
725 // May 22nd, 2026
726 if ( time() > 1779508748 ) { return; }
727
728 $hook_lines = array(
729 __( 'Tired of digging through settings? Let <strong>AI Admin Assistance</strong> guide you!', 'ultimate-faqs' ),
730 __( 'Stop wasting time searching for answers—use <strong>AI Admin Assistance</strong> to bring AI-powered help directly into your dashboard!', 'ultimate-faqs' ),
731 __( 'Overwhelmed in the WordPress admin? <strong>AI Admin Assistance</strong> has you covered with AI-powered help directly in your dashboard!', 'ultimate-faqs' ),
732 );
733
734 $selection = array_rand( $hook_lines );
735
736 ?>
737
738 <div class='notice notice-error is-dismissible ait-aiaa-new-plugin-notice'>
739
740 <div class='ewd-ufaq-new-plugin-notice-img'>
741 <img src='<?php echo EWD_UFAQ_PLUGIN_URL . '/assets/img/ait-aiaa-plugin-icon.png' ; ?>' />
742 </div>
743
744 <div class='ewd-ufaq-new-plugin-notice-txt'>
745 <p><?php echo $hook_lines[ $selection ]; ?></p>
746 <p><?php echo sprintf( __( 'As a thank you to our customers, for a limited time you can get a <strong>free pro license</strong>! Try the <a target=\'_blank\' href=\'%s\'>free version</a> today or use code <code>early_adopter_pro</code> to <a target=\'_blank\' href=\'%s\'>get your pro version license</a>!', 'ultimate-faqs' ), admin_url( 'plugin-install.php?tab=plugin-information&plugin=ait-ai-admin-assistance' ), 'https://www.wpaiplugins.dev/wordpress-ai-admin-assistance/?utm_source=' . dirname( EWD_UFAQ_PLUGIN_FNAME ) . '_aiaa_notice&utm_content=' . $selection ); ?></p>
747 </div>
748
749 <div class='ewd-ufaq-clear'></div>
750
751 </div>
752
753 <?php
754 }
755
756 public function hide_new_plugin_notice() {
757 global $ewd_ufaq_controller;
758
759 // Authenticate request
760 if (
761 ! check_ajax_referer( 'ewd-ufaq-helper-notice', 'nonce' )
762 ||
763 ! current_user_can( $ewd_ufaq_controller->settings->get_setting( 'access-role' ) )
764 ) {
765 ewdufaqHelper::admin_nopriv_ajax();
766
767 }
768
769 set_transient( 'ait-aiaa-plugin-notice-dismissed', true, 3600*24*7 );
770
771 die();
772 }
773
774 public function display_help_bubble() {
775
776 ewdufaqHelper::display_help_button();
777 }
778
779 public function admin_menu_optional( $menu_list ) {
780 global $ewd_ufaq_controller;
781
782 if ( $ewd_ufaq_controller->settings->get_setting( 'faq-order-by' ) == 'set_order' ) {
783 array_splice(
784 $menu_list,
785 count( $menu_list ) - 1,
786 0,
787 array(
788 array(
789 'id' => 'ordering-table',
790 'label' => __("FAQ Order", 'ultimate-faqs'),
791 'url' => 'edit.php?post_type=ufaq&page=ewd-ufaq-ordering-table',
792 'screen-id' => 'ufaq_page_ewd-ufaq-ordering-table',
793 )
794 )
795 );
796 }
797
798 return $menu_list;
799 }
800
801 /**
802 * Declares compatibility with WooCommerce High-Performance Order Storage
803 * @since 2.2.9
804 */
805 public function declare_wc_hpos() {
806
807 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
808
809 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
810 }
811 }
812 }
813 } // endif;
814
815 global $ewd_ufaq_controller;
816 $ewd_ufaq_controller = new ewdufaqInit();
817
818 do_action( 'ewd_ufaq_initialized' );