plugin_path = end( $plugin_path ); // Set plugin file $this->plugin_file = $plugin_file; // Set plugin name if ( isset( $plugins[$this->plugin_path . '/' . $this->plugin_file]['Name'] ) ) { $this->plugin_name = $plugins[$this->plugin_path . '/' . $this->plugin_file]['Name']; } else { $this->plugin_name = __( 'This plugin', 'affiliate-afnf' ); } // Is AffiliateWP installed? foreach ( $plugins as $plugin_path => $plugin ) { if ( $plugin['Name'] == 'AffiliateWP' ) { $this->has_affiliatewp = true; break; } } } /** * Show notice * * @access public * @since 1.0 * @return void */ public function run() { // Display notice add_action( 'admin_notices', array( $this, 'missing_affiliatewp_notice' ) ); } /** * Display notice if AffiliateWP isn't installed * * @access public * @since 1.0 * @return string The notice to display */ public function missing_affiliatewp_notice() { if ( $this->has_affiliatewp ) { echo '

' . sprintf( __( '%s requires %s. Please activate it to continue.', 'affiliatewp-allowed-products' ), $this->plugin_name, 'AffiliateWP' ) . '

'; } else { echo '

' . sprintf( __( '%s requires %s. Please install it to continue.', 'affiliatewp-allowed-products' ), $this->plugin_name, 'AffiliateWP' ) . '

'; } } }