Plugin Directory

Changeset 3253826


Ignore:
Timestamp:
03/11/2025 08:11:34 AM (12 months ago)
Author:
advancedads
Message:

Update to version 2.0.1 from GitHub

Location:
advanced-ads
Files:
16 edited
1 copied

Legend:

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

    r3253289 r3253826  
    1111 * @wordpress-plugin
    1212 * Plugin Name:       Advanced Ads
    13  * Version:           2.0.0
     13 * Version:           2.0.1
    1414 * Description:       Manage and optimize your ads in WordPress
    1515 * Plugin URI:        https://wpadvancedads.com
     
    3838
    3939define( 'ADVADS_FILE', __FILE__ );
    40 define( 'ADVADS_VERSION', '2.0.0' );
     40define( 'ADVADS_VERSION', '2.0.1' );
    4141
    4242// Load the autoloader.
  • advanced-ads/tags/2.0.1/includes/admin/class-version-control.php

    r3253289 r3253826  
    113113        }
    114114
    115         $info = $this->get_advanced_ads_info();
    116 
    117         if ( is_wp_error( $info ) ) {
    118             wp_send_json_error( $info->get_error_message() . '>>' . $info->get_error_message(), $info->get_error_code() );
    119         }
    120 
    121         $versions = $this->filter_version_number( $info['versions'] );
     115        $versions = $this->get_version_from_api();
     116
     117        if ( is_wp_error( $versions ) ) {
     118            wp_send_json_error( $versions->get_error_message() . '>>' . $versions->get_error_message(), $versions->get_error_code() );
     119        }
     120
     121        $versions = $this->filter_version_number( $versions );
    122122        set_transient( self::VERSIONS_TRANSIENT, $versions, 3 * HOUR_IN_SECONDS );
    123123        wp_send_json_success( $versions, 200 );
     
    145145     * @return array
    146146     */
    147     private function filter_version_number( $versions ) {
     147    public function filter_version_number( $versions ) {
    148148        $results = [];
    149149
     
    156156
    157157        $version_numbers = array_reverse( $version_numbers );
     158        array_shift( $version_numbers );
    158159
    159160        $major                 = '';
    160161        $minor                 = '';
    161         $minor_version_changes = -1;
    162         $major_version_changes = -1;
     162        $minor_version_changes = 0;
     163        $major_version_changes = 0;
    163164
    164165        foreach ( $version_numbers as $number ) {
    165             if ( false !== stripos( $number, 'rc' ) || false !== stripos( $number, 'alpha' ) || false !== stripos( $number, 'beta' ) ) {
    166                 // keep only production versions.
     166            // Skip pre-release versions.
     167            if ( preg_match( '/(rc|alpha|beta)/i', $number ) ) {
    167168                continue;
    168169            }
     170
    169171            $parts      = explode( '.', $number );
    170             $major_part = $parts[0];
    171             $minor_part = explode( '-', $parts[1] )[0];
     172            $major_part = $parts[1];
     173            $minor_part = $parts[2];
    172174
    173175            if ( $major !== $major_part ) {
    174176                $major = $major_part;
    175177                ++$major_version_changes;
     178                $minor_version_changes = 0;
    176179            }
    177180
     
    181184            }
    182185
    183             if ( self::MINOR_VERSION_COUNT >= $minor_version_changes || 1 === $major_version_changes ) {
     186            if ( $minor_version_changes <= self::MINOR_VERSION_COUNT ) {
    184187                $results[ $number ] = $versions[ $number ];
    185188            }
    186189
    187             if ( self::MINOR_VERSION_COUNT > $major_version_changes && 1 === $major_version_changes ) {
     190            if ( $major_version_changes >= self::MINOR_VERSION_COUNT ) {
    188191                break;
    189192            }
     
    201204     * @return array|\WP_Error
    202205     */
    203     private function get_advanced_ads_info() {
     206    private function get_version_from_api() {
    204207        $aa_info = wp_remote_get( 'https://api.wordpress.org/plugins/info/1.0/advanced-ads.json' );
    205208
     
    211214
    212215        if ( $info['versions'] ) {
    213             return $info;
     216            return $info['versions'];
    214217        }
    215218
  • advanced-ads/tags/2.0.1/includes/installation/class-compatibility.php

    r3253289 r3253826  
    2727     */
    2828    public function hooks(): void {
    29         add_action( 'plugin_loaded', [ $this, 'deactivate_plugins' ], 0 );
     29        if ( is_admin() ) {
     30            add_action( 'plugin_loaded', [ $this, 'deactivate_plugins' ], 0 );
     31        }
    3032        add_filter( 'upgrader_post_install', [ $this, 'upgrader_post_install' ], 10, 3 );
    3133    }
     
    5456     */
    5557    public function deactivate_plugins(): void {
     58        // Early bail!!
     59        if ( get_option( 'advanced-ads-2-compatibility-flag' ) ) {
     60            return;
     61        }
     62
    5663        $plugins = WordPress::get_wp_plugins();
    5764        foreach ( Constants::ADDONS_NON_COMPATIBLE_VERSIONS as $version => $slug ) {
  • advanced-ads/tags/2.0.1/includes/utilities/class-wordpress.php

    r3253289 r3253826  
    113113     */
    114114    public static function get_svg( $file, $folder = '/assets/img/' ): string {
    115         $file_url = ADVADS_BASE_URL . $folder . $file;
    116 
    117         return file_get_contents( $file_url ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
     115        $file_path = \untrailingslashit( ADVADS_ABSPATH ) . $folder . $file;
     116
     117        if ( file_exists( $file_path ) ) {
     118            ob_start();
     119            include $file_path;
     120            return ob_get_clean();
     121        }
     122
     123        return '';
    118124    }
    119125
  • advanced-ads/tags/2.0.1/packages/advanced-ads/framework/src/class-updates.php

    r3253289 r3253826  
    126126        foreach ( $this->get_updates() as $version => $path ) {
    127127            if ( version_compare( $installed_version, $version, '<' ) ) {
    128                 include $this->get_folder() . $path;
     128                require_once $this->get_folder() . $path;
    129129                $this->save_version( $version );
    130130            }
  • advanced-ads/tags/2.0.1/packages/composer/installed.json

    r3253289 r3253826  
    88                "type": "git",
    99                "url": "https://github.com/advanced-ads/framework.git",
    10                 "reference": "364c1de99e6e0e789857bc20ea97a2cc2970b4e1"
     10                "reference": "bafe2c32b1530cfb18d8b738adb9524f8406b9aa"
    1111            },
    1212            "dist": {
    1313                "type": "zip",
    14                 "url": "https://api.github.com/repos/advanced-ads/framework/zipball/364c1de99e6e0e789857bc20ea97a2cc2970b4e1",
    15                 "reference": "364c1de99e6e0e789857bc20ea97a2cc2970b4e1",
     14                "url": "https://api.github.com/repos/advanced-ads/framework/zipball/bafe2c32b1530cfb18d8b738adb9524f8406b9aa",
     15                "reference": "bafe2c32b1530cfb18d8b738adb9524f8406b9aa",
    1616                "shasum": ""
    1717            },
     
    2323                "wp-coding-standards/wpcs": "^3.0.0"
    2424            },
    25             "time": "2025-02-28T10:58:24+00:00",
     25            "time": "2025-03-10T12:31:18+00:00",
    2626            "default-branch": true,
    2727            "type": "wordpress-plugin",
  • advanced-ads/tags/2.0.1/packages/composer/installed.php

    r3253289 r3253826  
    2323            'pretty_version' => 'dev-main',
    2424            'version' => 'dev-main',
    25             'reference' => '364c1de99e6e0e789857bc20ea97a2cc2970b4e1',
     25            'reference' => 'bafe2c32b1530cfb18d8b738adb9524f8406b9aa',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../advanced-ads/framework',
  • advanced-ads/tags/2.0.1/readme.txt

    r3253289 r3253826  
    55Tested up to: 6.7
    66Requires PHP: 7.4
    7 Stable tag: 2.0.0
     7Stable tag: 2.0.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    357357== Changelog ==
    358358
     359= 2.0.1 (March 11, 2025) =
     360
     361- Improvement: reduce high CPU usage in the frontend
     362- Fix: correct a fatal error from a function declared multiple times during activation
     363- Fix: correct the version numbers in the rollback function dropdown
     364- Fix: resolve a PHP warning in the backend when file_get_contents is disabled
     365
    359366= 2.0.0 (March 10, 2025) =
    360367
  • advanced-ads/trunk/advanced-ads.php

    r3253289 r3253826  
    1111 * @wordpress-plugin
    1212 * Plugin Name:       Advanced Ads
    13  * Version:           2.0.0
     13 * Version:           2.0.1
    1414 * Description:       Manage and optimize your ads in WordPress
    1515 * Plugin URI:        https://wpadvancedads.com
     
    3838
    3939define( 'ADVADS_FILE', __FILE__ );
    40 define( 'ADVADS_VERSION', '2.0.0' );
     40define( 'ADVADS_VERSION', '2.0.1' );
    4141
    4242// Load the autoloader.
  • advanced-ads/trunk/includes/admin/class-version-control.php

    r3253289 r3253826  
    113113        }
    114114
    115         $info = $this->get_advanced_ads_info();
    116 
    117         if ( is_wp_error( $info ) ) {
    118             wp_send_json_error( $info->get_error_message() . '>>' . $info->get_error_message(), $info->get_error_code() );
    119         }
    120 
    121         $versions = $this->filter_version_number( $info['versions'] );
     115        $versions = $this->get_version_from_api();
     116
     117        if ( is_wp_error( $versions ) ) {
     118            wp_send_json_error( $versions->get_error_message() . '>>' . $versions->get_error_message(), $versions->get_error_code() );
     119        }
     120
     121        $versions = $this->filter_version_number( $versions );
    122122        set_transient( self::VERSIONS_TRANSIENT, $versions, 3 * HOUR_IN_SECONDS );
    123123        wp_send_json_success( $versions, 200 );
     
    145145     * @return array
    146146     */
    147     private function filter_version_number( $versions ) {
     147    public function filter_version_number( $versions ) {
    148148        $results = [];
    149149
     
    156156
    157157        $version_numbers = array_reverse( $version_numbers );
     158        array_shift( $version_numbers );
    158159
    159160        $major                 = '';
    160161        $minor                 = '';
    161         $minor_version_changes = -1;
    162         $major_version_changes = -1;
     162        $minor_version_changes = 0;
     163        $major_version_changes = 0;
    163164
    164165        foreach ( $version_numbers as $number ) {
    165             if ( false !== stripos( $number, 'rc' ) || false !== stripos( $number, 'alpha' ) || false !== stripos( $number, 'beta' ) ) {
    166                 // keep only production versions.
     166            // Skip pre-release versions.
     167            if ( preg_match( '/(rc|alpha|beta)/i', $number ) ) {
    167168                continue;
    168169            }
     170
    169171            $parts      = explode( '.', $number );
    170             $major_part = $parts[0];
    171             $minor_part = explode( '-', $parts[1] )[0];
     172            $major_part = $parts[1];
     173            $minor_part = $parts[2];
    172174
    173175            if ( $major !== $major_part ) {
    174176                $major = $major_part;
    175177                ++$major_version_changes;
     178                $minor_version_changes = 0;
    176179            }
    177180
     
    181184            }
    182185
    183             if ( self::MINOR_VERSION_COUNT >= $minor_version_changes || 1 === $major_version_changes ) {
     186            if ( $minor_version_changes <= self::MINOR_VERSION_COUNT ) {
    184187                $results[ $number ] = $versions[ $number ];
    185188            }
    186189
    187             if ( self::MINOR_VERSION_COUNT > $major_version_changes && 1 === $major_version_changes ) {
     190            if ( $major_version_changes >= self::MINOR_VERSION_COUNT ) {
    188191                break;
    189192            }
     
    201204     * @return array|\WP_Error
    202205     */
    203     private function get_advanced_ads_info() {
     206    private function get_version_from_api() {
    204207        $aa_info = wp_remote_get( 'https://api.wordpress.org/plugins/info/1.0/advanced-ads.json' );
    205208
     
    211214
    212215        if ( $info['versions'] ) {
    213             return $info;
     216            return $info['versions'];
    214217        }
    215218
  • advanced-ads/trunk/includes/installation/class-compatibility.php

    r3253289 r3253826  
    2727     */
    2828    public function hooks(): void {
    29         add_action( 'plugin_loaded', [ $this, 'deactivate_plugins' ], 0 );
     29        if ( is_admin() ) {
     30            add_action( 'plugin_loaded', [ $this, 'deactivate_plugins' ], 0 );
     31        }
    3032        add_filter( 'upgrader_post_install', [ $this, 'upgrader_post_install' ], 10, 3 );
    3133    }
     
    5456     */
    5557    public function deactivate_plugins(): void {
     58        // Early bail!!
     59        if ( get_option( 'advanced-ads-2-compatibility-flag' ) ) {
     60            return;
     61        }
     62
    5663        $plugins = WordPress::get_wp_plugins();
    5764        foreach ( Constants::ADDONS_NON_COMPATIBLE_VERSIONS as $version => $slug ) {
  • advanced-ads/trunk/includes/utilities/class-wordpress.php

    r3253289 r3253826  
    113113     */
    114114    public static function get_svg( $file, $folder = '/assets/img/' ): string {
    115         $file_url = ADVADS_BASE_URL . $folder . $file;
    116 
    117         return file_get_contents( $file_url ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
     115        $file_path = \untrailingslashit( ADVADS_ABSPATH ) . $folder . $file;
     116
     117        if ( file_exists( $file_path ) ) {
     118            ob_start();
     119            include $file_path;
     120            return ob_get_clean();
     121        }
     122
     123        return '';
    118124    }
    119125
  • advanced-ads/trunk/packages/advanced-ads/framework/src/class-updates.php

    r3253289 r3253826  
    126126        foreach ( $this->get_updates() as $version => $path ) {
    127127            if ( version_compare( $installed_version, $version, '<' ) ) {
    128                 include $this->get_folder() . $path;
     128                require_once $this->get_folder() . $path;
    129129                $this->save_version( $version );
    130130            }
  • advanced-ads/trunk/packages/composer/installed.json

    r3253289 r3253826  
    88                "type": "git",
    99                "url": "https://github.com/advanced-ads/framework.git",
    10                 "reference": "364c1de99e6e0e789857bc20ea97a2cc2970b4e1"
     10                "reference": "bafe2c32b1530cfb18d8b738adb9524f8406b9aa"
    1111            },
    1212            "dist": {
    1313                "type": "zip",
    14                 "url": "https://api.github.com/repos/advanced-ads/framework/zipball/364c1de99e6e0e789857bc20ea97a2cc2970b4e1",
    15                 "reference": "364c1de99e6e0e789857bc20ea97a2cc2970b4e1",
     14                "url": "https://api.github.com/repos/advanced-ads/framework/zipball/bafe2c32b1530cfb18d8b738adb9524f8406b9aa",
     15                "reference": "bafe2c32b1530cfb18d8b738adb9524f8406b9aa",
    1616                "shasum": ""
    1717            },
     
    2323                "wp-coding-standards/wpcs": "^3.0.0"
    2424            },
    25             "time": "2025-02-28T10:58:24+00:00",
     25            "time": "2025-03-10T12:31:18+00:00",
    2626            "default-branch": true,
    2727            "type": "wordpress-plugin",
  • advanced-ads/trunk/packages/composer/installed.php

    r3253289 r3253826  
    2323            'pretty_version' => 'dev-main',
    2424            'version' => 'dev-main',
    25             'reference' => '364c1de99e6e0e789857bc20ea97a2cc2970b4e1',
     25            'reference' => 'bafe2c32b1530cfb18d8b738adb9524f8406b9aa',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../advanced-ads/framework',
  • advanced-ads/trunk/readme.txt

    r3253289 r3253826  
    55Tested up to: 6.7
    66Requires PHP: 7.4
    7 Stable tag: 2.0.0
     7Stable tag: 2.0.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    357357== Changelog ==
    358358
     359= 2.0.1 (March 11, 2025) =
     360
     361- Improvement: reduce high CPU usage in the frontend
     362- Fix: correct a fatal error from a function declared multiple times during activation
     363- Fix: correct the version numbers in the rollback function dropdown
     364- Fix: resolve a PHP warning in the backend when file_get_contents is disabled
     365
    359366= 2.0.0 (March 10, 2025) =
    360367
Note: See TracChangeset for help on using the changeset viewer.