Changeset 11870
- Timestamp:
- 02/28/2018 07:25:32 PM (7 years ago)
- Location:
- trunk/src/bp-messages/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/classes/class-bp-messages-notices-admin.php
r11869 r11870 115 115 */ 116 116 public function admin_load() { 117 $redirect_to = false; 118 119 // Catch new notice saves. 117 120 if ( ! empty( $_POST['bp_notice']['send'] ) ) { 118 121 … … 125 128 126 129 if ( messages_send_notice( $notice['subject'], $notice['content'] ) ) { 127 $redirect_to = add_query_arg( 'success', 1, $this->url );130 $redirect_to = add_query_arg( 'success', 'create', $this->url ); 128 131 129 132 // Notice could not be sent. 130 133 } else { 131 $redirect_to = add_query_arg( 'error', 1, $this->url );134 $redirect_to = add_query_arg( 'error', 'create', $this->url ); 132 135 } 133 136 } 137 138 // Catch activation/deactivation/delete requests 139 if ( ! empty( $_GET['notice_id'] ) && ! empty( $_GET['notice_action'] ) ) { 140 $notice_id = absint( $_GET['notice_id'] ); 141 142 check_admin_referer( 'messages-' . $_GET['notice_action'] . '-notice-' . $notice_id ); 143 144 $success = false; 145 switch ( $_GET['notice_action'] ) { 146 case 'activate': 147 $notice = new BP_Messages_Notice( $notice_id ); 148 $success = $notice->activate(); 149 break; 150 case 'deactivate': 151 $notice = new BP_Messages_Notice( $notice_id ); 152 $success = $notice->deactivate(); 153 break; 154 case 'delete': 155 $notice = new BP_Messages_Notice( $notice_id ); 156 $success = $notice->delete(); 157 break; 158 } 159 if ( $success ) { 160 $redirect_to = add_query_arg( 'success', 'update', $this->url ); 161 162 // Notice could not be updated. 163 } else { 164 $redirect_to = add_query_arg( 'error', 'update', $this->url ); 165 } 166 167 } 168 169 if ( $redirect_to ) { 134 170 wp_safe_redirect( $redirect_to ); 135 171 exit(); … … 191 227 <p> 192 228 <?php 193 if ( isset( $_GET['error'] ) ) : 194 esc_html_e( 'Notice was not created. Please try again.', 'buddypress' ); 195 else : 196 esc_html_e( 'Notice successfully created.', 'buddypress' ); 197 endif; 229 if ( isset( $_GET['error'] ) ) { 230 if ( 'create' === $_GET['error'] ) { 231 esc_html_e( 'Notice was not created. Please try again.', 'buddypress' ); 232 } else { 233 esc_html_e( 'Notice was not updated. Please try again.', 'buddypress' ); 234 } 235 } else { 236 if ( 'create' === $_GET['success'] ) { 237 esc_html_e( 'Notice successfully created.', 'buddypress' ); 238 } else { 239 esc_html_e( 'Notice successfully updated.', 'buddypress' ); 240 } 241 } 198 242 ?> 199 243 </p> -
trunk/src/bp-messages/classes/class-bp-messages-notices-list-table.php
r11868 r11870 110 110 public function column_subject( $item ) { 111 111 $actions = array( 112 'activate_deactivate' => '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 113 'page' => 'bp-notices', 114 'activate' => $item->id 115 ), bp_get_admin_url( 'users.php' ) ) ), 'messages_activate_notice' ) . '" data-bp-notice-id="' . $item->id . '" data-bp-action="activate">' . esc_html__( 'Activate Notice', 'buddypress' ) . '</a>', 116 'delete' => '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 117 'page' => 'bp-notices', 118 'delete' => $item->id 119 ), bp_get_admin_url( 'users.php' ) ) ), 'messages_delete_thread' ) . '" data-bp-notice-id="' . $item->id . '" data-bp-action="delete">' . esc_html__( 'Delete Notice', 'buddypress' ) . '</a>', 112 'activate_deactivate' => sprintf( '<a href="%s" data-bp-notice-id="%d" data-bp-action="activate">%s</a>', 113 esc_url( wp_nonce_url( add_query_arg( array( 114 'page' => 'bp-notices', 115 'notice_action' => 'activate', 116 'notice_id' => $item->id 117 ), bp_get_admin_url( 'users.php' ) ), 'messages-activate-notice-' . $item->id ) ), 118 (int) $item->id, 119 esc_html__( 'Activate Notice', 'buddypress' ) ), 120 'delete' => sprintf( '<a href="%s" data-bp-notice-id="%d" data-bp-action="delete">%s</a>', 121 esc_url( wp_nonce_url( add_query_arg( array( 122 'page' => 'bp-notices', 123 'notice_action' => 'delete', 124 'notice_id' => $item->id 125 ), bp_get_admin_url( 'users.php' ) ), 'messages-delete-notice-' . $item->id ) ), 126 (int) $item->id, 127 esc_html__( 'Delete Notice', 'buddypress' ) ) 120 128 ); 121 129 122 130 if ( ! empty( $item->is_active ) ) { 123 $actions['activate_deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 124 'page' => 'bp-notices', 125 'deactivate' => $item->id 126 ), bp_get_admin_url( 'users.php' ) ) ), 'messages_deactivate_notice' ) . '" data-bp-notice-id="' . $item->id . '" data-bp-action="deactivate">' . esc_html__( 'Deactivate Notice', 'buddypress' ) . '</a>'; 131 $item->subject = sprintf( _x( 'Active: %s', 'Tag prepended to active site-wide notice titles on WP Admin notices list table', 'buddypress' ), $item->subject ); 132 $actions['activate_deactivate'] = sprintf( '<a href="%s" data-bp-notice-id="%d" data-bp-action="deactivate">%s</a>', 133 esc_url( wp_nonce_url( add_query_arg( array( 134 'page' => 'bp-notices', 135 'notice_action' => 'deactivate', 136 'notice_id' => $item->id 137 ), bp_get_admin_url( 'users.php' ) ), 'messages-deactivate-notice-' . $item->id ) ), 138 (int) $item->id, 139 esc_html__( 'Deactivate Notice', 'buddypress' ) ); 127 140 } 128 141
Note: See TracChangeset
for help on using the changeset viewer.