Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/sitepres.../inc
File: functions.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* SitePress Template functions
[2] Fix | Delete
*
[3] Fix | Delete
* @package wpml-core
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
use function WPML\Container\make;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Returns true if the site uses ICanLocalize.
[10] Fix | Delete
*
[11] Fix | Delete
* @return bool
[12] Fix | Delete
*/
[13] Fix | Delete
function wpml_site_uses_icl() {
[14] Fix | Delete
global $wpdb;
[15] Fix | Delete
[16] Fix | Delete
$setting = 'site_does_not_use_icl';
[17] Fix | Delete
[18] Fix | Delete
if ( icl_get_setting( $setting, false ) ) {
[19] Fix | Delete
return false;
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
$cache = new WPML_WP_Cache( 'wpml-checks' );
[23] Fix | Delete
[24] Fix | Delete
$found = false;
[25] Fix | Delete
$site_uses_icl = $cache->get( 'site_uses_icl', $found );
[26] Fix | Delete
[27] Fix | Delete
if ( ! $found ) {
[28] Fix | Delete
$site_uses_icl = false;
[29] Fix | Delete
[30] Fix | Delete
$table_exists = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}icl_translation_status'" );
[31] Fix | Delete
[32] Fix | Delete
if ( $table_exists ) {
[33] Fix | Delete
$icl_job_count_query = $wpdb->prepare( "SELECT rid
[34] Fix | Delete
FROM {$wpdb->prefix}icl_translation_status
[35] Fix | Delete
WHERE translation_service = %s
[36] Fix | Delete
LIMIT 1;", 'icanlocalize' );
[37] Fix | Delete
[38] Fix | Delete
$site_uses_icl = (bool) $wpdb->get_var( $icl_job_count_query );
[39] Fix | Delete
}
[40] Fix | Delete
$cache->set( 'site_uses_icl', $site_uses_icl );
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
if ( icl_get_setting( 'setup_complete', false ) && ! $site_uses_icl ) {
[44] Fix | Delete
icl_set_setting( $setting, true, true );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
return $site_uses_icl;
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Returns the value of a given key setting.
[52] Fix | Delete
*
[53] Fix | Delete
* @param string $key The setting's key.
[54] Fix | Delete
* @param mixed|false $default The value to use if the setting does not exist.
[55] Fix | Delete
*
[56] Fix | Delete
* @return bool|mixed
[57] Fix | Delete
* @since 3.1
[58] Fix | Delete
* @deprecated 3.2 use `\wpml_setting` or 'wpml_get_setting_filter' filter instead
[59] Fix | Delete
*/
[60] Fix | Delete
function icl_get_setting( $key, $default = false ) {
[61] Fix | Delete
return wpml_get_setting( $key, $default );
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Get a WPML setting value.
[66] Fix | Delete
* If the Main SitePress Class cannot be accessed by the function it will read the setting from the database.
[67] Fix | Delete
* It will return `$default` if the requested key is not set.
[68] Fix | Delete
*
[69] Fix | Delete
* @param string $key The setting's key.
[70] Fix | Delete
* @param mixed|null $default Required. The value to return if the settings key does not exist
[71] Fix | Delete
* (typically it's false, but you may want to use something else).
[72] Fix | Delete
*
[73] Fix | Delete
* @return mixed The value of the requested setting, or `$default`
[74] Fix | Delete
* @since 4.1
[75] Fix | Delete
*/
[76] Fix | Delete
function wpml_get_setting( $key, $default = null ) {
[77] Fix | Delete
global $sitepress_settings;
[78] Fix | Delete
$sitepress_settings = isset( $sitepress_settings ) ? $sitepress_settings : get_option( 'icl_sitepress_settings' );
[79] Fix | Delete
[80] Fix | Delete
return isset( $sitepress_settings[ $key ] ) ? $sitepress_settings[ $key ] : $default;
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Get a WPML setting value.
[85] Fix | Delete
* If the Main SitePress Class cannot be access to the function will read the setting from the database.
[86] Fix | Delete
* Will return false if the requested key is not set or.
[87] Fix | Delete
* the default value passed in the function's second parameter.
[88] Fix | Delete
*
[89] Fix | Delete
* @param mixed|false $default Required. The value to return if the settings key does not exist
[90] Fix | Delete
* (typically it's false, but you may want to use something else).
[91] Fix | Delete
* @param string $key The setting's key.
[92] Fix | Delete
*
[93] Fix | Delete
* @return mixed The value of the requested setting, or $default
[94] Fix | Delete
* @since 3.2
[95] Fix | Delete
* @use \SitePress::api_hooks
[96] Fix | Delete
*/
[97] Fix | Delete
function wpml_get_setting_filter( $default, $key ) {
[98] Fix | Delete
$args = func_get_args();
[99] Fix | Delete
if ( count( $args ) > 2 && $args[2] !== null ) {
[100] Fix | Delete
$default = $args[2];
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
return wpml_get_setting( $key, $default );
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* Returns the value of a given key sub-setting.
[108] Fix | Delete
*
[109] Fix | Delete
* @param string $key The setting's key.
[110] Fix | Delete
* @param string $sub_key The settings name key to return the value of.
[111] Fix | Delete
* @param mixed|false $default Required. The value to return if the settings key does not exist
[112] Fix | Delete
* (typically it's false, but you may want to use something else).
[113] Fix | Delete
*
[114] Fix | Delete
* @return bool|mixed
[115] Fix | Delete
* @since 3.1
[116] Fix | Delete
* @deprecated 3.2 use 'wpml_sub_setting' filter instead
[117] Fix | Delete
*/
[118] Fix | Delete
function icl_get_sub_setting( $key, $sub_key, $default = false ) {
[119] Fix | Delete
$parent = icl_get_setting( $key, array() );
[120] Fix | Delete
[121] Fix | Delete
return isset( $parent[ $sub_key ] ) ? $parent[ $sub_key ] : $default;
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
/**
[125] Fix | Delete
* Gets a WPML sub setting value.
[126] Fix | Delete
*
[127] Fix | Delete
* @uses \wpml_get_setting_filter
[128] Fix | Delete
*
[129] Fix | Delete
* @param mixed|false $default Required. The value to return if the settings key does not exist
[130] Fix | Delete
* (typically it's false, but you may want to use something else).
[131] Fix | Delete
* @param string $key The settings name key the sub key belongs to.
[132] Fix | Delete
* @param string $sub_key The sub key to return the value of.
[133] Fix | Delete
* @param mixed $deprecated Deprecated param.
[134] Fix | Delete
*
[135] Fix | Delete
* @todo [WPML 3.3] Remove deprecated argument
[136] Fix | Delete
*
[137] Fix | Delete
* @return mixed The value of the requested setting, or $default
[138] Fix | Delete
* @since 3.2
[139] Fix | Delete
* @use \SitePress::api_hooks
[140] Fix | Delete
*/
[141] Fix | Delete
function wpml_get_sub_setting_filter( $default, $key, $sub_key, $deprecated = null ) {
[142] Fix | Delete
$default = null !== $deprecated && ! $default ? $deprecated : $default;
[143] Fix | Delete
[144] Fix | Delete
$parent = wpml_get_setting_filter( array(), $key );
[145] Fix | Delete
[146] Fix | Delete
return isset( $parent[ $sub_key ] ) ? $parent[ $sub_key ] : $default;
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* Saves the value of a given key.
[151] Fix | Delete
*
[152] Fix | Delete
* @param string $key The settings name key the sub key belongs to.
[153] Fix | Delete
* @param mixed $value The value to assign to the given key.
[154] Fix | Delete
* @param bool $save_now Must call icl_save_settings() to permanently store the value.
[155] Fix | Delete
*
[156] Fix | Delete
* @return bool Always True. If `$save_now === true`, it returns the result of `update_option`
[157] Fix | Delete
*/
[158] Fix | Delete
function icl_set_setting( $key, $value, $save_now = false ) {
[159] Fix | Delete
global $sitepress_settings;
[160] Fix | Delete
[161] Fix | Delete
$result = true;
[162] Fix | Delete
[163] Fix | Delete
$sitepress_settings[ $key ] = $value;
[164] Fix | Delete
[165] Fix | Delete
if ( true === $save_now ) {
[166] Fix | Delete
/* We need to save settings anyway, in this case. */
[167] Fix | Delete
$result = update_option( 'icl_sitepress_settings', $sitepress_settings );
[168] Fix | Delete
do_action( 'icl_save_settings', $sitepress_settings );
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
return $result;
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
/**
[175] Fix | Delete
* Save the settings in the db.
[176] Fix | Delete
*/
[177] Fix | Delete
function icl_save_settings() {
[178] Fix | Delete
global $sitepress;
[179] Fix | Delete
$sitepress->save_settings();
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
/**
[183] Fix | Delete
* Gets all the settings.
[184] Fix | Delete
*
[185] Fix | Delete
* @return array|false
[186] Fix | Delete
*/
[187] Fix | Delete
function icl_get_settings() {
[188] Fix | Delete
global $sitepress;
[189] Fix | Delete
[190] Fix | Delete
return isset( $sitepress ) ? $sitepress->get_settings() : false;
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
/**
[194] Fix | Delete
* Add settings link to plugin page.
[195] Fix | Delete
*
[196] Fix | Delete
* @param $links
[197] Fix | Delete
* @param $file
[198] Fix | Delete
*
[199] Fix | Delete
* @return array
[200] Fix | Delete
*/
[201] Fix | Delete
function icl_plugin_action_links( $links, $file ) {
[202] Fix | Delete
if ( $file == WPML_PLUGIN_BASENAME ) {
[203] Fix | Delete
$links[] = '<a href="admin.php?page=' . WPML_PLUGIN_FOLDER . '/menu/languages.php">' . __( 'Configure', 'sitepress' ) . '</a>';
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
return $links;
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
if ( defined( 'ICL_DEBUG_MODE' ) && ICL_DEBUG_MODE ) {
[210] Fix | Delete
add_action( 'admin_notices', '_icl_deprecated_icl_debug_mode' );
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
function _icl_deprecated_icl_debug_mode() {
[214] Fix | Delete
echo '<div class="updated"><p><strong>ICL_DEBUG_MODE</strong> no longer supported. Please use <strong>WP_DEBUG</strong> instead.</p></div>';
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
if ( ! function_exists( 'icl_js_escape' ) ) {
[218] Fix | Delete
function icl_js_escape( $str ) {
[219] Fix | Delete
$str = esc_js( $str );
[220] Fix | Delete
$str = htmlspecialchars_decode( $str );
[221] Fix | Delete
[222] Fix | Delete
return $str;
[223] Fix | Delete
}
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
/**
[227] Fix | Delete
* Read and, if needed, generate the site ID based on the scope.
[228] Fix | Delete
*
[229] Fix | Delete
* @param string $scope Defaults to "global".
[230] Fix | Delete
* Use a different value when the ID is used for specific scopes.
[231] Fix | Delete
*
[232] Fix | Delete
* @param bool $create_new Forces the creation of a new ID.
[233] Fix | Delete
*
[234] Fix | Delete
* @return string|null The generated/stored ID or null if it wasn't possible to generate/store the value.
[235] Fix | Delete
*/
[236] Fix | Delete
function wpml_get_site_id( $scope = WPML_Site_ID::SITE_SCOPES_GLOBAL, $create_new = false ) {
[237] Fix | Delete
static $site_id;
[238] Fix | Delete
[239] Fix | Delete
if ( ! $site_id ) {
[240] Fix | Delete
$site_id = new WPML_Site_ID();
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
return $site_id->get_site_id( $scope, $create_new );
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
function _icl_tax_has_objects_recursive( $id, $term_id = -1, $rec = 0 ) {
[247] Fix | Delete
// based on the case where two categories were one the parent of another
[248] Fix | Delete
// eliminating the chance of infinite loops by letting this function calling itself too many times
[249] Fix | Delete
// 100 is the default limit in most of teh php configuration
[250] Fix | Delete
//
[251] Fix | Delete
// this limit this function to work only with categories nested up to 60 levels
[252] Fix | Delete
// should enough for most cases
[253] Fix | Delete
if ( $rec > 60 ) {
[254] Fix | Delete
return false;
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
global $wpdb;
[258] Fix | Delete
[259] Fix | Delete
if ( $term_id === -1 ) {
[260] Fix | Delete
$term_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id=%d", $id ) );
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
$children = $wpdb->get_results( $wpdb->prepare( "
[264] Fix | Delete
SELECT term_taxonomy_id, term_id, count FROM {$wpdb->term_taxonomy} WHERE parent = %d
[265] Fix | Delete
", $term_id ) );
[266] Fix | Delete
[267] Fix | Delete
$count = 0;
[268] Fix | Delete
foreach ( $children as $ch ) {
[269] Fix | Delete
$count += $ch->count;
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
if ( $count ) {
[273] Fix | Delete
return true;
[274] Fix | Delete
} else {
[275] Fix | Delete
foreach ( $children as $ch ) {
[276] Fix | Delete
if ( _icl_tax_has_objects_recursive( $ch->term_taxonomy_id, $ch->term_id, $rec + 1 ) ) {
[277] Fix | Delete
return true;
[278] Fix | Delete
}
[279] Fix | Delete
}
[280] Fix | Delete
}
[281] Fix | Delete
[282] Fix | Delete
return false;
[283] Fix | Delete
}
[284] Fix | Delete
[285] Fix | Delete
function _icl_trash_restore_prompt() {
[286] Fix | Delete
if ( isset( $_GET['lang'] ) ) {
[287] Fix | Delete
$post = get_post( intval( $_GET['post'] ) );
[288] Fix | Delete
if ( isset( $post->post_status ) && $post->post_status == 'trash' ) {
[289] Fix | Delete
$post_type_object = get_post_type_object( $post->post_type );
[290] Fix | Delete
[291] Fix | Delete
$delete_post_link = '<a href="' . esc_url( get_delete_post_link( $post->ID, '', true ) ) . '">' . esc_html( 'delete it permanently', 'sitepress' ) . '</a>';
[292] Fix | Delete
$restore_post_link = '<a href="' . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . '">' . esc_html( 'restore', 'sitepress' ) . '</a>';
[293] Fix | Delete
$ret = '<p>' . sprintf( esc_html__( 'This translation is currently in the trash. You need to either %s or %s it in order to continue.' ), $delete_post_link, $restore_post_link );
[294] Fix | Delete
[295] Fix | Delete
wp_die( $ret );
[296] Fix | Delete
}
[297] Fix | Delete
}
[298] Fix | Delete
}
[299] Fix | Delete
[300] Fix | Delete
/**
[301] Fix | Delete
* Build or update duplicated posts from a master post.
[302] Fix | Delete
*
[303] Fix | Delete
* @param string $master_post_id The ID of the post to duplicate from. Master post doesn't need to be in the default language.
[304] Fix | Delete
*
[305] Fix | Delete
* @uses SitePress
[306] Fix | Delete
* @uses TranslationManagement
[307] Fix | Delete
* @since unknown
[308] Fix | Delete
* @deprecated 3.2 use 'wpml_admin_make_duplicates' action instead
[309] Fix | Delete
*/
[310] Fix | Delete
function icl_makes_duplicates( $master_post_id ) {
[311] Fix | Delete
wpml_admin_make_post_duplicates_action( $master_post_id );
[312] Fix | Delete
}
[313] Fix | Delete
[314] Fix | Delete
/**
[315] Fix | Delete
* Build or update duplicated posts from a master post.
[316] Fix | Delete
* To be used only for admin backend actions
[317] Fix | Delete
*
[318] Fix | Delete
* @see $iclTranslationManagement in \SitePress:: __construct
[319] Fix | Delete
*
[320] Fix | Delete
* @param int $master_post_id The ID of the post to duplicate from.
[321] Fix | Delete
* The ID can be that of a post, page or custom post
[322] Fix | Delete
* Master post doesn't need to be in the default language.
[323] Fix | Delete
*
[324] Fix | Delete
* @uses SitePress
[325] Fix | Delete
* @uses TranslationManagement
[326] Fix | Delete
* @since 3.2
[327] Fix | Delete
* @use \SitePress::api_hooks
[328] Fix | Delete
*/
[329] Fix | Delete
function wpml_admin_make_post_duplicates_action( $master_post_id ) {
[330] Fix | Delete
$post = get_post( $master_post_id );
[331] Fix | Delete
$post_type = $post->post_type;
[332] Fix | Delete
[333] Fix | Delete
if ( $post->post_status == 'auto-draft' || $post->post_type == 'revision' ) {
[334] Fix | Delete
return;
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
global $sitepress;
[338] Fix | Delete
$iclTranslationManagement = wpml_load_core_tm();
[339] Fix | Delete
if ( $sitepress->is_translated_post_type( $post_type ) ) {
[340] Fix | Delete
$iclTranslationManagement->make_duplicates_all( $master_post_id );
[341] Fix | Delete
}
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
/**
[345] Fix | Delete
* Build duplicated posts from a master post only in case of the duplicate not being present at the time.
[346] Fix | Delete
*
[347] Fix | Delete
* @param string $master_post_id The ID of the post to duplicate from. Master post doesn't need to be in the default language.
[348] Fix | Delete
*
[349] Fix | Delete
* @uses SitePress
[350] Fix | Delete
* @since unknown
[351] Fix | Delete
* @deprecated 3.2 use 'wpml_make_post_duplicates' action instead
[352] Fix | Delete
*/
[353] Fix | Delete
function icl_makes_duplicates_public( $master_post_id ) {
[354] Fix | Delete
wpml_make_post_duplicates_action( $master_post_id );
[355] Fix | Delete
}
[356] Fix | Delete
[357] Fix | Delete
/**
[358] Fix | Delete
* Build duplicated posts from a master post only in case of the duplicate not being present at the time.
[359] Fix | Delete
*
[360] Fix | Delete
* @param int $master_post_id The ID of the post to duplicate from.
[361] Fix | Delete
* Master post doesn't need to be in the default language.
[362] Fix | Delete
*
[363] Fix | Delete
* @uses SitePress
[364] Fix | Delete
* @since 3.2
[365] Fix | Delete
* @use \SitePress::api_hooks
[366] Fix | Delete
* @deprecated This function will be removed in future releases.
[367] Fix | Delete
*/
[368] Fix | Delete
function wpml_make_post_duplicates_action( $master_post_id ) {
[369] Fix | Delete
[370] Fix | Delete
global $sitepress;
[371] Fix | Delete
[372] Fix | Delete
$master_post = get_post( $master_post_id );
[373] Fix | Delete
[374] Fix | Delete
if ( 'auto-draft' === $master_post->post_status || 'revision' === $master_post->post_type ) {
[375] Fix | Delete
return;
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
$active_langs = $sitepress->get_active_languages();
[379] Fix | Delete
[380] Fix | Delete
foreach ( $active_langs as $lang_to => $one ) {
[381] Fix | Delete
[382] Fix | Delete
$trid = $sitepress->get_element_trid( $master_post->ID, 'post_' . $master_post->post_type );
[383] Fix | Delete
$lang_from = $sitepress->get_source_language_by_trid( $trid );
[384] Fix | Delete
[385] Fix | Delete
if ( $lang_from == $lang_to ) {
[386] Fix | Delete
continue;
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
$sitepress->make_duplicate( $master_post_id, $lang_to );
[390] Fix | Delete
}
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
/**
[394] Fix | Delete
* Wrapper function for deprecated like_escape() and recommended wpdb::esc_like()
[395] Fix | Delete
*
[396] Fix | Delete
* @global wpdb $wpdb
[397] Fix | Delete
*
[398] Fix | Delete
* @param string $text
[399] Fix | Delete
*
[400] Fix | Delete
* @return string
[401] Fix | Delete
*/
[402] Fix | Delete
function wpml_like_escape( $text ) {
[403] Fix | Delete
global $wpdb;
[404] Fix | Delete
[405] Fix | Delete
if ( method_exists( $wpdb, 'esc_like' ) ) {
[406] Fix | Delete
return $wpdb->esc_like( $text );
[407] Fix | Delete
}
[408] Fix | Delete
[409] Fix | Delete
/** @noinspection PhpDeprecationInspection */
[410] Fix | Delete
[411] Fix | Delete
return like_escape( $text );
[412] Fix | Delete
}
[413] Fix | Delete
[414] Fix | Delete
function icl_do_not_promote() {
[415] Fix | Delete
return defined( 'ICL_DONT_PROMOTE' ) && ICL_DONT_PROMOTE;
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
/**
[419] Fix | Delete
* @param $time
[420] Fix | Delete
*
[421] Fix | Delete
* @return string
[422] Fix | Delete
*/
[423] Fix | Delete
function icl_convert_to_user_time( $time ) {
[424] Fix | Delete
[425] Fix | Delete
//offset between server time and user time in seconds
[426] Fix | Delete
$time_offset = get_option( 'gmt_offset' )*3600;
[427] Fix | Delete
$local_time = __( 'Last Update Time could not be determined', 'sitepress' );
[428] Fix | Delete
[429] Fix | Delete
try {
[430] Fix | Delete
//unix time stamp in server time
[431] Fix | Delete
$creation_time = strtotime( $time );
[432] Fix | Delete
//creating dates before 2014 are impossible
[433] Fix | Delete
if ( $creation_time !== false ) {
[434] Fix | Delete
$local_time = date( 'Y-m-d H:i:s', $creation_time + $time_offset );
[435] Fix | Delete
}
[436] Fix | Delete
} catch ( Exception $e ) {
[437] Fix | Delete
//Ignoring the exception, as we already set the default value in $local_time
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
return $local_time;
[441] Fix | Delete
}
[442] Fix | Delete
[443] Fix | Delete
/**
[444] Fix | Delete
* Check if given language is activated
[445] Fix | Delete
*
[446] Fix | Delete
* @global sitepress $sitepress
[447] Fix | Delete
*
[448] Fix | Delete
* @param string $language 2 letters language code
[449] Fix | Delete
*
[450] Fix | Delete
* @return boolean
[451] Fix | Delete
* @since unknown
[452] Fix | Delete
* @deprecated 3.2 use 'wpml_language_is_active' filter instead
[453] Fix | Delete
*/
[454] Fix | Delete
function icl_is_language_active( $language ) {
[455] Fix | Delete
global $sitepress;
[456] Fix | Delete
[457] Fix | Delete
$active_languages = $sitepress->get_active_languages();
[458] Fix | Delete
[459] Fix | Delete
return isset( $active_languages[ $language ] );
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
/**
[463] Fix | Delete
* Checks if given language is enabled
[464] Fix | Delete
*
[465] Fix | Delete
* @global sitepress $sitepress
[466] Fix | Delete
*
[467] Fix | Delete
* @param mixed $empty_value This is normally the value the filter will be modifying.
[468] Fix | Delete
* We are not filtering anything here therefore the NULL value
[469] Fix | Delete
* This for the filter function to actually receive the full argument list:
[470] Fix | Delete
* apply_filters('wpml_language_is_active', '', $language_code);
[471] Fix | Delete
* @param string $language_code The language code to check Accepts a 2-letter language code
[472] Fix | Delete
*
[473] Fix | Delete
* @return boolean
[474] Fix | Delete
* @since 3.2
[475] Fix | Delete
* @use \SitePress::api_hooks
[476] Fix | Delete
*/
[477] Fix | Delete
function wpml_language_is_active_filter( $empty_value, $language_code ) {
[478] Fix | Delete
global $sitepress;
[479] Fix | Delete
[480] Fix | Delete
return $sitepress->is_active_language( $language_code );
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
/**
[484] Fix | Delete
* @param string $url url either with or without schema
[485] Fix | Delete
* Removes the subdirectory in which WordPress is installed from a url.
[486] Fix | Delete
* If WordPress is not installed in a subdirectory, then the input is returned unaltered.
[487] Fix | Delete
*
[488] Fix | Delete
* @return string the url input without the blog's subdirectory. Potentially existing schemata on the input are kept intact.
[489] Fix | Delete
*/
[490] Fix | Delete
function wpml_strip_subdir_from_url( $url ) {
[491] Fix | Delete
/** @var WPML_URL_Converter $wpml_url_converter */
[492] Fix | Delete
global $wpml_url_converter;
[493] Fix | Delete
[494] Fix | Delete
$subdir = wpml_parse_url( $wpml_url_converter->get_abs_home(), PHP_URL_PATH );
[495] Fix | Delete
$subdir_slugs = array_values( array_filter( explode( '/', $subdir ) ) );
[496] Fix | Delete
[497] Fix | Delete
$url_path_expl = explode( '/', preg_replace( '#^(http|https)://#', '', $url ) );
[498] Fix | Delete
array_shift( $url_path_expl );
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function