coenjacobs / conductor

Enforces your WordPress plugin requirements by checking PHP versions and details of other plugins
5 stars 1 forks source link

DELETE THIS #3

Closed danieliser closed 4 years ago

danieliser commented 4 years ago

Since this package manages both the messaging and checks, it makes since (at least to me) to add a method that can be called to hook in the admin_notices using the existing messaging.

Would pair perfectly with #1 .

Based on the example in the main readme:

$handler = new CoenJacobs\Conductor\Handler();
$handler->setup([
    [
        'type' => 'php',
        'version' => '5.6.0',
        'i18n' => __( 'This plugin requires <b>PHP %s</b> or higher in order to run.' ),
    ],
    [
        'type' => 'plugin',
        'name' => 'WooCommerce',
        'slug' => 'woocommerce/woocommerce.php',
        'version' => '3.1.0',
        'i18n' => [
            'outdated' => __( 'This plugin requires <b>%s %s</b> or higher to be installed and activated, in order to run.' ),
            'not_activated' => __( 'This plugin b>%s %s</b> must activated, in order to run. Click here to <a href="%s">sactivate now</a>.' ),
    ],
]);

if ( $handler->check() === false ) {
    // if you end up here, something failed...
    $handler->render_notices(); // calls add_action( 'admin_notices', [ $handler->messages, 'print' ] ); or similar.
}
danieliser commented 4 years ago

Edit, close this as I found the setup method in Messages in the last section of the docs, sorry, thats what I get for working at 3am.

danieliser commented 4 years ago

That said ->setup() might not be the most intuitive name.