/** * 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_cf_installed_product', array())); // Get product info foreach ($plugins as $plugin) { if (!isset(self::$plugins[$plugin])) { self::$plugins[$plugin] = self::get($plugin); } } }
/** * Register admin menu for IT Contactform Plugin. * * @return void */ public static function wr_contactform_register_menus() { global $pagenow; // Get product information $plugin = WR_CF_Product_Info::get(WR_CONTACTFORM_IDENTIFICATION); // Generate menu title $menu_title = __('WR ContactForm', WR_CONTACTFORM_TEXTDOMAIN); if (isset($plugin['Available_Update']) && ('edit.php' != $pagenow || !isset($_GET['post_type']) || !in_array($_GET['post_type'], self::$pages))) { WR_CF_Init_Admin_Menu::replace('WR ContactForm', array(0 => "WR ContactForm <span class='wr-available-updates update-plugins count-{$plugin['Available_Update']}'><span class='pending-count'>{$plugin['Available_Update']}</span></span>", 1 => 'edit_posts', 2 => 'edit.php?post_type=wr_cf_post_type', 3 => '', 4 => 'menu-top menu-icon-wr_cf_post_type', 5 => 'menu-posts-wr_cf_post_type', 6 => WR_CONTACTFORM_URI . '/assets/images/icons-16/icon-forms.png')); } // Register menu item for Forms page WR_CF_Init_Admin_Menu::add(array('parent_slug' => 'edit.php?post_type=wr_cf_post_type', 'menu_title' => __('All Forms', WR_CONTACTFORM_TEXTDOMAIN), 'page_title' => __('All Forms', WR_CONTACTFORM_TEXTDOMAIN), 'menu_slug' => 'edit.php?post_type=wr_cf_post_type', 'capability' => 'edit_posts', 'menu_slug' => 'edit.php?post_type=wr_cf_post_type')); // Register menu item for Forms page WR_CF_Init_Admin_Menu::add(array('parent_slug' => 'edit.php?post_type=wr_cf_post_type', 'menu_title' => __('Add New', WR_CONTACTFORM_TEXTDOMAIN), 'page_title' => __('Add New', WR_CONTACTFORM_TEXTDOMAIN), 'menu_slug' => 'post-new.php?post_type=wr_cf_post_type', 'capability' => 'edit_posts', 'menu_slug' => 'post-new.php?post_type=wr_cf_post_type')); // Register menu item for Submissions page WR_CF_Init_Admin_Menu::add(array('parent_slug' => 'edit.php?post_type=' . 'wr_cf_post_type', 'page_title' => 'WR ContactForm Plugin - Submissions', 'menu_title' => 'Submissions', 'capability' => 'edit_posts', 'menu_slug' => 'edit.php?post_type=wr_cfsb_post_type')); // Register menu item for configuration page WR_CF_Init_Admin_Menu::add(array('parent_slug' => 'edit.php?post_type=' . 'wr_cf_post_type', 'page_title' => 'WR ContactForm Plugin - Settings', 'menu_title' => 'Settings', 'capability' => 'edit_posts', 'menu_slug' => 'wr-contactform-settings', 'function' => array('WR_Contactform_Helpers_Hook', 'settings'))); if ($plugin['Addons']) { // Generate menu title $menu_title = __('Add-ons', WR_CONTACTFORM_TEXTDOMAIN); if ($plugin['Available_Update'] && ('edit.php' == $pagenow && isset($_GET['post_type']) && in_array($_GET['post_type'], self::$pages))) { $menu_title .= " <span class='wr-available-updates update-plugins count-{$plugin['Available_Update']}'><span class='pending-count'>{$plugin['Available_Update']}</span></span>"; } // Register menu item for configuration page WR_CF_Init_Admin_Menu::add(array('parent_slug' => 'edit.php?post_type=' . 'wr_cf_post_type', 'page_title' => 'WR ContactForm Plugin - Addons', 'menu_title' => $menu_title, 'capability' => 'edit_posts', 'menu_slug' => 'wr-contactform-addons', 'function' => array('WR_Contactform_Helpers_Hook', 'addons'))); } WR_CF_Init_Admin_Menu::add(array('parent_slug' => 'edit.php?post_type=' . 'wr_cf_post_type', 'page_title' => 'WR ContactForm Plugin - About', 'menu_title' => 'About', 'capability' => 'edit_posts', 'menu_slug' => 'wr-contactform-about-us', 'function' => array('WR_Contactform_Helpers_Hook', 'about'))); }