Plugin Directory

Changeset 3134733


Ignore:
Timestamp:
08/13/2024 08:25:51 AM (16 months ago)
Author:
advancedads
Message:

Update to version 1.53.1 from GitHub

Location:
advanced-ads
Files:
6 added
4 deleted
32 edited
1 copied

Legend:

Unmodified
Added
Removed
  • advanced-ads/tags/1.53.1/advanced-ads.php

    r3134243 r3134733  
    1313 * Plugin URI:        https://wpadvancedads.com
    1414 * Description:       Manage and optimize your ads in WordPress
    15  * Version:           1.53.0
     15 * Version:           1.53.1
    1616 * Author:            Advanced Ads GmbH
    1717 * Author URI:        https://wpadvancedads.com
     
    3434
    3535define( 'ADVADS_FILE', __FILE__ );
    36 define( 'ADVADS_VERSION', '1.53.0' );
     36define( 'ADVADS_VERSION', '1.53.1' );
    3737
    3838// Load the autoloader.
  • advanced-ads/tags/1.53.1/classes/plugin.php

    r3029416 r3134733  
    428428                $this->update_internal_options( $this->internal_options );
    429429
    430                 self::get_instance()->create_capabilities();
     430                Capabilities::get_instance()->create_capabilities();
    431431            }
    432432
     
    545545     */
    546546    public function create_capabilities() {
    547         _deprecated_function( __METHOD__, '1.47.0', 'AdvancedAds\Installation\Capabilities::create_capabilities()' );
    548 
    549         ( new Capabilities() )->create_capabilities();
     547        _deprecated_function( __METHOD__, '1.47.0', 'AdvancedAds\Installation\Capabilities::get_instance()->create_capabilities();' );
     548
     549        Capabilities::get_instance()->create_capabilities();
    550550    }
    551551
  • advanced-ads/tags/1.53.1/classes/upgrades.php

    r2983598 r3134733  
    1 <?php
     1<?php // phpcs:ignoreFile
     2
     3use AdvancedAds\Installation\Capabilities;
    24
    35/**
     
    1517        $internal_options = Advanced_Ads_Plugin::get_instance()->internal_options();
    1618
    17         // the 'advanced_ads_edit_ads' capability was added to Entities::POST_TYPE_AD post type in this version
     19        // 'advanced_ads_edit_ads' capability was added to Entities::POST_TYPE_AD post type in this version
    1820        if ( ! isset( $internal_options['version'] ) || version_compare( $internal_options['version'], '1.7.2', '<' ) ) {
    19             Advanced_Ads_Plugin::get_instance()->create_capabilities();
     21            Capabilities::get_instance()->create_capabilities();
    2022        }
    2123
  • advanced-ads/tags/1.53.1/includes/installation/class-capabilities.php

    r2986093 r3134733  
    1616 */
    1717class Capabilities {
     18
     19    /**
     20     * Instance
     21     *
     22     * @var object
     23     */
     24    protected static $instance;
    1825
    1926    /**
     
    3643    public function __construct() {
    3744        $this->register_defaults();
     45    }
     46
     47    /**
     48     * Get instance
     49     *
     50     * @return Capabilities
     51     */
     52    public static function get_instance() {
     53        // If the single instance hasn't been set, set it now.
     54        if ( null === self::$instance ) {
     55            self::$instance = new self();
     56        }
     57
     58        return self::$instance;
    3859    }
    3960
  • advanced-ads/tags/1.53.1/includes/installation/class-install.php

    r2983598 r3134733  
    3636    protected function activate(): void {
    3737        // TODO: inform modules.
    38         ( new Capabilities() )->create_capabilities();
     38        Capabilities::get_instance()->create_capabilities();
    3939    }
    4040
     
    4646    protected function deactivate(): void {
    4747        // TODO: inform modules.
    48         ( new Capabilities() )->remove_capabilities();
     48        Capabilities::get_instance()->remove_capabilities();
    4949    }
    5050
  • advanced-ads/tags/1.53.1/languages/advanced-ads.pot

    r3134243 r3134733  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Advanced Ads 1.52.4\n"
     5"Project-Id-Version: Advanced Ads 1.53.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/advanced-ads/\n"
    77"Last-Translator: Thomas Maier <[email protected]>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-08-06T11:19:18+00:00\n"
     12"POT-Creation-Date: 2024-08-13T08:25:00+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.6.0\n"
     
    31303130msgstr ""
    31313131
    3132 #: includes/installation/class-capabilities.php:48
     3132#: includes/installation/class-capabilities.php:69
    31333133msgid "Allows changing plugin options"
    31343134msgstr ""
    31353135
    3136 #: includes/installation/class-capabilities.php:54
     3136#: includes/installation/class-capabilities.php:75
    31373137msgid "Allows access to the Advanced Ads backend"
    31383138msgstr ""
    31393139
    3140 #: includes/installation/class-capabilities.php:60
     3140#: includes/installation/class-capabilities.php:81
    31413141msgid "Allows editing ads"
    31423142msgstr ""
    31433143
    3144 #: includes/installation/class-capabilities.php:66
     3144#: includes/installation/class-capabilities.php:87
    31453145msgid "Allows changing the placements page"
    31463146msgstr ""
    31473147
    3148 #: includes/installation/class-capabilities.php:72
     3148#: includes/installation/class-capabilities.php:93
    31493149msgid "Enables shortcode button"
    31503150msgstr ""
  • advanced-ads/tags/1.53.1/packages/advanced-ads/framework/src/class-assets-registry.php

    r3035032 r3134733  
    1616/**
    1717 * Assets Registry.
     18 *
     19 * Script functions:
     20 *
     21 * @method void enqueue_script(string $handle)
     22 * @method void dequeue_script(string $handle)
     23 * @method void deregister_script(string $handle)
     24 * @method bool register_script(string $handle, string|false $src, string[] $deps = [], string|bool|null $ver = false, array|bool $args = [])
     25 * @method bool inline_script(string $handle, string $data, string $position = 'after')
     26 * @method bool is_script(string $handle, string $status = 'enqueued')
     27 *
     28 * Style functions:
     29 *
     30 * @method void enqueue_style(string $handle)
     31 * @method void dequeue_style(string $handle)
     32 * @method void deregister_style(string $handle)
     33 * @method bool register_style(string $handle, string|false $src, string[] $deps = [], string|bool|null $ver = false, string $media = 'all')
     34 * @method bool inline_style(string $handle, string $data, )
     35 * @method bool is_style(string $handle, string $status = 'enqueued')
    1836 */
    19 class Assets_Registry implements Integration_Interface {
     37abstract class Assets_Registry implements Integration_Interface {
    2038
    2139    /**
    22      * Version of plugin local asset.
     40     * Base URL for plugin local assets.
    2341     *
    24      * @var string
     42     * @return string
    2543     */
    26     const VERSION = '1.0.0';
     44    abstract public function get_base_url(): string;
    2745
    2846    /**
    2947     * Prefix to use in handle to make it unique.
    3048     *
    31      * @var string
     49     * @return string
    3250     */
    33     const PREFIX = 'advads';
     51    abstract public function get_prefix(): string;
    3452
    3553    /**
    36      * Enqueue stylesheet
    37      *
    38      * @param string $handle Name of the stylesheet.
    39      *
    40      * @return void
    41      */
    42     public static function enqueue_style( $handle ): void {
    43         wp_enqueue_style( self::prefix_it( $handle ) );
    44     }
    45 
    46     /**
    47      * Enqueue script
    48      *
    49      * @param string $handle Name of the script.
    50      *
    51      * @return void
    52      */
    53     public static function enqueue_script( $handle ): void {
    54         wp_enqueue_script( self::prefix_it( $handle ) );
    55     }
    56 
    57     /**
    58      * Prefix the handle
    59      *
    60      * @param string $handle Name of the asset.
     54     * Version for plugin local assets.
    6155     *
    6256     * @return string
    6357     */
    64     public static function prefix_it( $handle ): string {
    65         return self::PREFIX . '-' . $handle;
     58    abstract public function get_version(): string;
     59
     60    /**
     61     * Magic method to catch all calls to.
     62     *
     63     * @param string $name      The name of the method.
     64     * @param array  $arguments The arguments passed to the method.
     65     *
     66     * @return mixed
     67     */
     68    public function __call( $name, $arguments ) {
     69        if ( preg_match( '/^(enqueue|dequeue|register|deregister|is|inline)_(script|style)$/', $name, $matches ) ) {
     70            $action    = $matches[1];
     71            $type      = $matches[2];
     72            $handle    = $this->prefix_it( $arguments[0] );
     73            $func      = $this->resolve_function( $action . '_' . $type );
     74            $func_args = [ $handle ];
     75
     76            switch ( $action ) {
     77                case 'register':
     78                    $func_args[] = $this->resolve_url( $arguments[1] );
     79                    $func_args[] = $arguments[2] ?? [];
     80                    $func_args[] = isset( $arguments[3] ) && ! empty( $arguments[3] ) ? $arguments[3] : $this->get_version();
     81                    $func_args[] = $arguments[4] ?? ( 'script' === $type ? true : 'all' );
     82                    break;
     83                case 'is':
     84                    $func_args[] = $arguments[1] ?? 'enqueued';
     85                    break;
     86                case 'inline':
     87                    $func_args[] = $arguments[1] ?? '';
     88                    if ( 'script' === $type ) {
     89                        $func_args[] = $arguments[2] ?? 'after';
     90                    }
     91                    break;
     92                default:
     93                    break;
     94            }
     95
     96            return call_user_func_array( $func, $func_args );
     97        }
    6698    }
    6799
     
    72104     */
    73105    public function hooks(): void {
     106        add_action( 'wp_enqueue_scripts', [ $this, 'register_assets' ], 0 );
    74107        add_action( 'admin_enqueue_scripts', [ $this, 'register_assets' ], 0 );
    75108    }
     
    83116        $this->register_styles();
    84117        $this->register_scripts();
     118    }
     119
     120    /**
     121     * Prefix the handle
     122     *
     123     * @param string $handle Name of the asset.
     124     *
     125     * @return string
     126     */
     127    public function prefix_it( $handle ): string {
     128        return $this->get_prefix() . '-' . $handle;
    85129    }
    86130
     
    100144
    101145    /**
    102      * Register stylesheet
     146     * Resolves the URL.
    103147     *
    104      * @param string           $handle Name of the stylesheet. Should be unique.
    105      * @param string|bool      $src    URL of the stylesheet.
    106      * @param string[]         $deps   Optional. An array of registered stylesheet handles this stylesheet depends on.
    107      * @param string|bool|null $ver    Optional. String specifying stylesheet version number.
    108      * @param string           $media  Optional. The media for which this stylesheet has been defined.
     148     * If the provided URL is an absolute URL or protocol-relative URL, it is returned as is.
     149     * Otherwise, the base URL is prepended to the relative path.
    109150     *
    110      * @return void
     151     * @param string $src The source URL.
     152     *
     153     * @return string The resolved URL.
    111154     */
    112     private function register_style( $handle, $src, $deps = [], $ver = false, $media = 'all' ) {
    113         if ( false === $ver ) {
    114             $ver = self::VERSION;
     155    private function resolve_url( $src ): string {
     156        if ( preg_match( '/^(https?:)?\/\//', $src ) ) {
     157            return $src;
    115158        }
    116159
    117         wp_register_style( self::prefix_it( $handle ), ADVADS_BASE_URL . $src, $deps, $ver, $media );
     160        return $this->get_base_url() . $src;
    118161    }
    119162
    120163    /**
    121      * Register script
     164     * Resolves the function name.
    122165     *
    123      * @param string           $handle    Name of the stylesheet. Should be unique.
    124      * @param string|bool      $src       URL of the stylesheet.
    125      * @param string[]         $deps      Optional. An array of registered stylesheet handles this stylesheet depends on.
    126      * @param string|bool|null $ver       Optional. String specifying stylesheet version number.
    127      * @param bool             $in_footer Optional. The media for which this stylesheet has been defined.
     166     * @param string $name The name of the function.
    128167     *
    129      * @return void
     168     * @return string
    130169     */
    131     private function register_script( $handle, $src, $deps = [], $ver = false, $in_footer = false ) {
    132         if ( false === $ver ) {
    133             $ver = self::VERSION;
    134         }
     170    private function resolve_function( $name ): string {
     171        $method_map = [
     172            'is_script'     => 'script_is',
     173            'is_style'      => 'style_is',
     174            'inline_script' => 'add_inline_script',
     175            'inline_style'  => 'add_inline_style',
     176        ];
    135177
    136         $new_src = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? $src : str_replace( '.js', '.min.js', $src );
    137         wp_register_script( self::prefix_it( $handle ), ADVADS_BASE_URL . $src, $deps, $ver, $in_footer );
     178        $name = $method_map[ $name ] ?? $name;
     179
     180        return 'wp_' . $name;
    138181    }
    139182}
  • advanced-ads/tags/1.53.1/packages/advanced-ads/framework/src/installation/class-install.php

    r2983598 r3134733  
    4949     */
    5050    public function activation( $network_wide = false ): void {
    51         register_uninstall_hook( $this->base_file, [ self::class, 'uninstall' ] );
     51        register_uninstall_hook( $this->base_file, [ static::class, 'uninstall' ] );
    5252
    5353        if ( ! is_multisite() || ! $network_wide ) {
  • advanced-ads/tags/1.53.1/packages/advanced-ads/framework/src/notices/class-notice.php

    r2983598 r3134733  
    119119
    120120    /**
    121      * Serialize data.
     121     * Serialize data, for PHP version < 7.4.0
    122122     *
    123123     * @return string
     
    134134
    135135    /**
    136      * Unserialize string.
     136     * Return an array representing the serialized form the object. For PHP version >= 7.4.0
     137     *
     138     * @return array
     139     */
     140    public function __serialize(): array {
     141        return [
     142            'id'      => $this->id,
     143            'message' => $this->message,
     144            'options' => $this->options,
     145        ];
     146    }
     147
     148    /**
     149     * Recreate an instance of this class. For PHP version >= 7.4.0
     150     *
     151     * @param array $data the array returned by __serialize.
     152     *
     153     * @return void
     154     */
     155    public function __unserialize( $data ): void {}
     156
     157    /**
     158     * Unserialize string, for PHP version < 7.4.0
    137159     *
    138160     * @param string $data Data to unserialize.
  • advanced-ads/tags/1.53.1/packages/advanced-ads/framework/src/utilities/class-formatting.php

    r3035032 r3134733  
    1616 */
    1717class Formatting {
     18
    1819    /**
    1920     * Converts a string (e.g. 'yes' or 'no') to a bool.
     
    8586    public static function clean( $value ) {
    8687        if ( is_array( $value ) ) {
    87             return array_map( [ sel::class, 'clean' ], $value );
     88            return array_map( [ self::class, 'clean' ], $value );
    8889        }
    8990
     
    142143        );
    143144    }
    144 
    145     /**
    146      * Wrapper for mb_strtoupper which see's if supported first.
    147      *
    148      * @param string $str String to format.
    149      *
    150      * @return string
    151      */
    152     public static function strtoupper( $str ) {
    153         $str = $str ?? '';
    154         return function_exists( 'mb_strtoupper' ) ? mb_strtoupper( $str ) : strtoupper( $str );
    155     }
    156 
    157     /**
    158      * Make a string lowercase.
    159      * Try to use mb_strtolower() when available.
    160      *
    161      * @param string $str String to format.
    162      *
    163      * @return string
    164      */
    165     public static function strtolower( $str ) {
    166         $str = $str ?? '';
    167         return function_exists( 'mb_strtolower' ) ? mb_strtolower( $str ) : strtolower( $str );
    168     }
    169 
    170     /**
    171      * Implode and escape HTML attributes for output.
    172      *
    173      * @param array $raw_attributes Attribute name value pairs.
    174      *
    175      * @return string
    176      */
    177     public static function join_html_attributes( $raw_attributes ) {
    178         $attributes = [];
    179         foreach ( $raw_attributes as $name => $value ) {
    180             $attributes[] = esc_attr( $name ) . '="' . esc_attr( $value ) . '"';
    181         }
    182 
    183         return implode( ' ', $attributes );
    184     }
    185145}
  • advanced-ads/tags/1.53.1/packages/composer/LICENSE

    r2983598 r3134733  
    1 
    21Copyright (c) Nils Adermann, Jordi Boggiano
    32
     
    1918OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    2019THE SOFTWARE.
    21 
  • advanced-ads/tags/1.53.1/packages/composer/autoload_classmap.php

    r3134243 r3134733  
    4747    'AdvancedAds\\Framework\\Notices\\Storage' => $vendorDir . '/advanced-ads/framework/src/notices/class-storage.php',
    4848    'AdvancedAds\\Framework\\Updates' => $vendorDir . '/advanced-ads/framework/src/class-updates.php',
    49     'AdvancedAds\\Framework\\Utilities\\Arr' => $vendorDir . '/advanced-ads/framework/src/utilities/class-array.php',
     49    'AdvancedAds\\Framework\\Utilities\\Arr' => $vendorDir . '/advanced-ads/framework/src/utilities/class-arr.php',
    5050    'AdvancedAds\\Framework\\Utilities\\Formatting' => $vendorDir . '/advanced-ads/framework/src/utilities/class-formatting.php',
     51    'AdvancedAds\\Framework\\Utilities\\HTML' => $vendorDir . '/advanced-ads/framework/src/utilities/class-html.php',
    5152    'AdvancedAds\\Framework\\Utilities\\Params' => $vendorDir . '/advanced-ads/framework/src/utilities/class-params.php',
    52     'AdvancedAds\\Framework\\Utilities\\Str' => $vendorDir . '/advanced-ads/framework/src/utilities/class-string.php',
     53    'AdvancedAds\\Framework\\Utilities\\Str' => $vendorDir . '/advanced-ads/framework/src/utilities/class-str.php',
    5354    'AdvancedAds\\Groups\\Manager' => $baseDir . '/includes/groups/class-manager.php',
    5455    'AdvancedAds\\Groups\\Types\\Grid' => $baseDir . '/includes/groups/types/type-grid.php',
  • advanced-ads/tags/1.53.1/packages/composer/autoload_static.php

    r3134243 r3134733  
    7676        'AdvancedAds\\Framework\\Notices\\Storage' => __DIR__ . '/..' . '/advanced-ads/framework/src/notices/class-storage.php',
    7777        'AdvancedAds\\Framework\\Updates' => __DIR__ . '/..' . '/advanced-ads/framework/src/class-updates.php',
    78         'AdvancedAds\\Framework\\Utilities\\Arr' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-array.php',
     78        'AdvancedAds\\Framework\\Utilities\\Arr' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-arr.php',
    7979        'AdvancedAds\\Framework\\Utilities\\Formatting' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-formatting.php',
     80        'AdvancedAds\\Framework\\Utilities\\HTML' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-html.php',
    8081        'AdvancedAds\\Framework\\Utilities\\Params' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-params.php',
    81         'AdvancedAds\\Framework\\Utilities\\Str' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-string.php',
     82        'AdvancedAds\\Framework\\Utilities\\Str' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-str.php',
    8283        'AdvancedAds\\Groups\\Manager' => __DIR__ . '/../..' . '/includes/groups/class-manager.php',
    8384        'AdvancedAds\\Groups\\Types\\Grid' => __DIR__ . '/../..' . '/includes/groups/types/type-grid.php',
  • advanced-ads/tags/1.53.1/packages/composer/installed.json

    r3041809 r3134733  
    88                "type": "git",
    99                "url": "https://github.com/advanced-ads/framework.git",
    10                 "reference": "95e385daf3e3f11125711f43c5f7c437e00b075d"
     10                "reference": "9ceddbff73a7f588e29ab0172314b9a9a349546c"
    1111            },
    1212            "dist": {
    1313                "type": "zip",
    14                 "url": "https://api.github.com/repos/advanced-ads/framework/zipball/95e385daf3e3f11125711f43c5f7c437e00b075d",
    15                 "reference": "95e385daf3e3f11125711f43c5f7c437e00b075d",
     14                "url": "https://api.github.com/repos/advanced-ads/framework/zipball/9ceddbff73a7f588e29ab0172314b9a9a349546c",
     15                "reference": "9ceddbff73a7f588e29ab0172314b9a9a349546c",
    1616                "shasum": ""
    1717            },
     
    2323                "wp-coding-standards/wpcs": "^3.0.0"
    2424            },
    25             "time": "2023-12-18T07:33:42+00:00",
     25            "time": "2024-08-01T10:52:05+00:00",
    2626            "default-branch": true,
    2727            "type": "wordpress-plugin",
  • advanced-ads/tags/1.53.1/packages/composer/installed.php

    r3050336 r3134733  
    44        'pretty_version' => '1.42.1',
    55        'version' => '1.42.1.0',
    6         'reference' => NULL,
     6        'reference' => null,
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '95e385daf3e3f11125711f43c5f7c437e00b075d',
     16            'reference' => '9ceddbff73a7f588e29ab0172314b9a9a349546c',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../advanced-ads/framework',
     
    3434            'pretty_version' => '1.42.1',
    3535            'version' => '1.42.1.0',
    36             'reference' => NULL,
     36            'reference' => null,
    3737            'type' => 'wordpress-plugin',
    3838            'install_path' => __DIR__ . '/../../',
  • advanced-ads/tags/1.53.1/readme.txt

    r3134243 r3134733  
    55Tested up to: 6.5
    66Requires PHP: 7.2
    7 Stable tag: 1.53.0
     7Stable tag: 1.53.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    339339== Changelog ==
    340340
     341= 1.53.1 (August 13, 2024) =
     342
     343- Fix: resolve issue with deleting data on uninstall
     344- Fix: resolve JavaScript error when uninstall
     345
    341346= 1.53.0 (August 6, 2024) =
    342347
  • advanced-ads/trunk/advanced-ads.php

    r3134243 r3134733  
    1313 * Plugin URI:        https://wpadvancedads.com
    1414 * Description:       Manage and optimize your ads in WordPress
    15  * Version:           1.53.0
     15 * Version:           1.53.1
    1616 * Author:            Advanced Ads GmbH
    1717 * Author URI:        https://wpadvancedads.com
     
    3434
    3535define( 'ADVADS_FILE', __FILE__ );
    36 define( 'ADVADS_VERSION', '1.53.0' );
     36define( 'ADVADS_VERSION', '1.53.1' );
    3737
    3838// Load the autoloader.
  • advanced-ads/trunk/classes/plugin.php

    r3029416 r3134733  
    428428                $this->update_internal_options( $this->internal_options );
    429429
    430                 self::get_instance()->create_capabilities();
     430                Capabilities::get_instance()->create_capabilities();
    431431            }
    432432
     
    545545     */
    546546    public function create_capabilities() {
    547         _deprecated_function( __METHOD__, '1.47.0', 'AdvancedAds\Installation\Capabilities::create_capabilities()' );
    548 
    549         ( new Capabilities() )->create_capabilities();
     547        _deprecated_function( __METHOD__, '1.47.0', 'AdvancedAds\Installation\Capabilities::get_instance()->create_capabilities();' );
     548
     549        Capabilities::get_instance()->create_capabilities();
    550550    }
    551551
  • advanced-ads/trunk/classes/upgrades.php

    r2983598 r3134733  
    1 <?php
     1<?php // phpcs:ignoreFile
     2
     3use AdvancedAds\Installation\Capabilities;
    24
    35/**
     
    1517        $internal_options = Advanced_Ads_Plugin::get_instance()->internal_options();
    1618
    17         // the 'advanced_ads_edit_ads' capability was added to Entities::POST_TYPE_AD post type in this version
     19        // 'advanced_ads_edit_ads' capability was added to Entities::POST_TYPE_AD post type in this version
    1820        if ( ! isset( $internal_options['version'] ) || version_compare( $internal_options['version'], '1.7.2', '<' ) ) {
    19             Advanced_Ads_Plugin::get_instance()->create_capabilities();
     21            Capabilities::get_instance()->create_capabilities();
    2022        }
    2123
  • advanced-ads/trunk/includes/installation/class-capabilities.php

    r2986093 r3134733  
    1616 */
    1717class Capabilities {
     18
     19    /**
     20     * Instance
     21     *
     22     * @var object
     23     */
     24    protected static $instance;
    1825
    1926    /**
     
    3643    public function __construct() {
    3744        $this->register_defaults();
     45    }
     46
     47    /**
     48     * Get instance
     49     *
     50     * @return Capabilities
     51     */
     52    public static function get_instance() {
     53        // If the single instance hasn't been set, set it now.
     54        if ( null === self::$instance ) {
     55            self::$instance = new self();
     56        }
     57
     58        return self::$instance;
    3859    }
    3960
  • advanced-ads/trunk/includes/installation/class-install.php

    r2983598 r3134733  
    3636    protected function activate(): void {
    3737        // TODO: inform modules.
    38         ( new Capabilities() )->create_capabilities();
     38        Capabilities::get_instance()->create_capabilities();
    3939    }
    4040
     
    4646    protected function deactivate(): void {
    4747        // TODO: inform modules.
    48         ( new Capabilities() )->remove_capabilities();
     48        Capabilities::get_instance()->remove_capabilities();
    4949    }
    5050
  • advanced-ads/trunk/languages/advanced-ads.pot

    r3134243 r3134733  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Advanced Ads 1.52.4\n"
     5"Project-Id-Version: Advanced Ads 1.53.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/advanced-ads/\n"
    77"Last-Translator: Thomas Maier <[email protected]>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-08-06T11:19:18+00:00\n"
     12"POT-Creation-Date: 2024-08-13T08:25:00+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.6.0\n"
     
    31303130msgstr ""
    31313131
    3132 #: includes/installation/class-capabilities.php:48
     3132#: includes/installation/class-capabilities.php:69
    31333133msgid "Allows changing plugin options"
    31343134msgstr ""
    31353135
    3136 #: includes/installation/class-capabilities.php:54
     3136#: includes/installation/class-capabilities.php:75
    31373137msgid "Allows access to the Advanced Ads backend"
    31383138msgstr ""
    31393139
    3140 #: includes/installation/class-capabilities.php:60
     3140#: includes/installation/class-capabilities.php:81
    31413141msgid "Allows editing ads"
    31423142msgstr ""
    31433143
    3144 #: includes/installation/class-capabilities.php:66
     3144#: includes/installation/class-capabilities.php:87
    31453145msgid "Allows changing the placements page"
    31463146msgstr ""
    31473147
    3148 #: includes/installation/class-capabilities.php:72
     3148#: includes/installation/class-capabilities.php:93
    31493149msgid "Enables shortcode button"
    31503150msgstr ""
  • advanced-ads/trunk/packages/advanced-ads/framework/src/class-assets-registry.php

    r3035032 r3134733  
    1616/**
    1717 * Assets Registry.
     18 *
     19 * Script functions:
     20 *
     21 * @method void enqueue_script(string $handle)
     22 * @method void dequeue_script(string $handle)
     23 * @method void deregister_script(string $handle)
     24 * @method bool register_script(string $handle, string|false $src, string[] $deps = [], string|bool|null $ver = false, array|bool $args = [])
     25 * @method bool inline_script(string $handle, string $data, string $position = 'after')
     26 * @method bool is_script(string $handle, string $status = 'enqueued')
     27 *
     28 * Style functions:
     29 *
     30 * @method void enqueue_style(string $handle)
     31 * @method void dequeue_style(string $handle)
     32 * @method void deregister_style(string $handle)
     33 * @method bool register_style(string $handle, string|false $src, string[] $deps = [], string|bool|null $ver = false, string $media = 'all')
     34 * @method bool inline_style(string $handle, string $data, )
     35 * @method bool is_style(string $handle, string $status = 'enqueued')
    1836 */
    19 class Assets_Registry implements Integration_Interface {
     37abstract class Assets_Registry implements Integration_Interface {
    2038
    2139    /**
    22      * Version of plugin local asset.
     40     * Base URL for plugin local assets.
    2341     *
    24      * @var string
     42     * @return string
    2543     */
    26     const VERSION = '1.0.0';
     44    abstract public function get_base_url(): string;
    2745
    2846    /**
    2947     * Prefix to use in handle to make it unique.
    3048     *
    31      * @var string
     49     * @return string
    3250     */
    33     const PREFIX = 'advads';
     51    abstract public function get_prefix(): string;
    3452
    3553    /**
    36      * Enqueue stylesheet
    37      *
    38      * @param string $handle Name of the stylesheet.
    39      *
    40      * @return void
    41      */
    42     public static function enqueue_style( $handle ): void {
    43         wp_enqueue_style( self::prefix_it( $handle ) );
    44     }
    45 
    46     /**
    47      * Enqueue script
    48      *
    49      * @param string $handle Name of the script.
    50      *
    51      * @return void
    52      */
    53     public static function enqueue_script( $handle ): void {
    54         wp_enqueue_script( self::prefix_it( $handle ) );
    55     }
    56 
    57     /**
    58      * Prefix the handle
    59      *
    60      * @param string $handle Name of the asset.
     54     * Version for plugin local assets.
    6155     *
    6256     * @return string
    6357     */
    64     public static function prefix_it( $handle ): string {
    65         return self::PREFIX . '-' . $handle;
     58    abstract public function get_version(): string;
     59
     60    /**
     61     * Magic method to catch all calls to.
     62     *
     63     * @param string $name      The name of the method.
     64     * @param array  $arguments The arguments passed to the method.
     65     *
     66     * @return mixed
     67     */
     68    public function __call( $name, $arguments ) {
     69        if ( preg_match( '/^(enqueue|dequeue|register|deregister|is|inline)_(script|style)$/', $name, $matches ) ) {
     70            $action    = $matches[1];
     71            $type      = $matches[2];
     72            $handle    = $this->prefix_it( $arguments[0] );
     73            $func      = $this->resolve_function( $action . '_' . $type );
     74            $func_args = [ $handle ];
     75
     76            switch ( $action ) {
     77                case 'register':
     78                    $func_args[] = $this->resolve_url( $arguments[1] );
     79                    $func_args[] = $arguments[2] ?? [];
     80                    $func_args[] = isset( $arguments[3] ) && ! empty( $arguments[3] ) ? $arguments[3] : $this->get_version();
     81                    $func_args[] = $arguments[4] ?? ( 'script' === $type ? true : 'all' );
     82                    break;
     83                case 'is':
     84                    $func_args[] = $arguments[1] ?? 'enqueued';
     85                    break;
     86                case 'inline':
     87                    $func_args[] = $arguments[1] ?? '';
     88                    if ( 'script' === $type ) {
     89                        $func_args[] = $arguments[2] ?? 'after';
     90                    }
     91                    break;
     92                default:
     93                    break;
     94            }
     95
     96            return call_user_func_array( $func, $func_args );
     97        }
    6698    }
    6799
     
    72104     */
    73105    public function hooks(): void {
     106        add_action( 'wp_enqueue_scripts', [ $this, 'register_assets' ], 0 );
    74107        add_action( 'admin_enqueue_scripts', [ $this, 'register_assets' ], 0 );
    75108    }
     
    83116        $this->register_styles();
    84117        $this->register_scripts();
     118    }
     119
     120    /**
     121     * Prefix the handle
     122     *
     123     * @param string $handle Name of the asset.
     124     *
     125     * @return string
     126     */
     127    public function prefix_it( $handle ): string {
     128        return $this->get_prefix() . '-' . $handle;
    85129    }
    86130
     
    100144
    101145    /**
    102      * Register stylesheet
     146     * Resolves the URL.
    103147     *
    104      * @param string           $handle Name of the stylesheet. Should be unique.
    105      * @param string|bool      $src    URL of the stylesheet.
    106      * @param string[]         $deps   Optional. An array of registered stylesheet handles this stylesheet depends on.
    107      * @param string|bool|null $ver    Optional. String specifying stylesheet version number.
    108      * @param string           $media  Optional. The media for which this stylesheet has been defined.
     148     * If the provided URL is an absolute URL or protocol-relative URL, it is returned as is.
     149     * Otherwise, the base URL is prepended to the relative path.
    109150     *
    110      * @return void
     151     * @param string $src The source URL.
     152     *
     153     * @return string The resolved URL.
    111154     */
    112     private function register_style( $handle, $src, $deps = [], $ver = false, $media = 'all' ) {
    113         if ( false === $ver ) {
    114             $ver = self::VERSION;
     155    private function resolve_url( $src ): string {
     156        if ( preg_match( '/^(https?:)?\/\//', $src ) ) {
     157            return $src;
    115158        }
    116159
    117         wp_register_style( self::prefix_it( $handle ), ADVADS_BASE_URL . $src, $deps, $ver, $media );
     160        return $this->get_base_url() . $src;
    118161    }
    119162
    120163    /**
    121      * Register script
     164     * Resolves the function name.
    122165     *
    123      * @param string           $handle    Name of the stylesheet. Should be unique.
    124      * @param string|bool      $src       URL of the stylesheet.
    125      * @param string[]         $deps      Optional. An array of registered stylesheet handles this stylesheet depends on.
    126      * @param string|bool|null $ver       Optional. String specifying stylesheet version number.
    127      * @param bool             $in_footer Optional. The media for which this stylesheet has been defined.
     166     * @param string $name The name of the function.
    128167     *
    129      * @return void
     168     * @return string
    130169     */
    131     private function register_script( $handle, $src, $deps = [], $ver = false, $in_footer = false ) {
    132         if ( false === $ver ) {
    133             $ver = self::VERSION;
    134         }
     170    private function resolve_function( $name ): string {
     171        $method_map = [
     172            'is_script'     => 'script_is',
     173            'is_style'      => 'style_is',
     174            'inline_script' => 'add_inline_script',
     175            'inline_style'  => 'add_inline_style',
     176        ];
    135177
    136         $new_src = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? $src : str_replace( '.js', '.min.js', $src );
    137         wp_register_script( self::prefix_it( $handle ), ADVADS_BASE_URL . $src, $deps, $ver, $in_footer );
     178        $name = $method_map[ $name ] ?? $name;
     179
     180        return 'wp_' . $name;
    138181    }
    139182}
  • advanced-ads/trunk/packages/advanced-ads/framework/src/installation/class-install.php

    r2983598 r3134733  
    4949     */
    5050    public function activation( $network_wide = false ): void {
    51         register_uninstall_hook( $this->base_file, [ self::class, 'uninstall' ] );
     51        register_uninstall_hook( $this->base_file, [ static::class, 'uninstall' ] );
    5252
    5353        if ( ! is_multisite() || ! $network_wide ) {
  • advanced-ads/trunk/packages/advanced-ads/framework/src/notices/class-notice.php

    r2983598 r3134733  
    119119
    120120    /**
    121      * Serialize data.
     121     * Serialize data, for PHP version < 7.4.0
    122122     *
    123123     * @return string
     
    134134
    135135    /**
    136      * Unserialize string.
     136     * Return an array representing the serialized form the object. For PHP version >= 7.4.0
     137     *
     138     * @return array
     139     */
     140    public function __serialize(): array {
     141        return [
     142            'id'      => $this->id,
     143            'message' => $this->message,
     144            'options' => $this->options,
     145        ];
     146    }
     147
     148    /**
     149     * Recreate an instance of this class. For PHP version >= 7.4.0
     150     *
     151     * @param array $data the array returned by __serialize.
     152     *
     153     * @return void
     154     */
     155    public function __unserialize( $data ): void {}
     156
     157    /**
     158     * Unserialize string, for PHP version < 7.4.0
    137159     *
    138160     * @param string $data Data to unserialize.
  • advanced-ads/trunk/packages/advanced-ads/framework/src/utilities/class-formatting.php

    r3035032 r3134733  
    1616 */
    1717class Formatting {
     18
    1819    /**
    1920     * Converts a string (e.g. 'yes' or 'no') to a bool.
     
    8586    public static function clean( $value ) {
    8687        if ( is_array( $value ) ) {
    87             return array_map( [ sel::class, 'clean' ], $value );
     88            return array_map( [ self::class, 'clean' ], $value );
    8889        }
    8990
     
    142143        );
    143144    }
    144 
    145     /**
    146      * Wrapper for mb_strtoupper which see's if supported first.
    147      *
    148      * @param string $str String to format.
    149      *
    150      * @return string
    151      */
    152     public static function strtoupper( $str ) {
    153         $str = $str ?? '';
    154         return function_exists( 'mb_strtoupper' ) ? mb_strtoupper( $str ) : strtoupper( $str );
    155     }
    156 
    157     /**
    158      * Make a string lowercase.
    159      * Try to use mb_strtolower() when available.
    160      *
    161      * @param string $str String to format.
    162      *
    163      * @return string
    164      */
    165     public static function strtolower( $str ) {
    166         $str = $str ?? '';
    167         return function_exists( 'mb_strtolower' ) ? mb_strtolower( $str ) : strtolower( $str );
    168     }
    169 
    170     /**
    171      * Implode and escape HTML attributes for output.
    172      *
    173      * @param array $raw_attributes Attribute name value pairs.
    174      *
    175      * @return string
    176      */
    177     public static function join_html_attributes( $raw_attributes ) {
    178         $attributes = [];
    179         foreach ( $raw_attributes as $name => $value ) {
    180             $attributes[] = esc_attr( $name ) . '="' . esc_attr( $value ) . '"';
    181         }
    182 
    183         return implode( ' ', $attributes );
    184     }
    185145}
  • advanced-ads/trunk/packages/composer/LICENSE

    r2983598 r3134733  
    1 
    21Copyright (c) Nils Adermann, Jordi Boggiano
    32
     
    1918OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    2019THE SOFTWARE.
    21 
  • advanced-ads/trunk/packages/composer/autoload_classmap.php

    r3134243 r3134733  
    4747    'AdvancedAds\\Framework\\Notices\\Storage' => $vendorDir . '/advanced-ads/framework/src/notices/class-storage.php',
    4848    'AdvancedAds\\Framework\\Updates' => $vendorDir . '/advanced-ads/framework/src/class-updates.php',
    49     'AdvancedAds\\Framework\\Utilities\\Arr' => $vendorDir . '/advanced-ads/framework/src/utilities/class-array.php',
     49    'AdvancedAds\\Framework\\Utilities\\Arr' => $vendorDir . '/advanced-ads/framework/src/utilities/class-arr.php',
    5050    'AdvancedAds\\Framework\\Utilities\\Formatting' => $vendorDir . '/advanced-ads/framework/src/utilities/class-formatting.php',
     51    'AdvancedAds\\Framework\\Utilities\\HTML' => $vendorDir . '/advanced-ads/framework/src/utilities/class-html.php',
    5152    'AdvancedAds\\Framework\\Utilities\\Params' => $vendorDir . '/advanced-ads/framework/src/utilities/class-params.php',
    52     'AdvancedAds\\Framework\\Utilities\\Str' => $vendorDir . '/advanced-ads/framework/src/utilities/class-string.php',
     53    'AdvancedAds\\Framework\\Utilities\\Str' => $vendorDir . '/advanced-ads/framework/src/utilities/class-str.php',
    5354    'AdvancedAds\\Groups\\Manager' => $baseDir . '/includes/groups/class-manager.php',
    5455    'AdvancedAds\\Groups\\Types\\Grid' => $baseDir . '/includes/groups/types/type-grid.php',
  • advanced-ads/trunk/packages/composer/autoload_static.php

    r3134243 r3134733  
    7676        'AdvancedAds\\Framework\\Notices\\Storage' => __DIR__ . '/..' . '/advanced-ads/framework/src/notices/class-storage.php',
    7777        'AdvancedAds\\Framework\\Updates' => __DIR__ . '/..' . '/advanced-ads/framework/src/class-updates.php',
    78         'AdvancedAds\\Framework\\Utilities\\Arr' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-array.php',
     78        'AdvancedAds\\Framework\\Utilities\\Arr' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-arr.php',
    7979        'AdvancedAds\\Framework\\Utilities\\Formatting' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-formatting.php',
     80        'AdvancedAds\\Framework\\Utilities\\HTML' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-html.php',
    8081        'AdvancedAds\\Framework\\Utilities\\Params' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-params.php',
    81         'AdvancedAds\\Framework\\Utilities\\Str' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-string.php',
     82        'AdvancedAds\\Framework\\Utilities\\Str' => __DIR__ . '/..' . '/advanced-ads/framework/src/utilities/class-str.php',
    8283        'AdvancedAds\\Groups\\Manager' => __DIR__ . '/../..' . '/includes/groups/class-manager.php',
    8384        'AdvancedAds\\Groups\\Types\\Grid' => __DIR__ . '/../..' . '/includes/groups/types/type-grid.php',
  • advanced-ads/trunk/packages/composer/installed.json

    r3041809 r3134733  
    88                "type": "git",
    99                "url": "https://github.com/advanced-ads/framework.git",
    10                 "reference": "95e385daf3e3f11125711f43c5f7c437e00b075d"
     10                "reference": "9ceddbff73a7f588e29ab0172314b9a9a349546c"
    1111            },
    1212            "dist": {
    1313                "type": "zip",
    14                 "url": "https://api.github.com/repos/advanced-ads/framework/zipball/95e385daf3e3f11125711f43c5f7c437e00b075d",
    15                 "reference": "95e385daf3e3f11125711f43c5f7c437e00b075d",
     14                "url": "https://api.github.com/repos/advanced-ads/framework/zipball/9ceddbff73a7f588e29ab0172314b9a9a349546c",
     15                "reference": "9ceddbff73a7f588e29ab0172314b9a9a349546c",
    1616                "shasum": ""
    1717            },
     
    2323                "wp-coding-standards/wpcs": "^3.0.0"
    2424            },
    25             "time": "2023-12-18T07:33:42+00:00",
     25            "time": "2024-08-01T10:52:05+00:00",
    2626            "default-branch": true,
    2727            "type": "wordpress-plugin",
  • advanced-ads/trunk/packages/composer/installed.php

    r3050336 r3134733  
    44        'pretty_version' => '1.42.1',
    55        'version' => '1.42.1.0',
    6         'reference' => NULL,
     6        'reference' => null,
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '95e385daf3e3f11125711f43c5f7c437e00b075d',
     16            'reference' => '9ceddbff73a7f588e29ab0172314b9a9a349546c',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../advanced-ads/framework',
     
    3434            'pretty_version' => '1.42.1',
    3535            'version' => '1.42.1.0',
    36             'reference' => NULL,
     36            'reference' => null,
    3737            'type' => 'wordpress-plugin',
    3838            'install_path' => __DIR__ . '/../../',
  • advanced-ads/trunk/readme.txt

    r3134243 r3134733  
    55Tested up to: 6.5
    66Requires PHP: 7.2
    7 Stable tag: 1.53.0
     7Stable tag: 1.53.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    339339== Changelog ==
    340340
     341= 1.53.1 (August 13, 2024) =
     342
     343- Fix: resolve issue with deleting data on uninstall
     344- Fix: resolve JavaScript error when uninstall
     345
    341346= 1.53.0 (August 6, 2024) =
    342347
Note: See TracChangeset for help on using the changeset viewer.