/**
  * Return an instance of this class.
  *
  * @since     1.0.0
  *
  * @return    object    A single instance of this class.
  */
 public static function get_instance()
 {
     // If the single instance hasn't been set, set it now.
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
<?php

/**
 * Represents the view for the settings on the Theme Options panel.
 *
 * @package   SDS_One_Click_Child_Themes
 * @author    Slocum Studio
 * @license   GPL-2.0+
 * @link      http://slocumstudio.com/
 * @copyright 2014 Slocum Studio
 */
$sds_themes = SDS_Themes::get_instance();
?>

<?php 
// One-Click Child Themes Settings
?>
<div id="one-click-child-themes-tab-content" class="sds-theme-options-tab-content">
	<h3><?php 
_e('"One-Click" Child Themes', $this->plugin_slug);
?>
</h3>

	<?php 
if ($this->is_multisite) {
    // Multisite is active
    ?>
		<!--div class="message error settings-error sds-child-themes-message" style="border-left: 4px solid #ffba00; display: none !important;">
			<p><strong><?php 
    _e('Please Note: It looks like Multisite is active. Contact your network administrator to enable child themes on the network if you are having trouble.', $this->plugin_slug);
    ?>
 /**
  * Sanitize/Validate settings on the Theme Options panel.
  *
  * @since    1.0.0
  *
  * @return   array    Filtered/Sanitized user input
  */
 public function sanitize_option_sds_theme_options($input)
 {
     $sds_themes = SDS_Themes::get_instance();
     // Load admin functionality assets if necessary
     if (!function_exists('add_settings_error')) {
         require_once ABSPATH . 'wp-admin/includes/admin.php';
     }
     /**
      * "One-Click" Child Themes
      */
     // Create child theme
     if (isset($input['create_child_theme'])) {
         $theme_root = trailingslashit(get_theme_root());
         // Theme directory
         $child_theme_name = isset($input['child_theme']['name']) ? sanitize_title($input['child_theme']['name']) : false;
         // Child theme directory name
         $child_theme_directory = trailingslashit($theme_root . $child_theme_name);
         // Child theme
         $child_theme_stylesheet_header = $sds_themes->create_stylesheet_header(sanitize_text_field($input['child_theme']['name']));
         // Child theme stylesheet header
         // Make sure we have a valid theme name
         if (empty($child_theme_name)) {
             add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-name-invalid', __('Please enter a valid child theme name.', $this->plugin_slug));
         } else {
             if (file_exists($theme_root . $child_theme_name)) {
                 add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-exists', __('It appears that a child theme with that name already exists. Please try again with a different child theme name.', $this->plugin_slug));
             } else {
                 if (!$sds_themes->create_child_theme($child_theme_directory, $child_theme_stylesheet_header, $theme_root)) {
                     add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-creation-failed', __('There was a problem creating the child theme. Please check your server permissions.', $this->plugin_slug));
                 } else {
                     // Multisite
                     if ($this->is_multisite) {
                         // Activate the child theme
                         if (isset($input['child_theme']['activate'])) {
                             // Enable it across the network first
                             if ($sds_themes->network_enable_child_theme($child_theme_name)) {
                                 // Activate child theme
                                 if ($sds_themes->activate_child_theme($child_theme_name)) {
                                     add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-activation-success', sprintf(__('New theme activated. <a href="%s">Visit site</a> or <a href="%s">edit child theme</a>.', $this->plugin_slug), home_url('/'), admin_url('theme-editor.php?theme=' . urlencode($child_theme_name))), 'updated');
                                 } else {
                                     add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-activation-failed', sprintf(__('Child theme created successfully but there was a problem activating it. Please <a href="%s">try again</a>', $this->plugin_slug), wp_nonce_url(admin_url('themes.php?action=activate&amp;stylesheet=' . urlencode($child_theme_name)), 'switch-theme_' . $child_theme_name)), 'error');
                                 }
                             } else {
                                 add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-network-enable-failed', __('Child theme created successfully but there was a problem enabling it on the network. Please contact your network administrator.', $this->plugin_slug), 'error');
                             }
                         } else {
                             if (isset($input['child_theme']['network_enable'])) {
                                 // Enable it across the network
                                 if ($sds_themes->network_enable_child_theme($child_theme_name)) {
                                     add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-network-enable-success', sprintf(__('Child theme created successfully and enabled across the network. <a href="%s">Activate</a> your child theme.', $this->plugin_slug), wp_nonce_url(admin_url('themes.php?action=activate&amp;stylesheet=' . urlencode($child_theme_name)), 'switch-theme_' . $child_theme_name)), 'updated');
                                 } else {
                                     add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-network-enable-failed', __('Child theme created successfully but there was a problem enabling it on the network. Please contact your network administrator.', $this->plugin_slug), 'error');
                                 }
                             } else {
                                 add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-creation-success', __('Child theme created successfully. Please network enable your child theme.', $this->plugin_slug), 'updated');
                             }
                         }
                     } else {
                         // Activate the child theme
                         if (isset($input['child_theme']['activate'])) {
                             // Activate child theme
                             if ($sds_themes->activate_child_theme($child_theme_name)) {
                                 add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-activation-success', sprintf(__('New theme activated. <a href="%s">Visit site</a> or <a href="%s">edit child theme</a>.', $this->plugin_slug), home_url('/'), admin_url('theme-editor.php?theme=' . urlencode($child_theme_name))), 'updated');
                             } else {
                                 add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-activation-failed', sprintf(__('Child theme created successfully but there was a problem activating it. Please try againNew theme activated. <a href="%s">Visit site</a> or <a href="%s">edit child theme</a>.', $this->plugin_slug), home_url('/'), admin_url('theme-editor.php?theme=' . urlencode($child_theme_name))), 'updated');
                             }
                         } else {
                             add_settings_error('sds_theme_options', 'sds_theme_options-child-theme-creation-success', sprintf(__('Child theme created successfully. <a href="%s">Activate</a> your child theme.', $this->plugin_slug), wp_nonce_url(admin_url('themes.php?action=activate&amp;stylesheet=' . urlencode($child_theme_name)), 'switch-theme_' . $child_theme_name)), 'updated');
                         }
                     }
                 }
             }
         }
     }
     // Remove child theme data from option
     unset($input['child_theme']);
     unset($input['create_child_theme']);
     return $input;
 }