/** * Initialize WR PageBuilder plugin. * * @return void */ public static function init() { global $pagenow; // Get product information $plugin = WR_Pb_Product_Info::get(WR_PB_FILE); // Remove line below to enable Addons mechanism feature. $plugin['Addons'] = null; // Generate menu title $menu_title = __('WR PageBuilder', WR_PBL); // Define admin menus $admin_menus = array('page_title' => __('WR PageBuilder', WR_PBL), 'menu_title' => $menu_title, 'capability' => 'manage_options', 'menu_slug' => 'wr-pb-about-us', 'icon_url' => WR_Pb_Helper_Functions::path('assets/woorockets') . '/images/wr-pgbldr-icon-white.png', 'function' => array(__CLASS__, 'about_us'), 'children' => array(array('page_title' => __('WR PageBuilder - Settings', WR_PBL), 'menu_title' => __('Settings', WR_PBL), 'capability' => 'manage_options', 'menu_slug' => 'wr-pb-settings', 'function' => array(__CLASS__, 'settings')), array('page_title' => __('WR PageBuilder - About', WR_PBL), 'menu_title' => __('About', WR_PBL), 'capability' => 'manage_options', 'menu_slug' => 'wr-pb-about-us', 'function' => array(__CLASS__, 'about_us')))); if ($plugin['Addons']) { // Generate menu title $menu_title = __('Add-ons', WR_PBL); if ($plugin['Available_Update'] && ('admin.php' == $pagenow && isset($_REQUEST['page']) && in_array($_REQUEST['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 $admin_menus['children'][] = array('page_title' => __('WR PageBuilder - Add-ons', WR_PBL), 'menu_title' => $menu_title, 'capability' => 'manage_options', 'menu_slug' => 'wr-pb-addons', 'function' => array(__CLASS__, 'addons')); } // Initialize necessary WR Library classes WR_Pb_Init_Admin_Menu::hook(); WR_Pb_Product_Addons::hook(); // Register admin menus WR_Pb_Init_Admin_Menu::add($admin_menus); // Remove redundant menu WR_Pb_Init_Assets::inline('js', '$(\'#toplevel_page_wr-pb-about-us .wp-first-item\').hide();'); // Register 'wr_pb_installed_product' filter add_filter('wr_pb_installed_product', array(__CLASS__, 'register_product')); // Load required assets if ('admin.php' == $pagenow && isset($_REQUEST['page']) && in_array($_REQUEST['page'], array('wr-pb-settings', 'wr-pb-addons'))) { // Load common assets WR_Pb_Init_Assets::load(array('wr-bootstrap-css', 'wr-jsn-css')); switch ($_REQUEST['page']) { case 'wr-pb-addons': // Load addons style and script WR_Pb_Init_Assets::load(array('wr-pb-addons-css', 'wr-pb-addons-js')); break; } } // Register Ajax actions if ('admin-ajax.php' == $pagenow) { add_action('wp_ajax_wr-pb-convert-data', array(__CLASS__, 'convert_data')); } }
/** * Initialize WR Library. * * @return void */ public static function init() { global $pagenow; // Register Ajax actions if ('admin-ajax.php' == $pagenow && isset($_GET['action']) && in_array($_GET['action'], self::$actions)) { // Init WordPress Filesystem Abstraction WR_Pb_Init_File_System::get_instance(); // Register Ajax actions switch ($_GET['action']) { case 'wr-addons-management': WR_Pb_Product_Addons::hook(); break; } } // Add filter to fine-tune uploaded file name add_filter('wp_handle_upload_prefilter', array(__CLASS__, 'wp_handle_upload_prefilter')); // Do 'wr_init' action do_action('wr_pb_init'); // Register 'wr_sample_settings_url' filter add_filter('wr_pagebuilder_settings_url', array(__CLASS__, 'settings_url')); }