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_Utils

Class WPGlobus_Utils

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

Methods summary

public static string
# localize_url( string $url = '', string $language = '', WPGlobus_Config $config = null )

Localize URL by inserting language prefix

Localize URL by inserting language prefix

Parameters

$url
URL to localize
$language
Language code
$config
Alternative configuration (i.e. Unit Test mock object)

Returns

string
public static string
# extract_language_from_url( string $url = '', WPGlobus_Config $config = null )

Extract language from URL http://example.com/ru/page/ returns 'ru'

Extract language from URL http://example.com/ru/page/ returns 'ru'

Parameters

$url
$config
Alternative configuration (i.e. Unit Test mock object)

Returns

string
public static boolean
# is_function_in_backtrace( string $function_name )

Check if was called by a specific function (could be any levels deep). Note: does not check if the function is in a class method.

Check if was called by a specific function (could be any levels deep). Note: does not check if the function is in a class method.

Parameters

$function_name

Returns

boolean
public static string
# domain_tld( string $url )

Strip the prefix from the host name http://www.example.com becomes example.com

Strip the prefix from the host name http://www.example.com becomes example.com

Parameters

$url

Returns

string

Since

1.0.12
public static string
# build_multilingual_string( string[] $translations )

Convert array of local texts to multilingual string (with WPGlobus delimiters)

Convert array of local texts to multilingual string (with WPGlobus delimiters)

Parameters

$translations

Returns

string
public static
# current_url( )

Returns the current URL. There is no method of getting the current URL in WordPress. Various snippets published on the Web use a combination of home_url and add_query_arg. However, none of them work when WordPress is installed in a subfolder. The method below looks valid. There is a theoretical chance of HTTP_HOST tampered, etc. However, the same line of code is used by the WordPress core, for example in @see wp_admin_canonical_url, so we are going to use it, too * Note that #hash is always lost because it's a client-side parameter. We might add it using a JavaScript call.

Returns the current URL. There is no method of getting the current URL in WordPress. Various snippets published on the Web use a combination of home_url and add_query_arg. However, none of them work when WordPress is installed in a subfolder. The method below looks valid. There is a theoretical chance of HTTP_HOST tampered, etc. However, the same line of code is used by the WordPress core, for example in @see wp_admin_canonical_url, so we are going to use it, too * Note that #hash is always lost because it's a client-side parameter. We might add it using a JavaScript call.

Since

1.1.1
public static string[]
# hreflangs( WPGlobus_Config $config = null )

Build hreflang metas

Build hreflang metas

Parameters

$config
Alternative configuration (i.e. Unit Test mock object)

Returns

string[]
Array of rel-alternate link tags

Since

1.1.1
public static string
# localize_current_url( string $language = '', WPGlobus_Config $config = null )

Parameters

$language
$config
Alternative configuration (i.e. Unit Test mock object)

Returns

string

Since

1.2.3
public static string
# url_wpglobus_site( WPGlobus_Config $config = null )

Localize www.wpglobus.com for use in outgoing links

Localize www.wpglobus.com for use in outgoing links

Parameters

$config

Returns

string

Since

1.2.6
public static boolean
# is_enabled( string $language )

Parameters

$language

Returns

boolean

Codecoverageignore

Return true if language is in array of enabled languages, otherwise false
public static string
# safe_get( string $key )

Secure access to scalars in $_GET.

Secure access to scalars in $_GET.

Parameters

$key
Index ($_GET[ $key ]).

Returns

string
The value or empty string if not exists or not scalar.
public static boolean
# is_open( string $language )

Deprecated

Parameters

$language

Returns

boolean

Codecoverageignore

Return true if language is in array of opened languages, otherwise false
public static boolean
# starts_with( string $s, string $n )

Deprecated

Parameters

$s
$n

Returns

boolean

Codecoverageignore

WPGlobus API documentation generated by ApiGen