Plugin Directory

Changeset 2244629


Ignore:
Timestamp:
02/14/2020 09:14:53 PM (6 years ago)
Author:
frile
Message:

Custom post type support added

Location:
bulk-remove-posts-from-category
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • bulk-remove-posts-from-category/trunk/js/wpbulkremove.js

    r2047313 r2244629  
    77
    88jQuery(document).on('change', '#remcat input', function() {
    9  var $bulktype = wpbulkremove.wpbulkremove_type;
    10  if($bulktype == 'edit-post'){
    11     var $ini = 'post_category[]';
    12 } else {
    13     var $ini = 'tax_input[product_cat][]';
    14 }
     9    var $bulktype = wpbulkremove.wpbulkremove_type;
     10    var $bulktax = wpbulkremove.wpbulkremove_tax;
     11        if($bulktype == 'edit-post'){
     12            var $ini = 'post_category[]';
     13        } else if($bulktype == 'edit-product') {
     14            var $ini = 'tax_input[product_cat][]';
     15        } else {
     16            var $ini = 'tax_input['+$bulktax+'][]';
     17        }
    1518 var $repl = 'post_out_category';
    1619 var $list = jQuery(this).closest('.inline-edit-col').find('ul.cat-checklist');
     
    3538 
    3639        var $bulktype = wpbulkremove.wpbulkremove_type;
     40        var $bulktax = wpbulkremove.wpbulkremove_tax;
    3741        var bulk_edit_row = $( 'tr#bulk-edit' );
    3842        remcat = bulk_edit_row.find( 'input[name="remove_cat"]' ).attr('checked') ? 1 : 0;
     
    6165                        catout: catout,
    6266                        remcat: remcat,
    63                         type: $bulktype
     67                        type: $bulktype,
     68                        taxonomy: $bulktax
    6469                    }
    6570                });
  • bulk-remove-posts-from-category/trunk/readme.txt

    r2212802 r2244629  
    44Tags: post categories, bulk edit, bulk remove, product categories
    55Requires at least: 4.6
    6 Tested up to: 5.3.1
    7 Stable tag: 2.1
     6Tested up to: 5.3.2
     7Stable tag: 3.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1919This plugin extends default Bulk Editor so you can remove Categories from posts.
    2020
    21 The plugin works just with default Post type and Woocommerce products.
     21The plugin works just with default Post type, Woocommerce products and any other Custom Post Type.
    2222
    2323== Installation ==
     
    3434= Does it work with custom post types =
    3535
    36 Nope. This plugin doesn't support Custom Post Types.
     36Yes. This plugin works fine with Custom Post Types.
    3737
    3838== Changelog ==
     39
     40= 3.0 =
     41* Custom Post Type support
    3942
    4043= 2.1 =
  • bulk-remove-posts-from-category/trunk/wpbulkremove.php

    r2212802 r2244629  
    77 * Plugin URI:   https://masterns-studio.com/code-factory/wordpress-plugin/bulk-remove-from-category/
    88 * Description: Bulk remove posts from category
    9  * Version: 2.1
     9 * Version: 3.0
    1010 * Author: MasterNs
    1111 * Author URI: https://masterns-studio.com/
    1212 * License: GPLv2 or later
    1313 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    14  * Tested up to: 5.3.1
     14 * Tested up to: 5.3.2
    1515 * Text Domain: bulk-remove-posts-from-category
    1616 * Domain Path: languages/
     
    3838function wpbulkremove_enqueue($hook) {
    3939    $screen = get_current_screen();
     40    $can_run = false;
     41    $cpt_tax = '';
     42   
    4043    if (( 'edit-post' === $screen->id )||('edit-product' === $screen->id)) {
    41             wp_enqueue_style('wpbulkremove_style', plugins_url('/css/wpbulkremove_style.css', __FILE__));       
    42             wp_enqueue_script( 'wpbulkremove-js', plugins_url('/js/wpbulkremove.js', __FILE__));
    43             $wpbulkremove_array = array(
    44                 'wpbulkremove_string' => __( 'Remove from category', 'bulk-remove-posts-from-category' ),
    45                 'wpbulkremove_type' => $screen->id
    46             );
    47             wp_localize_script( 'wpbulkremove-js', 'wpbulkremove', $wpbulkremove_array );
    48     }   
     44        $can_run = true;   
     45    } else {
     46        $post_type = $screen->post_type;
     47        $taxonomies = get_object_taxonomies($post_type, 'objects');
     48            foreach($taxonomies as $tax){
     49                if($tax->hierarchical){
     50                    $can_run = true;
     51                    $cpt_tax = $tax->name;
     52                }
     53            }
     54    }
     55   
     56    if($can_run){
     57        wp_enqueue_style('wpbulkremove_style', plugins_url('/css/wpbulkremove_style.css', __FILE__));       
     58        wp_enqueue_script( 'wpbulkremove-js', plugins_url('/js/wpbulkremove.js', __FILE__));
     59        $wpbulkremove_array = array(
     60            'wpbulkremove_string' => __( 'Remove from category', 'bulk-remove-posts-from-category' ),
     61            'wpbulkremove_type' => $screen->id,
     62            'wpbulkremove_tax' => $cpt_tax
     63        );
     64        wp_localize_script( 'wpbulkremove-js', 'wpbulkremove', $wpbulkremove_array );
     65    }
    4966}
    5067
     
    6784    if( $_POST[ 'type' ] == 'edit-post' ) {
    6885        $bulktax = 'category';
     86    } elseif($_POST[ 'type' ] == 'edit-product') {
     87        $bulktax = 'product_cat';
    6988    } else {
    70         $bulktax = 'product_cat';
     89        $bulktax = $_POST[ 'taxonomy' ];
    7190    }
    7291 
Note: See TracChangeset for help on using the changeset viewer.