Skip to content

Commit

Permalink
Merge branch 'main' into enhance/replace-yith-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
officiallygod committed Sep 25, 2024
2 parents f3809a0 + b822681 commit c795c00
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 35 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
},
"require": {
"newfold-labs/wp-module-installer": "^1.1",
"newfold-labs/wp-module-patterns": "^2.0",
"newfold-labs/wp-module-patterns": "^2.4",
"newfold-labs/wp-module-ai": "^1.1",
"wp-forge/wp-upgrade-handler": "^1.0",
"mustache/mustache": "^2.14",
"newfold-labs/wp-module-data": "^2.0",
"newfold-labs/wp-module-data": "^2.6",
"newfold-labs/wp-module-coming-soon": "^1.2",
"newfold-labs/wp-module-performance": "^1.4",
"newfold-labs/wp-module-performance": "^2.0",
"newfold-labs/wp-module-install-checker": "^1.0",
"newfold-labs/wp-module-survey": "^1.0"
},
Expand Down
213 changes: 182 additions & 31 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions includes/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ final class Options {
'filter_active_plugins' => 'filter_active_plugins',
'sitegen_regenerated_homepages' => 'sitegen_regenerated_homepages',
'status' => 'status',
'wc_shop_page_id' => 'woocommerce_shop_page_id',
'wc_queue_flush_rewrite_rules' => 'woocommerce_queue_flush_rewrite_rules',
);

/**
Expand Down
30 changes: 29 additions & 1 deletion includes/Services/SiteGenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -948,10 +948,12 @@ public static function publish_sitemap_pages( $site_description, $content_style,
),
$slug
);

if ( $update_nav_menu && ! is_wp_error( $post_id ) ) {
$navigation_links_grammar .= self::get_nav_link_grammar_from_post_data( $post_id, $page['title'], get_permalink( $post_id ) );
}
if ( ! is_wp_error( $post_id ) && self::is_products_or_shop_page( $page['slug'] ) ) {
self::set_woo_shop_page( $post_id );
}
}

if ( $update_nav_menu ) {
Expand All @@ -977,6 +979,32 @@ public static function publish_sitemap_pages( $site_description, $content_style,
return true;
}

/**
* Checks if it is a products or shop slug
*
* @param string $slug Slug of the page being generated.
* @return boolean
*/
public static function is_products_or_shop_page( $slug ) {
$product_page_slug = array(
'products' => true,
'shop' => true,
);
return array_key_exists( $slug, $product_page_slug );
}

/**
* Sets the products page generated by AI to woocommerce shop page
*
* @param integer $page_id Id of the page
*/
public static function set_woo_shop_page( $page_id ) {
$option_shop_page_id = Options::get_option_name( 'wc_shop_page_id', false );
$option_wc_queue_flush_rewrite_rules = Options::get_option_name( 'wc_queue_flush_rewrite_rules', false );
update_option( $option_shop_page_id, $page_id );
update_option( $option_wc_queue_flush_rewrite_rules, 'yes' );
}

/**
* Trash the "Sample Page" generated for all new sites.
*
Expand Down

0 comments on commit c795c00

Please sign in to comment.