Plugin Directory

Changeset 2982731


Ignore:
Timestamp:
10/23/2023 05:52:47 PM (2 years ago)
Author:
kylephillips
Message:

Adds v3.2.5 updates

Location:
wp-nested-pages/trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • wp-nested-pages/trunk/app/Entities/AdminCustomization/AdminCustomizationBase.php

    r2144042 r2982731  
    4242    */
    4343    protected $current_user_role;
     44
     45    /**
     46    * The plugin directory
     47    */
     48    protected $plugin_dir;
    4449   
    4550    public function __construct()
  • wp-nested-pages/trunk/app/Entities/Listing/Listing.php

    r2671488 r2982731  
    127127    */
    128128    private $status_preference;
     129
     130    /**
     131     * User can perform bulk actions
     132     */
     133    private $can_user_perform_bulk_actions;
    129134
    130135    /**
     
    151156        $this->setStandardFields();
    152157        $this->setStatusPreference();
     158        $this->setCanUserPerformBulkActions();
    153159    }
    154160
     
    291297
    292298    /**
     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    /**
    293307    * Set the user status preference
    294308    */
     
    327341        // Primary List
    328342        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            }
    331347            echo '<ol class="' . $list_classes . '" id="np-' . $this->post_type->name . '">';
    332348            return;
  • wp-nested-pages/trunk/app/Entities/Post/PostUpdateRepository.php

    r2794140 r2982731  
    315315            if ( strpos($key, 'np_custom_') !== false) {
    316316                $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);
    317322                if ( !current_user_can('edit_post', $data['post_id']) ) continue;
    318323                update_post_meta(
    319324                    $data['post_id'],
    320325                    $field_key,
    321                     sanitize_text_field($data[$key])
     326                    $value
    322327                );
    323328            }
  • wp-nested-pages/trunk/app/Entities/PostType/PostTypeCustomFields.php

    r2130891 r2982731  
    33
    44/**
    5 * Enables the filtering of custom fields in the quick edit interface
    6 * 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
    77*
    88* Filter should return an array of fields
     
    2323class PostTypeCustomFields
    2424{
    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')
    2638    {
    2739        $fields = apply_filters('nestedpages_quickedit_custom_fields', [], $post_type, $column);
     
    5365    }
    5466
     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
    5576    public function selectField($field)
    5677    {
    5778        $out = '<div class="form-control">';
    5879        $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'] . '">';
    6081        foreach ( $field['choices'] as $key => $label ){
    6182            $out .= '<option value="' . $key . '">' . $label . '</option>';
     
    80101            if ( $custom_value ) :
    81102                $value = $custom_value[0];
     103                if ( $field['type'] == 'url' && $value !== '' ) $value = esc_url($value);
    82104                if ( $field['type'] == 'date' && $field['format_save'] && $value !== '' ) $value = date($field['format_save'], strtotime($value));
    83105                $out .= ' data-npcustom-' . $field['key'] . '="' . $value . '"';
  • wp-nested-pages/trunk/app/Entities/PostType/PostTypeRepository.php

    r2814679 r2982731  
    8484            $post_types[$type->name]->sort_options = $this->configuredFields($type->name, 'sort_options');
    8585            $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');
    8687        }
    8788        return $post_types;
     
    234235        }
    235236        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;
    236249    }
    237250
  • wp-nested-pages/trunk/app/Entities/User/UserRepository.php

    r2655339 r2982731  
    162162
    163163    /**
     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    /**
    164178    * Get an array of all users/ids
    165179    * @since 1.3.0
  • wp-nested-pages/trunk/app/NestedPages.php

    r2919170 r2982731  
    1313
    1414        global $np_version;
    15         $np_version = '3.2.4';
     15        $np_version = '3.2.5';
    1616
    1717        if ( is_admin() ) $app = new NestedPages\Bootstrap;
  • wp-nested-pages/trunk/app/Views/forms/quickedit-post.php

    r2772716 r2982731  
    124124
    125125            <?php
    126             $custom_fields_left = $this->custom_fields_repo->outputFields($this->post_type, 'left');
     126            $custom_fields_left = $this->custom_fields_repo->outputQuickEditFields($this->post_type, 'left');
    127127            if ( $custom_fields_left ) echo $custom_fields_left;
    128128            ?>
     
    189189
    190190            <?php
    191             $custom_fields_right = $this->custom_fields_repo->outputFields($this->post_type, 'right');
     191            $custom_fields_right = $this->custom_fields_repo->outputQuickEditFields($this->post_type, 'right');
    192192            if ( $custom_fields_right ) echo $custom_fields_right;
    193193            ?>
  • wp-nested-pages/trunk/app/Views/partials/bulk-edit.php

    r2671488 r2982731  
    8484                <?php endif; ?>
    8585
     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
    8691            </div><!-- .left -->
    8792
     
    117122                </div>
    118123                <?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                ?>
    119129
    120130            </div><!-- .right -->
  • wp-nested-pages/trunk/app/Views/partials/row-link.php

    r2812197 r2982731  
    110110        echo $out;
    111111    endif;
    112     ?>
    113112
     113    if ( $this->can_user_perform_bulk_actions ) : ?>
    114114    <div class="np-bulk-checkbox">
    115115        <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); ?>" />
    116116    </div>
     117    <?php endif ?>
    117118</div><!-- .row -->
  • wp-nested-pages/trunk/app/Views/partials/row.php

    r2812197 r2982731  
    320320        echo $out;
    321321    endif;
    322     ?>
    323 
     322
     323    if ( $this->can_user_perform_bulk_actions ) : ?>
    324324    <div class="np-bulk-checkbox">
    325325        <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); ?>" />
    326326    </div>
     327    <?php endif ?>
    327328</div><!-- .row -->
  • wp-nested-pages/trunk/app/Views/settings/settings-posttypes.php

    r2814679 r2982731  
    360360                </div><!-- .row -->
    361361            </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>
    362380            </ul>
    363381        </div><!-- .body -->
  • wp-nested-pages/trunk/nestedpages.php

    r2919170 r2982731  
    44Plugin URI: http://nestedpages.com
    55Description: 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.4
     6Version: 3.2.5
    77Author: Kyle Phillips
    88Author URI: https://github.com/kylephillips
  • wp-nested-pages/trunk/readme.txt

    r2919175 r2982731  
    44Tags: pages, admin, nested, tree view, page tree, sort, quick edit, structure
    55Requires at least: 3.8
    6 Tested up to: 6.1
     6Tested up to: 6.4
    77Requires PHP: 5.4
    88Stable tag: 3.2.4
     
    105105
    106106== 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
    107114
    108115= 3.2.4 =
Note: See TracChangeset for help on using the changeset viewer.