wdt_admin.php 43.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137
<?php
/**
 * @package wpDataTables
 * @version 1.6.0
 */
/**
 * The admin page
 */
?>
<?php

// Labels for create/edit JS
global $wdt_admin_translation_array;
$wdt_admin_translation_array = array(
    'table_type_not_empty' => __('Table type cannot be empty', 'wpdatatables'),
    'error_label' => __('Error!', 'wpdatatables'),
    'table_input_source_not_empty' => __('Table input data source cannot be empty', 'wpdatatables'),
    'mysql_query_cannot_be_empty' => __('MySQL query cannot be empty', 'wpdatatables'),
    'mysql_table_name_not_set' => __('MySQL table name for front-end editing is not set', 'wpdatatables'),
    'userid_column_not_set' => __('User ID column is not set. Please choose a column which will be used to identify rows belonging to the user.', 'wpdatatables'),
    'empty_result_error' => __('This usually happens when the MySQL query returns an empty result or is broken. Please check the results of the query in some DB manager (e.g. PHPMyAdmin)', 'wpdatatables'),
    'empty_manual_table_error' => __('Please add at least 1 row to the table through the editor before changing the settings. wpDataTables uses the actual table data to initialize table settings, so configuration for tables with no rows cannot be modified. Click "Go to editor" to start entering data.', 'wpdatatables'),
    'backend_error_report' => __('wpDataTables backend error: ', 'wpdatatables'),
    'successful_save' => __('Table saved successfully!', 'wpdatatables'),
    'success_label' => __('Success!', 'wpdatatables'),
    'file_too_large' => __('This error is usually occuring because you are trying to load file which is too large. Please try another datasource, use a smaller file.', 'wpdatatables'),
    'id_column_not_set' => __('ID column for front-end editing feature is not set', 'wpdatatables'),
    'are_you_sure_label' => __('Are you sure?', 'wpdatatables'),
    'are_you_sure_lose_unsaved_label' => __('Are you sure? You will lose unsaved changes!', 'wpdatatables'),
    'choose_file' => __('Use in wpDataTable', 'wpdatatables'),
    'select_excel_csv' => __('Select Excel or CSV file', 'wpdatatables'),
    'mysql_server_side_query_too_complicated' => __('Complicated queries (with WHERE clause, conditions, or with JOINs) are not supported together with server-side processing. Please store the query in a MySQL view and then create a wpDataTable based on the view.', 'wpdatatables'),
    'choose_id_column' => __('Please choose an ID column for editing...', 'wpdatatables'),
    'choose_user_id_column' => __('Please choose a user ID column...', 'wpdatatables'),
    'cancel' => __('Cancel', 'wpdatatables'),
    'ok' => __('OK', 'wpdatatables'),
    'no_formatting_rules' => __('No formatting rules for this column yet.', 'wpdatatables'),
    'merge' => __('Merge', 'wpdatatables'),
    'replace' => __('Replace', 'wpdatatables')
    //[<-- Full version insertion #01 -->]//
);

// add the page to WP Admin
add_action('admin_menu', 'wpdatatables_admin_menu');

add_action('admin_print_styles', 'wdt_print_min_css');

function wdt_print_min_css()
{
    wp_register_style('wpdatatables-min', WDT_CSS_PATH . 'wpdatatables.min.css');
    wp_enqueue_style('wpdatatables-min');
    wp_register_style('wpdatatables-admin', WDT_ASSETS_PATH . 'css/wpdatatables_admin.css');
    wp_enqueue_style('wpdatatables-admin');
}


/**
 * Generates the admin menu in admin panel sidebar
 */
function wpdatatables_admin_menu()
{
    $wdt_pages = array(
        add_menu_page('wpDataTables', 'wpDataTables', 'manage_options', 'wpdatatables-administration', 'wpdatatables_browse', 'none'),
        add_submenu_page('wpdatatables-administration', 'Add a new wpDataTable', __('Add from data source', 'wpdatatables'), 'manage_options', 'wpdatatables-addnew', 'wpdatatables_addnew'),
        add_submenu_page('wpdatatables-administration', 'wpDataTable Constructor', __('wpDataTable Constructor', 'wpdatatables'), 'manage_options', 'wpdatatables-constructor', 'wpdatatables_constructor'),
        add_submenu_page('wpdatatables-administration', 'wpDataTables Charts', __('wpDataTables Charts', 'wpdatatables'), 'manage_options', 'wpdatatables-charts', 'wpdatatables_charts'),
        add_submenu_page('wpdatatables-administration', 'Create Chart Wizard', __('Create Chart Wizard', 'wpdatatables'), 'manage_options', 'wpdatatables-chart-wizard', 'wpdatatables_chart_wizard'),
        add_submenu_page('wpdatatables-administration', 'wpDataTables settings', __('Settings', 'wpdatatables'), 'manage_options', 'wpdatatables-settings', 'wpdatatables_settings'),
        add_submenu_page('wpdatatables-administration', 'wpDataTables add-ons', '<span style="color: #ff8c00">' . __('Addons', 'wpdatatables') . '</span>', 'manage_options', 'wpdatatables-addons', 'wpdatatables_addons'),
        add_submenu_page(null, 'wpDataTables editor', 'Editor', 'manage_options', 'wpdatatables-editor', 'wpdatatables_editor')
    );
    foreach ($wdt_pages as $wdt_page) {
        add_action('admin_print_styles-' . $wdt_page, 'wdt_admin_styles');
        add_action('admin_print_scripts-' . $wdt_page, 'wdt_admin_scripts');
    }
}

/**
 * Adds JS to the admin panel
 */
function wdt_admin_scripts()
{
    wp_enqueue_media();
    wp_enqueue_script('media-upload');
    wp_enqueue_script('thickbox');
    wp_enqueue_script('postbox');
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-widget');
    wp_enqueue_script('jquery-ui-draggable');
    wp_enqueue_script('wp-color-picker');
    wp_enqueue_script('wp-color-picker');
    wp_enqueue_script('jquery-ui-sortable');
    wp_enqueue_script('jquery-ui-dialog');
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_script('jquery-ui-tabs');
    do_action('wpdatatables_admin_scripts');
}

