'Settings', // Do not translate ( used for css class )
'ajax' => false,
) );
}
/**
* Get the table classes for styling
*
* @since 1.8
*/
protected function get_table_classes() {
return array( 'wp-list-table', 'widefat', 'plugins', 'pll-settings' ); // get the style of the plugins list table + one specific class
}
/**
* Displays a single row
*
* @since 1.8
*
* @param object $item PLL_Settings_Module object
*/
public function single_row( $item ) {
// Classes to reuse css from the plugins list table
$classes = $item->is_active() ? 'active' : 'inactive';
if ( $message = $item->get_upgrade_message() ) {
$classes .= ' update';
}
// Display the columns
printf( '
', esc_attr( $item->module ), esc_attr( $classes ) );
$this->single_row_columns( $item );
echo '
';
// Display an upgrade message if there is any, reusing css from the plugins updates
if ( $message = $item->get_upgrade_message() ) {
printf( '
%s |
',
sprintf(
version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ?
'%s
' : // backward compatibility with WP < 4.6
'',
$message
)
);
}
// The settings if there are
// "inactive" class to reuse css from the plugins list table
if ( $form = $item->get_form() ) {
printf( '
%s
%s
|
',
esc_attr( $item->module ), esc_html( $item->title ), $form, implode( $item->get_buttons() )
);
}
}
/**
* Generates the columns for a single row of the table
*
* @since 1.8
*
* @param object $item The current item
*/
protected function single_row_columns( $item ) {
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$classes = "$column_name column-$column_name";
if ( $primary === $column_name ) {
$classes .= ' column-primary';
}
if ( in_array( $column_name, $hidden ) ) {
$classes .= ' hidden';
}
if ( 'cb' == $column_name ) {
echo '';
echo $this->column_cb( $item );
echo ' | ';
}
else {
printf( '', esc_attr( $classes ) );
echo $this->column_default( $item, $column_name );
echo ' | ';
}
}
}
/**
* Added for backward compatibility with WP < 4.2
*
* @since 1.8.2
*
* @param object $item
*/
protected function column_cb( $item ) {}
/**
* Displays the item information in a column ( default case )
*
* @since 1.8
*
* @param object $item
* @param string $column_name
* @return string
*/
protected function column_default( $item, $column_name ) {
if ( 'plugin-title' == $column_name ) {
return sprintf( '%s', esc_html( $item->title ) ) . $this->row_actions( $item->get_action_links(), true /*always visible*/ );
}
return $item->$column_name;
}
/**
* Gets the list of columns
*
* @since 1.8
*
* @return array the list of column titles
*/
public function get_columns() {
return array(
'cb' => '', // For the 4px border inherited from plugins when the module is activated
'plugin-title' => esc_html__( 'Module', 'polylang' ), // plugin-title for styling
'description' => esc_html__( 'Description', 'polylang' ),
);
}
/**
* Gets the name of the primary column.
*
* @since 1.8
*
* @return string The name of the primary column.
*/
protected function get_primary_column_name() {
return 'plugin-title';
}
/**
* Prepares the list of items for displaying
*
* @since 1.8
*
* @param array $items
*/
public function prepare_items( $items = array() ) {
$this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns(), $this->get_primary_column_name() );
$this->items = $items;
}
}