PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.13
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.13
1.4.17 1.4.16 1.4.15 1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 All 180 releases
disco / vendor / micropackage / requirements / README.md

README.md in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.4.13, at vendor/micropackage/requirements/README.md

134 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 # Requirements
2
3 [](https://bracketspace.com![BracketSpace Micropackage](https://img.shields.io/badge/BracketSpace-Micropackage-brightgreen)](https://bracketspace.com](https://bracketspace.com)
4 [](https://packagist.org/packages/micropackage/requirements![Latest Stable Version](https://poser.pugx.org/micropackage/requirements/v/stable)](https://packagist.org/packages/micropackage/requirements](https://packagist.org/packages/micropackage/requirements)
5 [](https://packagist.org/packages/micropackage/requirements![PHP from Packagist](https://img.shields.io/packagist/php-v/micropackage/requirements.svg)](https://packagist.org/packages/micropackage/requirements](https://packagist.org/packages/micropackage/requirements)
6 [](https://packagist.org/packages/micropackage/requirements![Total Downloads](https://poser.pugx.org/micropackage/requirements/downloads)](https://packagist.org/packages/micropackage/requirements](https://packagist.org/packages/micropackage/requirements)
7 [](https://packagist.org/packages/micropackage/requirements![License](https://poser.pugx.org/micropackage/requirements/license)](https://packagist.org/packages/micropackage/requirements](https://packagist.org/packages/micropackage/requirements)
8
9 <p align="center">
10 <img src="https://bracketspace.com/extras/micropackage/micropackage-small.png" alt="Micropackage logo"/>
11 </p>
12
13 ## 🧬 About Requirements
14
15 This micropackage allows you to test environment requirements to run your plugin.
16
17 It can test:
18
19 - PHP version
20 - PHP Extensions
21 - SSL state
22 - WordPress version
23 - Active plugins
24 - Current theme
25 - [](https://github.com/micropackage/dochooksDocHooks](https://github.com/micropackage/dochooks](https://github.com/micropackage/dochooks) support
26
27 But it's open for any other custom check.
28
29 ## 💾 Installation
30
31 ``` bash
32 composer require micropackage/requirements
33 ```
34
35 ## 🕹 Usage
36
37 ## Basic usage
38
39 In the plugin main file:
40
41 ```php
42 <?php
43 /*
44 Plugin Name: My Test Plugin
45 Version: 1.0.0
46 */
47
48 // Composer autoload.
49 require_once __DIR__ . '/vendor/autoload.php' ;
50
51 $requirements = new \Micropackage\Requirements\Requirements( 'My Test Plugin', array(
52 'php' => '7.0',
53 'php_extensions' => array( 'soap' ),
54 'wp' => '5.3',
55 'dochooks' => true,
56 'ssl' => true,
57 'plugins' => array(
58 array( 'file' => 'akismet/akismet.php', 'name' => 'Akismet', 'version' => '3.0' ),
59 array( 'file' => 'hello-dolly/hello.php', 'name' => 'Hello Dolly', 'version' => '1.5' )
60 ),
61 'theme' => array(
62 'slug' => 'twentysixteen',
63 'name' => 'Twenty Sixteen'
64 ),
65 ) );
66
67 /**
68 * Run all the checks and check if requirements has been satisfied.
69 * If not - display the admin notice and exit from the file.
70 */
71 if ( ! $requirements->satisfied() ) {
72 $requirements->print_notice();
73 return;
74 }
75
76 // ... plugin runtime.
77 ```
78
79 ## Advanced usage
80
81 You can also define your own custom checks.
82
83 ```php
84 class CustomCheck extends \Micropackage\Requirements\Abstracts\Checker {
85
86 /**
87 * Checker name
88 *
89 * @var string
90 */
91 protected $name = 'custom-check';
92
93 /**
94 * Checks if the requirement is met
95 *
96 * @param string $value Requirement.
97 * @return void
98 */
99 public function check( $value ) {
100
101 // Do your check here and if it fails, add the error.
102 if ( 'something' === $value ) {
103 $this->add_error( 'You need something!' );
104 }
105
106 }
107
108 }
109
110 $requirements = new \Micropackage\Requirements\Requirements( 'My Test Plugin', array(
111 'custom-check' => 'something else',
112 ) );
113
114 $requirements->register_checker( 'CustomCheck' );
115
116 $is_good = $requirements->satisfied();
117 ```
118
119 ## 📦 About the Micropackage project
120
121 Micropackages - as the name suggests - are micro packages with a tiny bit of reusable code, helpful particularly in WordPress development.
122
123 The aim is to have multiple packages which can be put together to create something bigger by defining only the structure.
124
125 Micropackages are maintained by [](https://bracketspace.comBracketSpace](https://bracketspace.com](https://bracketspace.com).
126
127 ## 📖 Changelog
128
129 [](./CHANGELOG.mdSee the changelog file](./CHANGELOG.md](./CHANGELOG.md).
130
131 ## 📃 License
132
133 This software is released under MIT license. See the [](./LICENSELICENSE](./LICENSE](./LICENSE) file for more information.
134