Skip to content

API & Feed Tuning Filters โ€‹

These filters tune how the plugin talks to each platform's API โ€” item limits, requested fields, and endpoints. All are in the wpsocialreviews/ namespace except the TikTok ones.

wpsocialreviews/facebook_feeds_limit โ€‹

wpsocialreviews/facebook_feeds_limit โ€” Number of Facebook feed items fetched

When it runs: applied by FacebookFeed::resolveFeedLimit() when building the Facebook feed API request.

Parameters:

  • $limit (int): the editor's feed count, run through absint().

Source: Services/Platforms/Feeds/Facebook/FacebookFeed.php

Usage:

php
add_filter('wpsocialreviews/facebook_feeds_limit', function ($limit) {
    return 25;
});

Changed in 4.5.0

The tier ceiling now applies after this filter, so the filter can lower a feed but not lift it past the tier: 50 items without Pro, 200 with Pro (see wpsocialreviews/facebook_feeds_max_limit). Before 4.5.0 the free cap ran first, so a free site's filter could fetch more than 50. The result is floored at 1.

wpsocialreviews/facebook_feeds_max_limit Pro 4.5.0 โ€” The Pro ceiling for Facebook feeds

When it runs: Applied by FacebookFeed::resolveFeedLimit() only when Pro is active. It sets the ceiling that wpsocialreviews/facebook_feeds_limit is clamped to. Without Pro the ceiling is a fixed 50 and this filter does not run.

Parameters:

  • $max (int): the ceiling, 200 by default.

Source: Services/Platforms/Feeds/Facebook/FacebookFeed.php

Usage:

php
add_filter('wpsocialreviews/facebook_feeds_max_limit', function ($max) {
    return 300;
});

TIP

A feed is cached as one blob, so a higher ceiling makes each cache entry larger and each refresh slower.

wpsocialreviews/youtube_feeds_limit 4.5.0 โ€‹

wpsocialreviews/youtube_feeds_limit โ€” Number of YouTube videos fetched

When it runs: Applied by YoutubeFeed::resolveFeedLimit() before the YouTube API request. Core caps the editor's count at 200 first; your callback has the final word, so it can lower or raise the count. The result is run through absint() and floored at 1.

Parameters:

  • $total (int): the editor's video count, capped at 200.
  • $feedType (string): the feed source โ€” channel_feed, playlist_feed, search_feed, live_streams_feed, or single_video_feed.

Source: Services/Platforms/Feeds/Youtube/YoutubeFeed.php

Usage:

php
add_filter('wpsocialreviews/youtube_feeds_limit', function ($total, $feedType) {
    return $feedType === 'search_feed' ? min($total, 50) : $total;
}, 10, 2);

API quota

Each page of 50 videos costs YouTube API quota, and a search page costs 100 units. Lowering the limit for search feeds is the cheapest way to stay under a daily quota.

wpsocialreviews/reviews_sync_time_limit 4.5.0 โ€‹

wpsocialreviews/reviews_sync_time_limit โ€” PHP time limit for a long review sync

When it runs: Applied before a Google or Facebook review sync. Since 4.5.0 a sync loads every page up to the review limit, so it can outlast PHP's default limit. The value is passed to set_time_limit() only when the current max_execution_time is shorter โ€” a longer or unlimited (0) limit is never shortened.

Parameters:

  • $seconds (int): the time limit, 300 by default.
  • $platform (string): google (core) or facebook (Pro).

Source: app/Services/Platforms/Reviews/GoogleMyBusiness.php; Pro app/Services/Platforms/Reviews/FacebookBusiness.php

Usage:

php
add_filter('wpsocialreviews/reviews_sync_time_limit', function ($seconds, $platform) {
    return $platform === 'google' ? 600 : $seconds;
}, 10, 2);

Feed API tuning (by platform) โ€‹

Facebook ยท Instagram ยท Twitter ยท YouTube ยท TikTok feed filters
Filter (examples)Purpose
facebook_timeline_feed_api_fields, facebook_feed_extend_api_endpoints, facebook_feed_should_fetch_more_attachmentsFacebook feed API
instagram_feeds_total_limit, instagram_feeds_limit, instagram_media_placeholder, fetch_instagram_commentsInstagram feed API
twitter_set_get_field, set_twitter_transient_name, twitter_feed_header_api_responseTwitter feed API
youtube_playlist_api_url_details, youtube_search_api_url_details, youtube_api_parts, youtube_thumbnail_size, youtube_feeds_by_popularityYouTube feed API
custom_feed_for_tiktok/tiktok_feeds_limit, tiktok_feeds_max_limit, tiktok_video_api_details, tiktok_specific_video_api_details, tiktok_specific_video_idsTikTok feed API

