PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.14
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.14
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 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.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/codeinwp/themeisle-sdk/src/Modules/Promotions.php +54 -443 4.0.73.11.14 View file →
@@ -201,216 +201,17 @@
201 201
202 202 add_filter( 'attachment_fields_to_edit', array( $this, 'add_attachment_field' ), 10, 2 );
203 203 add_action( 'current_screen', [ $this, 'load_available' ] );
204 204 add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'enqueue' ) );
205 - add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_visualizer_block_editor_shim' ), 100 );
206 205 add_action( 'wp_ajax_tisdk_update_option', array( $this, 'dismiss_promotion' ) );
207 - add_filter( 'plugins_api_result', array( $this, 'inject_visualizer_block_directory_suggestion' ), 10, 3 );
208 - add_filter( 'option_visualizer-activated', array( $this, 'suppress_visualizer_onboarding_in_editor' ) );
209 206 add_filter( 'themeisle_sdk_ran_promos', '__return_true' );
210 207
211 208 if ( get_option( $this->option_neve, false ) !== true ) {
212 - add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', 'ThemeisleSDK\Modules\Notification::dismiss' );
209 + add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', 'ThemeisleSDK\Modules\Notification::regular_dismiss' );
213 210 }
214 211 }
215 212
216 -
217 213 /**
218 - * Inject Visualizer as the first block-directory suggestion for chart queries.
219 - *
220 - * @param object|WP_Error $res Response object or WP_Error.
221 - * @param string $action The API action.
222 - * @param object $args The API arguments.
223 - * @return object|WP_Error
224 - */
225 - public function inject_visualizer_block_directory_suggestion( $res, $action, $args ) {
226 - if ( 'query_plugins' !== $action || ! is_object( $args ) || empty( $args->block ) ) {
227 - return $res;
228 - }
229 -
230 - if ( ! $this->should_suggest_visualizer( $args->block ) ) {
231 - return $res;
232 - }
233 -
234 - if ( $this->is_plugin_installed( 'visualizer' ) ) {
235 - return $res;
236 - }
237 -
238 - $plugin = $this->get_visualizer_block_directory_data();
239 - if ( empty( $plugin ) ) {
240 - return $res;
241 - }
242 -
243 - if ( is_wp_error( $res ) ) {
244 - $res = (object) array( 'plugins' => array() );
245 - }
246 -
247 - if ( ! isset( $res->plugins ) || ! is_array( $res->plugins ) ) {
248 - $res->plugins = array();
249 - }
250 -
251 - $res->plugins = array_values(
252 - array_filter(
253 - $res->plugins,
254 - function ( $existing ) use ( $plugin ) {
255 - return ! isset( $existing['slug'] ) || $existing['slug'] !== $plugin['slug'];
256 - }
257 - )
258 - );
259 -
260 - array_unshift( $res->plugins, $plugin );
261 -
262 - return $res;
263 - }
264 -
265 - /**
266 - * Check if the query should trigger the Visualizer suggestion.
267 - *
268 - * @param string $term Search term.
269 - * @return bool
270 - */
271 - private function should_suggest_visualizer( $term ) {
272 - $term = strtolower( (string) $term );
273 - return false !== strpos( $term, 'chart' ) || false !== strpos( $term, 'visualizer' ) || false !== strpos( $term, 'visualization' ) || false !== strpos( $term, 'graph' );
274 - }
275 -
276 - /**
277 - * Build the plugin data for Visualizer block directory results.
278 - *
279 - * @return array
280 - */
281 - private function get_visualizer_block_directory_data() {
282 - $slug = 'visualizer';
283 - $plugin_info = $this->call_plugin_api( $slug );
284 -
285 - if ( is_wp_error( $plugin_info ) || empty( $plugin_info ) ) {
286 - return array();
287 - }
288 -
289 - $icons = array();
290 - if ( ! empty( $plugin_info->icons ) ) {
291 - if ( ! empty( $plugin_info->icons['1x'] ) ) {
292 - $icons['1x'] = $plugin_info->icons['1x'];
293 - }
294 - if ( ! empty( $plugin_info->icons['2x'] ) ) {
295 - $icons['2x'] = $plugin_info->icons['2x'];
296 - }
297 - }
298 -
299 - $name = isset( $plugin_info->name ) ? $plugin_info->name : 'Visualizer';
300 -
301 - return array(
302 - 'slug' => $slug,
303 - 'name' => $name,
304 - 'short_description' => isset( $plugin_info->short_description ) ? $plugin_info->short_description : '',
305 - 'author' => isset( $plugin_info->author ) ? wp_strip_all_tags( $plugin_info->author ) : '',
306 - 'rating' => isset( $plugin_info->rating ) ? (int) $plugin_info->rating : 0,
307 - 'num_ratings' => isset( $plugin_info->num_ratings ) ? (int) $plugin_info->num_ratings : 0,
308 - 'active_installs' => isset( $plugin_info->active_installs ) ? (int) $plugin_info->active_installs : 0,
309 - 'author_block_rating' => isset( $plugin_info->author_block_rating ) ? (int) $plugin_info->author_block_rating : 0,
310 - 'author_block_count' => isset( $plugin_info->author_block_count ) ? (int) $plugin_info->author_block_count : 0,
311 - 'icons' => $icons,
312 - 'last_updated' => isset( $plugin_info->last_updated ) ? $plugin_info->last_updated : gmdate( 'Y-m-d H:i:s' ),
313 - 'blocks' => array(
314 - array(
315 - 'name' => 'visualizer/chart',
316 - 'title' => $name,
317 - ),
318 - ),
319 - );
320 - }
321 -
322 -
323 - /**
324 - * Prevent Visualizer onboarding redirects while in the block editor.
325 - *
326 - * @param mixed $value Option value.
327 - * @return mixed
328 - */
329 - public function suppress_visualizer_onboarding_in_editor( $value ) {
330 - if ( ! $this->is_block_editor_screen() ) {
331 - return $value;
332 - }
333 -
334 - return false;
335 - }
336 -
337 - /**
338 - * Add a small compatibility shim for Visualizer's block editor bundle.
339 - *
340 - * Visualizer's "Display an existing chart" flow reads
341 - * `google.visualization.Version` before the Google Charts loader has fully
342 - * populated `google.visualization`, which can throw after dynamic install.
343 - *
344 - * @return void
345 - */
346 - public function enqueue_visualizer_block_editor_shim() {
347 - global $themeisle_sdk_max_version;
348 -
349 - if ( ! $this->is_block_editor_screen() ) {
350 - return;
351 - }
352 -
353 - if ( ! wp_script_is( 'visualizer-gutenberg-block', 'enqueued' ) ) {
354 - return;
355 - }
356 -
357 - wp_register_script(
358 - 'ti-sdk-visualizer-editor-shim',
359 - '',
360 - array(),
361 - $themeisle_sdk_max_version,
362 - true
363 - );
364 - wp_enqueue_script( 'ti-sdk-visualizer-editor-shim' );
365 - wp_add_inline_script(
366 - 'ti-sdk-visualizer-editor-shim',
367 - 'window.google = window.google || {}; window.google.visualization = window.google.visualization || {}; window.google.visualization.Version = window.google.visualization.Version || "current";'
368 - );
369 - }
370 -
371 - /**
372 - * Check if the current admin screen is the block editor.
373 - *
374 - * @return bool
375 - */
376 - private function is_block_editor_screen() {
377 - if ( ! function_exists( 'get_current_screen' ) ) {
378 - return $this->is_block_editor_request();
379 - }
380 -
381 - $screen = get_current_screen();
382 - if ( is_object( $screen ) && method_exists( $screen, 'is_block_editor' ) && $screen->is_block_editor() ) {
383 - return true;
384 - }
385 -
386 - return $this->is_block_editor_request();
387 - }
388 -
389 - /**
390 - * Detect block editor requests before the current screen is available.
391 - *
392 - * @return bool
393 - */
394 - private function is_block_editor_request() {
395 - global $pagenow;
396 -
397 - if ( 'post-new.php' === $pagenow ) {
398 - $post_type = isset( $_GET['post_type'] ) ? sanitize_key( $_GET['post_type'] ) : 'post';
399 -
400 - return function_exists( 'use_block_editor_for_post_type' ) ? use_block_editor_for_post_type( $post_type ) : true;
401 - }
402 -
403 - if ( 'post.php' === $pagenow && isset( $_GET['post'] ) ) {
404 - $post_id = absint( $_GET['post'] );
405 -
406 - return function_exists( 'use_block_editor_for_post' ) ? use_block_editor_for_post( $post_id ) : true;
407 - }
408 -
409 - return false;
410 - }
411 -
412 - /**
413 214 * Load available promotions.
414 215 */
415 216 public function load_available() {
416 217 $this->promotions = $this->filter_by_screen_and_merge();
@@ -620,17 +421,14 @@
620 421 $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' );
621 422 $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' );
622 423 $has_redirection_cf7 = defined( 'WPCF7_PRO_REDIRECT_PLUGIN_VERSION' ) || $this->is_plugin_installed( 'wpcf7-redirect' );
623 424 $had_redirection_cf7_promo = get_option( $this->option_redirection_cf7, false );
624 - $is_min_php_7_4 = version_compare( PHP_VERSION, '7.4', '>=' );
625 - $is_min_php_7_2 = version_compare( PHP_VERSION, '7.2', '>=' );
626 - $can_check_plugin_install = $this->can_check_plugin_install_promo();
627 425 $has_hyve = defined( 'HYVE_LITE_VERSION' ) || $this->is_plugin_installed( 'hyve' ) || $this->is_plugin_installed( 'hyve-lite' );
628 426 $had_hyve_from_promo = get_option( $this->option_hyve, false );
629 - $has_hyve_conditions = $is_min_php_7_4 && ! $has_hyve && ! $had_hyve_from_promo && version_compare( get_bloginfo( 'version' ), '6.2', '>=' ) && $can_check_plugin_install && $this->has_support_page();
427 + $has_hyve_conditions = version_compare( get_bloginfo( 'version' ), '6.2', '>=' ) && $this->has_support_page();
630 428 $has_wfp_full_pay = defined( 'WP_FULL_STRIPE_BASENAME' ) || $this->is_plugin_installed( 'wp-full-stripe-free' );
631 429 $had_wfp_from_promo = get_option( $this->option_wp_full_pay, false );
632 - $has_wfp_conditions = ! $has_wfp_full_pay && ! $had_wfp_from_promo && $can_check_plugin_install && $this->has_donate_page();
430 + $has_wfp_conditions = $this->has_donate_page();
633 431 $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' );
634 432 $current_theme = wp_get_theme();
635 433 $has_neve = $current_theme->template === 'neve' || $current_theme->parent() === 'neve';
636 434 $has_neve_from_promo = get_option( $this->option_neve, false );
@@ -635,12 +433,15 @@
635 433 $has_neve = $current_theme->template === 'neve' || $current_theme->parent() === 'neve';
636 434 $has_neve_from_promo = get_option( $this->option_neve, false );
637 435 $has_enough_attachments = $this->has_min_media_attachments();
638 436 $has_enough_old_posts = $this->has_old_posts();
437 + $is_min_php_7_4 = version_compare( PHP_VERSION, '7.4', '>=' );
639 438 $has_feedzy = defined( 'FEEDZY_BASEFILE' ) || $this->is_plugin_installed( 'feedzy-rss-feedss' );
640 439 $had_feedzy_from_promo = get_option( $this->option_feedzy, false );
440 + $has_masteriyo = defined( 'MASTERIYO_VERSION' ) || $this->is_plugin_installed( 'learning-management-system' );
641 441 $had_masteriyo_from_promo = get_option( $this->option_masteriyo, false );
642 - $has_masteriyo_conditions = $is_min_php_7_2 && ! $had_masteriyo_from_promo && ! $this->has_active_lms_plugin() && $can_check_plugin_install && $this->has_lms_tagline();
442 + $has_masteriyo_conditions = $this->has_lms_tagline();
443 + $is_min_php_7_2 = version_compare( PHP_VERSION, '7.2', '>=' );
643 444
644 445 $all = [
645 446 'optimole' => [
646 447 'om-editor' => [
@@ -736,21 +537,21 @@
736 537 ],
737 538 ],
738 539 'hyve' => [
739 540 'hyve-plugins-install' => [
740 - 'env' => $has_hyve_conditions,
541 + 'env' => $is_min_php_7_4 && ! $has_hyve && ! $had_hyve_from_promo && $has_hyve_conditions,
741 542 'screen' => 'plugin-install',
742 543 ],
743 544 ],
744 545 'wp_full_pay' => [
745 546 'wp-full-pay-plugins-install' => [
746 - 'env' => $has_wfp_conditions,
547 + 'env' => ! $has_wfp_full_pay && ! $had_wfp_from_promo && $has_wfp_conditions,
747 548 'screen' => 'plugin-install',
748 549 ],
749 550 ],
750 551 'learning-management-system' => [
751 552 'masteriyo-plugins-install' => [
752 - 'env' => $has_masteriyo_conditions,
553 + 'env' => $is_min_php_7_2 && ! $has_masteriyo && ! $had_masteriyo_from_promo && $has_masteriyo_conditions,
753 554 'screen' => 'plugin-install',
754 555 ],
755 556 ],
756 557 ];
@@ -1597,265 +1398,75 @@
1597 1398 /**
1598 1399 * Check if the user has a support page.
1599 1400 */
1600 1401 public function has_support_page() {
1601 - $page_title_matches = $this->get_page_title_keyword_matches();
1402 + $transient_name = 'tisdk_has_support_page';
1403 + $has_support = get_transient( $transient_name );
1602 1404
1603 - return 'yes' === $page_title_matches['support'];
1604 - }
1405 + if ( false === $has_support ) {
1406 + global $wpdb;
1605 1407
1606 - /**
1607 - * Check if the user has a donate page.
1608 - */
1609 - public function has_donate_page() {
1610 - $page_title_matches = $this->get_page_title_keyword_matches();
1408 + // We use %i escape identifier that was added in WP 6.2.0, hence need to ignore PHPCS warning.
1409 + // We only show this notice to users on higher version as that is the minimum for Hyve as well.
1410 + $query = $wpdb->get_var( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1411 + $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
1412 + 'SELECT ID FROM %i WHERE post_type = %s AND post_status = %s AND post_title LIKE %s LIMIT 1', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder
1413 + $wpdb->posts,
1414 + 'page',
1415 + 'publish',
1416 + '%support%'
1417 + )
1418 + );
1611 1419
1612 - return 'yes' === $page_title_matches['donate'];
1613 - }
1420 + $has_support = $query ? 'yes' : 'no';
1614 1421
1615 - /**
1616 - * Check if the tagline or a published page title contains LMS related keywords.
1617 - *
1618 - * @return bool True if LMS-related keywords are found, false otherwise.
1619 - */
1620 - public function has_lms_tagline() {
1621 - $tagline = strtolower( get_bloginfo( 'description' ) );
1622 -
1623 - foreach ( $this->get_lms_keywords() as $keyword ) {
1624 - if ( $this->has_lms_keyword_match( $tagline, $keyword ) ) {
1625 - return true;
1626 - }
1422 + set_transient( $transient_name, $has_support, 7 * DAY_IN_SECONDS );
1627 1423 }
1628 1424
1629 - return $this->has_lms_page_title();
1425 + return 'yes' === $has_support;
1630 1426 }
1631 1427
1632 1428 /**
1633 - * Check if a supported LMS plugin is active.
1634 - *
1635 - * @return bool True if an LMS plugin is active, false otherwise.
1429 + * Check if the user has a donate page.
1636 1430 */
1637 - private function has_active_lms_plugin() {
1638 - if ( defined( 'MASTERIYO_VERSION' ) ) {
1639 - return true;
1640 - }
1431 + public function has_donate_page() {
1432 + $transient_name = 'tisdk_has_donate_page';
1433 + $has_donate = get_transient( $transient_name );
1641 1434
1642 - include_once ABSPATH . 'wp-admin/includes/plugin.php';
1435 + if ( false === $has_donate ) {
1436 + global $wpdb;
1643 1437
1644 - $lms_plugins = array(
1645 - 'tutor/tutor.php',
1646 - 'sfwd-lms/sfwd_lms.php',
1647 - 'lifterlms/lifterlms.php',
1648 - 'sensei-lms/sensei-lms.php',
1649 - 'learnpress/learnpress.php',
1650 - 'masterstudy-lms-learning-management-system/masterstudy-lms-learning-management-system.php',
1651 - 'learning-management-system/lms.php',
1652 - );
1438 + $query = $wpdb->get_var( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1439 + $wpdb->prepare(
1440 + 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s AND post_title LIKE %s LIMIT 1',
1441 + 'page',
1442 + 'publish',
1443 + '%donate%'
1444 + )
1445 + );
1653 1446
1654 - foreach ( $lms_plugins as $plugin ) {
1655 - if ( is_plugin_active( $plugin ) || ( is_multisite() && is_plugin_active_for_network( $plugin ) ) ) {
1656 - return true;
1657 - }
1658 - }
1447 + $has_donate = $query ? 'yes' : 'no';
1659 1448
1660 - return false;
1661 - }
1662 -
1663 - /**
1664 - * Check if the current request can display a plugin install promo.
1665 - *
1666 - * @return bool True if a plugin install promo can be displayed, false otherwise.
1667 - */
1668 - private function can_check_plugin_install_promo() {
1669 - if ( ! is_admin() || ! current_user_can( 'install_plugins' ) ) {
1670 - return false;
1449 + set_transient( $transient_name, $has_donate, 7 * DAY_IN_SECONDS );
1671 1450 }
1672 1451
1673 - $current_screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
1674 - if ( isset( $current_screen->id ) ) {
1675 - return $current_screen->id === 'plugin-install';
1676 - }
1677 -
1678 - global $pagenow;
1679 -
1680 - return isset( $pagenow ) && $pagenow === 'plugin-install.php';
1452 + return 'yes' === $has_donate;
1681 1453 }
1682 1454
1683 1455 /**
1684 - * Check if a published page title contains LMS related keywords.
1456 + * Check if the tagline contains LMS related keywords.
1685 1457 *
1686 - * @return bool True if an LMS-related page title is found, false otherwise.
1458 + * @return bool True if the tagline contains LMS-related keywords, false otherwise.
1687 1459 */
1688 - private function has_lms_page_title() {
1689 - $lms_page_title_signal = get_transient( 'tisdk_lms_page_title_signal_v1' );
1460 + public function has_lms_tagline() {
1461 + $tagline = strtolower( get_bloginfo( 'description' ) );
1462 + $lms_keywords = array( 'learning', 'courses' );
1690 1463
1691 - if ( in_array( $lms_page_title_signal, array( 'yes', 'no' ), true ) ) {
1692 - return 'yes' === $lms_page_title_signal;
1693 - }
1694 -
1695 - $has_lms_page_title = $this->has_published_page_title_with_keywords( $this->get_lms_page_title_keywords() );
1696 -
1697 - set_transient( 'tisdk_lms_page_title_signal_v1', $has_lms_page_title ? 'yes' : 'no', 7 * DAY_IN_SECONDS );
1698 -
1699 - return $has_lms_page_title;
1700 - }
1701 -
1702 - /**
1703 - * Get cached keyword matches for published page titles.
1704 - *
1705 - * @return array Page title keyword matches.
1706 - */
1707 - private function get_page_title_keyword_matches() {
1708 - $default_matches = array(
1709 - 'support' => 'no',
1710 - 'donate' => 'no',
1711 - );
1712 -
1713 - $page_title_matches = get_transient( 'tisdk_page_title_signals_v1' );
1714 -
1715 - if ( is_array( $page_title_matches ) && empty( array_diff_key( $default_matches, $page_title_matches ) ) ) {
1716 - return array_merge( $default_matches, $page_title_matches );
1717 - }
1718 -
1719 - global $wpdb;
1720 -
1721 - $select_clauses = array();
1722 - $query_values = array();
1723 - $page_checks = $this->get_page_title_checks();
1724 -
1725 - foreach ( $page_checks as $match_key => $keywords ) {
1726 - $match_clauses = array();
1727 -
1728 - $query_values[] = 'page';
1729 - $query_values[] = 'publish';
1730 -
1731 - foreach ( $keywords as $keyword ) {
1732 - $match_clauses[] = 'post_title LIKE %s';
1733 - $query_values[] = '%' . $wpdb->esc_like( $keyword ) . '%';
1464 + foreach ( $lms_keywords as $keyword ) {
1465 + if ( strpos( $tagline, $keyword ) !== false ) {
1466 + return true;
1734 1467 }
1735 -
1736 - $select_clauses[] = 'EXISTS( SELECT 1 FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s AND ( ' . implode( ' OR ', $match_clauses ) . ' ) LIMIT 1 ) AS has_' . $match_key;
1737 1468 }
1738 1469
1739 - // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1740 - $query = $wpdb->get_row( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1741 - $wpdb->prepare(
1742 - 'SELECT ' . implode( ', ', $select_clauses ),
1743 - $query_values
1744 - ),
1745 - ARRAY_A
1746 - );
1747 - // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1748 -
1749 - $page_title_matches = $default_matches;
1750 -
1751 - if ( is_array( $query ) ) {
1752 - foreach ( array_keys( $page_checks ) as $match_key ) {
1753 - $page_title_matches[ $match_key ] = ! empty( $query[ 'has_' . $match_key ] ) ? 'yes' : 'no';
1754 - }
1755 - }
1756 -
1757 - set_transient( 'tisdk_page_title_signals_v1', $page_title_matches, 7 * DAY_IN_SECONDS );
1758 -
1759 - return $page_title_matches;
1760 - }
1761 -
1762 - /**
1763 - * Check if a keyword matches content.
1764 - *
1765 - * @param string $content Content to check.
1766 - * @param string $keyword Keyword to look for.
1767 - *
1768 - * @return bool True if the keyword matches, false otherwise.
1769 - */
1770 - private function has_lms_keyword_match( $content, $keyword ) {
1771 - if ( in_array( $keyword, array( 'lms', 'course', 'class' ), true ) ) {
1772 - return preg_match( '/(^|[^a-z0-9])' . preg_quote( $keyword, '/' ) . '([^a-z0-9]|$)/', $content ) === 1;
1773 - }
1774 -
1775 - return strpos( $content, $keyword ) !== false;
1776 - }
1777 -
1778 - /**
1779 - * Get LMS related keywords.
1780 - *
1781 - * @return array LMS related keywords.
1782 - */
1783 - private function get_lms_keywords() {
1784 - return array(
1785 - 'lms',
1786 - 'learning',
1787 - 'course',
1788 - 'courses',
1789 - 'academy',
1790 - 'training',
1791 - 'lesson',
1792 - 'lessons',
1793 - 'class',
1794 - 'classes',
1795 - 'student',
1796 - 'students',
1797 - 'teach',
1798 - 'teaching',
1799 - 'tutor',
1800 - 'quiz',
1801 - 'education',
1802 - 'online course',
1803 - 'online courses',
1804 - );
1805 - }
1806 -
1807 - /**
1808 - * Get LMS related keywords for page title matching.
1809 - *
1810 - * @return array LMS related keywords.
1811 - */
1812 - private function get_lms_page_title_keywords() {
1813 - return array_values( array_diff( $this->get_lms_keywords(), array( 'lms', 'course', 'class' ) ) );
1814 - }
1815 -
1816 - /**
1817 - * Check if a published page title contains any of the provided keywords.
1818 - *
1819 - * @param array $keywords Keywords to look for.
1820 - *
1821 - * @return bool True if a matching page title is found, false otherwise.
1822 - */
1823 - private function has_published_page_title_with_keywords( $keywords ) {
1824 - if ( empty( $keywords ) ) {
1825 - return false;
1826 - }
1827 -
1828 - global $wpdb;
1829 -
1830 - $query_values = array( 'page', 'publish' );
1831 - $clauses = array();
1832 -
1833 - foreach ( $keywords as $keyword ) {
1834 - $clauses[] = 'post_title LIKE %s';
1835 - $query_values[] = '%' . $wpdb->esc_like( $keyword ) . '%';
1836 - }
1837 -
1838 - // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1839 - $page_title_match = $wpdb->get_var( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1840 - $wpdb->prepare(
1841 - 'SELECT 1 FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s AND ( ' . implode( ' OR ', $clauses ) . ' ) LIMIT 1',
1842 - $query_values
1843 - )
1844 - );
1845 - // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1846 -
1847 - return ! empty( $page_title_match );
1848 - }
1849 -
1850 - /**
1851 - * Get page title keyword checks.
1852 - *
1853 - * @return array Page title keyword checks.
1854 - */
1855 - private function get_page_title_checks() {
1856 - return array(
1857 - 'support' => array( 'support' ),
1858 - 'donate' => array( 'donate' ),
1859 - );
1470 + return false;
1860 1471 }
1861 1472 }