post_types ) ) ) || ! isset( $_GET['post_type'] ) ) { ?> current_action(); $sendback = ''; switch ( $action ) { case ( 'block' ): case ( 'unblock' ): // Validate nonce. check_admin_referer( 'bulk-posts' ); // Get the posts. $posts = ( isset( $_REQUEST['post'] ) ) ? $_REQUEST['post'] : ''; // Update posts. $x = ''; if ( $posts ) { foreach ( $posts as $post_id ) { $x++; $post = get_post( $post_id ); $type = $post->post_type; // Update accordingly. if ( $wpmem->block[ $type ] == 0 ) { if ( $action == 'block' ) { update_post_meta( $post_id, '_wpmem_block', 1 ); } else { delete_post_meta( $post_id, '_wpmem_block' ); } } if ( $wpmem->block[ $type ] == 1 ) { if ( $action == 'unblock' ) { update_post_meta( $post_id, '_wpmem_block', 0 ); } else { delete_post_meta( $post_id, '_wpmem_block' ); } } } // Set the return message. $arr = array( 'a' => $action, 'n' => $x, 'post_type' => $type, ); if ( isset( $_GET['post_status'] ) && 'all' != $_GET['post_status'] ) { $arr['post_status'] = $_GET['post_status']; } $sendback = add_query_arg( array( $arr ), '', $sendback ); } else { // Set the return message. $sendback = add_query_arg( array( 'a' => 'none' ), '', $sendback ); } break; default: return; } // If we did not return already, we need to wp_redirect. wp_redirect( $sendback ); exit(); } /** * Function to echo admin update message. * * @since 2.8.2 * * @global $pagenow * @global $post_type */ function wpmem_posts_admin_notices() { global $pagenow, $post_type; if ( $pagenow == 'edit.php' && isset( $_REQUEST['a'] ) ) { $msg = ( $_REQUEST['a'] == 'block' ) ? sprintf( __( '%s blocked', 'wp-members' ), $post_type ) : sprintf( __( '%s unblocked', 'wp-members' ), $post_type ); echo '
' . $_REQUEST['n'] . ' ' . $msg . '
' . __( 'Edit', 'wp-members' ) . ''; ?>
ID, $meta, true ), $block ); ?> />
post_types ) ) { $columns['wpmem_block'] = ( $wpmem->block[ $post_type ] == 1 ) ? __( 'Unblocked?', 'wp-members' ) : __( 'Blocked?', 'wp-members' ); } return $columns; } /** * Adds blocking status to the Post Table column. * * @since 2.8.3 * * @global object $wpmem The WP_Members Object. * @param string $column_name * @param int $post_ID */ function wpmem_post_columns_content( $column_name, $post_ID ) { global $wpmem; $post_type = ( isset( $_REQUEST['post_type'] ) ) ? $_REQUEST['post_type'] : 'post'; if ( $column_name == 'wpmem_block' ) { $block_meta = get_post_meta( $post_ID, '_wpmem_block', true ); // Backward compatibility for old block/unblock meta. if ( ! $block_meta ) { // Check for old meta. $old_block = get_post_meta( $post_ID, 'block', true ); $old_unblock = get_post_meta( $post_ID, 'unblock', true ); $block_meta = ( $old_block ) ? 1 : ( ( $old_unblock ) ? 0 : $block_meta ); } echo ( $wpmem->block[ $post_type ] == 1 && $block_meta == '0' ) ? __( 'Yes' ) : ''; echo ( $wpmem->block[ $post_type ] == 0 && $block_meta == '1' ) ? __( 'Yes' ) : ''; } } /** * Adds shortcode dropdown to post editor tinymce. * * @since 3.0 * * @global object $wpmem_shortcode The WP_Members_TinyMCE_Buttons object. */ function wpmem_load_tinymce() { // @todo For now, only load if WP version is high enough. if ( version_compare( get_bloginfo( 'version' ), '3.9', '>=' ) ) { global $wpmem_shortcode; include( WPMEM_PATH . 'admin/includes/class-wp-members-tinymce-buttons.php' ); $wpmem_shortcode = new WP_Members_TinyMCE_Buttons; } } // End of File.