Changeset 1571375
- Timestamp:
- 01/09/2017 07:15:02 PM (9 years ago)
- Location:
- at-multiauthor/trunk
- Files:
-
- 4 edited
-
at-multiauthor.php (modified) (2 diffs)
-
includes/class-backend.php (modified) (5 diffs)
-
includes/functions.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
at-multiauthor/trunk/at-multiauthor.php
r1570252 r1571375 4 4 * Plugin URI: http://thinkatat.com/ 5 5 * Description: One post, multiple contributors! 6 * Version: 1.0. 16 * Version: 1.0.2 7 7 * Author: thinkatat 8 8 * Author URI: http://thinkatat.com/ … … 18 18 19 19 // Plugin setup - Basic constants. 20 define( 'ATMAT_VERSION', '1.0. 1' );20 define( 'ATMAT_VERSION', '1.0.2' ); 21 21 define( 'ATMAT_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); 22 22 define( 'ATMAT_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); -
at-multiauthor/trunk/includes/class-backend.php
r1570297 r1571375 51 51 52 52 $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 ) ) ) { 54 54 // Current user is not allowed to manage contributors. 55 55 $disabled = 'disabled'; … … 64 64 'atmatStrings', 65 65 array( 66 'placeholder' => __( 'Select Contributor(s)', 'at-multiauthor')66 'placeholder' => __( 'Select Contributor(s)', 'at-multiauthor' ), 67 67 ) 68 68 ); … … 72 72 'orderby' => 'login', 73 73 'order' => 'ASC', 74 'role__in' => get_contributors_role_in( $post->ID ), 74 75 ) 75 76 ); … … 101 102 */ 102 103 public function save_metabox_multiauthor( $post_id ) { 103 // Security pass 1 .104 // Security pass 1 - Nonce verification. 104 105 if ( ! isset( $_POST['atmat-nonce'] ) || ! wp_verify_nonce( sanitize_text_field( $_POST['atmat-nonce'] ), 'atmat_save_settings' ) ) { 105 106 return; 106 107 } 107 108 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 ) ) ) { 110 111 // Current user is not allowed to manage contributors. 111 112 return; … … 115 116 116 117 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 } 118 128 } 119 129 -
at-multiauthor/trunk/includes/functions.php
r1570252 r1571375 13 13 * Function returns user roles having access to manage contributors. 14 14 * 15 * @param int $post_id Post ID for which want. 15 16 * @return array $allowed_roles Allowed roles. 16 17 * @since 1.0.1 17 18 */ 18 function get_allowed_roles( ) {19 return apply_filters( 'atmat_get_allowed_roles', array( 'administrator', 'editor', 'author' ) );19 function get_allowed_roles( $post_id = null ) { 20 return apply_filters( 'atmat_get_allowed_roles', array( 'administrator', 'editor', 'author' ), $post_id ); 20 21 } 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 */ 31 function 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 30 30 == Changelog == 31 31 32 = 1.0.2 = 33 * Removed Subscriber from Contributors list. 34 32 35 = 1.0.1 = 33 36 * Applied WordPress coding standards.
Note: See TracChangeset
for help on using the changeset viewer.