get_data(); /** * Looping over to check how many licenses are invalid and pushing notification and error accordingly */ if ( $licenses && count( $licenses ) > 0 ) { foreach ( $licenses as $key => $license ) { if ( $license['product_status'] == 'invalid' ) { add_action( 'in_plugin_update_message-' . $key, array( __CLASS__, 'need_license_message' ), 10, 2 ); } } } } /** * Message displayed if license not activated.
* * @param array $plugin_data * @param object $r * * @return void */ public static function need_license_message( $plugin_data, $r ) { if ( empty( $r->package ) ) { echo wp_kses_post( '
' . __( 'To enable this update please activate your XL license by visiting the Dashboard Page.', 'xlplugins' ) . '
' ); } } /** * Register dashboard function just initializes the execution by firing some hooks that helps getting and rendering data * * @param type $attrs */ public static function register_dashboard( $attrs ) { self::$is_dashboard_page = true; self::$currentPage = ( isset( $attrs['name'] ) ) ? $attrs['name'] : null; self::$parent = ( isset( $attrs['parent'] ) ) ? $attrs['parent'] : null; //registering necessary hooks //making sure these hooks loads only when register for dashboard happens (specific page) add_action( 'admin_enqueue_scripts', array( __CLASS__, 'xl_dashboard_scripts' ) ); add_action( 'xl_tabs_modal_licenses', array( __CLASS__, 'xl_licenses_data' ), 99 ); add_action( 'xl_tabs_modal_support', array( __CLASS__, 'xl_support_data' ), 99 ); add_action( 'xl_tabs_modal_tools', array( __CLASS__, 'xl_tools_data' ), 99 ); } /** * Setting expected url , some time i need to access url for dashboard even when register function doesn't hit *
To get over with this issue we set expected url before register executes * * @param type $url */ public static function set_expected_url( $urls ) { self::$expectedurl = $urls; } public static function get_expected_slug() { return self::$expectedslug; } public static function set_expected_slug( $slug ) { self::$expectedslug = $slug; } /** * Model function to fire over licensing page.
* Hooked over 'xl_tabs_modal_licenses'.
* @return mixed false on failure and data on success */ public static function xl_licenses_data() { if ( false === XL_API::get_xl_status() ) { return; } $get_list = array(); $License = XL_licenses::get_instance(); return (object) array_merge( (array) $get_list, (array) array( 'additional_tabs' => apply_filters( 'xl_additional_tabs', array( array( 'slug' => 'tools', 'label' => __( 'Tools', 'xlplugins' ), ), ) ), 'licenses' => $License->get_data(), 'current_tab' => self::$selected, ) ); } /** * Model function to fire over licensing page.
* Hooked over 'xl_tabs_modal_licenses'.
* @return mixed false on failure and data on success */ public static function xl_tools_data() { if ( false === XL_API::get_xl_status() ) { return; } $get_list = array(); return (object) array_merge( (array) $get_list, (array) array( 'additional_tabs' => apply_filters( 'xl_additional_tabs', array( array( 'slug' => 'tools', 'label' => __( 'Tools', 'xlplugins' ), ), ) ), 'current_tab' => self::$selected, ) ); } /** * Model function to fire over support page.
* Hooked over 'xl_tabs_modal_support'.
* @return mixed false on failure and data on success */ public static function xl_support_data( $data ) { //getting plugins list and tabs data $get_list = array(); /** creating instance of XL_licenses and getting all installed plugins */ $License = XL_licenses::get_instance(); $get_installed = XL_addons::get_installed_plugins(); //Creating Instance of support class for further operations (like system info) $object_support = XL_Support::get_instance(); return (object) array_merge( (array) $get_list, (array) array( 'additional_tabs' => apply_filters( 'xl_additional_tabs', array( array( 'slug' => 'tools', 'label' => __( 'Tools', 'xlplugins' ), ), ) ), 'installed' => $get_installed, 'system_info' => $object_support->prepare_system_information_report(), 'licenses' => $License->get_data(), 'email' => get_bloginfo( 'admin_email' ), 'current_tab' => self::$selected, ) ); } /** * Get current admin url for dashboard page.
* To be used in view files.
* @return type */ public static function get_current_url() { return admin_url( 'admin.php?page=' . self::$currentPage ); } /** * Get current admin url for dashboard page.
* To be used in view files.
* @return type */ public static function get_current_license_management() { return admin_url( 'admin.php?page=' . self::$currentPage . '&tab=license' ); } /** * Hooked over 'admin_enqueue_scripts' under the register function, cannot run on every admin page * Enqueues `updates` handle script, core script that is responsible for plugin updates */ public static function xl_dashboard_scripts() { ?>