Plugin Directory


Ignore:
Timestamp:
05/07/2026 03:44:00 AM (6 months ago)
Author:
mryudha
Message:

Update to version 1.0.4 from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • foureyed-shortcode-control/trunk/includes/Features/ShortcodeManager/Api/ShortcodeManagerApi.php

    r3523935 r3524967  
    3838        }
    3939
     40        /**
     41         * Get shortcode status counts for stats display.
     42         * Single source of truth for all stat cards (Manager, Start Here, etc.).
     43         *
     44         * Four categories:
     45         *  - enabled  → status 'registered'                              (plugin active, shortcode on)
     46         *  - disabled → status 'unregistered' AND is_active true         (user disabled an active shortcode, returns raw text)
     47         *  - hidden   → status 'hidden'                                  (user silenced it, outputs nothing)
     48         *  - orphaned → status 'unregistered' AND is_active false        (plugin deactivated, user hasn't touched it)
     49         *
     50         * @return array{enabled: int, disabled: int, hidden: int, orphaned: int}
     51         */
     52        public static function get_stats(): array
     53        {
     54                $data = self::get_all_data();
     55
     56                // Respect the "hide core shortcodes" setting, same as the Manager page does.
     57                $hide_core = get_option(\FoureyedShortcodeControl\DataRegistry::OPTION_HIDE_CORE, true);
     58                if ($hide_core) {
     59                        $data = array_filter($data, fn($sc) => ($sc['source_type'] ?? '') !== 'core');
     60                }
     61
     62                $enabled  = 0;
     63                $disabled = 0;
     64                $hidden   = 0;
     65                $orphaned = 0;
     66
     67                foreach ($data as $sc) {
     68                        $status    = $sc['status'] ?? '';
     69                        $is_active = $sc['is_active'] ?? false;
     70                        if ($status === 'registered') {
     71                                $enabled++;
     72                        } elseif ($status === 'hidden') {
     73                                $hidden++;
     74                        } elseif ($status === 'unregistered' && $is_active) {
     75                                $disabled++;
     76                        } elseif ($status === 'unregistered' && !$is_active) {
     77                                $orphaned++;
     78                        }
     79                }
     80
     81                return compact('enabled', 'disabled', 'hidden', 'orphaned');
     82        }
     83
    4084}
Note: See TracChangeset for help on using the changeset viewer.