1

I have built a custom taxonomy for which I have built a custom page that lists the terms associated with it. Everything seems to be working fine so far except the Quick Edit, which simply does nothing... By looking at the code, it also seems like the inline-edit js are not included in the page.

Here is my code so far:

function custom_term_options_panel(){
    global $menu_page;
    $menu_page = add_menu_page(
        'Page title',
        'Menu label',
        'manage_options',
        'custom-term-options',
        'custom_term_function');

    add_action("load-$menu_page", 'custom_term_options');
}

function custom_term_options() {
    global $taxnow;
    $tax = get_taxonomy( $taxnow );
    get_current_screen()->id = "edit-{$tax->name}";

    $option = 'per_page';
    $args = [
        'default' => 20,
        'option' => 'edit_' . $tax->name . '_per_page',
        'label' => "Number of $tax->name per page",
    ];
    add_screen_option( $option, $args);
}

function custom_term_function(){
    global $taxnow;
    global $post_type;
    $wp_list_table = _get_list_table('WP_Terms_List_Table');

    $tax = get_taxonomy($taxnow);
    get_current_screen()->id = "edit-{$tax->name}";
    get_current_screen()->parent_base = "{$tax->name}";
    get_current_screen()->parent_file = "{$tax->name}";
    get_current_screen()->post_type = "post";
    $wp_list_table->prepare_items();

    ?>
    <div class="wrap nosubsub">
        <h1>All <?php echo $tax->labels->name; ?></h1>
        <form class="search-form wp-clearfix" method="get">
            <input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>" />
            <input type="hidden" name="taxonomy" value="<?php echo esc_attr($tax->name); ?>" />
            <input type="hidden" name="post_type" value="<?php echo esc_attr('post'); ?>" />

            <?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>

        </form>
    <?php
    $wp_list_table->display();
    ?>
    </div>
    <?php
}

add_action('admin_menu', 'custom_term_options_panel');

Right now, the Edit, View & Delete functions seems to be working fine considering that they point to the default edit-tags.php page to perform these tasks. I had to set up the screen options through functions to reproduce the default behavior, but those were outside of the wp_list_table while the quick edit is inside, so I am not entirely sure how to approach this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.