PHP Class Internacional, Internacional

************************************************************************* Plugin Name: Internacional [Abandoned Plugin] Description: [Abandoned Plugin] Internationalization for your posts. Multiple languages on one blog. Based on concepts by Flickr. Version: 0.2010.11.23 Author: Automattic Author URI: http://automattic.com/ ************************************************************************
Exibir arquivo Open project: Automattic/Internacional

Public Properties

Property Type Description
$cookie_name Bad idea to change this after plugin usage
$current_language
$current_url_parts This one's an object
$default_language These will be set later
$disable_query_filter
$fake_all_term Term ID, not an object
$internal_query_count Don't modify this directly
$languages
$real_request_uri
$tax_sql_cache
$taxonomy_name

Public Methods

Method Description
__construct ( ) Plugin setup
add_custom_columns ( array $columns ) : array Adds new columns on the administrative post listing
add_language_into_url_via_redirect ( ) Redirects to the current URL but with the language in it
add_language_to_post_link ( string $url, object | integer $post ) : string Adds a language slug into the URL (after the site's root, before the relative URL)
add_language_to_url ( string $url, string $language_slug = null ) : string Adds a language slug into a URL (after the site's root, before the relative URL)
add_meta_boxes ( ) Meta box manipulation for the write screens
cancel_redirect_to_self ( string $redirect_url ) : string | false At times redirect_canonical() will attempt to redirect from the URL it thinks it's at to the URL that is actually in the address bar. This function prevents those redirect loops.
change_locale ( string $locale ) : string Changes the locale setting based on the current post language being displayed
create_new_language_term ( string $name, string $slug ) : array | false Creates a new language term. This plugin's term slugs are prefixed to avoid collisions, so this function just makes life easier.
debug_query ( string $query ) : string Output some text for debugging queries
debug_var_dump ( mixed $var ) : mixed var_dump() the passed variable. Used for debugging filters.
debug_wp_redirect ( string $redirect_to ) : string | null Output some text about where a redirect attempt was made to for debugging purposes
do_url_hackery ( ) Takes care of all of the URL hackery
filter_by_language_dropdown ( ) Adds an additional filter dropdown for language to the manage posts page in the admin area
get_post_language ( integer $post_ID ) : object | false Get the language of a post ID
get_tax_sql_cached ( $post_table_name, $type ) * A caching wrapper for get_tax_sql()
get_term ( $value ) : mixed Fetches a taxonomy term by it's slug or ID. This plugin's term slugs are prefixed to avoid collisions, so this function just makes life easier.
get_translations ( integer $post_ID ) : array | false Fetches a list of all versions of a post ID
join_in_taxonomy_table ( string $join, string $post_table_name = null ) : string Modifies a query by JOIN'ing in the taxonomy tables, but only if needed (determined by Internacional::should_modify_query() )
join_in_taxonomy_table_p ( string $join ) : string Modifies a query by JOIN'ing in the taxonomy tables, but only if needed (determined by Internacional::should_modify_query() ) The previous/next post link queries use "p" instead of the actual posts database table name.
language_picker_meta_box ( ) Outputs the contents of the language picker meta box for the write screen
limit_where_by_language ( string $where ) : string Modifies the WHERE part of a query by limiting the results to the current language
list_translations ( string $content ) : string Adds a list of other versions of a post to the end of the passed string (i.e. the_content)
output_custom_columns_content ( $column_name, $post_ID ) Outputs the contents of the custom columns
register_setting_section ( ) Adds a new section to Settings -> Reading
register_sidebar_widget ( ) Registers a sidebar widget
relationship_picker_meta_box ( ) Outputs the contents of the relationship picker meta box for the write screen
save_meta_box_results ( $post_ID, $post ) Saves the results of the custom meta boxes
settings_field_language ( ) Outputs the new settings section for selecting the default language
settings_section ( ) Outputs the new settings section for selecting the default language
should_modify_query ( ) : boolean A helper function to determine if the database queries should be altered to limit the shown data to a single language
strip_slug_prefix ( string | object $slug ) : string | object Strips the prefix out of a slug
wp_loaded ( ) Stuff that needs to run a bit later

Method Details

__construct() public method

Plugin setup
public __construct ( )

add_custom_columns() public method

Adds new columns on the administrative post listing
public add_custom_columns ( array $columns ) : array
$columns array Existing columns.
return array An array of columns with the new ones added.

add_language_into_url_via_redirect() public method

Redirects to the current URL but with the language in it

add_language_to_post_link() public method

The language slug will be the post's language if it has one, otherwise it'll be the default language
public add_language_to_post_link ( string $url, object | integer $post ) : string
$url string The existing post URL.
$post object | integer A post object or ID.
return string The post URL with a language slug added into it.

add_language_to_url() public method

Adds a language slug into a URL (after the site's root, before the relative URL)
public add_language_to_url ( string $url, string $language_slug = null ) : string
$url string A URL.
$language_slug string Optional. A language slug. Defaults to the default language.
return string The modified URL with the language slug in it.

add_meta_boxes() public method

Removes a default taxonomy meta box, replaces it with another one, and adds an additional meta box
public add_meta_boxes ( )

cancel_redirect_to_self() public method

At times redirect_canonical() will attempt to redirect from the URL it thinks it's at to the URL that is actually in the address bar. This function prevents those redirect loops.
public cancel_redirect_to_self ( string $redirect_url ) : string | false
$redirect_url string The URL that is planned on being redirected to.
return string | false The $redirect_url value if the redirect is okay, false if it matches the real current URL.

change_locale() public method

Changes the locale setting based on the current post language being displayed
public change_locale ( string $locale ) : string
$locale string The current locale.
return string The modified locale.

create_new_language_term() public method

Creates a new language term. This plugin's term slugs are prefixed to avoid collisions, so this function just makes life easier.
public create_new_language_term ( string $name, string $slug ) : array | false
$name string The language's name
$slug string The non-prefixed slug to create for
return array | false The Term ID and Term Taxonomy ID or false on error

debug_query() public method

Output some text for debugging queries
public debug_query ( string $query ) : string
$query string The query
return string The exact value passed to the function

debug_var_dump() public method

var_dump() the passed variable. Used for debugging filters.
public debug_var_dump ( mixed $var ) : mixed
$var mixed Any variable
return mixed The passed variable

debug_wp_redirect() public method

Output some text about where a redirect attempt was made to for debugging purposes
public debug_wp_redirect ( string $redirect_to ) : string | null
$redirect_to string The URL that will be redirected to
return string | null If debug is off then the original URL will be returned, otherwise this function will exit()

do_url_hackery() public method

Parses the URL for a language slug Adds a language slug to the URL if there isn't one Removes the language slug from the URL internally so WordPress doesn't see it
public do_url_hackery ( )

filter_by_language_dropdown() public method

Adds an additional filter dropdown for language to the manage posts page in the admin area

get_post_language() public method

Get the language of a post ID
public get_post_language ( integer $post_ID ) : object | false
$post_ID integer A post's ID
return object | false The language term object for the given post ID or false if the post doesn't have a language value set.

get_tax_sql_cached() public method

* A caching wrapper for get_tax_sql()
public get_tax_sql_cached ( $post_table_name, $type )
$post_table_name The name of the table
$type The query type desired ("where" or "join")

get_term() public method

Fetches a taxonomy term by it's slug or ID. This plugin's term slugs are prefixed to avoid collisions, so this function just makes life easier.
public get_term ( $value ) : mixed
return mixed Term Row from database. Will return false if $taxonomy does not exist or $term was not found.

get_translations() public method

Fetches a list of all versions of a post ID
public get_translations ( integer $post_ID ) : array | false
$post_ID integer A post's ID
return array | false False if the post is not a translation, otherwise an array in the format language term ID => translated post ID

join_in_taxonomy_table() public method

Modifies a query by JOIN'ing in the taxonomy tables, but only if needed (determined by Internacional::should_modify_query() )
public join_in_taxonomy_table ( string $join, string $post_table_name = null ) : string
$join string The passed existing JOIN query part.
$post_table_name string Optional. An alternate name (alias) for the posts database table. Be careful, this isn't validated.
return string A potentially modified JOIN query part.

join_in_taxonomy_table_p() public method

Modifies a query by JOIN'ing in the taxonomy tables, but only if needed (determined by Internacional::should_modify_query() ) The previous/next post link queries use "p" instead of the actual posts database table name.
public join_in_taxonomy_table_p ( string $join ) : string
$join string The passed existing JOIN query part.
return string A potentially modified JOIN query part.

language_picker_meta_box() public method

Outputs the contents of the language picker meta box for the write screen

limit_where_by_language() public method

Modifies the WHERE part of a query by limiting the results to the current language
public limit_where_by_language ( string $where ) : string
$where string The passed existing WHERE query part.
return string A potentially modified WHERE query part.

list_translations() public method

Adds a list of other versions of a post to the end of the passed string (i.e. the_content)
public list_translations ( string $content ) : string
$content string The post content
return string The post content with a list of available post languages at the end of it

output_custom_columns_content() public method

Outputs the contents of the custom columns
public output_custom_columns_content ( $column_name, $post_ID )

register_setting_section() public method

Adds a new section to Settings -> Reading

register_sidebar_widget() public method

Registers a sidebar widget

relationship_picker_meta_box() public method

Outputs the contents of the relationship picker meta box for the write screen

save_meta_box_results() public method

Saves the results of the custom meta boxes
public save_meta_box_results ( $post_ID, $post )

settings_field_language() public method

Outputs the new settings section for selecting the default language

settings_section() public method

Outputs the new settings section for selecting the default language
public settings_section ( )

should_modify_query() public method

A helper function to determine if the database queries should be altered to limit the shown data to a single language
public should_modify_query ( ) : boolean
return boolean Whether or not the database queries should be modified

strip_slug_prefix() public method

Strips the prefix out of a slug
public strip_slug_prefix ( string | object $slug ) : string | object
$slug string | object Either a full term object or a slug string
return string | object The passed variable but with the prefix stripped off the slug

wp_loaded() public method

Stuff that needs to run a bit later
public wp_loaded ( )

Property Details

$current_language public_oe property

public $current_language

$current_url_parts public_oe property

This one's an object
public $current_url_parts

$default_language public_oe property

These will be set later
public $default_language

$disable_query_filter public_oe property

public $disable_query_filter

$fake_all_term public_oe property

Term ID, not an object
public $fake_all_term

$internal_query_count public_oe property

Don't modify this directly
public $internal_query_count

$languages public_oe property

public $languages

$real_request_uri public_oe property

public $real_request_uri

$tax_sql_cache public_oe property

public $tax_sql_cache

$taxonomy_name public_oe property

public $taxonomy_name