From bca3ff1c836b4cd893fba2333a12bab907a451f3 Mon Sep 17 00:00:00 2001 From: JiveDig Date: Fri, 5 May 2023 17:04:26 -0400 Subject: [PATCH 1/5] fix deprecated function by adding our own mai_get_page_by_title --- lib/admin/setup-wizard.php | 8 +++--- lib/classes/class-mai-setup-wizard-ajax.php | 4 +-- lib/functions/utilities.php | 32 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lib/admin/setup-wizard.php b/lib/admin/setup-wizard.php index 88658f480..3bb931c01 100644 --- a/lib/admin/setup-wizard.php +++ b/lib/admin/setup-wizard.php @@ -279,10 +279,10 @@ function mai_after_setup_wizard_import( $demo ) { $home = 'Home - ' . mai_convert_case( mai_get_active_theme() . ' ' . $demo, 'title' ); // Assign front page and posts page. - $front = get_page_by_title( $home ); - $front = $front ?: get_page_by_title( 'Home' ); // Fallback if no home with demo name. - $blog = get_page_by_title( 'Blog' ); - $shop = get_page_by_title( 'Shop' ); + $front = mai_get_page_by_title( $home ); + $front = $front ?: mai_get_page_by_title( 'Home' ); // Fallback if no home with demo name. + $blog = mai_get_page_by_title( 'Blog' ); + $shop = mai_get_page_by_title( 'Shop' ); if ( $front ) { update_option( 'page_on_front', $front->ID ); diff --git a/lib/classes/class-mai-setup-wizard-ajax.php b/lib/classes/class-mai-setup-wizard-ajax.php index 7dba55e34..82f8ad8f7 100644 --- a/lib/classes/class-mai-setup-wizard-ajax.php +++ b/lib/classes/class-mai-setup-wizard-ajax.php @@ -26,10 +26,10 @@ class Mai_Setup_Wizard_Ajax extends Mai_Setup_Wizard_Service_Provider { */ public function add_hooks() { add_action( 'wp_ajax_mai_setup_wizard_welcome', [ $this, 'step_welcome' ] ); - add_action( 'wp_ajax_mai_setup_wizard_demo', [ $this, 'step_demo' ] ); + add_action( 'wp_ajax_mai_setup_wizard_demo', [ $this, 'step_demo' ] ); add_action( 'wp_ajax_mai_setup_wizard_plugins', [ $this, 'step_plugins' ] ); add_action( 'wp_ajax_mai_setup_wizard_content', [ $this, 'step_content' ] ); - add_action( 'wp_ajax_mai_setup_wizard_done', [ $this, 'step_done' ] ); + add_action( 'wp_ajax_mai_setup_wizard_done', [ $this, 'step_done' ] ); } /** diff --git a/lib/functions/utilities.php b/lib/functions/utilities.php index 5ccc754bd..5d5587fd5 100644 --- a/lib/functions/utilities.php +++ b/lib/functions/utilities.php @@ -1992,6 +1992,38 @@ function mai_sanitize_get( $param, $function = 'esc_html' ) { return isset( $_GET[ $param ] ) ? $function( $_GET[ $param ] ) : null; } +/** + * Undocumented function + * + * @access private + * + * @param string $title The page title. + * @param string $post_type The post type. + * + * @return WP_Post|false + */ +function mai_get_page_by_title( $title, $post_type = 'page' ) { + $page = false; + $query = new WP_Query( + [ + 'post_type' => $post_type, + 'title' => $title, + 'post_status' => 'all', + 'posts_per_page' => 1, + 'ignore_sticky_posts' => true, + 'no_found_rows' => true, + 'update_post_term_cache' => false, + 'update_post_meta_cache' => false, + ] + ); + + if ( ! empty( $query->post ) ) { + $page = $query->post; + } + + return $page; +} + /** * Gets all non latin locales in WP. * From 4d52caf9c4d9ca0f6d06ef2702bc405b0199777e Mon Sep 17 00:00:00 2001 From: JiveDig Date: Fri, 5 May 2023 17:04:40 -0400 Subject: [PATCH 2/5] update Mai Inspire demo urls --- config/inspire.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/inspire.php b/config/inspire.php index da49d4522..2b84b08c9 100644 --- a/config/inspire.php +++ b/config/inspire.php @@ -11,9 +11,9 @@ return [ 'demos' => [ - // 'home-garden' => 35, + 'home-garden' => 'https://demo.bizbudding.com/inspire-home-garden/wp-content/uploads/sites/35/mai-engine/', 'health-beauty' => 'https://demo.bizbudding.com/inspire-health-beauty/wp-content/uploads/sites/36/mai-engine/', - // 'travel' => 37, + 'travel' => 'https://demo.bizbudding.com/inspire-travel/wp-content/uploads/sites/37/mai-engine/', ], 'global-styles' => [ 'colors' => [ From f9345fb91a1c088456c0f6821c517c2c27c22996 Mon Sep 17 00:00:00 2001 From: JiveDig Date: Fri, 5 May 2023 17:04:48 -0400 Subject: [PATCH 3/5] 2.28.1-beta.1 --- mai-engine.php | 2 +- vendor/composer/installed.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mai-engine.php b/mai-engine.php index fa3653fea..5961f34ed 100644 --- a/mai-engine.php +++ b/mai-engine.php @@ -6,7 +6,7 @@ * Plugin URI: https://bizbudding.com/mai-theme/ * GitHub Plugin URI: https://github.com/maithemewp/mai-engine/ * Description: The required plugin to power Mai child themes. - * Version: 2.28.0 + * Version: 2.28.1-beta.1 * Author: BizBudding * Author URI: https://bizbudding.com/ * Text Domain: mai-engine diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 17aa28f13..79a509f54 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'maithemewp/mai-engine', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '92cf6c82758b061aea32fa6574d1aa2395724e2d', + 'reference' => 'eae38d82147b08b407b777886cf85be3e854863d', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -319,7 +319,7 @@ 'maithemewp/mai-engine' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '92cf6c82758b061aea32fa6574d1aa2395724e2d', + 'reference' => 'eae38d82147b08b407b777886cf85be3e854863d', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), From a570d015ba52755d5e6dada187c8b90acbc80e47 Mon Sep 17 00:00:00 2001 From: JiveDig Date: Wed, 10 May 2023 11:28:35 -0400 Subject: [PATCH 4/5] Fix wrong ID being returned on front page in some scenarios --- lib/functions/layout.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/functions/layout.php b/lib/functions/layout.php index 9d4b61c63..fa1abc237 100644 --- a/lib/functions/layout.php +++ b/lib/functions/layout.php @@ -82,8 +82,15 @@ function mai_site_layout() { else { if ( is_singular() || ( is_home() && ! genesis_is_root_page() ) ) { - $post_id = is_home() ? get_option( 'page_for_posts' ) : null; - $site_layout = genesis_get_custom_field( '_genesis_layout', $post_id ); + $post_id = null; + + if ( is_home() ) { + $post_id = get_option( 'page_for_posts' ); + } elseif ( is_front_page() ) { + $post_id = get_option( 'page_on_front' ); + } + + $site_layout = genesis_get_custom_field( '_genesis_layout', $post_id ); // Function handles null. } elseif ( is_category() || is_tag() || is_tax() ) { From a144000c31a07c23e71052b7e7ed17744ce38e7e Mon Sep 17 00:00:00 2001 From: JiveDig Date: Wed, 10 May 2023 11:36:18 -0400 Subject: [PATCH 5/5] 2.28.1 --- CHANGES.md | 5 +++++ mai-engine.php | 2 +- vendor/composer/installed.php | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f85775408..b8ba026e3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Changelog +## 2.28.1 (5/10/23) +* Fixed: Wrong ID being returned on front page for site layout in some scenarios. +* Fixed: Replace deprecated `get_page_by_title()` function. +* Fixed: Mai Inspire demos not working in Mai Setup Wizard. + ## 2.28.0 (5/5/23) * Changed: Update ACF to 6.1.6. * Fixed: More thorough handling of markup processing to make sure valid markup is returned. diff --git a/mai-engine.php b/mai-engine.php index 5961f34ed..135550612 100644 --- a/mai-engine.php +++ b/mai-engine.php @@ -6,7 +6,7 @@ * Plugin URI: https://bizbudding.com/mai-theme/ * GitHub Plugin URI: https://github.com/maithemewp/mai-engine/ * Description: The required plugin to power Mai child themes. - * Version: 2.28.1-beta.1 + * Version: 2.28.1 * Author: BizBudding * Author URI: https://bizbudding.com/ * Text Domain: mai-engine diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 79a509f54..c6896bb37 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'maithemewp/mai-engine', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'eae38d82147b08b407b777886cf85be3e854863d', + 'reference' => 'a570d015ba52755d5e6dada187c8b90acbc80e47', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -319,7 +319,7 @@ 'maithemewp/mai-engine' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'eae38d82147b08b407b777886cf85be3e854863d', + 'reference' => 'a570d015ba52755d5e6dada187c8b90acbc80e47', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),