Droit Dark Mode Shortcode

Below, you’ll find a detailed guide on how to add the Droit Dark Mode Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Droit Dark Mode Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Droit Dark Mode Plugin and the shortcodes it provides:

Plugin Icon
Droit Dark Mode

"Droit Dark Mode is a highly effective WordPress plugin that allows users to easily switch their website interface between daytime and night mode, offering a comfortable browsing experience."

★★★☆✩ (17) Active Installs: 5000+ Tested with: 6.2.3 PHP Version: 7.0
Included Shortcodes:
  • [drdt_dark_mode]

Droit Dark Mode [drdt_dark_mode] Shortcode

The Droit Dark Mode shortcode is a functional tool that enables the display of a dark mode button on your website. It retrieves button position and style settings from your WordPress options. If the frontend mode is enabled, it loads the button style based on the attributes given. It then outputs the button design, defaulting to style-1 if the specified style isn’t found.

Shortcode: [drdt_dark_mode]


Here is a list of all possible drdt_dark_mode shortcode parameters and attributes:

  • position – defines the location of the dark mode button
  • style – determines the appearance of the dark mode button

Examples and Usage

Basic example – The following example showcases the basic usage of the ‘drdt_dark_mode’ shortcode without any parameters. The button style and position will be fetched from the saved options.

[drdt_dark_mode /]

Advanced examples

Example 1 – In this example, we are specifying the ‘position’ parameter to customize the button’s position. The ‘position’ attribute could be ‘left’, ‘right’, ‘top’ or ‘bottom’.

[drdt_dark_mode position="right" /]

Example 2 – Here, we are specifying both ‘position’ and ‘style’ parameters. The ‘style’ attribute is a numeric value that corresponds to the button’s style variations. For instance, ‘style=2’ would load the second style variation of the button.

[drdt_dark_mode position="top" style="2" /]

These examples demonstrate how the ‘drdt_dark_mode’ shortcode can be used with different parameters to customize the dark mode button’s appearance and position.

PHP Function Code

In case you have difficulties debugging what causing issues with [drdt_dark_mode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'drdt_dark_mode', [ $this, 'render_dark_mode_btn' ] );

Shortcode PHP function:

function render_dark_mode_btn( $atts ){
        $data = get_option($this->option_keys, true);
        $position = ($data['button_position']) ?? '';
        $style = ($data['button_style']) ?? 1;
        $atts = shortcode_atts( 
                'position' => $position,
                'style'    => $style,

        $mode = isset($data['frontend']) ? 'yes' : 'no';
        if( $mode != 'yes'){
        // loaf style of button
        $sty = ($atts['style']) ?? $style;
        $posi = ($atts['position']) ?? $position;
        $designpath = Contr::dtdr_dir() . 'templates/button/style-'.$sty.'.php';
        // start objetc content data here
        if( is_readable( $designpath ) ){
            include_once $designpath;
        } else {
            include_once Contr::dtdr_dir() . 'templates/button/style-1.php';
        $content = ob_get_contents();

        return $content;

Code file location:



Now that you’ve learned how to embed the Droit Dark Mode Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.


Leave a Reply

Your email address will not be published. Required fields are marked *