/**
 * Adds CSS styles in the admin
 */
function wdt_admin_styles($page)
{
    wp_register_style('wpdatatables-min', WDT_CSS_PATH . 'wpdatatables.min.css');
    wp_enqueue_style('wpdatatables-min');
    wp_register_style('jquery-style', WDT_CSS_PATH . 'jquery-ui.min.css');
    wp_enqueue_style('jquery-style');
    wp_enqueue_style('thickbox');
    wp_register_style('pickadate-default', WDT_ASSETS_PATH . 'css/datepicker.default.css');
    wp_enqueue_style('pickadate-default');
    wp_register_style('pickadate-default-date', WDT_ASSETS_PATH . 'css/datepicker.default.date.css');
    wp_enqueue_style('pickadate-default-date');
    wp_register_style('jquery-fileupload', WDT_CSS_PATH . 'jquery.fileupload.css');
    wp_enqueue_style('jquery-fileupload');
    wp_register_style('tabletools', WDT_CSS_PATH . 'TableTools.css');
    wp_enqueue_style('tabletools');
    wp_register_style('datatables-responsive', WDT_ASSETS_PATH . 'css/datatables.responsive.css');
    wp_enqueue_style('datatables-responsive');
    // Get skin setting
    $skin = get_option('wdtBaseSkin');
    if (empty($skin)) {
        $skin = 'skin1';
    }
    $renderSkin = $skin == 'skin1' ? WDT_ASSETS_PATH . 'css/wpDataTablesSkin.css' : WDT_ASSETS_PATH . 'css/wpDataTablesSkin_1.css';
    wp_register_style('wpdatatables-skin', $renderSkin);
    wp_enqueue_style('wpdatatables-skin');
    wp_enqueue_style('dashicons');
    wp_enqueue_style('wp-color-picker');
    do_action('wpdatatables_admin_styles');
}

/**
 * Get all tables for the browser
 */
function wdt_get_all_tables()
{
    global $wpdb;
    $query = "SELECT id, title, table_type
							FROM {$wpdb->prefix}wpdatatables ";

    if (isset($_REQUEST['s'])) {
        $query .= " WHERE title LIKE '%" . sanitize_text_field($_POST['s']) . "%' ";
    }

    if (isset($_REQUEST['orderby'])) {
        if (in_array($_REQUEST['orderby'], array('id', 'title', 'table_type'))) {
            $query .= " ORDER BY " . $_GET['orderby'];
            if ($_REQUEST['order'] == 'desc') {
                $query .= " DESC";
            } else {
                $query .= " ASC";
            }
        }
    } else {
        $query .= " ORDER BY id ASC ";
    }

    if (isset($_REQUEST['paged'])) {
        $paged = (int)$_REQUEST['paged'];
    } else {
        $paged = 1;
    }

    $tables_per_page = get_option('wdtTablesPerPage') ? get_option('wdtTablesPerPage') : 10;

    $query .= " LIMIT " . ($paged - 1) * $tables_per_page . ", " . $tables_per_page;

    $all_tables = $wpdb->get_results($query, ARRAY_A);

    $all_tables = apply_filters('wpdatatables_filter_browse_tables', $all_tables);

    return $all_tables;
}

/**
 * Get all tables non-paged for the chart wizard
 */
function wdt_get_all_tables_nonpaged()
{
    global $wpdb;
    $query = "SELECT id, title, table_type, server_side
                                    FROM {$wpdb->prefix}wpdatatables ORDER BY id";

    $all_tables = $wpdb->get_results($query, ARRAY_A);

    return $all_tables;
}

/**
 * Get all charts non-paged for the MCE editor
 */
function wdt_get_all_charts_nonpaged()
{
    global $wpdb;
    $query = "SELECT id, title
                                    FROM {$wpdb->prefix}wpdatacharts ";

    $all_charts = $wpdb->get_results($query, ARRAY_A);

    return $all_charts;
}

/**
 * Get table count for the browser
 */
function wdt_get_table_count()
{
    global $wpdb;

    $query = "SELECT COUNT(*) FROM {$wpdb->prefix}wpdatatables";

    $count = $wpdb->get_var($query);

    return $count;
}

/**
 * Helper method which creates the
 * columnset in the DB from a WPDataTable object
 */
