bsf_extension_nag( string $product_id = '', bool $mu_updater = false )

Generate’s markup to generate notice to ask users to install required extensions.


Description


Parameters

$product_id

(string) (Optional) (string) Product ID of the brainstorm product.

Default value: ''

$mu_updater

(bool) (Optional) (bool) If True - give nag to separately install brainstorm updater multisite plugin.

Default value: false


Source

File: admin/bsf-core/includes/helpers.php

	function bsf_extension_nag( $product_id = '', $mu_updater = false ) {

		$display_nag = get_user_meta( get_current_user_id(), $product_id . '-bsf_nag_dismiss', true );

		if ( true === $mu_updater ) {
			bsf_nag_brainstorm_updater_multisite();
		}

		if ( '1' === $display_nag ||
			! user_can( get_current_user_id(), 'activate_plugins' ) ||
			! user_can( get_current_user_id(), 'install_plugins' ) ) {
			return;
		}

		$bsf_installed_plugins     = '';
		$bsf_not_installed_plugins = '';
		$bsf_not_activated_plugins = '';
		$installer                 = '';
		$bsf_install               = false;
		$bsf_activate              = false;
		$bsf_bundled_products      = bsf_bundled_plugins( $product_id );
		$bsf_product_name          = brainstrom_product_name( $product_id );

		foreach ( $bsf_bundled_products as $key => $plugin ) {

			if ( ! isset( $plugin->id ) || '' === $plugin->id || ! isset( $plugin->must_have_extension ) || 'false' === $plugin->must_have_extension ) {
				continue;
			}

			$plugin_abs_path = WP_PLUGIN_DIR . '/' . $plugin->init;
			if ( is_file( $plugin_abs_path ) ) {

				if ( ! is_plugin_active( $plugin->init ) ) {
					$bsf_not_activated_plugins .= $bsf_bundled_products[ $key ]->name . ', ';
				}
			} else {
				$bsf_not_installed_plugins .= $bsf_bundled_products[ $key ]->name . ', ';
			}
		}

		$bsf_not_activated_plugins = rtrim( $bsf_not_activated_plugins, ', ' );
		$bsf_not_installed_plugins = rtrim( $bsf_not_installed_plugins, ', ' );

		if ( '' !== $bsf_not_activated_plugins || '' !== $bsf_not_installed_plugins ) {
			echo '<div class="updated notice is-dismissible"><p></p>';
			if ( '' !== $bsf_not_activated_plugins ) {
				echo '<p>';
				echo esc_html( $bsf_product_name ) . esc_html__( ' requires following plugins to be active : ', 'bsf' );
				echo '<strong><em>';
				echo esc_html( $bsf_not_activated_plugins );
				echo '</strong></em>';
				echo '</p>';
				$bsf_activate = true;
			}

			if ( '' !== $bsf_not_installed_plugins ) {
				echo '<p>';
				echo esc_html( $bsf_product_name ) . esc_html__( ' requires following plugins to be installed and activated : ', 'bsf' );
				echo '<strong><em>';
				echo esc_html( $bsf_not_installed_plugins );
				echo '</strong></em>';
				echo '</p>';
				$bsf_install = true;
			}

			if ( true === $bsf_activate ) {
				$installer .= '<a href="' . get_admin_url() . 'plugins.php?plugin_status=inactive">' . __( 'Begin activating plugins', 'bsf' ) . '</a> | ';
			}

			if ( true === $bsf_install ) {
				$installer .= '<a href="' . bsf_exension_installer_url( $product_id ) . '">' . __( 'Begin installing plugins', 'bsf' ) . '</a> | ';
			}

			$installer .= '<a href="' . esc_url( add_query_arg( 'bsf-dismiss-notice', $product_id ) ) . '">' . __( 'Dismiss This Notice', 'bsf' ) . '</a>';

			$installer = ltrim( $installer, '| ' );

			wp_nonce_field( 'bsf-extension-nag', 'bsf-extension-nag-nonce', true, 1 );
			echo '<p><strong>';
			echo esc_html( rtrim( $installer, ' |' ) );
			echo '</p></strong>';

			echo '<p></p></div>';
		}
	}

Changelog

Changelog
Version Description
Graupi 1.9 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.