Exemple #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;
 }
 /**
  * Initialize WR MegaMenu admin menu.
  *
  * @return  void
  */
 public static function init()
 {
     global $pagenow;
     // Get product information
     $plugin = WR_Megamenu_Product_Info::get(WR_MEGAMENU_IDENTIFIED_NAME);
     // Generate menu title
     $menu_title = __('WR MegaMenu', WR_MEGAMENU_TEXTDOMAIN);
     if (isset($plugin['Available_Update']) && $plugin['Available_Update'] && ('admin.php' != $pagenow || !isset($_GET['page']) || !in_array($_GET['page'], self::$pages))) {
         $menu_title .= " <span class='wr-available-updates update-plugins count-{$plugin['Available_Update']}'><span class='pending-count'>{$plugin['Available_Update']}</span></span>";
     }
     $menu = array('page_title' => __($menu_title, WR_MEGAMENU_TEXTDOMAIN), 'menu_title' => __('Settings', WR_MEGAMENU_TEXTDOMAIN), 'capability' => 'manage_options', 'menu_slug' => 'wr-megamenu-settings', 'function' => array(__CLASS__, 'settings'));
     /*
     WR_Megamenu_Init_Admin_Menu::add( $menu , 'edit.php?post_type=wr_megamenu_profile' );
     */
     if (@$plugin['Addons']) {
         // Generate menu title
         $menu_title = __('Add-ons', WR_MEGAMENU_TEXTDOMAIN);
         if (@$plugin['Available_Update'] && ('admin.php' == $pagenow && isset($_GET['page']) && in_array($_GET['page'], self::$pages))) {
             $menu_title .= " <span class='wr-available-updates update-plugins count-{$plugin['Available_Update']}'><span class='pending-count'>{$plugin['Available_Update']}</span></span>";
         }
         // Update admin menus
         $menu = array('page_title' => __('WR MegaMenu - Add-ons', WR_MEGAMENU_TEXTDOMAIN), 'menu_title' => $menu_title, 'capability' => 'manage_options', 'menu_slug' => 'wr-menu-addons', 'function' => array(__CLASS__, 'addons'));
         WR_Megamenu_Init_Admin_Menu::add($menu, 'edit.php?post_type=wr_megamenu_profile');
     }
     WR_Megamenu_Init_Admin_Menu::add(array('page_title' => __('WR MegaMenu - About', WR_MEGAMENU_TEXTDOMAIN), 'menu_title' => __('About', WR_MEGAMENU_TEXTDOMAIN), 'capability' => 'manage_options', 'menu_slug' => 'wr-megamenu-about-us', 'function' => array(__CLASS__, 'about_us')), 'edit.php?post_type=wr_megamenu_profile');
 }
Exemple #3
0
 /**
  * Hook into WordPress.
  *
  * @return  void
  */
 public static function hook()
 {
     // Register necessary action and filter
     static $registered;
     if (!isset($registered)) {
         // Execute parent hook
         parent::hook();
         // Register filter to get product update
         add_filter('site_transient_update_plugins', array(__CLASS__, 'site_transient_update_plugins'));
         // Register action to display product update details
         add_action('install_plugins_pre_plugin-information', array(__CLASS__, 'install_plugins_pre_information'));
         // Register filter to post-process product update
         add_filter('upgrader_post_install', array(__CLASS__, 'upgrader_post_install'), 10, 3);
         $registered = true;
     }
     // Get installed product
     $plugins = array_unique(apply_filters('wr_mm_installed_product', array()));
     // Get product info
     foreach ($plugins as $plugin) {
         if (!isset(self::$plugins[$plugin])) {
             self::$plugins[$plugin] = self::get($plugin);
         }
     }
 }