WPGlobus
  • Package
  • Class

Packages

  • WPGlobus
    • ACF
    • Admin
      • Customizer
      • HelpDesk
      • Options
        • Field
    • All-in-One-SEO
    • Compat
    • MailChimp
    • RevSlider
    • The-Events-Calendar
    • Yoast

Classes

  • WPGlobus
  • WPGlobus_Config
  • WPGlobus_Core
  • WPGlobus_Filters
  • WPGlobus_Plugin
  • WPGlobus_Utils
  • WPGlobus_WP
  • WPGlobusWidget

Class WPGlobus_Filters

Class WPGlobus_Filters

Package: WPGlobus
Located at includes/class-wpglobus-filters.php

Methods summary

public static string
# filter__text( string $text )

This is the basic filter used to extract the text portion in the current language from a string. Applied to the main WP texts, such as post title, content and excerpt.

This is the basic filter used to extract the text portion in the current language from a string. Applied to the main WP texts, such as post title, content and excerpt.

Parameters

$text

Returns

string
public static array
# filter__the_posts( array $posts, WP_Query & $query )

This filter is needed to display correctly the posts with the '--- MORE ---' separator in archives. Without it, the post content is truncated at the beginning of , thus keeping only the first language. * 'the_posts' filter is used by @see get_posts(), which is commonly used in all sorts of places, including, for instance, @see wp_get_associated_nav_menu_items while deleting a post. So, to minimize potential side effects, we limit the scope to main queries, or when the 'wpglobus_force_filter__the_posts' is set (@see WPGlobus_QA::_test_get_posts for example).

This filter is needed to display correctly the posts with the '--- MORE ---' separator in archives. Without it, the post content is truncated at the beginning of , thus keeping only the first language. * 'the_posts' filter is used by @see get_posts(), which is commonly used in all sorts of places, including, for instance, @see wp_get_associated_nav_menu_items while deleting a post. So, to minimize potential side effects, we limit the scope to main queries, or when the 'wpglobus_force_filter__the_posts' is set (@see WPGlobus_QA::_test_get_posts for example).

Parameters

$posts
$query

Returns

array

Since

1.0.14
public static string
# filter__text_default_language( string $text )

This is similar to the @see filter__text filter, but it returns text in the DEFAULT language.

This is similar to the @see filter__text filter, but it returns text in the DEFAULT language.

Parameters

$text

Returns

string

Since

1.0.8
public static array
# filter__get_terms( array $terms )

Filter @see get_terms

Filter @see get_terms

Parameters

$terms

Returns

array

Scope

admin
front
public static array
# filter__get_the_terms( object[]|WP_Error $terms )

Filter @see get_the_terms

Filter @see get_the_terms

Parameters

$terms
List of attached terms, or WP_Error on failure.

Returns

array

Scope

admin
public static array
# filter__wp_get_object_terms( array $terms )

Filter @see wp_get_object_terms()

Filter @see wp_get_object_terms()

Parameters

$terms
An array of terms for the given object or objects.

Returns

array

Scope

admin
front
public static string
# filter__sanitize_title( string $title )

This filter is needed to build correct permalink (slug, post_name)

using only the main part of the post title (in the default language).

Because 'sanitize_title' is a commonly used function, we have to apply our filter

only on very specific calls. Therefore, there are (ugly) debug_backtrace checks.

Case 1 When a draft post is created, the post title is converted to the slug in the @see get_sample_permalink function,

using the 'sanitize_title' filter.

Case 2 When the draft is published, @see wp_insert_post calls

This filter is needed to build correct permalink (slug, post_name)

using only the main part of the post title (in the default language).

Because 'sanitize_title' is a commonly used function, we have to apply our filter

only on very specific calls. Therefore, there are (ugly) debug_backtrace checks.

Case 1 When a draft post is created, the post title is converted to the slug in the @see get_sample_permalink function,

using the 'sanitize_title' filter.

Case 2 When the draft is published, @see wp_insert_post calls

Parameters

$title

Returns

string

See

sanitize_title to set the slug


WPGLobus_QA::_test_post_name


WPSEO_Metabox::localize_script
public static string|object
# filter__get_term( string|object $term )

Filter @see get_term()

Filter @see get_term()

Parameters

$term

Returns

string|object
public static string
# filter__terms_to_edit( string $terms_to_edit )