function wdt_create_columns_from_table($table, $table_id)
{
    global $wpdb;

    do_action('wpdatatables_before_create_columns', $table, $table_id);

    // Get existing columns array (except formulas)
    $existing_columns_query = $wpdb->prepare("SELECT orig_header
															FROM " . $wpdb->prefix . "wpdatatables_columns
															WHERE table_id = %d
															AND column_type != 'formula'",
        $table_id
    );
    $columns_to_delete = $wpdb->get_col($existing_columns_query);
    if (!empty($_POST['columns_to_delete'])) {
        $columns_to_delete = array_merge($columns_to_delete, $_POST['columns_to_delete']);
    }

    $columns = $table->getColumns();

    foreach ($columns as $key => &$column) {
        $column->table_id = $table_id;
        $column->orig_header = $column->getTitle();
        $column->display_header = $column->getTitle();
        $column->column_type = $column->getDataType();
        $column->use_in_chart = false;
        $column->chart_horiz_axis = false;
        $column->group_column = false;
        $column->pos = $key;
        $column->width = '';
        $column->visible = 1;
        //[<-- Full version -->]//
        $column->possible_values = '';
        $column->default_value = '';
        $column->input_type = 'text';
        $column->input_mandatory = 0;
        $column->filter_type = $column->getFilterType()->type;
        //[<--/ Full version -->]//

        $column = apply_filters('wpdatatables_filter_column_before_save', $column, $table_id);

        if (($delete_key = array_search($column->orig_header, $columns_to_delete)) !== false) {
            unset($columns_to_delete[$delete_key]);
        }

        // Check if column with this header exists in the DB
        $column_query = $wpdb->prepare("SELECT id
                                                                FROM " . $wpdb->prefix . "wpdatatables_columns
                                                                WHERE table_id = %d
                                                                AND orig_header = %s",
            $table_id,
            $column->orig_header);

        $column_id = $wpdb->get_var($column_query);

        if (!empty($column_id)) {
            // If column exists we update it
            $update_array = array(
                'display_header' => $column->display_header,
                'column_type' => $column->column_type,
                'group_column' => 0,
                'sort_column' => 0,
                'use_in_chart' => (int)$column->use_in_chart,
                'chart_horiz_axis' => (int)$column->chart_horiz_axis,
                'pos' => $column->pos,
                'width' => $column->width,
                'visible' => $column->visible,
                //[<-- Full version -->]//
                'possible_values' => $column->possible_values,
                'default_value' => $column->default_value,
                'input_type' => $column->input_type,
                'filter_type' => $column->filter_type,
                //[<--/ Full version -->]//
            );

            $update_array = apply_filters('wpdatatables_filter_update_column_array', $update_array, $table_id, $column);

            $column->id = $column_id;

            $wpdb->update(
                $wpdb->prefix . 'wpdatatables_columns',
                $update_array,
                array(
                    'id' => $column_id
                ),
                array(
                    '%d'
                )
            );

        } else {
            // If column doesn't exist we insert it
            $insert_array = array(
                'table_id' => $table_id,
                'orig_header' => $column->orig_header,
                'display_header' => $column->display_header,
                'group_column' => 0,
                'sort_column' => 0,
                'use_in_chart' => (int)$column->use_in_chart,
                'chart_horiz_axis' => (int)$column->chart_horiz_axis,
                'pos' => $column->pos,
                'width' => $column->width,
                'visible' => $column->visible,
                //[<-- Full version -->]//
                'possible_values' => $column->possible_values,
                'default_value' => $column->default_value,
                'input_type' => $column->input_type,
                'filter_type' => $column->filter_type,
                //[<--/ Full version -->]//
            );

            $insert_array = apply_filters('wpdatatables_filter_insert_column_array', $insert_array, $table_id, $column);

            $wpdb->insert($wpdb->prefix . 'wpdatatables_columns', $insert_array);
            $column->id = $wpdb->insert_id;
        }

        do_action('wpdatatables_after_insert_column', $column, $table_id);

    }

    // Delete from DB all columns that do not exist any more
    foreach ($columns_to_delete as $delete_header) {
        $wpdb->delete(
            $wpdb->prefix . "wpdatatables_columns",
            array(
                'orig_header' => $delete_header,
                'table_id' => $table_id
            ),
            array(
                '%s',
                '%d'
            )
        );
    }

    return $columns;
}

/**
 * Tries to generate a WPDataTable object by user's setiings
 */
function wdt_try_generate_table($type, $content)
{
    $tbl = new WPDataTable();
    $result = array();

    do_action('wpdatatables_try_generate_table', $type, $content);

    $table_params = array('limit' => '10');
    switch ($type) {
        //[<-- Full version -->]//
        case 'mysql' :
        case 'manual' :
            try {
                $tbl->queryBasedConstruct($content, array(), $table_params, true);
                $result['table'] = $tbl;
            } catch (Exception $e) {
                $result['error'] = $e->getMessage();
                return $result;
            }
            break;
        //[<--/ Full version -->]//
        case 'csv' :
        case 'xls' :
            try {
                $tbl->excelBasedConstruct($content, $table_params);
                $result['table'] = $tbl;
            } catch (Exception $e) {
                $result['error'] = $e->getMessage();
                return $result;
            }
            break;
        case 'xml' :
            try {
                $tbl->XMLBasedConstruct($content, $table_params);
                $result['table'] = $tbl;
            } catch (Exception $e) {
                $result['error'] = $e->getMessage();
                return $result;
            }
            break;
        case 'json' :
            try {
                $tbl->jsonBasedConstruct($content, $table_params);
                $result['table'] = $tbl;
            } catch (Exception $e) {
                $result['error'] = $e->getMessage();
                return $result;
            }
            break;
        case 'serialized' :
            try {
                $array = unserialize(WDTTools::curlGetData($content));
                $tbl->arrayBasedConstruct($array, $table_params);
                $result['table'] = $tbl;
            } catch (Exception $e) {
                $result['error'] = $e->getMessage();
                return $result;
            }
            break;
        //[<-- Full version -->]//
        case 'google_spreadsheet':
            try {
                $array = WDTTools::extractGoogleSpreadsheetArray($content);
                if (empty($array)) {
                    $result['error'] = __(
                        'Could not read Google spreadsheet, please check if the URL is correct and the spreadsheet is published to everyone',
                        'wpdatatables'
                    );
                }
                $tbl->arrayBasedConstruct($array, $table_params);
                $result['table'] = $tbl;
            } catch (Exception $e) {
                $result['error'] = $e->getMessage();
                return $result;
            }
            break;
        //[<--/ Full version -->]//
    }

    $result = apply_filters('wpdatatables_try_generate_table_result', $result);

    return $result;
}

