Changeset 3317324
- Timestamp:
- 06/25/2025 04:48:41 AM (7 months ago)
- Location:
- php-constants-manager
- Files:
-
- 10 edited
- 1 copied
-
assets/icon-128x128.png (modified) (1 prop) (previous)
-
assets/icon-256x256.png (modified) (1 prop) (previous)
-
tags/1.1.5 (copied) (copied from php-constants-manager/trunk)
-
tags/1.1.5/php-constants-manager.php (modified) (6 diffs)
-
tags/1.1.5/readme.txt (modified) (2 diffs)
-
tags/1.1.5/views/admin/help.php (modified) (1 diff)
-
tags/1.1.5/views/admin/settings.php (modified) (2 diffs)
-
trunk/php-constants-manager.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/views/admin/help.php (modified) (1 diff)
-
trunk/views/admin/settings.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
php-constants-manager/assets/icon-128x128.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
php-constants-manager/assets/icon-256x256.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
php-constants-manager/tags/1.1.5/php-constants-manager.php
r3317261 r3317324 4 4 * Plugin URI: https://github.com/cartpauj/php-constants-manager 5 5 * Description: Safely manage PHP constants (defines) through the WordPress admin interface 6 * Version: 1.1. 46 * Version: 1.1.5 7 7 * Author: cartpauj 8 8 * Author URI: https://github.com/cartpauj/ … … 75 75 //add_action('init', array($this, 'init')); 76 76 add_action('admin_init', array($this, 'handle_admin_actions')); 77 add_action('admin_init', array($this, 'migrate_mu_plugin_filename')); 77 78 add_action('admin_menu', array($this, 'add_admin_menu')); 78 79 add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_assets')); … … 825 826 */ 826 827 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'; 828 829 return file_exists($mu_plugin_path); 829 830 } … … 838 839 } 839 840 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'; 841 842 842 843 // Generate static must-use plugin content that queries the database … … 946 947 */ 947 948 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'; 949 950 950 951 if (!file_exists($mu_plugin_path)) { … … 959 960 960 961 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 } 961 987 } 962 988 -
php-constants-manager/tags/1.1.5/readme.txt
r3317311 r3317324 1 1 === PHP Constants Manager === 2 2 Contributors: cartpauj 3 Tags: constants, php, developer, admin, defines3 Tags: constants, php, configuration, admin, defines 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 Stable tag: 1.1. 46 Stable tag: 1.1.5 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 176 176 177 177 == Changelog == 178 = 1.1.5 = 179 * Renamed must-use plugin to attempt to get it to load earlier than other must-use plugins 180 178 181 = 1.1.4 = 179 182 * Security hardening -
php-constants-manager/tags/1.1.5/views/admin/help.php
r3317261 r3317324 514 514 <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> 515 515 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><?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 536 if (!defined('ABSPATH')) { 537 exit; 538 } 539 540 // Load PHP Constants Manager constants early 541 function 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 620 phpcm_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 516 637 <h3><?php esc_html_e('Need More Help?', 'php-constants-manager'); ?></h3> 517 638 <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 53 53 break; 54 54 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'); 56 56 break; 57 57 default: … … 91 91 <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span> 92 92 <?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> 94 94 </p> 95 95 <?php else: ?> -
php-constants-manager/trunk/php-constants-manager.php
r3317261 r3317324 4 4 * Plugin URI: https://github.com/cartpauj/php-constants-manager 5 5 * Description: Safely manage PHP constants (defines) through the WordPress admin interface 6 * Version: 1.1. 46 * Version: 1.1.5 7 7 * Author: cartpauj 8 8 * Author URI: https://github.com/cartpauj/ … … 75 75 //add_action('init', array($this, 'init')); 76 76 add_action('admin_init', array($this, 'handle_admin_actions')); 77 add_action('admin_init', array($this, 'migrate_mu_plugin_filename')); 77 78 add_action('admin_menu', array($this, 'add_admin_menu')); 78 79 add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_assets')); … … 825 826 */ 826 827 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'; 828 829 return file_exists($mu_plugin_path); 829 830 } … … 838 839 } 839 840 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'; 841 842 842 843 // Generate static must-use plugin content that queries the database … … 946 947 */ 947 948 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'; 949 950 950 951 if (!file_exists($mu_plugin_path)) { … … 959 960 960 961 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 } 961 987 } 962 988 -
php-constants-manager/trunk/readme.txt
r3317311 r3317324 1 1 === PHP Constants Manager === 2 2 Contributors: cartpauj 3 Tags: constants, php, developer, admin, defines3 Tags: constants, php, configuration, admin, defines 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 Stable tag: 1.1. 46 Stable tag: 1.1.5 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 176 176 177 177 == Changelog == 178 = 1.1.5 = 179 * Renamed must-use plugin to attempt to get it to load earlier than other must-use plugins 180 178 181 = 1.1.4 = 179 182 * Security hardening -
php-constants-manager/trunk/views/admin/help.php
r3317261 r3317324 514 514 <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> 515 515 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><?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 536 if (!defined('ABSPATH')) { 537 exit; 538 } 539 540 // Load PHP Constants Manager constants early 541 function 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 620 phpcm_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 516 637 <h3><?php esc_html_e('Need More Help?', 'php-constants-manager'); ?></h3> 517 638 <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 53 53 break; 54 54 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'); 56 56 break; 57 57 default: … … 91 91 <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span> 92 92 <?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> 94 94 </p> 95 95 <?php else: ?>
Note: See TracChangeset
for help on using the changeset viewer.