File tree Expand file tree Collapse file tree 1 file changed +18
-11
lines changed
Expand file tree Collapse file tree 1 file changed +18
-11
lines changed Original file line number Diff line number Diff line change 77Description: WordPress REST API to JSON File
88*/
99
10+ function enable_permalinks_notice () {
11+ ?>
12+ <div class="notice notice-warning">
13+ <p><?php _e ( 'WP Serverless Redirects requires Permalinks. <a href="/wp-admin/options-permalink.php">Enable Permalinks</a> ' ); ?> </p>
14+ </div>
15+ <?php
16+ }
17+
18+ if ( !get_option ('permalink_structure ' ) ) {
19+ add_action ( 'admin_notices ' , 'enable_permalinks_notice ' );
20+ }
1021
1122function compile_db (
1223 $ routes = array (
@@ -19,7 +30,12 @@ function compile_db(
1930 $ db_array = array ();
2031
2132 foreach ($ routes as $ route ) {
22- $ url = 'https://demo.wp-api.org/wp-json/wp/v2/ ' . $ route ;
33+ if (getenv ("SHIFTER_ACCESS_TOKEN " ) === false ) {
34+ $ url = 'https://demo.wp-api.org/wp-json/wp/v2/ ' . $ route ;
35+ } else {
36+ $ url = '/wp-json/wp/v2/ ' . $ route ;
37+ }
38+
2339 $ jsonData = json_decode ( file_get_contents ($ url ) );
2440
2541 $ db_array [$ route ] = (array ) $ jsonData ;
@@ -55,13 +71,4 @@ function build_db()
5571 save_db ($ db );
5672}
5773
58- add_action ( 'save_post ' , 'build_db ' );
59-
60- /**
61- * Create JSON on Activation
62- */
63- register_activation_hook ( __FILE__ , 'pluginprefix_install ' );
64- function pluginprefix_install ()
65- {
66- build_db ();
67- }
74+ add_action ( 'save_post ' , 'build_db ' );
You can’t perform that action at this time.
0 commit comments