function wpdatatables_enqueue_editing_scripts()
{
    global $wdt_admin_translation_array;
    // Admin JS
    wp_enqueue_script('wpdatatables-admin', WDT_JS_PATH . 'wpdatatables/wpdatatables_admin.js');
    // Google Charts
    wp_enqueue_script('wdt_google_charts', 'https://www.google.com/jsapi');
    // Selecter
    wp_enqueue_script('wpdatatables-selecter', WDT_JS_PATH . 'selecter/jquery.fs.selecter.min.js');
    wp_enqueue_style('wpdatatables-selecter', WDT_CSS_PATH . 'jquery.fs.selecter.css');
    // Popup
    wp_enqueue_script('wpdatatables-popup', WDT_JS_PATH . 'popup/jquery.remodal.min.js');
    wp_enqueue_style('wpdatatables-popup', WDT_CSS_PATH . 'jquery.remodal.css');
    // JsRender
    wp_enqueue_script('wpdatatables-jsrender', WDT_JS_PATH . 'jsrender/jsrender.min.js');
    //[<-- Full version -->]//
    // iCheck
    wp_enqueue_script('wpdatatables-icheck', WDT_JS_PATH . 'icheck/icheck.min.js');
    wp_enqueue_style('wpdatatables-icheck', WDT_CSS_PATH . 'icheck.minimal.css');
    // Responsive
    wp_enqueue_script('wpdatatables-responsive', WDT_JS_PATH . 'responsive/datatables.responsive.min.js');
    // Datepicker
    wp_enqueue_script('pickadate-main', WDT_JS_PATH . 'datepicker/picker.js');
    wp_enqueue_script('pickadate-date', WDT_JS_PATH . 'datepicker/picker.date.js');
    wp_enqueue_script('pickadate-time', WDT_JS_PATH . 'datepicker/picker.time.js');
    //[<--/ Full version -->]//
    // Table create/edit JS
    wp_enqueue_script('wpdatatables-edit', WDT_JS_PATH . 'wpdatatables/wpdatatables_edit_table.js');
    // Media upload
    wp_enqueue_script('media-upload');
    // ACE syntax highlight
    wp_enqueue_script('wpdatatables-ace', WDT_JS_PATH . 'ace/ace.js');
    //tags input
    wp_enqueue_script('wpdatatables-tagsinput', WDT_JS_PATH . 'tagsinput/jquery.tagsinput.min.js');
    wp_enqueue_style('wpdatatables-tagsinput', WDT_CSS_PATH . 'jquery.tagsinput.min.css');
    // Localization
    wp_localize_script('wpdatatables-edit', 'wpdatatables_edit_strings', $wdt_admin_translation_array);
    wp_localize_script('wpdatatables-edit', 'wpdatatables_frontend_strings', WDTTools::getTranslationStrings());
    // New Table Tools
    //wp_enqueue_style('wpdt-buttons-css', WDT_JS_PATH.'export-tools/buttons.dataTables.css');
    do_action('wpdatatables_admin_editing_scripts');


}

//[<-- Full version -->]//
/**
 * Helper function to delete manually created table if needed
 */
function wpdatatables_delete_manual_table($id)
{
    global $wpdb;

    // First check if the table is manual, and if it is delete the table from DB
    $tbl_data = wdt_get_table_by_id($id);
    if (!empty($tbl_data['table_type'])) {
        if ($tbl_data['table_type'] == 'manual') {
            $wpdb->query("DROP TABLE {$tbl_data['mysql_table_name']}");
        }
    }

}

//[<--/ Full version -->]//

/**
 * Renders the browser of existing tables
 */
function wpdatatables_browse()
{
    global $wpdb, $wdt_admin_translation_array;
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    if ($action == 'edit') {
        $id = $_GET['table_id'];
        $tpl = new PDTTpl();
        $tpl->setTemplate('edit_table.inc.php');
        wpdatatables_enqueue_editing_scripts();
        $tpl->addData('wpShowTitle', __('Edit wpDataTable', 'wpdatatables'));
        $tpl->addData('table_id', $id);
        $tpl->addData('wdtDateFormat', get_option('wdtDateFormat'));

        $table_data = wdt_get_table_by_id($id);

        if (!empty($table_data['table_type']) && $table_data['table_type'] != 'mysql') {
            $uploads_dir = wp_upload_dir();
            if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                $table_content = str_replace(str_replace('/', '\\', $uploads_dir['basedir']), $uploads_dir['baseurl'], $table_data['content']);
            } else {
                $table_content = str_replace($uploads_dir['basedir'], $uploads_dir['baseurl'], $table_data['content']);
            }
        } else {
            $table_content = '';
        }

        $tpl->addData('table_data', $table_data);
        $tpl->addData('table_content', $table_content);
        $tpl->addData('column_data', wdt_get_columns_by_table_id($id));
        $tpl->addData('wdtUserRoles', get_editable_roles());


        $edit_page = $tpl->returnData();

        $edit_page = apply_filters('wpdatatables_filter_edit_page', $edit_page);

        echo $edit_page;

    } else {
        if ($action == 'delete') {
            $id = $_REQUEST['table_id'];

            if (!is_array($id)) {
                //[<-- Full version -->]//
                wpdatatables_delete_manual_table($id);
                //[<--/ Full version -->]//
                wpdatatables_delete_table( $id );
            } else {
                foreach ($id as $single_id) {
                    //[<-- Full version -->]//
                    wpdatatables_delete_manual_table($single_id);
                    //[<--/ Full version -->]//
                    wpdatatables_delete_table( $single_id );
                }
            }
        }

        $wdtBrowseTable = new WDTBrowseTable();

        $wdtBrowseTable->prepare_items();

        ob_start();
        $wdtBrowseTable->search_box('search', 'search_id');
        $wdtBrowseTable->display();
        $tableHTML = ob_get_contents();
        ob_end_clean();

        $tpl = new PDTTpl();
        // Popup
        $tpl->addJs(WDT_JS_PATH . 'popup/jquery.remodal.min.js');
        $tpl->addCss(WDT_CSS_PATH . 'jquery.remodal.css');
        // Admin JS
        $tpl->addJs(WDT_JS_PATH . 'wpdatatables/wpdatatables_admin.js');
        $tpl->setTemplate('browse.inc.php');
        $tpl->addData('tableHTML', $tableHTML);
        $browse_page = $tpl->returnData();
        $browse_page = apply_filters('wpdatatables_filter_browse_page', $browse_page);

        echo $browse_page;
    }

    do_action('wpdatatables_browse_page');
}

