PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
← All changes | src/TestData/ServiceProvider.php +23 -0 2.30.04.16.9 View file →
@@ -24,8 +24,12 @@
24 24 * @inheritDoc
25 25 */
26 26 public function register()
27 27 {
28 + if ( ! $this->isFakerInstalled()) {
29 + return;
30 + }
31 +
28 32 // Instead of passing around an instance, bind a singleton to the container.
29 33 give()->singleton(
30 34 FakerGenerator::class,
31 35 function () {
@@ -38,8 +42,12 @@
38 42 * @inheritDoc
39 43 */
40 44 public function boot()
41 45 {
46 + if ( ! $this->isFakerInstalled()) {
47 + return;
48 + }
49 +
42 50 // Add CLI commands
43 51 if (defined('WP_CLI') && WP_CLI) {
44 52 $this->addCommands();
45 53
@@ -86,6 +94,21 @@
86 94 WP_CLI::add_command('give test-donation-statuses', give()->make(DonationStatusCommand::class));
87 95 WP_CLI::add_command('give test-demonstration-page', give()->make(PageSeedCommand::class));
88 96 WP_CLI::add_command('give test-donation-form', give()->make(FormSeedCommand::class));
89 97 WP_CLI::add_command('give test-logs', give()->make(LogsSeedCommand::class));
98 + }
99 +
100 + /**
101 + * Helper function used to check if Faker library is installed
102 + *
103 + * @see https://getcomposer.org/doc/07-runtime.md#installed-versions
104 + *
105 + * @since 4.11.0 use class_exists instead of InstalledVersions::isInstalled to avoid conflicts with other plugins using composer
106 + * @since 3.17.2
107 + *
108 + * @return bool
109 + */
110 + private function isFakerInstalled(): bool
111 + {
112 + return class_exists(\Faker\Factory::class) && class_exists(\Faker\Generator::class);
90 113 }
91 114 }