wpdesk / wp-show-decision
There is no license information available for the latest version (1.1.0) of this package.
1.1.0
2024-05-21 11:26 UTC
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
Requires (Dev)
- 10up/wp_mock: *
- mockery/mockery: *
- phpunit/phpunit: ^6||^7||^8||^9
- squizlabs/php_codesniffer: ^3.0.2
- wp-coding-standards/wpcs: ^0.14.1
This package is auto-updated.
Last update: 2026-06-24 11:29:19 UTC
README
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$_GETparameters. Inner array meansAND, outer array meansOR.PostTypeStrategy- matches a WordPress post type.ConstantDefinedStrategy- true when a constant is defined.ConstantNotDefinedStrategy- true when a constant is not defined.AndStrategy- combines strategies withAND.OrStrategy- combines strategies withOR.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