arrays.php
2 months ago
dates.php
2 months ago
general.php
2 months ago
index.php
2 months ago
screen.php
2 months ago
strings.php
2 months ago
general.php
61 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Foo Functions - General |
| 4 | * A bunch of common and useful functions that don't fall into any specific category |
| 5 | * |
| 6 | * Author: Brad Vincent |
| 7 | * Author URI: http://fooplugins.com |
| 8 | * License: GPL2 |
| 9 | */ |
| 10 | |
| 11 | if ( !function_exists( 'foo_check_php_version' ) ) { |
| 12 | |
| 13 | /** |
| 14 | * Checks the version of PHP running on the server. |
| 15 | * |
| 16 | * @param string $plugin_title The title of the plugin that is doing the check. |
| 17 | * @param string $ver The minimum required version |
| 18 | * |
| 19 | * @throws Exception if the version does not meet minimum requirements |
| 20 | */ |
| 21 | function foo_check_php_version($plugin_title, $ver) { |
| 22 | $php_version = phpversion(); |
| 23 | if ( version_compare( $php_version, $ver ) < 0 ) { |
| 24 | throw new Exception( sprintf( esc_html__( "%s requires at least version %s of PHP. You are running an older version (%s). Please update!", "foogallery" ), esc_html( $plugin_title ), esc_html( $ver ), esc_html( $php_version ) ) ); |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | if ( !function_exists( 'foo_check_wp_version' ) ) { |
| 30 | |
| 31 | /** |
| 32 | * Checks the version of WordPress running on the server. |
| 33 | * |
| 34 | * @param string $plugin_title The title of the plugin that is doing the check. |
| 35 | * @param string $ver The minimum required version |
| 36 | * |
| 37 | * @throws Exception if the version does not meet minimum requirements |
| 38 | */ |
| 39 | function foo_check_wp_version($plugin_title, $ver) { |
| 40 | global $wp_version; |
| 41 | if ( version_compare( $wp_version, $ver ) < 0 ) { |
| 42 | throw new Exception( sprintf( esc_html__( "%s requires at least version %s of WordPress. You are running an older version (%s). Please update!", "foogallery" ), esc_html( $plugin_title ), esc_html( $ver ), esc_html( $wp_version ) ) ); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | if ( !function_exists( 'foo_check_wp_version_at_least' ) ) { |
| 48 | |
| 49 | /** |
| 50 | * @TODO |
| 51 | * @param $ver |
| 52 | * |
| 53 | * @return bool |
| 54 | */ |
| 55 | function foo_check_wp_version_at_least($ver) { |
| 56 | global $wp_version; |
| 57 | |
| 58 | return version_compare( $wp_version, $ver ) >= 0; |
| 59 | } |
| 60 | } |
| 61 |