ActionScheduler_ListTable::display_admin_notices()publicWC 1.0

Renders admin notifications

Notifications:

  1. When the maximum number of tasks are being executed simultaneously.
  2. Notifications when a task is manually executed.
  3. Tables are missing.

Метод класса: ActionScheduler_ListTable{}

Возвращает

null. Ничего (null).

Использование

$ActionScheduler_ListTable = new ActionScheduler_ListTable();
$ActionScheduler_ListTable->display_admin_notices();

Код ActionScheduler_ListTable::display_admin_notices() WC 9.3.3

public function display_admin_notices() {
	global $wpdb;

	if ( ( is_a( $this->store, 'ActionScheduler_HybridStore' ) || is_a( $this->store, 'ActionScheduler_DBStore' ) ) && apply_filters( 'action_scheduler_enable_recreate_data_store', true ) ) {
		$table_list = array(
			'actionscheduler_actions',
			'actionscheduler_logs',
			'actionscheduler_groups',
			'actionscheduler_claims',
		);

		$found_tables = $wpdb->get_col( "SHOW TABLES LIKE '{$wpdb->prefix}actionscheduler%'" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		foreach ( $table_list as $table_name ) {
			if ( ! in_array( $wpdb->prefix . $table_name, $found_tables ) ) {
				$this->admin_notices[] = array(
					'class'   => 'error',
					'message' => __( 'It appears one or more database tables were missing. Attempting to re-create the missing table(s).' , 'woocommerce' ),
				);
				$this->recreate_tables();
				parent::display_admin_notices();

				return;
			}
		}
	}

	if ( $this->runner->has_maximum_concurrent_batches() ) {
		$claim_count           = $this->store->get_claim_count();
		$this->admin_notices[] = array(
			'class'   => 'updated',
			'message' => sprintf(
				/* translators: %s: amount of claims */
				_n(
					'Maximum simultaneous queues already in progress (%s queue). No additional queues will begin processing until the current queues are complete.',
					'Maximum simultaneous queues already in progress (%s queues). No additional queues will begin processing until the current queues are complete.',
					$claim_count,
					'woocommerce'
				),
				$claim_count
			),
		);
	} elseif ( $this->store->has_pending_actions_due() ) {

		$async_request_lock_expiration = ActionScheduler::lock()->get_expiration( 'async-request-runner' );

		// No lock set or lock expired
		if ( false === $async_request_lock_expiration || $async_request_lock_expiration < time() ) {
			$in_progress_url       = add_query_arg( 'status', 'in-progress', remove_query_arg( 'status' ) );
			/* translators: %s: process URL */
			$async_request_message = sprintf( __( 'A new queue has begun processing. <a href="%s">View actions in-progress &raquo;</a>', 'woocommerce' ), esc_url( $in_progress_url ) );
		} else {
			/* translators: %d: seconds */
			$async_request_message = sprintf( __( 'The next queue will begin processing in approximately %d seconds.', 'woocommerce' ), $async_request_lock_expiration - time() );
		}

		$this->admin_notices[] = array(
			'class'   => 'notice notice-info',
			'message' => $async_request_message,
		);
	}

	$notification = get_transient( 'action_scheduler_admin_notice' );

	if ( is_array( $notification ) ) {
		delete_transient( 'action_scheduler_admin_notice' );

		$action = $this->store->fetch_action( $notification['action_id'] );
		$action_hook_html = '<strong><code>' . $action->get_hook() . '</code></strong>';
		if ( 1 == $notification['success'] ) {
			$class = 'updated';
			switch ( $notification['row_action_type'] ) {
				case 'run' :
					/* translators: %s: action HTML */
					$action_message_html = sprintf( __( 'Successfully executed action: %s', 'woocommerce' ), $action_hook_html );
					break;
				case 'cancel' :
					/* translators: %s: action HTML */
					$action_message_html = sprintf( __( 'Successfully canceled action: %s', 'woocommerce' ), $action_hook_html );
					break;
				default :
					/* translators: %s: action HTML */
					$action_message_html = sprintf( __( 'Successfully processed change for action: %s', 'woocommerce' ), $action_hook_html );
					break;
			}
		} else {
			$class = 'error';
			/* translators: 1: action HTML 2: action ID 3: error message */
			$action_message_html = sprintf( __( 'Could not process change for action: "%1$s" (ID: %2$d). Error: %3$s', 'woocommerce' ), $action_hook_html, esc_html( $notification['action_id'] ), esc_html( $notification['error_message'] ) );
		}

		$action_message_html = apply_filters( 'action_scheduler_admin_notice_html', $action_message_html, $action, $notification );

		$this->admin_notices[] = array(
			'class'   => $class,
			'message' => $action_message_html,
		);
	}

	parent::display_admin_notices();
}