| @@ -1,85 +1,179 @@ | ||
| 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: 1.1.6 | |
| 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 | -if ( ! defined( 'WPINC' ) ) { | |
| 30 | - die; | |
| 31 | -} | |
| 32 | - | |
| 33 | - | |
| 34 | - defined('CBXGOOGLEMAP_PLUGIN_NAME') or define( 'CBXGOOGLEMAP_PLUGIN_NAME', 'cbxgooglemap' ); | |
| 35 | - defined('CBXGOOGLEMAP_PLUGIN_VERSION') or define( 'CBXGOOGLEMAP_PLUGIN_VERSION', '1.1.6' ); | |
| 36 | - defined('CBXGOOGLEMAP_BASE_NAME') or define('CBXGOOGLEMAP_BASE_NAME', plugin_basename(__FILE__)); | |
| 37 | - defined('CBXGOOGLEMAP_ROOT_PATH') or define('CBXGOOGLEMAP_ROOT_PATH', plugin_dir_path( __FILE__ )); | |
| 38 | - defined('CBXGOOGLEMAP_ROOT_URL') or define('CBXGOOGLEMAP_ROOT_URL', plugin_dir_url( __FILE__ )); | |
| 39 | - | |
| 40 | - | |
| 41 | -/** | |
| 42 | - * The code that runs during plugin activation. | |
| 43 | - * This action is documented in includes/class-cbxgooglemap-activator.php | |
| 44 | - */ | |
| 45 | -function activate_cbxgooglemap() { | |
| 46 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-cbxgooglemap-activator.php'; | |
| 47 | - CBXGoogleMap_Activator::activate(); | |
| 48 | -} | |
| 49 | - | |
| 50 | -/** | |
| 51 | - * The code that runs during plugin deactivation. | |
| 52 | - * This action is documented in includes/class-cbxgooglemap-deactivator.php | |
| 53 | - */ | |
| 54 | -function deactivate_cbxgooglemap() { | |
| 55 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-cbxgooglemap-deactivator.php'; | |
| 56 | - CBXGoogleMap_Deactivator::deactivate(); | |
| 57 | -} | |
| 58 | - | |
| 59 | -register_activation_hook( __FILE__, 'activate_cbxgooglemap' ); | |
| 60 | -register_deactivation_hook( __FILE__, 'deactivate_cbxgooglemap' ); | |
| 61 | - | |
| 62 | -/** | |
| 63 | - * The core plugin class that is used to define internationalization, | |
| 64 | - * admin-specific hooks, and public-facing site hooks. | |
| 65 | - */ | |
| 66 | -require plugin_dir_path( __FILE__ ) . 'includes/cbxgooglemap-functions.php'; | |
| 67 | -require plugin_dir_path( __FILE__ ) . 'includes/class-cbxgooglemap-helper.php'; | |
| 68 | -require plugin_dir_path( __FILE__ ) . 'includes/class-cbxgooglemap.php'; | |
| 69 | - | |
| 70 | -/** | |
| 71 | - * Begins execution of the plugin. | |
| 72 | - * | |
| 73 | - * Since everything within the plugin is registered via hooks, | |
| 74 | - * then kicking off the plugin from this point in the file does | |
| 75 | - * not affect the page life cycle. | |
| 76 | - * | |
| 77 | - * @since 1.0.0 | |
| 78 | - */ | |
| 79 | -function run_cbxgooglemap() { | |
| 80 | - | |
| 81 | - $plugin = new Cbxgooglemap(); | |
| 82 | - $plugin->run(); | |
| 83 | - | |
| 84 | -} | |
| 85 | -run_cbxgooglemap(); | |
| 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.5 | |
| 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.5' ); | |
| 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 | +defined( 'CBXGOOGLEMAP_PRO_VERSION' ) or define( 'CBXGOOGLEMAP_PRO_VERSION', '2.0.5' ); | |
| 44 | + | |
| 45 | +// Include the main class | |
| 46 | +if ( ! class_exists( 'CBXGoogleMap', false ) ) { | |
| 47 | + include_once CBXGOOGLEMAP_ROOT_PATH . 'includes/CBXGoogleMap.php'; | |
| 48 | +} | |
| 49 | + | |
| 50 | +/** | |
| 51 | + * Checking wp version | |
| 52 | + * | |
| 53 | + * @param $version | |
| 54 | + * | |
| 55 | + * @return bool | |
| 56 | + */ | |
| 57 | +function cbxgooglemap_compatible_wp_version( $version = '' ) { | |
| 58 | + if($version == '') $version = CBXGOOGLEMAP_WP_MIN_VERSION; | |
| 59 | + | |
| 60 | + if ( version_compare( $GLOBALS['wp_version'], $version, '<' ) ) { | |
| 61 | + return false; | |
| 62 | + } | |
| 63 | + | |
| 64 | + // Add sanity checks for other version requirements here | |
| 65 | + | |
| 66 | + return true; | |
| 67 | +}//end method cbxgooglemap_compatible_wp_version | |
| 68 | + | |
| 69 | +/** | |
| 70 | + * Checking php version | |
| 71 | + * | |
| 72 | + * @param $version | |
| 73 | + * | |
| 74 | + * @return bool | |
| 75 | + */ | |
| 76 | +function cbxgooglemap_compatible_php_version( $version = '' ) { | |
| 77 | + if($version == '') $version = CBXGOOGLEMAP_PHP_MIN_VERSION; | |
| 78 | + | |
| 79 | + if ( version_compare( PHP_VERSION, $version, '<' ) ) { | |
| 80 | + return false; | |
| 81 | + } | |
| 82 | + | |
| 83 | + return true; | |
| 84 | +}//end method cbxgooglemap_compatible_php_version | |
| 85 | + | |
| 86 | +register_activation_hook( __FILE__, 'cbxgooglemap_activate' ); | |
| 87 | +register_deactivation_hook( __FILE__, 'cbxgooglemap_deactivate' ); | |
| 88 | + | |
| 89 | +/** | |
| 90 | + * The code that runs during plugin activation. | |
| 91 | + * This action is documented in includes/class-cbxgooglemap-activator.php | |
| 92 | + */ | |
| 93 | +function cbxgooglemap_activate() { | |
| 94 | + try { | |
| 95 | + $wp_version = CBXGOOGLEMAP_WP_MIN_VERSION; | |
| 96 | + $php_version = CBXGOOGLEMAP_PHP_MIN_VERSION; | |
| 97 | + | |
| 98 | + $activate_ok = true; | |
| 99 | + if ( ! cbxgooglemap_compatible_wp_version() ) { | |
| 100 | + $activate_ok = false; | |
| 101 | + deactivate_plugins( plugin_basename( __FILE__ ) ); | |
| 102 | + | |
| 103 | + /* translators: WordPress version */ | |
| 104 | + 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 | |
| 105 | + } | |
| 106 | + | |
| 107 | + if ( ! cbxgooglemap_compatible_php_version() ) { | |
| 108 | + $activate_ok = false; | |
| 109 | + deactivate_plugins( plugin_basename( __FILE__ ) ); | |
| 110 | + | |
| 111 | + /* translators: PHP version */ | |
| 112 | + 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 | |
| 113 | + } | |
| 114 | + | |
| 115 | + if($activate_ok) { | |
| 116 | + cbxgooglemap_core(); | |
| 117 | + CBXGooglemapHelper::activate(); | |
| 118 | + } | |
| 119 | + } | |
| 120 | + catch ( Throwable $e ) { | |
| 121 | + if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { | |
| 122 | + //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r | |
| 123 | + error_log( print_r( [ | |
| 124 | + 'message' => $e->getMessage(), | |
| 125 | + 'file' => $e->getFile(), | |
| 126 | + 'line' => $e->getLine(), | |
| 127 | + 'trace' => $e->getTraceAsString(), | |
| 128 | + ], true ) ); | |
| 129 | + } | |
| 130 | + | |
| 131 | + | |
| 132 | + deactivate_plugins( plugin_basename( __FILE__ ) ); | |
| 133 | + | |
| 134 | + wp_die( | |
| 135 | + sprintf( | |
| 136 | + 'Activation error: %s', | |
| 137 | + esc_html( $e->getMessage() ) | |
| 138 | + ) | |
| 139 | + ); | |
| 140 | + } | |
| 141 | +}//end method cbxgooglemap_activate | |
| 142 | + | |
| 143 | +/** | |
| 144 | + * The code that runs during plugin deactivation. | |
| 145 | + * This action is documented in includes/class-cbxgooglemap-deactivator.php | |
| 146 | + */ | |
| 147 | +function cbxgooglemap_deactivate() { | |
| 148 | + CBXGooglemapHelper::deactivate(); | |
| 149 | +} | |
| 150 | + | |
| 151 | +/** | |
| 152 | + * Initialize the plugin manually | |
| 153 | + * | |
| 154 | + * @return CBXGoogleMap|null | |
| 155 | + */ | |
| 156 | +function cbxgooglemap_core() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid | |
| 157 | + global $cbxgooglemap_core; | |
| 158 | + | |
| 159 | + if ( ! isset( $cbxgooglemap_core ) ) { | |
| 160 | + $cbxgooglemap_core = cbxgooglemap_run(); | |
| 161 | + } | |
| 162 | + | |
| 163 | + return $cbxgooglemap_core; | |
| 164 | +}//end method cbxgooglemap_core | |
| 165 | + | |
| 166 | +/** | |
| 167 | + * Begins execution of the plugin. | |
| 168 | + * | |
| 169 | + * Since everything within the plugin is registered via hooks, | |
| 170 | + * then kicking off the plugin from this point in the file does | |
| 171 | + * not affect the page life cycle. | |
| 172 | + * | |
| 173 | + * @since 1.0.0 | |
| 174 | + */ | |
| 175 | +function cbxgooglemap_run() { | |
| 176 | + return CBXGoogleMap::instance(); | |
| 177 | +}//end method cbxgooglemap_run | |
| 178 | + | |
| 179 | +$GLOBALS['cbxgooglemap_core'] = cbxgooglemap_run(); | |