Пример #1
0
    function tt_render_list_page()
    {
        global $SUCCESS;
        //Create an instance of our package class...
        $zoneListTable = new Zone_List_Table();
        //Fetch, prepare, sort, and filter our data...
        $zoneListTable->prepare_items();
        ?>
        <div class="wrap woocommerce">
            
            <div id="icon-users" class="icon32"><br/></div>
            <h2>Shipping Zones <a href="?page=<?php 
        echo $_REQUEST['page'];
        ?>
&tab=shipping_zones&action=new" class="add-new-h2">Add New</a></h2>
            </form>

            <?php 
        if (isset($_GET['upgrade']) && $_GET['upgrade'] == 'true') {
            ?>
            <div class="updated" style="font-weight:bold;">
                <p><?php 
            _e('Your zones have been updated. Please test your forms to ensure that everything is in working order.', 'be_table_rate');
            ?>
</p>
            </div>
            <?php 
        }
        ?>

            <?php 
        if (isset($_GET['action']) && $_GET['action'] == 'delete') {
            ?>
                <?php 
            if (isset($SUCCESS) && $SUCCESS) {
                ?>
            <div class="updated" style="font-weight:bold;">
                <p><?php 
                _e('The selected zone(s) have been deleted.', 'be_table_rate');
                ?>
</p>
            </div>
                <?php 
            } else {
                ?>
            <div class="error" style="font-weight:bold;">
                <p><?php 
                _e('An error has occurred and the selected zone(s) were not deleted.', 'be_table_rate');
                ?>
</p>
            </div>
                <?php 
            }
            ?>
            <?php 
        }
        ?>

            <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
            <form id="zones-filter" method="post" action="">
                <!-- For plugins, we also need to ensure that the form posts back to our current page -->
                <input type="hidden" name="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
" />
                <!-- Now we can render the completed list table -->
                <?php 
        $zoneListTable->display();
        ?>
                <?php 
        wp_nonce_field('woocommerce-settings', '_wpnonce', true, true);
        ?>
                <p class="submit">
                    <input name="save" class="button-primary" type="submit" value="Save changes" />
                    <input type="hidden" name="subtab" id="last_tab" />
                </p>
            </form>
            
        </div>
        <script>
            jQuery(function() {
                var fixHelperModified = function(e, tr) {
                    var $originals = tr.children();
                    var $helper = tr.clone();
                    $helper.children().each(function(index)
                    {
                      jQuery(this).width($originals.eq(index).width())
                    });
                    return $helper;
                };
                jQuery("#the-list").sortable({
                    helper: fixHelperModified
                }).disableSelection();
            });
        </script>
        <?php 
    }