wpdesk/wp-show-decision

There is no license information available for the latest version (1.1.0) of this package.

Maintainers

Package info

github.com/WP-Desk/wp-show-decision

pkg:composer/wpdesk/wp-show-decision

Statistics

Installs: 8 370

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.1.0 2024-05-21 11:26 UTC

This package is auto-updated.

Last update: 2026-06-24 11:29:19 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

wp-show-decision

Small library for deciding whether something should be displayed in WordPress.

Each strategy implements WPDesk\ShowDecision\ShouldShowStrategy and exposes one method:

public function shouldDisplay(): bool;

Requirements

  • PHP 7.4+

Installation

composer require wpdesk/wp-show-decision

Usage

use WPDesk\ShowDecision\GetStrategy;

$strategy = new GetStrategy(
	[
		[ 'page' => 'wc-settings', 'tab' => 'shipping' ],
		[ 'page' => 'my-plugin' ],
	]
);

if ( $strategy->shouldDisplay() ) {
	// Show something.
}

Available Strategies

  • GetStrategy - matches $_GET parameters. Inner array means AND, outer array means OR.
  • PostTypeStrategy - matches a WordPress post type.
  • ConstantDefinedStrategy - true when a constant is defined.
  • ConstantNotDefinedStrategy - true when a constant is not defined.
  • AndStrategy - combines strategies with AND.
  • OrStrategy - combines strategies with OR.
  • WooCommerce\ShippingMethodStrategy - matches WooCommerce shipping method settings page.
  • WooCommerce\ShippingMethodInstanceStrategy - matches WooCommerce shipping method instance settings page.

Documentation

PHPDoc: https://wpdesk.gitlab.io/wp-show-decision/index.html