| 760 | |
| 761 | /** |
| 762 | * Adds Type, Visibility and Status fields to Quick Edit options |
| 763 | * @param string $column_name Name of the column |
| 764 | * @param string $post_type Current Post Type (i.e. forum) |
| 765 | * @return void |
| 766 | */ |
| 767 | public function display_custom_quickedit_forum( $column_name, $post_type ) { |
| 768 | |
| 769 | if ( $this->bail() ) { |
| 770 | return; |
| 771 | } |
| 772 | |
| 773 | if( $column_name !== 'bbp_forum_topic_count' ) |
| 774 | return; |
| 775 | |
| 776 | ?> |
| 777 | |
| 778 | <fieldset class="inline-edit-col-left inline-edit-<?php echo $post_type ?>"> |
| 779 | <div class="inline-edit-col"> |
| 780 | <label class="inline-edit-group"> |
| 781 | <span class="title"><?php esc_html_e( 'Type', 'bbpress' ); ?></span> |
| 782 | <select name="bbp_forum_type" id="bbp_forum_type_select"> |
| 783 | <option value=""><?php _e( '— No Change —' ); ?></option> |
| 784 | <?php foreach ( bbp_get_forum_types() as $key => $label ) : ?> |
| 785 | |
| 786 | <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></option> |
| 787 | |
| 788 | <?php endforeach; ?> |
| 789 | |
| 790 | </select> |
| 791 | </label> |
| 792 | </div> |
| 793 | </fieldset> |
| 794 | |
| 795 | <fieldset class="inline-edit-col-left inline-edit-<?php echo $post_type ?>"> |
| 796 | <div class="inline-edit-col"> |
| 797 | <label class="inline-edit-group"> |
| 798 | <span class="title"><?php esc_html_e( 'Forum Status', 'bbpress' ); ?></span> |
| 799 | <select name="bbp_forum_status" id="bbp_forum_status_select"> |
| 800 | <option value=""><?php _e( '— No Change —' ); ?></option> |
| 801 | <?php foreach ( bbp_get_forum_statuses() as $key => $label ) : ?> |
| 802 | |
| 803 | <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></option> |
| 804 | |
| 805 | <?php endforeach; ?> |
| 806 | |
| 807 | </select> |
| 808 | </label> |
| 809 | </div> |
| 810 | </fieldset> |
| 811 | |
| 812 | <fieldset class="inline-edit-col-left inline-edit-<?php echo $post_type ?>"> |
| 813 | <div class="inline-edit-col"> |
| 814 | <label class="inline-edit-group"> |
| 815 | <span class="title"><?php esc_html_e( 'Visibility', 'bbpress' ); ?></span> |
| 816 | <select name="_bbp_forum_visibility" id="bbp_forum_visibility_select"> |
| 817 | <option value=""><?php _e( '— No Change —' ); ?></option> |
| 818 | <?php foreach ( bbp_get_forum_visibilities() as $key => $label ) : ?> |
| 819 | |
| 820 | <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></option> |
| 821 | |
| 822 | <?php endforeach; ?> |
| 823 | |
| 824 | </select> |
| 825 | </label> |
| 826 | </div> |
| 827 | </fieldset> |
| 828 | |
| 829 | <?php |
| 830 | } |
| 831 | |
| 832 | /** |
| 833 | * Process bulk edit actions via AJAX |
| 834 | * |
| 835 | * @return void |
| 836 | */ |
| 837 | public function save_bulk_edit() { |
| 838 | |
| 839 | $forum_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array(); |
| 840 | |
| 841 | if ( ! empty( $forum_ids ) && is_array( $forum_ids ) ) { |
| 842 | |
| 843 | foreach ( $forum_ids as $forum_id ) { |
| 844 | |
| 845 | if( ! current_user_can( 'edit_post', $forum_id ) ) { |
| 846 | continue; |
| 847 | } |
| 848 | |
| 849 | /** Forum Type ********************************************************/ |
| 850 | |
| 851 | if ( ! empty( $_POST['bbp_forum_type'] ) && in_array( $_POST['bbp_forum_type'], array( 'forum', 'category' ) ) ) { |
| 852 | if ( 'category' === $_POST['bbp_forum_type'] && ! bbp_is_forum_category( $forum_id ) ) { |
| 853 | bbp_categorize_forum( $forum_id ); |
| 854 | } elseif ( 'forum' === $_POST['bbp_forum_type'] && ! bbp_is_forum_category( $forum_id ) ) { |
| 855 | bbp_normalize_forum( $forum_id ); |
| 856 | } elseif ( 'forum' === $_POST['bbp_forum_type'] && bbp_is_forum_category( $forum_id ) ) { |
| 857 | bbp_normalize_forum( $forum_id ); |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | /** Forum Status ******************************************************/ |
| 862 | |
| 863 | if ( ! empty( $_POST['bbp_forum_status'] ) && in_array( $_POST['bbp_forum_status'], array( 'open', 'closed' ) ) ) { |
| 864 | if ( 'closed' === $_POST['bbp_forum_status'] && ! bbp_is_forum_closed( $forum_id, false ) ) { |
| 865 | bbp_close_forum( $forum_id ); |
| 866 | } elseif ( 'open' === $_POST['bbp_forum_status'] && bbp_is_forum_open( $forum_id, false ) ) { |
| 867 | bbp_open_forum( $forum_id ); |
| 868 | } elseif ( 'open' === $_POST['bbp_forum_status'] && bbp_is_forum_closed( $forum_id, false ) ) { |
| 869 | bbp_open_forum( $forum_id ); |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | /** Forum Visibility **************************************************/ |
| 874 | $visibility = isset( $_POST['bbp_forum_visibility'] ) ? $_POST['bbp_forum_visibility'] : ''; |
| 875 | if ( ! empty( $visibility ) ) { |
| 876 | // What is the new forum visibility setting? |
| 877 | switch ( $visibility ) { |
| 878 | |
| 879 | // Hidden |
| 880 | case bbp_get_hidden_status_id() : |
| 881 | bbp_hide_forum( $forum_id ); |
| 882 | break; |
| 883 | |
| 884 | // Private |
| 885 | case bbp_get_private_status_id() : |
| 886 | bbp_privatize_forum( $forum_id ); |
| 887 | break; |
| 888 | |
| 889 | // Publish (default) |
| 890 | case bbp_get_public_status_id() : |
| 891 | default : |
| 892 | bbp_publicize_forum( $forum_id ); |
| 893 | break; |
| 894 | } |
| 895 | } |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | die(); |
| 900 | } |
| 901 | |