Appearance
Global Helpers
WP Social Ninja defines a set of global helper functions in the core plugin's boot/globals.php. They load before the framework, are function_exists()-guarded, and are available everywhere — Pro and the TikTok plugin define no globals of their own.
Loaded before the framework
boot/globals.php runs before the WPFluent container exists, so helpers defined there must not call framework services. Use the bootstrap hooks or Application::ready() for anything that needs the container.
Data helpers
| Function | Purpose |
|---|---|
wpsrGetReviews($platforms = [], $filters = []) | Return a filtered reviews array for the given platforms |
wpsrGetReviewsBusinessInfo($platforms = [], $sourceIds = []) | Business info for the given platforms/sources |
wpsrGetReviewsDataFromTemplate($templateId) | Resolve template_meta + reviews + business info from a saved template post |
php
// Fetch approved reviews for Google + Facebook
$reviews = wpsrGetReviews(['google', 'facebook']);
// Everything a template needs, in one call
$data = wpsrGetReviewsDataFromTemplate(123);
// $data => ['template_meta' => [...], 'reviews' => [...], 'business_info' => [...]]URL helpers 4.4.0
One http(s) URL rule, shared by the review form, the REST validator, and every renderer — so a URL that saves is a URL that renders.
| Function | Purpose |
|---|---|
wpsr_trim_url($value) | Trim a URL the way JavaScript's String.prototype.trim() does |
wpsr_is_http_url($value) | true when the value is a usable http(s) URL |
wpsr_sanitize_http_url($value) | The normalized URL, or '' |
php
$url = wpsr_sanitize_http_url($request->get('video_url'));
if ($url === '') {
return; // not a usable http(s) URL
}wpsr_trim_url() strips the same character set as JavaScript — ordinary whitespace plus U+00A0, U+FEFF, U+2000–U+200D, U+2028, U+2029 and U+3000. The set is mirrored by WPSR_TRIM_CHARS in resources/admin/utils/videoUrl.js, so the browser and the server agree on what a pasted URL trims to — change one and change the other. Non-string input returns ''.
wpsr_sanitize_http_url() is deliberately stricter than esc_url_raw() alone, which happily turns a bare word into a URL. It requires an http:// or https:// scheme, requires a host, rejects a host containing non-ASCII bytes, and re-checks scheme and host afteresc_url_raw() has run. wpsr_is_http_url() is the boolean form of the same rule.
IDN must arrive as punycode
A non-ASCII host is rejected; a non-ASCII path is fine and preserved. Convert internationalized domains to punycode before validating.
Container helpers
| Function | Purpose |
|---|---|
wpsrSocialReviews($key = null) | Get the Application container, or resolve a bound service by key |
wpsrDb() | The framework query builder (wpsrSocialReviews('db')) |
php
$app = wpsrSocialReviews(); // Application instance
$router = wpsrSocialReviews('router'); // a bound service
$rows = wpsrDb()->table('wpsr_reviews')->where('rating', 5)->get();Sanitizer helpers
boot/globals.php also defines the input and style sanitizers used across the backend — wpsr_backend_sanitizer() plus a family of wpsr_sanitize_* functions. These get their own page:
Reference
These functions are the plugin's stable, intentionally-global surface. When you need review data or the container from outside a controller (in a shortcode, a template, or another plugin), reach for these rather than instantiating services yourself.

