PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / trunk
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar vtrunk
3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 All 156 releases
notificationx / includes / Abilities / Read / ListSources.php

ListSources.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar trunk, at includes/Abilities/Read/ListSources.php

72 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Ability: list the available NotificationX data sources (extensions).
4 *
5 * @package NotificationX\Abilities\Read
6 */
7
8 namespace NotificationX\Abilities\Read;
9
10 use NotificationX\Abilities\AbilityBase;
11 use NotificationX\Extensions\ExtensionFactory;
12 use NotificationX\Core\Modules;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * Returns the data sources/integrations and whether their module is active.
20 */
21 class ListSources extends AbilityBase {
22
23 protected $id = 'notificationx/list-sources';
24 protected $label = 'List data sources';
25 protected $description = 'List the data sources/integrations (e.g. WooCommerce, Comments, Contact Form) that can power a notification, which notification type each belongs to, whether it is Pro-only, and whether its module is currently enabled.';
26
27 public function input_schema() {
28 return array(
29 'type' => 'object',
30 'properties' => (object) array(),
31 );
32 }
33
34 public function output_schema() {
35 return array(
36 'type' => 'object',
37 'properties' => array(
38 'count' => array( 'type' => 'integer' ),
39 'sources' => array( 'type' => 'array' ),
40 ),
41 );
42 }
43
44 public function execute( $input ) {
45 $extensions = ExtensionFactory::get_instance()->get_all();
46 $modules = Modules::get_instance();
47 $result = array();
48
49 if ( is_array( $extensions ) ) {
50 foreach ( $extensions as $key => $ext ) {
51 if ( ! is_object( $ext ) ) {
52 continue;
53 }
54 $module = isset( $ext->module ) ? $ext->module : '';
55 $result[] = array(
56 'id' => isset( $ext->id ) ? $ext->id : (string) $key,
57 'title' => isset( $ext->title ) ? $ext->title : '',
58 'type' => isset( $ext->types ) ? $ext->types : '',
59 'is_pro' => ! empty( $ext->is_pro ),
60 'module' => $module,
61 'module_enabled' => $module ? (bool) $modules->is_enabled( $module ) : true,
62 );
63 }
64 }
65
66 return array(
67 'count' => count( $result ),
68 'sources' => $result,
69 );
70 }
71 }
72