| 1 |
<?php |
| 2 |
|
| 3 |
namespace MakeCommerce\Shipping\Method\ParcelMachine; |
| 4 |
|
| 5 |
/** |
| 6 |
* Google maps functionality for parcel machines |
| 7 |
* |
| 8 |
* @since 3.3.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
trait Map { |
| 12 |
|
| 13 |
/** |
| 14 |
* Initializes the map |
| 15 |
* |
| 16 |
* @since 3.3.0 |
| 17 |
*/ |
| 18 |
public static function initialize_map( $vars ) { |
| 19 |
|
| 20 |
$vars['path'] = plugin_dir_url(__FILE__) . '/images'; |
| 21 |
|
| 22 |
\MakeCommerce::mc_enqueue_script( 'MC_PARCELMACHINE_MAP_JS', dirname(__FILE__) . '/js/parcelmachinemap.js', $vars, [ 'jquery' ] ); |
| 23 |
|
| 24 |
wp_enqueue_style( "mc_parcelmachinemap", plugin_dir_url(__FILE__) . 'css/parcelmachinemap.css', array(), MAKECOMMERCE_VERSION ); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Checks if map is enabled in admin settings |
| 29 |
* |
| 30 |
* @since 3.3.0 |
| 31 |
*/ |
| 32 |
public static function map_enabled() { |
| 33 |
|
| 34 |
return !empty( get_option( 'mc_google_api_key', '' ) ) |
| 35 |
&& get_option( 'mc_parcel_machine_map', '' ) === 'yes'; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Checks if secret key is enabled in admin settings |
| 40 |
* |
| 41 |
* @since 3.3.0 |
| 42 |
*/ |
| 43 |
public static function geocoding_enabled() { |
| 44 |
return !empty( get_option( 'mc_map_geocoding_api_key', '' ) ) |
| 45 |
&& get_option( 'mc_map_geocoding', '' ) === 'yes'; |
| 46 |
} |
| 47 |
} |
| 48 |
|