PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.3.1
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.3.1
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 / GetStatus.php

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

75 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Ability: report NotificationX status — versions, edition, key toggles and
4 * notification counts — so a client can orient itself in one call.
5 *
6 * @package NotificationX\Abilities\Read
7 */
8
9 namespace NotificationX\Abilities\Read;
10
11 use NotificationX\Abilities\AbilityBase;
12 use NotificationX\NotificationX;
13 use NotificationX\Admin\Settings;
14 use NotificationX\Core\PostType;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * A one-call overview: Free/Pro versions, whether Pro is active, whether the MCP
22 * connector / REST API / analytics are on, and how many notifications exist vs
23 * how many are active. Call this first to tell a Free site from a Pro one and to
24 * know which features are available before acting.
25 */
26 class GetStatus extends AbilityBase {
27
28 protected $id = 'notificationx/get-status';
29 protected $label = 'Get status';
30 protected $description = 'Get a one-call overview of this NotificationX install: Free and Pro versions, whether Pro is active, whether the MCP connector, REST API and analytics are enabled, and the total vs active notification counts. Use it to tell a Free site from a Pro one and to know what is available before creating or editing.';
31
32 public function input_schema() {
33 return array(
34 'type' => 'object',
35 'properties' => (object) array(),
36 );
37 }
38
39 public function output_schema() {
40 return array(
41 'type' => 'object',
42 'properties' => array(
43 'version' => array( 'type' => 'string' ),
44 'pro_version' => array( 'type' => 'string' ),
45 'is_pro' => array( 'type' => 'boolean' ),
46 'mcp_enabled' => array( 'type' => 'boolean' ),
47 'rest_api_enabled' => array( 'type' => 'boolean' ),
48 'analytics_enabled' => array( 'type' => 'boolean' ),
49 'notifications' => array( 'type' => 'object' ),
50 ),
51 );
52 }
53
54 public function execute( $input ) {
55 $settings = Settings::get_instance();
56 $post_type = PostType::get_instance();
57
58 $all = $post_type->get_posts( array(), 'nx_id' );
59 $active = $post_type->get_posts( array( 'enabled' => true ), 'nx_id' );
60
61 return array(
62 'version' => defined( 'NOTIFICATIONX_VERSION' ) ? NOTIFICATIONX_VERSION : '',
63 'pro_version' => defined( 'NOTIFICATIONX_PRO_VERSION' ) ? NOTIFICATIONX_PRO_VERSION : '',
64 'is_pro' => (bool) NotificationX::is_pro(),
65 'mcp_enabled' => (bool) $settings->get( 'settings.enable_mcp' ),
66 'rest_api_enabled' => (bool) $settings->get( 'settings.enable_rest_api', false ),
67 'analytics_enabled' => (bool) $settings->get( 'settings.enable_analytics', true ),
68 'notifications' => array(
69 'total' => is_array( $all ) ? count( $all ) : 0,
70 'active' => is_array( $active ) ? count( $active ) : 0,
71 ),
72 );
73 }
74 }
75