Changeset 6915
- Timestamp:
- 11/03/2019 03:27:08 AM (6 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/core/actions.php
r6876 r6915 240 240 241 241 // Sticky 242 add_action( 'bbp_spam_topic', 'bbp_unstick_topic' ); 243 add_action( 'bbp_trash_topic', 'bbp_unstick_topic' ); 244 add_action( 'bbp_delete_topic', 'bbp_unstick_topic' ); 242 add_action( 'bbp_stick_topic', 'bbp_unstick_topic' ); 243 add_action( 'bbp_unapprove_topic', 'bbp_unstick_topic' ); 244 add_action( 'bbp_spam_topic', 'bbp_unstick_topic' ); 245 add_action( 'bbp_trash_topic', 'bbp_unstick_topic' ); 246 add_action( 'bbp_delete_topic', 'bbp_unstick_topic' ); 245 247 246 248 // Update topic branch -
trunk/src/includes/topics/functions.php
r6855 r6915 3109 3109 } 3110 3110 3111 // We may have a super sticky to which we want to convert into a normal 3112 // sticky and vice versa; unstick the topic first to avoid any possible error. 3113 bbp_unstick_topic( $topic_id ); 3114 3115 $forum_id = empty( $super ) ? bbp_get_topic_forum_id( $topic_id ) : 0; 3111 do_action( 'bbp_stick_topic', $topic_id, $super ); 3112 3113 // Maybe get the forum ID if not getting supers 3114 $forum_id = empty( $super ) 3115 ? bbp_get_topic_forum_id( $topic_id ) 3116 : 0; 3117 3118 // Get the stickies, maybe from the forum ID 3116 3119 $stickies = bbp_get_stickies( $forum_id ); 3117 3120 3118 do_action( 'bbp_stick_topic', $topic_id, $super ); 3119 3120 if ( ! is_array( $stickies ) ) { 3121 $stickies = array( $topic_id ); 3122 } else { 3123 $stickies[] = $topic_id; 3124 } 3121 // Add the topic to the stickies 3122 $stickies[] = $topic_id; 3125 3123 3126 3124 // Pull out duplicates and empties … … 3136 3134 // Reset keys 3137 3135 $stickies = array_values( $stickies ); 3138 $success = ! empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies ); 3136 3137 // Update 3138 $success = ! empty( $super ) 3139 ? update_option( '_bbp_super_sticky_topics', $stickies ) 3140 : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies ); 3139 3141 3140 3142 do_action( 'bbp_stuck_topic', $topic_id, $super, $success ); … … 3238 3240 */ 3239 3241 function bbp_unstick_topic( $topic_id = 0 ) { 3242 3243 // Get topic sticky status 3240 3244 $topic_id = bbp_get_topic_id( $topic_id ); 3241 3245 $super = bbp_is_topic_super_sticky( $topic_id ); … … 3246 3250 do_action( 'bbp_unstick_topic', $topic_id ); 3247 3251 3252 // Nothing to unstick 3248 3253 if ( empty( $stickies ) ) { 3249 3254 $success = true; 3255 3256 // Topic not in stickies 3250 3257 } elseif ( ! in_array( $topic_id, $stickies, true ) ) { 3251 3258 $success = true; 3259 3260 // Topic not in stickies 3252 3261 } elseif ( false === $offset ) { 3253 3262 $success = true; 3263 3264 // Splice out the offset 3254 3265 } else { 3255 3266 array_splice( $stickies, $offset, 1 ); 3267 3256 3268 if ( empty( $stickies ) ) { 3257 $success = ! empty( $super ) ? delete_option( '_bbp_super_sticky_topics' ) : delete_post_meta( $forum_id, '_bbp_sticky_topics' ); 3269 $success = ! empty( $super ) 3270 ? delete_option( '_bbp_super_sticky_topics' ) 3271 : delete_post_meta( $forum_id, '_bbp_sticky_topics' ); 3258 3272 } else { 3259 $success = ! empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies ); 3273 $success = ! empty( $super ) 3274 ? update_option( '_bbp_super_sticky_topics', $stickies ) 3275 : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies ); 3260 3276 } 3261 3277 }
Note: See TracChangeset
for help on using the changeset viewer.