| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The plugin bootstrap file |
| 5 |
* |
| 6 |
* This file is read by WordPress to generate the plugin information in the plugin |
| 7 |
* admin area. This file also includes all of the dependencies used by the plugin, |
| 8 |
* registers the activation and deactivation functions, and defines a function |
| 9 |
* that starts the plugin. |
| 10 |
* |
| 11 |
* @link https://codeboxr.com |
| 12 |
* @since 1.0.0 |
| 13 |
* @package Cbxgooglemap |
| 14 |
* |
| 15 |
* @wordpress-plugin |
| 16 |
* Plugin Name: CBX Map for Google Map & OpenStreetMap |
| 17 |
* Plugin URI: https://codeboxr.com/product/cbx-google-map-for-wordpress/ |
| 18 |
* Description: Easy responsive embed of google map and openstreet map |
| 19 |
* Version: 2.0.0 |
| 20 |
* Author: Codeboxr |
| 21 |
* Author URI: https://codeboxr.com |
| 22 |
* License: GPL-2.0+ |
| 23 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 24 |
* Text Domain: cbxgooglemap |
| 25 |
* Domain Path: /languages |
| 26 |
*/ |
| 27 |
|
| 28 |
// If this file is called directly, abort. |
| 29 |
use Cbx\Googlemap\Helpers\CBXGooglemapHelper; |
| 30 |
|
| 31 |
if ( ! defined( 'WPINC' ) ) { |
| 32 |
die; |
| 33 |
} |
| 34 |
|
| 35 |
defined( 'CBXGOOGLEMAP_PLUGIN_NAME' ) or define( 'CBXGOOGLEMAP_PLUGIN_NAME', 'cbxgooglemap' ); |
| 36 |
defined( 'CBXGOOGLEMAP_PLUGIN_VERSION' ) or define( 'CBXGOOGLEMAP_PLUGIN_VERSION', '2.0.0' ); |
| 37 |
defined( 'CBXGOOGLEMAP_BASE_NAME' ) or define( 'CBXGOOGLEMAP_BASE_NAME', plugin_basename( __FILE__ ) ); |
| 38 |
defined( 'CBXGOOGLEMAP_ROOT_PATH' ) or define( 'CBXGOOGLEMAP_ROOT_PATH', plugin_dir_path( __FILE__ ) ); |
| 39 |
defined( 'CBXGOOGLEMAP_ROOT_URL' ) or define( 'CBXGOOGLEMAP_ROOT_URL', plugin_dir_url( __FILE__ ) ); |
| 40 |
|
| 41 |
defined( 'CBXGOOGLEMAP_WP_MIN_VERSION' ) or define( 'CBXGOOGLEMAP_WP_MIN_VERSION', '5.3' ); |
| 42 |
defined( 'CBXGOOGLEMAP_PHP_MIN_VERSION' ) or define( 'CBXGOOGLEMAP_PHP_MIN_VERSION', '7.4' ); |
| 43 |
|
| 44 |
// Include the main class |
| 45 |
if ( ! class_exists( 'CBXGoogleMap', false ) ) { |
| 46 |
include_once CBXGOOGLEMAP_ROOT_PATH . 'includes/CBXGoogleMap.php'; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Checking wp version |
| 51 |
* |
| 52 |
* @param $version |
| 53 |
* |
| 54 |
* @return bool |
| 55 |
*/ |
| 56 |
function cbxgooglemap_compatible_wp_version( $version = '' ) { |
| 57 |
if($version == '') $version = CBXGOOGLEMAP_WP_MIN_VERSION; |
| 58 |
|
| 59 |
if ( version_compare( $GLOBALS['wp_version'], $version, '<' ) ) { |
| 60 |
return false; |
| 61 |
} |
| 62 |
|
| 63 |
// Add sanity checks for other version requirements here |
| 64 |
|
| 65 |
return true; |
| 66 |
}//end method cbxgooglemap_compatible_wp_version |
| 67 |
|
| 68 |
/** |
| 69 |
* Checking php version |
| 70 |
* |
| 71 |
* @param $version |
| 72 |
* |
| 73 |
* @return bool |
| 74 |
*/ |
| 75 |
function cbxgooglemap_compatible_php_version( $version = '' ) { |
| 76 |
if($version == '') $version = CBXGOOGLEMAP_PHP_MIN_VERSION; |
| 77 |
|
| 78 |
if ( version_compare( PHP_VERSION, $version, '<' ) ) { |
| 79 |
return false; |
| 80 |
} |
| 81 |
|
| 82 |
return true; |
| 83 |
}//end method cbxgooglemap_compatible_php_version |
| 84 |
|
| 85 |
register_activation_hook( __FILE__, 'activate_cbxgooglemap' ); |
| 86 |
register_deactivation_hook( __FILE__, 'deactivate_cbxgooglemap' ); |
| 87 |
|
| 88 |
/** |
| 89 |
* The code that runs during plugin activation. |
| 90 |
* This action is documented in includes/class-cbxgooglemap-activator.php |
| 91 |
*/ |
| 92 |
function activate_cbxgooglemap() { |
| 93 |
$wp_version = CBXGOOGLEMAP_WP_MIN_VERSION; |
| 94 |
$php_version = CBXGOOGLEMAP_PHP_MIN_VERSION; |
| 95 |
|
| 96 |
$activate_ok = true; |
| 97 |
if ( ! cbxgooglemap_compatible_wp_version() ) { |
| 98 |
$activate_ok = false; |
| 99 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 100 |
|
| 101 |
/* translators: WordPress version */ |
| 102 |
wp_die( sprintf( esc_html__( 'CBX Google Map plugin requires WordPress %s or higher!', 'cbxgooglemap' ), esc_attr($wp_version) ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 103 |
} |
| 104 |
|
| 105 |
if ( ! cbxgooglemap_compatible_php_version() ) { |
| 106 |
$activate_ok = false; |
| 107 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 108 |
|
| 109 |
/* translators: PHP version */ |
| 110 |
wp_die( sprintf( esc_html__( 'CBX Google Map plugin requires PHP %s or higher!', 'cbxgooglemap' ), esc_attr($php_version) ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 111 |
} |
| 112 |
|
| 113 |
if($activate_ok) { |
| 114 |
cbxgooglemap_core(); |
| 115 |
CBXGooglemapHelper::activate(); |
| 116 |
} |
| 117 |
}//end method activate_cbxgooglemap |
| 118 |
|
| 119 |
/** |
| 120 |
* The code that runs during plugin deactivation. |
| 121 |
* This action is documented in includes/class-cbxgooglemap-deactivator.php |
| 122 |
*/ |
| 123 |
function deactivate_cbxgooglemap() { |
| 124 |
CBXGooglemapHelper::deactivate(); |
| 125 |
} |
| 126 |
|
| 127 |
/** |
| 128 |
* Initialize the plugin manually |
| 129 |
* |
| 130 |
* @return CBXGoogleMap|null |
| 131 |
*/ |
| 132 |
function cbxgooglemap_core() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid |
| 133 |
global $cbxgooglemap_core; |
| 134 |
|
| 135 |
if ( ! isset( $cbxgooglemap_core ) ) { |
| 136 |
$cbxgooglemap_core = run_cbxgooglemap(); |
| 137 |
} |
| 138 |
|
| 139 |
return $cbxgooglemap_core; |
| 140 |
}//end method cbxgooglemap_core |
| 141 |
|
| 142 |
/** |
| 143 |
* Begins execution of the plugin. |
| 144 |
* |
| 145 |
* Since everything within the plugin is registered via hooks, |
| 146 |
* then kicking off the plugin from this point in the file does |
| 147 |
* not affect the page life cycle. |
| 148 |
* |
| 149 |
* @since 1.0.0 |
| 150 |
*/ |
| 151 |
function run_cbxgooglemap() { |
| 152 |
return CBXGoogleMap::instance(); |
| 153 |
}//end method run_cbxgooglemap |
| 154 |
|
| 155 |
$GLOBALS['cbxgooglemap_core'] = run_cbxgooglemap(); |