Plugin Directory

Changeset 1571375


Ignore:
Timestamp:
01/09/2017 07:15:02 PM (9 years ago)
Author:
thinkatat
Message:

Removed Subscriber from Contributors list.

Location:
at-multiauthor/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • at-multiauthor/trunk/at-multiauthor.php

    r1570252 r1571375  
    44 * Plugin URI: http://thinkatat.com/
    55 * Description: One post, multiple contributors!
    6  * Version: 1.0.1
     6 * Version: 1.0.2
    77 * Author: thinkatat
    88 * Author URI: http://thinkatat.com/
     
    1818
    1919// Plugin setup - Basic constants.
    20 define( 'ATMAT_VERSION', '1.0.1' );
     20define( 'ATMAT_VERSION', '1.0.2' );
    2121define( 'ATMAT_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
    2222define( 'ATMAT_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
  • at-multiauthor/trunk/includes/class-backend.php

    r1570297 r1571375  
    5151
    5252        $disabled = null;
    53         if ( ! count( array_intersect( get_allowed_roles(), (array) wp_get_current_user()->roles ) ) ) {
     53        if ( ! count( array_intersect( get_allowed_roles( $post->ID ), (array) wp_get_current_user()->roles ) ) ) {
    5454            // Current user is not allowed to manage contributors.
    5555            $disabled = 'disabled';
     
    6464            'atmatStrings',
    6565            array(
    66                 'placeholder' => __('Select Contributor(s)', 'at-multiauthor')
     66                'placeholder' => __( 'Select Contributor(s)', 'at-multiauthor' ),
    6767            )
    6868        );
     
    7272                'orderby'      => 'login',
    7373                'order'        => 'ASC',
     74                'role__in' => get_contributors_role_in( $post->ID ),
    7475            )
    7576        );
     
    101102     */
    102103    public function save_metabox_multiauthor( $post_id ) {
    103         // Security pass 1.
     104        // Security pass 1 - Nonce verification.
    104105        if ( ! isset( $_POST['atmat-nonce'] ) || ! wp_verify_nonce( sanitize_text_field( $_POST['atmat-nonce'] ), 'atmat_save_settings' ) ) {
    105106            return;
    106107        }
    107108
    108         // Security pass 2.
    109         if ( ! count( array_intersect( get_allowed_roles(), (array) wp_get_current_user()->roles ) ) ) {
     109        // Security pass 2 - Check if current user is allowed to manage contributors or not.
     110        if ( ! count( array_intersect( get_allowed_roles( $post_id ), (array) wp_get_current_user()->roles ) ) ) {
    110111            // Current user is not allowed to manage contributors.
    111112            return;
     
    115116
    116117        if ( isset( $_POST['atmat-authors'] ) ) {
    117             $authors = array_map( 'esc_attr', (array) $_POST['atmat-authors'] );
     118            $role_in = get_contributors_role_in( $post_id );
     119           
     120            // Security pass 3 - Validate contributors ID.
     121            foreach ( (array) $_POST['atmat-authors'] as $contributor_id ) {
     122                $contributor_id = (int) $contributor_id;
     123                $contributor = get_userdata( $contributor_id );
     124                if ( count( array_intersect( $role_in, $contributor->roles ) ) ) {
     125                    $authors[] = $contributor_id;
     126                }
     127            }
    118128        }
    119129
  • at-multiauthor/trunk/includes/functions.php

    r1570252 r1571375  
    1313 * Function returns user roles having access to manage contributors.
    1414 *
     15 * @param  int $post_id Post ID for which want.
    1516 * @return array $allowed_roles Allowed roles.
    1617 * @since 1.0.1
    1718 */
    18 function get_allowed_roles() {
    19     return apply_filters( 'atmat_get_allowed_roles', array( 'administrator', 'editor', 'author' ) );
     19function get_allowed_roles( $post_id = null ) {
     20    return apply_filters( 'atmat_get_allowed_roles', array( 'administrator', 'editor', 'author' ), $post_id );
    2021}
     22
     23
     24/**
     25 * Function returns user roles which have to be in the contributors list.
     26 *
     27 * @param  int $post_id Post ID for which roles want.
     28 * @return array $include_roles Roles which have to include in the contributors list.
     29 * @since 1.0.2
     30 */
     31function get_contributors_role_in( $post_id = null ) {
     32    return apply_filters( 'atmat_get_contributors_role_in', array( 'administrator', 'editor', 'author', 'contributor' ), $post_id );
     33}
  • at-multiauthor/trunk/readme.txt

    r1570252 r1571375  
    3030== Changelog ==
    3131
     32= 1.0.2 =
     33* Removed Subscriber from Contributors list.
     34
    3235= 1.0.1 =
    3336* Applied WordPress coding standards.
Note: See TracChangeset for help on using the changeset viewer.