(Non-TikTok entries are wpsocialreviews/-prefixed.)

Removed in 4.5.0 โ€” wpsocialreviews/instagram_trim_caption_words

Caption trimming is now free and done by core in InstagramTemplateHandler. It trims after post_settings.trim_caption_words words, adds ..., and keeps HTML tags whole. The filter is no longer called, so a callback on it does nothing. To change the caption, override the wpsocialreviews/instagram_post_caption element action.

Review API tuning (by platform) โ€‹

Google ยท Airbnb ยท Booking review filters
Filter (examples)Purpose
gmb_reviews_limit, gmb_reviews_accounts_limit, gmb_locations_limitGoogle reviews
airbnb_reviews_limit_end_point, airbnb_cookie_header, airbnb_api_key, airbnb_p3_impression_idAirbnb reviews

Source: GoogleMyBusiness.php, Airbnb.php.

Changed in 4.5.0 โ€” gmb_reviews_limit

The value is now run through absint() and floored at 1. Without Pro it is still capped at 200; with Pro the filter's value is final. A sync loads every page up to the limit (see wpsocialreviews/reviews_sync_time_limit).

Removed in 4.5.0 โ€” wpsocialreviews/booking_header_request_cookie_set

Booking.com (Pro) no longer requests Booking pages directly, so there are no request headers to filter, and there is no replacement hook.

Business info refresh 4.4.0 โ€‹

Business details (name, rating, address) cost an API call per sync but change slowly, so they refresh on a much longer cycle than reviews.

wpsocialreviews/tripadvisor_business_info_ttl Pro โ€” How long Tripadvisor business info stays fresh

When it runs: Applied by Tripadvisor::businessInfoIsStale() on every staleness check. Return the lifetime in seconds; the default is 2592000 (30 days). Missing or unstamped info always counts as stale regardless of what you return, and the value is floored at 0.

Parameters:

  • $ttl (int): the lifetime in seconds.

Source: Pro app/Services/Platforms/Reviews/Tripadvisor.php

Usage:

php
add_filter('wpsocialreviews/tripadvisor_business_info_ttl', function ($ttl) {
    return WEEK_IN_SECONDS;
});
wpsocialreviews/airbnb_rooms_business_info_payload โ€” Supply an Airbnb request template

When it runs: Applied by Airbnb::getBusinessInfoPayloadTemplate() before fetching listing details. Airbnb serves business info from a persisted GraphQL query, so the request needs a variables object and the sha256Hash that was persisted with it. Return '' (the default) to skip the template entirely.

Core accepts three shapes and parses whichever it is given:

  • A full request URL โ€” variables and extensions are read from the query string, and the hash is also matched out of a /StaysPdpSections/<hash> path segment.
  • A query string containing variables=.
  • The raw variables JSON object, pasted on its own (must start with {).

Only the listing id fields are swapped into the pasted template before the request goes out (id, demandStayListingId, p3ImpressionId, and pdpSectionsRequest.p3ImpressionId), so the payload still matches the hash it was persisted with. Anything that does not yield both a non-empty variables array and a 64-character lowercase hex hash is discarded.

Parameters:

  • $payload (string): the request template, '' by default.

Source: app/Services/Platforms/Reviews/Airbnb.php

Usage:

php
add_filter('wpsocialreviews/airbnb_rooms_business_info_payload', function ($payload) {
    return 'https://www.airbnb.com/api/v3/StaysPdpSections/abcโ€ฆ?variables=%7Bโ€ฆ%7D&extensions=%7Bโ€ฆ%7D';
});

TIP

If you already have the variables JSON but no hash, paste the JSON here and supply the hash separately through wpsocialreviews/airbnb_rooms_business_info_api_secret_key. A hash found in the pasted payload always wins over that filter.

Common feed filters โ€‹

Cross-platform feed behavior โ€” Common/FeedFilters.php

These apply across feed platforms (replace {platform} with the slug):

FilterPurpose
wpsocialreviews/{platform}_feeds_by_popularitySort by popularity
wpsocialreviews/feeds_by_randomRandomize order
wpsocialreviews/responsive_post_countResponsive item count
wpsocialreviews/include_or_exclude_feedInclude/exclude items
wpsocialreviews/hide_feedHide specific items
wpsocialreviews/facebook_event_feed_sortingEvent feed sorting

Source: app/Services/Platforms/Feeds/Common/FeedFilters.php

Usage:

php
add_filter('wpsocialreviews/responsive_post_count', function ($count) {
    return 3; // show 3 items per row on small screens
});

WP Social Ninja Developer Documentation