PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 2.4.6
Admin Columns v2.4.6
7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / settings.php
codepress-admin-columns / classes Last commit date
column 10 years ago storage_model 10 years ago addons.php 10 years ago column.php 10 years ago review_notice.php 10 years ago settings.php 10 years ago storage_model.php 10 years ago third_party.php 10 years ago upgrade.php 10 years ago utility.php 10 years ago
settings.php
966 lines
1 <?php
2
3 /**
4 * CPAC_Settings Class
5 *
6 * @since 2.0
7 */
8 class CPAC_Settings {
9
10 /**
11 * CPAC class
12 *
13 * @since 2.0
14 */
15 private $cpac;
16
17 /**
18 * Settings Page
19 *
20 * @since 2.0
21 */
22 private $settings_page;
23
24 /**
25 * @since 2.0
26 * @param object CPAC
27 */
28 function __construct( $cpac ) {
29
30 $this->cpac = $cpac;
31
32 // register settings
33 add_action( 'admin_menu', array( $this, 'settings_menu' ) );
34
35 // handle requests gets a low priority so it will trigger when all other plugins have loaded their columns
36 add_action( 'admin_init', array( $this, 'handle_column_request' ), 1000 );
37
38 add_action( 'wp_ajax_cpac_column_refresh', array( $this, 'ajax_column_refresh' ) );
39
40 add_action( 'cpac_messages', array( $this, 'maybe_display_addon_statuschange_message' ) );
41 }
42
43 /**
44 * @since 3.1.1
45 */
46 public function get_settings_page() {
47 return $this->settings_page;
48 }
49
50 /**
51 * Get available Admin Columns admin page URLs
52 *
53 * @since 2.2
54 * @return array Available settings URLs ([settings_page] => [url])
55 */
56 public function get_settings_urls() {
57
58 /**
59 * Filter the URLs for the different settings screens available in admin columns
60 *
61 * @since 2.2
62 *
63 * @param array $settings_urls Available settings URLs ([settings_page] => [url])
64 * @param CPAC_Settings $settings_instance Settings class instance
65 */
66 $settings_urls = apply_filters( 'cac/settings/settings_urls', array(
67 'admin' => admin_url( 'options-general.php?page=codepress-admin-columns' ),
68 'settings' => admin_url( 'options-general.php?page=codepress-admin-columns&tab=settings' ),
69 'info' => admin_url( 'options-general.php?page=codepress-admin-columns&info=' ),
70 'upgrade' => admin_url( 'options-general.php?page=cpac-upgrade' )
71 ), $this );
72
73 return $settings_urls;
74 }
75
76 /**
77 * Get the settings URL for a page
78 *
79 * @since 2.2
80 * @param string $page Optional. Admin page to get the URL from. Defaults to the basic Admin Columns page
81 * @return string Settings page URL
82 */
83 public function get_settings_url( $page = '' ) {
84
85 $settings_urls = $this->get_settings_urls();
86
87 if ( isset( $settings_urls[ $page ] ) ) {
88 return $settings_urls[ $page ];
89 }
90
91 if ( ! $page ) {
92 return $settings_urls['admin'];;
93 }
94
95 return add_query_arg( 'tab', $page, $this->get_settings_url() );
96 }
97
98 /**
99 * Display an activation/deactivation message on the addons page if applicable
100 *
101 * @since 2.2
102 */
103 public function maybe_display_addon_statuschange_message() {
104
105 if ( empty( $_REQUEST['tab'] ) || $_REQUEST['tab'] != 'addons' ) {
106 return;
107 }
108
109 $message = '';
110
111 if ( ! empty( $_REQUEST['activate'] ) ) {
112 $message = __( 'Add-on successfully activated.', 'cpac' );
113 }
114 else if ( ! empty( $_REQUEST['deactivate'] ) ) {
115 $message = __( 'Add-on successfully deactivated.', 'cpac' );
116 }
117
118 if ( ! $message ) {
119 return;
120 }
121 ?>
122 <div class="updated cac-notification below-h2">
123 <p><?php echo $message; ?></p>
124 </div>
125 <?php
126 }
127
128 /**
129 * @since 2.2
130 */
131 public function ajax_column_refresh() {
132 if ( ! empty( $_POST['formdata'] ) && ! empty( $_POST['column'] ) ) {
133 parse_str( $_POST['formdata'], $formdata );
134 $storagemodel_key = ! empty( $formdata['cpac_key'] ) ? $formdata['cpac_key'] : '';
135
136 if ( $storagemodel_key && ! empty( $formdata[ $storagemodel_key ][ $_POST['column'] ] ) ) {
137 $columndata = $formdata[ $formdata['cpac_key'] ][ $_POST['column'] ];
138 $storage_model = $this->cpac->get_storage_model( $formdata['cpac_key'] );
139 $registered_columns = $storage_model->get_registered_columns();
140
141 if ( in_array( $columndata['type'], array_keys( $registered_columns ) ) ) {
142 $column = clone $registered_columns[ $columndata['type'] ];
143 $column->set_clone( $columndata['clone'] );
144
145 foreach ( $columndata as $optionname => $optionvalue ) {
146 $column->set_options( $optionname, $optionvalue );
147 }
148
149 $column->sanitize_label();
150
151 $columns = array( $column->properties->name => $column );
152
153 do_action( 'cac/columns', $columns );
154 do_action( "cac/columns/storage_key={$storagemodel_key}", $columns );
155
156 $column->display();
157 }
158 }
159 }
160
161 exit;
162 }
163
164 /**
165 * @since 1.0
166 */
167 public function settings_menu() {
168
169 // add settings page
170 $this->settings_page = add_submenu_page( 'options-general.php', __( 'Admin Columns Settings', 'cpac' ), __( 'Admin Columns', 'cpac' ), 'manage_admin_columns', 'codepress-admin-columns', array( $this, 'display' ), false, 98 );
171
172 // add help tabs
173 add_action( "load-{$this->settings_page}", array( $this, 'help_tabs' ) );
174
175 // add scripts & styles
176 add_action( "admin_print_styles-{$this->settings_page}", array( $this, 'admin_styles' ) );
177 add_action( "admin_print_scripts-{$this->settings_page}", array( $this, 'admin_scripts' ) );
178
179 // register setting
180 register_setting( 'cpac-general-settings', 'cpac_general_options' );
181
182 // add cap to options.php
183 add_filter( 'option_page_capability_cpac-general-settings', array( $this, 'add_capability' ) );
184 }
185
186 /**
187 * Allows the capaiblity 'manage_admin_columns' to store data through /wp-admin/options.php
188 *
189 * @since 2.0
190 */
191 public function add_capability() {
192 return 'manage_admin_columns';
193 }
194
195 /**
196 * @since 1.0
197 */
198 public function admin_styles() {
199 $minified = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
200
201 wp_enqueue_style( 'wp-pointer' );
202 wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL . 'assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' );
203 wp_enqueue_style( 'cpac-admin', CPAC_URL . "assets/css/admin-column{$minified}.css", array(), CPAC_VERSION, 'all' );
204 }
205
206 /**
207 * @since 1.0
208 */
209 public function admin_scripts() {
210
211 wp_enqueue_script( 'wp-pointer' );
212 wp_enqueue_script( 'jquery-ui-slider' );
213
214 $minified = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
215
216 wp_enqueue_script( 'cpac-admin-settings', CPAC_URL . "assets/js/admin-settings{$minified}.js", array( 'jquery', 'dashboard', 'jquery-ui-slider', 'jquery-ui-sortable' ), CPAC_VERSION );
217
218 // javascript translations
219 wp_localize_script( 'cpac-admin-settings', 'cpac_i18n', array(
220 'clone' => __( '%s column is already present and can not be duplicated.', 'cpac' ),
221 ));
222 }
223
224 /**
225 * @since 1.0
226 */
227 public function handle_column_request() {
228
229 // only handle updates from the admin columns page
230 if ( ! ( isset($_GET['page'] ) && in_array( $_GET['page'], array( 'codepress-admin-columns' ) ) && isset( $_REQUEST['cpac_action'] ) ) ) {
231 return false;
232 }
233
234 // use $_REQUEST because the values are send both over $_GET and $_POST
235 $action = isset( $_REQUEST['cpac_action'] ) ? $_REQUEST['cpac_action'] : '';
236 $nonce = isset( $_REQUEST['_cpac_nonce'] ) ? $_REQUEST['_cpac_nonce'] : '';
237 $key = isset( $_REQUEST['cpac_key'] ) ? $_REQUEST['cpac_key'] : '';
238
239 switch ( $action ) :
240
241 case 'update_by_type' :
242 if ( wp_verify_nonce( $nonce, 'update-type' ) && $key ) {
243 if ( $storage_model = $this->cpac->get_storage_model( $key ) ) {
244 $storage_model->store();
245 }
246 }
247 break;
248
249 case 'restore_by_type' :
250 if ( wp_verify_nonce( $nonce, 'restore-type' ) && $key ) {
251 if ( $storage_model = $this->cpac->get_storage_model( $key ) ) {
252 $storage_model->restore();
253 }
254 }
255 break;
256
257 case 'restore_all' :
258 if ( wp_verify_nonce( $nonce, 'restore-all' ) ) {
259 $this->restore_all();
260 }
261 break;
262
263 endswitch;
264 }
265
266 /**
267 * Restore all column defaults
268 *
269 * @since 1.0
270 */
271 private function restore_all() {
272 global $wpdb;
273
274 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'cpac_options_%'" );
275
276 cpac_admin_message( __( 'Default settings succesfully restored.', 'cpac' ), 'updated' );
277 }
278
279 /**
280 * Add help tabs to top menu
281 *
282 * @since 1.3.0
283 */
284 public function help_tabs() {
285
286 $screen = get_current_screen();
287
288 if ( ! method_exists( $screen,'add_help_tab' ) )
289 return;
290
291 $tabs = array(
292 array(
293 'title' => __( "Overview", 'cpac' ),
294 'content' =>
295 "<h5>Admin Columns</h5>
296 <p>". __( "This plugin is for adding and removing additional columns to the administration screens for post(types), pages, media library, comments, links and users. Change the column's label and reorder them.", 'cpac' ) . "</p>"
297 ),
298 array(
299 'title' => __( "Basics", 'cpac' ),
300 'content' => "
301 <h5>" . __( "Change order", 'cpac' ) . "</h5>
302 <p>" . __( "By dragging the columns you can change the order which they will appear in.", 'cpac' ) . "</p>
303 <h5>" . __( "Change label", 'cpac' ) . "</h5>
304 <p>" . __( "By clicking on the triangle you will see the column options. Here you can change each label of the columns heading.", 'cpac' ) . "</p>
305 <h5>" . __( "Change column width", 'cpac' ) . "</h5>
306 <p>" . __( "By clicking on the triangle you will see the column options. By using the draggable slider you can set the width of the columns in percentages.", 'cpac' ) . "</p>
307 "
308 ),
309 array(
310 'title' => __( "Custom Field", 'cpac' ),
311 'content' =>
312 "<h5>". __( "'Custom Field' column", 'cpac' ) . "</h5>
313 <p>". __( "The custom field colum uses the custom fields from posts and users. There are 10 types which you can set.", 'cpac' ) . "</p>
314 <ul>
315 <li><strong>". __( "Default", 'cpac' ) . "</strong><br/>". __( "Value: Can be either a string or array. Arrays will be flattened and values are seperated by a ',' comma.", 'cpac' ) . "</li>
316 <li><strong>". __( "Image", 'cpac' ) . "</strong><br/>". __( "Value: should contain an image URL or Attachment IDs ( seperated by a ',' comma ).", 'cpac' ) . "</li>
317 <li><strong>". __( "Excerpt", 'cpac' ) . "</strong><br/>". __( "Value: This will show the first 20 words of the Post content.", 'cpac' ) . "</li>
318 <li><strong>". __( "Multiple Values", 'cpac' ) . "</strong><br/>". __( "Value: should be an array. This will flatten any ( multi dimensional ) array.", 'cpac' ) . "</li>
319 <li><strong>". __( "Numeric", 'cpac' ) . "</strong><br/>". __( "Value: Integers only.<br/>If you have the 'sorting addon' this will be used for sorting, so you can sort your posts on numeric (custom field) values.", 'cpac' ) . "</li>
320 <li><strong>". __( "Date", 'cpac' ) . "</strong><br/>". sprintf( __( "Value: Can be unix time stamp or a date format as described in the <a href='%s'>Codex</a>. You can change the outputted date format at the <a href='%s'>general settings</a> page.", 'cpac' ), 'http://codex.wordpress.org/Formatting_Date_and_Time', get_admin_url() . 'options-general.php' ) . "</li>
321 <li><strong>". __( "Post Titles", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more Post ID's (seperated by ',').", 'cpac' ) . "</li>
322 <li><strong>". __( "Usernames", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more User ID's (seperated by ',').", 'cpac' ) . "</li>
323 <li><strong>". __( "Checkmark", 'cpac' ) . "</strong><br/>". __( "Value: should be a 1 (one) or 0 (zero).", 'cpac' ) . "</li>
324 <li><strong>". __( "Color", 'cpac' ) . "</strong><br/>". __( "Value: hex value color, such as #808080.", 'cpac' ) . "</li>
325 <li><strong>". __( "Counter", 'cpac' ) . "</strong><br/>". __( "Value: Can be either a string or array. This will display a count of the number of times the meta key is used by the item.", 'cpac' ) . "</li>
326 </ul>
327 "
328 )
329 );
330
331 foreach ( $tabs as $k => $tab ) {
332 $screen->add_help_tab( array(
333 'id' => 'cpac-tab-'.$k,
334 'title' => $tab['title'],
335 'content' => $tab['content'],
336 ));
337 }
338 }
339
340 /**
341 * @since 1.0
342 * @param string $storage_model URL type.
343 * @return string Url.
344 */
345 public function get_url( $type ) {
346
347 $site_url = 'http://www.admincolumns.com';
348
349 $urls = array(
350 'main' => $site_url,
351 'pricing' => $site_url . '/pricing-purchase/',
352 'codepress' => 'http://www.codepresshq.com',
353 'admincolumns' => $site_url,
354 'admincolumnspro' => $site_url,
355 'documentation' => $site_url . '/documentation/',
356 'feedback' => 'http://www.codepresshq.com/contact',
357 'plugins' => 'http://wordpress.org/extend/plugins/codepress-admin-columns/',
358 'support' => 'http://wordpress.org/tags/codepress-admin-columns/',
359 );
360
361 if ( ! isset( $urls[ $type ] ) )
362 return false;
363
364 return $urls[ $type ];
365 }
366
367 /**
368 * @since 2.0
369 */
370 public function uses_custom_fields() {
371
372 $old_columns = get_option('cpac_options');
373
374 if ( empty( $old_columns['columns'] ) ) return false;
375
376 foreach ( $old_columns['columns'] as $columns ) {
377 foreach ( $columns as $id => $values ) {
378 if ( strpos( $id, 'column-meta-' ) !== false )
379 return true;
380 }
381 }
382
383 return false;
384 }
385
386 /**
387 * Welcome screen
388 *
389 * @since 2.0
390 */
391 public function welcome_screen() {
392
393 // Should only be set after upgrade
394 $show_welcome = false !== get_transient('cpac_show_welcome');
395
396 // Should only be set manual
397 if ( isset( $_GET['info'] ) ) {
398 $show_welcome = true;
399 }
400
401 if ( ! $show_welcome ) {
402 return false;
403 }
404
405 // Set check that welcome should not be displayed.
406 delete_transient('cpac_show_welcome');
407
408 $tab = !empty( $_GET['info'] ) ? $_GET['info'] : 'whats-new';
409
410 ?>
411
412 <div id="cpac-welcome" class="wrap about-wrap">
413
414 <h1><?php _e( "Welcome to Admin Columns",'cpac'); ?> <?php echo CPAC_VERSION; ?></h1>
415
416 <div class="about-text">
417 <?php _e( "Thank you for updating to the latest version!", 'cpac' ); ?>
418 <?php _e( "Admin Columns is more polished and enjoyable than ever before. We hope you like it.", 'cpac' ); ?>
419 </div>
420
421 <div class="cpac-content-body">
422 <h2 class="nav-tab-wrapper">
423 <a class="cpac-tab-toggle nav-tab <?php if( $tab == 'whats-new' ){ echo 'nav-tab-active'; } ?>" href="<?php echo $this->get_settings_url( 'info' ); ?>whats-new"><?php _e( "What’s New", 'cpac' ); ?></a>
424 <a class="cpac-tab-toggle nav-tab <?php if( $tab == 'changelog' ){ echo 'nav-tab-active'; } ?>" href="<?php echo $this->get_settings_url( 'info' ); ?>changelog"><?php _e( "Changelog", 'cpac' ); ?></a>
425 </h2>
426
427 <?php if ( 'whats-new' === $tab ) : ?>
428
429 <h3><?php _e( "Important", 'cpac' ); ?></h3>
430
431 <h4><?php _e( "Database Changes", 'cpac' ); ?></h4>
432 <p><?php _e("The database has been changed between versions 1 and 2. But we made sure you can still roll back to version 1x without any issues.",'cpac'); ?></p>
433
434 <?php if ( get_option( 'cpac_version', false ) < CPAC_UPGRADE_VERSION ) : ?>
435 <p><?php _e("Make sure you backup your database and then click",'cpac'); ?> <a href="<?php echo $this->get_settings_url( 'upgrade' ); ?>" class="button-primary"><?php _e( "Upgrade Database", 'cpac' );?></a></p>
436 <?php endif; ?>
437
438 <h4><?php _e( "Potential Issues", 'cpac' ); ?></h4>
439 <p><?php _e( "Do to the sizable refactoring the code, surounding Addons and action/filters, your website may not operate correctly. It is important that you read the full", 'cpac' ); ?> <a href="<?php echo $this->get_url('admincolumns'); ?>migrating-from-v1-to-v2" target="_blank"><?php _e( "Migrating from v1 to v2", 'cpac' ); ?></a> <?php _e( "guide to view the full list of changes.", 'cpac' ); ?> <?php printf( __( 'When you have found a bug please <a href="%s">report them to us</a> so we can fix it in the next release.', 'cpac'), 'mailto:info@codepress.nl' ); ?></p>
440
441 <div class="cpac-alert cpac-alert-error">
442 <p><strong><?php _e( "Important!", 'cpac' ); ?></strong> <?php _e( "If you updated the Admin Columns plugin without prior knowledge of such changes, Please roll back to the latest", 'cpac' ); ?> <a href="http://downloads.wordpress.org/plugin/codepress-admin-columns.1.4.9.zip"> <?php _e( "version 1", 'cpac' ); ?></a> <?php _e( "of this plugin.", 'cpac' ); ?></p>
443 </div>
444
445 <?php endif; ?>
446 <?php if ( 'changelog' === $tab ) : ?>
447
448 <h3><?php _e("Changelog for", 'cpac'); ?> <?php echo CPAC_VERSION; ?></h3>
449 <?php
450
451 $items = file_get_contents( CPAC_DIR . 'readme.txt' );
452 $items = explode('= ' . CPAC_VERSION . ' =', $items);
453 $items = end( $items );
454 $items = current( explode("\n\n", $items) );
455 $items = current( explode("= ", $items) );
456 $items = array_filter( array_map('trim', explode("*", $items)) );
457
458 ?>
459 <ul class="cpac-changelog">
460 <?php foreach( $items as $item ) :
461 $item = explode('http', $item);
462 ?>
463 <li><?php echo $item[0]; ?><?php if( isset($item[1]) ): ?><a href="http<?php echo $item[1]; ?>" target="_blank"><?php _e("Learn more", 'cpac'); ?></a><?php endif; ?></li>
464 <?php endforeach; ?>
465 </ul>
466
467 <?php endif; ?>
468 <hr/>
469
470 </div><!--.cpac-content-body-->
471
472 <div class="cpac-content-footer">
473 <a class="button-primary button-large" href="<?php echo $this->get_settings_url( 'general' ); ?>"><?php _e("Start using Admin Columns",'cpac'); ?></a>
474 </div><!--.cpac-content-footer-->
475
476 </div>
477 <?php
478
479 return true;
480 }
481
482 /**
483 * @since 1.0
484 */
485 public function display_settings() {
486 ?>
487 <table class="form-table cpac-form-table settings">
488 <tbody>
489
490 <tr class="general">
491 <th scope="row">
492 <h3><?php _e( 'General Settings', 'cpac' ); ?></h3>
493 <p><?php _e( 'Customize your Admin Columns settings.', 'cpac' ); ?></p>
494 </th>
495 <td class="padding-22">
496 <div class="cpac_general">
497 <form method="post" action="options.php">
498 <?php settings_fields( 'cpac-general-settings' ); ?>
499 <?php $options = get_option( 'cpac_general_options' ); ?>
500 <p>
501 <label for="show_edit_button">
502 <input name="cpac_general_options[show_edit_button]" type="hidden" value="0" >
503 <input name="cpac_general_options[show_edit_button]" id="show_edit_button" type="checkbox" value="1" <?php checked( ! isset( $options['show_edit_button'] ) || ( '1' == $options['show_edit_button'] ) ); ?>>
504 <?php _e( 'Show "Edit Columns" button on admin screens. Default is <code>on</code>.', 'cpac' ); ?>
505 </label>
506 </p>
507
508 <?php do_action( 'cac/settings/general', $options ); ?>
509
510 <p>
511 <input type="submit" class="button" value="<?php _e( 'Save' ); ?>" />
512 </p>
513 </form>
514 </div>
515 </td>
516 </tr><!--.general-->
517
518 <?php
519
520 /** Allow plugins to add their own custom settings to the settings page. */
521 if ( $groups = apply_filters( 'cac/settings/groups', array() ) ) {
522
523 foreach ( $groups as $id => $group ) {
524
525 $title = isset( $group['title'] ) ? $group['title'] : '';
526 $description = isset( $group['description'] ) ? $group['description'] : '';
527
528 ?>
529 <tr>
530 <th scope="row">
531 <h3><?php echo $title; ?></h3>
532 <p><?php echo $description; ?></p>
533 </th>
534 <td class="padding-22">
535 <?php
536
537 /** Use this Hook to add additonal fields to the group */
538 do_action( "cac/settings/groups/row={$id}" );
539
540 ?>
541 </td>
542 </tr>
543 <?php
544 }
545 }
546
547 ?>
548
549 <tr class="restore">
550 <th scope="row">
551 <h3><?php _e( 'Restore Settings', 'cpac' ); ?></h3>
552 <p><?php _e( 'This will delete all column settings and restore the default settings.', 'cpac' ); ?></p>
553 </th>
554 <td class="padding-22">
555 <form method="post" action="">
556 <?php wp_nonce_field( 'restore-all','_cpac_nonce'); ?>
557 <input type="hidden" name="cpac_action" value="restore_all" />
558 <input type="submit" class="button" name="cpac-restore-defaults" value="<?php _e( 'Restore default settings', 'cpac' ) ?>" onclick="return confirm('<?php _e("Warning! ALL saved admin columns data will be deleted. This cannot be undone. \'OK\' to delete, \'Cancel\' to stop", 'cpac' ); ?>');" />
559 </form>
560 </td>
561 </tr><!--.restore-->
562
563 </tbody>
564 </table>
565
566 <?php
567 }
568
569 /**
570 * @since 2.4.1
571 */
572 private function get_menu_types() {
573 $menu_types = array(
574 'post' => __( 'Posttypes', 'cpac' ),
575 'other' => __( 'Others', 'cpac' ),
576 'taxonomy' => __( 'Taxonomies', 'cpac' ),
577 );
578 return apply_filters( 'cac/menu_types', $menu_types );
579 }
580
581 /**
582 * @since 1.0
583 */
584 public function display() {
585
586 if ( $this->welcome_screen() ) {
587 return;
588 }
589
590 $tabs = array(
591 'general' => __( 'Admin Columns', 'cpac' ),
592 'settings' => __( 'Settings', 'cpac' ),
593 'addons' => __( 'Add-ons', 'cpac' )
594 );
595
596 /**
597 * Filter the tabs on the settings screen
598 *
599 * @param array $tabs Available tabs
600 */
601 $tabs = apply_filters( 'cac/settings/tabs', $tabs );
602
603 $current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : sanitize_text_field( urldecode( $_GET['tab'] ) );
604 ?>
605 <div id="cpac" class="wrap">
606 <?php screen_icon( 'codepress-admin-columns' ); ?>
607 <h2 class="nav-tab-wrapper cpac-nav-tab-wrapper">
608 <?php foreach( $tabs as $name => $label ) : ?>
609 <a href="<?php echo $this->get_settings_url( 'admin' ) . "&amp;tab={$name}"; ?>" class="nav-tab<?php if( $current_tab == $name ) echo ' nav-tab-active'; ?>"><?php echo $label; ?></a>
610 <?php endforeach; ?>
611 </h2>
612
613 <?php do_action( 'cpac_messages' ); ?>
614
615 <?php
616 switch ( $current_tab ) :
617 case 'general':
618
619 $post_types = array_values( $this->cpac->get_post_types() );
620 $first = array_shift( $post_types );
621
622 $storage_models_by_type = array();
623 foreach ( $this->cpac->storage_models as $k => $storage_model ) {
624 $storage_models_by_type[ $storage_model->menu_type ][ $k ] = $storage_model;
625 }
626
627 ?>
628 <div class="cpac-menu">
629 <?php
630 foreach ( $this->get_menu_types() as $menu_type => $label ) {
631 if ( ! empty( $storage_models_by_type[ $menu_type ] ) ) {
632 $count = 0; ?>
633 <ul class="subsubsub">
634 <li class="first"><?php echo $label; ?>: </li>
635 <?php foreach ( $storage_models_by_type[ $menu_type ] as $storage_model ) : ?>
636 <li><?php echo $count++ != 0 ? ' | ' : ''; ?><a href="#cpac-box-<?php echo $storage_model->key; ?>" <?php echo $storage_model->is_menu_type_current( $first ) ? ' class="current"' : '';?> ><?php echo $storage_model->label; ?></a></li>
637 <?php endforeach; ?>
638 </ul>
639 <?php
640 }
641 }
642 ?>
643 </div>
644
645 <?php do_action( 'cac/settings/after_menu' ); ?>
646
647 <?php $count = 0; ?>
648 <?php foreach ( $this->cpac->storage_models as $storage_model ) : ?>
649 <div class="columns-container" data-type="<?php echo $storage_model->key ?>"<?php echo $storage_model->is_menu_type_current( $first ) ? '' : ' style="display:none"'; ?>>
650
651 <div class="columns-left">
652 <div id="titlediv">
653 <h2>
654 <?php echo $storage_model->label; ?>
655 <?php $storage_model->screen_link(); ?>
656 </h2>
657 </div>
658
659 <?php if ( $storage_model->is_using_php_export() ) : ?>
660 <div class="error below-h2">
661 <p><?php printf( __( 'The columns for %s are set up via PHP and can therefore not be edited in the admin panel.', 'cpac' ), '<strong>' . $storage_model->label . '</strong>' ); ?></p>
662 </div>
663 <?php endif; ?>
664 </div>
665
666 <div class="columns-right">
667 <div class="columns-right-inside">
668 <?php if ( ! $storage_model->is_using_php_export() ) : ?>
669 <div class="sidebox" id="form-actions">
670 <h3>
671 <?php _e( 'Store settings', 'cpac' ) ?>
672 </h3>
673 <?php $has_been_stored = $storage_model->get_stored_columns() ? true : false; ?>
674 <div class="form-update">
675 <a href="javascript:;" class="button-primary submit-update"><?php echo $has_been_stored ? __( 'Update' ) : __('Save'); ?> <?php echo $storage_model->label; ?></a>
676 </div>
677 <?php if ( $has_been_stored ) : ?>
678 <div class="form-reset">
679 <a href="<?php echo add_query_arg( array( '_cpac_nonce' => wp_create_nonce('restore-type'), 'cpac_key' => $storage_model->key, 'cpac_action' => 'restore_by_type' ), $this->get_settings_url( 'admin' ) ); ?>" class="reset-column-type" onclick="return confirm('<?php printf( __( "Warning! The %s columns data will be deleted. This cannot be undone. \'OK\' to delete, \'Cancel\' to stop", 'cpac' ), $storage_model->label ); ?>');">
680 <?php _e( 'Restore', 'cpac' ); ?> <?php echo $storage_model->label; ?> <?php _e( 'columns', 'cpac' ); ?>
681 </a>
682 </div>
683 <?php endif; ?>
684
685 <?php do_action( 'cac/settings/form_actions', $storage_model ); ?>
686
687 </div><!--form-actions-->
688 <?php endif; ?>
689
690 <?php if ( ! class_exists( 'CAC_Addon_Pro' ) ) : ?>
691 <?php $url_args = array(
692 'utm_source' => 'plugin-installation',
693 'utm_medium' => 'banner',
694 'utm_campaign' => 'plugin-installation'
695 ); ?>
696 <div class="sidebox" id="pro-version">
697 <div class="padding-box cta">
698 <h3>
699 <a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'title' ) ), $this->get_url( 'admincolumnspro' ) ); ?>"><?php _e( 'Get Admin Columns Pro', 'cpac' ) ?></a>
700 </h3>
701 <div class="inside">
702 <ul>
703 <li><a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-sorting' ) ), $this->get_url( 'admincolumnspro' ) ) ?>"><?php _e( 'Add Sorting', 'cpac' ); ?></a></li>
704 <li><a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-filtering' ) ), $this->get_url( 'admincolumnspro' ) ) ?>"><?php _e( 'Add Filtering', 'cpac' ); ?></a></li>
705 <li><a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-import-export' ) ), $this->get_url( 'admincolumnspro' ) ) ?>"><?php _e( 'Add Import/Export', 'cpac' ); ?></a></li>
706 <li><a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-editing' ) ), $this->get_url( 'admincolumnspro' ) ) ?>"><?php _e( 'Add Direct Editing', 'cpac' ); ?></a></li>
707 </ul>
708 <p>
709 <?php printf( __( 'Check out <a href="%s">Admin Columns Pro</a> for more details!', 'cpac' ), add_query_arg( array_merge( $url_args, array( 'utm_content' => 'cta' ) ), $this->get_url( 'admincolumnspro' ) ) ); ?>
710 </p>
711 </div>
712 </div>
713 </div>
714
715 <?php
716 // @todo: add newsletter
717 /* ?>
718 <div class="padding-box newsletter">
719 <form action="http://codepress.us4.list-manage.com/subscribe/post?u=902ae7f162ce5bc38a0bc8a4f&amp;id=183e843a76" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank">
720 <?php $user = wp_get_current_user(); ?>
721 <p>
722 <?php _e ( "Subscribe to receive news &amp; updates below.", 'cpac' ); ?>
723 </p>
724 <div class="mc-field-group">
725 <label for="mce-FNAME"><?php _e( 'First Name', 'cpac' ); ?></label>
726 <input type="text" value="<?php echo trim( esc_attr( $user->first_name ) ); ?>" name="FNAME" class="" id="mce-FNAME">
727 </div>
728 <div class="mc-field-group">
729 <label for="mce-EMAIL"><?php _e( 'Your Email', 'cpac' ); ?></label>
730 <input type="email" value="<?php echo trim( esc_attr( $user->user_email ) ); ?>" name="EMAIL" class="required email" id="mce-EMAIL">
731 </div>
732 <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
733 </form>
734 </div>
735 <?php */ ?>
736
737
738 <div class="sidebox" id="direct-feedback">
739 <div id="feedback-choice">
740 <h3><?php _e( 'Are you happy with Admin Columns?', 'cpac' ); ?></h3>
741 <div class="inside">
742 <a href="#" class="yes">Yes</a>
743 <a href="#" class="no">No</a>
744 </div>
745 </div>
746 <div id="feedback-support">
747 <div class="inside">
748 <p><?php _e( "What's wrong? Need help? Let us know!", 'cpac' ); ?></p>
749 <p><?php _e( 'Check out our extensive documentation, or you can open a support topic on WordPress.org!', 'cpac' ); ?></p>
750 <ul class="share">
751 <li>
752 <a href="<?php echo add_query_arg( array(
753 'utm_source' => 'plugin-installation',
754 'utm_medium' => 'feedback-docs-button',
755 'utm_campaign' => 'plugin-installation'
756 ), $this->get_url( 'documentation' ) ); ?>" target="_blank">
757 <div class="dashicons dashicons-editor-help"></div> <?php _e( 'Docs', 'cpac' ); ?>
758 </a>
759 </li>
760 <li>
761 <a href="https://wordpress.org/support/plugin/codepress-admin-columns" target="_blank">
762 <div class="dashicons dashicons-wordpress"></div> <?php _e( 'Forums', 'cpac' ); ?>
763 </a>
764 </li>
765 </ul>
766 <div class="clear"></div>
767 </div>
768 </div>
769 <div id="feedback-rate">
770 <div class="inside">
771 <p><?php _e( "Woohoo! We're glad to hear that!", 'cpac' ); ?></p>
772 <p><?php _e( 'We would really love it if you could show your appreciation by giving us a rating on WordPress.org or tweet about Admin Columns!', 'cpac' ); ?></p>
773 <ul class="share">
774 <li>
775 <a href="http://wordpress.org/support/view/plugin-reviews/codepress-admin-columns#postform" target="_blank">
776 <div class="dashicons dashicons-star-empty"></div> <?php _e( 'Rate', 'cpac' ); ?>
777 </a>
778 </li>
779
780 <li>
781 <a href="<?php echo add_query_arg( array(
782 'hashtags' => 'wordpress',
783 'text' => urlencode( "I'm using Admin Columns for WordPress!" ),
784 'url' => urlencode( 'http://wordpress.org/plugins/codepress-admin-columns/' ),
785 'via' => 'wpcolumns'
786 ), 'https://twitter.com/intent/tweet' ); ?>" target="_blank">
787 <div class="dashicons dashicons-twitter"></div> <?php _e( 'Tweet', 'cpac' ); ?>
788 </a>
789 </li>
790
791 <li>
792 <a href="<?php echo add_query_arg( array(
793 'utm_source' => 'plugin-installation',
794 'utm_medium' => 'feedback-purchase-button',
795 'utm_campaign' => 'plugin-installation'
796 ), $this->get_url( 'admincolumnspro' ) ); ?>" target="_blank">
797 <div class="dashicons dashicons-cart"></div> <?php _e( 'Buy Pro', 'cpac' ); ?>
798 </a>
799 </li>
800 </ul>
801 <div class="clear"></div>
802 </div>
803 </div>
804 </div>
805
806 <?php endif; ?>
807
808 <div class="sidebox" id="plugin-support">
809 <h3><?php _e( 'Support', 'cpac' ); ?></h3>
810 <div class="inside">
811 <?php if ( version_compare( get_bloginfo( 'version' ), '3.2', '>' ) ) : ?>
812 <p><?php _e( 'Check the <strong>Help</strong> section in the top-right screen.', 'cpac' ); ?></p>
813 <?php endif; ?>
814 <p>
815 <?php printf( __("For full documentation, bug reports, feature suggestions and other tips <a href='%s'>visit the Admin Columns website</a>", 'cpac' ), $this->get_url('documentation') ); ?>
816 </p>
817 </div>
818 </div><!--plugin-support-->
819
820 </div><!--.columns-right-inside-->
821 </div><!--.columns-right-->
822
823 <div class="columns-left">
824 <div class="cpac-boxes">
825 <?php if ( ! $storage_model->is_using_php_export() ) : ?>
826 <div class="cpac-columns">
827
828 <form method="post" action="">
829 <?php wp_nonce_field( 'update-type', '_cpac_nonce'); ?>
830
831 <input type="hidden" name="cpac_key" value="<?php echo $storage_model->key; ?>" />
832 <input type="hidden" name="cpac_action" value="update_by_type" />
833
834 <?php
835 foreach ( $storage_model->columns as $column ) {
836 $column->display();
837 }
838 ?>
839 </form>
840
841 </div><!--.cpac-columns-->
842
843 <div class="column-footer">
844 <div class="order-message"><?php _e( 'Drag and drop to reorder', 'cpac' ); ?></div>
845
846 <div class="button-container">
847 <a href="javascript:;" class="add_column button button-primary">+ <?php _e( 'Add Column', 'cpac' );?></a><br/>
848 </div>
849
850 </div><!--.cpac-column-footer-->
851 <?php endif; ?>
852 </div><!--.cpac-boxes-->
853 </div><!--.columns-left-->
854 <div class="clear"></div>
855
856 <div class="for-cloning-only" style="display:none">
857 <?php
858 foreach ( $storage_model->get_registered_columns() as $column ) {
859 $column->display();
860 }
861 ?>
862 </div>
863 </div><!--.columns-container-->
864 <?php endforeach; // storage_models ?>
865
866 <div class="clear"></div>
867 <?php
868 break; // case: general
869 case 'settings' :
870 $this->display_settings();
871 break;
872 case 'addons' :
873 $this->tab_addons();
874 break;
875 case 'help' :
876 //$this->tab_addons();
877 break;
878 default:
879
880 /**
881 * Action to add tab contents
882 *
883 */
884 do_action( 'cac/settings/tab_contents/tab=' . $current_tab );
885
886 endswitch;
887 ?>
888 </div><!--.wrap-->
889 <?php
890 }
891
892 /**
893 * @since 2.2
894 */
895 public function tab_addons() {
896
897 $addon_groups = $this->cpac->addons()->get_addon_groups();
898 $grouped_addons = $this->cpac->addons()->get_available_addons( true );
899 ?>
900 <?php foreach ( $grouped_addons as $group_name => $addons ) : ?>
901 <h3><?php echo $addon_groups[ $group_name ]; ?></h3>
902
903 <ul class="cpac-addons">
904 <?php foreach ( $addons as $addon_name => $addon ) : ?>
905 <li>
906 <div class="cpac-addon-content">
907 <?php if ( ! empty( $addon['image'] ) ) : ?>
908 <img src="<?php echo $addon['image']; ?>" />
909 <?php else : ?>
910 <h3><?php echo $addon['title']; ?></h3>
911 <?php endif; ?>
912 </div>
913 <div class="cpac-addon-header">
914 <h3><?php echo $addon['title']; ?></h3>
915 <p><?php echo $addon['description']; ?></p>
916 </div>
917 <div class="cpac-addon-actions">
918 <?php
919
920 // Installed..
921 if ( ( $plugin_basename = $this->cpac->addons()->get_installed_addon_plugin_basename( $addon_name ) ) ) : ?>
922 <?php if ( is_plugin_active( $plugin_basename ) ) : ?>
923 <?php $deactivation_url = wp_nonce_url( add_query_arg( array(
924 'action' => 'deactivate',
925 'plugin' => urlencode( $plugin_basename ),
926 'cpac-redirect' => true
927 ), admin_url( 'plugins.php' ) ), 'deactivate-plugin_' . $plugin_basename ); ?>
928 <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Active', 'cpac' ); ?></a>
929 <a href="<?php echo esc_attr( $deactivation_url ); ?>" class="button right"><?php _e( 'Deactivate', 'cpac' ); ?></a>
930 <?php else : ?>
931 <?php $activation_url = wp_nonce_url( add_query_arg( array(
932 'action' => 'activate',
933 'plugin' => urlencode( $plugin_basename ),
934 'cpac-redirect' => true
935 ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_basename ); ?>
936 <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Installed', 'cpac' ); ?></a>
937 <a href="<?php echo esc_attr( $activation_url ); ?>" class="button right"><?php _e( 'Activate', 'cpac' ); ?></a>
938 <?php endif; ?>
939 <?php
940
941 // Not installed...
942 else :
943
944 // Got ACP?
945 if ( class_exists('CAC_Addon_Pro') ) :
946 $install_url = wp_nonce_url( add_query_arg( array(
947 'action' => 'install',
948 'plugin' => $addon_name,
949 ), $this->get_settings_url( 'addons' ) ), 'install-cac-addon' );
950 ?>
951 <a href="<?php echo esc_attr( $install_url ); ?>" class="button"><?php _e( 'Download & Install', 'cpac' ); ?></a>
952 <?php
953
954 // Get ACP?
955 else : ?>
956 <a target="_blank" href="<?php echo esc_attr( $this->get_url('pricing') ); ?>" class="button"><?php _e( 'Get this add-on', 'cpac' ); ?></a>
957 <?php endif; ?>
958 <?php endif; ?>
959 </div>
960 </li>
961 <?php endforeach; // addons ?>
962 </ul>
963 <?php endforeach; // grouped_addons ?>
964 <?php
965 }
966 }