Plugin Directory

Changeset 3369912


Ignore:
Timestamp:
09/29/2025 05:14:57 PM (5 months ago)
Author:
logtivity
Message:

Provide additional deatils for user/term update log entries

Location:
logtivity
Files:
110 added
10 deleted
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • logtivity/tags/3.3.0/logtivity.php

    r3354825 r3369912  
    66 * Description:       Record activity logs and errors logs across all your WordPress sites.
    77 * Author:            Logtivity
    8  * Version:           3.2.1
     8 * Version:           3.3.0
    99 * Text Domain:       logtivity
    1010 * Requires at least: 4.7
     
    4545     * @var string
    4646     */
    47     protected string $version = '3.2.1';
    48 
    49     /**
    50      * List all classes here with their file paths. Keep class names the same as filenames.
    51      * Ordering of this list matters!
    52      * @TODO: Implement psr-0 autoloading
    53      *
    54      * @var string[]
    55      */
    56     private array $dependencies = [
    57         'Helpers/Compatibility',
    58         'Helpers/Helpers',
    59         'Helpers/Logtivity_Wp_User',
    60         'Admin/Logtivity_Log_Index_Controller',
    61         'Admin/Logtivity_Dismiss_Notice_Controller',
    62         'Admin/Logtivity_Options',
    63         'Admin/Logtivity_Response',
    64         'Admin/Logtivity_Admin',
    65         'Services/Logtivity_User_Logger_Trait',
    66         'Services/Logtivity_Api',
    67         'Services/Logtivity_Logger',
    68         'Services/Logtivity_Register_Site',
    69         'Helpers/Logtivity_Log_Global_Function',
    70         'Logs/Logtivity_Abstract_Logger',
    71         'Services/Logtivity_Check_For_Disabled_Individual_Logs',
    72         'Services/Logtivity_Check_For_New_Settings',
    73         'Services/Logtivity_Rest_Endpoints',
    74         /**
    75          * Error logging
    76          */
    77         'Errors/Logtivity_Stack_Trace_Snippet',
    78         'Errors/Logtivity_Stack_Trace',
    79         'Errors/Logtivity_Error_Logger',
    80         'Errors/Logtivity_Error_Log',
     47    protected string $version = '3.3.0';
     48
     49    /**
     50     * Integrations with other plugins
     51     *
     52     * @var array[]
     53     */
     54    private array $integrations = [
     55        WP_DLM::class                 => 'Download_Monitor',
     56        MeprCtrlFactory::class        => 'Memberpress',
     57        Easy_Digital_Downloads::class => 'Easy_Digital_Downloads',
     58        EDD_Software_Licensing::class => 'Easy_Digital_Downloads/Licensing',
     59        EDD_Recurring::class          => 'Easy_Digital_Downloads/Recurring',
     60        FrmHooksController::class     => 'Formidable',
     61        PMXI_Plugin::class            => 'WP_All_Import',
     62        \Code_Snippets\Plugin::class  => 'Code_Snippets',
    8163    ];
    82     /**
    83      * @var string[]
    84      */
    85     private array $logClasses = [
    86         /**
    87          * Activity logging
    88          */
    89         'Logs/Core/Logtivity_Post',
    90         'Logs/Core/Logtivity_User',
    91         'Logs/Core/Logtivity_Core',
    92         'Logs/Core/Logtivity_Theme',
    93         'Logs/Core/Logtivity_Plugin',
    94         'Logs/Core/Logtivity_Comment',
    95         'Logs/Core/Logtivity_Term',
    96         'Logs/Core/Logtivity_Meta',
    97     ];
    98     /**
    99      * List all integration dependencies
    100      *
    101      * @var array[]
    102      */
    103     private array $integrationDependencies = [
    104         'WP_DLM'                 => [
    105             'Logs/Download_Monitor/Logtivity_Download_Monitor',
    106         ],
    107         'MeprCtrlFactory'        => [
    108             'Logs/Memberpress/Logtivity_Memberpress',
    109         ],
    110         'Easy_Digital_Downloads' => [
    111             'Logs/Easy_Digital_Downloads/Logtivity_Abstract_Easy_Digital_Downloads',
    112             'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads',
    113         ],
    114         'EDD_Software_Licensing' => [
    115             'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads_Software_Licensing',
    116         ],
    117         'EDD_Recurring'          => [
    118             'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads_Recurring',
    119         ],
    120         'FrmHooksController'     => [
    121             'Logs/Formidable/Logtivity_FrmEntryFormatter',
    122             'Logs/Formidable/Logtivity_Formidable',
    123         ],
    124         'PMXI_Plugin'            => [
    125             'Logs/WP_All_Import/Logtivity_WP_All_Import',
    126         ],
    127         '\Code_Snippets\Plugin'  => [
    128             'Logs/Code_Snippets/Logtivity_Code_Snippets',
    129         ],
    130     ];
    13164
    13265    public function __construct()
    13366    {
    134         $this->loadDependencies();
     67        $this->loadCore();
     68        $this->activateLoggers();
    13569
    13670        add_action('upgrader_process_complete', [$this, 'upgradeProcessComplete'], 10, 2);
     
    14781
    14882    /**
    149      * @return void
    150      */
    151     public function loadDependencies(): void
    152     {
    153         foreach ($this->dependencies as $filePath) {
    154             $this->loadFile($filePath);
    155         }
    156 
     83     * @return self
     84     */
     85    public static function init(): self
     86    {
     87        return new static();
     88    }
     89
     90    /**
     91     * @return void
     92     */
     93    protected function loadCore(): void
     94    {
     95        $requires = array_merge(
     96            $this->getFiles(__DIR__ . '/functions'),
     97            $this->getFiles(__DIR__ . '/Base')
     98        );
     99        foreach ($requires as $file) {
     100            require_once $file;
     101        }
     102
     103        $coreFiles   = $this->getFiles(__DIR__ . '/Core');
     104        $initClasses = [];
     105        foreach ($coreFiles as $file) {
     106            require_once $file;
     107            $className = basename($file, '.php');
     108            if (is_callable([$className, 'init'])) {
     109                $initClasses[] = $className;
     110            }
     111        }
     112        foreach ($initClasses as $class) {
     113            call_user_func([$class, 'init']);
     114        }
     115    }
     116
     117    protected function activateLoggers(): void
     118    {
    157119        add_action('plugins_loaded', function () {
    158120            $this->updateCheck();
    159121
    160             if ($this->defaultLoggingDisabled()) {
    161                 return;
    162             }
    163 
    164             $this->maybeLoadLogClasses();
    165 
    166             $this->loadIntegrationDependencies();
     122            if ($this->defaultLoggingDisabled() == false) {
     123                $this->loadCoreLoggers();
     124                $this->loadIntegrations();
     125            }
    167126        });
    168     }
    169 
    170     /**
    171      * @param string $filePath
    172      *
    173      * @return void
    174      */
    175     public function loadFile(string $filePath): void
    176     {
    177         require_once plugin_dir_path(__FILE__) . $filePath . '.php';
     127
     128    }
     129
     130    /**
     131     * @param string $path
     132     * @param bool   $recurse
     133     * @param string $extension
     134     *
     135     * @return array
     136     */
     137    protected function getFiles(string $path, bool $recurse = true, string $extension = 'php'): array
     138    {
     139        if (is_dir($path)) {
     140            $files = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
     141        } elseif (is_file($path)) {
     142            return [realpath($path)];
     143        } else {
     144            return [];
     145        }
     146
     147        $list = [];
     148        foreach ($files as $file) {
     149            if ($file->isFile()) {
     150                if ($file->getExtension() == $extension) {
     151                    $list[] = $file->getRealPath();
     152                }
     153
     154            } elseif ($recurse) {
     155                $list = array_merge($list, $this->getFiles($file->getRealPath(), $recurse, $extension));
     156            }
     157        }
     158
     159        return $list;
    178160    }
    179161
     
    188170
    189171        if (version_compare($currentVersion, '3.1.6', '<=')) {
    190             static::checkCapabilities();
     172            $this->checkCapabilities();
    191173        }
    192174
     
    204186     * @return void
    205187     */
    206     public static function checkCapabilities(): void
     188    protected function checkCapabilities(): void
    207189    {
    208190        $capabilities = array_filter(
     
    231213     * @return bool
    232214     */
    233     public function defaultLoggingDisabled(): bool
     215    protected function defaultLoggingDisabled(): bool
    234216    {
    235217        return (bool)(new Logtivity_Options())->getOption('logtivity_disable_default_logging');
     
    239221     * @return void
    240222     */
    241     public function maybeLoadLogClasses(): void
    242     {
    243         foreach ($this->logClasses as $filePath) {
    244             $this->loadFile($filePath);
    245         }
    246     }
    247 
    248     /**
    249      * @return void
    250      */
    251     public function loadIntegrationDependencies(): void
    252     {
    253         foreach ($this->integrationDependencies as $key => $value) {
     223    protected function loadCoreLoggers(): void
     224    {
     225        $coreLoggers = $this->getFiles(__DIR__ . '/Loggers/Core');
     226        foreach ($coreLoggers as $logger) {
     227            require_once $logger;
     228        }
     229    }
     230
     231    /**
     232     * @return void
     233     */
     234    protected function loadIntegrations(): void
     235    {
     236        $loggerFolder = __DIR__ . '/Loggers/';
     237
     238        foreach ($this->integrations as $key => $folder) {
     239            $integrationFolder = $loggerFolder . $folder;
    254240            if (class_exists($key)) {
    255                 foreach ($value as $filePath) {
    256                     $this->loadFile($filePath);
     241                if (is_dir($integrationFolder . '/Base')) {
     242                    // Load any base classes
     243                    $baseFiles = $this->getFiles($integrationFolder . '/Base');
     244                    foreach ($baseFiles as $file) {
     245                        require_once $file;
     246                    }
     247                }
     248
     249                $files = $this->getFiles($integrationFolder, false);
     250                foreach ($files as $file) {
     251                    require_once $file;
    257252                }
    258253            }
     
    420415        add_option('logtivity_activate', true);
    421416
    422         static::checkCapabilities();
     417        $this->checkCapabilities();
    423418
    424419        if (apply_filters('logtivity_hide_settings_page', false)) {
     
    501496}
    502497
    503 new Logtivity();
     498Logtivity::init();
  • logtivity/tags/3.3.0/readme.txt

    r3354825 r3369912  
    55Requires at least: 6.6
    66Tested up to: 6.8
    7 Stable tag: 3.2.1
     7Stable tag: 3.3.0
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    262262
    263263== Changelog ==
     264
     265= 3.3.0 - 25 Sep 2025 =
     266  * Provide more detailed information for term updates
     267  * Provide more detailed information for user updates
    264268
    265269= 3.2.1 - 02 Sep 2025 =
  • logtivity/trunk/logtivity.php

    r3354825 r3369912  
    66 * Description:       Record activity logs and errors logs across all your WordPress sites.
    77 * Author:            Logtivity
    8  * Version:           3.2.1
     8 * Version:           3.3.0
    99 * Text Domain:       logtivity
    1010 * Requires at least: 4.7
     
    4545     * @var string
    4646     */
    47     protected string $version = '3.2.1';
    48 
    49     /**
    50      * List all classes here with their file paths. Keep class names the same as filenames.
    51      * Ordering of this list matters!
    52      * @TODO: Implement psr-0 autoloading
    53      *
    54      * @var string[]
    55      */
    56     private array $dependencies = [
    57         'Helpers/Compatibility',
    58         'Helpers/Helpers',
    59         'Helpers/Logtivity_Wp_User',
    60         'Admin/Logtivity_Log_Index_Controller',
    61         'Admin/Logtivity_Dismiss_Notice_Controller',
    62         'Admin/Logtivity_Options',
    63         'Admin/Logtivity_Response',
    64         'Admin/Logtivity_Admin',
    65         'Services/Logtivity_User_Logger_Trait',
    66         'Services/Logtivity_Api',
    67         'Services/Logtivity_Logger',
    68         'Services/Logtivity_Register_Site',
    69         'Helpers/Logtivity_Log_Global_Function',
    70         'Logs/Logtivity_Abstract_Logger',
    71         'Services/Logtivity_Check_For_Disabled_Individual_Logs',
    72         'Services/Logtivity_Check_For_New_Settings',
    73         'Services/Logtivity_Rest_Endpoints',
    74         /**
    75          * Error logging
    76          */
    77         'Errors/Logtivity_Stack_Trace_Snippet',
    78         'Errors/Logtivity_Stack_Trace',
    79         'Errors/Logtivity_Error_Logger',
    80         'Errors/Logtivity_Error_Log',
     47    protected string $version = '3.3.0';
     48
     49    /**
     50     * Integrations with other plugins
     51     *
     52     * @var array[]
     53     */
     54    private array $integrations = [
     55        WP_DLM::class                 => 'Download_Monitor',
     56        MeprCtrlFactory::class        => 'Memberpress',
     57        Easy_Digital_Downloads::class => 'Easy_Digital_Downloads',
     58        EDD_Software_Licensing::class => 'Easy_Digital_Downloads/Licensing',
     59        EDD_Recurring::class          => 'Easy_Digital_Downloads/Recurring',
     60        FrmHooksController::class     => 'Formidable',
     61        PMXI_Plugin::class            => 'WP_All_Import',
     62        \Code_Snippets\Plugin::class  => 'Code_Snippets',
    8163    ];
    82     /**
    83      * @var string[]
    84      */
    85     private array $logClasses = [
    86         /**
    87          * Activity logging
    88          */
    89         'Logs/Core/Logtivity_Post',
    90         'Logs/Core/Logtivity_User',
    91         'Logs/Core/Logtivity_Core',
    92         'Logs/Core/Logtivity_Theme',
    93         'Logs/Core/Logtivity_Plugin',
    94         'Logs/Core/Logtivity_Comment',
    95         'Logs/Core/Logtivity_Term',
    96         'Logs/Core/Logtivity_Meta',
    97     ];
    98     /**
    99      * List all integration dependencies
    100      *
    101      * @var array[]
    102      */
    103     private array $integrationDependencies = [
    104         'WP_DLM'                 => [
    105             'Logs/Download_Monitor/Logtivity_Download_Monitor',
    106         ],
    107         'MeprCtrlFactory'        => [
    108             'Logs/Memberpress/Logtivity_Memberpress',
    109         ],
    110         'Easy_Digital_Downloads' => [
    111             'Logs/Easy_Digital_Downloads/Logtivity_Abstract_Easy_Digital_Downloads',
    112             'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads',
    113         ],
    114         'EDD_Software_Licensing' => [
    115             'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads_Software_Licensing',
    116         ],
    117         'EDD_Recurring'          => [
    118             'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads_Recurring',
    119         ],
    120         'FrmHooksController'     => [
    121             'Logs/Formidable/Logtivity_FrmEntryFormatter',
    122             'Logs/Formidable/Logtivity_Formidable',
    123         ],
    124         'PMXI_Plugin'            => [
    125             'Logs/WP_All_Import/Logtivity_WP_All_Import',
    126         ],
    127         '\Code_Snippets\Plugin'  => [
    128             'Logs/Code_Snippets/Logtivity_Code_Snippets',
    129         ],
    130     ];
    13164
    13265    public function __construct()
    13366    {
    134         $this->loadDependencies();
     67        $this->loadCore();
     68        $this->activateLoggers();
    13569
    13670        add_action('upgrader_process_complete', [$this, 'upgradeProcessComplete'], 10, 2);
     
    14781
    14882    /**
    149      * @return void
    150      */
    151     public function loadDependencies(): void
    152     {
    153         foreach ($this->dependencies as $filePath) {
    154             $this->loadFile($filePath);
    155         }
    156 
     83     * @return self
     84     */
     85    public static function init(): self
     86    {
     87        return new static();
     88    }
     89
     90    /**
     91     * @return void
     92     */
     93    protected function loadCore(): void
     94    {
     95        $requires = array_merge(
     96            $this->getFiles(__DIR__ . '/functions'),
     97            $this->getFiles(__DIR__ . '/Base')
     98        );
     99        foreach ($requires as $file) {
     100            require_once $file;
     101        }
     102
     103        $coreFiles   = $this->getFiles(__DIR__ . '/Core');
     104        $initClasses = [];
     105        foreach ($coreFiles as $file) {
     106            require_once $file;
     107            $className = basename($file, '.php');
     108            if (is_callable([$className, 'init'])) {
     109                $initClasses[] = $className;
     110            }
     111        }
     112        foreach ($initClasses as $class) {
     113            call_user_func([$class, 'init']);
     114        }
     115    }
     116
     117    protected function activateLoggers(): void
     118    {
    157119        add_action('plugins_loaded', function () {
    158120            $this->updateCheck();
    159121
    160             if ($this->defaultLoggingDisabled()) {
    161                 return;
    162             }
    163 
    164             $this->maybeLoadLogClasses();
    165 
    166             $this->loadIntegrationDependencies();
     122            if ($this->defaultLoggingDisabled() == false) {
     123                $this->loadCoreLoggers();
     124                $this->loadIntegrations();
     125            }
    167126        });
    168     }
    169 
    170     /**
    171      * @param string $filePath
    172      *
    173      * @return void
    174      */
    175     public function loadFile(string $filePath): void
    176     {
    177         require_once plugin_dir_path(__FILE__) . $filePath . '.php';
     127
     128    }
     129
     130    /**
     131     * @param string $path
     132     * @param bool   $recurse
     133     * @param string $extension
     134     *
     135     * @return array
     136     */
     137    protected function getFiles(string $path, bool $recurse = true, string $extension = 'php'): array
     138    {
     139        if (is_dir($path)) {
     140            $files = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
     141        } elseif (is_file($path)) {
     142            return [realpath($path)];
     143        } else {
     144            return [];
     145        }
     146
     147        $list = [];
     148        foreach ($files as $file) {
     149            if ($file->isFile()) {
     150                if ($file->getExtension() == $extension) {
     151                    $list[] = $file->getRealPath();
     152                }
     153
     154            } elseif ($recurse) {
     155                $list = array_merge($list, $this->getFiles($file->getRealPath(), $recurse, $extension));
     156            }
     157        }
     158
     159        return $list;
    178160    }
    179161
     
    188170
    189171        if (version_compare($currentVersion, '3.1.6', '<=')) {
    190             static::checkCapabilities();
     172            $this->checkCapabilities();
    191173        }
    192174
     
    204186     * @return void
    205187     */
    206     public static function checkCapabilities(): void
     188    protected function checkCapabilities(): void
    207189    {
    208190        $capabilities = array_filter(
     
    231213     * @return bool
    232214     */
    233     public function defaultLoggingDisabled(): bool
     215    protected function defaultLoggingDisabled(): bool
    234216    {
    235217        return (bool)(new Logtivity_Options())->getOption('logtivity_disable_default_logging');
     
    239221     * @return void
    240222     */
    241     public function maybeLoadLogClasses(): void
    242     {
    243         foreach ($this->logClasses as $filePath) {
    244             $this->loadFile($filePath);
    245         }
    246     }
    247 
    248     /**
    249      * @return void
    250      */
    251     public function loadIntegrationDependencies(): void
    252     {
    253         foreach ($this->integrationDependencies as $key => $value) {
     223    protected function loadCoreLoggers(): void
     224    {
     225        $coreLoggers = $this->getFiles(__DIR__ . '/Loggers/Core');
     226        foreach ($coreLoggers as $logger) {
     227            require_once $logger;
     228        }
     229    }
     230
     231    /**
     232     * @return void
     233     */
     234    protected function loadIntegrations(): void
     235    {
     236        $loggerFolder = __DIR__ . '/Loggers/';
     237
     238        foreach ($this->integrations as $key => $folder) {
     239            $integrationFolder = $loggerFolder . $folder;
    254240            if (class_exists($key)) {
    255                 foreach ($value as $filePath) {
    256                     $this->loadFile($filePath);
     241                if (is_dir($integrationFolder . '/Base')) {
     242                    // Load any base classes
     243                    $baseFiles = $this->getFiles($integrationFolder . '/Base');
     244                    foreach ($baseFiles as $file) {
     245                        require_once $file;
     246                    }
     247                }
     248
     249                $files = $this->getFiles($integrationFolder, false);
     250                foreach ($files as $file) {
     251                    require_once $file;
    257252                }
    258253            }
     
    420415        add_option('logtivity_activate', true);
    421416
    422         static::checkCapabilities();
     417        $this->checkCapabilities();
    423418
    424419        if (apply_filters('logtivity_hide_settings_page', false)) {
     
    501496}
    502497
    503 new Logtivity();
     498Logtivity::init();
  • logtivity/trunk/readme.txt

    r3354825 r3369912  
    55Requires at least: 6.6
    66Tested up to: 6.8
    7 Stable tag: 3.2.1
     7Stable tag: 3.3.0
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    262262
    263263== Changelog ==
     264
     265= 3.3.0 - 25 Sep 2025 =
     266  * Provide more detailed information for term updates
     267  * Provide more detailed information for user updates
    264268
    265269= 3.2.1 - 02 Sep 2025 =
Note: See TracChangeset for help on using the changeset viewer.