/** * Add the theme settings to the admin panel. * * @param mixed[] $settingsObj * @return type */ public function add_settings($settingsObj = null, $section = null, $group = null) { if ($settingsObj == null) { $settingsObj = $this->settings; } // Exit is directory does not exist // if (!is_dir($this->css_dir)) { if (isset($this->notifications)) { $this->notifications->add_notice(2, sprintf(__('The theme directory:<br/>%s<br/>is missing. ', 'wpcsl'), $this->css_dir) . __('Create it to enable themes and get rid of this message.', 'wpcsl')); } return; } // The Themes // No themes? Force the default at least // $themeArray = get_option($this->prefix . '-theme_array'); if (count($themeArray, COUNT_RECURSIVE) < 2) { $themeArray = array('Default' => 'default'); } // Check for theme files // $lastNewThemeDate = get_option($this->prefix . '-theme_lastupdated'); $newEntry = array(); if ($dh = opendir($this->css_dir)) { while (($file = readdir($dh)) !== false) { // If not a hidden file // if (!preg_match('/^\\./', $file)) { $thisFileModTime = filemtime($this->css_dir . $file); // We have a new theme file possibly... // if ($thisFileModTime > $lastNewThemeDate) { $newEntry = $this->get_ThemeInfo($this->css_dir . $file); $themeArray = array_merge($themeArray, array($newEntry['label'] => $newEntry['file'])); update_option($this->prefix . '-theme_lastupdated', $thisFileModTime); } } } closedir($dh); } // Remove empties and sort $themeArray = array_filter($themeArray); ksort($themeArray); // Delete the default theme if we have specific ones // $resetDefault = false; if (count($themeArray, COUNT_RECURSIVE) > 1 && isset($themeArray['Default'])) { unset($themeArray['Default']); $resetDefault = true; } // We added at least one new theme // if (count($newEntry, COUNT_RECURSIVE) > 1 || $resetDefault) { update_option($this->prefix . '-theme_array', $themeArray); } if ($section == null) { $section = 'Display Settings'; } $settingsObj->add_itemToGroup(array('section' => $section, 'group' => $group, 'label' => __('Select A Theme', 'wpcsl'), 'setting' => 'theme', 'type' => 'list', 'custom' => $themeArray, 'value' => 'default', 'description' => __('How should the plugin UI elements look? ', 'wpcsl') . sprintf(__('Learn more in the <a href="%s" target="csa">online documentation</a>.', 'wpcsl'), $this->support_url . 'user-experience/view/themes-custom-css/'), 'onChange' => "AdminUI.show_ThemeDetails(this);")); // Add Theme Details Divs // $settingsObj->add_ItemToGroup(array('section' => $section, 'group' => $group, 'setting' => 'themedesc', 'type' => 'subheader', 'label' => '', 'description' => $this->setup_ThemeDetails($themeArray), 'show_label' => false)); }
/** * Compare current plugin version with minimum required. * * Set a notification message. * Disable the requesting add-on pack if requirement is not met. * * $params['addon_name'] - the plain text name for the add-on pack. * $params['addon_slug'] - the slug for the add-on pack. * $params['min_required_version'] - the minimum required version of the base plugin. * * @param mixed[] $params */ function VersionCheck($params) { // Minimum version requirement not met. // if (version_compare($this->version, $params['min_required_version'], '<')) { if (is_admin()) { if (isset($this->notifications)) { $this->notifications->add_notice(4, '<strong>' . sprintf(__('%s has been deactivated.', 'wpcsl'), $params['addon_name']) . '<br/> ' . '</strong>' . sprintf(__('You have %s version %s.', 'wpcsl'), $this->name, $this->version) . '<br/> ' . sprintf(__('You need version %s or greater for this version of %s.', 'wpcsl'), $params['min_required_version'], $params['addon_name']) . '<br/> ' . sprintf(__('Please install an older version of %s or upgrade.', 'wpcsl'), $this->name) . '<br/> ' . sprintf(__('Upgrading major versions of %s requires paid upgrades to all related add-on packs.', 'wpcsl'), $this->name) . '<br/><br/>'); } deactivate_plugins(array($params['addon_slug'])); } return; } // Register add on if version is ok // $this->register_addon($params['addon_slug']); }