esc_html__( 'Map Settings', 'cbxgooglemap' ), 'maplocation' => esc_html__( 'Primary Marker', 'cbxgooglemap' ), ]; return apply_filters( 'cbxgooglemap_sections', $sections ); }//end method meta_field_sections /** * Meta fields for sessions * * @param int $post_id * * @return array */ public static function cbxgooglemap_meta_fields( $post_id = 0 ) { $meta_fields = []; $settings = new CBXGooglemapSettings(); $general_settings = get_option( 'cbxgooglemap_general', [] ); $zoom_level = intval( $settings->get_field( 'zoom', 'cbxgooglemap_general', '8' ) ); if ( $zoom_level == 0 ) { $zoom_level = 8; } $width_default = $settings->get_field( 'width', 'cbxgooglemap_general', '100%' ); if ( $width_default == '' || $width_default == 0 ) { $width_default = '100%'; } $height_default = intval( $settings->get_field( 'height', 'cbxgooglemap_general', '300' ) ); if ( $height_default == 0 ) { $height_default = 300; } $scrollwheel = intval( $settings->get_field( 'scrollwheel', 'cbxgooglemap_general', 1 ) ); $showinfo = intval( $settings->get_field( 'showinfo', 'cbxgooglemap_general', 1 ) ); $infow_open = intval( $settings->get_field( 'infow_open', 'cbxgooglemap_general', 1 ) ); $maptype = $settings->get_field( 'maptype', 'cbxgooglemap_general', 'roadmap' ); $meta_fields['mapsettings'] = apply_filters( 'cbxgooglemap_mapsettings_fields', [ 'maptype' => [ 'label' => esc_html__( 'Map Type', 'cbxgooglemap' ), 'type' => 'select', 'default' => $maptype, 'options' => [ 'roadmap' => esc_html__( 'Road Map', 'cbxgooglemap' ), 'satellite' => esc_html__( 'Satellite Map', 'cbxgooglemap' ), 'hybrid' => esc_html__( 'Hybrid Map', 'cbxgooglemap' ), 'terrain' => esc_html__( 'Terrain Map', 'cbxgooglemap' ), ], 'desc' => esc_html__( 'Google Map only', 'cbxgooglemap' ), 'sanitize_callback' => 'sanitize_text_field' ], 'zoom' => [ 'label' => esc_html__( 'Zoom Level', 'cbxgooglemap' ), 'desc' => esc_html__( 'Plain address with road no etc', 'cbxgooglemap' ), 'type' => 'text', 'default' => $zoom_level, 'sanitize_callback' => 'sanitize_text_field' ], 'width' => [ 'label' => esc_html__( 'Width', 'cbxgooglemap' ), 'desc' => esc_html__( 'Map width, use % if need, don\'t use px as it will be automatically if no % used.', 'cbxgooglemap' ), 'type' => 'text', 'default' => $width_default, 'sanitize_callback' => 'sanitize_text_field' ], 'height' => [ 'label' => esc_html__( 'Height', 'cbxgooglemap' ), 'desc' => esc_html__( 'Map height, don\'t use px', 'cbxgooglemap' ), 'type' => 'text', 'default' => $height_default, 'sanitize_callback' => 'sanitize_text_field' ], 'scrollwheel' => [ 'label' => esc_html__( 'Mouse Scroll Wheel', 'cbxgooglemap' ), 'desc' => esc_html__( 'Enable/disable mouse scroll whell', 'cbxgooglemap' ), 'type' => 'radio', 'default' => $scrollwheel, 'desc_tip' => true, 'options' => [ '1' => esc_html__( 'Enable', 'cbxgooglemap' ), '0' => esc_html__( 'Disable', 'cbxgooglemap' ), ], 'inline' => true, 'sanitize_callback' => 'absint' ], 'showinfo' => [ 'label' => esc_html__( 'Show Info window', 'cbxgooglemap' ), 'desc' => esc_html__( 'Show information on click of marker', 'cbxgooglemap' ), 'type' => 'radio', 'default' => $showinfo, 'desc_tip' => true, 'options' => [ '1' => esc_html__( 'Enable', 'cbxgooglemap' ), '0' => esc_html__( 'Disable', 'cbxgooglemap' ), ], 'inline' => true, 'sanitize_callback' => 'absint' ], 'infow_open' => [ 'label' => esc_html__( 'Info/Popup Window', 'cbxgooglemap' ), 'type' => 'radio', 'default' => $infow_open, 'desc_tip' => true, 'options' => [ '1' => esc_html__( 'Open(Default)', 'cbxgooglemap' ), '0' => esc_html__( 'On Click', 'cbxgooglemap' ), ], 'inline' => true, 'sanitize_callback' => 'absint' ], ] ); $meta_fields['maplocation'] = apply_filters( 'cbxgooglemap_maplocation_fields', [ 'title' => [ 'label' => esc_html__( 'Marker Heading', 'cbxgooglemap' ), 'desc' => esc_html__( 'Heading title will be used for marker pop info', 'cbxgooglemap' ), 'type' => 'text', 'default' => esc_html__('Default Title', 'cbxgooglemap'), 'sanitize_callback' => 'sanitize_text_field' ], 'address' => [ 'label' => esc_html__( 'Address', 'cbxgooglemap' ), 'desc' => esc_html__( 'Plain address with road no etc', 'cbxgooglemap' ), 'type' => 'text', 'default' => '', 'sanitize_callback' => 'sanitize_text_field' ], 'website' => [ 'label' => esc_html__( 'Website Link', 'cbxgooglemap' ), 'desc' => esc_html__( 'If website link is given then market popup will show the Title as linked with this address', 'cbxgooglemap' ), 'type' => 'text', 'default' => '', 'sanitize_callback' => 'sanitize_text_field' ], 'location' => [ 'label' => esc_html__( 'Map Location', 'cbxgooglemap' ), 'desc' => esc_html__( 'Type location and select from google map auto suggest.', 'cbxgooglemap' ), 'type' => 'location', 'default' => '', 'sanitize_callback' => 'sanitize_text_field' ], 'lat' => [ 'label' => esc_html__( 'Latitude', 'cbxgooglemap' ), 'desc' => esc_html__( 'If you select location from google map then latitude will be picked automatically but still you can put manually', 'cbxgooglemap' ), 'type' => 'lat', 'default' => '', 'sortable' => true, 'sanitize_callback' => 'sanitize_text_field' ], 'lng' => [ 'label' => esc_html__( 'Longitude', 'cbxgooglemap' ), 'desc' => esc_html__( 'If you select location from google map then longitude will be picked automatically but still you can put manually', 'cbxgooglemap' ), 'type' => 'lng', 'default' => '', 'sortable' => true, 'sanitize_callback' => 'sanitize_text_field' ], 'mapicon' => [ 'label' => esc_html__( 'Map Icon', 'cbxgooglemap' ), 'desc' => esc_html__( 'Map marker custom icon', 'cbxgooglemap' ), 'type' => 'file', 'default' => '', 'desc_tip' => true, 'sanitize_callback' => 'sanitize_text_field' ], ] ); return apply_filters( 'cbxgooglemap_fields', $meta_fields ); }//end method cbxgooglemap_meta_fields /** * Render the meta fields html * * @param $post * @param $meta_fields * @param $combined_field * @param $meta_prefix * @param $sectionable * * @return void\ */ public static function render_meta_fields( $post, $meta_fields, $combined_field, $meta_prefix, $sectionable = false ) { $settings = new CBXGooglemapSettings(); $general_settings = get_option( 'cbxgooglemap_general', [] ); $api_key = esc_attr( $settings->get_field( 'apikey', 'cbxgooglemap_general', '' ) ); $map_source = absint( $settings->get_field( 'mapsource', 'cbxgooglemap_general', 1 ) ); $scrollwheel_default = absint( $settings->get_field( 'scrollwheel', 'cbxgooglemap_general', 1 ) ); $showinfo_default = absint( $settings->get_field( 'showinfo', 'cbxgooglemap_general', 1 ) ); $mapicon_default = esc_url( $settings->get_field( 'mapicon', 'cbxgooglemap_general', '' ) ); if ( isset( $post->ID ) && $post->ID > 0 ) { $post_id = $post->ID; $post_type = $post->post_type; wp_nonce_field( 'cbxmetahelper_' . $post_type . '_meta_box', 'cbxmetahelper_' . $post_type . '_meta_box_nonce' ); $meta_combined = get_post_meta( $post_id, $combined_field, true ); //meta fields not sortable $mapicon = isset( $meta_combined['_cbxgooglemapmapicon'] ) ? esc_url( $meta_combined['_cbxgooglemapmapicon'] ) : $mapicon_default; $sections_found = false; $sections = []; $sections = CBXGooglemapMetaHelper::meta_field_sections( $post_id, $post_type ); echo '
'; } else { echo esc_html__( 'Please save first to add extra information.', 'cbxgooglemap' ); } }//end method render_meta_fields }//end class CBXGooglemapHelper