Exemplo n.º 1
0
function wpsRunFixes()
{
    $methods = WpsSettings::getSettingsList();
    if (empty($methods)) {
        return false;
    }
    foreach ($methods as $method) {
        add_action('init', array('WsdSecurity', $method['name']));
    }
}
Exemplo n.º 2
0
 /**
  * Retrieve the settings from database. This method will extract all methods found in the WsdSecurity class and provide them as
  * settings in the settings page. It will also auto update itself in case new methods are added to the class or if
  * some of them were removed.
  * @return array
  */
 public static function getSettings()
 {
     $className = 'WsdSecurity';
     if (!class_exists($className)) {
         return array();
     }
     if (wpsIsMultisite()) {
         $settings = get_blog_option(1, WpsSettings::PLUGIN_SETTINGS_OPTION_NAME);
     } else {
         $settings = WpsOption::getOption(WpsSettings::PLUGIN_SETTINGS_OPTION_NAME);
     }
     $methods = WpsSettings::getSettingsList();
     $useReflection = false;
     if (empty($settings)) {
         $settings = array();
         foreach ($methods as $method) {
             $settings[$method['name']] = array('name' => $method['name'], 'value' => 0, 'desc' => $method['text']);
         }
     } else {
         // Check to see whether or not new methods were added or subtracted
         $numSettings = count($settings);
         $numMethods = count($methods);
         if ($numMethods != $numSettings) {
             // add new methods
             $_temp = array();
             foreach ($methods as $method) {
                 if (!isset($settings[$method['name']])) {
                     $settings[$method['name']] = array('name' => $method['name'], 'value' => 0, 'desc' => $method['text']);
                 }
                 array_push($_temp, $method['name']);
             }
             // remove missing methods
             foreach ($settings as $k => &$entry) {
                 if (!in_array($entry['name'], $_temp)) {
                     unset($settings[$k]);
                 }
             }
         }
     }
     WpsOption::addOption(WpsSettings::PLUGIN_SETTINGS_OPTION_NAME, $settings);
     return $settings;
 }