wpsl_admin_marker_dir

  1. Description
  2. Usage
  3. Changelog
  4. Source File
  5. Related

Description

This filter sets the path to a folder with your own marker images. The markers in this folder are added to the marker lists in the Markers settings.

The easier way to use your own marker is the Marker Studio under Store Locator > Marker Studio. You can design a marker there, or upload your own image, without any files or code. See Use Custom Markers.

The filter receives the path to the plugin’s own marker folder. Return the path to your folder instead. Your folder is searched first, and its markers are listed together with the bundled markers. A file with the same name as a bundled marker, for example red.png, replaces that bundled marker.

  • The marker files can be SVG or PNG. When a marker exists as both, the SVG file is used.
  • For a PNG marker, add a version at twice the size for high resolution screens, named my-marker@2x.png. Put it in the same folder. The my-marker2x.png name from older versions also works.
  • Other file types in the folder are ignored.
You also need to set the WPSL_MARKER_URI constant to the URL of the same folder. Without it, your markers show up in the marker lists, but their images are loaded from the plugin’s marker folder and don’t show.

Usage

This example uses a wpsl-markers folder inside your active theme folder.

add_filter( 'wpsl_admin_marker_dir', 'custom_admin_marker_dir' );
function custom_admin_marker_dir() {
// The 'wpsl-markers' folder inside your active theme.
return get_stylesheet_directory() . '/wpsl-markers/';
}

The path will look like this: /home/user/public_html/wp-content/themes/my_theme/wpsl-markers/.

Then set the WPSL_MARKER_URI constant to the URL of the same folder.

define( 'WPSL_MARKER_URI', get_stylesheet_directory_uri() . '/wpsl-markers/' );

The URL will look like this: https://example.com/wp-content/themes/my_theme/wpsl-markers/.

Upload your marker files to the folder, then pick them in Store Locator > Settings > Markers.

Only put marker images in this folder. Every PNG and SVG file in it is listed as a marker. If you also followed Change the Marker Cluster Style, its cluster.png shows up as a marker called “Cluster”. Move that image to another folder and update the path in that snippet.

A marker image from your folder is shown at the size of the image file. For a PNG marker, make my-marker.png the size you want to show, and my-marker@2x.png twice that size. To change the size in code, see wpsl_marker_props.

Changelog

VersionDescription
3.0Moved to includes/core/functions/functions-markers.php. Your folder no longer replaces the bundled markers. It is searched first, and its markers are listed together with the bundled ones. The filter now receives the path to assets/img/frontend/markers/. SVG markers are supported, and the SVG file is used when a marker exists as both SVG and PNG.
2.1Introduced.

Source File

This filter is located in /includes/core/functions/functions-markers.php.

Placement

The code needs to be placed in the functions.php file inside your active theme folder.