2
2
3
3
namespace NewfoldLabs \WP \Module \Onboarding \Services ;
4
4
5
- use NewfoldLabs \WP \Module \Onboarding \Data \Options ;
6
5
use NewfoldLabs \WP \Module \Onboarding \Data \Services \SitePagesService ;
7
6
use NewfoldLabs \WP \Module \Onboarding \Data \Services \SiteGenService as LegacySiteGenService ;
8
7
@@ -47,14 +46,8 @@ public function publish_homepage( string $selected_sitegen_homepage ): int | \WP
47
46
}
48
47
49
48
$ selected_homepage = $ this ->sitegen_data ['homepages ' ][ $ selected_sitegen_homepage ];
50
- // Always set the default homepage to a page.
51
- $ show_pages_on_front = \get_option ( Options::get_option_name ( 'show_on_front ' , false ) );
52
- if ( 'posts ' === $ show_pages_on_front ) {
53
- \update_option ( Options::get_option_name ( 'show_on_front ' , false ), 'page ' );
54
- }
55
-
56
- $ content = $ selected_homepage ['content ' ];
57
- $ title = __ ( 'Home ' , 'wp-module-onboarding ' );
49
+ $ content = $ selected_homepage ['content ' ];
50
+ $ title = __ ( 'Home ' , 'wp-module-onboarding ' );
58
51
59
52
$ post_id = SitePagesService::publish_page (
60
53
$ title ,
@@ -74,8 +67,13 @@ public function publish_homepage( string $selected_sitegen_homepage ): int | \WP
74
67
// Add the homepage to the site navigation.
75
68
$ this ->add_page_to_navigation ( $ post_id , $ title , get_permalink ( $ post_id ) );
76
69
70
+ // Change WordPress reading options to show static page as homepage.
71
+ $ wp_reading_homepage_option = get_option ( 'show_on_front ' );
72
+ if ( 'page ' !== $ wp_reading_homepage_option ) {
73
+ update_option ( 'show_on_front ' , 'page ' );
74
+ }
77
75
// Set the homepage as the front page.
78
- \ update_option ( Options:: get_option_name ( 'page_on_front ' , false ) , $ post_id );
76
+ update_option ( 'page_on_front ' , $ post_id );
79
77
80
78
return $ post_id ;
81
79
}
0 commit comments