Filter @see get_terms_to_edit()

Filter @see get_terms_to_edit()

Parameters

$terms_to_edit

Returns

string

Since

1.6.4
public static string
# filter__home_url( string $url )

Localize home_url Should be processed on: - front - AJAX, except for several specific actions

Localize home_url Should be processed on: - front - AJAX, except for several specific actions

Parameters

$url

Returns

string
public static WP_Post[]
# filter__get_pages( WP_Post[] $pages )

Filter @see get_pages

Filter @see get_pages

Parameters

$pages

Returns

WP_Post[]

Qa

See a list of available pages in the "Parent Page" metabox when editing a page.
public static string
# filter__get_locale( string $locale )

Filter for @see get_locale

Filter for @see get_locale

Parameters

$locale

Returns

string

See

setlocale

Link

http://php.net/manual/en/function.setlocale.php

Example

echo setlocale(LC_ALL, 'Russian'); => Russian_Russia.1251
public static WP_Post[]
# filter__nav_menu_item( WP_Post[] $object )

Filter @see wp_setup_nav_menu_item in wp-includes\nav-menu.php for more info

Filter @see wp_setup_nav_menu_item in wp-includes\nav-menu.php for more info

Parameters

$object

Returns

WP_Post[]

Since

1.0.0
public static string
# filter__nav_menu_description( string $description )

Filter @see nav_menu_description

Filter @see nav_menu_description

Parameters

$description

Returns

string

Since

1.0.0
public static array
# filter__heartbeat_received( array $response, array $data, string $screen_id )

Filter @see heartbeat_received

Filter @see heartbeat_received

Parameters

$response
$data
$screen_id

Returns

array

Since

1.0.1
public static array
# filter__nav_menu_objects( array $object )

Filter @see wp_nav_menu_objects

Filter @see wp_nav_menu_objects

Parameters

$object

Returns

array

Since

1.0.2
public static string[]
# filter__widget_display_callback( string[] $instance )

Translate widget strings (besides the title handled by the widget_title filter)

Translate widget strings (besides the title handled by the widget_title filter)

Parameters

$instance

Returns

string[]

Since

1.0.6

See

WP_Widget::display_callback

Scope

front
public static string
# filter__comment_moderation( string $text, integer $comment_id )

Filter @see comment_moderation_text,

Filter @see comment_moderation_text,

Parameters

$text
$comment_id

Returns

string

Since

1.0.6

See

comment_moderation_subject
public static string
# filter__wp_trim_words( string $text, integer $num_words, string $more, string $original_text )

Filter @see wp_trim_words

Filter @see wp_trim_words

Parameters

$text
The trimmed text.
$num_words
The number of words to trim the text to.
$more
An optional string to append to the end of the trimmed text, e.g. ….
$original_text
The text before it was trimmed.

Returns

string

Since

1.0.14

Qa

At the /wp-admin/index.php page is a Quick Draft metabox which shows 3 last post drafts. This filter lets post content in default language.


public static
# register_widgets( )

Register the WPGlobus widgets

Register the WPGlobus widgets

Since

1.0.7

Wp-hook

widgets_init
public static
# action__admin_init( )

Do something on admin_init hook.

Do something on admin_init hook.

public static
# set_multilingual_meta_keys( )

Specify meta keys where the meta data can be multilingual

Specify meta keys where the meta data can be multilingual

Since

1.2.1

Example

add_filter( 'wpglobus_multilingual_meta_keys',
     function ( $multilingual_meta_keys ) {
         $multilingual_meta_keys['slides'] = true;
         return $multilingual_meta_keys;
     }
 );

public static string|array
# filter__postmeta( string|array $value, integer $object_id, string $meta_key, string|array $single )

Translate meta data

Translate meta data

Parameters

$value
Null is passed. We set the value.
$object_id
Post ID
$meta_key
Passed by the filter. We need only one key.
$single
Meta value, or an array of values.

Returns

string|array

See

WPGlobus_Filters::set_multilingual_meta_keys()
public static
# fetch_feed_options( $obj )

Localize feed url

Localize feed url

Since

1.5.3

Scope

front

Properties summary

protected static string[] $multilingual_meta_keys

Meta keys where data can be multilingual

Meta keys where data can be multilingual

# array()
WPGlobus API documentation generated by ApiGen