PluginProbe
Ever Compare – Products Compare Plugin for WooCommerce / 1.1.8
Ever Compare – Products Compare Plugin for WooCommerce v1.1.8
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 1.1.8, at includes/classes/Admin/Notices.php

66 lines 2.4 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 * Notices handlers class
5 */
6 class Notices {
7
8 /**
9 * Run the Notices
10 *
11 * @return void
12 */
13 public function notice() {
14 $this->all_notices();
15 }
16
17 /**
18 * Add Notices
19 */
20 public function all_notices() {
21
22 // Notice for WooCommerce
23 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
24 add_action( 'admin_notices', [ $this, 'admin_notice_missing_woocommerce_plugin' ] );
25 return;
26 }
27
28 }
29
30 /**
31 * [is_plugins_active] Check Plugin is Installed or not
32 * @param [string] $pl_file_path plugin file path
33 * @return boolean true|false
34 */
35 public function is_plugins_active( $pl_file_path = NULL ){
36 $installed_plugins_list = get_plugins();
37 return isset( $installed_plugins_list[$pl_file_path] );
38 }
39
40 /**
41 * [admin_notice_missing_woocommerce_plugin] Admin Notice For missing WooCommerce
42 * @return [void]
43 */
44 public function admin_notice_missing_woocommerce_plugin(){
45 $woocommerce = 'woocommerce/woocommerce.php';
46 if( $this->is_plugins_active( $woocommerce ) ) {
47 if( ! current_user_can( 'activate_plugins' ) ) {
48 return;
49 }
50 $activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $woocommerce . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $woocommerce );
51 $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>');
52 $button_text = __( 'Activate WooCommerce', 'ever-compare' );
53 } else {
54 if( ! current_user_can( 'activate_plugins' ) ) {
55 return;
56 }
57 $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
58 $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>' );
59 $button_text = __( 'Install WooCommerce', 'ever-compare' );
60 }
61 $button = '<p><a href="' . $activation_url . '" class="button-primary">' . $button_text . '</a></p>';
62 printf( '<div class="error"><p>%1$s</p>%2$s</div>', __( $message ), $button );
63 }
64
65
66 }