Developer reference

Hooks and filters

Developers: filters for customising TuneSera and TuneSera Pro.

On this page
  1. Free plugin filters
  2. TuneSera Pro filters
  3. Examples
  4. Related articles

TuneSera provides WordPress filters so developers can change its behaviour without editing plugin files. Add these to a small custom plugin or your child theme’s functions.php.

Free plugin filters#

FilterArgumentsUse it to
tunesera_directory_station_query_args$query_args, $sortChange the WP_Query arguments used by the directory.
tunesera_directory_sort_options$sortsSort options offered to visitors. Default: newest, name_asc, name_desc.
tunesera_directory_initial_options$optionsThe directory’s initial filter and view options.
tunesera_home_station_query_args$args, $mode, $countryQuery arguments for homepage, featured and popular station sections.
tunesera_home_default_country$countryDefault country for country-based homepage sections.
tunesera_import_batch_size$size, $optionsStations processed per import batch (default 100).
tunesera_import_permissions$allowed, $optionsWhether the current user may run imports.
tunesera_import_directory_countries$countriesCountries offered in the bundled directory import.
tunesera_metadata_request_limit$limitMaximum outgoing now-playing requests per minute, site-wide (default 60, maximum 120).
tunesera_admin_settings$settingsData passed to the admin settings app.
tunesera_overview_data$dataData shown on the TuneSera dashboard.
tunesera_admin_promotion_enabled$enabledReturn false to hide Pro promotions in the free plugin.
tunesera_pro_upgrade_url$urlThe upgrade link used in the free plugin.

TuneSera Pro filters#

FilterArgumentsUse it to
tunesera_pro_country_lookup_url$urlCountry lookup service for local discovery (default https://api.country.is/).
tunesera_pro_analytics_country$country, $requestProvide a verified two-letter listener country for analytics, for example from a local GeoIP database.
tunesera_pro_analytics_rate_limit$limitMaximum analytics events accepted per rate window (default 600).
tunesera_analytics_health_thresholds$thresholdsWhen a station is flagged in Playback Health. Default: 20 attempts minimum, 90% success.

Examples#

Only list stations that broadcast on FM:

add_filter( 'tunesera_directory_station_query_args', function ( $args, $sort ) {
  $args['meta_query'][] = array(
    'key'     => '_tunesera_broadcast_type',
    'value'   => 'FM',
    'compare' => 'LIKE',
  );
  return $args;
}, 10, 2 );

Use a local GeoIP lookup for analytics countries (Pro):

add_filter( 'tunesera_pro_analytics_country', function ( $country, $request ) {
  // Return a verified two-letter ISO code from your server's GeoIP provider.
  return $country;
}, 10, 2 );

Filters can change in future releases. Test after updating, and keep customisations in a child theme or custom plugin so updates don’t overwrite them.

Still stuck?Our team usually replies the same day. Open a private ticket and we'll help you sort it out. Open a ticket