/**
 * Delete a table
 */
function wpdatatables_delete_table( $id ){
    global $wpdb;
    if( empty( $id ) || !current_user_can('manage_options') ){ return false; }

    $wpdb->query("DELETE
									FROM {$wpdb->prefix}wpdatatables
									WHERE id={$id}");
    $wpdb->query("DELETE
									FROM {$wpdb->prefix}wpdatatables_columns
									WHERE table_id={$id}");
    $wpdb->query("DELETE
									FROM {$wpdb->prefix}wpdatacharts
									WHERE wpdatatable_id={$id}");
}

/**
 * Add new page
 */
function wpdatatables_addnew()
{
    global $wdt_admin_translation_array;

    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $tpl = new PDTTpl();
    wpdatatables_enqueue_editing_scripts();
    $tpl->setTemplate('edit_table.inc.php');
    $tpl->addData('wdtUserRoles', get_editable_roles());
    $tpl->addData('wdtDateFormat', get_option('wdtDateFormat'));
    $tpl->addData('table_content', '');
    $tpl->addData('wpShowTitle', 'Add a new wpDataTable');
    $tpl->addData('table_data', array('tabletools_config' => array('print' => 1, 'copy' => 1, 'excel' => 1, 'csv' => 1, 'pdf' => 1)));
    $newtable_page = $tpl->returnData();

    $newtable_page = apply_filters('wpdatatables_filter_new_table_page', $newtable_page);

    echo $newtable_page;

    do_action('wpdatatables_addnew_page');

}

/**
 * Addons page
 **/
function wpdatatables_addons()
{
    global $wdt_admin_translation_array;
    $tpl = new PDTTpl();
    $tpl->setTemplate('addons.inc.php');
    $addons_page = apply_filters('wpdatatables_filter_new_table_page', $tpl->returnData());
    echo $addons_page;
    do_action('wpdatatables_addons_page');

}


/**
 * Charts browse
 */
function wpdatatables_charts()
{
    global $wdt_admin_translation_array;

    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $tpl = new PDTTpl();

    /**
     * Handle deleting
     */
    if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'delete')) {
        $delete_id = $_REQUEST['chart_id'];
        if (is_array($delete_id)) {
            foreach ($delete_id as $single_delete_id) {
                $single_delete_id = filter_var($single_delete_id, FILTER_SANITIZE_NUMBER_INT);
                wpDataChart::deleteChart($single_delete_id);
            }
        } else {
            $delete_id = filter_var($delete_id, FILTER_SANITIZE_NUMBER_INT);
            wpDataChart::deleteChart($delete_id);
        }
    }


    // Admin JS
    wp_enqueue_script('wpdatatables-admin', WDT_JS_PATH . 'wpdatatables/wpdatatables_admin.js');
    // Selecter
    wp_enqueue_script('wpdatatables-selecter', WDT_JS_PATH . 'selecter/jquery.fs.selecter.min.js');
    wp_enqueue_style('wpdatatables-selecter', WDT_CSS_PATH . 'jquery.fs.selecter.css');
    //[<-- Full version -->]//
    // iCheck
    wp_enqueue_script('wpdatatables-icheck', WDT_JS_PATH . 'icheck/icheck.min.js');
    wp_enqueue_style('wpdatatables-icheck', WDT_CSS_PATH . 'icheck.minimal.css');
    //[<--/ Full version -->]//
    // Popup
    wp_enqueue_script('wpdatatables-popup', WDT_JS_PATH . 'popup/jquery.remodal.min.js');
    wp_enqueue_style('wpdatatables-popup', WDT_CSS_PATH . 'jquery.remodal.css');

    wp_localize_script('wpdatatables-edit', 'wpdatatables_edit_strings', $wdt_admin_translation_array);

    $wdtBrowseChartsTable = new WDTBrowseChartsTable();

    $wdtBrowseChartsTable->prepare_items();

    ob_start();
    $wdtBrowseChartsTable->search_box('search', 'search_id');
    $wdtBrowseChartsTable->display();
    $tableHTML = ob_get_contents();
    ob_end_clean();


    $tpl->addData('wdtUserRoles', get_editable_roles());
    $tpl->setTemplate('browse_charts.inc.php');
    $tpl->addData('wpShowTitle', 'Browse wpDataTables Charts');
    $tpl->addData('tableHTML', $tableHTML);
    $browse_charts_page = $tpl->returnData();

    $browse_charts_page = apply_filters('wpdatatables_filter_charts_table_page', $browse_charts_page);

    echo $browse_charts_page;

    do_action('wpdatatables_browse_charts_page');

}

/**
 * Create/edit chart wizard
 */
function wpdatatables_chart_wizard()
{
    global $wdt_admin_translation_array;

    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $tpl = new PDTTpl();

    //[<-- Full version -->]//
    // Google Chart JS
    wp_enqueue_script('wdt_google_charts', '//www.google.com/jsapi');
    // Highcharts JS
    wp_enqueue_script('wdt_highcharts', '//code.highcharts.com/highcharts.js');
    wp_enqueue_script('wdt_highcharts3d', '//code.highcharts.com/highcharts-3d.js');
    wp_enqueue_script('wdt_exporting', '//code.highcharts.com/modules/exporting.js');
    // iCheck
    wp_enqueue_script('wpdatatables-icheck', WDT_JS_PATH . 'icheck/icheck.min.js');
    wp_enqueue_style('wpdatatables-icheck', WDT_CSS_PATH . 'icheck.minimal.css');
    //[<--/ Full version -->]//
    // Admin JS
    wp_enqueue_script('wpdatatables-admin', WDT_JS_PATH . 'wpdatatables/wpdatatables_admin.js');
    // Selecter
    wp_enqueue_script('wpdatatables-selecter', WDT_JS_PATH . 'selecter/jquery.fs.selecter.min.js');
    wp_enqueue_style('wpdatatables-selecter', WDT_CSS_PATH . 'jquery.fs.selecter.css');
    // Popup
    wp_enqueue_script('wpdatatables-popup', WDT_JS_PATH . 'popup/jquery.remodal.min.js');
    wp_enqueue_style('wpdatatables-popup', WDT_CSS_PATH . 'jquery.remodal.css');
    // JsRender
    wp_enqueue_script('wpdatatables-jsrender', WDT_JS_PATH . 'jsrender/jsrender.min.js');
    // ImagePicker
    wp_enqueue_script('wpdatatables-image-picker', WDT_JS_PATH . 'image-picker/image-picker.min.js');
    wp_enqueue_style('wpdatatables-image-picker', WDT_CSS_PATH . 'image-picker.css');
    // Chart wizard JS
    wp_enqueue_script('wpdatatables-chart-wizard', WDT_JS_PATH . 'wpdatatables/wpdatatables_chart_wizard.js');
    //[<-- Full version -->]//
    // Google Chart wpDataTable JS library
    wp_enqueue_script('wpdatatables-google-chart', WDT_JS_PATH . 'wpdatatables/wpdatatables_google_charts.js');
    // Highchart wpDataTable JS library
    wp_enqueue_script('wpdatatables-highcharts', WDT_JS_PATH . 'wpdatatables/wpdatatables_highcharts.js');
    //[<--/ Full version -->]//

    wp_localize_script('wpdatatables-edit', 'wpdatatables_edit_strings', $wdt_admin_translation_array);

    // Edit or add new
    $chart_id = isset($_GET['chart_id']) ? filter_var($_GET['chart_id'], FILTER_SANITIZE_NUMBER_INT) : false;
    if (!empty($chart_id)) {
        $chartObj = new WPDataChart();
        $chartObj->setId($chart_id);
        $chartObj->loadFromDB();
        $chartObj->prepareData();
        $chartObj->shiftStringColumnUp();
    }

    $tpl->setTemplate('chart_wizard.inc.php');
    $tpl->addData('chart_id', $chart_id);
    if (!empty($chart_id)) {
        $tpl->addData('wpShowTitle', __('wpDataTables Chart Edit Wizard', 'wpdatatables'));
        $tpl->addData('chartObj', $chartObj);
    } else {
        $tpl->addData('wpShowTitle', __('wpDataTables Chart Create Wizard', 'wpdatatables'));
    }
    $tpl->addData('chartDataJson', json_encode(array()));
    $chart_wizard_page = $tpl->returnData();

    $chart_wizard_page = apply_filters('wpdatatables_filter_chart_wizard_page', $chart_wizard_page);

    echo $chart_wizard_page;

    do_action('wpdatatables_chart_wizard_page');
}

/**
 * Settings page
 */
function wpdatatables_settings()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }

    wp_enqueue_script('wdt-colorpicker');

    $languages = array();

    foreach (glob(WDT_ROOT_PATH . 'source/lang/*.inc.php') as $lang_filename) {
        $lang_filename = str_replace(WDT_ROOT_PATH . 'source/lang/', '', $lang_filename);
        $name = ucwords(str_replace('_', ' ', $lang_filename));
        $name = str_replace('.inc.php', '', $name);
        $languages[] = array('file' => $lang_filename, 'name' => $name);
    }

    $tpl = new PDTTpl();
    $tpl->setTemplate('settings.inc.php');
    //[<-- Full version insertion #21 -->]//
    $tpl->addData('wpUseSeparateCon', get_option('wdtUseSeparateCon'));
    $tpl->addData('wpMySqlHost', get_option('wdtMySqlHost'));
    $tpl->addData('wpMySqlDB', get_option('wdtMySqlDB'));
    $tpl->addData('wpMySqlUser', get_option('wdtMySqlUser'));
    $tpl->addData('wpMySqlPwd', get_option('wdtMySqlPwd'));
    $tpl->addData('wpMySqlPort', get_option('wdtMySqlPort'));
    $tpl->addData('wpRenderCharts', get_option('wdtRenderCharts'));
    $tpl->addData('wpRenderFilter', get_option('wdtRenderFilter'));
    $tpl->addData('wdtTablesPerPage', get_option('wdtTablesPerPage'));
    $tpl->addData('wdtNumberFormat', get_option('wdtNumberFormat'));
    $tpl->addData('wdtDecimalPlaces', get_option('wdtDecimalPlaces'));
    $tpl->addData('wdtTimepickerRange', get_option('wdtTimepickerRange') != '' ? get_option('wdtTimepickerRange') : 5);
    $tpl->addData('wdtNumbersAlign', get_option('wdtNumbersAlign'));
    $tpl->addData('wdtTabletWidth', get_option('wdtTabletWidth'));
    $tpl->addData('wdtMobileWidth', get_option('wdtMobileWidth'));
    $tpl->addData('wdtCustomJs', get_option('wdtCustomJs'));
    $tpl->addData('wdtCustomCss', get_option('wdtCustomCss'));
    $tpl->addData('wdtMinifiedJs', get_option('wdtMinifiedJs'));
    $tpl->addData('wpDateFormat', get_option('wdtDateFormat'));
    $tpl->addData('wdtTimeFormat', get_option('wdtTimeFormat'));
    $tpl->addData('wpTopOffset', get_option('wdtTopOffset'));
    $tpl->addData('wpLeftOffset', get_option('wdtLeftOffset'));
    $tpl->addData('languages', $languages);
    $tpl->addData('wpInterfaceLanguage', get_option('wdtInterfaceLanguage'));
    $tpl->addData('wdtFonts', wdt_get_system_fonts());
    $tpl->addData('wdtBaseSkin', get_option('wdtBaseSkin'));
    //[<-- Full version -->]//
    $tpl->addData('wdtPurchaseCode', get_option('wdtPurchaseCode'));
    //[<--/ Full version -->]//
    $wpFontColorSettings = get_option('wdtFontColorSettings');
    if (!empty($wpFontColorSettings)) {
        $wpFontColorSettings = unserialize($wpFontColorSettings);
    } else {
        $wpFontColorSettings = array();
    }
    // Admin JS
    $tpl->addJs(WDT_JS_PATH . 'wpdatatables/wpdatatables_admin.js');
    // Selecter
    $tpl->addJs(WDT_JS_PATH . 'selecter/jquery.fs.selecter.min.js');
    $tpl->addCss(WDT_CSS_PATH . 'jquery.fs.selecter.css');
    //[<-- Full version -->]//
    // iCheck
    wp_enqueue_script('wpdatatables-icheck', WDT_JS_PATH . 'icheck/icheck.min.js');
    wp_enqueue_style('wpdatatables-icheck', WDT_CSS_PATH . 'icheck.minimal.css');
    //[<--/ Full version -->]//
    // Popup
    $tpl->addJs(WDT_JS_PATH . 'popup/jquery.remodal.min.js');
    $tpl->addCss(WDT_CSS_PATH . 'jquery.remodal.css');

    $tpl->addData('wdtFontColorSettings', $wpFontColorSettings);
    $settings_page = $tpl->returnData();

    $settings_page = apply_filters('wpdatatables_filter_settings_page', $settings_page);

    echo $settings_page;

    do_action('wpdatatables_settings_page');
}

