| | 198 | * Updates _site_state_changed option in database |
| | 199 | * |
| | 200 | * Should be called when a theme or plugin has been activated or deactivated. |
| | 201 | * Used to facilitate tasks like flushing rewrite rules for the registration |
| | 202 | * and deregistration of post types and taxonomies. |
| | 203 | * |
| | 204 | * @since 5.2.2 |
| | 205 | * |
| | 206 | * @param string|array $arg single function name or list of function names |
| | 207 | */ |
| | 208 | function update_site_state_changed( $arg ) { |
| | 209 | $value = []; |
| | 210 | |
| | 211 | register_post_type('book', ['public' => true]); |
| | 212 | |
| | 213 | if( $state = get_option( '_site_state_changed' ) ) { |
| | 214 | $value = maybe_unserialize( $state ); |
| | 215 | |
| | 216 | if( !is_array( $value ) ) { |
| | 217 | $value = []; |
| | 218 | } |
| | 219 | } |
| | 220 | |
| | 221 | if( is_array( $arg ) ) { |
| | 222 | $value = array_merge( $value, $arg ); |
| | 223 | } else { |
| | 224 | $value[] = $arg; |
| | 225 | } |
| | 226 | |
| | 227 | update_option( '_site_state_changed', $value ); |
| | 228 | } |
| | 229 | |
| | 230 | /** |
| | 231 | * Check site state |
| | 232 | */ |
| | 233 | function check_site_state_change() { |
| | 234 | if ( $site_state = get_option( '_site_state_changed' ) ) { |
| | 235 | $site_state = apply_filters( 'site_state_changed', $site_state ); |
| | 236 | |
| | 237 | if( is_array( $site_state ) ) { |
| | 238 | $site_state = array_unique($site_state); |
| | 239 | foreach ( $site_state as $site_state_func ) |
| | 240 | add_action( 'site_state_changed', $site_state_func ); |
| | 241 | } |
| | 242 | |
| | 243 | do_action( 'site_state_changed', $site_state ); |
| | 244 | delete_option( '_site_state_changed' ); |
| | 245 | } |
| | 246 | } |
| | 247 | |
| | 248 | /** |