Recent

Helpersclass

Helpers

Static utility helpers used throughout Contextual Related Posts.

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

Methods

__construct()

Constructor class.

Since: 3.5.0
Line: 28

public function __construct(  );

is_sqlite() static

Check if the current database driver is SQLite.

Used to disable MySQL-specific features (FULLTEXT search, SHOW INDEX, etc.) when running on SQLite, e.g. in WordPress Playground.

Since: 4.3.0
Line: 41

static public function is_sqlite(  ): bool;

Returns: bool — True if SQLite is the active database driver.

str_putcsv() static

Convert a string to CSV.

Since: 3.5.0
Line: 56

static public function str_putcsv( $input, $delimiter = ..., $enclosure = ..., $terminator = ... ): string;
Type Name Description
array $input Input array.
string $delimiter Delimiter.
string $enclosure Enclosure.
string $terminator Terminating string.

Returns: string — CSV string.

trim_char() static

Truncate a string to a certain length.

Since: 3.5.0
Line: 111

static public function trim_char( $input, $count = ..., $more = ..., $break_words = ... ): string;
Type Name Description
string $input String to truncate.
int $count Maximum number of characters to take.
string $more What to append if $input needs to be trimmed.
bool $break_words Optionally choose to break words.

Returns: string — Truncated string.

get_primary_term() static

Get the primary term for a given post.

Since: 3.5.0
Line: 158

static public function get_primary_term( $post, $term = ..., $return_all = ..., $return_first = ... ): array;
Type Name Description
int|\WP_Post $post Post ID or WP_Post object.
string $term Term name.
bool $return_all Whether to return all terms.
bool $return_first Whether to return the first term.

Returns: array — Primary term object at primary and array of term

get_all_terms() static

Get all terms of a post.

Since: 3.5.0
Line: 238

static public function get_all_terms( $post ): array;
Type Name Description
int|\WP_Post $post Post ID or WP_Post object.

Returns: array — Array of taxonomies.

strip_stopwords() static

Strip stopwords from text.

Since: 3.1.0
Line: 273

static public function strip_stopwords( $subject = ..., $search = ..., $replace = ... ): string;
Type Name Description
string|array $subject The string or an array with strings to search and replace.
string|array $search Optional. The pattern to search for. It can be either a string or an array with strings.
string|array $replace Optional. The string to replace with. Default empty string.

Returns: string — Processed text with stopwords removed.

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.

Since: 4.0.0
Line: 336

static public function parse_wp_query_arguments( $query_vars ): array;
Type Name Description
array $query_vars Defined query variables.

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

sanitize_args() static

Sanitize args.

Since: 4.0.3
Line: 373

static public function sanitize_args( $args ): array;
Type Name Description
array $args Array of arguments.

Returns: array — Sanitized array of arguments.

get_database_compatibility_message() static

Get a message about MySQL/MariaDB compatibility issues.

Since: 4.0.0
Line: 400

static public function get_database_compatibility_message(  ): string;

Returns: string — Message about compatibility or empty string if compatible.

get_sites() static

Retrieve sites without WordPress’s default 100-site cap.

get_sites() defaults to number => 100. Passing number => 0 removes the LIMIT so network-wide operations see every site.

Since: 4.4.0
Line: 465

static public function get_sites( array $args = ... ): array;
Type Name Description
array $args Optional. Arguments passed to get_sites().

Returns: array — Array of WP_Site objects, IDs, or fields depending on $args.