Plugin Directory

Opened 3 years ago

Last modified 3 years ago

#2294 new defect

POLYLANG: Hooking for custom columns in categories/tags admin pages is done wrong BLOCKING other plugins to output custom columns

Reported by: oacsu Owned by:
Priority: high Severity: normal
Plugin: not-listed Keywords: Polylang


In WP output for custom colums in admin tables is done using the "manage_{$this->screen->taxonomy}_custom_column" FILTER (https://developer.wordpress.org/reference/hooks/manage_this-screen-taxonomy_custom_column/).

apply_filters ( "manage_{$this->screen->taxonomy}_custom_column", string $string, string $column_name, int $term_id )

Polylang (1.5.5) use it as an ACTION (admin-filter-columns.php). In contructor is added as an action and in term_column method html is output directly with printf and does not return the first parameter.

Here is what is blocking other plugins to output custom columns:

public function term_column($empty, $column, $term_id)
		$inline = defined('DOING_AJAX') && $_REQUEST['action'] == 'inline-save-tax' && isset($_POST['inline_lang_choice']);
		if (false === strpos($column, 'language_') || !($lang = $inline ? $this->model->get_language($_POST['inline_lang_choice']) : $this->model->get_term_language($term_id)))
			//return; - this is the wrong return
			return $empty; // this is correct

$empty is not empty if other plugins added custom columns, it may contain the output of one of these columns. This parameter should be always returned (we are inside a FILTER and WP expects something to be returned from a filter).

Also the method uses printf to output html. It should use sprintf to put html in a variable and return $empty . $var.
Current code works with printf (but blocking other plugins to output) because WP echoes the returned value from "manage_{$this->screen->taxonomy}_custom_column" filter immediately.

Change History (1)

comment:1 @oacsu3 years ago

Forgot to tell, in constructor (admin-filter-columns.php - class PLL_Admin_Filters_Columns) it should be:

add_filter('manage_'.$tax.'_custom_column', array(&$this, 'term_column'), 10, 3);


add_action('manage_'.$tax.'_custom_column', array(&$this, 'term_column'), 10, 3);

Also this kind of problem may be present in other places but I looked only at this specific case.

Note: See TracTickets for help on using tickets.