Plugin Directory

Changeset 3229571


Ignore:
Timestamp:
01/27/2025 01:16:21 PM (13 months ago)
Author:
axeptio
Message:

version 2.5.7 release

Location:
axeptio-sdk-integration
Files:
1502 added
5 edited

Legend:

Unmodified
Added
Removed
  • axeptio-sdk-integration/trunk/axeptio-wordpress-plugin.php

    r3228096 r3229571  
    44    Plugin URI: https://www.axeptio.eu/
    55    Description: Axeptio allows you to make your website compliant with GDPR.
    6     Version: 2.5.6
     6    Version: 2.5.7
    77    Author: axeptio
    88    License: GPLv3
     
    1212 **/
    1313
    14 define( 'XPWP_VERSION', '2.5.6' );
     14define( 'XPWP_VERSION', '2.5.7' );
    1515define( 'XPWP_URL', plugin_dir_url( __FILE__ ) );
    1616define( 'XPWP_PATH', plugin_dir_path( __FILE__ ) );
  • axeptio-sdk-integration/trunk/includes/classes/frontend/class-hook-modifier.php

    r3228096 r3229571  
    1616use Axeptio\Plugin\Utils\User_Hook_Parser;
    1717use Closure;
    18 use ReflectionException;
    19 use ReflectionFunction;
    20 use ReflectionMethod;
    2118
    2219class Hook_Modifier extends Module {
     
    121118            return;
    122119        }
     120
     121        Search_Callback_File_Location::initialize_cache();
     122
    123123        $this->process_shortcode_tags();
    124124        $this->process_wp_filter();
     
    167167
    168168    /**
    169      * Process shortcode tags.
     169     * Process shortcode tags and write cache to file.
    170170     *
    171171     * @return array
     
    238238        }
    239239
     240        // Write the cache to a file after processing all shortcode tags.
     241        Search_Callback_File_Location::write_cache_to_file();
     242
    240243        return $stats;
    241244    }
     
    507510            }
    508511        }
     512
     513        // Write the cache to a file after processing all hooks.
     514        Search_Callback_File_Location::write_cache_to_file();
    509515
    510516        return $stats;
  • axeptio-sdk-integration/trunk/includes/classes/models/class-plugins.php

    r3206185 r3229571  
    108108            $configuration_id,
    109109            $force_refresh
    110             );
     110        );
    111111    }
    112112
     
    140140     */
    141141    public static function find_all(): array {
    142         global $wpdb;
    143         return $wpdb->get_results( "SELECT * FROM `$wpdb->axeptio_plugin_configuration` ORDER BY axeptio_configuration_id = 'all' DESC", ARRAY_A ); // @codingStandardsIgnoreLine
     142        return Remember::get_or_reset_result(
     143            'plugins_find_all',
     144            function () {
     145                global $wpdb;
     146                return $wpdb->get_results( "SELECT * FROM `$wpdb->axeptio_plugin_configuration` ORDER BY axeptio_configuration_id = 'all' DESC", ARRAY_A ); // @codingStandardsIgnoreLine
     147            },
     148            'all',
     149            true
     150        );
    144151    }
    145152
  • axeptio-sdk-integration/trunk/includes/classes/utils/class-search-callback-file-location.php

    r3206185 r3229571  
    1111
    1212    /**
    13      * Cache expiration time in seconds (1 hour)
    14      */
    15     const CACHE_EXPIRATION = 3600;
     13     * Cache expiration time in seconds (1 week)
     14     */
     15    const CACHE_EXPIRATION = 604800;
     16
     17    /**
     18     * Temporary storage for callback file locations.
     19     *
     20     * @var array
     21     */
     22    private static $callback_file_locations = null;
     23
     24    /**
     25     * Initial state of the callback file locations for comparison.
     26     *
     27     * @var array
     28     */
     29    private static $initial_callback_file_locations = null;
     30
     31    /**
     32     * Initialize the callback file locations from cache.
     33     *
     34     * @return void
     35     */
     36    public static function initialize_cache() {
     37        if (self::$callback_file_locations !== null) {
     38            return;
     39        }
     40
     41        $cache_file = self::get_cache_file_path();
     42
     43        if (file_exists($cache_file) && (time() - filemtime($cache_file)) < self::CACHE_EXPIRATION) {
     44            self::$callback_file_locations = (array) include $cache_file;
     45        } else {
     46            self::$callback_file_locations = array();
     47        }
     48
     49        // Store the initial state for later comparison
     50        self::$initial_callback_file_locations = self::$callback_file_locations;
     51    }
    1652
    1753    /**
     
    2561     */
    2662    public static function get_filename( $callback_function, ?string $name = null, ?string $filter = null, ?int $priority = null ): ?string {
    27         $cache_key     = self::generate_cache_key( $callback_function, $name, $filter, $priority );
    28         $cached_result = wp_cache_get( $cache_key, self::CACHE_GROUP );
    29 
    30         if ( false !== $cached_result && ! is_null( $cached_result ) ) {
    31             return $cached_result;
     63        self::initialize_cache();
     64
     65        $cache_key = self::generate_cache_key( $callback_function, $name, $filter, $priority );
     66
     67        // Check if the filename is already in the temporary storage.
     68        if ( isset( self::$callback_file_locations[ $cache_key ] ) ) {
     69            return self::$callback_file_locations[ $cache_key ];
    3270        }
    3371
    3472        $filename = self::find_filename( $callback_function, $name, $filter, $priority );
    3573
    36         wp_cache_set( $cache_key, $filename, self::CACHE_GROUP, self::CACHE_EXPIRATION );
     74        // Store the result in the temporary storage.
     75        self::$callback_file_locations[ $cache_key ] = $filename;
    3776
    3877        return $filename;
     78    }
     79
     80    /**
     81     * Write the callback file locations to a PHP file.
     82     *
     83     * @return void
     84     */
     85    public static function write_cache_to_file() {
     86        // Sort both arrays to ensure they are in the same order for comparison
     87        ksort(self::$callback_file_locations);
     88        ksort(self::$initial_callback_file_locations);
     89
     90        // Only write to the file if the data has changed
     91        if (self::$callback_file_locations === self::$initial_callback_file_locations) {
     92            return;
     93        }
     94
     95        $cache_file = self::get_cache_file_path();
     96
     97        // Check if the directory exists, if not, create it.
     98        self::ensure_cache_directory_exists();
     99
     100        $content = "<?php\nreturn " . var_export( self::$callback_file_locations, true ) . ";\n";
     101
     102        file_put_contents( $cache_file, $content );
    39103    }
    40104
     
    50114    private static function find_filename( $callback_function, ?string $name = null, ?string $filter = null, ?int $priority = null ): ?string {
    51115        try {
    52             // Handle string callbacks (function names).
    53             if ( is_string( $callback_function ) ) {
    54                 if ( function_exists( $callback_function ) ) {
    55                     $reflection = new \ReflectionFunction( $callback_function );
    56                     return $reflection->getFileName();
    57                 } elseif ( strpos( $callback_function, '::' ) !== false ) {
    58                     // Static method call string like 'Class::method'.
    59                     list($class, $method) = explode( '::', $callback_function );
    60                     $reflection           = new \ReflectionMethod( $class, $method );
    61                     return $reflection->getFileName();
    62                 }
    63             }
    64 
    65             // Handle array callbacks.
    66             if ( is_array( $callback_function ) && count( $callback_function ) === 2 ) {
    67                 list($object_or_class, $method) = $callback_function;
    68 
    69                 if ( is_object( $object_or_class ) ) {
    70                     $reflection = new \ReflectionMethod( get_class( $object_or_class ), $method );
    71                 } elseif ( is_string( $object_or_class ) ) {
    72                     $reflection = new \ReflectionMethod( $object_or_class, $method );
    73                 } else {
    74                     return null;
    75                 }
    76 
     116            if (is_string($callback_function)) {
     117                return self::get_filename_from_string($callback_function);
     118            }
     119
     120            if (is_array($callback_function) && count($callback_function) === 2) {
     121                return self::get_filename_from_array($callback_function);
     122            }
     123
     124            if ($callback_function instanceof \Closure) {
     125                $reflection = new \ReflectionFunction($callback_function);
    77126                return $reflection->getFileName();
    78127            }
    79128
    80             // Handle Closure.
    81             if ( $callback_function instanceof \Closure ) {
    82                 $reflection = new \ReflectionFunction( $callback_function );
     129            if (is_object($callback_function) && method_exists($callback_function, '__invoke')) {
     130                $reflection = new \ReflectionMethod($callback_function, '__invoke');
    83131                return $reflection->getFileName();
    84132            }
    85133
    86             // Handle invokable objects.
    87             if ( is_object( $callback_function ) && method_exists( $callback_function, '__invoke' ) ) {
    88                 $reflection = new \ReflectionMethod( $callback_function, '__invoke' );
    89                 return $reflection->getFileName();
    90             }
    91 
    92             // Handle WordPress-specific cases.
    93             if ( is_string( $name ) && is_string( $filter ) ) {
    94                 return self::handle_wp_specific_cases( $name, $filter, $priority );
    95             }
    96         } catch ( \ReflectionException $e ) {
     134            if (is_string($name) && is_string($filter)) {
     135                return self::handle_wp_specific_cases($name, $filter, $priority);
     136            }
     137        } catch (\ReflectionException $e) {
    97138            // Log the exception or handle it as needed.
    98139            return null;
    99140        }
    100141
    101         // If we couldn't determine the file name, return null.
    102142        return null;
    103143    }
     
    148188        return 'unknown';
    149189    }
    150 
    151190
    152191    /**
     
    178217        return null;
    179218    }
     219
     220    /**
     221     * Get the cache file path.
     222     *
     223     * @return string
     224     */
     225    private static function get_cache_file_path(): string {
     226        $upload_dir = wp_upload_dir();
     227        return $upload_dir['basedir'] . '/axeptio/callback_file_cache.php';
     228    }
     229
     230    /**
     231     * Ensure the cache directory exists.
     232     *
     233     * @return void
     234     */
     235    private static function ensure_cache_directory_exists() {
     236        $cache_dir = dirname(self::get_cache_file_path());
     237        if (!file_exists($cache_dir)) {
     238            wp_mkdir_p($cache_dir);
     239        }
     240    }
     241
     242    /**
     243     * Get the filename from a string callback.
     244     *
     245     * @param string $callback_function
     246     * @return string|null
     247     */
     248    private static function get_filename_from_string(string $callback_function): ?string {
     249        if (function_exists($callback_function)) {
     250            $reflection = new \ReflectionFunction($callback_function);
     251            return $reflection->getFileName();
     252        } elseif (strpos($callback_function, '::') !== false) {
     253            list($class, $method) = explode('::', $callback_function);
     254            $reflection = new \ReflectionMethod($class, $method);
     255            return $reflection->getFileName();
     256        }
     257        return null;
     258    }
     259
     260    /**
     261     * Get the filename from an array callback.
     262     *
     263     * @param array $callback_function
     264     * @return string|null
     265     */
     266    private static function get_filename_from_array(array $callback_function): ?string {
     267        list($object_or_class, $method) = $callback_function;
     268
     269        if (is_object($object_or_class)) {
     270            $reflection = new \ReflectionMethod(get_class($object_or_class), $method);
     271        } elseif (is_string($object_or_class)) {
     272            $reflection = new \ReflectionMethod($object_or_class, $method);
     273        } else {
     274            return null;
     275        }
     276
     277        return $reflection->getFileName();
     278    }
    180279}
  • axeptio-sdk-integration/trunk/readme.txt

    r3228096 r3229571  
    44Requires at least: 5.0
    55Tested up to: 6.5.5
    6 Stable tag: 2.5.6
     6Stable tag: 2.5.7
    77Requires PHP: 7.4
    88License: GPLv3
     
    8585== Changelog ==
    8686
     87### 🚀 2.5.7 🚀 ###
     88
     89- **Code Refactoring:** Improved code readability and maintainability with better function organization and reduced duplication.
     90- **Performance Optimization:** Ensured efficient cache handling with minimal performance impact.
     91
    8792### ⚡️ 2.5.6 ⚡️ ###
    8893
     
    125130**Error Logging Tool Taking a Power Nap 💤**
    126131
    127 In this release, we've temporarily disabled our error logging tool. But don't worry! Its just taking a break to come back stronger, faster, and smarter. 💪
     132In this release, we've temporarily disabled our error logging tool. But don't worry! It's just taking a break to come back stronger, faster, and smarter. 💪
    128133
    129134### 🎉 2.4.9 🎉 ###
     
    163168
    164169**Temporary Removal of Caching Feature 🔄**
    165 Weve identified an issue with our new caching system that might have affected performance for some users. As we work on a more robust solution, we have temporarily removed this feature to ensure the best experience for all our users.
     170We've identified an issue with our new caching system that might have affected performance for some users. As we work on a more robust solution, we have temporarily removed this feature to ensure the best experience for all our users.
    166171
    167172- **Apologies for Any Inconvenience 🙏**
Note: See TracChangeset for help on using the changeset viewer.