Tribe__PUE__Checker::maybe_display_json_error_on_plugins_page( string $page )

Displays a PUE message on the page if it is relevant


Parameters

$page

(string) (Required) The current page.


Top ↑

Source

File: src/Tribe/PUE/Checker.php

		public function maybe_display_json_error_on_plugins_page( $page ) {
			if ( 'plugins.php' !== $page ) {
				return;
			}

			$state = $this->get_state();
			$messages = array();
			$plugin_updates = get_plugin_updates();
			$update_available = isset( $plugin_updates[ $this->plugin_file ] );

			// Check to see if there is an licensing error or update message we should show
			if ( ! empty( $state->update->license_error ) ) {
				$messages[] = $state->update->license_error;
			} elseif ( $update_available && current_user_can( 'update_plugins' ) ) {
				// A plugin update is available
				$update_now = sprintf(
					esc_html__( 'Update now to version %s.', 'tribe-common' ),
					$state->update->version
				);

				$update_now_link = sprintf(
					' <a href="%1$s" class="update-link">%2$s</a>',
					wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->plugin_file, 'upgrade-plugin_' . $this->plugin_file ),
					$update_now
				);

				$update_message = sprintf(
					esc_html__( 'There is a new version of %1$s available. %2$s', 'tribe-common' ),
					$this->plugin_name,
					$update_now_link
				);

				$messages[] = sprintf(
					'<p>%s</p>',
					$update_message
				);
			}

			if ( empty( $messages ) ) {
				return;
			}

			$message_row_html = '';

			foreach ( $messages as $message ) {
				$message_row_html .= sprintf(
					'<div class="update-message notice inline notice-warning notice-alt">%s</div>',
					$message
				);
			}

			$message_row_html = sprintf(
				'<tr class="plugin-update-tr active"><td colspan="3" class="plugin-update">%s</td></tr>',
				$message_row_html
			);

			$this->plugin_notice = array(
				'slug'             => $this->plugin_file,
				'message_row_html' => $message_row_html,
			);

			add_filter( 'tribe_plugin_notices', array( $this, 'add_notice_to_plugin_notices' ) );

		}