PHP code example of timelsass / wp-php-version-check

1. Go to this page and download the library: Download timelsass/wp-php-version-check library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

timelsass / wp-php-version-check example snippets


$ composer 

if ( ! class_exists( 'Wp_Php_Version_Check' ) ) {
  

Wp_Php_Version_Check::init( $plugin, $wp_version, $php_version (, $callback, ...$args) );

Wp_Php_Version_Check::init( plugin_basename( __FILE__ ), '4.7', '5.3' );

add_action( 'example-plugin:init', function() {
  wp_die( 'Passes Version Requirements.' );
});

Wp_Php_Version_Check::init( plugin_basename( __FILE__ ), '4.7', '5.3', 'example_plugin_init', true, 'The plugin has been initialized!' );

function example_plugin_init( $passed, $message ) {
    if ( $passed ) {
        wp_die( $message );
    }
}

/**
 * Plugin Name: Example Plugin
 * Plugin URI: https://github.com/timelsass/wp-php-version-check
 * Description: This is an example of using Wp_Php_Version_Check class.
 * Version: 1.0.0
 * License: GPLv2 or later
 */
 
// Prevent direct calls.
defined( 'WPINC' ) ? : die;

// Load the Wp_Php_Version_Check file and make sure that the class doesn't exist first.
if ( ! class_exists( 'Wp_Php_Version_Check' ) ) {
  gin passes the version check