all_notices(); } /** * Add Notices */ public function all_notices() { // Notice for WooCommerce if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { add_action( 'admin_notices', [ $this, 'admin_notice_missing_woocommerce_plugin' ] ); return; } } /** * [is_plugins_active] Check Plugin is Installed or not * @param [string] $pl_file_path plugin file path * @return boolean true|false */ public function is_plugins_active( $pl_file_path = NULL ){ $installed_plugins_list = get_plugins(); return isset( $installed_plugins_list[$pl_file_path] ); } /** * [admin_notice_missing_woocommerce_plugin] Admin Notice For missing WooCommerce * @return [void] */ public function admin_notice_missing_woocommerce_plugin(){ $woocommerce = 'woocommerce/woocommerce.php'; if( $this->is_plugins_active( $woocommerce ) ) { if( ! current_user_can( 'activate_plugins' ) ) { return; } $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $woocommerce . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $woocommerce ); /* * translators: %1$s: strong tag start * translators: %2$s: strong tag end */ $message = sprintf( __( '%1$sEver Compare%2$s requires %1$s"WooCommerce"%2$s plugin to be active. Please activate WooCommerce to continue.', 'ever-compare' ), '', ''); $button_text = __( 'Activate WooCommerce', 'ever-compare' ); } else { if( ! current_user_can( 'activate_plugins' ) ) { return; } $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ); /* * translators: %1$s: strong tag start * translators: %2$s: strong tag end */ $message = sprintf( __( '%1$sEver Compare%2$s requires %1$s"WooCommerce"%2$s plugin to be installed and activated. Please install WooCommerce to continue.', 'ever-compare' ), '', '' ); $button_text = __( 'Install WooCommerce', 'ever-compare' ); } $button = '
'; printf( '%1$s
%2$s