array( 'name' => esc_html__( 'Map', 'mega' ), 'description' => esc_html__( 'Map Block', 'mega' )), 'before' => '
', 'universal' => $mega_package > 0 ? true : false, 'universal_pro' => true ); parent::__construct( __CLASS__, $args ); } public function settings( $form ) { $form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Title', 'mega' ), 'pro' => 1, 'value' => esc_html__( 'Where we are?', 'mega' ), 'name' => 'title' )); $form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Google API Key', 'mega' ), 'value' => '', 'name' => 'key' )); $form->add_control( 'Mega_Control_Select', array( 'label' => esc_html__( 'Type', 'mega' ), 'value' => 'latlng', 'name' => 'type', 'choices' => array( 'address' => esc_html__( 'Address', 'mega' ), 'latlng' => esc_html__( 'Latitude / Longitude', 'mega' ) ) )); $form->add_sub_control( 'Mega_Control_Text', array( 'control' => 'type', 'control_value' => 'address', 'label' => esc_html__( 'Address', 'mega' ), 'value' => esc_html__( 'Palo Alto', 'mega' ), 'name' => 'address' )); $form->add_sub_control( 'Mega_Control_Text', array( 'control' => 'type', 'control_value' => 'latlng', 'label' => esc_html__( 'Latitude', 'mega' ), 'value' => '40.685944', 'name' => 'lat' )); $form->add_sub_control( 'Mega_Control_Text', array( 'control' => 'type', 'control_value' => 'latlng', 'label' => esc_html__( 'Longitude', 'mega' ), 'value' => '-73.997499', 'name' => 'lng' )); $form->add_control( 'Mega_Control_Number', array( 'label' => esc_html__( 'Height', 'mega' ), 'value' => 350, 'name' => 'height' )); $form->add_control( 'Mega_Control_Number', array( 'label' => esc_html__( 'Zoom', 'mega' ), 'pro' => 1, 'value' => 19, 'name' => 'zoom' )); $form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Custom Marker', 'mega' ), 'pro' => 1, 'value' => '', 'name' => 'marker' )); } public function hookOnce() { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' )); } public function enqueue() { wp_enqueue_script( 'google.maps', '//maps.googleapis.com/maps/api/js?key=' . $this->mega['settings_defaults']['key'], array(), false, true ); wp_enqueue_script( 'mega.jquery.map', MEGA_DIR_URI . '/assets/js/mega.jquery.map.js', array( 'jquery', 'google.maps' ), false, true ); wp_localize_script( 'mega.jquery.map', 'megamap', array( 'msg' => esc_html__( 'Google was unable to find the address you specified, please try a different address or use the Latitude & Longitude parameters.', 'mega' ))); } public function hook() { add_action( 'wp_footer', array( $this, 'footer' ), 20 ); } public function footer() { $this->mega['settings']['zoom'] = (int) $this->mega['settings']['zoom']; $json = json_encode( $this->mega['settings'] );//, JSON_NUMERIC_CHECK = php 5.3.3 + //$id = $this->mega['args']['id_base_low'] . '-' . $this->mega['args']['id']; $id = '#' . $this->id; echo ""; } public function block() { extract( $this->mega['settings'] ); echo ''; } }