Plugin Directory

Changeset 3422021


Ignore:
Timestamp:
12/17/2025 02:52:59 PM (4 months ago)
Author:
them.es
Message:

updated trunk

Location:
billy
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • billy/tags/2.1.0/billy.php

    r3422004 r3422021  
    133133
    134134/**
    135  * On admin init: Test compatibility.
    136  *
    137  * @return void
    138  */
    139 function billy_admin_init(): void {
     135 * On load:
     136 * 1. Test compatibility.
     137 * 2. Initialize plugin.
     138 *
     139 * @return void
     140 */
     141function billy_plugins_loaded(): void {
    140142    // TODO: Temporary workaround to fix a potential "Declaration of Billy_Pro::init() must be compatible with Billy::init(): void" fatal error on plugin activation!
    141     if ( defined( 'BILLY_PRO_PLUGIN_FILE' ) && version_compare( get_plugin_data( BILLY_PRO_PLUGIN_FILE )['Version'], '2.1.0', '<' ) ) {
    142         deactivate_plugins( plugin_basename( BILLY_PRO_PLUGIN_FILE ) );
    143 
    144         add_action( 'admin_notices', 'billy_pro_incompatible_admin_notice' );
    145         return;
     143    if ( defined( 'BILLY_PRO_PLUGIN_FILE' ) ) {
     144        $plugin_file = WP_PLUGIN_DIR . '/billy-pro/billy-pro.php';
     145
     146        if ( file_exists( $plugin_file ) ) {
     147            // Load the plugin's main file.
     148            require_once $plugin_file;
     149
     150            $content = file_get_contents( $plugin_file );
     151            preg_match( '/Version:\s*(.*)/', $content, $matches );
     152            $version = isset( $matches[1] ) ? trim( $matches[1] ) : false;
     153
     154            if ( version_compare( $version, '2.1.0', '<' ) ) {
     155                deactivate_plugins( plugin_basename( BILLY_PRO_PLUGIN_FILE ) );
     156
     157                add_action( 'admin_notices', 'billy_pro_incompatible_admin_notice' );
     158                return;
     159            }
     160        }
    146161    }
    147162
     
    170185        add_action( 'admin_notices', 'billy_temp_pdfdirectory_not_writable_admin_notice' );
    171186    }
    172 }
    173 add_action( 'admin_init', 'billy_admin_init', 998 );
    174 
    175 /**
    176  * On load: Initialize plugin.
    177  *
    178  * @return void
    179  */
    180 function billy_plugins_loaded(): void {
     187
    181188    // Initialize Classes.
    182189    include_once __DIR__ . '/inc/class-billy.php';
  • billy/trunk/billy.php

    r3422004 r3422021  
    133133
    134134/**
    135  * On admin init: Test compatibility.
    136  *
    137  * @return void
    138  */
    139 function billy_admin_init(): void {
     135 * On load:
     136 * 1. Test compatibility.
     137 * 2. Initialize plugin.
     138 *
     139 * @return void
     140 */
     141function billy_plugins_loaded(): void {
    140142    // TODO: Temporary workaround to fix a potential "Declaration of Billy_Pro::init() must be compatible with Billy::init(): void" fatal error on plugin activation!
    141     if ( defined( 'BILLY_PRO_PLUGIN_FILE' ) && version_compare( get_plugin_data( BILLY_PRO_PLUGIN_FILE )['Version'], '2.1.0', '<' ) ) {
    142         deactivate_plugins( plugin_basename( BILLY_PRO_PLUGIN_FILE ) );
    143 
    144         add_action( 'admin_notices', 'billy_pro_incompatible_admin_notice' );
    145         return;
     143    if ( defined( 'BILLY_PRO_PLUGIN_FILE' ) ) {
     144        $plugin_file = WP_PLUGIN_DIR . '/billy-pro/billy-pro.php';
     145
     146        if ( file_exists( $plugin_file ) ) {
     147            // Load the plugin's main file.
     148            require_once $plugin_file;
     149
     150            $content = file_get_contents( $plugin_file );
     151            preg_match( '/Version:\s*(.*)/', $content, $matches );
     152            $version = isset( $matches[1] ) ? trim( $matches[1] ) : false;
     153
     154            if ( version_compare( $version, '2.1.0', '<' ) ) {
     155                deactivate_plugins( plugin_basename( BILLY_PRO_PLUGIN_FILE ) );
     156
     157                add_action( 'admin_notices', 'billy_pro_incompatible_admin_notice' );
     158                return;
     159            }
     160        }
    146161    }
    147162
     
    170185        add_action( 'admin_notices', 'billy_temp_pdfdirectory_not_writable_admin_notice' );
    171186    }
    172 }
    173 add_action( 'admin_init', 'billy_admin_init', 998 );
    174 
    175 /**
    176  * On load: Initialize plugin.
    177  *
    178  * @return void
    179  */
    180 function billy_plugins_loaded(): void {
     187
    181188    // Initialize Classes.
    182189    include_once __DIR__ . '/inc/class-billy.php';
Note: See TracChangeset for help on using the changeset viewer.