Changeset 2982731
- Timestamp:
- 10/23/2023 05:52:47 PM (2 years ago)
- Location:
- wp-nested-pages/trunk
- Files:
-
- 14 edited
-
app/Entities/AdminCustomization/AdminCustomizationBase.php (modified) (1 diff)
-
app/Entities/Listing/Listing.php (modified) (4 diffs)
-
app/Entities/Post/PostUpdateRepository.php (modified) (1 diff)
-
app/Entities/PostType/PostTypeCustomFields.php (modified) (4 diffs)
-
app/Entities/PostType/PostTypeRepository.php (modified) (2 diffs)
-
app/Entities/User/UserRepository.php (modified) (1 diff)
-
app/NestedPages.php (modified) (1 diff)
-
app/Views/forms/quickedit-post.php (modified) (2 diffs)
-
app/Views/partials/bulk-edit.php (modified) (2 diffs)
-
app/Views/partials/row-link.php (modified) (1 diff)
-
app/Views/partials/row.php (modified) (1 diff)
-
app/Views/settings/settings-posttypes.php (modified) (1 diff)
-
nestedpages.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-nested-pages/trunk/app/Entities/AdminCustomization/AdminCustomizationBase.php
r2144042 r2982731 42 42 */ 43 43 protected $current_user_role; 44 45 /** 46 * The plugin directory 47 */ 48 protected $plugin_dir; 44 49 45 50 public function __construct() -
wp-nested-pages/trunk/app/Entities/Listing/Listing.php
r2671488 r2982731 127 127 */ 128 128 private $status_preference; 129 130 /** 131 * User can perform bulk actions 132 */ 133 private $can_user_perform_bulk_actions; 129 134 130 135 /** … … 151 156 $this->setStandardFields(); 152 157 $this->setStatusPreference(); 158 $this->setCanUserPerformBulkActions(); 153 159 } 154 160 … … 291 297 292 298 /** 299 * Set if the user can perform bulk actions 300 */ 301 private function setCanUserPerformBulkActions() 302 { 303 $this->can_user_perform_bulk_actions = $this->user->canPerformBulkActions($this->post_type_settings); 304 } 305 306 /** 293 307 * Set the user status preference 294 308 */ … … 327 341 // Primary List 328 342 if ( $count == 0 ) { 329 include( Helpers::view('partials/list-header') ); // List Header 330 include( Helpers::view('partials/bulk-edit') ); // Bulk Edit 343 if ( $this->can_user_perform_bulk_actions ) { 344 include( Helpers::view('partials/list-header') ); // List Header 345 include( Helpers::view('partials/bulk-edit') ); // Bulk Edit 346 } 331 347 echo '<ol class="' . $list_classes . '" id="np-' . $this->post_type->name . '">'; 332 348 return; -
wp-nested-pages/trunk/app/Entities/Post/PostUpdateRepository.php
r2794140 r2982731 315 315 if ( strpos($key, 'np_custom_') !== false) { 316 316 $field_key = str_replace('np_custom_', '', $key); 317 $matches = preg_match('/nptype_(.*)_nptype/', $field_key, $output_array); 318 $field_type = ( $output_array && isset($output_array[1]) ) ? $output_array[1] : null; 319 $value = sanitize_text_field($data[$key]); 320 $field_key = preg_replace('/nptype_(.*)_nptype_/', '', $field_key); 321 if ( $field_type == 'url' ) $value = esc_url($value); 317 322 if ( !current_user_can('edit_post', $data['post_id']) ) continue; 318 323 update_post_meta( 319 324 $data['post_id'], 320 325 $field_key, 321 sanitize_text_field($data[$key])326 $value 322 327 ); 323 328 } -
wp-nested-pages/trunk/app/Entities/PostType/PostTypeCustomFields.php
r2130891 r2982731 3 3 4 4 /** 5 * Enables the filtering of custom fields in the quick edit interface6 * Basic field types currently supported : text|date|select 5 * Enables the filtering of custom fields in the quick edit and bulk edit interfaces 6 * Basic field types currently supported : text|date|select|url 7 7 * 8 8 * Filter should return an array of fields … … 23 23 class PostTypeCustomFields 24 24 { 25 public function outputFields($post_type, $column = 'left') 25 public function outputBulkEditFields($post_type, $column = 'left') 26 { 27 $fields = apply_filters('nestedpages_bulkedit_custom_fields', [], $post_type, $column); 28 if ( empty($fields) ) return; 29 $out = ''; 30 foreach ( $fields as $field ){ 31 $method = $field['type'] . 'Field'; 32 if ( method_exists($this, $method) ) $out .= $this->$method($field); 33 } 34 return $out; 35 } 36 37 public function outputQuickEditFields($post_type, $column = 'left') 26 38 { 27 39 $fields = apply_filters('nestedpages_quickedit_custom_fields', [], $post_type, $column); … … 53 65 } 54 66 67 public function urlField($field) 68 { 69 $out = '<div class="form-control">'; 70 $out .= '<label>' . $field['label'] . '</label>'; 71 $out .= '<input type="text" name="np_custom_nptype_url_nptype_' . $field['key'] . '" value="" data-np-custom-field="' . $field['key'] . '" />'; 72 $out .= '</div>'; 73 return $out; 74 } 75 55 76 public function selectField($field) 56 77 { 57 78 $out = '<div class="form-control">'; 58 79 $out .= '<label>' . $field['label'] . '</label>'; 59 $out .= '<select name="np_custom_ ' . $field['key'] . '" value="" data-np-custom-field="' . $field['key'] . '">';80 $out .= '<select name="np_custom_nptype_select_nptype_' . $field['key'] . '" value="" data-np-custom-field="' . $field['key'] . '">'; 60 81 foreach ( $field['choices'] as $key => $label ){ 61 82 $out .= '<option value="' . $key . '">' . $label . '</option>'; … … 80 101 if ( $custom_value ) : 81 102 $value = $custom_value[0]; 103 if ( $field['type'] == 'url' && $value !== '' ) $value = esc_url($value); 82 104 if ( $field['type'] == 'date' && $field['format_save'] && $value !== '' ) $value = date($field['format_save'], strtotime($value)); 83 105 $out .= ' data-npcustom-' . $field['key'] . '="' . $value . '"'; -
wp-nested-pages/trunk/app/Entities/PostType/PostTypeRepository.php
r2814679 r2982731 84 84 $post_types[$type->name]->sort_options = $this->configuredFields($type->name, 'sort_options'); 85 85 $post_types[$type->name]->custom_statuses = $this->configuredFields($type->name, 'custom_statuses'); 86 $post_types[$type->name]->bulk_edit_roles = $this->configuredFields($type->name, 'bulk_edit_roles'); 86 87 } 87 88 return $post_types; … … 234 235 } 235 236 return $enabled; 237 } 238 239 /** 240 * Does the user role have access to bulk edit 241 * @return boolean 242 */ 243 public function roleCanBulkEdit($post_type, $role) 244 { 245 $option = $this->configuredFields($post_type, 'bulk_edit_roles'); 246 if ( !$option ) return true; 247 if ( is_array($option) && empty($option) ) return true; 248 return ( in_array($role, $option) ) ? true : false; 236 249 } 237 250 -
wp-nested-pages/trunk/app/Entities/User/UserRepository.php
r2655339 r2982731 162 162 163 163 /** 164 * Can the user perform bulk actions? 165 */ 166 public function canPerformBulkActions($post_type_settings) 167 { 168 if ( !isset($post_type_settings->bulk_edit_roles) || !is_array($post_type_settings->bulk_edit_roles) ) return true; 169 $allowed = false; 170 foreach ( $post_type_settings->bulk_edit_roles as $role ){ 171 if ( current_user_can($role) ) $allowed = true; 172 break; 173 } 174 return $allowed; 175 } 176 177 /** 164 178 * Get an array of all users/ids 165 179 * @since 1.3.0 -
wp-nested-pages/trunk/app/NestedPages.php
r2919170 r2982731 13 13 14 14 global $np_version; 15 $np_version = '3.2. 4';15 $np_version = '3.2.5'; 16 16 17 17 if ( is_admin() ) $app = new NestedPages\Bootstrap; -
wp-nested-pages/trunk/app/Views/forms/quickedit-post.php
r2772716 r2982731 124 124 125 125 <?php 126 $custom_fields_left = $this->custom_fields_repo->output Fields($this->post_type, 'left');126 $custom_fields_left = $this->custom_fields_repo->outputQuickEditFields($this->post_type, 'left'); 127 127 if ( $custom_fields_left ) echo $custom_fields_left; 128 128 ?> … … 189 189 190 190 <?php 191 $custom_fields_right = $this->custom_fields_repo->output Fields($this->post_type, 'right');191 $custom_fields_right = $this->custom_fields_repo->outputQuickEditFields($this->post_type, 'right'); 192 192 if ( $custom_fields_right ) echo $custom_fields_right; 193 193 ?> -
wp-nested-pages/trunk/app/Views/partials/bulk-edit.php
r2671488 r2982731 84 84 <?php endif; ?> 85 85 86 <?php 87 $custom_fields_left = $this->custom_fields_repo->outputBulkEditFields($this->post_type, 'left'); 88 if ( $custom_fields_left ) echo $custom_fields_left; 89 ?> 90 86 91 </div><!-- .left --> 87 92 … … 117 122 </div> 118 123 <?php endif; endif; // Edit theme options ?> 124 125 <?php 126 $custom_fields_right = $this->custom_fields_repo->outputBulkEditFields($this->post_type, 'right'); 127 if ( $custom_fields_right ) echo $custom_fields_right; 128 ?> 119 129 120 130 </div><!-- .right --> -
wp-nested-pages/trunk/app/Views/partials/row-link.php
r2812197 r2982731 110 110 echo $out; 111 111 endif; 112 ?>113 112 113 if ( $this->can_user_perform_bulk_actions ) : ?> 114 114 <div class="np-bulk-checkbox"> 115 115 <input type="checkbox" name="nestedpages_bulk[]" value="<?php echo esc_attr($this->post->id); ?>" data-np-bulk-checkbox="<?php echo esc_attr($this->post->title); ?>" class="np-redirect-bulk" data-np-post-type="<?php echo esc_attr($this->post->post_type); ?>" /> 116 116 </div> 117 <?php endif ?> 117 118 </div><!-- .row --> -
wp-nested-pages/trunk/app/Views/partials/row.php
r2812197 r2982731 320 320 echo $out; 321 321 endif; 322 ?> 323 322 323 if ( $this->can_user_perform_bulk_actions ) : ?> 324 324 <div class="np-bulk-checkbox"> 325 325 <input type="checkbox" name="nestedpages_bulk[]" value="<?php echo esc_attr($this->post->id); ?>" data-np-bulk-checkbox="<?php echo esc_attr($this->post->title); ?>" data-np-post-type="<?php echo esc_attr($this->post->post_type); ?>" /> 326 326 </div> 327 <?php endif ?> 327 328 </div><!-- .row --> -
wp-nested-pages/trunk/app/Views/settings/settings-posttypes.php
r2814679 r2982731 360 360 </div><!-- .row --> 361 361 </li> 362 <li> 363 <div class="row"> 364 <div class="description"> 365 <p><strong><?php _e('Bulk Edit Roles', 'wp-nested-pages'); ?></strong><br /> 366 <?php _e('Limit bulk edit capabilities to specific roles. Note: Features within bulk edit will respect role-specific rules. This will remove bulk edit completely from deselected roles.', 'wp-nested-pages'); ?></p> 367 </div> 368 <div class="field"> 369 <div class="nestedpages-sort-options-selection"> 370 <?php foreach ( $this->user_repo->allRoles([]) as $role ) : ?> 371 <label> 372 <input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][bulk_edit_roles][]" value="<?php echo $role['name']; ?>" <?php if ( $this->post_type_repo->roleCanBulkEdit($type->name, $role['name']) ) echo 'checked'; ?> /> 373 <?php echo esc_html($role['label']); ?> 374 </label> 375 <?php endforeach; ?> 376 </div><!-- .nestedpages-sort-options-selection --> 377 </div><!-- .field --> 378 </div><!-- .row --> 379 </li> 362 380 </ul> 363 381 </div><!-- .body --> -
wp-nested-pages/trunk/nestedpages.php
r2919170 r2982731 4 4 Plugin URI: http://nestedpages.com 5 5 Description: Provides an intuitive drag and drop interface for managing pages in the Wordpress admin, while enhancing quick edit. Includes an auto-generated menu to match the nested interface, support for all post types and more. 6 Version: 3.2. 46 Version: 3.2.5 7 7 Author: Kyle Phillips 8 8 Author URI: https://github.com/kylephillips -
wp-nested-pages/trunk/readme.txt
r2919175 r2982731 4 4 Tags: pages, admin, nested, tree view, page tree, sort, quick edit, structure 5 5 Requires at least: 3.8 6 Tested up to: 6. 16 Tested up to: 6.4 7 7 Requires PHP: 5.4 8 8 Stable tag: 3.2.4 … … 105 105 106 106 == Changelog == 107 108 = 3.2.5 = 109 * Adds ability to hide bulk edit functionality on a user-role basis. Thanks to Robert Ehrenleitner from PLUS. 110 * Adds ability to include basic custom fields in bulk edit through the use of a new filter: nestedpages_bulkedit_custom_fields 111 * Various bugs fixed 112 * PHP 8.2 compatibility 113 * WordPress 6.4 compatibility 107 114 108 115 = 3.2.4 =
Note: See TracChangeset
for help on using the changeset viewer.