Recent

Helpers class

Helpers

Helpers class.

Namespace: WebberZone\Top_Ten\Util
Since: 3.3.0
Source: includes/util/class-helpers.php line 21

Methods

__construct()

Constructor class.

Since: 3.3.0
Line: 28

public function __construct(  );

get_from_date() static

Retrieve the from date for the query

Since: 2.6.0
Line: 41

static public function get_from_date( $time = ..., $daily_range = ..., $hour_range = ... ): string;
TypeNameDescription
string$timeA date/time string.
int$daily_rangeDaily range.
int$hour_rangeHour range.

Returns: string — From date

get_daily_range_label() static

Get a human-readable label for a custom period range.

Since: 4.3.2
Line: 76

static public function get_daily_range_label( $daily_range = ... ): string;
TypeNameDescription
int|null$daily_rangeNumber of days. Defaults to the ‘daily_range’ option.

Returns: string — ‘Daily’ when the range is 1 day, else ‘Custom (N days)‘.

number_format_i18n() static

Convert float number to format based on the locale if number_format_count is true.

Since: 4.4.0
Line: 103

static public function number_format_i18n( $number, $decimals = ..., $style = ... ): string;
TypeNameDescription
float$numberThe number to convert based on locale.
int$decimalsOptional. Precision of the number of decimal places. Default 0.
string|null$styleOptional. ‘full’ or ‘abbreviated’. Default null, which uses the

Returns: string — Converted number in string format.

abbreviate_number() static

Abbreviate a number, e.g. 1200 becomes 1.2k and 3400000 becomes 3.4M.

The decimal separator is locale-aware via number_format_i18n().

Since: 4.4.0
Line: 138

static public function abbreviate_number( $number, $decimals = ... ): string;
TypeNameDescription
float|int$numberThe number to abbreviate.
int$decimalsOptional. Maximum number of decimal places. Default 1.

Returns: string — Abbreviated number, e.g. 1.2k, 3.4M. Numbers below the lowest

str_putcsv() static

Convert a string to CSV.

Since: 2.9.0
Line: 204

static public function str_putcsv( $input, $delimiter = ..., $enclosure = ..., $terminator = ... ): string;
TypeNameDescription
array$inputInput string.
string$delimiterDelimiter.
string$enclosureEnclosure.
string$terminatorTerminating string.

Returns: string — CSV string.

trim_char() static

Truncate a string to a certain length.

Since: 2.5.4
Line: 258

static public function trim_char( $input, $count = ..., $more = ..., $break_words = ... ): string;
TypeNameDescription
string$inputString to truncate.
int$countMaximum number of characters to take.
string$moreWhat to append if $input needs to be trimmed.
bool$break_wordsOptionally choose to break words.

Returns: string — Truncated string.

get_wp_query_arguments() static

Get the WP_Query arguments.

Line: 288

static public function get_wp_query_arguments(  ): array;

Returns: array — WP_Query arguments.

parse_wp_query_arguments() static

Parse WP_Query variables to parse comma separated list of IDs and convert them to arrays as needed by WP_Query.

Line: 373

static public function parse_wp_query_arguments( $query_vars ): array;
TypeNameDescription
array$query_varsDefined query variables.

Returns: array — Complete query variables with undefined ones filled in empty.

is_bot() static

Check if the user agent matches known bots.

Uses the jaybizzle/crawler-detect library for the primary check, and falls back to a filterable list of patterns for bots that library doesn’t recognise (or if the library isn’t available at all).

Since: 4.4.0
Line: 415

static public function is_bot(  ): bool;

Returns: bool — True if the user agent matches a known bot pattern, false otherwise.

get_all_terms() static

Get all terms of a post.

Since: 4.0.0
Line: 649

static public function get_all_terms( $post ): array;
TypeNameDescription
int|\WP_Post$postPost ID or WP_Post object.

Returns: array — Array of taxonomies.

sanitize_args() static

Sanitize args.

Since: 4.1.1
Line: 681

static public function sanitize_args( $args ): array;
TypeNameDescription
array$argsArray of arguments.

Returns: array — Sanitized array of arguments.