/**
 * Constructor page
 */
function wpdatatables_constructor()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }

    // Admin JS
    wp_enqueue_script('wpdatatables-admin', WDT_JS_PATH . 'wpdatatables/wpdatatables_admin.js');
    // Popup
    wp_enqueue_script('wpdatatables-popup', WDT_JS_PATH . 'popup/jquery.remodal.min.js');
    wp_enqueue_style('wpdatatables-popup', WDT_CSS_PATH . 'jquery.remodal.css');

    wp_enqueue_script('wpdatatables-ace', WDT_JS_PATH . 'ace/ace.js');
    wp_enqueue_script('wpdatatables-jsrender', WDT_JS_PATH . 'jsrender/jsrender.min.js');
    //[<-- Full version -->]//
    wp_enqueue_script('wpdatatables-constructor', WDT_JS_PATH . 'wpdatatables/wpdatatables_constructor.js');
    //[<--/ Full version -->]//
    wp_enqueue_script('wpdatatables-selecter', WDT_JS_PATH . 'selecter/jquery.fs.selecter.min.js');
    wp_enqueue_style('wpdatatables-selecter', WDT_CSS_PATH . 'jquery.fs.selecter.css');
    wp_enqueue_script('wpdatatables-tagsinput', WDT_JS_PATH . 'tagsinput/jquery.tagsinput.min.js');
    wp_enqueue_style('wpdatatables-tagsinput', WDT_CSS_PATH . 'jquery.tagsinput.min.css');
    //[<-- Full version insertion #25 -->]//

    $translatedStrings = array(
        'new_column_name' => __('New column', 'wpdatatables'),
        'select_excel_csv' => __('Select an Excel or CSV file', 'wpdatatables'),
        'choose_file' => __('Choose file', 'wpdatatables'),
        'fileupload_empty_file' => __('Please upload or choose a file from Media Library!', 'wpdatatables'),
        'error_creating' => __('Unfortunately an SQL error was thrown when Table Constructor tried to create the table, probably the constructed query is incorrect. Please modify the query so that it would return results.','wpdatatables'),
        'sql_error' => __( 'SQL error','wpdatatables' ),
        'error' => __( 'Error', 'wpdatatables' )
    );

    wp_localize_script('wpdatatables-jsrender', 'wdt_constructor_strings', $translatedStrings);

    $tpl = new PDTTpl();
    $tpl->setTemplate('constructor.inc.php');
    $constructor_page = $tpl->returnData();

    $constructor_page = apply_filters('wpdatatables_filter_constructor_page', $constructor_page);

    echo $constructor_page;

    do_action('wpdatatables_constructor_page');

}

