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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/sitepres.../inc
File: template-functions.php
[1000] Fix | Delete
/**
[1001] Fix | Delete
* @since unknown
[1002] Fix | Delete
* @deprecated 3.2 use 'wpml_element_translation_type' filter instead
[1003] Fix | Delete
*
[1004] Fix | Delete
* @param $id
[1005] Fix | Delete
* @param string $type
[1006] Fix | Delete
*
[1007] Fix | Delete
* @return bool|int
[1008] Fix | Delete
*/
[1009] Fix | Delete
function wpml_get_translation_type( $id, $type = 'post' ) {
[1010] Fix | Delete
$translation_type = WPML_ELEMENT_IS_NOT_TRANSLATED;
[1011] Fix | Delete
[1012] Fix | Delete
if ( $type == 'post' ) {
[1013] Fix | Delete
$translation_type = wpml_post_has_translations( $id );
[1014] Fix | Delete
}
[1015] Fix | Delete
[1016] Fix | Delete
//TODO: [WPML 3.3] handle other element types (e.g. taxonomies, strings, etc.)
[1017] Fix | Delete
[1018] Fix | Delete
return $translation_type;
[1019] Fix | Delete
}
[1020] Fix | Delete
[1021] Fix | Delete
/**
[1022] Fix | Delete
* @since 3.2
[1023] Fix | Delete
* Accepts the ID and type of an element and returns its translation type.
[1024] Fix | Delete
* Values will be one of these:
[1025] Fix | Delete
* WPML_ELEMENT_IS_NOT_TRANSLATED = 0
[1026] Fix | Delete
* WPML_ELEMENT_IS_TRANSLATED = 1
[1027] Fix | Delete
* WPML_ELEMENT_IS_DUPLICATED = 2
[1028] Fix | Delete
* WPML_ELEMENT_IS_A_DUPLICATE = 3
[1029] Fix | Delete
*
[1030] Fix | Delete
* @param mixed $empty_value
[1031] Fix | Delete
*
[1032] Fix | Delete
* @see \wpml_get_active_languages_filter
[1033] Fix | Delete
*
[1034] Fix | Delete
* @param int $element_id The element id to retrieve the information of. Use term_id for taxonomies, post_id for posts
[1035] Fix | Delete
* @param string $element_type Can be a post type: post, page, attachment, nav_menu_item, {custom post key}
[1036] Fix | Delete
* or taxonomy: category, post_tag, nav_menu {custom taxonomy key}
[1037] Fix | Delete
*
[1038] Fix | Delete
* @return int
[1039] Fix | Delete
* @use \SitePress::api_hooks
[1040] Fix | Delete
*/
[1041] Fix | Delete
function wpml_get_element_translation_type_filter( $empty_value, $element_id, $element_type ) {
[1042] Fix | Delete
$translation_type = WPML_ELEMENT_IS_NOT_TRANSLATED;
[1043] Fix | Delete
[1044] Fix | Delete
$element_has_translations = apply_filters( 'wpml_element_has_translations', null, $element_id, $element_type );
[1045] Fix | Delete
$element_is_master = apply_filters( 'wpml_master_post_from_duplicate', $element_id );
[1046] Fix | Delete
$element_is_duplicate = apply_filters( 'wpml_post_duplicates', $element_id );
[1047] Fix | Delete
[1048] Fix | Delete
if ( $element_has_translations ) {
[1049] Fix | Delete
$translation_type = WPML_ELEMENT_IS_TRANSLATED;
[1050] Fix | Delete
if ( $element_is_master ) {
[1051] Fix | Delete
$translation_type = WPML_ELEMENT_IS_A_DUPLICATE;
[1052] Fix | Delete
} elseif ( $element_is_duplicate ) {
[1053] Fix | Delete
$translation_type = WPML_ELEMENT_IS_DUPLICATED;
[1054] Fix | Delete
}
[1055] Fix | Delete
}
[1056] Fix | Delete
[1057] Fix | Delete
return $translation_type;
[1058] Fix | Delete
}
[1059] Fix | Delete
[1060] Fix | Delete
/**
[1061] Fix | Delete
* Accepts the ID of a post and returns its translation type.
[1062] Fix | Delete
* Values will be one of these:
[1063] Fix | Delete
* WPML_ELEMENT_IS_NOT_TRANSLATED = 0
[1064] Fix | Delete
* WPML_ELEMENT_IS_TRANSLATED = 1
[1065] Fix | Delete
* WPML_ELEMENT_IS_DUPLICATED = 2
[1066] Fix | Delete
* WPML_ELEMENT_IS_A_DUPLICATE = 3
[1067] Fix | Delete
*
[1068] Fix | Delete
* @param int $post_id The ID of the post from which to get translation information
[1069] Fix | Delete
*
[1070] Fix | Delete
* @return int
[1071] Fix | Delete
* @internal param string $post_type
[1072] Fix | Delete
* @since 3.2
[1073] Fix | Delete
* @deprecated 3.2 use 'wpml_element_translation_type' filter instead
[1074] Fix | Delete
*/
[1075] Fix | Delete
function wpml_get_post_translation_type( $post_id ) {
[1076] Fix | Delete
$translation_type = WPML_ELEMENT_IS_NOT_TRANSLATED;
[1077] Fix | Delete
[1078] Fix | Delete
$post_type = get_post_type( $post_id );
[1079] Fix | Delete
if ( wpml_post_has_translations( $post_id, $post_type ) ) {
[1080] Fix | Delete
$translation_type = WPML_ELEMENT_IS_TRANSLATED;
[1081] Fix | Delete
if ( wpml_get_master_post_from_duplicate( $post_id ) ) {
[1082] Fix | Delete
$translation_type = WPML_ELEMENT_IS_A_DUPLICATE;
[1083] Fix | Delete
} elseif ( wpml_get_post_duplicates( $post_id ) ) {
[1084] Fix | Delete
$translation_type = WPML_ELEMENT_IS_DUPLICATED;
[1085] Fix | Delete
}
[1086] Fix | Delete
}
[1087] Fix | Delete
[1088] Fix | Delete
return $translation_type;
[1089] Fix | Delete
}
[1090] Fix | Delete
[1091] Fix | Delete
/**
[1092] Fix | Delete
* @param int $post_id
[1093] Fix | Delete
* @param string $post_type
[1094] Fix | Delete
*
[1095] Fix | Delete
* @return bool
[1096] Fix | Delete
* @since 3.2
[1097] Fix | Delete
* @deprecated 3.2 use 'wpml_element_has_translations' filter instead
[1098] Fix | Delete
*/
[1099] Fix | Delete
function wpml_post_has_translations( $post_id, $post_type = 'post' ) {
[1100] Fix | Delete
$has_translations = false;
[1101] Fix | Delete
global $sitepress;
[1102] Fix | Delete
if ( isset( $sitepress ) ) {
[1103] Fix | Delete
$trid = $sitepress->get_element_trid( $post_id, 'post_' . $post_type );
[1104] Fix | Delete
$translations = $sitepress->get_element_translations( $trid );
[1105] Fix | Delete
if ( $translations && count( $translations ) > 1 ) {
[1106] Fix | Delete
$has_translations = true;
[1107] Fix | Delete
}
[1108] Fix | Delete
}
[1109] Fix | Delete
[1110] Fix | Delete
return $has_translations;
[1111] Fix | Delete
}
[1112] Fix | Delete
[1113] Fix | Delete
/**
[1114] Fix | Delete
* Checks if an element has translations
[1115] Fix | Delete
* A translation can be a manual translation or a duplication.
[1116] Fix | Delete
* @since 3.2
[1117] Fix | Delete
*
[1118] Fix | Delete
* @param mixed $empty_value
[1119] Fix | Delete
*
[1120] Fix | Delete
* @see \wpml_get_active_languages_filter
[1121] Fix | Delete
*
[1122] Fix | Delete
* @param int $element_id Use term_id for taxonomies, post_id for posts
[1123] Fix | Delete
* @param string $element_type Can be a post type: post, page, attachment, nav_menu_item, {custom post key}
[1124] Fix | Delete
* or taxonomy: category, post_tag, nav_menu {custom taxonomy key}
[1125] Fix | Delete
*
[1126] Fix | Delete
* @return bool
[1127] Fix | Delete
* @use \SitePress::api_hooks
[1128] Fix | Delete
*/
[1129] Fix | Delete
function wpml_element_has_translations_filter( $empty_value, $element_id, $element_type = 'post' ) {
[1130] Fix | Delete
$has_translations = false;
[1131] Fix | Delete
global $sitepress;
[1132] Fix | Delete
if ( isset( $sitepress ) ) {
[1133] Fix | Delete
$wpml_element_type = apply_filters( 'wpml_element_type', $element_type );
[1134] Fix | Delete
[1135] Fix | Delete
if ( strpos( $wpml_element_type, 'tax_' ) === 0 ) {
[1136] Fix | Delete
/** @var WPML_Term_Translation $wpml_term_translations*/
[1137] Fix | Delete
global $wpml_term_translations;
[1138] Fix | Delete
$element_id = $wpml_term_translations->adjust_ttid_for_term_id( $element_id );
[1139] Fix | Delete
}
[1140] Fix | Delete
[1141] Fix | Delete
$trid = $sitepress->get_element_trid( $element_id, $wpml_element_type );
[1142] Fix | Delete
[1143] Fix | Delete
$translations = apply_filters( 'wpml_get_element_translations_filter', '', $trid, $wpml_element_type );
[1144] Fix | Delete
[1145] Fix | Delete
if ( $translations && count( $translations ) > 1 ) {
[1146] Fix | Delete
$has_translations = true;
[1147] Fix | Delete
}
[1148] Fix | Delete
}
[1149] Fix | Delete
[1150] Fix | Delete
return $has_translations;
[1151] Fix | Delete
}
[1152] Fix | Delete
[1153] Fix | Delete
function wpml_get_content_translations_filter( $empty, $post_id, $content_type = 'post' ) {
[1154] Fix | Delete
global $sitepress;
[1155] Fix | Delete
$translations = array();
[1156] Fix | Delete
if ( isset( $sitepress ) ) {
[1157] Fix | Delete
$wpml_element_type = apply_filters( 'wpml_element_type', $content_type );
[1158] Fix | Delete
[1159] Fix | Delete
$trid = $sitepress->get_element_trid( $post_id, $wpml_element_type );
[1160] Fix | Delete
[1161] Fix | Delete
$translations = apply_filters( 'wpml_get_element_translations', null, $trid, $wpml_element_type );
[1162] Fix | Delete
}
[1163] Fix | Delete
[1164] Fix | Delete
return $translations;
[1165] Fix | Delete
}
[1166] Fix | Delete
[1167] Fix | Delete
/**
[1168] Fix | Delete
* @param $post_id
[1169] Fix | Delete
*
[1170] Fix | Delete
* @return mixed
[1171] Fix | Delete
* @since 3.2
[1172] Fix | Delete
* @deprecated 3.2 use 'wpml_master_post_from_duplicate' filter instead
[1173] Fix | Delete
*/
[1174] Fix | Delete
function wpml_get_master_post_from_duplicate( $post_id ) {
[1175] Fix | Delete
return get_post_meta( $post_id, '_icl_lang_duplicate_of', true );
[1176] Fix | Delete
}
[1177] Fix | Delete
[1178] Fix | Delete
/**
[1179] Fix | Delete
* Get the original post from the duplicated post
[1180] Fix | Delete
*
[1181] Fix | Delete
* @param int $post_id The duplicated post ID
[1182] Fix | Delete
*
[1183] Fix | Delete
* @return int or empty string if there is nothing to return
[1184] Fix | Delete
* @use \SitePress::api_hooks
[1185] Fix | Delete
*/
[1186] Fix | Delete
function wpml_get_master_post_from_duplicate_filter( $post_id ) {
[1187] Fix | Delete
return get_post_meta( $post_id, '_icl_lang_duplicate_of', true );
[1188] Fix | Delete
}
[1189] Fix | Delete
[1190] Fix | Delete
/**
[1191] Fix | Delete
* @param $master_post_id
[1192] Fix | Delete
*
[1193] Fix | Delete
* @return mixed
[1194] Fix | Delete
* @since 3.2
[1195] Fix | Delete
* @deprecated 3.2 use 'wpml_post_duplicates' filter instead
[1196] Fix | Delete
*/
[1197] Fix | Delete
function wpml_get_post_duplicates( $master_post_id ) {
[1198] Fix | Delete
global $sitepress;
[1199] Fix | Delete
if ( isset( $sitepress ) ) {
[1200] Fix | Delete
return $sitepress->get_duplicates( $master_post_id );
[1201] Fix | Delete
}
[1202] Fix | Delete
[1203] Fix | Delete
return array();
[1204] Fix | Delete
}
[1205] Fix | Delete
[1206] Fix | Delete
/**
[1207] Fix | Delete
* Get the duplicated post ids
[1208] Fix | Delete
* Will return an associative array with language codes as indexes and post_ids as values
[1209] Fix | Delete
*
[1210] Fix | Delete
* @param int $master_post_id The original post id from which duplicates exist
[1211] Fix | Delete
*
[1212] Fix | Delete
* @return array
[1213] Fix | Delete
* @use \SitePress::api_hooks
[1214] Fix | Delete
*/
[1215] Fix | Delete
function wpml_get_post_duplicates_filter( $master_post_id ) {
[1216] Fix | Delete
global $sitepress;
[1217] Fix | Delete
if ( isset( $sitepress ) ) {
[1218] Fix | Delete
return $sitepress->get_duplicates( $master_post_id );
[1219] Fix | Delete
}
[1220] Fix | Delete
[1221] Fix | Delete
return array();
[1222] Fix | Delete
}
[1223] Fix | Delete
[1224] Fix | Delete
/**
[1225] Fix | Delete
* Filters a WordPress element by adding the WPML prefix 'post_', 'tax_', or nothing for 'comment' as used in icl_translations db table
[1226] Fix | Delete
* @since 3.2
[1227] Fix | Delete
*
[1228] Fix | Delete
* @param string $element_type Accepts comment, post, page, attachment, nav_menu_item, {custom post key},
[1229] Fix | Delete
* nav_menu, category, post_tag, {custom taxonomy key}
[1230] Fix | Delete
*
[1231] Fix | Delete
* @return string
[1232] Fix | Delete
* @use \SitePress::api_hooks
[1233] Fix | Delete
*/
[1234] Fix | Delete
function wpml_element_type_filter( $element_type ) {
[1235] Fix | Delete
global $wp_post_types, $wp_taxonomies;
[1236] Fix | Delete
[1237] Fix | Delete
$post_types = array_keys( (array) $wp_post_types );
[1238] Fix | Delete
$taxonomies = array_keys( (array) $wp_taxonomies );
[1239] Fix | Delete
[1240] Fix | Delete
if ( in_array( $element_type, $taxonomies ) ) {
[1241] Fix | Delete
$wpml_element_type = 'tax_' . $element_type;
[1242] Fix | Delete
} elseif ( in_array( $element_type, $post_types ) ) {
[1243] Fix | Delete
$wpml_element_type = 'post_' . $element_type;
[1244] Fix | Delete
} else {
[1245] Fix | Delete
$wpml_element_type = $element_type;
[1246] Fix | Delete
}
[1247] Fix | Delete
[1248] Fix | Delete
return $wpml_element_type;
[1249] Fix | Delete
}
[1250] Fix | Delete
[1251] Fix | Delete
/**
[1252] Fix | Delete
* Retrieves language information for a translatable element
[1253] Fix | Delete
* Checks icl_translations db table and returns an object with the element's
[1254] Fix | Delete
* trid, source language code and language code
[1255] Fix | Delete
* @since 3.2.2
[1256] Fix | Delete
*
[1257] Fix | Delete
* @param mixed $element_object A WordPress object. Defaults to null
[1258] Fix | Delete
* @param array $args {
[1259] Fix | Delete
* Required An array of arguments to be used
[1260] Fix | Delete
*
[1261] Fix | Delete
* @type int $element_id Use term_taxonomy_id for taxonomies, post_id for posts
[1262] Fix | Delete
* @type string $element_type Can be a post type: post, page, attachment, nav_menu_item, {custom post key}
[1263] Fix | Delete
* or taxonomy: category, post_tag, nav_menu {custom taxonomy key}
[1264] Fix | Delete
* }
[1265] Fix | Delete
* @return object
[1266] Fix | Delete
* @use \SitePress::api_hooks
[1267] Fix | Delete
*/
[1268] Fix | Delete
function wpml_element_language_details_filter($element_object = null, $args) {
[1269] Fix | Delete
global $sitepress;
[1270] Fix | Delete
if(isset($sitepress)) {
[1271] Fix | Delete
$element_type = apply_filters( 'wpml_element_type', $args[ 'element_type' ] );
[1272] Fix | Delete
$element_object = $sitepress->get_element_language_details( $args[ 'element_id' ], $element_type );
[1273] Fix | Delete
}
[1274] Fix | Delete
[1275] Fix | Delete
return $element_object;
[1276] Fix | Delete
}
[1277] Fix | Delete
[1278] Fix | Delete
/**
[1279] Fix | Delete
* Retrieves the language code for a translatable element
[1280] Fix | Delete
* Checks icl_translations db table and returns the element's language code
[1281] Fix | Delete
* @since 3.2.2
[1282] Fix | Delete
*
[1283] Fix | Delete
* @param mixed $language_code A 2-letter language code. Defaults to null
[1284] Fix | Delete
* @param array $args {
[1285] Fix | Delete
* Required An array of arguments to be used
[1286] Fix | Delete
*
[1287] Fix | Delete
* @type int $element_id Use term_taxonomy_id for taxonomies, post_id for posts
[1288] Fix | Delete
* @type string $element_type Can be a post type: post, page, attachment, nav_menu_item, {custom post key}
[1289] Fix | Delete
* or taxonomy: category, post_tag, nav_menu {custom taxonomy key}
[1290] Fix | Delete
* }
[1291] Fix | Delete
* @return string
[1292] Fix | Delete
* @use \SitePress::api_hooks
[1293] Fix | Delete
*/
[1294] Fix | Delete
function wpml_element_language_code_filter($language_code = null, $args) {
[1295] Fix | Delete
global $sitepress;
[1296] Fix | Delete
if(isset($sitepress)) {
[1297] Fix | Delete
$element_type = apply_filters( 'wpml_element_type', $args[ 'element_type' ] );
[1298] Fix | Delete
[1299] Fix | Delete
$language_code = $sitepress->get_language_for_element( $args[ 'element_id' ], $element_type );
[1300] Fix | Delete
}
[1301] Fix | Delete
[1302] Fix | Delete
return $language_code;
[1303] Fix | Delete
}
[1304] Fix | Delete
[1305] Fix | Delete
/**
[1306] Fix | Delete
* Retrieves the elements without translations
[1307] Fix | Delete
* Queries the database and returns an array with ids
[1308] Fix | Delete
* @since 3.2.2
[1309] Fix | Delete
*
[1310] Fix | Delete
* @param array $element_ids An array of element ids. Defaults to an empty array
[1311] Fix | Delete
* @param array $args {
[1312] Fix | Delete
* Required An array of arguments to be used
[1313] Fix | Delete
*
[1314] Fix | Delete
* @type string $target_language The target language code
[1315] Fix | Delete
* @type string $source_language The source language code
[1316] Fix | Delete
* @type string $element_type Can be a post type: post, page, attachment, nav_menu_item, {custom post key}
[1317] Fix | Delete
* or taxonomy: category, post_tag, nav_menu {custom taxonomy key}
[1318] Fix | Delete
* }
[1319] Fix | Delete
* @return array
[1320] Fix | Delete
* @use \SitePress::api_hooks
[1321] Fix | Delete
*/
[1322] Fix | Delete
function wpml_elements_without_translations_filter($element_ids = array(), $args) {
[1323] Fix | Delete
global $sitepress;
[1324] Fix | Delete
if(isset($sitepress)) {
[1325] Fix | Delete
$element_type = apply_filters( 'wpml_element_type', $args[ 'element_type' ] );
[1326] Fix | Delete
$element_ids = $sitepress->get_elements_without_translations( $element_type, $args[ 'target_language' ], $args[ 'source_language' ] );
[1327] Fix | Delete
}
[1328] Fix | Delete
return $element_ids;
[1329] Fix | Delete
}
[1330] Fix | Delete
[1331] Fix | Delete
/**
[1332] Fix | Delete
* @deprecated Use the filter hook `wpml_permalink` instead
[1333] Fix | Delete
*
[1334] Fix | Delete
* Filters a WordPress permalink and converts it to a language specific permalink based on plugin settings
[1335] Fix | Delete
*
[1336] Fix | Delete
* @since 3.2.2
[1337] Fix | Delete
*
[1338] Fix | Delete
* @param string $url The WordPress generated url to filter
[1339] Fix | Delete
* @param null|string $language_code if null, it falls back to default language for root page,
[1340] Fix | Delete
* or current language in all other cases.
[1341] Fix | Delete
*
[1342] Fix | Delete
* @return string
[1343] Fix | Delete
*/
[1344] Fix | Delete
function wpml_permalink_filter( $url, $language_code = null ) {
[1345] Fix | Delete
return apply_filters( 'wpml_permalink', $url, $language_code );
[1346] Fix | Delete
}
[1347] Fix | Delete
[1348] Fix | Delete
/**
[1349] Fix | Delete
* Switches WPML's query language
[1350] Fix | Delete
* @since 3.2.2
[1351] Fix | Delete
* @type null|string $language_code The language code to switch to
[1352] Fix | Delete
* If set to null it restores the original language
[1353] Fix | Delete
* If set to 'all' it will query content from all active languages
[1354] Fix | Delete
* Defaults to null
[1355] Fix | Delete
* @use \SitePress::api_hooks
[1356] Fix | Delete
*/
[1357] Fix | Delete
function wpml_switch_language_action($language_code = null) {
[1358] Fix | Delete
global $sitepress;
[1359] Fix | Delete
[1360] Fix | Delete
$sitepress->switch_lang( $language_code, true );
[1361] Fix | Delete
}
[1362] Fix | Delete
[1363] Fix | Delete
[1364] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function