Changeset 5925 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
- Timestamp:
- 09/14/2017 12:53:56 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
r5903 r5925 13 13 add_action( 'pre_get_posts', array( $this, 'hide_non_public_forums' ) ); 14 14 add_filter( 'pre_option__bbp_edit_lock', array( $this, 'increase_edit_lock_time' ) ); 15 add_filter( 'bbp_map_meta_caps', array( $this, 'disallow_editing_past_lock_time' ), 10, 4 ); 15 16 add_filter( 'redirect_canonical', array( $this, 'disable_redirect_guess_404_permalink' ) ); 16 17 add_filter( 'wp_insert_post_data', array( $this, 'set_post_date_gmt_for_pending_posts' ) ); … … 112 113 public function increase_edit_lock_time() { 113 114 return 60; 115 } 116 117 /** 118 * Disallow editing topics or replies past edit lock time for non-moderators. 119 * 120 * @see https://bbpress.trac.wordpress.org/ticket/3164 121 * 122 * @param array $caps User's actual capabilities. 123 * @param string $cap Capability name. 124 * @param int $user_id Current user ID. 125 * @param array $args Capability context, typically the object ID. 126 * @return array Filtered capabilities. 127 */ 128 function disallow_editing_past_lock_time( $caps, $cap, $user_id, $args ) { 129 switch ( $cap ) { 130 case 'edit_topic': 131 case 'edit_reply': 132 $post = get_post( $args[0] ); 133 134 if ( 135 $post && bbp_past_edit_lock( $post->post_date_gmt ) 136 && 137 ! user_can( $user_id, 'moderate', $post->ID ) 138 ) { 139 $caps = array( 'do_not_allow' ); 140 } 141 142 break; 143 } 144 145 return $caps; 114 146 } 115 147
Note: See TracChangeset
for help on using the changeset viewer.