'ids', 'number' => 0, ) ) as $site_id ) { switch_to_blog( (int) $site_id ); call_user_func( $callback ); restore_current_blog(); } } /** * Takes over the Classic Editor values of the current site, once. */ public static function activate_site(): void { if ( false !== get_option( ThreeCE_Editor_Switch::OPTION ) ) { return; } $replace = get_option( 'classic-editor-replace' ); $allow = get_option( 'classic-editor-allow-users' ); if ( false === $replace && false === $allow ) { return; } update_option( ThreeCE_Editor_Switch::OPTION, array( // Classic Editor still accepts its old values "replace" and "no-replace". 'editor' => ( 'block' === $replace || 'no-replace' === $replace ) ? 'block' : 'classic', 'allow_users' => ( 'allow' === $allow ), ) ); } /** * Editor Classic Editor remembered for a post, or ''. * * @param int $post_id Post ID. * @return string */ public static function post_editor( $post_id ) { $which = get_post_meta( $post_id, 'classic-editor-remember', true ); if ( 'block-editor' === $which ) { return 'block'; } return ( 'classic-editor' === $which ) ? 'classic' : ''; } /** * Default editor a user chose in Classic Editor, or ''. * * @param int $user_id User ID. * @return string */ public static function user_editor( $user_id ) { $which = get_user_option( 'classic-editor-settings', $user_id ); return ( 'block' === $which || 'classic' === $which ) ? $which : ''; } }