PluginProbe
Polylang / 2.3.6
Polylang v2.3.6
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | settings/table-settings.php +38 -50 3.02.3.6 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 if ( ! class_exists( 'WP_List_Table' ) ) {
7 4 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
8 5 }
@@ -18,15 +15,13 @@
18 15 * Constructor
19 16 *
20 17 * @since 1.8
21 18 */
22 - public function __construct() {
23 - parent::__construct(
24 - array(
25 - 'plural' => 'Settings', // Do not translate ( used for css class )
26 - 'ajax' => false,
27 - )
28 - );
19 + function __construct() {
20 + parent::__construct( array(
21 + 'plural' => 'Settings', // Do not translate ( used for css class )
22 + 'ajax' => false,
23 + ) );
29 24 }
30 25
31 26 /**
32 27 * Get the table classes for styling
@@ -37,14 +32,13 @@
37 32 return array( 'wp-list-table', 'widefat', 'plugins', 'pll-settings' ); // get the style of the plugins list table + one specific class
38 33 }
39 34
40 35 /**
41 - * Displays a single row.
36 + * Displays a single row
42 37 *
43 38 * @since 1.8
44 39 *
45 - * @param PLL_Settings_Module $item Settings module item.
46 - * @return void
40 + * @param object $item PLL_Settings_Module object
47 41 */
48 42 public function single_row( $item ) {
49 43 // Classes to reuse css from the plugins list table
50 44 $classes = $item->is_active() ? 'active' : 'inactive';
@@ -58,13 +52,18 @@
58 52 echo '</tr>';
59 53
60 54 // Display an upgrade message if there is any, reusing css from the plugins updates
61 55 if ( $message = $item->get_upgrade_message() ) {
62 - printf(
63 - '<tr class="plugin-update-tr">
56 + printf( '
57 + <tr class="plugin-update-tr">
64 58 <td colspan="3" class="plugin-update colspanchange">%s</td>
65 59 </tr>',
66 - sprintf( '<div class="update-message notice inline notice-warning notice-alt"><p>%s</p></div>', $message ) // phpcs:ignore WordPress.Security.EscapeOutput
60 + sprintf(
61 + version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ?
62 + '<div class="update-message">%s</div>' : // backward compatibility with WP < 4.6
63 + '<div class="update-message notice inline notice-warning notice-alt"><p>%s</p></div>',
64 + $message
65 + )
67 66 );
68 67 }
69 68
70 69 // The settings if there are
@@ -69,10 +68,10 @@
69 68
70 69 // The settings if there are
71 70 // "inactive" class to reuse css from the plugins list table
72 71 if ( $form = $item->get_form() ) {
73 - printf(
74 - '<tr id="pll-configure-%s" class="pll-configure inactive inline-edit-row" style="display: none;">
72 + printf( '
73 + <tr id="pll-configure-%s" class="pll-configure inactive inline-edit-row" style="display: none;">
75 74 <td colspan="3">
76 75 <legend>%s</legend>
77 76 %s
78 77 <p class="submit inline-edit-save">
@@ -79,42 +78,41 @@
79 78 %s
80 79 </p>
81 80 </td>
82 81 </tr>',
83 - esc_attr( $item->module ),
84 - esc_html( $item->title ),
85 - $form, // phpcs:ignore
86 - implode( $item->get_buttons() ) // phpcs:ignore
82 + esc_attr( $item->module ), esc_html( $item->title ), $form, implode( $item->get_buttons() )
87 83 );
88 84 }
89 85 }
90 86
91 87 /**
92 - * Generates the columns for a single row of the table.
88 + * Generates the columns for a single row of the table
93 89 *
94 90 * @since 1.8
95 91 *
96 - * @param PLL_Settings_Module $item Settings module item.
97 - * @return void
92 + * @param object $item The current item
98 93 */
99 94 protected function single_row_columns( $item ) {
100 - $column_info = $this->get_column_info();
101 - $columns = $column_info[0];
102 - $primary = $column_info[3];
95 + list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
103 96
104 - foreach ( array_keys( $columns ) as $column_name ) {
97 + foreach ( $columns as $column_name => $column_display_name ) {
105 98 $classes = "$column_name column-$column_name";
106 99 if ( $primary === $column_name ) {
107 100 $classes .= ' column-primary';
108 101 }
109 102
103 + if ( in_array( $column_name, $hidden ) ) {
104 + $classes .= ' hidden';
105 + }
106 +
110 107 if ( 'cb' == $column_name ) {
111 108 echo '<th scope="row" class="check-column">';
112 - echo $this->column_cb( $item ); // phpcs:ignore WordPress.Security.EscapeOutput
109 + echo $this->column_cb( $item );
113 110 echo '</th>';
114 - } else {
111 + }
112 + else {
115 113 printf( '<td class="%s">', esc_attr( $classes ) );
116 - echo $this->column_default( $item, $column_name ); // phpcs:ignore WordPress.Security.EscapeOutput
114 + echo $this->column_default( $item, $column_name );
117 115 echo '</td>';
118 116 }
119 117 }
120 118 }
@@ -119,15 +117,15 @@
119 117 }
120 118 }
121 119
122 120 /**
123 - * Displays the item information in a column (default case).
121 + * Displays the item information in a column ( default case )
124 122 *
125 123 * @since 1.8
126 124 *
127 - * @param PLL_Settings_Module $item Settings module item.
128 - * @param string $column_name Column name.
129 - * @return string The column name.
125 + * @param object $item
126 + * @param string $column_name
127 + * @return string
130 128 */
131 129 protected function column_default( $item, $column_name ) {
132 130 if ( 'plugin-title' == $column_name ) {
133 131 return sprintf( '<strong>%s</strong>', esc_html( $item->title ) ) . $this->row_actions( $item->get_action_links(), true /*always visible*/ );
@@ -135,13 +133,13 @@
135 133 return $item->$column_name;
136 134 }
137 135
138 136 /**
139 - * Gets the list of columns.
137 + * Gets the list of columns
140 138 *
141 139 * @since 1.8
142 140 *
143 - * @return string[] The list of column titles.
141 + * @return array the list of column titles
144 142 */
145 143 public function get_columns() {
146 144 return array(
147 145 'cb' => '', // For the 4px border inherited from plugins when the module is activated
@@ -165,21 +163,12 @@
165 163 * Prepares the list of items for displaying
166 164 *
167 165 * @since 1.8
168 166 *
169 - * @param PLL_Settings_Module[] $items Array of settings module items.
170 - * @return void
167 + * @param array $items
171 168 */
172 169 public function prepare_items( $items = array() ) {
173 170 $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns(), $this->get_primary_column_name() );
174 -
175 - // Sort rows, lowest priority on top.
176 - usort(
177 - $items,
178 - function( $a, $b ) {
179 - return $a->priority > $b->priority ? 1 : -1;
180 - }
181 - );
182 171 $this->items = $items;
183 172 }
184 173
185 174 /**
@@ -187,8 +176,7 @@
187 176 *
188 177 * @since 2.1
189 178 *
190 179 * @param string $which 'top' or 'bottom'
191 - * @return void
192 180 */
193 - protected function display_tablenav( $which ) {} // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
181 + protected function display_tablenav( $which ) {}
194 182 }