Plugin Directory

Changeset 3317324


Ignore:
Timestamp:
06/25/2025 04:48:41 AM (7 months ago)
Author:
cartpauj
Message:

Update to version 1.1.5 from GitHub

Location:
php-constants-manager
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • php-constants-manager/assets/icon-128x128.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • php-constants-manager/assets/icon-256x256.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • php-constants-manager/tags/1.1.5/php-constants-manager.php

    r3317261 r3317324  
    44 * Plugin URI: https://github.com/cartpauj/php-constants-manager
    55 * Description: Safely manage PHP constants (defines) through the WordPress admin interface
    6  * Version: 1.1.4
     6 * Version: 1.1.5
    77 * Author: cartpauj
    88 * Author URI: https://github.com/cartpauj/
     
    7575        //add_action('init', array($this, 'init'));
    7676        add_action('admin_init', array($this, 'handle_admin_actions'));
     77        add_action('admin_init', array($this, 'migrate_mu_plugin_filename'));
    7778        add_action('admin_menu', array($this, 'add_admin_menu'));
    7879        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_assets'));
     
    825826     */
    826827    private function mu_plugin_exists() {
    827         $mu_plugin_path = WPMU_PLUGIN_DIR . '/php-constants-manager-early.php';
     828        $mu_plugin_path = WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php';
    828829        return file_exists($mu_plugin_path);
    829830    }
     
    838839        }
    839840       
    840         $mu_plugin_path = WPMU_PLUGIN_DIR . '/php-constants-manager-early.php';
     841        $mu_plugin_path = WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php';
    841842       
    842843        // Generate static must-use plugin content that queries the database
     
    946947     */
    947948    private function remove_mu_plugin() {
    948         $mu_plugin_path = WPMU_PLUGIN_DIR . '/php-constants-manager-early.php';
     949        $mu_plugin_path = WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php';
    949950       
    950951        if (!file_exists($mu_plugin_path)) {
     
    959960       
    960961        return $wp_filesystem->delete($mu_plugin_path);
     962    }
     963   
     964    /**
     965     * Migrate old must-use plugin filename to new naming convention
     966     */
     967    public function migrate_mu_plugin_filename() {
     968        // Only run for admin users
     969        if (!current_user_can('manage_options')) {
     970            return;
     971        }
     972       
     973        $old_mu_plugin_path = WPMU_PLUGIN_DIR . '/php-constants-manager-early.php';
     974        $new_mu_plugin_path = WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php';
     975       
     976        // Check if old file exists and new file doesn't exist
     977        if (file_exists($old_mu_plugin_path) && !file_exists($new_mu_plugin_path)) {
     978            global $wp_filesystem;
     979            if (empty($wp_filesystem)) {
     980                require_once(ABSPATH . '/wp-admin/includes/file.php');
     981                WP_Filesystem();
     982            }
     983           
     984            // Rename the file quietly
     985            $wp_filesystem->move($old_mu_plugin_path, $new_mu_plugin_path);
     986        }
    961987    }
    962988   
  • php-constants-manager/tags/1.1.5/readme.txt

    r3317311 r3317324  
    11=== PHP Constants Manager ===
    22Contributors: cartpauj
    3 Tags: constants, php, developer, admin, defines
     3Tags: constants, php, configuration, admin, defines
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 1.1.4
     6Stable tag: 1.1.5
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    176176
    177177== Changelog ==
     178= 1.1.5 =
     179* Renamed must-use plugin to attempt to get it to load earlier than other must-use plugins
     180
    178181= 1.1.4 =
    179182* Security hardening
  • php-constants-manager/tags/1.1.5/views/admin/help.php

    r3317261 r3317324  
    514514        <p><strong><?php esc_html_e('Note:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Replace "wp_" with your actual WordPress table prefix if different.', 'php-constants-manager'); ?></p>
    515515       
     516        <h3><?php esc_html_e('Early Loading Setup Failed', 'php-constants-manager'); ?></h3>
     517        <p><?php esc_html_e('If the automatic Early Loading setup fails in Settings, you can manually create the must-use plugin file:', 'php-constants-manager'); ?></p>
     518       
     519        <h4><?php esc_html_e('Manual Must-Use Plugin Creation', 'php-constants-manager'); ?></h4>
     520        <ol>
     521            <li><strong><?php esc_html_e('Create Directory:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Ensure the mu-plugins directory exists:', 'php-constants-manager'); ?> <code>wp-content/mu-plugins/</code></li>
     522            <li><strong><?php esc_html_e('Create File:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Create a new file named:', 'php-constants-manager'); ?> <code>0001-php-constants-manager-early.php</code></li>
     523            <li><strong><?php esc_html_e('Add Content:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Copy the following code into the file:', 'php-constants-manager'); ?></li>
     524        </ol>
     525       
     526        <h4><?php esc_html_e('Must-Use Plugin Code', 'php-constants-manager'); ?></h4>
     527        <p><strong><?php esc_html_e('File:', 'php-constants-manager'); ?></strong> <code>wp-content/mu-plugins/0001-php-constants-manager-early.php</code></p>
     528        <pre><code>&lt;?php
     529/**
     530 * PHP Constants Manager - Early Loading
     531 * This file loads constants from PHP Constants Manager before other plugins
     532 * DO NOT EDIT - Managed by PHP Constants Manager plugin
     533 */
     534
     535// Prevent direct access
     536if (!defined('ABSPATH')) {
     537    exit;
     538}
     539
     540// Load PHP Constants Manager constants early
     541function phpcm_load_early_constants() {
     542    global $wpdb;
     543   
     544    // Initialize the global array
     545    $GLOBALS['phpcm_early_defined_constants'] = array();
     546   
     547    // Get the table name
     548    $table_name = $wpdb->prefix . 'phpcm_constants';
     549   
     550    // Check if table exists
     551    if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") !== $table_name) {
     552        return;
     553    }
     554   
     555    // Get active constants
     556    $constants = $wpdb->get_results(
     557        "SELECT name, value, type FROM $table_name WHERE is_active = 1"
     558    );
     559   
     560    if (empty($constants)) {
     561        return;
     562    }
     563   
     564    // Track which constants we successfully define
     565    $phpcm_early_defined = array();
     566   
     567    foreach ($constants as $constant) {
     568        if (!defined($constant->name)) {
     569            $value = $constant->value;
     570           
     571            switch ($constant->type) {
     572                case 'boolean':
     573                    if (is_string($value)) {
     574                        $lower_value = strtolower(trim($value));
     575                        if (in_array($lower_value, ['true', '1', 'yes', 'on'], true)) {
     576                            $value = true;
     577                        } elseif (in_array($lower_value, ['false', '0', 'no', 'off', ''], true)) {
     578                            $value = false;
     579                        } else {
     580                            $value = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
     581                            if ($value === null) {
     582                                $value = false;
     583                            }
     584                        }
     585                    } elseif (is_numeric($value)) {
     586                        $value = (bool)intval($value);
     587                    } else {
     588                        $value = (bool)$value;
     589                    }
     590                    break;
     591                case 'integer':
     592                    if (is_numeric($value)) {
     593                        $value = intval($value);
     594                    } else {
     595                        $value = 0;
     596                    }
     597                    break;
     598                case 'float':
     599                    if (is_numeric($value)) {
     600                        $value = floatval($value);
     601                    } else {
     602                        $value = 0.0;
     603                    }
     604                    break;
     605                case 'null':
     606                    $value = null;
     607                    break;
     608            }
     609           
     610            define($constant->name, $value);
     611            $phpcm_early_defined[] = $constant->name;
     612        }
     613    }
     614   
     615    // Store the list for the main plugin to check
     616    $GLOBALS['phpcm_early_defined_constants'] = $phpcm_early_defined;
     617}
     618
     619// Load constants
     620phpcm_load_early_constants();</code></pre>
     621       
     622        <h4><?php esc_html_e('Important Notes', 'php-constants-manager'); ?></h4>
     623        <ul>
     624            <li><strong><?php esc_html_e('Filename Format:', 'php-constants-manager'); ?></strong> <?php esc_html_e('The "0001-" prefix ensures this file loads before other must-use plugins', 'php-constants-manager'); ?></li>
     625            <li><strong><?php esc_html_e('File Permissions:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Ensure the file is readable by your web server (typically 644)', 'php-constants-manager'); ?></li>
     626            <li><strong><?php esc_html_e('Table Prefix:', 'php-constants-manager'); ?></strong> <?php esc_html_e('The code automatically uses your WordPress table prefix', 'php-constants-manager'); ?></li>
     627            <li><strong><?php esc_html_e('Settings Integration:', 'php-constants-manager'); ?></strong> <?php esc_html_e('After manual creation, visit Settings and check "Enable early loading" to sync the plugin state with the file', 'php-constants-manager'); ?></li>
     628        </ul>
     629       
     630        <h4><?php esc_html_e('Common Issues', 'php-constants-manager'); ?></h4>
     631        <ul>
     632            <li><strong><?php esc_html_e('Permission Denied:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Contact your hosting provider to create the mu-plugins directory and set proper permissions', 'php-constants-manager'); ?></li>
     633            <li><strong><?php esc_html_e('File Not Loading:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Verify the filename is exactly: 0001-php-constants-manager-early.php', 'php-constants-manager'); ?></li>
     634            <li><strong><?php esc_html_e('PHP Errors:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Check that the file content was copied correctly without any extra characters', 'php-constants-manager'); ?></li>
     635        </ul>
     636
    516637        <h3><?php esc_html_e('Need More Help?', 'php-constants-manager'); ?></h3>
    517638        <p><?php esc_html_e('Use the "All Constants" page to see every constant currently defined in your WordPress installation. This can help you understand what\'s already taken and avoid conflicts.', 'php-constants-manager'); ?></p>
  • php-constants-manager/tags/1.1.5/views/admin/settings.php

    r3317261 r3317324  
    5353                        break;
    5454                    case 'mu_plugin_remove_failed':
    55                         esc_html_e('Failed to remove the must-use plugin file. Please manually delete the file at wp-content/mu-plugins/php-constants-manager-early.php', 'php-constants-manager');
     55                        esc_html_e('Failed to remove the must-use plugin file. Please manually delete the file at wp-content/mu-plugins/0001-php-constants-manager-early.php', 'php-constants-manager');
    5656                        break;
    5757                    default:
     
    9191                                        <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
    9292                                        <?php esc_html_e('Must-use plugin file exists:', 'php-constants-manager'); ?>
    93                                         <code><?php echo esc_html(WPMU_PLUGIN_DIR . '/php-constants-manager-early.php'); ?></code>
     93                                        <code><?php echo esc_html(WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php'); ?></code>
    9494                                    </p>
    9595                                <?php else: ?>
  • php-constants-manager/trunk/php-constants-manager.php

    r3317261 r3317324  
    44 * Plugin URI: https://github.com/cartpauj/php-constants-manager
    55 * Description: Safely manage PHP constants (defines) through the WordPress admin interface
    6  * Version: 1.1.4
     6 * Version: 1.1.5
    77 * Author: cartpauj
    88 * Author URI: https://github.com/cartpauj/
     
    7575        //add_action('init', array($this, 'init'));
    7676        add_action('admin_init', array($this, 'handle_admin_actions'));
     77        add_action('admin_init', array($this, 'migrate_mu_plugin_filename'));
    7778        add_action('admin_menu', array($this, 'add_admin_menu'));
    7879        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_assets'));
     
    825826     */
    826827    private function mu_plugin_exists() {
    827         $mu_plugin_path = WPMU_PLUGIN_DIR . '/php-constants-manager-early.php';
     828        $mu_plugin_path = WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php';
    828829        return file_exists($mu_plugin_path);
    829830    }
     
    838839        }
    839840       
    840         $mu_plugin_path = WPMU_PLUGIN_DIR . '/php-constants-manager-early.php';
     841        $mu_plugin_path = WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php';
    841842       
    842843        // Generate static must-use plugin content that queries the database
     
    946947     */
    947948    private function remove_mu_plugin() {
    948         $mu_plugin_path = WPMU_PLUGIN_DIR . '/php-constants-manager-early.php';
     949        $mu_plugin_path = WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php';
    949950       
    950951        if (!file_exists($mu_plugin_path)) {
     
    959960       
    960961        return $wp_filesystem->delete($mu_plugin_path);
     962    }
     963   
     964    /**
     965     * Migrate old must-use plugin filename to new naming convention
     966     */
     967    public function migrate_mu_plugin_filename() {
     968        // Only run for admin users
     969        if (!current_user_can('manage_options')) {
     970            return;
     971        }
     972       
     973        $old_mu_plugin_path = WPMU_PLUGIN_DIR . '/php-constants-manager-early.php';
     974        $new_mu_plugin_path = WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php';
     975       
     976        // Check if old file exists and new file doesn't exist
     977        if (file_exists($old_mu_plugin_path) && !file_exists($new_mu_plugin_path)) {
     978            global $wp_filesystem;
     979            if (empty($wp_filesystem)) {
     980                require_once(ABSPATH . '/wp-admin/includes/file.php');
     981                WP_Filesystem();
     982            }
     983           
     984            // Rename the file quietly
     985            $wp_filesystem->move($old_mu_plugin_path, $new_mu_plugin_path);
     986        }
    961987    }
    962988   
  • php-constants-manager/trunk/readme.txt

    r3317311 r3317324  
    11=== PHP Constants Manager ===
    22Contributors: cartpauj
    3 Tags: constants, php, developer, admin, defines
     3Tags: constants, php, configuration, admin, defines
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 1.1.4
     6Stable tag: 1.1.5
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    176176
    177177== Changelog ==
     178= 1.1.5 =
     179* Renamed must-use plugin to attempt to get it to load earlier than other must-use plugins
     180
    178181= 1.1.4 =
    179182* Security hardening
  • php-constants-manager/trunk/views/admin/help.php

    r3317261 r3317324  
    514514        <p><strong><?php esc_html_e('Note:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Replace "wp_" with your actual WordPress table prefix if different.', 'php-constants-manager'); ?></p>
    515515       
     516        <h3><?php esc_html_e('Early Loading Setup Failed', 'php-constants-manager'); ?></h3>
     517        <p><?php esc_html_e('If the automatic Early Loading setup fails in Settings, you can manually create the must-use plugin file:', 'php-constants-manager'); ?></p>
     518       
     519        <h4><?php esc_html_e('Manual Must-Use Plugin Creation', 'php-constants-manager'); ?></h4>
     520        <ol>
     521            <li><strong><?php esc_html_e('Create Directory:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Ensure the mu-plugins directory exists:', 'php-constants-manager'); ?> <code>wp-content/mu-plugins/</code></li>
     522            <li><strong><?php esc_html_e('Create File:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Create a new file named:', 'php-constants-manager'); ?> <code>0001-php-constants-manager-early.php</code></li>
     523            <li><strong><?php esc_html_e('Add Content:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Copy the following code into the file:', 'php-constants-manager'); ?></li>
     524        </ol>
     525       
     526        <h4><?php esc_html_e('Must-Use Plugin Code', 'php-constants-manager'); ?></h4>
     527        <p><strong><?php esc_html_e('File:', 'php-constants-manager'); ?></strong> <code>wp-content/mu-plugins/0001-php-constants-manager-early.php</code></p>
     528        <pre><code>&lt;?php
     529/**
     530 * PHP Constants Manager - Early Loading
     531 * This file loads constants from PHP Constants Manager before other plugins
     532 * DO NOT EDIT - Managed by PHP Constants Manager plugin
     533 */
     534
     535// Prevent direct access
     536if (!defined('ABSPATH')) {
     537    exit;
     538}
     539
     540// Load PHP Constants Manager constants early
     541function phpcm_load_early_constants() {
     542    global $wpdb;
     543   
     544    // Initialize the global array
     545    $GLOBALS['phpcm_early_defined_constants'] = array();
     546   
     547    // Get the table name
     548    $table_name = $wpdb->prefix . 'phpcm_constants';
     549   
     550    // Check if table exists
     551    if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") !== $table_name) {
     552        return;
     553    }
     554   
     555    // Get active constants
     556    $constants = $wpdb->get_results(
     557        "SELECT name, value, type FROM $table_name WHERE is_active = 1"
     558    );
     559   
     560    if (empty($constants)) {
     561        return;
     562    }
     563   
     564    // Track which constants we successfully define
     565    $phpcm_early_defined = array();
     566   
     567    foreach ($constants as $constant) {
     568        if (!defined($constant->name)) {
     569            $value = $constant->value;
     570           
     571            switch ($constant->type) {
     572                case 'boolean':
     573                    if (is_string($value)) {
     574                        $lower_value = strtolower(trim($value));
     575                        if (in_array($lower_value, ['true', '1', 'yes', 'on'], true)) {
     576                            $value = true;
     577                        } elseif (in_array($lower_value, ['false', '0', 'no', 'off', ''], true)) {
     578                            $value = false;
     579                        } else {
     580                            $value = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
     581                            if ($value === null) {
     582                                $value = false;
     583                            }
     584                        }
     585                    } elseif (is_numeric($value)) {
     586                        $value = (bool)intval($value);
     587                    } else {
     588                        $value = (bool)$value;
     589                    }
     590                    break;
     591                case 'integer':
     592                    if (is_numeric($value)) {
     593                        $value = intval($value);
     594                    } else {
     595                        $value = 0;
     596                    }
     597                    break;
     598                case 'float':
     599                    if (is_numeric($value)) {
     600                        $value = floatval($value);
     601                    } else {
     602                        $value = 0.0;
     603                    }
     604                    break;
     605                case 'null':
     606                    $value = null;
     607                    break;
     608            }
     609           
     610            define($constant->name, $value);
     611            $phpcm_early_defined[] = $constant->name;
     612        }
     613    }
     614   
     615    // Store the list for the main plugin to check
     616    $GLOBALS['phpcm_early_defined_constants'] = $phpcm_early_defined;
     617}
     618
     619// Load constants
     620phpcm_load_early_constants();</code></pre>
     621       
     622        <h4><?php esc_html_e('Important Notes', 'php-constants-manager'); ?></h4>
     623        <ul>
     624            <li><strong><?php esc_html_e('Filename Format:', 'php-constants-manager'); ?></strong> <?php esc_html_e('The "0001-" prefix ensures this file loads before other must-use plugins', 'php-constants-manager'); ?></li>
     625            <li><strong><?php esc_html_e('File Permissions:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Ensure the file is readable by your web server (typically 644)', 'php-constants-manager'); ?></li>
     626            <li><strong><?php esc_html_e('Table Prefix:', 'php-constants-manager'); ?></strong> <?php esc_html_e('The code automatically uses your WordPress table prefix', 'php-constants-manager'); ?></li>
     627            <li><strong><?php esc_html_e('Settings Integration:', 'php-constants-manager'); ?></strong> <?php esc_html_e('After manual creation, visit Settings and check "Enable early loading" to sync the plugin state with the file', 'php-constants-manager'); ?></li>
     628        </ul>
     629       
     630        <h4><?php esc_html_e('Common Issues', 'php-constants-manager'); ?></h4>
     631        <ul>
     632            <li><strong><?php esc_html_e('Permission Denied:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Contact your hosting provider to create the mu-plugins directory and set proper permissions', 'php-constants-manager'); ?></li>
     633            <li><strong><?php esc_html_e('File Not Loading:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Verify the filename is exactly: 0001-php-constants-manager-early.php', 'php-constants-manager'); ?></li>
     634            <li><strong><?php esc_html_e('PHP Errors:', 'php-constants-manager'); ?></strong> <?php esc_html_e('Check that the file content was copied correctly without any extra characters', 'php-constants-manager'); ?></li>
     635        </ul>
     636
    516637        <h3><?php esc_html_e('Need More Help?', 'php-constants-manager'); ?></h3>
    517638        <p><?php esc_html_e('Use the "All Constants" page to see every constant currently defined in your WordPress installation. This can help you understand what\'s already taken and avoid conflicts.', 'php-constants-manager'); ?></p>
  • php-constants-manager/trunk/views/admin/settings.php

    r3317261 r3317324  
    5353                        break;
    5454                    case 'mu_plugin_remove_failed':
    55                         esc_html_e('Failed to remove the must-use plugin file. Please manually delete the file at wp-content/mu-plugins/php-constants-manager-early.php', 'php-constants-manager');
     55                        esc_html_e('Failed to remove the must-use plugin file. Please manually delete the file at wp-content/mu-plugins/0001-php-constants-manager-early.php', 'php-constants-manager');
    5656                        break;
    5757                    default:
     
    9191                                        <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
    9292                                        <?php esc_html_e('Must-use plugin file exists:', 'php-constants-manager'); ?>
    93                                         <code><?php echo esc_html(WPMU_PLUGIN_DIR . '/php-constants-manager-early.php'); ?></code>
     93                                        <code><?php echo esc_html(WPMU_PLUGIN_DIR . '/0001-php-constants-manager-early.php'); ?></code>
    9494                                    </p>
    9595                                <?php else: ?>
Note: See TracChangeset for help on using the changeset viewer.