/** * @param \CMB2 $meta_box The meta box to add fields to. * @param array $params The params to add fields with. */ private function add_blocks($meta_box, $params) { $meta_box->add_field(array('name' => $params['block'] . ' ' . __('block title', 'yoastcom'), 'id' => 'block_' . $params['name'] . '_title', 'type' => 'text')); $meta_box->add_field(array('name' => $params['block'] . ' ' . __('block description', 'yoastcom'), 'id' => 'block_' . $params['name'] . '_description', 'type' => 'textarea')); $meta_box->add_field(array('name' => $params['block'] . ' ' . __('block link text', 'yoastcom'), 'id' => 'block_' . $params['name'] . '_link_text', 'type' => 'text')); $meta_box->add_field(array('name' => $params['block'] . ' ' . __('block link', 'yoastcom'), 'id' => 'block_' . $params['name'] . '_link', 'type' => 'text_url')); $meta_box->add_field(array('name' => $params['block'] . ' ' . __('block icon', 'yoastcom'), 'id' => 'block_' . $params['name'] . '_icon', 'type' => 'select', 'options' => array('academy' => 'Academy', 'blog' => 'Blog', 'book' => 'Book', 'calendar' => 'Calendar', 'drupal' => 'Drupal', 'pencil' => 'Pencil', 'video' => 'Video', 'wordpress' => 'WordPress'))); }
/** * Initiate CMB2 Taxonomy Meta * * @since 1.0.0 * * @param string $taxonomy Taxonomy Slug * @param mixed $meta_box Metabox config array or Metabox ID * @param string $title Optional section title * @param array $option_callbacks Override the option setting/getting */ public function __construct($taxonomy, $metabox, $title = '', $option_callbacks = array()) { $this->cmb = cmb2_get_metabox($metabox); // if passing a metabox ID, and that ID was not found if (!$this->cmb) { return; } // If a title was passed in if ($title) { // Then add a title field to the list of fields for CMB $this->cmb->add_field(array('name' => $title, 'id' => sanitize_title($title), 'type' => 'title'), 1); } parent::__construct($taxonomy, array(), '', $option_callbacks); }
/** * Defines the Google Places CPT metabox and field configuration. * * @since 1.0.0 * @return array */ public function cpt2_metaboxes_fields() { $prefix = 'gmb_'; $default_options = $this->get_default_map_options(); // Google map preview. $preview_box = cmb2_get_metabox(array('id' => 'google_maps_preview_metabox', 'title' => __('Google Map Preview', 'google-maps-builder'), 'object_types' => array('google_maps'), 'context' => 'normal', 'priority' => 'high', 'show_names' => false)); $preview_box->add_field(array('name' => __('Map Preview', 'google-maps-builder'), 'id' => $prefix . 'preview', 'type' => 'google_maps_preview', 'default' => '')); // Google maps markers. $this->marker_box = cmb2_get_metabox(array('id' => 'google_maps_markers', 'title' => __('Map Markers', 'google-maps-builder'), 'object_types' => array('google_maps'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true)); $this->marker_box->add_field(array('name' => __('Create Marker', 'google-maps-builder'), 'id' => $prefix . 'geocoder', 'type' => 'google_geocoder')); $this->marker_box_group_field_id = $this->marker_box->add_field(array('name' => __('Existing Markers', 'google-maps-builder'), 'id' => $prefix . 'markers_group', 'type' => 'group', 'description' => __('Map marker data is contained within the repeatable fields below. You may add or update marker data here or directly on the map.', 'google-maps-builder') . '<a href="#" class="button button-small toggle-repeater-groups">' . __('Toggle Marker Groups', 'google-maps-builder') . '</a>', 'options' => array('group_title' => __('Marker: {#}', 'cmb'), 'add_button' => __('Add Another Marker', 'google-maps-builder'), 'remove_button' => __('Remove Marker', 'google-maps-builder'), 'sortable' => true))); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Marker Title', 'google-maps-builder'), 'id' => 'title', 'type' => 'text')); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Marker Description', 'google-maps-builder'), 'description' => __('Write a short description for this marker', 'google-maps-builder'), 'id' => 'description', 'type' => 'textarea_small', 'sanitization_cb' => false)); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Marker Reference', 'google-maps-builder'), 'id' => 'reference', 'type' => 'text')); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Marker Place ID', 'google-maps-builder'), 'id' => 'place_id', 'type' => 'text')); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Hide Place Details', 'google-maps-builder'), 'id' => 'hide_details', 'type' => 'checkbox')); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Marker Latitude', 'google-maps-builder'), 'id' => 'lat', 'type' => 'text')); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Marker Longitude', 'google-maps-builder'), 'id' => 'lng', 'type' => 'text')); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Custom Marker Image', 'google-maps-builder'), 'id' => 'marker_img', 'row_classes' => 'gmb-hidden', 'type' => 'file', 'options' => array('url' => false, 'add_upload_file_text' => __('Add Marker Image', 'google-maps-builder')))); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Included Marker Icon', 'google-maps-builder'), 'row_classes' => 'gmb-hidden', 'id' => 'marker_included_img', 'type' => 'text')); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Marker Data', 'google-maps-builder'), 'row_classes' => 'gmb-hidden', 'id' => 'marker', 'type' => 'textarea_code')); $this->marker_box->add_group_field($this->marker_box_group_field_id, array('name' => __('Marker Label Data', 'google-maps-builder'), 'row_classes' => 'gmb-hidden', 'id' => 'label', 'type' => 'textarea_code')); // Search options. $this->search_options = cmb2_get_metabox(array('id' => 'google_maps_search_options', 'title' => __('Google Places', 'google-maps-builder'), 'object_types' => array('google_maps'), 'context' => 'normal', 'priority' => 'core', 'show_names' => true)); $this->search_options->add_field(array('name' => __('Show Places?', 'google-maps-builder'), 'desc' => __('Display establishments, prominent points of interest, geographic locations, and more.', 'google-maps-builder'), 'id' => $prefix . 'show_places', 'type' => 'radio_inline', 'options' => array('yes' => __('Yes', 'cmb'), 'no' => __('No', 'cmb')))); $this->search_options->add_field(array('name' => __('Search Radius', 'google-maps-builder'), 'desc' => __('Defines the distance (in meters) within which to return Place markers. The maximum allowed radius is 50,000 meters.', 'google-maps-builder'), 'default' => '3000', 'id' => $prefix . 'search_radius', 'type' => 'text_small')); $this->search_options->add_field(array('name' => __('Place Types', 'google-maps-builder'), 'desc' => __('Select which type of places you would like to display on this map.', 'google-maps-builder'), 'id' => $prefix . 'places_search_multicheckbox', 'type' => 'multicheck', 'options' => apply_filters('gmb_place_types', array('accounting' => __('Accounting', 'google-maps-builder'), 'airport' => __('Airport', 'google-maps-builder'), 'amusement_park' => __('Amusement Park', 'google-maps-builder'), 'aquarium' => __('Aquarium', 'google-maps-builder'), 'art_gallery' => __('Art Gallery', 'google-maps-builder'), 'atm' => __('ATM', 'google-maps-builder'), 'bakery' => __('Bakery', 'google-maps-builder'), 'bank' => __('Bank', 'google-maps-builder'), 'bar' => __('Bar', 'google-maps-builder'), 'beauty_salon' => __('Beauty Salon', 'google-maps-builder'), 'bicycle_store' => __('Bicycle Store', 'google-maps-builder'), 'book_store' => __('Book Store', 'google-maps-builder'), 'bowling_alley' => __('Bowling Alley', 'google-maps-builder'), 'bus_station' => __('Bus Station', 'google-maps-builder'), 'cafe' => __('Cafe', 'google-maps-builder'), 'campground' => __('Campground', 'google-maps-builder'), 'car_dealer' => __('Car Dealer', 'google-maps-builder'), 'car_rental' => __('Car Rental', 'google-maps-builder'), 'car_repair' => __('Car Repair', 'google-maps-builder'), 'car_wash' => __('Car Wash', 'google-maps-builder'), 'casino' => __('Casino', 'google-maps-builder'), 'cemetery' => __('Cemetery', 'google-maps-builder'), 'church' => __('Church', 'google-maps-builder'), 'city_hall' => __('City Hall', 'google-maps-builder'), 'clothing_store' => __('Clothing Store', 'google-maps-builder'), 'convenience_store' => __('Convenience Store', 'google-maps-builder'), 'courthouse' => __('Courthouse', 'google-maps-builder'), 'dentist' => __('Dentist', 'google-maps-builder'), 'department_store' => __('Department Store', 'google-maps-builder'), 'doctor' => __('Doctor', 'google-maps-builder'), 'electrician' => __('Electrician', 'google-maps-builder'), 'electronics_store' => __('Electronics Store', 'google-maps-builder'), 'embassy' => __('Embassy', 'google-maps-builder'), 'establishment' => __('Establishment', 'google-maps-builder'), 'finance' => __('Finance', 'google-maps-builder'), 'fire_station' => __('Fire Station', 'google-maps-builder'), 'florist' => __('Florist', 'google-maps-builder'), 'food' => __('Food', 'google-maps-builder'), 'funeral_home' => __('Funeral Home', 'google-maps-builder'), 'furniture_store' => __('Furniture_store', 'google-maps-builder'), 'gas_station' => __('Gas Station', 'google-maps-builder'), 'general_contractor' => __('General Contractor', 'google-maps-builder'), 'grocery_or_supermarket' => __('Grocery or Supermarket', 'google-maps-builder'), 'gym' => __('Gym', 'google-maps-builder'), 'hair_care' => __('Hair Care', 'google-maps-builder'), 'hardware_store' => __('Hardware Store', 'google-maps-builder'), 'health' => __('Health', 'google-maps-builder'), 'hindu_temple' => __('Hindu Temple', 'google-maps-builder'), 'home_goods_store' => __('Home Goods Store', 'google-maps-builder'), 'hospital' => __('Hospital', 'google-maps-builder'), 'insurance_agency' => __('Insurance Agency', 'google-maps-builder'), 'jewelry_store' => __('Jewelry Store', 'google-maps-builder'), 'laundry' => __('Laundry', 'google-maps-builder'), 'lawyer' => __('Lawyer', 'google-maps-builder'), 'library' => __('Library', 'google-maps-builder'), 'liquor_store' => __('Liquor Store', 'google-maps-builder'), 'local_government_office' => __('Local Government Office', 'google-maps-builder'), 'locksmith' => __('Locksmith', 'google-maps-builder'), 'lodging' => __('Lodging', 'google-maps-builder'), 'meal_delivery' => __('Meal Delivery', 'google-maps-builder'), 'meal_takeaway' => __('Meal Takeaway', 'google-maps-builder'), 'mosque' => __('Mosque', 'google-maps-builder'), 'movie_rental' => __('Movie Rental', 'google-maps-builder'), 'movie_theater' => __('Movie Theater', 'google-maps-builder'), 'moving_company' => __('Moving Company', 'google-maps-builder'), 'museum' => __('Museum', 'google-maps-builder'), 'night_club' => __('Night Club', 'google-maps-builder'), 'painter' => __('Painter', 'google-maps-builder'), 'park' => __('Park', 'google-maps-builder'), 'parking' => __('Parking', 'google-maps-builder'), 'pet_store' => __('Pet Store', 'google-maps-builder'), 'pharmacy' => __('Pharmacy', 'google-maps-builder'), 'physiotherapist' => __('Physiotherapist', 'google-maps-builder'), 'place_of_worship' => __('Place of Worship', 'google-maps-builder'), 'plumber' => __('Plumber', 'google-maps-builder'), 'police' => __('Police', 'google-maps-builder'), 'post_office' => __('Post Office', 'google-maps-builder'), 'real_estate_agency' => __('Real Estate Agency', 'google-maps-builder'), 'restaurant' => __('Restaurant', 'google-maps-builder'), 'roofing_contractor' => __('Roofing Contractor', 'google-maps-builder'), 'rv_park' => __('RV Park', 'google-maps-builder'), 'school' => __('School', 'google-maps-builder'), 'shoe_store' => __('Shoe Store', 'google-maps-builder'), 'shopping_mall' => __('Shopping Mall', 'google-maps-builder'), 'spa' => __('Spa', 'google-maps-builder'), 'stadium' => __('Stadium', 'google-maps-builder'), 'storage' => __('Storage', 'google-maps-builder'), 'store' => __('Store', 'google-maps-builder'), 'subway_station' => __('Subway Station', 'google-maps-builder'), 'synagogue' => __('Synagogue', 'google-maps-builder'), 'taxi_stand' => __('Taxi Stand', 'google-maps-builder'), 'train_station' => __('Train Station', 'google-maps-builder'), 'travel_agency' => __('Travel Agency', 'google-maps-builder'), 'university' => __('University', 'google-maps-builder'), 'veterinary_care' => __('Veterinary Care', 'google-maps-builder'), 'zoo' => __('Zoo', 'google-maps-builder'))))); /** * Display Options */ $this->display_options = cmb2_get_metabox(array('id' => 'google_maps_options', 'title' => __('Display Options', 'google-maps-builder'), 'object_types' => array('google_maps'), 'context' => 'side', 'priority' => 'default', 'show_names' => true)); $this->display_options->add_field(array('name' => __('Map Size', 'google-maps-builder'), 'id' => $prefix . 'width_height', 'type' => 'width_height', 'width_std' => $default_options['width'], 'width_unit_std' => $default_options['width_unit'], 'height_std' => $default_options['height'], 'desc' => '')); $this->display_options->add_field(array('name' => __('Map Location', 'google-maps-builder'), 'id' => $prefix . 'lat_lng', 'type' => 'lat_lng', 'lat_std' => '', 'lng_std' => '', 'desc' => '')); $this->display_options->add_field(array('name' => __('Map Type', 'google-maps-builder'), 'id' => $prefix . 'type', 'type' => 'select', 'default' => 'default', 'options' => array('RoadMap' => __('Road Map', 'google-maps-builder'), 'Satellite' => __('Satellite', 'google-maps-builder'), 'Hybrid' => __('Hybrid', 'google-maps-builder'), 'Terrain' => __('Terrain', 'google-maps-builder')))); $this->display_options->add_field(array('name' => 'Zoom', 'desc' => __('Adjust the map zoom (0-21)', 'google-maps-builder'), 'id' => $prefix . 'zoom', 'type' => 'select', 'default' => '15', 'options' => apply_filters('gmb_map_zoom_levels', array('21' => '21', '20' => '20', '19' => '19', '18' => '18', '17' => '17', '16' => '16', '15' => '15', '14' => '14', '13' => '13', '12' => '12', '11' => '11', '10' => '10', '9' => '9', '8' => '8', '7' => '7', '6' => '6', '5' => '5', '4' => '4', '3' => '3', '2' => '2', '1' => '1', '0' => '0')))); $this->display_options->add_field(array('name' => 'Map Layers', 'desc' => __('Layers provide additional information overlayed on the map.', 'google-maps-builder'), 'id' => $prefix . 'layers', 'type' => 'multicheck', 'select_all_button' => false, 'options' => apply_filters('gmb_map_zoom_levels', array('traffic' => __('Traffic', 'google-maps-builder'), 'transit' => __('Transit', 'google-maps-builder'), 'bicycle' => __('Bicycle', 'google-maps-builder'))))); $this->display_options->add_field(array('name' => __('Map Theme', 'google-maps-builder'), 'desc' => sprintf(__('Set optional preconfigured <a href="%1s" class="snazzy-link new-window" target="_blank">Snazzy Maps</a> styles by selecting from the dropdown above.', 'google-maps-builder'), esc_url('http://snazzymaps.com')), 'id' => $prefix . 'theme', 'type' => 'select', 'default' => 'none', 'options' => apply_filters('gmb_snazzy_maps', array('none' => __('None', 'google-maps-builder'), '68' => __('Aqua', 'google-maps-builder'), '73' => __('A Dark World', 'google-maps-builder'), '28' => __('Bluish', 'google-maps-builder'), '80' => __('Cool Grey', 'google-maps-builder'), '77' => __('Clean Cut', 'google-maps-builder'), '36' => __('Flat Green', 'google-maps-builder'), '44' => __('MapBox', 'google-maps-builder'), '83' => __('Muted Blue', 'google-maps-builder'), '22' => __('Old Timey', 'google-maps-builder'), '1' => __('Pale Dawn', 'google-maps-builder'), '19' => __('Paper', 'google-maps-builder'), '37' => __('Lunar Landscape', 'google-maps-builder'), '75' => __('Shade of Green', 'google-maps-builder'), '27' => __('Shift Worker', 'google-maps-builder'), '15' => __('Subtle Grayscale', 'google-maps-builder'), '50' => __('The Endless Atlas', 'google-maps-builder'))))); $this->display_options->add_field(array('name' => __('Custom Map Theme JSON', 'google-maps-builder'), 'desc' => __('Paste the Snazzy Map JSON code into the field above to set the theme.', 'google-maps-builder'), 'id' => $prefix . 'theme_json', 'type' => 'textarea_code')); // Control options. $this->control_options = cmb2_get_metabox(array('id' => 'google_maps_control_options', 'title' => __('Map Controls', 'google-maps-builder'), 'object_types' => array('google_maps'), 'context' => 'side', 'priority' => 'default', 'show_names' => true)); $this->control_options->add_field(array('name' => __('Zoom Control', 'google-maps-builder'), 'id' => $prefix . 'zoom_control', 'type' => 'select', 'default' => 'default', 'options' => array('none' => __('None', 'google-maps-builder'), 'small' => __('Small', 'google-maps-builder'), 'large' => __('Large', 'google-maps-builder'), 'default' => __('Default', 'google-maps-builder')))); $this->control_options->add_field(array('name' => __('Street View', 'google-maps-builder'), 'id' => $prefix . 'street_view', 'type' => 'select', 'default' => 'true', 'options' => array('none' => __('None', 'google-maps-builder'), 'true' => __('Standard', 'google-maps-builder')))); $this->control_options->add_field(array('name' => __('Pan Control', 'google-maps-builder'), 'id' => $prefix . 'pan', 'type' => 'select', 'default' => 'true', 'options' => array('none' => __('None', 'google-maps-builder'), 'true' => __('Standard', 'google-maps-builder')))); $this->control_options->add_field(array('name' => __('Map Type Control', 'google-maps-builder'), 'id' => $prefix . 'map_type_control', 'type' => 'select', 'default' => 'horizontal_bar', 'options' => array('none' => __('None', 'google-maps-builder'), 'dropdown_menu' => __('Dropdown Menu', 'google-maps-builder'), 'horizontal_bar' => __('Horizontal Bar', 'google-maps-builder')))); $this->control_options->add_field(array('name' => __('Draggable Map', 'google-maps-builder'), 'id' => $prefix . 'draggable', 'type' => 'select', 'default' => 'true', 'options' => array('none' => __('None', 'google-maps-builder'), 'true' => __('Standard', 'google-maps-builder')))); $this->control_options->add_field(array('name' => __('Double Click to Zoom', 'google-maps-builder'), 'id' => $prefix . 'double_click', 'type' => 'select', 'default' => 'true', 'options' => array('none' => __('None', 'google-maps-builder'), 'true' => __('Standard', 'google-maps-builder')))); $this->control_options->add_field(array('name' => __('Mouse Wheel to Zoom', 'google-maps-builder'), 'id' => $prefix . 'wheel_zoom', 'type' => 'select', 'default' => 'true', 'options' => array('none' => __('Disabled', 'google-maps-builder'), 'true' => __('Standard', 'google-maps-builder')))); }