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 -12 0.7.31.0.2 View file →
@@ -38,17 +38,8 @@
38 38 return '1' === faustwp_get_setting( 'disable_theme' );
39 39 }
40 40
41 41 /**
42 - * Determine if events are enabled.
43 - *
44 - * @return bool True if events are enabled, false if else.
45 - */
46 -function is_events_enabled() {
47 - return '1' === faustwp_get_setting( 'events_enabled' );
48 -}
49 -
50 -/**
51 42 * Determine if sourcing images from WP domain is enabled.
52 43 *
53 44 * @return bool True if image sources from WP are enabled, false if else.
54 45 */
@@ -66,9 +57,9 @@
66 57 return faustwp_get_setting( 'secret_key', '' );
67 58 }
68 59
69 60 /**
70 - * Get a FaustWP setting by name.
61 + * Get a Faust setting by name.
71 62 *
72 63 * @param string $name The setting name.
73 64 * @param mixed $default Optional setting value. Default false.
74 65 *
@@ -92,9 +83,9 @@
92 83 return apply_filters( 'faustwp_get_setting', $value, $name, $default );
93 84 }
94 85
95 86 /**
96 - * Update a FaustWP setting value.
87 + * Update a Faust setting value.
97 88 *
98 89 * @link https://developer.wordpress.org/reference/functions/update_option/
99 90 *
100 91 * @param string $name The setting name.
@@ -109,9 +100,9 @@
109 100 update_option( 'faustwp_settings', $settings );
110 101 }
111 102
112 103 /**
113 - * Get all FaustWP settings.
104 + * Get all Faust settings.
114 105 *
115 106 * @return array An array of settings.
116 107 */
117 108 function faustwp_get_settings() {
@@ -122,5 +113,47 @@
122 113 *
123 114 * @param array $settings Array of plugin settings.
124 115 */
125 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 '';
126 159 }