| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?> |
| 2 |
<?php |
| 3 |
|
| 4 |
use FluentCart\Framework\Database\Orm\Builder; |
| 5 |
use FluentCart\Framework\Foundation\Application; |
| 6 |
|
| 7 |
use FluentCart\App\Services\Payments\SubscriptionHelper; |
| 8 |
use FluentCart\Framework\Support\Arr; |
| 9 |
|
| 10 |
/** |
| 11 |
* All registered filter's handlers should be in app\Hooks\Handlers, |
| 12 |
* addFilter is similar to add_filter and addCustomFlter is just a |
| 13 |
* wrapper over add_filter which will add a prefix to the hook name |
| 14 |
* using the plugin slug to make it unique in all wordpress plugins, |
| 15 |
* ex: $app->addCustomFilter('foo', ['FooHandler', 'handleFoo']) is |
| 16 |
* equivalent to add_filter('slug-foo', ['FooHandler', 'handleFoo']). |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* |
| 21 |
* @var Application $app |
| 22 |
*/ |
| 23 |
|
| 24 |
|
| 25 |
add_filter('block_categories_all', function ($categories) { |
| 26 |
$categories[] = array( |
| 27 |
'slug' => 'fluent-cart', |
| 28 |
'title' => __('FluentCart', 'fluent-cart'), |
| 29 |
); |
| 30 |
|
| 31 |
$categories[] = array( |
| 32 |
'slug' => 'fluent-cart-buttons', |
| 33 |
'title' => __('FluentCart Buttons', 'fluent-cart'), |
| 34 |
); |
| 35 |
|
| 36 |
return $categories; |
| 37 |
}); |
| 38 |
|
| 39 |
add_filter('fluent_cart/dummy_product_info', function ($info) { |
| 40 |
$infos = [ |
| 41 |
'mens-shoes' => [ |
| 42 |
'title' => __("Men’s Shoes", 'fluent-cart'), |
| 43 |
'count' => "0", |
| 44 |
'category' => 'mens-shoes', |
| 45 |
'icon' => 'RunningShoe' |
| 46 |
], |
| 47 |
|
| 48 |
'menswear' => [ |
| 49 |
'title' => __("Menswear", 'fluent-cart'), |
| 50 |
'count' => "0", |
| 51 |
'category' => 'menswear', |
| 52 |
'icon' => 'Cloth' |
| 53 |
], |
| 54 |
// 'clothing' => [ |
| 55 |
// 'title' => __("Clothing's", 'fluent-cart'), |
| 56 |
// 'count' => "0", |
| 57 |
// 'category' => 'clothing' |
| 58 |
// ], |
| 59 |
// 'food' => [ |
| 60 |
// 'title' => __("Food", 'fluent-cart'), |
| 61 |
// 'count' => "0", |
| 62 |
// 'category' => 'food' |
| 63 |
// ], |
| 64 |
// 'electronics' => [ |
| 65 |
// 'title' => __('Electronics', 'fluent-cart'), |
| 66 |
// 'count' => "0", |
| 67 |
// 'category' => 'electronics' |
| 68 |
// ] |
| 69 |
]; |
| 70 |
|
| 71 |
foreach ($infos as $key => $info) { |
| 72 |
$filePath = FLUENTCART_PLUGIN_PATH . 'dummies' . DIRECTORY_SEPARATOR . $key . '.json'; |
| 73 |
if (file_exists($filePath)) { |
| 74 |
try { |
| 75 |
$json = file_get_contents($filePath); |
| 76 |
$products = json_decode($json, true); |
| 77 |
$infos[$key]['count'] = count($products); |
| 78 |
} catch (\Exception $exception) { |
| 79 |
|
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
return $infos; |
| 86 |
}); |