mustardBees / cmb_field_map

Google Maps field type for Custom Metaboxes and Fields for WordPress
120 stars 49 forks source link

Idea to customize URL #28

Open kalicki opened 9 years ago

kalicki commented 9 years ago

It is interesting to use constant in URL, this allows me to change or custom by the theme

E.g.:

public function __construct() {
        if ( ! defined( 'PW_CMB2_Field_Google_Maps_URL' ) ) {
            define( 'PW_CMB2_Field_Google_Maps_URL', plugin_dir_url( __FILE__ ) );
        }
        add_filter( 'cmb2_render_pw_map', array( $this, 'render_pw_map' ), 10, 5 );
        add_filter( 'cmb2_sanitize_pw_map', array( $this, 'sanitize_pw_map' ), 10, 4 );
    }
public function setup_admin_scripts() {
        wp_register_script( 'pw-google-maps-api', '//maps.googleapis.com/maps/api/js?sensor=false&libraries=places', null, null );
        wp_enqueue_script( 'pw-google-maps', PW_CMB2_Field_Google_Maps_URL . 'js/script.js', array( 'pw-google-maps-api' ), self::VERSION );
        wp_enqueue_style( 'pw-google-maps', PW_CMB2_Field_Google_Maps_URL . 'css/style.css', array(), self::VERSION );
    }