get_error_codes(); if ( ! empty( $error_codes ) ) { return $version_check_errors; } return true; } /** * Check WP version * * @author nvwd * * @since 2.0.0 * * @param \WP_Error $version_check_errors version check errors. * * @return \WP_Error * * phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName -- Slevomat can't make up its mind with or without the '\', so I'm opting for with. */ function a2zaal_check_wp_version( \WP_Error $version_check_errors ) { global $wp_version; if ( version_compare( $wp_version, A2ZAAL_WP_MIN_VERSION, '>=' ) ) { return $version_check_errors; } add_action( 'admin_notices', 'a2zaal_wp_version_failure_message' ); $version_check_errors->add( 'wp_version', esc_html__( 'WordPress version check for A2Z Alphabetical Archive Links failed. A2Z Alphabetical Archive Links should not be active.', 'nvwd-a2zaal' ) ); return $version_check_errors; } // phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName /** * Check PHP version * * @author nvwd * * @since 2.0.0 * * @param \WP_Error $version_check_errors version check errors. * * @return \WP_Error * * phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName -- Slevomat can't make up its mind with or without the '\', so I'm opting for with. */ function a2zaal_check_php_version( \WP_Error $version_check_errors ) { if ( version_compare( PHP_VERSION, A2ZAAL_PHP_MIN_VERSION, '>=' ) ) { return $version_check_errors; } add_action( 'admin_notices', 'a2zaal_php_version_failure_message' ); $version_check_errors->add( 'php_version', esc_html__( 'PHP version check for A2Z Alphabetical Archive Links failed. A2Z Alphabetical Archive Links should not be active.', 'nvwd-a2zaal' ) ); return $version_check_errors; } // phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName /** * Create admin notice of WP version check failure * * @author nvwd * * @since 2.0.0 */ function a2zaal_wp_version_failure_message() { $css_class = 'notice notice-error'; $message = sprintf( /* translators: 1: Minimum WordPress version */ __( 'A2Z Alphabetical Archive Links requires WordPress %1$s to function properly. Please upgrade WordPress. A2Z Alphabetical Archive Links has been auto-deactivated.', 'nvwd-a2zaal' ), A2ZAAL_WP_MIN_VERSION ); a2zaal_output_admin_notice( $css_class, $message ); } /** * Create admin notice of PHP version check failure * * @author nvwd * * @since 2.0.0 */ function a2zaal_php_version_failure_message() { $css_class = 'notice notice-error'; $message = sprintf( /* translators: 1: Minimum php version */ __( 'A2Z Alphabetical Archive Links requires PHP %1$s to function properly. Please upgrade PHP. A2Z Alphabetical Archive Links has been auto-deactivated.', 'nvwd-a2zaal' ), A2ZAAL_PHP_MIN_VERSION ); a2zaal_output_admin_notice( $css_class, $message ); } /** * Display admin notice * * @author nvwd * * @since 2.0.0 * * @param string $css_class css class for the message output. * @param string $message message to display. */ function a2zaal_output_admin_notice( string $css_class, string $message ) { printf( '

%2$s

', esc_attr( $css_class ), esc_html( $message ) ); } if ( function_exists( 'register_block_type' ) ) { add_action( 'init', static function () { register_block_type( __DIR__ . '/build/blocks/a2z-links' ); } ); }