Waymorphic Map. * * @package WaymorphicMap */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Registers the option and its fields. */ function waymorphic_map_register_settings() { register_setting( 'waymorphic_map', 'waymorphic_map_options', array( 'type' => 'array', 'sanitize_callback' => 'waymorphic_map_sanitize_options', 'default' => waymorphic_map_option_defaults(), ) ); add_settings_section( 'waymorphic_map_defaults', __( 'Defaults', 'waymorphic-map' ), 'waymorphic_map_section_text', 'waymorphic_map' ); $fields = array( 'style' => __( 'Map style', 'waymorphic-map' ), 'height' => __( 'Height', 'waymorphic-map' ), 'zoom' => __( 'Zoom', 'waymorphic-map' ), 'directions' => __( 'Directions link', 'waymorphic-map' ), 'tiles_url' => __( 'Tile server URL', 'waymorphic-map' ), ); foreach ( $fields as $name => $label ) { add_settings_field( 'waymorphic_map_' . $name, $label, 'waymorphic_map_field', 'waymorphic_map', 'waymorphic_map_defaults', array( 'name' => $name, 'label_for' => 'waymorphic_map_' . $name, ) ); } } /** * The text above the fields. */ function waymorphic_map_section_text() { echo '

' . esc_html__( 'A map uses these values when its block or shortcode does not set them.', 'waymorphic-map' ) . '

'; } /** * One field. * * @param array $args The field name and id. */ function waymorphic_map_field( $args ) { $options = waymorphic_map_options(); $name = $args['name']; $id = $args['label_for']; $input = 'waymorphic_map_options[' . $name . ']'; switch ( $name ) { case 'style': echo ''; break; case 'height': echo ''; echo '

' . esc_html__( 'A CSS length, for example 400px or 60vh. A number without a unit is in pixels.', 'waymorphic-map' ) . '

'; break; case 'zoom': echo ''; echo '

' . esc_html__( '0 shows the world, 12 a town, 16 a street.', 'waymorphic-map' ) . '

'; break; case 'directions': $current = waymorphic_map_default_directions(); echo ''; echo '

' . esc_html__( 'The map service that the directions link of a map opens. The link shows on the maps that have the directions link on. A map can have its own service.', 'waymorphic-map' ) . '

'; break; case 'tiles_url': echo ''; echo '

' . esc_html__( 'Change this only if you run your own Waymorphic Map tile server.', 'waymorphic-map' ) . '

'; break; } } /** * Adds the page to the Settings menu. */ function waymorphic_map_add_settings_page() { add_options_page( __( 'Waymorphic Map', 'waymorphic-map' ), __( 'Waymorphic Map', 'waymorphic-map' ), 'manage_options', 'waymorphic-map', 'waymorphic_map_settings_page' ); } /** * The page. */ function waymorphic_map_settings_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } ?>


[waymorphic_map lat="51.5074" lng="-0.1276" zoom="11" label="London"]

Waymorphic Map', 'OpenStreetMap' ), array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array(), ), ) ); ?>

contact@waymorphic.com

$links The links of the plugin. * @return array */ function waymorphic_map_action_links( $links ) { array_unshift( $links, '' . esc_html__( 'Settings', 'waymorphic-map' ) . '' ); return $links; }