PluginProbe
Faust.js / 1.0.2
Faust.js v1.0.2
1.8.12 1.8.11 1.4.1 1.8.0 1.8.8 1.8.9 trunk 0.7.0 0.7.1 0.7.10 0.7.11 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9 0.8.0 0.8.1 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 All 40 releases
← All changes | includes/settings/functions.php +45 -3 0.7.71.0.2 View file →
@@ -57,9 +57,9 @@
57 57 return faustwp_get_setting( 'secret_key', '' );
58 58 }
59 59
60 60 /**
61 - * Get a FaustWP setting by name.
61 + * Get a Faust setting by name.
62 62 *
63 63 * @param string $name The setting name.
64 64 * @param mixed $default Optional setting value. Default false.
65 65 *
@@ -83,9 +83,9 @@
83 83 return apply_filters( 'faustwp_get_setting', $value, $name, $default );
84 84 }
85 85
86 86 /**
87 - * Update a FaustWP setting value.
87 + * Update a Faust setting value.
88 88 *
89 89 * @link https://developer.wordpress.org/reference/functions/update_option/
90 90 *
91 91 * @param string $name The setting name.
@@ -100,9 +100,9 @@
100 100 update_option( 'faustwp_settings', $settings );
101 101 }
102 102
103 103 /**
104 - * Get all FaustWP settings.
104 + * Get all Faust settings.
105 105 *
106 106 * @return array An array of settings.
107 107 */
108 108 function faustwp_get_settings() {
@@ -113,5 +113,47 @@
113 113 *
114 114 * @param array $settings Array of plugin settings.
115 115 */
116 116 return apply_filters( 'faustwp_get_settings', $settings );
117 +}
118 +
119 +/**
120 + * Applies the default settings to a site if settings don't already exist.
121 + *
122 + * @return void
123 + */
124 +function maybe_set_default_settings() {
125 + $secret_key = get_secret_key();
126 + $settings = faustwp_get_settings();
127 +
128 + if ( empty( $settings ) ) {
129 + faustwp_update_setting( 'disable_theme', '0' );
130 + faustwp_update_setting( 'enable_rewrites', '1' );
131 + faustwp_update_setting( 'enable_redirects', '1' );
132 +
133 + // Force WP to regenerate rewrite rules without calling flush_rewrite_rules which breaks
134 + // things when used inside of `switch_to_blog()`.
135 + if ( is_multisite() ) {
136 + delete_option( 'rewrite_rules' );
137 + }
138 + }
139 +
140 + if ( ! $secret_key ) {
141 + faustwp_update_setting( 'secret_key', wp_generate_uuid4() );
142 + }
143 +}
144 +
145 +/**
146 + * Get the contents of an SVG icon.
147 + *
148 + * @param string $icon Filename of the SVG without the .svg extension.
149 + * @return string The SVG icon contents or empty string if the icon file does not exist.
150 + */
151 +function get_icon( $icon ) {
152 + $path = __DIR__ . '/assets/icons/' . $icon . '.svg';
153 +
154 + if ( file_exists( $path ) ) {
155 + return file_get_contents( $path ); //phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
156 + }
157 +
158 + return '';
117 159 }