PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | class/class-mainwp-updates-table-helper.php +93 -20 5.1 → 6.2.2 View file →
@@ -6,8 +6,13 @@
6 6 */
7 7
8 8 namespace MainWP\Dashboard;
9 9
10 +// Exit if accessed directly.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
14 +
10 15 /**
11 16 * Class MainWP_Updates_Table_Helper
12 17 *
13 18 * @package MainWP\Dashboard
@@ -72,10 +77,10 @@
72 77 $title = ( 'plugin' === $this->type ) ? esc_html__( 'Plugin', 'mainwp' ) : esc_html__( 'Theme', 'mainwp' );
73 78 }
74 79
75 80 $columns = array(
81 + 'site' => esc_html__( 'Website', 'mainwp' ),
76 82 'title' => $title,
77 - 'login' => '<i class="sign in alternate icon"></i>',
78 83 'version' => esc_html__( 'Version', 'mainwp' ),
79 84 'latest' => esc_html__( 'Latest', 'mainwp' ),
80 85 'trusted' => esc_html__( 'Trusted', 'mainwp' ),
81 86 'status' => esc_html__( 'Status', 'mainwp' ),
@@ -83,14 +88,19 @@
83 88 'action' => '',
84 89 );
85 90
86 91 if ( MAINWP_VIEW_PER_PLUGIN_THEME !== $this->view_per ) {
87 - unset( $columns['login'] );
92 + unset( $columns['site'] );
88 93 unset( $columns['client'] );
94 + } else {
95 + unset( $columns['title'] );
89 96 }
90 97 if ( MAINWP_VIEW_PER_PLUGIN_THEME === $this->view_per ) {
91 98 unset( $columns['trusted'] );
92 99 }
100 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_clients' ) ) {
101 + unset( $columns['client'] );
102 + }
93 103 return $columns;
94 104 }
95 105
96 106 /**
@@ -101,9 +111,10 @@
101 111 return $this->columns_info;
102 112 }
103 113 $columns = $this->get_columns();
104 114 $sortable = $this->get_sortable_columns();
105 - $this->columns_info = apply_filters( 'mainwp_updates_table_columns_header', array( $columns, $sortable ), $this->type, $this->view_per );
115 + $collapsing = $this->get_collapsing_columns();
116 + $this->columns_info = apply_filters( 'mainwp_updates_table_columns_header', array( $columns, $sortable, $collapsing ), $this->type, $this->view_per );
106 117 return $this->columns_info;
107 118 }
108 119
109 120 /**
@@ -120,8 +131,24 @@
120 131 );
121 132 }
122 133
123 134 /**
135 + * Get collapsing columns.
136 + *
137 + * @return array $collapsing_columns Array of collapsing columns.
138 + */
139 + public function get_collapsing_columns() {
140 + return array(
141 + 'version' => true,
142 + 'latest' => true,
143 + 'trusted' => true,
144 + 'status' => true,
145 + 'client' => true,
146 + 'action' => true,
147 + );
148 + }
149 +
150 + /**
124 151 * Echo the column headers.
125 152 *
126 153 * @param bool $top true|false.
127 154 */
@@ -126,9 +153,9 @@
126 153 * @param bool $top true|false.
127 154 */
128 155 public function print_column_headers( $top = true ) {
129 156
130 - list( $columns_header, $sortable ) = $this->get_column_info();
157 + list( $columns_header, $sortable, $collapsing ) = $this->get_column_info();
131 158
132 159 foreach ( $columns_header as $column_key => $column_display_name ) {
133 160 $class = array();
134 161 if ( ! isset( $sortable[ $column_key ] ) ) {
@@ -133,8 +160,11 @@
133 160 $class = array();
134 161 if ( ! isset( $sortable[ $column_key ] ) ) {
135 162 $class[] = 'no-sort';
136 163 }
164 + if ( isset( $collapsing[ $column_key ] ) ) {
165 + $class[] = 'two wide collapsing';
166 + }
137 167
138 168 if ( ! empty( $class ) ) {
139 169 $class = "class='" . join( ' ', $class ) . "'";
140 170 } else {
@@ -151,14 +181,9 @@
151 181 *
152 182 * @param mixed $value Value of column.
153 183 */
154 184 public function column_trusted( $value ) {
155 - if ( $value ) {
156 - $label = '<span class="ui tiny basic green label mainwp-768-fluid">Trusted</span>';
157 - } else {
158 - $label = '<span class="ui tiny basic grey label mainwp-768-fluid">Not Trusted</span>';
159 - }
160 - return '<td class="mainwp-768-half-width-cell">' . $label . '</td>';
185 + return MainWP_Manage_Sites_Update_View::get_column_trusted( $value );
161 186 }
162 187
163 188 /**
164 189 * Status column.
@@ -172,30 +197,78 @@
172 197 $label = '<span class="ui tiny basic grey label mainwp-768-fluid">Inactive</span>';
173 198 }
174 199 return '<td class="mainwp-768-half-width-cell">' . $label . '</td>';
175 200 }
201 + /**
202 + * Title column.
203 + *
204 + * @param mixed $value Value of column.
205 + * @param object $website The website.
206 + *
207 + * @return string Column HTML.
208 + */
209 + public function column_site( $value, $website = null ) {
210 + if ( true !== $value ) {
211 + return '<td></td>';
212 + }
176 213
214 + $current_wpid = MainWP_System_Utility::get_current_wpid();
215 +
216 + $column_content = '';
217 +
218 + if ( empty( $current_wpid ) || $this->show_select ) {
219 + $column_content .= '<div class="ui child checkbox">
220 + <input type="checkbox" name="">
221 + </div>';
222 + }
223 +
224 + if ( empty( $current_wpid ) && ! empty( $website ) ) {
225 + $column_content .= MainWP_Utility::mainwp_display_site( $website );
226 + }
227 +
228 + return '<td>' . $column_content . '</td>';
229 + }
230 +
177 231 /**
232 + * Title column.
233 + *
234 + * @param mixed $value Value of column.
235 + *
236 + * @return string Column HTML.
237 + */
238 + public function column_title( $value ) {
239 +
240 + $current_wpid = MainWP_System_Utility::get_current_wpid();
241 +
242 + $column_content = '';
243 +
244 + if ( empty( $current_wpid ) || $this->show_select ) {
245 + $column_content .= '<div class="ui child checkbox">
246 + <input type="checkbox" name="">
247 + </div>';
248 + }
249 +
250 + $column_content .= $value;
251 +
252 + return '<td>' . $column_content . '</td>';
253 + }
254 +
255 + /**
178 256 * Default column.
179 257 *
180 258 * @param mixed $value Value of column.
181 259 * @param mixed $column_name Name of column.
182 260 * @param array $others others data.
261 + *
262 + * @return string Column HTML.
183 263 */
184 264 public function column_default( $value, $column_name, $others = array() ) {
185 - $current_wpid = MainWP_System_Utility::get_current_wpid();
186 - $class = '';
265 + $class = '';
187 266 if ( 'version' === $column_name || 'latest' === $column_name ) {
188 267 $class = 'mainwp-768-half-width-cell';
189 268 }
190 269
191 - $column_content = '';
192 - if ( 'title' === $column_name && ( empty( $current_wpid ) || $this->show_select ) ) {
193 - $column_content .= '<div class="ui child checkbox">
194 - <input type="checkbox" name="">
195 - </div>';
196 - }
197 - $column_content .= $value;
270 + $column_content = $value;
198 271
199 272 if ( 'latest' === $column_name && ! empty( $others['roll_info'] ) ) {
200 273 $column_content = $others['roll_info'] . ' ' . $column_content;
201 274 }
@@ -218,9 +291,9 @@
218 291 foreach ( $columns_header as $col => $title ) {
219 292 if ( isset( $row_columns[ $col ] ) ) {
220 293 $value = $row_columns[ $col ];
221 294 if ( method_exists( $this, 'column_' . $col ) ) {
222 - echo call_user_func( array( &$this, 'column_' . $col ), $value ); // phpcs:ignore WordPress.Security.EscapeOutput
295 + echo call_user_func( array( &$this, 'column_' . $col ), $value, $website, $others ); // phpcs:ignore WordPress.Security.EscapeOutput
223 296 } else {
224 297 echo $this->column_default( $value, $col, $others ); // phpcs:ignore WordPress.Security.EscapeOutput
225 298 }
226 299 }