Another plugin: EM Dashboard (beta)

Hello :slight_smile:

I've written yet another plugin but I'm not sure if w.org is the right place to beta test this.

EM Dashboard stands for Easy Mode Dashboard. It's activated or deactivated through a simple switch.

It just makes your dashboard more clean. Superb for when you're done editing themes or for when you allow WP beginners in your dashboard.

It also adds a new completely overhauled lollipop theme.
And it sets the default theme for when a user registers.

Most of this will be adjustable through settings, but the settings page still has to be made :smiley:

Read the comments below (if any) for updates :slight_smile:

The plugin:
1. Creates a space-grey theme easy on the eyes in the wp-admin dashboard
2. Adds an option for the user on the bottom left of the admin menu
3. The option (when turned on) removes all kinds of stuff
4. This option is adjustable with a filter (more on that later)
5. The option is per-user, not per-site, and will carry over on other sites in a WPMU environment where the plugin is active
6. Works on both multisite and single (AFAIK)

Feel free to test it out and share your thoughts :slight_smile: It's still in beta which means all styles are dumped in one file so over the time I will split everything up into nice color-themed sections.

Enjoy :slight_smile:

The download:
https://cyberwire.nl/hmp/plugins/em-dashboard.zip

When I'm satisfied with the results i.e. no more beta, I'll post this plugin on w.org free for everyone to use and update :smiley:

  • Michael Bissett

    Hey @Sybre Waaijer, thanks for sharing this! :slight_smile:

    Just had a quick test myself, and I got this parse error on activating it:

    Parse error: syntax error, unexpected '[' in /home/codeweas/public_html/dev7/wp-content/plugins/em-dashboard/init.php on line 212

    Line 212 of that file being this:

    $option = $this->option()['easy_mode'];

    Here's my test setup:

    - PHP version 5.3.26
    - WordPress version 4.2.3
    - Twenty Fifteen theme was in use
    - No other plugins were active

    This looks to be coming up due to the version of PHP that's in use on the host, as array dereferencing was implemented in PHP 5.4.

    Hope this helps! :slight_smile:

    Kind Regards,
    Michael

  • Sybre Waaijer

    v1.0.0beta-2 is out:
    * Updated class structure so it's easy to extend (EM_Dashboard_Load in load.class.php)
    * Updated the EM Dashboard theme (css and js)
    * Removed bugs :slight_smile:
    * Made the button work on default admin themes :slight_smile:

    * Add this line to your wp-config.php to load the EM Dashboard theme:
    define( 'USE_EM_DASHBOARD_THEME', true);

    An Options Page will be added soon and then it's time for wordpress.org ^^
    Also, hard to understand option pages will be removed (like custom post types) in easy mode.

    Download link is still in the first post :slight_smile:

  • Sybre Waaijer

    Oi,

    Trying to add an options page is harder than I thought. Somehow, the settings aren't saving, any idea why? (warning: a lot of code :smiley:) The POST values are what I'm expecting though, but WordPress thinks: nope. =/ No error, no PHP warnings/notices/etc.

    <?php
    /**
     * Class EM_Dashboard_OptionsPage
     *
     * Adds options pages for the plugin
     *
     * @since 1.0.0
     */
    class EM_Dashboard_OptionsPage extends EM_Dashboard_Options {
    
        /**
         * Constructor, load parent constructor
         */
        public function __construct() {
            parent::__construct();
    
            register_activation_hook( __FILE__, array( $this, 'set_options' ) );
    
            add_action( 'admin_init' , array( &$this, 'register_fields' ) );
    
            if (is_multisite()) {
                add_action('network_admin_menu', array( &$this, 'add_menu_link' ) );
            } else {
                add_action('admin_menu',         array( &$this, 'add_menu_link' ) );
            }
        }
    
        /**
         * Activation hook
         *
         * @since ???
         *
         * @todo everything
         */
        private function set_options() { }
    
        /**
         * Add Option fields to /settings_or_options.php?page=em_dashboard_settings
         *
         * @since 1.0.0
         * @return void
         */
        public function register_fields() {
    
            /**
             * Start General Settings
             *
             * @since 1.0.0
             */
            register_setting( 'em_dashboard_g_settings', 'em_dashboard_em_styles',                 array( $this, 's_boolean' ) ); //default false
            register_setting( 'em_dashboard_g_settings', 'em_dashboard_em_fonts',                     array( $this, 's_boolean' ) ); //default true
            register_setting( 'em_dashboard_g_settings', 'em_dashboard_color_scheme',                 array( $this, 's_colorscheme' ) ); //default light
            register_setting( 'em_dashboard_g_settings', 'em_dashboard_color_picker',                 array( $this, 's_boolean' ) ); //Default true
            register_setting( 'em_dashboard_g_settings', 'em_dashboard_load_easy',                 array( $this, 's_boolean' ) ); // Default true
            register_setting( 'em_dashboard_g_settings', 'em_dashboard_easy_mode',                 array( $this, 's_default_easy' ) ); // Default 'off'
            register_setting( 'em_dashboard_g_settings', 'em_dashboard_force_easy',                 array( $this, 's_boolean' ) ); //default false
            register_setting( 'em_dashboard_g_settings', 'em_dashboard_force_easy_capability',     array( $this, 's_capability' ) ); //default edit_plugins
    
            add_settings_section(
                'em_dashboard_general_settings',            // id
                __('General Settings', 'em-dashboard'),        // title
                array( $this, 'general_settings_fields'),    // callback
                'em_dashboard_g_settings'                    // page
            );
    
            /**
             * General settings section tab
             *
             * Doing it right: the WP way. Boring.
             */
            add_settings_field (
                'em_dashboard_em_styles',                             // id
                __('Enable EM Dashboard Styles', 'emdashboard'),     // title
                array( $this, 'checkbox'),                             // callback
                'em_dashboard_g_settings',                              // page
                'em_dashboard_general_settings',                     // section
                array(                                                 // args
                    'name'         => 'em_dashboard_em_styles',
                    'page'        => 'em_dashboard_g_settings',
                    'default'     => 'em_styles',
                    'labelinfo'    => __( 'This loads the EM Dashboard theme', 'emdashboard'),
                    'hoverinfo'    => __( 'Experimental flat soft WP theme', 'emdashboard'),
                    'hoverinfosite'    => '',
                    'hoverinfonetwork' => '',
                )
            );
            add_settings_field (
                'em_dashboard_em_fonts',                         // id
                __('Enable EM Dashboard Fonts', 'emdashboard'), // title
                array( $this, 'checkbox'),                         // callback
                'em_dashboard_g_settings',                          // page
                'em_dashboard_general_settings',                // section
                array(                                             // args
                    'name'         => 'em_dashboard_em_fonts',
                    'page'        => 'em_dashboard_g_settings',
                    'default'     => 'em_fonts',
                    'labelinfo'    => __( 'Load the Merriweather Google Font that goes with the EM Dashboard theme.', 'emdashboard'),
                    'hoverinfo'    => __( 'This option only has effect if the Dashboard styles are also active', 'emdashboard'),
                    'hoverinfosite'    => '',
                    'hoverinfonetwork' => '',
                )
            );
            add_settings_field (
                'em_dashboard_color_scheme',                     // id
                __('Default Color Scheme', 'emdashboard'),         // title
                'em_dashboard_g_settings',                          // page
                'em_dashboard_general_settings',                // section
                array(                                             // args
                    'name'         => 'em_dashboard_color_scheme',
                    'page'        => 'em_dashboard_g_settings',
                    'default'     => 'color_scheme',
                    'labelinfo'    => __( 'Set the default theme for newly registered users.', 'emdashboard'),
                    'hoverinfo'    => __( 'This does not affect currently registered users.', 'emdashboard'),
                    'hoverinfosite'    => '',
                    'hoverinfonetwork' => '',
                )
            );
            add_settings_field (
                'em_dashboard_color_picker',                 // id
                __('Enable Color Picker', 'emdashboard'),     // title
                array( $this, 'checkbox'),                    // callback
                'em_dashboard_g_settings',                      // page
                'em_dashboard_general_settings',            // section
                array(                                         // args
                    'name'         => 'em_dashboard_color_picker',
                    'page'        => 'em_dashboard_g_settings',
                    'default'     => 'color_picker',
                    'labelinfo'    => __( 'When this option is on, the color picker shows in the user profile page.', 'emdashboard'),
                    'hoverinfo'    => '',
                    'hoverinfosite'    => __( "This option is best used in combination with 'Enable EM Dashboard Styles'. This has no effect on the admin", 'emdashboard'),
                    'hoverinfonetwork'    => __( "This option is best used in combination with 'Enable EM Dashboard Styles'. This has no effect on the super-admin", 'emdashboard'),
                )
            );
            add_settings_field (
                'em_dashboard_load_easy',                             // id
                __('Enable the Easy Mode feature', 'emdashboard'),    // title
                array( $this, 'checkbox'),                             // callback
                'em_dashboard_g_settings',                              // page
                'em_dashboard_general_settings',                    // section
                array(                                                 // args
                    'name'         => 'em_dashboard_load_easy',
                    'page'        => 'em_dashboard_g_settings',
                    'default'     => 'load_easy',
                    'labelinfo'    => __( 'Enable the easy mode button.', 'emdashboard'),
                    'hoverinfo'    => '',
                    'hoverinfosite'    => __( 'The button on the bottom left.', 'emdashboard'),
                    'hoverinfonetwork'    => __( "The button on the bottom left. This doesn't have effect in the network admin screen", 'emdashboard'),
                )
            );
            add_settings_field (
                'em_dashboard_easy_mode',                         // id
                __('Default Easy Mode Setting', 'emdashboard'), // title
                array( $this, 'dropdown'),                         // callback
                'em_dashboard_g_settings',                          // page
                'em_dashboard_general_settings',                // section
                array(                                             // args
                    'name'         => 'em_dashboard_easy_mode',
                    'page'        => 'em_dashboard_g_settings',
                    'default'     => 'easy_mode',
                    'labelinfo'    => __( 'Turn the button on the bottom left on or off for new users.', 'emdashboard'),
                    'hoverinfo'    => __( "This option only has effect on users who haven't touched it yet", 'emdashboard'),
                    'hoverinfosite'    => '',
                    'hoverinfonetwork' => '',
                )
            );
            add_settings_field (
                'em_dashboard_force_easy',                     // id
                __('Force Easy Mode', 'emdashboard'),         // title
                array( $this, 'checkbox'),                     // callback
                'em_dashboard_g_settings',                     // page
                'em_dashboard_general_settings',            // section
                array(                                         // args
                    'name'         => 'em_dashboard_force_easy',
                    'page'        => 'em_dashboard_g_settings',
                    'default'     => array( 'force_easy', '0'),
                    'labelinfo'    => __( "Force Easy Mode for everyone except for the set Capability below.", 'emdashboard'),
                    'hoverinfo'    => __( 'This option also removes the button on the bottom left.', 'emdashboard'),
                    'hoverinfosite'    => '',
                    'hoverinfonetwork' => '',
                )
            );
            add_settings_field (
                'em_dashboard_force_easy_capability',                     // id
                __('Minimum Non-Forced Capability', 'emdashboard'),        // title
                array( $this, 'dropdown'),                                // callback
                'em_dashboard_g_settings',                                 // page
                'em_dashboard_general_settings',                         // section
                array(                                                     // args
                    'name'         => 'em_dashboard_force_easy_capability',
                    'page'        => 'em_dashboard_g_settings',
                    'default'     => array( 'force_easy', '1'),
                    'labelinfo'    => __( "The minimum role that doesn't get Easy Mode forced.", 'emdashboard'),
                    'hoverinfo'    => __( "If you get stuck in Easy Mode, please see the plugin page's 'Other Nodes'", 'emdashboard'),
                    'hoverinfosite'    => '',
                    'hoverinfonetwork' => '',
                )
            );
        }
    
        /**
         * Adds menu links under "settings" in the wp-admin dashboard
         *
         * @since 1.0.0
         * @return void
         */
        public function add_menu_link() {
            $parent_slug = is_multisite() ? 'settings.php' : 'options-general.php';
    
            $pagetitle = __('EM Dashboard Settings', 'emdashboard');
            $menutitle = 'EM Dashboard';
            $capability = 'edit_plugins';
            $menu_slug = 'em_dashboard_settings';
    
            $callback = array($this, 'menu_page');
    
            add_submenu_page( $parent_slug, $pagetitle, $menutitle, $capability, $menu_slug, $callback );
        }
    
        /**
         * Initialize the tabbed menu page
         *
         * @since 1.0.0
         * @return bool false if not admin || string menu page if admin
         */
        public function menu_page() {
    
            // Prevent access from non-admins and outside of admin pages.
            if ( false == is_super_admin() ) return false;
    
            $title = __( 'EM Dashboard Settings', 'emdashboard' );
    
            // WordPress 4.3.0 has new accessibility settings for screen readers (mainly h1/h2)
            $wp430 = $this->wp_version( '4.3.0', '>=' );
    
            ?>
            <div class="wrap">
    
                <?php if ( $wp430 ) : ?>
                    <h1><?php echo $title; ?></h1>
                <?php else : ?>
                    <h2><?php echo $title; ?></h2>
                <?php endif; ?>
    
                <?php if(isset($_POST['submit'])) { ?>
                    <div id="message" class="updated">
                        <p>
                            <?php _e( 'Your settings have been saved', 'emdashboard' ) ?>
                        </p>
                    </div>
                <?php }
    
                $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general_options'; //save tab location
                ?>
                <h2 class="nav-tab-wrapper">
                    <a href="?page=em_dashboard_settings&tab=general_options" class="nav-tab <?php echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; ?>">
                        <?php _e( 'General Settings', 'emdashboard' ); ?>
                    </a>
                    <!--<a href="?page=em_dashboard_settings&tab=easy_options" class="nav-tab <?php echo $active_tab == 'easy_options' ? 'nav-tab-active' : ''; ?>">
                        <?php _e( 'Easy Mode Settings', 'emdashboard' ); ?>
                    </a>-->
                    <a href="#" class="nav-tab " style="pointer-events:none;">
                        <?php _e( 'More coming soon!', 'emdashboard' ); ?>
                    </a>
                </h2>
    
                <?php
                if(isset($_POST['em_dashboard_g_settings'])){
            //        foreach((array)$_POST['em_dashboard_g_settings'] as $key => $value) {
            //            update_site_option($key,$value);
            //        }
                }
    
                if ( is_multisite() ) {
                    $action = 'settings.php?page=em_dashboard_settings&tab=general_options';
                } else {
                    $action = 'options.php';
                }
                ?>
                <form method="post" action="<?php echo $action; ?>">
                    <?php
                        //* @todo add more setting pages
                        // display tab content
                        //    if( $active_tab == 'display_options' ) {
                                do_settings_sections( 'em_dashboard_g_settings' );
                        //    } else {
                        //        do_settings_sections( 'pmt_tab_2' );
                        //    }
                    ?>
    
                    <?php submit_button(); ?>
                </form>
            </div>
            <?php
        }
    
        public function general_settings_fields() {
            settings_fields('em_dashboard_g_settings');
    
            if ( is_multisite() ) {
                $welcome = __('The settings on this page affect every user and site on your network.', 'emdashboard');
            } else {
                $welcome  = __('The settings on this page affect every user on your website', 'emdashboard');
            }
            ?><p style="display:inline-block;width:auto;padding:10px;margin:3px 0;border:1px solid #aaa;" class="widefat"><?php echo $welcome; ?></p>
            <hr>
            <?php
    
        }
    
        // ****************************************************************************************
        // Option fields
        // ****************************************************************************************
    
        /**
         * A checkbox setting field
         *
         * @param array $args the settings argument
         * @return string the settings field
         *
         * @since 1.0.0
         */
        public function checkbox( $args = array() ) {
    
            $name             = $args['name'];
            $page             = $args['page'];
            $default         = $args['default'];
            $info             = esc_attr( $args['labelinfo'] );
            $label_hover    = esc_attr( $args['hoverinfo'] );
            $hover_site     = esc_attr( $args['hoverinfosite'] );
            $hover_network    = esc_attr( $args['hoverinfonetwork'] );
    
            $option = $this->option();
    
            if ( is_array( $default ) ) {
                $option_name = $default[0];
    
                $default = $default[1];
                $option = $option[$option_name];
            }
            $the_option = get_site_option( $name, $option[$default] );
    
            $checked = ( $the_option === true ) ? 'checked="checked"' : '';
            $value = ( $the_option === true ) ? '1' : '0';
    
            if ( empty($label_hover) ) {
                if ( is_multisite() ) {
                    $label_hover = $hover_network;
                } else {
                    $label_hover = $hover_site;
                }
            }
            ?>
    
            <label>
            <?php /* <input type="checkbox" name="<?php echo $page; ?>[<?php echo $name; ?>]" id="<?php echo $name; ?>" value="<?php echo $value; ?>" <?php echo $checked; ?> /> */ ?>
                <input type="checkbox" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo $value; ?>" <?php echo $checked; ?> />
                <em><?php echo $info; ?></em>
                <?php
                if ( !empty( $label_hover ) ) {
                     ?><span style="text-decoration:underline" title="<?php echo $label_hover; ?>">[?]</span><?php
                }
            ?></label><?php
        }
    
        /**
         * A dropdown setting field
         *
         * Set the option values here based on the selected option.
         *
         * @param array $args the settings argument
         * @return string the settings field
         *
         * @todo maybe external filter for more options
         *
         * @since 1.0.0
         */
        public function dropdown( $args = array() ) {
            $name          = $args['name'];
            $page          = $args['page'];
            $default      = $args['default'];
            $info         = esc_attr( $args['labelinfo'] );
            $label_hover = esc_attr( $args['hoverinfo'] );
    
            $option = $this->option();
    
            if ( is_array( $default ) ) {
                $option_name = $default[0];
    
                $default = $default[1];
                $option = $option[$option_name];
            }
    
            $the_option = get_site_option( $name, $option[$default] );
    
            $options = array();
            $optionsi18n = array();
    
            /**
             * Start Options
             *
             * @since 1.0.0
             */
            // Start color_scheme
            if ( $name === 'em_dashboard_color_scheme' ) {
                global $_wp_admin_css_colors;
    
                ksort( $_wp_admin_css_colors );
    
                if ( isset( $_wp_admin_css_colors ) ) {
                    foreach ( $_wp_admin_css_colors as $color => $color_info ) { // Too tired/lazy at this point to check if the => $color_info is needed.
                        $options[] = $color;
                        $optionsi18n[] = $color_info->name;
                    }
                // Fallback
                } else {
                    $options = array( 'default', 'light', 'blue', 'midnight', 'sunrise', 'ectoplasm', 'ocean', 'coffee' );
                    $optionsi18n = array( __('Default'), __('Light'), __('Blue'), __('Midnight'), __('Sunrise'), __('Ectoplasm'), __('Ocean'), __('Coffee') );
                }
            // Start easy_mode
            } else if ( $name === 'em_dashboard_easy_mode' ) {
                $options = array( 'on', 'off');
                $optionsi18n = array(
                    __('On', 'emdashboard'),
                    __('Off', 'emdashboard'),
                );
            // Start Force Easy Capabilities
            } else if ( $name === 'em_dashboard_force_easy_capability') {
                //* Show only roles the current user is/can edit. Prevents getting stuck.
                $roles = get_editable_roles(); // this crashes outside the WP admin area. No problem.
                foreach ( $roles as $role_name => $role_info ) {
                    foreach ( $role_info['capabilities'] as $capability => $bool ) {
                        $capabilities[] = $capability;
                    }
                }
    
                $caps = array(
                    'edit_plugins'                 => __( 'Super Administrator', 'emdashboard' ),
                    'manage_options'             => __( 'Administrator', 'emdashboard' ),
                    'publish_pages'             => __( 'Editor', 'emdashboard' ),
                    'publish_posts'             => __( 'Author', 'emdashboard' ),
                    'edit_posts'                 => __( 'Contributor', 'emdashboard' ),
                    'read'                         => __( 'Subscriber', 'emdashboard' ),
                );
    
                foreach ( $caps as $cap => $capi18n ) {
                        if ( in_array ( $cap, $capabilities) ) {
                            $options[] = $cap;
                            $optionsi18n[] = $capi18n;
                        }
                }
            } else {
                // Option isn't parsed, bail. Doesn't really need translation.
                ?><em>Option failed to load. Please report to the plugin author.</em><?php
                return;
            }
    
            ?>
        <?php /* <select name="<?php echo $page; ?>[<?php echo $name; ?>]" value="<?php echo $the_option; ?>"> */ ?>
            <select name="<?php echo $name; ?>" value="<?php echo $the_option; ?>">
                <?php foreach ( array_combine($options, $optionsi18n) as $sel_option => $sel_option_i18n ) {
                        $selected = ($the_option == $sel_option ) ? 'selected' : '';
                        // Fall back to option name is no i18n is set.
                        $sel_option_i18n = !empty( $sel_option_i18n ) ? $sel_option_i18n : $sel_option;
    
                        $output = '<option value="' . $sel_option . '" ' . $selected . '>' . $sel_option_i18n . '</option>';
                        echo $output;
                }
                ?>
            </select>
    
            <label for="<?php echo $name ?>"><em><?php echo $info; ?> </em>
            <?php
            if ( !empty( $label_hover ) ) {
                 ?><span style="text-decoration:underline" title="<?php echo $label_hover; ?>">[?]</span><?php
             }
            ?></label><?php
        }
    
        // ****************************************************************************************
        //  Option sanitzation
        // ****************************************************************************************
    
        /**
         * @todo figure out a way to pass defaults, or not?
         */
    
        /**
         * Sanitize Checked
         *
         * @since 1.0.0
         *
         * @param bool/string $value the option
         * @return string 1 or 0 the sanitized option
         */
        public function s_checked($value, $default = '') {
    
            if ( $value === '1' || $value === '0' ) {
                return $value;
            } else if ( $value === true ) {
                return '1';
            } else if ( $value === false ) {
                return '0';
            } else {
                return $default;
            }
    
        }
    
        /**
         * Sanitize boolean
         *
         * @since 1.0.0
         *
         * @param bool/string $value the option
         * @return string 1 or 0 the sanitized option
         */
        public function s_boolean($value, $default = '') {
    
            if ( $value === true || $value === false ) {
                return $value;
            } else if ( $value === '1' ) {
                return true;
            } else if ( $value === '0' ) {
                return false;
            } else {
                return $default;
            }
    
        }
    
        /**
         * Sanitize color_scheme
         *
         * @since 1.0.0
         *
         * @param string $value the color scheme
         * @return string the sanitized option
         */
        public function s_colorscheme($value, $default = '') {
            global $_wp_admin_css_colors;
    
            ksort( $_wp_admin_css_colors );
    
            if ( isset( $_wp_admin_css_colors ) ) {
                foreach ( $_wp_admin_css_colors as $color => $color_info ) { // Too tired/lazy at this point to check if the => $color_info is needed.
                    if ( in_array( $value, $color, false ) && is_string($value) ) {
                        return $value;
                        break;
                    }
                }
            // Fallback
            } else {
                $color = array('default', 'light', 'blue', 'midnight', 'sunrise', 'ectoplasm', 'ocean', 'coffee');
                if ( in_array( $value, $color, false ) && is_string($value) ) {
                    return ucfirst($value);
                }
            }
    
            // Back to default if sanitation failed
            return $default;
        }
    
        /**
         * Sanitize Default Easy setting (on/off)
         *
         * @since 1.0.0
         */
        public function s_default_easy($value, $default = '') {
    
            if ( $value === 'on' || $value === 'off' ) {
                return $value;
            } else if ( $value === '1' || $value === true ) {
                return 'on';
            } else if ( $value === '0' || $value === false ) {
                return 'off';
            } else {
                return $default;
            }
    
        }
    
        /**
         * Sanitize Capability
         *
         * @uses get_editable_roles
         * @since 1.0.0
         */
        public function s_capability($value, $default = '') {
            $roles = get_editable_roles();
    
            if ( in_array( $value, $roles, false ) && is_string($value) ) {
                return $value;
            } else {
                return $default;
            }
    
        }
    
    }
  • Michael Bissett

    Hey @Sybre Waaijer,

    In addition to checking out the WordPress codex:

    https://codex.wordpress.org/Creating_Options_Pages

    https://codex.wordpress.org/Settings_API

    (as well as the external references in the Settings API codex entry)

    You may also wish to check out this article, in terms of getting the options to save:

    http://tangrufus.com/wordpress-plugin-boilerplate-tutorial-options-page/

    Hope this helps! :slight_smile:

    Kind Regards,
    Michael

    • Sybre Waaijer

      Hi @Michael Bissett

      Thank you so much for dropping by.

      I've fixed it already :slight_smile: The problem is is that there's no settings API for multisite options :slight_frown: Tickets on these issues have been open for 4 to 7 years already :stuck_out_tongue:

      So I've done the following, might this be useful to others:

      if ( $_POST && is_multisite() ) {
          if ( isset( $_POST['submit'] ) && $_POST['_wpnonce'] === $_REQUEST['_wpnonce'] ) {
      
              $settings = array_fill_keys( array(
                  'em_dashboard_em_styles', 'em_dashboard_em_fonts', 'em_dashboard_color_picker', 'em_dashboard_color_scheme',             //em_dashboard_g_settings
                  'em_dashboard_load_easy', 'em_dashboard_easy_mode', 'em_dashboard_force_easy', 'em_dashboard_force_easy_capability',    //em_dashboard_g_settings
              ), '');
      
              foreach( (array)$_POST as $key => $value ) {
                  if ( array_key_exists( $key, $settings ) ) {
                      update_site_option( $key, $value );
                  }
              }
          }
      }

      What it does is add an extra layer of option saving where it compares the $settings array (these must be equal to the add_settings_field id and register_setting id) and then saves them accordingly.

      The values are still passed through the sanitation callback (as I'm now still fixing :smiley:) set in register_setting('group', 'optionname', 'yoursanitationcallback') so it's pretty rock solid :smiley:

      If it's not a multisite environment, the options are getting saved accordingly through the settings api, so the $_POST action isn't needed. This still has to be tested but I still need to re-install my virtualbox :slight_smile:

      Hopefully others can learn from this :slight_smile: <3

      Thank you once again for your time ^^

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.