update_with( $niche_json_data ); } private function update_global_styles() { $json_file = static::JSON_FILE; if ( empty( $json_file ) || ! file_exists( $json_file ) ) { return; } $active_global_styles_id = \WP_Theme_JSON_Resolver::get_user_global_styles_post_id(); $changes = new \stdClass(); $changes->ID = $active_global_styles_id; $post = get_post( $active_global_styles_id ); $existing_config = array(); if ( $post ) { $existing_config = json_decode( $post->post_content, true ); $json_decoding_error = json_last_error(); if ( JSON_ERROR_NONE !== $json_decoding_error || ! isset( $existing_config['isGlobalStylesUserThemeJSON'] ) || ! $existing_config['isGlobalStylesUserThemeJSON'] ) { $existing_config = array(); } } $data = json_decode( file_get_contents( $json_file ), true ); $config = array(); if ( isset( $data['settings'] ) ) { $config['settings'] = Helpers::recursive_wp_parse_args( $data['settings'], $existing_config['settings'] ); } if ( isset( $data['styles'] ) ) { $config['styles'] = Helpers::recursive_wp_parse_args( $data['styles'], $existing_config['styles'] ); } $config['isGlobalStylesUserThemeJSON'] = true; $config['version'] = \WP_Theme_JSON::LATEST_SCHEMA; $changes->post_content = wp_json_encode( $config ); $result = wp_update_post( wp_slash( (array) $changes ), true, false ); return $changes; } public static function is_current_niche() { return brandy_is_current_niche( static::NICHE_ID ); } }