/**
 * Editor page
 */
function wpdatatables_editor()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }

    wp_enqueue_script('wpdatatables-jsrender', WDT_JS_PATH . 'jsrender/jsrender.min.js');
    wp_enqueue_script('wpdatatables-selecter', WDT_JS_PATH . 'selecter/jquery.fs.selecter.min.js');
    wp_enqueue_style('wpdatatables-selecter', WDT_CSS_PATH . 'jquery.fs.selecter.css');

    $table_id = $_GET['table_id'];

    $table_data = wdt_get_table_by_id($table_id);
    $column_data = wdt_get_columns_by_table_id($table_id);

    // Do action before rendering a table
    do_action('wpdatatables_before_render_table', $table_id);

    // Preparing column properties
    $column_order = array();
    $column_titles = array();
    $column_widths = array();
    $column_types = array();
    $column_possible_values = array();
    foreach ($column_data as $column) {
        $column_order[(int)$column->pos] = $column->orig_header;
        if ($column->display_header) {
            $column_titles[$column->orig_header] = $column->display_header;
        }
        if ($column->width) {
            $column_widths[$column->orig_header] = $column->width;
        }
        if ($column->column_type != 'autodetect') {
            $column_types[$column->orig_header] = $column->column_type;
        }
        $column_possible_values[$column->orig_header] = $column->possible_values;
    }

    if (isset($_GET['table_type']) && $_GET['table_type'] == 'excel') {
        $tbl = new WPExcelDataTable();
    } else {
        $tbl = new WPDataTable();
    }

    $tbl->setWpId($table_id);

    //[<-- Full version -->]//
    $tbl->queryBasedConstruct($table_data['content'], array(),
        array(
            'data_types' => $column_types,
            'column_titles' => $column_titles
        )
    );

    $tbl->setColumnsPossibleValues($column_possible_values);
    //[<--/ Full version -->]//

    $tbl->reorderColumns($column_order);
    $tbl->wdtDefineColumnsWidth($column_widths);

    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-progressbar');
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_script('jquery-ui-button');
    wp_enqueue_style('dashicons');
    wp_enqueue_script('wdt_google_charts', 'https://www.google.com/jsapi');
    wp_enqueue_script('formstone-selecter', WDT_JS_PATH . 'selecter/jquery.fs.selecter.min.js');
    wp_enqueue_style('formstone-selecter', WDT_CSS_PATH . 'jquery.fs.selecter.css');
    //[<-- Full version -->]//
    wp_enqueue_script('moment', WDT_JS_PATH . 'moment/moment.js');
    wp_enqueue_script('wpdatatables-icheck', WDT_JS_PATH . 'icheck/icheck.min.js');
    wp_enqueue_style('wpdatatables-icheck', WDT_CSS_PATH . 'icheck.minimal.css');
    wp_enqueue_script('pickadate-main', WDT_JS_PATH . 'datepicker/picker.js');
    wp_enqueue_script('pickadate-date', WDT_JS_PATH . 'datepicker/picker.date.js');
    wp_enqueue_script('pickadate-time', WDT_JS_PATH . 'datepicker/picker.time.js');
    wp_enqueue_style('pickadate-main', WDT_CSS_PATH . 'datepicker.default.css');
    wp_enqueue_style('pickadate-date', WDT_CSS_PATH . 'datepicker.default.date.css');
    wp_enqueue_style('pickadate-time',  WDT_CSS_PATH.'datepicker.default.time.css');
    //[<--/ Full version -->]//
    wp_enqueue_script('remodal-popup', WDT_JS_PATH . 'popup/jquery.remodal.min.js');
    wp_enqueue_style('remodal-popup', WDT_CSS_PATH . 'jquery.remodal.css');
    wp_enqueue_script('wpdatatables-tagsinput', WDT_JS_PATH . 'tagsinput/jquery.tagsinput.min.js');
    wp_enqueue_style('wpdatatables-tagsinput', WDT_CSS_PATH . 'jquery.tagsinput.min.css');
    wp_enqueue_script('wpdatatables-editor', WDT_JS_PATH . 'wpdatatables/wpdatatables_editor.js');
    wp_enqueue_media();

    //[<-- Full version -->]//
    // Check the saerch values passed from URL
    if (isset($_GET['wdt_search'])) {
        $tbl->setDefaultSearchValue($_GET['wdt_search']);
    }
    //[<--/ Full version -->]//

    foreach ($column_data as $column) {
        // Set CSS class
        $tbl->getColumn($column->orig_header)->addCSSClass($column->css_class);
        // set visibility
        if (!$column->visible) {
            $tbl->getColumn($column->orig_header)->hide();
        }

        //[<-- Full version -->]//
        // Set filter types
        $tbl->getColumn($column->orig_header)->setFilterType($column->filter_type);
        // Set default value
        $tbl->getColumn($column->orig_header)->setDefaultValue($column->default_value);

        // Check the default values passed from URL
        if (isset($_GET['wdt_column_filter'])) {
            foreach ($_GET['wdt_column_filter'] as $fltColKey => $fltDefVal) {
                $tbl->getColumn($fltColKey)->setDefaultValue($fltDefVal);
            }
        }

        // Set hiding on phones and tablets for responsiveness
        if ($tbl->isResponsive()) {
            if ($column->hide_on_phones) {
                $tbl->getColumn($column->orig_header)->hideOnPhones();
            }
            if ($column->hide_on_tablets) {
                $tbl->getColumn($column->orig_header)->hideOnTablets();
            }
        }
        //[<--/ Full version -->]//

        // if grouping enabled for this column, passing it to table class
        if ($column->group_column) {
            $tbl->groupByColumn($column->orig_header);
        }
        if ($column->sort_column !== '0') {
            $tbl->setDefaultSortColumn($column->orig_header);
            if ($column->sort_column == '1') {
                $tbl->setDefaultSortDirection('ASC');
            } elseif ($column->sort_column == '2') {
                $tbl->setDefaultSortDirection('DESC');
            }
        }
        if ($table_data['chart'] != 'none') {
            if ($column->use_in_chart) {
                $tbl->addChartSeries($column->orig_header);
            }
            if ($column->chart_horiz_axis) {
                $tbl->setChartHorizontalAxis($column->orig_header);
            }
        }
        // Set ID column if specified
        if ($column->id_column) {
            $tbl->setIdColumnKey($column->orig_header);
        }

        //[<-- Full version -->]//
        // Set front-end editor input type
        $tbl->getColumn($column->orig_header)->setInputType($column->input_type);
        //[<--/ Full version -->]//
    }
    $output_str = '';

    if ($table_data['title']) {
        $output_str .= apply_filters('wpdatatables_filter_table_title', (empty($table_data['title']) ? '' : '<h2>' . $table_data['title'] . '</h2>'), $table_id);
    }

    $tbl->disableTT();

    //[<-- Full version -->]//
    $tbl->enableEditing();
    if ($table_data['inline_editing']) {
        $tbl->enableInlineEditing();
    }
    if ($table_data['popover_tools']) {
        $tbl->enablePopoverTools();
    }
    $tbl->enableServerProcessing();
    //[<--/ Full version -->]//

    if (get_option('wdtInterfaceLanguage') != '') {
        $tbl->setInterfaceLanguage(get_option('wdtInterfaceLanguage'));
    }

    $output_str .= $tbl->generateTable();

    $tpl = new PDTTpl();
    $tpl->addData('table_id', $table_id);
    $tpl->addData('table_to_edit', $output_str);
    $tpl->addData('column_data', $column_data);
    $tpl->setTemplate('editor.inc.php');
    $editor_page = $tpl->returnData();
    $editor_page = apply_filters('wpdatatables_filter_editor_page', $editor_page);

    echo $editor_page;

    do_action('wpdatatables_settings_page');

}

?>