From 6385b0263311510346cd33a167364a265cd479b1 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Mon, 24 Aug 2026 11:54:39 +0000 Subject: [PATCH] v1.2.6 --- changelog.txt | 22 +++++++++++++++ includes/class-robotstxt-hello-plugin.php | 33 +++++++++++++++-------- readme.txt | 19 ++++++------- robotstxt-hello.php | 29 +++++++++++++++++--- 4 files changed, 80 insertions(+), 23 deletions(-) diff --git a/changelog.txt b/changelog.txt index d7263f3..cbfbb4f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,27 @@ == Changelog == += 1.2.6 = + +_Release date: 2026-08-24_ + +**Changed** + +* Manager (by ROBOTSTXT) detection now uses the ecosystem presence constant ROBOTSTXT_MANAGER_NOTICED, defined by Manager 1.6.2+ when it loads. When the constant is absent (older Manager versions), detection falls back to scanning the installed plugin list and checking whether the Manager entry is active, covering both single-site and network-wide activation. +* Minimum PHP version raised from 5.6 to 7.0: the detection method now declares a bool return type, which is PHP 7.0+ syntax. The main plugin file carries a PHP version guard, so sites on older PHP get an admin notice instead of a fatal error. + +**Compatibility** + +* WordPress: 4.0 - 7.2 +* PHP: 7.0 - 8.5 +* MariaDB: 11.8 (staging) + +**Tests** + +* PHP Coding Standards: 3.13.6 +* WordPress Coding Standards: 3.4.1 +* PHPStan: 2.2.9 with wp-compat (Requires at least 4.0) +* PHPUnit: 9.6.36 (plugin header tests included, line coverage 89.8%) + = 1.2.5 = _Release date: 2026-08-18_ diff --git a/includes/class-robotstxt-hello-plugin.php b/includes/class-robotstxt-hello-plugin.php index 6f4eff5..1544d5f 100644 --- a/includes/class-robotstxt-hello-plugin.php +++ b/includes/class-robotstxt-hello-plugin.php @@ -276,24 +276,35 @@ if ( ! class_exists( 'Robotstxt_Hello_Plugin' ) ) { } /** - * Checks whether the Manager (by ROBOTSTXT) plugin is active. + * Returns whether Manager (by ROBOTSTXT) is installed and active. * - * Detection covers both single-site and network-wide activation. + * Uses the ecosystem presence constant (Manager 1.6.2+) and falls back + * to a plugin-list scan for older Manager versions. * * @since 1.2.4 + * @since 1.2.6 Switched to the ROBOTSTXT_MANAGER_NOTICED presence + * constant with a plugin-list scan fallback. * - * @return bool True when any active plugin basename starts with 'robotstxt-manager/'. + * @return bool True when Manager is present and activated. */ - private function is_manager_active() { - $active = (array) get_option( 'active_plugins', array() ); - - if ( is_multisite() ) { - $active = array_merge( $active, array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) ) ); + public function is_manager_active(): bool { + if ( defined( 'ROBOTSTXT_MANAGER_NOTICED' ) && ROBOTSTXT_MANAGER_NOTICED ) { + return true; } - foreach ( $active as $basename ) { - if ( is_string( $basename ) && 0 === strpos( $basename, 'robotstxt-manager/' ) ) { - return true; + if ( ! function_exists( 'get_plugins' ) ) { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + } + + foreach ( get_plugins() as $file => $data ) { + $slug = dirname( $file ); + + if ( '.' === $slug ) { + $slug = basename( $file, '.php' ); + } + + if ( 'robotstxt-manager' === $slug ) { + return is_plugin_active( $file ); } } diff --git a/readme.txt b/readme.txt index 8bf1f9e..0d5dcf7 100644 --- a/readme.txt +++ b/readme.txt @@ -2,10 +2,10 @@ Contributors: robotstxt, javiercasares Tags: hello-world Requires at least: 4.0 -Tested up to: 7.1 -Stable tag: 1.2.5 -Requires PHP: 5.6 -Version: 1.2.5 +Tested up to: 7.2 +Stable tag: 1.2.6 +Requires PHP: 7.0 +Version: 1.2.6 License: GPL-3.0-or-later License URI: https://www.gnu.org/licenses/gpl-3.0.txt @@ -35,11 +35,15 @@ Automatic updates for this plugin are delivered through the ROBOTSTXT ecosystem == Compatibility == -* WordPress: 4.0 - 7.1 -* PHP: 5.6 - 8.5 +* WordPress: 4.0 - 7.2 +* PHP: 7.0 - 8.5 == Changelog == += 1.2.6 = +* Manager (by ROBOTSTXT) detection now uses the ecosystem presence constant ROBOTSTXT_MANAGER_NOTICED (Manager 1.6.2+) instead of scanning the active plugins list, with a fallback plugin-list scan for older Manager versions. +* Minimum PHP version raised from 5.6 to 7.0. The plugin shows an admin notice instead of running on older PHP versions. + = 1.2.5 = * Fixed a conflict on WordPress 4.0-6.4 where the Hello menu item could remove another plugin's top-level menu (and vice versa) when both used the same menu position. The menu is now registered at position 1000, past the last core separator (99), so it renders at the bottom of the menu. @@ -50,9 +54,6 @@ Automatic updates for this plugin are delivered through the ROBOTSTXT ecosystem * Restored the real minimum requirements: WordPress 4.0 and PHP 5.6, verified with a full-range compatibility scan. * Author, contributors and plugin URLs now point to the ROBOTSTXT software site. -= 1.2.3 = -* Test release for update validation. - = Previous versions = If you want to see the full changelog, visit the [changelog](https://www.robotstxt.software/plugins/robotstxt-hello/) page. diff --git a/robotstxt-hello.php b/robotstxt-hello.php index cda648d..3889ad6 100644 --- a/robotstxt-hello.php +++ b/robotstxt-hello.php @@ -4,9 +4,9 @@ * Plugin URI: https://www.robotstxt.software/plugins/robotstxt-hello/ * Update URI: https://www.robotstxt.software/plugins/robotstxt-hello/ * Description: Adds a Hello admin page for demonstration purposes. - * Version: 1.2.5 + * Version: 1.2.6 * Requires at least: 4.0 - * Requires PHP: 5.6 + * Requires PHP: 7.0 * Network: true * Security: robotstxt@robotstxt.es * Author: ROBOTSTXT @@ -23,7 +23,30 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -define( 'ROBOTSTXT_HELLO_VERSION', '1.2.5' ); +if ( version_compare( PHP_VERSION, '7.0', '<' ) ) { + add_action( 'admin_notices', 'robotstxt_hello_render_php_version_notice' ); + + return; +} + +/** + * Renders the admin notice shown when the PHP version is too old. + * + * Defined in the main file because the plugin class itself uses PHP 7.0+ + * syntax and must not be loaded on older versions. + * + * @since 1.2.6 + * + * @return void + */ +function robotstxt_hello_render_php_version_notice() { + printf( + '

%s

', + esc_html__( 'Hello (by ROBOTSTXT) requires PHP 7.0 or newer. The plugin stays inactive until PHP is updated.', 'robotstxt-hello' ) + ); +} + +define( 'ROBOTSTXT_HELLO_VERSION', '1.2.6' ); define( 'ROBOTSTXT_HELLO_FILE', __FILE__ ); require_once __DIR__ . '/includes/class-robotstxt-hello-plugin.php';