Skip to content

OG Easy Eye: developer's guide

This page lists what OG Easy Eye exposes to code: shortcodes, constants, options, markup hooks and the front-end script. For settings and everyday use, see the user guide.

OG Easy Eye has no REST routes, no blocks, no MCP tools and no WP-CLI commands. It fires no actions or filters of its own.

Shortcode

[og_easy_eye_toggle]

Prints a button that switches dark mode on and off.

<button type="button" class="oge-inline" data-oge-toggle aria-pressed="false">Toggle dark mode</button>
Attribute Values
none The shortcode takes no attributes.

It prints nothing on pages where dark mode does not run (dark mode switched off, a skipped page, an editor preview and so on).

Constants

Constant Where to set it What it does
OG_EASY_EYE_DISABLE wp-config.php true switches every feature off. Only the admin notice runs.
OG_EASY_EYE_VERSION Set by the plugin The running version. If it is already defined when the plugin loads (two copies installed), the second copy does nothing.
OG_EASY_EYE_FILE Set by the plugin Full path to the main plugin file.
OG_EASY_EYE_DIR Set by the plugin Plugin folder path, with a trailing slash.
OG_EASY_EYE_URL Set by the plugin Plugin folder URL, with a trailing slash.
// wp-config.php: switch OG Easy Eye off without wp-admin.
define( 'OG_EASY_EYE_DISABLE', true );

Options

Option Type What it holds
oge_settings array All settings. See the keys below.
oge_faults array Faults in the last hour, up to 10 entries. Each is ['t' => unix time, 'm' => message]. Not autoloaded.
oge_safe_mode int 1 while safe mode is on. Not autoloaded.

oge_settings keys

Key Type Default Allowed values
front_enabled int 1 0 or 1
admin_enabled int 1 0 or 1
front_default string auto auto, dark, light
admin_default string light auto, dark, light
base string light light, dark (the theme's own look)
style string invert invert, palette
brightness int 100 50 to 150
contrast int 92 50 to 150
sepia int 0 0 to 100
bg string #121212 Hex colour
text string #e6e6e6 Hex colour
link string #8ab4f8 Hex colour
show_toggle int 1 0 or 1
menus int[] [] Nav menu term IDs that get a toggle item
menu_label string Dark mode Up to 40 characters; empty = icon only
toggle_pos string bl br, bl, tr, tl
exclude_selectors string empty One CSS selector per line, up to 50
flip_selectors string .ogaie-icon One CSS selector per line, up to 50
exclude_urls string empty One address fragment per line, up to 50
custom_css string empty Plain CSS; tags and < are stripped

Settings are registered in the oge_group settings group, so values saved through update_option() pass the same sanitising.

// Turn dark mode off on the front end from code.
$s = get_option( 'oge_settings', array() );
$s['front_enabled'] = 0;
update_option( 'oge_settings', $s );

Changing oge_settings purges LiteSpeed Cache, WP Rocket, WP Super Cache and Autoptimize.

Admin-post actions

Action Capability Nonce What it does
oge_reset manage_options oge_reset Clears oge_safe_mode and oge_faults, then returns to the settings screen. Only registered while safe mode is on.

Admin screen

Item Value
Menu slug og-easy-eye (top-level, manage_options)
Open a section admin.php?page=og-easy-eye&oge_tab=<section>
Sections mode, style, toggle, exceptions, health, more

Markup and CSS

Item Meaning
html.oge-dark Class on <html> while dark mode shows. Start your own dark-mode rules with it.
html[data-oge-base] light or dark: the site's own look. wp-admin is always light.
html[data-oge-key] The local storage key in use: oge-front or oge-admin.
[data-oge-toggle] Any element with this attribute toggles dark mode on click. Its aria-pressed is kept in sync.
#oge-toggle The floating button. Position classes: oge-br, oge-bl, oge-tr, oge-tl.
.oge-menu-item The menu toggle <li>. Inside it: .oge-menu-icon and .oge-menu-label.
.oge-inline The shortcode button.
#wp-admin-bar-oge-toggle The admin-bar node (oge-toggle). It sits under ogaie-settings when OG AI Core adds that node.
#oge-early Inline head script that applies the saved choice before paint.
#oge-css Inline dark-mode styles.

Add your own toggle anywhere:

<a href="#" data-oge-toggle aria-pressed="false">Switch theme</a>
html.oge-dark .my-card { box-shadow: none; }

Front-end script

The toggle script is assets/oge.js, loaded deferred in the footer with the handle og-easy-eye.

Item Value
Storage localStorage key oge-front (website) or oge-admin (wp-admin). Value dark or light.
Keyboard Alt+Shift+D toggles.
Globals None.
Events None. Watch the oge-dark class on document.documentElement if you need to react.
// React when dark mode changes.
new MutationObserver(function () {
  var dark = document.documentElement.classList.contains('oge-dark');
  console.log('Dark mode', dark);
}).observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });

When dark mode does not run

The head script, styles and toggles are skipped on:

  • feeds, embeds, the Customizer preview and REST requests;
  • Elementor, Divi and Beaver Builder editors and previews;
  • admin AJAX requests;
  • pages whose address contains a line from exclude_urls.

Optimisers

The plugin adds og-easy-eye/assets/oge.js to these exclusion lists: litespeed_optimize_js_excludes, litespeed_optm_js_defer_exc, rocket_exclude_js, rocket_exclude_defer_js and autoptimize_filter_js_exclude. The inline tags carry data-no-optimize, data-no-defer, data-no-minify, data-noptimize, data-cfasync="false", data-pagespeed-no-defer and data-rocket-no-defer.

Uninstall

uninstall.php deletes oge_settings, oge_faults and oge_safe_mode (site and network options). Nothing else is removed.