# darkify/1.4.23/src/Admin/Framework/Classes/abstract.class.php

Darkify – Dark Mode &amp; Night Mode for Website &amp; Admin (Dark Theme Included), version 1.4.23. 187 lines.

- Page: https://pluginprobe.com/plugins/darkify/1.4.23/code/src/Admin/Framework/Classes/abstract.class.php
- Raw: https://pluginprobe.com/plugins/darkify/1.4.23/raw/src/Admin/Framework/Classes/abstract.class.php
- Modified: 2026-02-23T11:28:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/darkify/1.4.23/code/src/Admin/Framework/Classes/abstract.class.php#L10-L20`.

```php
<?php

use ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify;

 if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
/**
 *
 * Abstract Class
 *
 * @since 1.0.0
 * @version 1.0.0
 *
 */
if ( ! class_exists( 'DarkifyAbstract' ) ) {
  abstract class DarkifyAbstract {

    public $abstract   = '';
    public $output_css = '';

    public function __construct() {}

    public function recursive_output_css( $fields = array(), $combine_field = array() ) {

      if ( ! empty( $fields ) ) {

        foreach ( $fields as $field ) {

          $field_id     = ( ! empty( $field['id'] ) ) ? $field['id'] : '';
          $field_type   = ( ! empty( $field['type'] ) ) ? $field['type'] : '';
          $field_output = ( ! empty( $field['output'] ) ) ? $field['output'] : '';
          $field_check  = ( $field_type === 'typography' || $field_output ) ? true : false;
          $field_class  = 'DarkifyField_' . $field_type;

          if ( $field_type && $field_id ) {

            if( $field_type === 'fieldset' ) {
              if ( ! empty( $field['fields'] ) ) {
                $this->recursive_output_css( $field['fields'], $field );
              }
            }

            if( $field_type === 'accordion' ) {
              if ( ! empty( $field['accordions'] ) ) {
                foreach ( $field['accordions'] as $accordion ) {
                  $this->recursive_output_css( $accordion['fields'], $field );
                }
              }
            }

            if( $field_type === 'tabbed' ) {
              if ( ! empty( $field['tabs'] ) ) {
                foreach ( $field['tabs'] as $accordion ) {
                  $this->recursive_output_css( $accordion['fields'], $field );
                }
              }
            }

            if( $field_type === 'section_tab' ) {
              if ( ! empty( $field['tabs'] ) ) {
                foreach ( $field['tabs'] as $accordion ) {
                  $this->recursive_output_css( $accordion['fields'], $field );
                }
              }
            }
            if( $field_type === 'section_inner_tab' ) {
              if ( ! empty( $field['tabs'] ) ) {
                foreach ( $field['tabs'] as $accordion ) {
                  $this->recursive_output_css( $accordion['fields'], $field );
                }
              }
            }

            if ( class_exists( $field_class ) ) {

              if ( method_exists( $field_class, 'output' ) || method_exists( $field_class, 'enqueue_google_fonts' ) ) {

                $field_value = '';

                if ( $field_check && ( $this->abstract === 'options' || $this->abstract === 'customize' ) ) {

                  if( ! empty( $combine_field ) ) {

                    $field_value = ( isset( $this->options[$combine_field['id']][$field_id] ) ) ? $this->options[$combine_field['id']][$field_id] : '';

                  } else {

                    $field_value = ( isset( $this->options[$field_id] ) ) ? $this->options[$field_id] : '';

                  }

                } else if ( $field_check && ( $this->abstract === 'metabox' && is_singular() || $this->abstract === 'taxonomy' && is_archive() ) ) {

                  if( ! empty( $combine_field ) ) {

                    $meta_value  = $this->get_meta_value( $combine_field );
                    $field_value = ( isset( $meta_value[$field_id] ) ) ? $meta_value[$field_id] : '';

                  } else {

                    $meta_value  = $this->get_meta_value( $field );
                    $field_value = ( isset( $meta_value ) ) ? $meta_value : '';

                  }

                }

                $instance = new $field_class( $field, $field_value, $this->unique, 'wp/enqueue', $this );

                // output css
                if ( $field_output && $this->args['output_css'] ) {
                  Darkify::$css .= $instance->output();
                }

                unset( $instance );

              }
            }
          }
        }
      }
    }

    public function pre_tabs( $sections ) {

      $count   = 100;
      $result  = array();
      $parents = array();

      foreach ( $sections as $key => $section ) {
        if ( ! empty( $section['parent'] ) ) {
          $section['priority'] = ( isset( $section['priority'] ) ) ? $section['priority'] : $count;
          $parents[$section['parent']][] = $section;
          unset( $sections[$key] );
        }
        $count++;
      }

      foreach ( $sections as $key => $section ) {
        $section['priority'] = ( isset( $section['priority'] ) ) ? $section['priority'] : $count;
        if ( ! empty( $section['id'] ) && ! empty( $parents[$section['id']] ) ) {
          $section['subs'] = wp_list_sort( $parents[$section['id']], array( 'priority' => 'ASC' ), 'ASC', true );
        }
        $result[] = $section;
        $count++;
      }

      return wp_list_sort( $result, array( 'priority' => 'ASC' ), 'ASC', true );

    }

    public function pre_sections( $sections ) {

      $result = array();

      foreach ( $this->pre_tabs( $sections ) as $section ) {
        if ( ! empty( $section['subs'] ) ) {
          foreach ( $section['subs'] as $sub ) {
            $sub['ptitle'] = ( ! empty( $section['title'] ) ) ? $section['title'] : '';
            $result[] = $sub;
          }
        }
        if ( empty( $section['subs'] ) ) {
          $result[] = $section;
        }
      }

      return $result;
    }

    public function pre_fields( $sections ) {

      $result = array();

      foreach ( $sections as $key => $section ) {
        if ( ! empty( $section['fields'] ) ) {
          foreach ( $section['fields'] as $field ) {
            $result[] = $field;
          }
        }
      }

      return $result;
    }

  }
}

```
