Ejemplo n.º 1
0
 /**
  * Set site transient to fake update information.
  *
  * @param   array  $value  The value of update_plugins site transient.
  *
  * @return  mixed
  */
 public static function site_transient_update_plugins($value)
 {
     // Get update simulator settings
     $settings = WR_Megamenu_Settings::get();
     if (@$settings['update-simulator']) {
         $update = array();
         // Preset value
         if (!is_object($value)) {
             $value = (object) array('response' => array());
         }
         foreach (array('pagebuilder', 'uniform', 'poweradmin') as $plugin) {
             // Simulate update info for configured plugins
             if (!empty($settings["wr-{$plugin}-version"]) && !empty($settings["wr-{$plugin}-link"])) {
                 // Simulate update available only if plugin is installed
                 if (@is_file(WP_PLUGIN_DIR . '/' . $settings["wr-{$plugin}-file"])) {
                     // Make simulated version is really newer
                     $current = WR_Megamenu_Product_Info::get(WP_PLUGIN_DIR . '/' . $settings["wr-{$plugin}-file"]);
                     if (version_compare($current['Version'], $settings["wr-{$plugin}-version"], '<')) {
                         $value->response[$settings["wr-{$plugin}-file"]] = (object) array('id' => 0, 'slug' => "wr-{$plugin}", 'new_version' => $settings["wr-{$plugin}-version"], 'url' => "https://wordpress.org/plugins/wr-{$plugin}/", 'package' => $settings["wr-{$plugin}-link"]);
                     }
                 }
             }
         }
     }
     return $value;
 }
Ejemplo n.º 2
0
 /**
  * Method to get WR MegaMenu settings.
  *
  * @param   boolean  $update_options  Whether to update options array with real value or not?
  *
  * @return  array
  */
 public static function get($update_options = false)
 {
     if (!isset(self::$settings)) {
         // Get current settings
         $settings = get_option('wr_megamenu_settings', array());
         // Apply default settings if neccessary
         if (!$update_options && !count($settings)) {
             foreach (self::$options['fields'] as $name => $value) {
                 if (isset($value['default'])) {
                     $settings[$name] = $value['default'];
                 }
             }
         }
         self::$settings = $settings;
     }
     // Update options array if requested
     if ($update_options) {
         // Set current settings to field values
         if (count(self::$settings)) {
             foreach (self::$settings as $name => $value) {
                 self::$options['fields'][$name]['value'] = $value;
             }
         }
         // Get WooRockets customer account
         $customer_account = get_option('wr_mm_customer_account', null);
         if (!empty($customer_account)) {
             foreach (array('username', 'password') as $field) {
                 self::$options['fields']["customer-{$field}"]['value'] = $customer_account[$field];
             }
         }
     }
     return self::$settings;
 }