' . __('Configure', 'sitepress') . '';
}
return $links;
}
if(defined('ICL_DEBUG_MODE') && ICL_DEBUG_MODE){
add_action('admin_notices', '_icl_deprecated_icl_debug_mode');
}
function _icl_deprecated_icl_debug_mode(){
echo '
ICL_DEBUG_MODE no longer supported. Please use WP_DEBUG instead.
';
}
function icl_js_escape($str){
$str = esc_js($str);
$str = htmlspecialchars_decode($str);
return $str;
}
function icl_nobreak($str){
return preg_replace("# #", ' ', $str);
}
function _icl_tax_has_objects_recursive($id, $term_id = -1, $rec = 0){
// based on the case where two categories were one the parent of another
// eliminating the chance of infinite loops by letting this function calling itself too many times
// 100 is the default limit in most of teh php configuration
//
// this limit this function to work only with categories nested up to 60 levels
// should enough for most cases
if($rec > 60) return false;
global $wpdb;
if($term_id === -1){
$term_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id=%d", $id));
}
$children = $wpdb->get_results($wpdb->prepare("
SELECT term_taxonomy_id, term_id, count FROM {$wpdb->term_taxonomy} WHERE parent = %d
", $term_id));
$count = 0;
foreach($children as $ch){
$count += $ch->count;
}
if($count){
return true;
}else{
foreach($children as $ch){
if(_icl_tax_has_objects_recursive($ch->term_taxonomy_id, $ch->term_id, $rec+1)){
return true;
}
}
}
return false;
}
function icl_get_post_children_recursive($post, $type = 'page'){
global $wpdb;
$post = (array)$post;
$children = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type=%s AND post_parent IN (".join(',', $post).")", $type));
if(!empty($children)){
$children = array_merge($children, icl_get_post_children_recursive($children));
}
return $children;
}
function icl_get_tax_children_recursive($id, $taxonomy = 'category'){
global $wpdb;
$id = (array)$id;
$children = $wpdb->get_col($wpdb->prepare("SELECT term_id FROM {$wpdb->term_taxonomy} x WHERE x.taxonomy=%s AND parent IN (".join(',', $id).")", $taxonomy));
if(!empty($children)){
$children = array_merge($children, icl_get_tax_children_recursive($children));
}
return $children;
}
function _icl_trash_restore_prompt(){
global $sitepress;
if(isset($_GET['lang'])){
$post = get_post(intval($_GET['post']));
if(isset($post->post_status) && $post->post_status == 'trash'){
$post_type_object = get_post_type_object( $post->post_type );
$ret = '';
$ret .= sprintf(__('This translation is currently in the trash. You need to either delete it permanently or restore it in order to continue.'),
get_delete_post_link($post->ID, '', true) ,
wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID)
);
$ret .= '
';
wp_die($ret);
}
}
}
function icl_pop_info($message, $icon='info', $args = array()){
switch($icon){
case 'info':
$icon = ICL_PLUGIN_URL . '/res/img/info.png';
break;
case 'question':
$icon = ICL_PLUGIN_URL . '/res/img/question1.png';
break;
}
$defaults = array(
'icon_size' => 16,
'but_style' => array()
);
extract($defaults);
extract($args, EXTR_OVERWRITE);
?>