PluginProbe
Ever Compare – Products Compare Plugin for WooCommerce / trunk
Ever Compare – Products Compare Plugin for WooCommerce vtrunk
1.3.7 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 trunk 1.0.0 1.0.1 1.0.2 All 31 releases
ever-compare / includes / classes / Admin / Notices.php

Notices.php in Ever Compare – Products Compare Plugin for WooCommerce trunk, at includes/classes/Admin/Notices.php

76 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace EverCompare\Admin;
3
4 defined( 'ABSPATH' ) || exit;
5 /**
6 * Notices handlers class
7 */
8 class Notices {
9
10 /**
11 * Run the Notices
12 *
13 * @return void
14 */
15 public function notice() {
16 $this->all_notices();
17 }
18
19 /**
20 * Add Notices
21 */
22 public function all_notices() {
23
24 // Notice for WooCommerce
25 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
26 add_action( 'admin_notices', [ $this, 'admin_notice_missing_woocommerce_plugin' ] );
27 return;
28 }
29
30 }
31
32 /**
33 * [is_plugins_active] Check Plugin is Installed or not
34 * @param [string] $pl_file_path plugin file path
35 * @return boolean true|false
36 */
37 public function is_plugins_active( $pl_file_path = NULL ){
38 $installed_plugins_list = get_plugins();
39 return isset( $installed_plugins_list[$pl_file_path] );
40 }
41
42 /**
43 * [admin_notice_missing_woocommerce_plugin] Admin Notice For missing WooCommerce
44 * @return [void]
45 */
46 public function admin_notice_missing_woocommerce_plugin(){
47 $woocommerce = 'woocommerce/woocommerce.php';
48 if( $this->is_plugins_active( $woocommerce ) ) {
49 if( ! current_user_can( 'activate_plugins' ) ) {
50 return;
51 }
52 $activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $woocommerce . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $woocommerce );
53 /*
54 * translators: %1$s: strong tag start
55 * translators: %2$s: strong tag end
56 */
57 $message = sprintf( __( '%1$sEver Compare%2$s requires %1$s"WooCommerce"%2$s plugin to be active. Please activate WooCommerce to continue.', 'ever-compare' ), '<strong>', '</strong>');
58 $button_text = __( 'Activate WooCommerce', 'ever-compare' );
59 } else {
60 if( ! current_user_can( 'activate_plugins' ) ) {
61 return;
62 }
63 $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
64 /*
65 * translators: %1$s: strong tag start
66 * translators: %2$s: strong tag end
67 */
68 $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' ), '<strong>', '</strong>' );
69 $button_text = __( 'Install WooCommerce', 'ever-compare' );
70 }
71 $button = '<p><a href="' . $activation_url . '" class="button-primary">' . $button_text . '</a></p>';
72 printf( '<div class="error"><p>%1$s</p>%2$s</div>', wp_kses_post($message) , wp_kses_post($button) );
73 }
74
75
76 }