Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder/module
File: Map.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class ET_Builder_Module_Map extends ET_Builder_Module {
[2] Fix | Delete
function init() {
[3] Fix | Delete
$this->name = esc_html__( 'Map', 'et_builder' );
[4] Fix | Delete
$this->plural = esc_html__( 'Maps', 'et_builder' );
[5] Fix | Delete
$this->slug = 'et_pb_map';
[6] Fix | Delete
$this->vb_support = 'on';
[7] Fix | Delete
$this->child_slug = 'et_pb_map_pin';
[8] Fix | Delete
$this->child_item_text = esc_html__( 'Pin', 'et_builder' );
[9] Fix | Delete
[10] Fix | Delete
$this->settings_modal_toggles = array(
[11] Fix | Delete
'general' => array(
[12] Fix | Delete
'toggles' => array(
[13] Fix | Delete
'map' => esc_html__( 'Map', 'et_builder' ),
[14] Fix | Delete
),
[15] Fix | Delete
),
[16] Fix | Delete
'advanced' => array(
[17] Fix | Delete
'toggles' => array(
[18] Fix | Delete
'controls' => esc_html__( 'Controls', 'et_builder' ),
[19] Fix | Delete
'child_filters' => array(
[20] Fix | Delete
'title' => esc_html__( 'Map', 'et_builder' ),
[21] Fix | Delete
'priority' => 51,
[22] Fix | Delete
),
[23] Fix | Delete
),
[24] Fix | Delete
),
[25] Fix | Delete
);
[26] Fix | Delete
[27] Fix | Delete
$this->advanced_fields = array(
[28] Fix | Delete
'box_shadow' => array(
[29] Fix | Delete
'default' => array(
[30] Fix | Delete
'css' => array(
[31] Fix | Delete
'overlay' => 'inset',
[32] Fix | Delete
),
[33] Fix | Delete
),
[34] Fix | Delete
),
[35] Fix | Delete
'margin_padding' => array(
[36] Fix | Delete
'css' => array(
[37] Fix | Delete
'important' => array( 'custom_margin' ), // needed to overwrite last module margin-bottom styling
[38] Fix | Delete
),
[39] Fix | Delete
),
[40] Fix | Delete
'filters' => array(
[41] Fix | Delete
'css' => array(
[42] Fix | Delete
'main' => '%%order_class%%',
[43] Fix | Delete
),
[44] Fix | Delete
'child_filters_target' => array(
[45] Fix | Delete
'tab_slug' => 'advanced',
[46] Fix | Delete
'toggle_slug' => 'child_filters',
[47] Fix | Delete
'label' => esc_html__( 'Map', 'et_builder' ),
[48] Fix | Delete
),
[49] Fix | Delete
),
[50] Fix | Delete
'child_filters' => array(
[51] Fix | Delete
'css' => array(
[52] Fix | Delete
'main' => '%%order_class%% .gm-style>div>div>div>div>div>img',
[53] Fix | Delete
),
[54] Fix | Delete
),
[55] Fix | Delete
'height' => array(
[56] Fix | Delete
'css' => array(
[57] Fix | Delete
'main' => '%%order_class%% > .et_pb_map',
[58] Fix | Delete
),
[59] Fix | Delete
'options' => array(
[60] Fix | Delete
'height' => array(
[61] Fix | Delete
'default' => '440px',
[62] Fix | Delete
'default_tablet' => '350px',
[63] Fix | Delete
'default_phone' => '200px',
[64] Fix | Delete
),
[65] Fix | Delete
),
[66] Fix | Delete
),
[67] Fix | Delete
'fonts' => false,
[68] Fix | Delete
'text' => false,
[69] Fix | Delete
'button' => false,
[70] Fix | Delete
'position_fields' => array(
[71] Fix | Delete
'default' => 'relative',
[72] Fix | Delete
),
[73] Fix | Delete
);
[74] Fix | Delete
[75] Fix | Delete
$this->help_videos = array(
[76] Fix | Delete
array(
[77] Fix | Delete
'id' => 'rV3rxmACDmw',
[78] Fix | Delete
'name' => esc_html__( 'An introduction to the Map module', 'et_builder' ),
[79] Fix | Delete
),
[80] Fix | Delete
);
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
function get_fields() {
[84] Fix | Delete
$fields = array(
[85] Fix | Delete
'google_maps_script_notice' => array(
[86] Fix | Delete
'type' => 'warning',
[87] Fix | Delete
'value' => et_pb_enqueue_google_maps_script(),
[88] Fix | Delete
'display_if' => false,
[89] Fix | Delete
'message' => esc_html__(
[90] Fix | Delete
sprintf(
[91] Fix | Delete
'The Google Maps API Script is currently disabled in the <a href="%s" target="_blank">Theme Options</a>. This module will not function properly without the Google Maps API.',
[92] Fix | Delete
admin_url( 'admin.php?page=et_divi_options' )
[93] Fix | Delete
),
[94] Fix | Delete
'et_builder'
[95] Fix | Delete
),
[96] Fix | Delete
'toggle_slug' => 'map',
[97] Fix | Delete
),
[98] Fix | Delete
'google_api_key' => array(
[99] Fix | Delete
'label' => esc_html__( 'Google API Key', 'et_builder' ),
[100] Fix | Delete
'type' => 'text',
[101] Fix | Delete
'option_category' => 'basic_option',
[102] Fix | Delete
'attributes' => 'readonly',
[103] Fix | Delete
'additional_button' => sprintf(
[104] Fix | Delete
' <a href="%2$s" target="_blank" class="et_pb_update_google_key button" data-empty_text="%3$s">%1$s</a>',
[105] Fix | Delete
esc_html__( 'Change API Key', 'et_builder' ),
[106] Fix | Delete
esc_url( et_pb_get_options_page_link() ),
[107] Fix | Delete
esc_attr__( 'Add Your API Key', 'et_builder' )
[108] Fix | Delete
),
[109] Fix | Delete
'additional_button_type' => 'change_google_api_key',
[110] Fix | Delete
'class' => array( 'et_pb_google_api_key', 'et-pb-helper-field' ),
[111] Fix | Delete
'description' => et_get_safe_localization( sprintf( __( 'The Maps module uses the Google Maps API and requires a valid Google API Key to function. Before using the map module, please make sure you have added your API key inside the Divi Theme Options panel. Learn more about how to create your Google API Key <a href="%1$s" target="_blank">here</a>.', 'et_builder' ), esc_url( 'http://www.elegantthemes.com/gallery/divi/documentation/map/#gmaps-api-key' ) ) ),
[112] Fix | Delete
'toggle_slug' => 'map',
[113] Fix | Delete
),
[114] Fix | Delete
'address' => array(
[115] Fix | Delete
'label' => esc_html__( 'Map Center Address', 'et_builder' ),
[116] Fix | Delete
'type' => 'text',
[117] Fix | Delete
'option_category' => 'basic_option',
[118] Fix | Delete
'additional_button' => sprintf(
[119] Fix | Delete
' <a href="#" class="et_pb_find_address button">%1$s</a>',
[120] Fix | Delete
esc_html__( 'Find', 'et_builder' )
[121] Fix | Delete
),
[122] Fix | Delete
'class' => array( 'et_pb_address' ),
[123] Fix | Delete
'description' => esc_html__( 'Enter an address for the map center point, and the address will be geocoded and displayed on the map below.', 'et_builder' ),
[124] Fix | Delete
'toggle_slug' => 'map',
[125] Fix | Delete
),
[126] Fix | Delete
'zoom_level' => array(
[127] Fix | Delete
'type' => 'hidden',
[128] Fix | Delete
'class' => array( 'et_pb_zoom_level' ),
[129] Fix | Delete
'default' => '18',
[130] Fix | Delete
),
[131] Fix | Delete
'address_lat' => array(
[132] Fix | Delete
'type' => 'hidden',
[133] Fix | Delete
'class' => array( 'et_pb_address_lat' ),
[134] Fix | Delete
),
[135] Fix | Delete
'address_lng' => array(
[136] Fix | Delete
'type' => 'hidden',
[137] Fix | Delete
'class' => array( 'et_pb_address_lng' ),
[138] Fix | Delete
),
[139] Fix | Delete
'map_center_map' => array(
[140] Fix | Delete
'type' => 'center_map',
[141] Fix | Delete
'use_container_wrapper' => false,
[142] Fix | Delete
'option_category' => 'basic_option',
[143] Fix | Delete
'toggle_slug' => 'map',
[144] Fix | Delete
),
[145] Fix | Delete
'mouse_wheel' => array(
[146] Fix | Delete
'label' => esc_html__( 'Mouse Wheel Zoom', 'et_builder' ),
[147] Fix | Delete
'type' => 'yes_no_button',
[148] Fix | Delete
'option_category' => 'configuration',
[149] Fix | Delete
'options' => array(
[150] Fix | Delete
'on' => et_builder_i18n( 'On' ),
[151] Fix | Delete
'off' => et_builder_i18n( 'Off' ),
[152] Fix | Delete
),
[153] Fix | Delete
'tab_slug' => 'advanced',
[154] Fix | Delete
'toggle_slug' => 'controls',
[155] Fix | Delete
'description' => esc_html__( 'Here you can choose whether the zoom level will be controlled by mouse wheel or not.', 'et_builder' ),
[156] Fix | Delete
'default_on_front' => 'on',
[157] Fix | Delete
),
[158] Fix | Delete
'mobile_dragging' => array(
[159] Fix | Delete
'label' => esc_html__( 'Draggable On Mobile', 'et_builder' ),
[160] Fix | Delete
'type' => 'yes_no_button',
[161] Fix | Delete
'option_category' => 'configuration',
[162] Fix | Delete
'options' => array(
[163] Fix | Delete
'on' => et_builder_i18n( 'On' ),
[164] Fix | Delete
'off' => et_builder_i18n( 'Off' ),
[165] Fix | Delete
),
[166] Fix | Delete
'tab_slug' => 'advanced',
[167] Fix | Delete
'toggle_slug' => 'controls',
[168] Fix | Delete
'description' => esc_html__( 'Here you can choose whether or not the map will be draggable on mobile devices.', 'et_builder' ),
[169] Fix | Delete
'default_on_front' => 'on',
[170] Fix | Delete
),
[171] Fix | Delete
'use_grayscale_filter' => array(
[172] Fix | Delete
'label' => esc_html__( 'Use Grayscale Filter', 'et_builder' ),
[173] Fix | Delete
'description' => esc_html__( 'Applying the grayscale filter will change the map colors to black and white.', 'et_builder' ),
[174] Fix | Delete
'type' => 'yes_no_button',
[175] Fix | Delete
'option_category' => 'configuration',
[176] Fix | Delete
'options' => array(
[177] Fix | Delete
'off' => et_builder_i18n( 'No' ),
[178] Fix | Delete
'on' => et_builder_i18n( 'Yes' ),
[179] Fix | Delete
),
[180] Fix | Delete
'affects' => array(
[181] Fix | Delete
'grayscale_filter_amount',
[182] Fix | Delete
),
[183] Fix | Delete
'tab_slug' => 'advanced',
[184] Fix | Delete
'toggle_slug' => 'child_filters',
[185] Fix | Delete
'default_on_front' => 'off',
[186] Fix | Delete
),
[187] Fix | Delete
'grayscale_filter_amount' => array(
[188] Fix | Delete
'label' => esc_html__( 'Grayscale Filter Amount (%)', 'et_builder' ),
[189] Fix | Delete
'description' => esc_html__( 'Adjusting the grayscale filter will allow you to change the color saturation of the map.', 'et_builder' ),
[190] Fix | Delete
'type' => 'range',
[191] Fix | Delete
'default' => '0',
[192] Fix | Delete
'option_category' => 'configuration',
[193] Fix | Delete
'tab_slug' => 'advanced',
[194] Fix | Delete
'toggle_slug' => 'child_filters',
[195] Fix | Delete
'depends_show_if' => 'on',
[196] Fix | Delete
'unitless' => false,
[197] Fix | Delete
'mobile_options' => true,
[198] Fix | Delete
),
[199] Fix | Delete
);
[200] Fix | Delete
return $fields;
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
public function get_transition_fields_css_props() {
[204] Fix | Delete
$fields = parent::get_transition_fields_css_props();
[205] Fix | Delete
$filters = $this->get_transition_filters_fields_css_props( 'child_filters' );
[206] Fix | Delete
[207] Fix | Delete
return array_merge( $fields, $filters );
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
/**
[211] Fix | Delete
* Renders the module output.
[212] Fix | Delete
*
[213] Fix | Delete
* @param array $attrs List of attributes.
[214] Fix | Delete
* @param string $content Content being processed.
[215] Fix | Delete
* @param string $render_slug Slug of module that is used for rendering output.
[216] Fix | Delete
*
[217] Fix | Delete
* @return string
[218] Fix | Delete
*/
[219] Fix | Delete
public function render( $attrs, $content, $render_slug ) {
[220] Fix | Delete
$address_lat = $this->props['address_lat'];
[221] Fix | Delete
$address_lng = $this->props['address_lng'];
[222] Fix | Delete
$zoom_level = $this->props['zoom_level'];
[223] Fix | Delete
$mouse_wheel = $this->props['mouse_wheel'];
[224] Fix | Delete
$mobile_dragging = $this->props['mobile_dragging'];
[225] Fix | Delete
$use_grayscale_filter = $this->props['use_grayscale_filter'];
[226] Fix | Delete
[227] Fix | Delete
// Grayscale Filter.
[228] Fix | Delete
$grayscale_filter_amount_values = et_pb_responsive_options()->get_property_values( $this->props, 'grayscale_filter_amount' );
[229] Fix | Delete
$grayscale_filter_amount = isset( $grayscale_filter_amount_values['desktop'] ) ? $grayscale_filter_amount_values['desktop'] : '';
[230] Fix | Delete
$grayscale_filter_amount_tablet = isset( $grayscale_filter_amount_values['tablet'] ) ? $grayscale_filter_amount_values['tablet'] : '';
[231] Fix | Delete
$grayscale_filter_amount_phone = isset( $grayscale_filter_amount_values['phone'] ) ? $grayscale_filter_amount_values['phone'] : '';
[232] Fix | Delete
[233] Fix | Delete
if ( et_pb_enqueue_google_maps_script() ) {
[234] Fix | Delete
wp_enqueue_script( 'google-maps-api' );
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
$video_background = $this->video_background();
[238] Fix | Delete
$parallax_image_background = $this->get_parallax_image_background();
[239] Fix | Delete
[240] Fix | Delete
$all_pins_content = $this->content;
[241] Fix | Delete
[242] Fix | Delete
$grayscale_filter_data = '';
[243] Fix | Delete
$grayscale_filter_data_tablet = '';
[244] Fix | Delete
$grayscale_filter_data_phone = '';
[245] Fix | Delete
if ( 'on' === $use_grayscale_filter ) {
[246] Fix | Delete
if ( '' !== $grayscale_filter_amount ) {
[247] Fix | Delete
$grayscale_filter_data = sprintf( ' data-grayscale="%1$s"', esc_attr( $grayscale_filter_amount ) );
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
if ( '' !== $grayscale_filter_amount_tablet ) {
[251] Fix | Delete
$grayscale_filter_data_tablet = sprintf( ' data-grayscale-tablet="%1$s"', esc_attr( $grayscale_filter_amount_tablet ) );
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
if ( '' !== $grayscale_filter_amount_phone ) {
[255] Fix | Delete
$grayscale_filter_data_phone = sprintf( ' data-grayscale-phone="%1$s"', esc_attr( $grayscale_filter_amount_phone ) );
[256] Fix | Delete
}
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
// Map Tiles: Add CSS Filters and Mix Blend Mode rules (if set)
[260] Fix | Delete
if ( array_key_exists( 'child_filters', $this->advanced_fields ) && array_key_exists( 'css', $this->advanced_fields['child_filters'] ) ) {
[261] Fix | Delete
$this->add_classname(
[262] Fix | Delete
$this->generate_css_filters(
[263] Fix | Delete
$render_slug,
[264] Fix | Delete
'child_',
[265] Fix | Delete
self::$data_utils->array_get( $this->advanced_fields['child_filters']['css'], 'main', '%%order_class%%' )
[266] Fix | Delete
)
[267] Fix | Delete
);
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
// Module classnames
[271] Fix | Delete
$this->add_classname(
[272] Fix | Delete
array(
[273] Fix | Delete
'et_pb_map_container',
[274] Fix | Delete
)
[275] Fix | Delete
);
[276] Fix | Delete
[277] Fix | Delete
$this->remove_classname( $render_slug );
[278] Fix | Delete
[279] Fix | Delete
$output = sprintf(
[280] Fix | Delete
'<div%5$s class="%6$s"%8$s%12$s%13$s>
[281] Fix | Delete
%11$s
[282] Fix | Delete
%10$s
[283] Fix | Delete
<div class="et_pb_map" data-center-lat="%1$s" data-center-lng="%2$s" data-zoom="%3$d" data-mouse-wheel="%7$s" data-mobile-dragging="%9$s"></div>
[284] Fix | Delete
%4$s
[285] Fix | Delete
</div>',
[286] Fix | Delete
esc_attr( $address_lat ),
[287] Fix | Delete
esc_attr( $address_lng ),
[288] Fix | Delete
esc_attr( $zoom_level ),
[289] Fix | Delete
$all_pins_content,
[290] Fix | Delete
$this->module_id(), // #5
[291] Fix | Delete
$this->module_classname( $render_slug ),
[292] Fix | Delete
esc_attr( $mouse_wheel ),
[293] Fix | Delete
$grayscale_filter_data,
[294] Fix | Delete
esc_attr( $mobile_dragging ),
[295] Fix | Delete
$video_background, // #10
[296] Fix | Delete
$parallax_image_background,
[297] Fix | Delete
$grayscale_filter_data_tablet,
[298] Fix | Delete
$grayscale_filter_data_phone
[299] Fix | Delete
);
[300] Fix | Delete
[301] Fix | Delete
return $output;
[302] Fix | Delete
}
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
new ET_Builder_Module_Map();
[306] Fix | Delete
[307] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function