Utilities * Utilities and helpers * */ if ( ! defined( 'ABSPATH' ) ) exit; if ( ! defined( 'TBKKT_REQUIRES_WP' ) ) define( 'TBKKT_REQUIRES_WP', '6.0' ); if ( ! defined( 'TBKKT_REQUIRES_PHP' ) ) define( 'TBKKT_REQUIRES_PHP', '8.0' ); /** * Get plugin name */ function tbkkt_plugin_get_name(): string { static $tbkkt_plugin_name = null; if ( null !== $tbkkt_plugin_name ) return $tbkkt_plugin_name; $data = get_plugin_data( TBKKT_PLUGIN_FILE, false, false ); $tbkkt_plugin_name = $data['Name'] ?? __( 'Plugin', 'tms-block-kit' ); return $tbkkt_plugin_name; } /** * File modification time for a path under the plugin directory, or plugin version if missing */ function tbkkt_plugin_get_asset_file_mtime( string $relative ): int { $path = TBKKT_PLUGIN_PATH . $relative; return file_exists( $path ) ? (int) filemtime( $path ) : (int) TBKKT_PLUGIN_VERSION; } /** * Minimum WordPress and PHP version */ function tbkkt_plugin_requirements_are_met(): bool { global $wp_version; $wp = is_string( $wp_version ) ? $wp_version : ''; if ( $wp === '' ) return false; return version_compare( $wp, TBKKT_REQUIRES_WP, '>=' ) && version_compare( PHP_VERSION, TBKKT_REQUIRES_PHP, '>=' ); } function tbkkt_plugin_requirements_render_admin_notice(): void { if ( ! current_user_can( 'activate_plugins' ) ) : return; endif; global $wp_version; $wp_current = is_string( $wp_version ) ? $wp_version : __( 'unknown', 'tms-block-kit' ); $name = tbkkt_plugin_get_name(); $message = sprintf( /* translators: 1: plugin name, 2: required WP version, 3: current WP version, 4: required PHP version, 5: current PHP version */ __( '%1$s requires WordPress %2$s or higher (you are running %3$s) and PHP %4$s or higher (this server reports %5$s). Please update WordPress or PHP, or contact your host.', 'tms-block-kit' ), $name, TBKKT_REQUIRES_WP, $wp_current, TBKKT_REQUIRES_PHP, PHP_VERSION ); echo '
' . esc_html( $message ) . '