true ), 'objects' );
foreach ( $taxonomy_objs as $taxonomy_obj ) {
if ($falang_taxonomy->is_taxonomy_translatable( $taxonomy_obj->name )){
add_filter( 'manage_edit-' . $taxonomy_obj->name . '_columns', array( $this, 'add_term_column' ) );
add_filter( 'manage_' . $taxonomy_obj->name . '_custom_column', array( $this, 'term_column' ), 10, 3 );
}
}
}
/**
* Adds the language column ( before the posts column ) in the 'Categories' or 'Post Tags' table
*
* @since 1.2.4
*
* @param array $columns list of terms table columns
* @return array modified list of columns
*/
public function add_term_column( $columns ) {
return $this->add_column( $columns, 'posts' );
}
/**
* Fills the language column in the 'Categories' or 'Post Tags' table
*
* @since 1.2.4
*
* @param string $out
* @param string $column Column name
* @param int $term_id
*/
public function term_column( $out, $column, $term_id ) {
$inline = wp_doing_ajax() && isset( $_REQUEST['action'], $_POST['inline_lang_choice'] ) && 'inline-save-tax' === $_REQUEST['action']; // phpcs:ignore WordPress.Security.NonceVerification
if ( false === strpos( $column, 'language_' ) ) { // phpcs:ignore WordPress.Security.NonceVerification
return $out;
}
//from polylang
if ( isset( $_REQUEST['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$post_type = sanitize_key( $_REQUEST['post_type'] ); // phpcs:ignore WordPress.Security.NonceVerification
}
if ( isset( $GLOBALS['post_type'] ) ) {
$post_type = $GLOBALS['post_type'];
}
if ( isset( $_REQUEST['taxonomy'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$taxonomy = sanitize_key( $_REQUEST['taxonomy'] ); // phpcs:ignore WordPress.Security.NonceVerification
}
if ( isset( $GLOBALS['taxonomy'] ) ) {
$taxonomy = $GLOBALS['taxonomy'];
}
if ( ! post_type_exists( $post_type ) || ! taxonomy_exists( $taxonomy ) ) {
return $out;
}
//get locale from column name ex : language_de_DE => de_DE
$locale = str_replace('language_','',$column);
$term_status = get_term_meta($term_id ,Falang_Core::get_prefix($locale).'published',true);
$status = '';
if (!empty($term_status)){
if ($term_status){
$status = '';
} else {
$status = '';
}
}
$term_original = get_term($term_id);
$header_title = ''.$term_original->name.'';
$title_locale = get_term_meta($term_id,Falang_Core::get_prefix($locale).'name' , true);
if (!empty($title_locale)){
$header_title = $title_locale;
}
$out = $status.' '.$header_title;
return $out;
}
}