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