PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 2.2.3
Admin Columns v2.2.3
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 12 years ago storage_model 12 years ago addons.php 12 years ago column.php 12 years ago settings.php 12 years ago storage_model.php 12 years ago third_party.php 12 years ago upgrade.php 12 years ago utility.php 12 years ago
settings.php
896 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 * @since 2.0
19 * @param object CPAC
20 */
21 function __construct( $cpac ) {
22
23 $this->cpac = $cpac;
24
25 // register settings
26 add_action( 'admin_menu', array( $this, 'settings_menu' ) );
27
28 // handle requests gets a low priority so it will trigger when all other plugins have loaded their columns
29 add_action( 'admin_init', array( $this, 'handle_column_request' ), 1000 );
30
31 add_action( 'wp_ajax_cpac_column_refresh', array( $this, 'ajax_column_refresh' ) );
32
33 add_action( 'cpac_messages', array( $this, 'maybe_display_addon_statuschange_message' ) );
34 }
35
36 /**
37 * Get available Admin Columns admin page URLs
38 *
39 * @since 2.2
40 * @return array Available settings URLs ([settings_page] => [url])
41 */
42 public function get_settings_urls() {
43
44 /**
45 * Filter the URLs for the different settings screens available in admin columns
46 *
47 * @since 2.2
48 *
49 * @param array $settings_urls Available settings URLs ([settings_page] => [url])
50 * @param CPAC_Settings $settings_instance Settings class instance
51 */
52 $settings_urls = apply_filters( 'cac/settings/settings_urls', array(
53 'admin' => admin_url( 'options-general.php?page=codepress-admin-columns' ),
54 'info' => admin_url( 'options-general.php?page=codepress-admin-columns&info=' ),
55 'upgrade' => admin_url( 'options-general.php?page=cpac-upgrade' )
56 ), $this );
57
58 return $settings_urls;
59 }
60
61 /**
62 * Get the settings URL for a page
63 *
64 * @since 2.2
65 * @param string $page Optional. Admin page to get the URL from. Defaults to the basic Admin Columns page
66 * @return string Settings page URL
67 */
68 public function get_settings_url( $page = '' ) {
69
70 $settings_urls = $this->get_settings_urls();
71
72 if ( isset( $settings_urls[ $page ] ) ) {
73 return $settings_urls[ $page ];
74 }
75
76 if ( ! $page ) {
77 return $settings_urls['admin'];;
78 }
79
80 return add_query_arg( 'tab', $page, $this->get_settings_url() );
81 }
82
83 /**
84 * Display an activation/deactivation message on the addons page if applicable
85 *
86 * @since 2.2
87 */
88 public function maybe_display_addon_statuschange_message() {
89
90 if ( empty( $_REQUEST['tab'] ) || $_REQUEST['tab'] != 'addons' ) {
91 return;
92 }
93
94 $message = '';
95
96 if ( ! empty( $_REQUEST['activate'] ) ) {
97 $message = __( 'Add-on successfully activated.', 'cpac' );
98 }
99 else if ( ! empty( $_REQUEST['deactivate'] ) ) {
100 $message = __( 'Add-on successfully deactivated.', 'cpac' );
101 }
102
103 if ( ! $message ) {
104 return;
105 }
106 ?>
107 <div class="updated cac-notification below-h2">
108 <p><?php echo $message; ?></p>
109 </div>
110 <?php
111 }
112
113 /**
114 * @since 2.2
115 */
116 public function ajax_column_refresh() {
117 if ( ! empty( $_POST['formdata'] ) && ! empty( $_POST['column'] ) ) {
118 parse_str( $_POST['formdata'], $formdata );
119 $storagemodel_key = ! empty( $formdata['cpac_key'] ) ? $formdata['cpac_key'] : '';
120
121 if ( $storagemodel_key && ! empty( $formdata[ $storagemodel_key ][ $_POST['column'] ] ) ) {
122 $columndata = $formdata[ $formdata['cpac_key'] ][ $_POST['column'] ];
123 $storage_model = $this->cpac->get_storage_model( $formdata['cpac_key'] );
124 $registered_columns = $storage_model->get_registered_columns();
125
126 if ( in_array( $columndata['type'], array_keys( $registered_columns ) ) ) {
127 $column = clone $registered_columns[ $columndata['type'] ];
128 $column->set_clone( $columndata['clone'] );
129
130 foreach ( $columndata as $optionname => $optionvalue ) {
131 $column->set_options( $optionname, $optionvalue );
132 }
133
134 $column->sanitize_label();
135
136 $columns = array( $column->properties->name => $column );
137
138 do_action( 'cac/columns', $columns );
139 do_action( "cac/columns/storage_key={$storagemodel_key}", $columns );
140
141 $column->display();
142 }
143 }
144 }
145
146 exit;
147 }
148
149 /**
150 * @since 1.0
151 */
152 public function settings_menu() {
153
154 // add settings page
155 $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 );
156
157 // add help tabs
158 add_action( "load-{$settings_page}", array( $this, 'help_tabs' ) );
159
160 // add scripts & styles
161 add_action( "admin_print_styles-{$settings_page}", array( $this, 'admin_styles' ) );
162 add_action( "admin_print_scripts-{$settings_page}", array( $this, 'admin_scripts' ) );
163
164 // register setting
165 register_setting( 'cpac-general-settings', 'cpac_general_options' );
166
167 // add cap to options.php
168 add_filter( 'option_page_capability_cpac-general-settings', array( $this, 'add_capability' ) );
169 }
170
171 /**
172 * Allows the capaiblity 'manage_admin_columns' to store data through /wp-admin/options.php
173 *
174 * @since 2.0
175 */
176 public function add_capability() {
177 return 'manage_admin_columns';
178 }
179
180 /**
181 * @since 1.0
182 */
183 public function admin_styles() {
184 wp_enqueue_style( 'wp-pointer' );
185 wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL . 'assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' );
186 wp_enqueue_style( 'cpac-admin', CPAC_URL . 'assets/css/admin-column.css', array(), CPAC_VERSION, 'all' );
187 }
188
189 /**
190 * @since 1.0
191 */
192 public function admin_scripts() {
193
194 wp_enqueue_script( 'wp-pointer' );
195 wp_enqueue_script( 'jquery-ui-slider' );
196
197 $minified = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
198
199 wp_enqueue_script( 'cpac-admin-columns', CPAC_URL . "assets/js/admin-columns{$minified}.js", array( 'jquery', 'dashboard', 'jquery-ui-slider', 'jquery-ui-sortable' ), CPAC_VERSION );
200
201 // javascript translations
202 wp_localize_script( 'cpac-admin-columns', 'cpac_i18n', array(
203 'clone' => __( '%s column is already present and can not be duplicated.', 'cpac' ),
204 ));
205 }
206
207 /**
208 * @since 1.0
209 */
210 public function handle_column_request() {
211
212 // only handle updates from the admin columns page
213 if ( ! ( isset($_GET['page'] ) && in_array( $_GET['page'], array( 'codepress-admin-columns' ) ) && isset( $_REQUEST['cpac_action'] ) ) )
214 return false;
215
216 // use $_REQUEST because the values are send both over $_GET and $_POST
217 $action = isset( $_REQUEST['cpac_action'] ) ? $_REQUEST['cpac_action'] : '';
218 $nonce = isset( $_REQUEST['_cpac_nonce'] ) ? $_REQUEST['_cpac_nonce'] : '';
219 $key = isset( $_REQUEST['cpac_key'] ) ? $_REQUEST['cpac_key'] : '';
220
221 switch ( $action ) :
222
223 case 'update_by_type' :
224 if ( wp_verify_nonce( $nonce, 'update-type' ) ) {
225 $storage_model = $this->cpac->get_storage_model( $key );
226 $storage_model->store();
227 }
228 break;
229
230 case 'restore_by_type' :
231 if ( wp_verify_nonce( $nonce, 'restore-type' ) ) {
232 $storage_model = $this->cpac->get_storage_model( $key );
233 $storage_model->restore();
234 }
235 break;
236
237 case 'restore_all' :
238 if ( wp_verify_nonce( $nonce, 'restore-all' ) ) {
239 $this->restore_all();
240 }
241 break;
242
243 endswitch;
244 }
245
246 /**
247 * Restore all column defaults
248 *
249 * @since 1.0
250 */
251 private function restore_all() {
252 global $wpdb;
253
254 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'cpac_options_%'" );
255
256 cpac_admin_message( __( 'Default settings succesfully restored.', 'cpac' ), 'updated' );
257 }
258
259 /**
260 * Add help tabs to top menu
261 *
262 * @since 1.3.0
263 */
264 public function help_tabs() {
265
266 $screen = get_current_screen();
267
268 if ( ! method_exists( $screen,'add_help_tab' ) )
269 return;
270
271 $tabs = array(
272 array(
273 'title' => __( "Overview", 'cpac' ),
274 'content' =>
275 "<h5>Codepress Admin Columns</h5>
276 <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>"
277 ),
278 array(
279 'title' => __( "Basics", 'cpac' ),
280 'content' => "
281 <h5>" . __( "Change order", 'cpac' ) . "</h5>
282 <p>" . __( "By dragging the columns you can change the order which they will appear in.", 'cpac' ) . "</p>
283 <h5>" . __( "Change label", 'cpac' ) . "</h5>
284 <p>" . __( "By clicking on the triangle you will see the column options. Here you can change each label of the columns heading.", 'cpac' ) . "</p>
285 <h5>" . __( "Change column width", 'cpac' ) . "</h5>
286 <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>
287 "
288 ),
289 array(
290 'title' => __( "Custom Field", 'cpac' ),
291 'content' =>
292 "<h5>". __( "'Custom Field' column", 'cpac' ) . "</h5>
293 <p>". __( "The custom field colum uses the custom fields from posts and users. There are 10 types which you can set.", 'cpac' ) . "</p>
294 <ul>
295 <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>
296 <li><strong>". __( "Image", 'cpac' ) . "</strong><br/>". __( "Value: should contain an image URL or Attachment IDs ( seperated by a ',' comma ).", 'cpac' ) . "</li>
297 <li><strong>". __( "Excerpt", 'cpac' ) . "</strong><br/>". __( "Value: This will show the first 20 words of the Post content.", 'cpac' ) . "</li>
298 <li><strong>". __( "Multiple Values", 'cpac' ) . "</strong><br/>". __( "Value: should be an array. This will flatten any ( multi dimensional ) array.", 'cpac' ) . "</li>
299 <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>
300 <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>
301 <li><strong>". __( "Post Titles", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more Post ID's (seperated by ',').", 'cpac' ) . "</li>
302 <li><strong>". __( "Usernames", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more User ID's (seperated by ',').", 'cpac' ) . "</li>
303 <li><strong>". __( "Checkmark", 'cpac' ) . "</strong><br/>". __( "Value: should be a 1 (one) or 0 (zero).", 'cpac' ) . "</li>
304 <li><strong>". __( "Color", 'cpac' ) . "</strong><br/>". __( "Value: hex value color, such as #808080.", 'cpac' ) . "</li>
305 <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>
306 </ul>
307 "
308 )
309 );
310
311 foreach ( $tabs as $k => $tab ) {
312 $screen->add_help_tab( array(
313 'id' => 'cpac-tab-'.$k,
314 'title' => $tab['title'],
315 'content' => $tab['content'],
316 ));
317 }
318 }
319
320 /**
321 * @since 1.0
322 * @param string $storage_model URL type.
323 * @return string Url.
324 */
325 function get_url( $type ) {
326
327 $site_url = 'http://www.admincolumns.com';
328
329 $urls = array(
330 'main' => $site_url,
331 'pricing' => $site_url . '/pricing-purchase/',
332 'codepress' => 'http://www.codepresshq.com',
333 'admincolumns' => $site_url,
334 'admincolumnspro' => $site_url,
335 'documentation' => $site_url . '/documentation/',
336 'feedback' => 'http://www.codepresshq.com/contact',
337 'plugins' => 'http://wordpress.org/extend/plugins/codepress-admin-columns/',
338 'support' => 'http://wordpress.org/tags/codepress-admin-columns/',
339 );
340
341 if ( ! isset( $urls[ $type ] ) )
342 return false;
343
344 return $urls[ $type ];
345 }
346
347 /**
348 * @since 2.0
349 */
350 public function uses_custom_fields() {
351
352 $old_columns = get_option('cpac_options');
353
354 if ( empty( $old_columns['columns'] ) ) return false;
355
356 foreach ( $old_columns['columns'] as $columns ) {
357 foreach ( $columns as $id => $values ) {
358 if ( strpos( $id, 'column-meta-' ) !== false )
359 return true;
360 }
361 }
362
363 return false;
364 }
365
366 /**
367 * Welcome screen
368 *
369 * @since 2.0
370 */
371 public function welcome_screen() {
372
373 // Should only be set after upgrade
374 $show_welcome = false !== get_transient('cpac_show_welcome');
375
376 // Should only be set manual
377 if ( isset( $_GET['info'] ) )
378 $show_welcome = true;
379
380 if ( ! $show_welcome )
381 return false;
382
383 // Set check that welcome should not be displayed.
384 delete_transient('cpac_show_welcome');
385
386 $tab = !empty( $_GET['info'] ) ? $_GET['info'] : 'whats-new';
387
388 // check if old site used custom field columns
389 $uses_customfields = $this->uses_custom_fields();
390 $uses_sortorder = get_option( "cpac_sortable_ac" ) && ! class_exists( 'CAC_Addon_Pro' ) ? true : false;
391
392 $installed_customfields = false;
393 $installed_sortorder = false;
394
395 ?>
396
397 <div id="cpac-welcome" class="wrap about-wrap">
398
399 <h1><?php _e( "Welcome to Admin Columns",'cpac'); ?> <?php echo CPAC_VERSION; ?></h1>
400
401 <div class="about-text">
402 <?php _e( "Thank you for updating to the latest version!", 'cpac' ); ?>
403 <?php _e( "Admin Columns is more polished and enjoyable than ever before. We hope you like it.", 'cpac' ); ?>
404 </div>
405
406 <div class="cpac-content-body">
407 <h2 class="nav-tab-wrapper">
408 <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>
409 <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>
410 </h2>
411
412 <?php if ( 'whats-new' === $tab ) : ?>
413
414 <h3><?php _e( "Addons", 'cpac' ); ?></h3>
415 <p>
416 <?php _e( "Addons are now activated by downloading and installing individual plugins. Although these plugins will not be hosted on the wordpress.org repository, each Add-on will continue to receive updates in the usual way.",'cpac'); ?>
417 </p>
418 <?php if ( $uses_sortorder ) : ?>
419 <h4><?php _e( "This website uses the Sortorder Addon. This addon needs to be downloaded." ,'cpac' ); ?></h4>
420 <div class="cpac-alert cpac-alert-success">
421 <p>
422 <?php _e( "Addons are seperate plugins which need to be downloaded.", 'cpac' ); ?> <a href="<?php echo $this->get_settings_url( 'info' ); ?>download-add-ons" class="button-primary" style="display: inline-block;"><?php _e( "Download your Addons", 'cpac'); ?></a>
423 </p>
424 </div>
425 <?php else : ?>
426 <div class="cpac-alert cpac-alert-success">
427 <p>
428 <strong><?php _e( 'This website does not use add-ons', 'cpac' ); ?></strong>. <a target="_blank" href="<?php echo $this->get_url('admincolumnspro'); ?>"><?php _e( 'See our website for Admin Columns Pro.', 'cpac' ); ?></a>
429 </p>
430 </div>
431 <?php endif; ?>
432
433 <hr />
434
435 <h3><?php _e( "Important", 'cpac' ); ?></h3>
436
437 <h4><?php _e( "Database Changes", 'cpac' ); ?></h4>
438 <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>
439
440 <?php if ( get_option( 'cpac_version', false ) < CPAC_UPGRADE_VERSION ) : ?>
441 <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>
442 <?php endif; ?>
443
444 <h4><?php _e( "Potential Issues", 'cpac' ); ?></h4>
445 <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>
446
447 <div class="cpac-alert cpac-alert-error">
448 <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>
449 </div>
450
451 <?php endif; ?>
452 <?php if ( 'changelog' === $tab ) : ?>
453
454 <h3><?php _e("Changelog for", 'cpac'); ?> <?php echo CPAC_VERSION; ?></h3>
455 <?php
456
457 $items = file_get_contents( CPAC_DIR . 'readme.txt' );
458
459 $items = end( explode('= ' . CPAC_VERSION . ' =', $items) );
460 $items = current( explode("\n\n", $items) );
461 $items = current( explode("= ", $items) );
462 $items = array_filter( array_map('trim', explode("*", $items)) );
463
464 ?>
465 <ul class="cpac-changelog">
466 <?php foreach( $items as $item ) :
467 $item = explode('http', $item);
468 ?>
469 <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>
470 <?php endforeach; ?>
471 </ul>
472
473 <?php endif; ?>
474 <hr/>
475
476 </div><!--.cpac-content-body-->
477
478 <div class="cpac-content-footer">
479 <a class="button-primary button-large" href="<?php echo $this->get_settings_url( 'general' ); ?>"><?php _e("Start using Admin Columns",'cpac'); ?></a>
480 </div><!--.cpac-content-footer-->
481
482 </div>
483 <?php
484
485 return true;
486 }
487
488 /**
489 * @since 2.2
490 */
491 function display_menu_by_type( $menu_type = '', $label = '', $active_item = '' ) {
492
493 $storage_models_by_type = array();
494
495 foreach( $this->cpac->storage_models as $k => $storage_model ) {
496 if ( $menu_type == $storage_model->menu_type ) {
497 $storage_models_by_type[ $menu_type ][ $k ] = $storage_model;
498 }
499 }
500
501 if ( ! empty( $storage_models_by_type[ $menu_type ] ) ) { $count = 0; ?>
502 <ul class="subsubsub">
503 <li class="first"><?php echo $label; ?>: </li>
504 <?php foreach ( $storage_models_by_type[ $menu_type ] as $storage_model ) : ?>
505 <li><?php echo $count++ != 0 ? ' | ' : ''; ?><a href="#cpac-box-<?php echo $storage_model->key; ?>" <?php echo $storage_model->is_menu_type_current( $active_item ) ? ' class="current"' : '';?> ><?php echo $storage_model->label; ?></a></li>
506 <?php endforeach; ?>
507 </ul>
508 <?php
509 }
510 }
511
512 /**
513 * @since 1.0
514 */
515 public function display_settings() {
516 ?>
517 <table class="form-table cpac-form-table">
518 <tbody>
519
520 <tr class="general">
521 <th scope="row">
522 <h3><?php _e( 'General Settings', 'cpac' ); ?></h3>
523 <p><?php _e( 'Customize your Admin Columns settings.', 'cpac' ); ?></p>
524 </th>
525 <td class="padding-22">
526 <div class="cpac_general">
527 <form method="post" action="options.php">
528 <?php settings_fields( 'cpac-general-settings' ); ?>
529 <?php $options = get_option( 'cpac_general_options' ); ?>
530 <p>
531 <br/>
532 </p>
533 <?php
534 /*
535 <p>
536 <label for="show_hidden">
537 <input name="cpac_general_options[show_hidden]" id="show_hidden" type="checkbox" value="1" <?php checked( isset( $options['show_hidden'] ) ? $options['show_hidden'] : '', '1' ); ?>>
538 <?php _e( 'Show hidden custom fields. Default is <code>off</code>.', 'cpac' ); ?>
539 </label>
540 </p>
541 */
542 ?>
543 <p>
544 <label for="show_edit_button">
545 <input name="cpac_general_options[show_edit_button]" id="show_edit_button" type="checkbox" value="1" <?php checked( isset( $options['show_edit_button'] ) ? $options['show_edit_button'] : '', '1' ); ?>>
546 <?php _e( 'Show "Edit Columns" button on admin screens. Default is <code>off</code>.', 'cpac' ); ?>
547 </label>
548 </p>
549
550 <?php do_action( 'cac/settings/general', $options ); ?>
551
552 <p>
553 <input type="submit" class="button" value="<?php _e( 'Save' ); ?>" />
554 </p>
555 </form>
556 </div>
557 </td>
558 </tr><!--.general-->
559
560 <?php
561
562 /** Allow plugins to add their own custom settings to the settings page. */
563 if ( $groups = apply_filters( 'cac/settings/groups', array() ) ) {
564
565 foreach ( $groups as $id => $group ) {
566
567 $title = isset( $group['title'] ) ? $group['title'] : '';
568 $description = isset( $group['description'] ) ? $group['description'] : '';
569
570 ?>
571 <tr>
572 <th scope="row">
573 <h3><?php echo $title; ?></h3>
574 <p><?php echo $description; ?></p>
575 </th>
576 <td class="padding-22">
577 <?php
578
579 /** Use this Hook to add additonal fields to the group */
580 do_action( "cac/settings/groups/row={$id}" );
581
582 ?>
583 </td>
584 </tr>
585 <?php
586 }
587 }
588
589 ?>
590
591 <tr class="restore">
592 <th scope="row">
593 <h3><?php _e( 'Restore Settings', 'cpac' ); ?></h3>
594 <p><?php _e( 'This will delete all column settings and restore the default settings.', 'cpac' ); ?></p>
595 </th>
596 <td class="padding-22">
597 <form method="post" action="">
598 <?php wp_nonce_field( 'restore-all','_cpac_nonce'); ?>
599 <input type="hidden" name="cpac_action" value="restore_all" />
600 <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' ); ?>');" />
601 </form>
602 </td>
603 </tr><!--.restore-->
604
605 </tbody>
606 </table>
607
608 <?php
609 }
610
611 /**
612 * @since 1.0
613 */
614 public function display() {
615
616 if ( $this->welcome_screen() ) return;
617
618 $tabs = array(
619 'general' => __( 'Admin Columns', 'cpac' ),
620 'settings' => __( 'Settings', 'cpac' ),
621 'addons' => __( 'Add-ons', 'cpac' )
622 );
623
624 $tabs = apply_filters( 'cac/settings/tabs', $tabs );
625
626 $current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : sanitize_text_field( urldecode( $_GET['tab'] ) );
627
628 $post_types = array_values( $this->cpac->get_post_types() );
629 $first = array_shift( $post_types );
630 ?>
631
632 <div id="cpac" class="wrap">
633 <?php screen_icon( 'codepress-admin-columns' ); ?>
634 <h2 class="nav-tab-wrapper cpac-nav-tab-wrapper">
635 <?php foreach( $tabs as $name => $label ) : ?>
636 <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>
637 <?php endforeach; ?>
638 </h2>
639
640 <?php do_action( 'cpac_messages' ); ?>
641
642 <?php
643 switch ( $current_tab ) :
644 case 'general':
645 ?>
646 <div class="cpac-menu">
647 <?php $this->display_menu_by_type( 'post', __( 'Posttypes', 'cpac' ), $first ); ?>
648 <?php $this->display_menu_by_type( 'other', __( 'Others', 'cpac' ) ); ?>
649 <?php $this->display_menu_by_type( 'taxonomy', __( 'Taxonomies', 'cpac' ) ); ?>
650 </div>
651
652 <?php do_action( 'cac/settings/after_menu' ); ?>
653
654 <?php $count = 0; ?>
655 <?php foreach ( $this->cpac->storage_models as $storage_model ) : ?>
656 <div class="columns-container" data-type="<?php echo $storage_model->key ?>"<?php echo $storage_model->is_menu_type_current( $first ) ? '' : ' style="display:none"'; ?>>
657
658 <div class="columns-left">
659 <div id="titlediv">
660 <h2>
661 <?php echo $storage_model->label; ?>
662 <?php $storage_model->screen_link(); ?>
663 </h2>
664 </div>
665
666 <?php if ( $storage_model->stored_columns !== NULL ) : ?>
667 <div class="error below-h2">
668 <p><?php printf( __( 'The columns for <strong>%s</strong> are set up via PHP and can therefore not be edited in the admin panel.', 'cpac' ), $storage_model->label ); ?></p>
669 </div>
670 <?php endif; ?>
671 </div>
672
673 <div class="columns-right">
674 <div class="columns-right-inside">
675 <?php if ( $storage_model->stored_columns === NULL ) : ?>
676 <div class="sidebox" id="form-actions">
677 <h3>
678 <?php _e( 'Store settings', 'cpac' ) ?>
679 </h3>
680 <?php $has_been_stored = $storage_model->get_stored_columns() ? true : false; ?>
681 <div class="form-update">
682 <a href="javascript:;" class="button-primary submit-update"><?php echo $has_been_stored ? __( 'Update' ) : __('Save'); ?> <?php echo $storage_model->label; ?></a>
683 </div>
684 <?php if ( $has_been_stored ) : ?>
685 <div class="form-reset">
686 <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 ); ?>');">
687 <?php _e( 'Restore', 'cpac' ); ?> <?php echo $storage_model->label; ?> <?php _e( 'columns', 'cpac' ); ?>
688 </a>
689 </div>
690 <?php endif; ?>
691
692 <?php do_action( 'cac/settings/form_actions', $storage_model ); ?>
693
694 </div><!--form-actions-->
695 <?php endif; ?>
696
697 <?php if ( ! class_exists( 'CAC_Addon_Pro' ) ) : ?>
698 <?php $url_args = array(
699 'utm_source' => 'plugin-installation',
700 'utm_medium' => 'banner',
701 'utm_campaign' => 'plugin-installation'
702 ); ?>
703 <div class="sidebox" id="pro-version">
704 <div class="padding-box cta">
705 <h3>
706 <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>
707 </h3>
708 <div class="inside">
709 <ul>
710 <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>
711 <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>
712 <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>
713 <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>
714 </ul>
715 <p>
716 <?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' ) ) ); ?>
717 </p>
718 </div>
719 </div>
720
721
722 <?php
723 // @todo: add newsletter
724 /* ?>
725 <div class="padding-box newsletter">
726 <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">
727 <?php $user = wp_get_current_user(); ?>
728 <p>
729 <?php _e ( "Subscribe to receive news &amp; updates below.", 'cpac' ); ?>
730 </p>
731 <div class="mc-field-group">
732 <label for="mce-FNAME"><?php _e( 'First Name', 'cpac' ); ?></label>
733 <input type="text" value="<?php echo trim( esc_attr( $user->first_name ) ); ?>" name="FNAME" class="" id="mce-FNAME">
734 </div>
735 <div class="mc-field-group">
736 <label for="mce-EMAIL"><?php _e( 'Your Email', 'cpac' ); ?></label>
737 <input type="email" value="<?php echo trim( esc_attr( $user->user_email ) ); ?>" name="EMAIL" class="required email" id="mce-EMAIL">
738 </div>
739 <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
740 </form>
741 </div>
742 <?php */ ?>
743 </div><!--pro-version-->
744 <?php endif; ?>
745
746 <div class="sidebox" id="plugin-support">
747 <h3><?php _e( 'Support', 'cpac' ); ?></h3>
748 <div class="inside">
749 <?php if ( version_compare( get_bloginfo( 'version' ), '3.2', '>' ) ) : ?>
750 <p><?php _e( 'Check the <strong>Help</strong> section in the top-right screen.', 'cpac' ); ?></p>
751 <?php endif; ?>
752 <p>
753 <?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') ); ?>
754 </p>
755 </div>
756 </div><!--plugin-support-->
757
758 </div><!--.columns-right-inside-->
759 </div><!--.columns-right-->
760
761 <div class="columns-left">
762 <div class="cpac-boxes">
763 <?php if ( $storage_model->stored_columns === NULL ) : ?>
764 <div class="cpac-columns">
765
766 <form method="post" action="">
767 <?php wp_nonce_field( 'update-type', '_cpac_nonce'); ?>
768
769 <input type="hidden" name="cpac_key" value="<?php echo $storage_model->key; ?>" />
770 <input type="hidden" name="cpac_action" value="update_by_type" />
771
772 <?php
773 foreach ( $storage_model->columns as $column ) {
774 $column->display();
775 }
776 ?>
777 </form>
778
779 </div><!--.cpac-columns-->
780
781 <div class="column-footer">
782 <div class="order-message"><?php _e( 'Drag and drop to reorder', 'cpac' ); ?></div>
783
784 <div class="button-container">
785 <a href="javascript:;" class="add_column button button-primary">+ <?php _e( 'Add Column', 'cpac' );?></a><br/>
786 </div>
787
788 </div><!--.cpac-column-footer-->
789 <?php endif; ?>
790 </div><!--.cpac-boxes-->
791 </div><!--.columns-left-->
792 <div class="clear"></div>
793
794 <div class="for-cloning-only" style="display:none">
795 <?php
796 foreach ( $storage_model->get_registered_columns() as $column ) {
797 $column->display();
798 }
799 ?>
800 </div>
801 </div><!--.columns-container-->
802 <?php endforeach; // storage_models ?>
803
804 <div class="clear"></div>
805 <?php
806 break; // case: general
807 case 'settings' :
808 $this->display_settings();
809 break;
810 case 'addons':
811 $this->tab_addons();
812 break;
813 default:
814 echo apply_filters( 'cac/settings/tab_contents/tab=' . $current_tab, apply_filters( 'cac/settings/tab_contents', '', $current_tab ) );
815 break;
816 endswitch;
817 ?>
818 </div><!--.wrap-->
819 <?php
820 }
821
822 /**
823 * @since 2.2
824 */
825 public function tab_addons() {
826
827 $addon_groups = $this->cpac->addons()->get_addon_groups();
828 $grouped_addons = $this->cpac->addons()->get_available_addons( true );
829 ?>
830 <?php foreach ( $grouped_addons as $group_name => $addons ) : ?>
831 <h3><?php echo $addon_groups[ $group_name ]; ?></h3>
832
833 <ul class="cpac-addons">
834 <?php foreach ( $addons as $addon_name => $addon ) : ?>
835 <li>
836 <div class="cpac-addon-content">
837 <?php if ( ! empty( $addon['image'] ) ) : ?>
838 <img src="<?php echo $addon['image']; ?>" />
839 <?php else : ?>
840 <h3><?php echo $addon['title']; ?></h3>
841 <?php endif; ?>
842 </div>
843 <div class="cpac-addon-header">
844 <h3><?php echo $addon['title']; ?></h3>
845 <p><?php echo $addon['description']; ?></p>
846 </div>
847 <div class="cpac-addon-actions">
848 <?php
849
850 // Installed..
851 if ( ( $plugin_basename = $this->cpac->addons()->get_installed_addon_plugin_basename( $addon_name ) ) ) : ?>
852 <?php if ( is_plugin_active( $plugin_basename ) ) : ?>
853 <?php $deactivation_url = wp_nonce_url( add_query_arg( array(
854 'action' => 'deactivate',
855 'plugin' => urlencode( $plugin_basename ),
856 'cpac-redirect' => true
857 ), admin_url( 'plugins.php' ) ), 'deactivate-plugin_' . $plugin_basename ); ?>
858 <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Active', 'cpac' ); ?></a>
859 <a href="<?php echo esc_attr( $deactivation_url ); ?>" class="button right"><?php _e( 'Deactivate', 'cpac' ); ?></a>
860 <?php else : ?>
861 <?php $activation_url = wp_nonce_url( add_query_arg( array(
862 'action' => 'activate',
863 'plugin' => urlencode( $plugin_basename ),
864 'cpac-redirect' => true
865 ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_basename ); ?>
866 <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Installed', 'cpac' ); ?></a>
867 <a href="<?php echo esc_attr( $activation_url ); ?>" class="button right"><?php _e( 'Activate', 'cpac' ); ?></a>
868 <?php endif; ?>
869 <?php
870
871 // Not installed...
872 else :
873
874 // Got ACP?
875 if ( class_exists('CAC_Addon_Pro') ) :
876 $install_url = wp_nonce_url( add_query_arg( array(
877 'action' => 'install',
878 'plugin' => $addon_name,
879 ), $this->get_settings_url( 'addons' ) ), 'install-cac-addon' );
880 ?>
881 <a href="<?php echo esc_attr( $install_url ); ?>" class="button"><?php _e( 'Download & Install', 'cpac' ); ?></a>
882 <?php
883
884 // Get ACP?
885 else : ?>
886 <a target="_blank" href="<?php echo esc_attr( $this->get_url('pricing') ); ?>" class="button"><?php _e( 'Get this add-on', 'cpac' ); ?></a>
887 <?php endif; ?>
888 <?php endif; ?>
889 </div>
890 </li>
891 <?php endforeach; // addons ?>
892 </ul>
893 <?php endforeach; // grouped_addons ?>
894 <?php
895 }
896 }