forked from Michel2/wp-jquery-datatable
Compare commits
15
Commits
6143b0d88f
...
3632c834ac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3632c834ac | ||
|
|
dbe5b03e9e | ||
|
|
3f85ed6f74 | ||
|
|
abf0b19c0e | ||
|
|
390c27aee3 | ||
|
|
23e0878cd0 | ||
|
|
507fe4412c | ||
|
|
d42ff6fc14 | ||
|
|
d1db4ebbed | ||
|
|
5193324625 | ||
|
|
4bf2d4c049 | ||
|
|
0fd3f36078 | ||
|
|
36b4e606be | ||
|
|
3841f4e246 | ||
|
|
e84c5d66da |
@@ -0,0 +1,313 @@
|
||||
{
|
||||
"aria": {
|
||||
"orderable": "Sorteren inschakelen",
|
||||
"orderableRemove": "Sortering verwijderen",
|
||||
"orderableReverse": "Sortering omkeren",
|
||||
"paginate": {
|
||||
"first": "Eerste",
|
||||
"last": "Laatste",
|
||||
"next": "Volgende",
|
||||
"previous": "Vorige"
|
||||
}
|
||||
},
|
||||
"autoFill": {
|
||||
"cancel": "Annuleren",
|
||||
"fill": "Vul alle cellen met <i>%d<\/i>",
|
||||
"fillHorizontal": "Vul cellen horizontaal",
|
||||
"fillVertical": "Vul cellen verticaal",
|
||||
"info": ""
|
||||
},
|
||||
"buttons": {
|
||||
"collection": "Verzameling",
|
||||
"colvis": "Kolom zichtbaarheid",
|
||||
"colvisRestore": "Herstel zichtbaarheid",
|
||||
"copy": "Kopieer",
|
||||
"copyKeys": "Klik ctrl of u2318 + C om de tabeldata to kopiëren naar je klembord. Om te annuleren klik hier of klik op escape.",
|
||||
"copySuccess": {
|
||||
"_": "%ds regels naar klembord gekopieerd",
|
||||
"1": "1 regel naar klembord gekopieerd"
|
||||
},
|
||||
"copyTitle": "Kopieer naar klembord",
|
||||
"createState": "Maak staat",
|
||||
"csv": "CSV",
|
||||
"excel": "Excel",
|
||||
"pageLength": {
|
||||
"_": "Toon %d regels",
|
||||
"-1": "Toon alle regels",
|
||||
"1": "Toon 1 regel"
|
||||
},
|
||||
"pdf": "PDF",
|
||||
"print": "Print",
|
||||
"removeAllStates": "Verwijder alle",
|
||||
"removeState": "Verwijder",
|
||||
"renameState": "Hernoem",
|
||||
"savedStates": "Opgeslagen",
|
||||
"stateRestore": "Preset %d",
|
||||
"updateState": "Bijwerken"
|
||||
},
|
||||
"columnControl": {
|
||||
"buttons": {
|
||||
"searchClear": "Reset zoekactie"
|
||||
},
|
||||
"colVis": "Kolom zichtbaarheid",
|
||||
"colVisDropdown": "Kolom zichtbaarheid",
|
||||
"dropdown": "Meer...",
|
||||
"list": {
|
||||
"all": "Selecteer alles",
|
||||
"empty": "Leeg",
|
||||
"none": "Deselecteer",
|
||||
"search": "Zoeken..."
|
||||
},
|
||||
"orderAddAsc": "Sortering toevoegen (oplopend)",
|
||||
"orderAddDesc": "Sortering toevoegen (aflopend)",
|
||||
"orderAsc": "Oplopend sorteren",
|
||||
"orderClear": "Reset sortering",
|
||||
"orderDesc": "Aflopend sorteren",
|
||||
"orderRemove": "Verwijder van sortering",
|
||||
"reorder": "Kolommen herschikken",
|
||||
"reorderLeft": "Verplaats kolom links",
|
||||
"reorderRight": "Verplaatst kolom rechts",
|
||||
"search": {
|
||||
"datetime": {
|
||||
"empty": "Leeg",
|
||||
"equal": "Gelijk aan",
|
||||
"greater": "Na",
|
||||
"less": "Vóór",
|
||||
"notEmpty": "Niet leeg",
|
||||
"notEqual": "Niet gelijk aan"
|
||||
},
|
||||
"number": {
|
||||
"empty": "Leeg",
|
||||
"equal": "Gelijk aan",
|
||||
"greater": "Meer dan",
|
||||
"greaterOrEqual": "Meer of gelijk",
|
||||
"less": "Minder dan",
|
||||
"lessOrEqual": "Minder of gelijk",
|
||||
"notEmpty": "Niet leeg",
|
||||
"notEqual": "Niet gelijk aan"
|
||||
},
|
||||
"text": {
|
||||
"contains": "Bevat",
|
||||
"empty": "Leeg",
|
||||
"ends": "Eindigt",
|
||||
"equal": "Gelijk aan",
|
||||
"notContains": "Bevat niet",
|
||||
"notEmpty": "Niet leeg",
|
||||
"notEqual": "Niet gelijk aan",
|
||||
"starts": "Begint"
|
||||
}
|
||||
},
|
||||
"searchClear": "Reset zoekactie",
|
||||
"searchDropdown": "Zoeken"
|
||||
},
|
||||
"datetime": {
|
||||
"amPm": {
|
||||
"0": "vm",
|
||||
"1": "nm"
|
||||
},
|
||||
"hours": "Uur",
|
||||
"minutes": "Minuut",
|
||||
"months": {
|
||||
"0": "Januari",
|
||||
"1": "Februari",
|
||||
"10": "November",
|
||||
"11": "December",
|
||||
"2": "Maart",
|
||||
"3": "April",
|
||||
"4": "Mei",
|
||||
"5": "Juni",
|
||||
"6": "Juli",
|
||||
"7": "Augustus",
|
||||
"8": "September",
|
||||
"9": "Oktober"
|
||||
},
|
||||
"next": "Volgende",
|
||||
"previous": "Vorige",
|
||||
"seconds": "Seconde",
|
||||
"unknown": "Onbekend",
|
||||
"weekdays": {
|
||||
"0": "Zo",
|
||||
"1": "Ma",
|
||||
"2": "Di",
|
||||
"3": "Wo",
|
||||
"4": "Do",
|
||||
"5": "Vr",
|
||||
"6": "Za"
|
||||
}
|
||||
},
|
||||
"decimal": "",
|
||||
"editor": {
|
||||
"close": "Sluiten",
|
||||
"create": {
|
||||
"button": "Nieuw",
|
||||
"submit": "Toevoegen",
|
||||
"title": "Voeg nieuwe gegevens toe"
|
||||
},
|
||||
"edit": {
|
||||
"button": "Wijzigen",
|
||||
"submit": "Wijzigen",
|
||||
"title": "Wijzig gegevens"
|
||||
},
|
||||
"error": {
|
||||
"system": "Er is een fout gebeurd"
|
||||
},
|
||||
"multi": {
|
||||
"info": "De geselecteerde items bevatten verschillende waarden voor deze invoer. Om alle items voor deze invoer op dezelfde waarde te zetten, klik of tik hier, zoniet zullen de individuele waarden behouden blijven.",
|
||||
"noMulti": "Deze invoer kan individueel gewijzigd worden, maar niet als deel van een groep.",
|
||||
"restore": "Wijzigingen ongedaan maken",
|
||||
"title": "Meerdere waarden"
|
||||
},
|
||||
"remove": {
|
||||
"button": "Verwijderen",
|
||||
"confirm": {
|
||||
"_": "Bent u zeker dat u %d rijen wil verwijderen?",
|
||||
"1": "Bent u zeker dat u 1 rij wil verwijderen?"
|
||||
},
|
||||
"submit": "Verwijder",
|
||||
"title": "Verwijder"
|
||||
}
|
||||
},
|
||||
"emptyTable": "Geen resultaten aanwezig in de tabel",
|
||||
"info": "_START_ tot _END_ van _TOTAL_ resultaten",
|
||||
"infoEmpty": "Geen resultaten om weer te geven",
|
||||
"infoFiltered": " (gefilterd uit _MAX_ resultaten)",
|
||||
"infoPostFix": "",
|
||||
"infoThousands": ".",
|
||||
"lengthLabels": {
|
||||
"-1": "Alle"
|
||||
},
|
||||
"lengthMenu": "_MENU_ resultaten weergeven",
|
||||
"loadingRecords": "Een moment geduld aub - bezig met laden...",
|
||||
"orderClear": "Reset sortering",
|
||||
"processing": "Verwerken...",
|
||||
"search": "Zoeken:",
|
||||
"searchBuilder": {
|
||||
"add": "Toevoegen",
|
||||
"button": {
|
||||
"_": "Zoekwizard (%d)",
|
||||
"0": "Zoekwizard"
|
||||
},
|
||||
"clearAll": "Verwijder alles",
|
||||
"condition": "Conditie",
|
||||
"conditions": {
|
||||
"array": {
|
||||
"contains": "Bevat",
|
||||
"empty": "Leeg",
|
||||
"equals": "Gelijk aan",
|
||||
"not": "Niet",
|
||||
"notEmpty": "Niet leeg",
|
||||
"without": "Zonder"
|
||||
},
|
||||
"date": {
|
||||
"after": "Na",
|
||||
"before": "Voor",
|
||||
"between": "Tussen",
|
||||
"empty": "Leeg",
|
||||
"equals": "Gelijk aan",
|
||||
"not": "Niet",
|
||||
"notBetween": "Niet tussen",
|
||||
"notEmpty": "Niet leeg"
|
||||
},
|
||||
"number": {
|
||||
"between": "Tussen",
|
||||
"empty": "Leeg",
|
||||
"equals": "Gelijk aan",
|
||||
"gt": "Groter dan",
|
||||
"gte": "Groter dan of gelijk aan",
|
||||
"lt": "Kleiner dan",
|
||||
"lte": "kleiner dan of gelijk aan",
|
||||
"not": "Niet",
|
||||
"notBetween": "Niet tussen",
|
||||
"notEmpty": "Niet leeg"
|
||||
},
|
||||
"string": {
|
||||
"contains": "Bevat",
|
||||
"empty": "Leeg",
|
||||
"endsWith": "Eindigt met",
|
||||
"equals": "Gelijk aan",
|
||||
"not": "Niet",
|
||||
"notContains": "Zonder",
|
||||
"notEmpty": "Niet leeg",
|
||||
"notEndsWith": "Eindigt niet met",
|
||||
"notStartsWith": "Begint niet met",
|
||||
"startsWith": "Start met"
|
||||
}
|
||||
},
|
||||
"data": "Data",
|
||||
"deleteTitle": "Verwijder",
|
||||
"leftTitle": "Afwijkende criteria",
|
||||
"logicAnd": "En",
|
||||
"logicOr": "Of",
|
||||
"rightTitle": "Criteria inspringen",
|
||||
"search": "Zoeken",
|
||||
"title": {
|
||||
"_": "Zoekwizard (%d) ",
|
||||
"0": "Zoekwizard"
|
||||
},
|
||||
"value": "Waarde"
|
||||
},
|
||||
"searchPanes": {
|
||||
"clearMessage": "Alles leegmaken",
|
||||
"collapse": {
|
||||
"_": "Zoekpanelen (%d)",
|
||||
"0": "Zoekpanelen"
|
||||
},
|
||||
"collapseMessage": "Instorten",
|
||||
"count": "{total}",
|
||||
"countFiltered": "{shown} ({total})",
|
||||
"emptyMessage": "<em>Leeg<\/em>",
|
||||
"emptyPanes": "Geen zoekpanelen",
|
||||
"loadMessage": "Zoekpanelen laden...",
|
||||
"showMessage": "Alles weergeven",
|
||||
"title": "%d filters actief"
|
||||
},
|
||||
"searchPlaceholder": "",
|
||||
"select": {
|
||||
"cells": {
|
||||
"_": "%d cellen geselecteerd",
|
||||
"0": "",
|
||||
"1": "1 cel geselecteerd"
|
||||
},
|
||||
"columns": {
|
||||
"_": "%d kolommen geselecteerd",
|
||||
"0": "",
|
||||
"1": "1 kolom geselecteerd"
|
||||
},
|
||||
"rows": {
|
||||
"_": "%d rijen geselecteerd",
|
||||
"0": "",
|
||||
"1": "1 rij geselecteerd"
|
||||
}
|
||||
},
|
||||
"stateRestore": {
|
||||
"creationModal": {
|
||||
"button": "Aanmaken",
|
||||
"columns": {
|
||||
"search": "Zoeken in kolom",
|
||||
"visible": "Kolom tonen"
|
||||
},
|
||||
"name": "Naam",
|
||||
"order": "Sorteervolgorde",
|
||||
"paging": "Paginering",
|
||||
"scroller": "Meescrollen",
|
||||
"search": "Zoeken",
|
||||
"searchBuilder": "SearchBuilder",
|
||||
"select": "Selecteer",
|
||||
"title": "Nieuwe staat aanmaken",
|
||||
"toggleLabel": "Bevat"
|
||||
},
|
||||
"duplicateError": "Staat bestaat al",
|
||||
"emptyError": "Naam kan niet leeg zijn",
|
||||
"emptyStates": "Geen beschikbare staten",
|
||||
"removeConfirm": "Weet u zeker dat u deze wil verwijderen:",
|
||||
"removeError": "De verwijdering is mislukt",
|
||||
"removeJoiner": "en",
|
||||
"removeSubmit": "Verwijder",
|
||||
"removeTitle": "Verwijder staat",
|
||||
"renameButton": "Hernoem",
|
||||
"renameLabel": "Nieuwe naam voor staat",
|
||||
"renameTitle": "Hernoem staat"
|
||||
},
|
||||
"thousands": ".",
|
||||
"zeroRecords": "Geen resultaten gevonden"
|
||||
}
|
||||
+15
@@ -79,6 +79,21 @@ Is this plugin prepared for multisites? Yes.
|
||||
* Added DataTables language support for 'search'.
|
||||
* Added VSCode settings.json for formatOnSave.
|
||||
* Added .gitignore.
|
||||
* Added security measurement to prevent the public to run the php-script directly.
|
||||
* Changed the registering of settings during installation to an array.
|
||||
* Changed the unregistering of settings during uninstallation to an array.
|
||||
* Deleted the setting of unnecessary variables under wp_jdt_activate_plugin() and made all the if statements strict.
|
||||
* Changed the user role for the options page from 'administrator' to 'manage_options'.
|
||||
* Added a check for the options page to only load if the user has sufficient rights.
|
||||
* Changed the radio buttons on the options page to use the WordPress checked() function.
|
||||
* Changed get_option() for the options page to make use a $default_value.
|
||||
* Rewrite of the wp_jdt_shortcode() function to put security measuremnts in place, better fallback and loading the JS script in the footer.
|
||||
* Removed a new line and some commented code no longer used.
|
||||
* Removed some unnecessary <br> tags.
|
||||
* Removed the extra Select option from the page lenght menu.
|
||||
* Added the default page lenghts and the option for All in the page lenght dropdown.
|
||||
* Added the choosen page lenght as an option to the dropdown if it's not one of the default options.
|
||||
* Changed the language for DataTables to make use of the i18n plug-in json file and added the Dutch translation file.
|
||||
|
||||
= 4.1.0 =
|
||||
* Compatibility with WordPress version 6.7.1
|
||||
|
||||
+187
-233
@@ -9,40 +9,31 @@
|
||||
* WordPress Tested up to: 7.0.2
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
die('Invalid request.');
|
||||
}
|
||||
|
||||
register_activation_hook(__FILE__, 'wp_jdt_activate_plugin');
|
||||
function wp_jdt_activate_plugin()
|
||||
{
|
||||
|
||||
$fields = array(
|
||||
'wp_jdt_info',
|
||||
'wp_jdt_paging',
|
||||
// 'wp_jdt_paging_type',
|
||||
// 'wp_jdt_page_length',
|
||||
'wp_jdt_b_length_change',
|
||||
'wp_jdt_ordering',
|
||||
// 'wp_jdt_order_row',
|
||||
// 'wp_jdt_order_row_sort',
|
||||
'wp_jdt_searching',
|
||||
);
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$data = get_option($field);
|
||||
if ($data == FALSE) {
|
||||
if (get_option($field) === false) {
|
||||
update_option($field, 'true');
|
||||
}
|
||||
}
|
||||
|
||||
$data = get_option('wp_jdt_paging_type');
|
||||
($data == FALSE) ? update_option('wp_jdt_paging_type', 'simple') : '';
|
||||
|
||||
$data = get_option('wp_jdt_page_length');
|
||||
($data == FALSE) ? update_option('wp_jdt_page_length', '10') : '';
|
||||
|
||||
$data = get_option('wp_jdt_order_row');
|
||||
($data == FALSE) ? update_option('wp_jdt_order_row', '0') : '';
|
||||
|
||||
$data = get_option('wp_jdt_order_row_sort');
|
||||
($data == FALSE) ? update_option('wp_jdt_order_row_sort', 'desc') : '';
|
||||
if (get_option('wp_jdt_paging_type') === false) update_option('wp_jdt_paging_type', 'simple');
|
||||
if (get_option('wp_jdt_page_length') === false) update_option('wp_jdt_page_length', '10');
|
||||
if (get_option('wp_jdt_order_row') === false) update_option('wp_jdt_order_row', '0');
|
||||
if (get_option('wp_jdt_order_row_sort') === false) update_option('wp_jdt_order_row_sort', 'desc');
|
||||
}
|
||||
|
||||
add_action('admin_menu', 'wp_jdt_create_menu');
|
||||
@@ -50,7 +41,7 @@ function wp_jdt_create_menu()
|
||||
{
|
||||
|
||||
//create admin side menu
|
||||
add_options_page(__('WP jQuery DataTable Settings', 'wp-jquery-datatable'), __('WP jQuery DataTable', 'wp-jquery-datatable'), 'administrator', 'wp-jdt', 'wp_jdt_settings_page');
|
||||
add_options_page(__('WP jQuery DataTable Settings', 'wp-jquery-datatable'), __('WP jQuery DataTable', 'wp-jquery-datatable'), 'manage_options', 'wp-jdt', 'wp_jdt_settings_page');
|
||||
|
||||
//call register settings function
|
||||
add_action('admin_init', 'wp_jdt_settings');
|
||||
@@ -59,29 +50,39 @@ function wp_jdt_create_menu()
|
||||
function wp_jdt_settings()
|
||||
{
|
||||
//register our settings
|
||||
register_setting('wp-jdt-settings-group', 'wp_jdt_info');
|
||||
register_setting('wp-jdt-settings-group', 'wp_jdt_paging');
|
||||
register_setting('wp-jdt-settings-group', 'wp_jdt_page_length');
|
||||
register_setting('wp-jdt-settings-group', 'wp_jdt_paging_type');
|
||||
register_setting('wp-jdt-settings-group', 'wp_jdt_b_length_change');
|
||||
register_setting('wp-jdt-settings-group', 'wp_jdt_ordering');
|
||||
register_setting('wp-jdt-settings-group', 'wp_jdt_order_row');
|
||||
register_setting('wp-jdt-settings-group', 'wp_jdt_order_row_sort');
|
||||
register_setting('wp-jdt-settings-group', 'wp_jdt_searching');
|
||||
$settings = array(
|
||||
'wp_jdt_info',
|
||||
'wp_jdt_paging',
|
||||
'wp_jdt_page_length',
|
||||
'wp_jdt_paging_type',
|
||||
'wp_jdt_b_length_change',
|
||||
'wp_jdt_ordering',
|
||||
'wp_jdt_order_row',
|
||||
'wp_jdt_order_row_sort',
|
||||
'wp_jdt_searching'
|
||||
);
|
||||
|
||||
foreach ($settings as $setting) {
|
||||
register_setting('wp-jdt-settings-group', $setting);
|
||||
}
|
||||
}
|
||||
|
||||
function wp_jdt_settings_page()
|
||||
{
|
||||
// Admin side page options
|
||||
$wp_jdt_info = get_option('wp_jdt_info');
|
||||
$wp_jdt_paging = get_option('wp_jdt_paging');
|
||||
$wp_jdt_page_length = get_option('wp_jdt_page_length');
|
||||
$wp_jdt_paging_type = get_option('wp_jdt_paging_type');
|
||||
$wp_jdt_b_length_change = get_option('wp_jdt_b_length_change');
|
||||
$wp_jdt_ordering = get_option('wp_jdt_ordering');
|
||||
$wp_jdt_order_row = get_option('wp_jdt_order_row');
|
||||
$wp_jdt_order_row_sort = get_option('wp_jdt_order_row_sort');
|
||||
$wp_jdt_searching = get_option('wp_jdt_searching');
|
||||
if (!current_user_can('manage_options')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$wp_jdt_info = get_option('wp_jdt_info', 'true');
|
||||
$wp_jdt_paging = get_option('wp_jdt_paging', 'true');
|
||||
$wp_jdt_page_length = get_option('wp_jdt_page_length', '10');
|
||||
$wp_jdt_paging_type = get_option('wp_jdt_paging_type', 'simple');
|
||||
$wp_jdt_b_length_change = get_option('wp_jdt_b_length_change', 'true');
|
||||
$wp_jdt_ordering = get_option('wp_jdt_ordering', 'true');
|
||||
$wp_jdt_order_row = get_option('wp_jdt_order_row', '0');
|
||||
$wp_jdt_order_row_sort = get_option('wp_jdt_order_row_sort', 'asc');
|
||||
$wp_jdt_searching = get_option('wp_jdt_searching', 'true');
|
||||
?>
|
||||
<div class='wrap'>
|
||||
<h2><?php _e('WP jQuery DataTable Settings', 'wp-jquery-datatable'); ?></h2>
|
||||
@@ -94,19 +95,8 @@ function wp_jdt_settings_page()
|
||||
<th scope='row'><?php _e('Show Information', 'wp-jquery-datatable'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<?php
|
||||
if ($wp_jdt_info != "false") {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" checked="checked" value="true" name="wp_jdt_info"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" value="false" name="wp_jdt_info"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" value="true" name="wp_jdt_info"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" checked="checked" value="false" name="wp_jdt_info"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" <?php checked($wp_jdt_info, 'true'); ?> value="true" name="wp_jdt_info"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" <?php checked($wp_jdt_info, 'false'); ?> value="false" name="wp_jdt_info"> <span><?php _e('No'); ?></span></label>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -115,19 +105,8 @@ function wp_jdt_settings_page()
|
||||
<th scope='row'><?php _e('Pagination'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<?php
|
||||
if ($wp_jdt_paging != "false") {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" checked="checked" value="true" name="wp_jdt_paging"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" value="false" name="wp_jdt_paging"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" value="true" name="wp_jdt_paging"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" checked="checked" value="false" name="wp_jdt_paging"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" <?php checked($wp_jdt_paging, 'true'); ?> value="true" name="wp_jdt_paging"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" <?php checked($wp_jdt_paging, 'false'); ?> value="false" name="wp_jdt_paging"> <span><?php _e('No'); ?></span></label>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -136,38 +115,10 @@ function wp_jdt_settings_page()
|
||||
<th scope='row'><?php _e('Pagination Type', 'wp-jquery-datatable'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<?php
|
||||
if ($wp_jdt_paging_type == "full_numbers") {
|
||||
?>
|
||||
<label title="<?php _e('Simple', 'wp-jquery-datatable'); ?>"><input type="radio" value="simple" name="wp_jdt_paging_type"> <span><?php _e('Simple', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Simple Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" value="simple_numbers" name="wp_jdt_paging_type"> <span><?php _e('Simple Numbers', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full', 'wp-jquery-datatable'); ?>"><input type="radio" value="full" name="wp_jdt_paging_type"> <span><?php _e('Full', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" checked="checked" value="full_numbers" name="wp_jdt_paging_type"> <span><?php _e('Full Numbers', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<?php
|
||||
} else if ($wp_jdt_paging_type == "full") {
|
||||
?>
|
||||
<label title="<?php _e('Simple', 'wp-jquery-datatable'); ?>"><input type="radio" value="simple" name="wp_jdt_paging_type"> <span><?php _e('Simple', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Simple Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" value="simple_numbers" name="wp_jdt_paging_type"> <span><?php _e('Simple Numbers', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full', 'wp-jquery-datatable'); ?>"><input type="radio" checked="checked" value="full" name="wp_jdt_paging_type"> <span><?php _e('Full', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" value="full_numbers" name="wp_jdt_paging_type"> <span><?php _e('Full Numbers', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<?php
|
||||
} else if ($wp_jdt_paging_type == "simple_numbers") {
|
||||
?>
|
||||
<label title="<?php _e('Simple', 'wp-jquery-datatable'); ?>"><input type="radio" value="simple" name="wp_jdt_paging_type"> <span><?php _e('Simple', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Simple Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" checked="checked" value="simple_numbers" name="wp_jdt_paging_type"> <span><?php _e('Simple Numbers', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full', 'wp-jquery-datatable'); ?>"><input type="radio" value="full" name="wp_jdt_paging_type"> <span><?php _e('Full', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" value="full_numbers" name="wp_jdt_paging_type"> <span><?php _e('Full Numbers', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<label title="<?php _e('Simple', 'wp-jquery-datatable'); ?>"><input type="radio" checked="checked" value="simple" name="wp_jdt_paging_type"> <span><?php _e('Simple', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Simple Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" value="simple_numbers" name="wp_jdt_paging_type"> <span><?php _e('Simple Numbers', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full', 'wp-jquery-datatable'); ?>"><input type="radio" value="full" name="wp_jdt_paging_type"> <span><?php _e('Full', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" value="full_numbers" name="wp_jdt_paging_type"> <span><?php _e('Full Numbers', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<label title="<?php _e('Simple', 'wp-jquery-datatable'); ?>"><input type="radio" <?php checked($wp_jdt_paging_type, 'simple'); ?> value="simple" name="wp_jdt_paging_type"> <span><?php _e('Simple', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Simple Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" <?php checked($wp_jdt_paging_type, 'simple_numbers'); ?> value="simple_numbers" name="wp_jdt_paging_type"> <span><?php _e('Simple Numbers', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full', 'wp-jquery-datatable'); ?>"><input type="radio" <?php checked($wp_jdt_paging_type, 'full'); ?> value="full" name="wp_jdt_paging_type"> <span><?php _e('Full', 'wp-jquery-datatable'); ?></span></label><br>
|
||||
<label title="<?php _e('Full Numbers', 'wp-jquery-datatable'); ?>"><input type="radio" <?php checked($wp_jdt_paging_type, 'full_numbers'); ?> value="full_numbers" name="wp_jdt_paging_type"> <span><?php _e('Full Numbers', 'wp-jquery-datatable'); ?></span></label>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -175,11 +126,7 @@ function wp_jdt_settings_page()
|
||||
<tr valign='top'>
|
||||
<th scope='row'><?php _e('Rows Per Page', 'wp-jquery-datatable'); ?></th>
|
||||
<td>
|
||||
<input type="number" class="small-text" value="<?php if ($wp_jdt_page_length != NULL) {
|
||||
echo $wp_jdt_page_length;
|
||||
} else {
|
||||
echo "10";
|
||||
} ?>" min="1" step="1" name="wp_jdt_page_length">
|
||||
<input type="number" class="small-text" value="<?php echo $wp_jdt_page_length; ?>" min="1" step="1" name="wp_jdt_page_length">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -187,19 +134,8 @@ function wp_jdt_settings_page()
|
||||
<th scope='row'><?php _e('Show Per Page DropDown', 'wp-jquery-datatable'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<?php
|
||||
if ($wp_jdt_b_length_change != "false") {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" checked="checked" value="true" name="wp_jdt_b_length_change"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" value="false" name="wp_jdt_b_length_change"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" value="true" name="wp_jdt_b_length_change"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" checked="checked" value="false" name="wp_jdt_b_length_change"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" <?php checked($wp_jdt_b_length_change, 'true'); ?> value="true" name="wp_jdt_b_length_change"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" <?php checked($wp_jdt_b_length_change, 'false'); ?> value="false" name="wp_jdt_b_length_change"> <span><?php _e('No'); ?></span></label>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -208,19 +144,8 @@ function wp_jdt_settings_page()
|
||||
<th scope='row'><?php _e('Ordering', 'wp-jquery-datatable'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<?php
|
||||
if ($wp_jdt_ordering != "false") {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" checked="checked" value="true" name="wp_jdt_ordering"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" value="false" name="wp_jdt_ordering"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" value="true" name="wp_jdt_ordering"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" checked="checked" value="false" name="wp_jdt_ordering"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" <?php checked($wp_jdt_ordering, 'true'); ?> value="true" name="wp_jdt_ordering"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" <?php checked($wp_jdt_ordering, 'false'); ?> value="false" name="wp_jdt_ordering"> <span><?php _e('No'); ?></span></label>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -228,26 +153,11 @@ function wp_jdt_settings_page()
|
||||
<tr valign='top'>
|
||||
<th scope='row'><?php _e('Specific Column Order', 'wp-jquery-datatable'); ?></th>
|
||||
<td>
|
||||
<input type="number" class="small-text" value="<?php if ($wp_jdt_order_row != NULL) {
|
||||
echo $wp_jdt_order_row;
|
||||
} else {
|
||||
echo "0";
|
||||
} ?>" min="0" step="1" name="wp_jdt_order_row"><br>
|
||||
<input type="number" class="small-text" value="<?php echo $wp_jdt_order_row; ?>" min="0" step="1" name="wp_jdt_order_row"><br>
|
||||
<br>
|
||||
<fieldset>
|
||||
<?php
|
||||
if ($wp_jdt_order_row_sort != "desc") {
|
||||
?>
|
||||
<label title="<?php _e('Ascending'); ?>"><input type="radio" checked="checked" value="asc" name="wp_jdt_order_row_sort"> <span><?php _e('Ascending'); ?></span></label><br>
|
||||
<label title="<?php _e('Descending'); ?>"><input type="radio" value="desc" name="wp_jdt_order_row_sort"> <span><?php _e('Descending'); ?></span></label><br>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<label title="<?php _e('Ascending'); ?>"><input type="radio" value="asc" name="wp_jdt_order_row_sort"> <span><?php _e('Ascending'); ?></span></label><br>
|
||||
<label title="<?php _e('Descending'); ?>"><input type="radio" checked="checked" value="desc" name="wp_jdt_order_row_sort"> <span><?php _e('Descending'); ?></span></label><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<label title="<?php _e('Ascending'); ?>"><input type="radio" <?php checked($wp_jdt_order_row_sort, 'asc'); ?> value="asc" name="wp_jdt_order_row_sort"> <span><?php _e('Ascending'); ?></span></label><br>
|
||||
<label title="<?php _e('Descending'); ?>"><input type="radio" <?php checked($wp_jdt_order_row_sort, 'desc'); ?> value="desc" name="wp_jdt_order_row_sort"> <span><?php _e('Descending'); ?></span></label>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -256,19 +166,8 @@ function wp_jdt_settings_page()
|
||||
<th scope='row'><?php _e('Searching', 'wp-jquery-datatable'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<?php
|
||||
if ($wp_jdt_searching != "false") {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" checked="checked" value="true" name="wp_jdt_searching"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" value="false" name="wp_jdt_searching"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" value="true" name="wp_jdt_searching"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" checked="checked" value="false" name="wp_jdt_searching"> <span><?php _e('No'); ?></span></label><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<label title="<?php _e('Yes'); ?>"><input type="radio" <?php checked($wp_jdt_searching, 'true'); ?> value="true" name="wp_jdt_searching"> <span><?php _e('Yes'); ?></span></label><br>
|
||||
<label title="<?php _e('No'); ?>"><input type="radio" <?php checked($wp_jdt_searching, 'false'); ?> value="false" name="wp_jdt_searching"> <span><?php _e('No'); ?></span></label>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -276,7 +175,7 @@ function wp_jdt_settings_page()
|
||||
<?php submit_button(); ?>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', 'wp_jdt_style_and_script'); // add custom style and script
|
||||
@@ -295,99 +194,154 @@ function wp_jdt_load_textdomain()
|
||||
load_plugin_textdomain('wp-jquery-datatable', false, dirname(plugin_basename(__FILE__)) . '/languages');
|
||||
}
|
||||
|
||||
add_shortcode('wp_jdt', 'wp_jdt_shortcode'); // add shortcode [wp_jdt id="test" info="true" paging="true" page_length="7" paging_type="full_numbers" b_length_change="true" ordering="true" order_row_number="3" order_row_number_sort="desc" searching="true"]
|
||||
function wp_jdt_shortcode($atts, $content = "")
|
||||
add_shortcode('wp_jdt', 'wp_jdt_shortcode');
|
||||
function wp_jdt_shortcode($atts)
|
||||
{
|
||||
// Get defaults from options for when not set in shortcode
|
||||
$defaults = array(
|
||||
'id' => 'example',
|
||||
'info' => get_option('wp_jdt_info', 'true'),
|
||||
'paging' => get_option('wp_jdt_paging', 'true'),
|
||||
'page_length' => get_option('wp_jdt_page_length', '10'),
|
||||
'paging_type' => get_option('wp_jdt_paging_type', 'simple'),
|
||||
'b_length_change' => get_option('wp_jdt_b_length_change', 'true'),
|
||||
'ordering' => get_option('wp_jdt_ordering', 'true'),
|
||||
'order_row_number' => get_option('wp_jdt_order_row', '0'),
|
||||
'order_row_number_sort' => get_option('wp_jdt_order_row_sort', 'desc'),
|
||||
'searching' => get_option('wp_jdt_searching', 'true'),
|
||||
);
|
||||
|
||||
$wp_jdt_info = get_option('wp_jdt_info');
|
||||
$wp_jdt_paging = get_option('wp_jdt_paging');
|
||||
/*if(get_option('wp_jdt_paging')){
|
||||
$wp_jdt_paging = 'true';
|
||||
}else{
|
||||
$wp_jdt_paging = '';
|
||||
}*/
|
||||
$wp_jdt_page_length = get_option('wp_jdt_page_length');
|
||||
$wp_jdt_paging_type = get_option('wp_jdt_paging_type');
|
||||
$wp_jdt_b_length_change = get_option('wp_jdt_b_length_change');
|
||||
$wp_jdt_ordering = get_option('wp_jdt_ordering');
|
||||
$wp_jdt_order_row = get_option('wp_jdt_order_row');
|
||||
$wp_jdt_order_row_sort = get_option('wp_jdt_order_row_sort');
|
||||
$wp_jdt_searching = get_option('wp_jdt_searching');
|
||||
// Combines user attributes with known attributes and fill in defaults when needed
|
||||
$atts = shortcode_atts($defaults, $atts, 'wp_jdt');
|
||||
|
||||
$atts = shortcode_atts(array(
|
||||
'id' => "example",
|
||||
'info' => "$wp_jdt_info",
|
||||
'paging' => "$wp_jdt_paging",
|
||||
'page_length' => "$wp_jdt_page_length",
|
||||
'paging_type' => "$wp_jdt_paging_type",
|
||||
'b_length_change' => "$wp_jdt_b_length_change",
|
||||
'ordering' => "$wp_jdt_ordering",
|
||||
'order_row_number' => "$wp_jdt_order_row",
|
||||
'order_row_number_sort' => "$wp_jdt_order_row_sort",
|
||||
'searching' => "$wp_jdt_searching",
|
||||
), $atts, 'wp_jdt');
|
||||
// Sanitize and fall back to defaults when setting from shortcode is unknown
|
||||
$table_id = preg_replace('/[^a-zA-Z0-9_\-]/', '', $atts['id']);
|
||||
$table_info = ($atts['info'] === 'true') ? 'true' : 'false';
|
||||
$table_paging = ($atts['paging'] === 'true') ? 'true' : 'false';
|
||||
$table_page_length = absint($atts['page_length']);
|
||||
|
||||
$table_id = esc_js($atts['id']);
|
||||
$table_info = esc_js($atts['info']);
|
||||
$table_paging = esc_js($atts['paging']);
|
||||
$table_page_length = esc_js($atts['page_length']);
|
||||
$table_paging_type = esc_js($atts['paging_type']);
|
||||
$table_b_length_change = esc_js($atts['b_length_change']);
|
||||
$table_ordering = esc_js($atts['ordering']);
|
||||
$table_order_row_number = esc_js($atts['order_row_number']);
|
||||
$table_order_row_number_sort = esc_js($atts['order_row_number_sort']);
|
||||
$table_searching = esc_js($atts['searching']);
|
||||
$allowed_table_paging_types = array('simple', 'simple_numbers', 'full', 'full_numbers');
|
||||
$table_paging_type = in_array($atts['paging_type'], $allowed_table_paging_types, true) ? $atts['paging_type'] : 'simple';
|
||||
|
||||
$wp_jdt_script = "";
|
||||
$wp_jdt_script .= "<script type='text/javascript' language='javascript' class='init'> \n";
|
||||
$wp_jdt_script .= "jQuery(document).ready(function() { \n";
|
||||
$table_b_length_change = ($atts['b_length_change'] === 'true') ? 'true' : 'false';
|
||||
$table_ordering = ($atts['ordering'] === 'true') ? 'true' : 'false';
|
||||
$table_order_row_number = absint($atts['order_row_number']);
|
||||
$table_order_sort = (strtolower($atts['order_row_number_sort']) === 'asc') ? 'asc' : 'desc';
|
||||
$table_searching = ($atts['searching'] === 'true') ? 'true' : 'false';
|
||||
|
||||
$wp_jdt_script .= "jQuery('#$table_id').DataTable({ \n";
|
||||
$wp_jdt_script .= "'info': $table_info, \n";
|
||||
$wp_jdt_script .= "'paging': $table_paging, \n";
|
||||
if ($table_page_length > 0) {
|
||||
$wp_jdt_script .= "'pageLength': $table_page_length, \n";
|
||||
} else {
|
||||
$wp_jdt_script .= "'pageLength': $wp_jdt_page_length, \n";
|
||||
$table_length_menu = array(10, 25, 50, 100, -1);
|
||||
if (!in_array($table_page_length, $table_length_menu)) {
|
||||
// Add the missing page length option to the array
|
||||
$table_length_menu[] = (int)$table_page_length;
|
||||
|
||||
// Temporarily remove -1 ("All") if present to preserve its position at the end
|
||||
$has_all = false;
|
||||
if (($key = array_search(-1, $table_length_menu)) !== false) {
|
||||
unset($table_length_menu[$key]);
|
||||
$has_all = true;
|
||||
}
|
||||
|
||||
$wp_jdt_script .= "'pagingType': '$table_paging_type', \n";
|
||||
$wp_jdt_script .= "'bLengthChange': $table_b_length_change, \n";
|
||||
$wp_jdt_script .= "'ordering': $table_ordering, \n";
|
||||
if ($table_order_row_number != '') { // if 'Specific Column Order' is not null than add this attribute
|
||||
// Sort the remaining numeric options in ascending order
|
||||
sort($table_length_menu);
|
||||
|
||||
$table_order_row_number_sort = ($table_order_row_number_sort != "") ? $table_order_row_number_sort : 'desc';
|
||||
$wp_jdt_script .= "'order': [$table_order_row_number,'$table_order_row_number_sort'], \n";
|
||||
// Append -1 back to the end of the array
|
||||
if ($has_all) {
|
||||
$table_length_menu[] = -1;
|
||||
}
|
||||
}
|
||||
$wp_jdt_script .= "'searching': $table_searching, \n";
|
||||
$wp_jdt_script .= "language: {\n";
|
||||
$wp_jdt_script .= "'search': '" . __('Searching', 'wp-jquery-datatable') . ":', \n";
|
||||
$wp_jdt_script .= "}, \n";
|
||||
$wp_jdt_script .= "} ); \n";
|
||||
$table_wrapper_id = $table_id . "_wrapper";
|
||||
|
||||
$wp_jdt_script .= "jQuery('#$table_wrapper_id select').prepend('<option value=$table_page_length>" . __('Select') . "</option>').val('');";
|
||||
|
||||
$wp_jdt_script .= "} ); \n";
|
||||
$wp_jdt_script .= "</script>";
|
||||
|
||||
// css and js
|
||||
wp_enqueue_style('jdt-style-data-tables');
|
||||
wp_enqueue_script('jdt-js-datatables');
|
||||
|
||||
return $wp_jdt_script;
|
||||
// Load JS script via wp_footer anonymous function
|
||||
add_action('wp_footer', function () use (
|
||||
$table_id,
|
||||
$table_info,
|
||||
$table_paging,
|
||||
$table_page_length,
|
||||
$table_length_menu,
|
||||
$table_paging_type,
|
||||
$table_b_length_change,
|
||||
$table_ordering,
|
||||
$table_order_row_number,
|
||||
$table_order_sort,
|
||||
$table_searching
|
||||
) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('#<?php echo esc_js($table_id); ?>').DataTable({
|
||||
'info': <?php echo $table_info; ?>,
|
||||
'paging': <?php echo $table_paging; ?>,
|
||||
'pageLength': <?php echo $table_page_length; ?>,
|
||||
'lengthMenu': <?php echo json_encode($table_length_menu); ?>,
|
||||
'pagingType': '<?php echo esc_js($table_paging_type); ?>',
|
||||
'bLengthChange': <?php echo $table_b_length_change; ?>,
|
||||
'ordering': <?php echo $table_ordering; ?>,
|
||||
'order': [<?php echo $table_order_row_number; ?>, '<?php echo esc_js($table_order_sort); ?>'],
|
||||
'searching': <?php echo $table_searching; ?>,
|
||||
'language': {
|
||||
'url': '<?php echo esc_url(get_jdt_locale_json_file()); ?>',
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
});
|
||||
|
||||
// return empty string
|
||||
return '';
|
||||
}
|
||||
|
||||
register_uninstall_hook(__FILE__, 'wp_jdt_uninstall'); // uninstall plug-in
|
||||
function wp_jdt_uninstall()
|
||||
{
|
||||
delete_option('wp_jdt_info');
|
||||
delete_option('wp_jdt_paging');
|
||||
delete_option('wp_jdt_page_length');
|
||||
delete_option('wp_jdt_paging_type');
|
||||
delete_option('wp_jdt_b_length_change');
|
||||
delete_option('wp_jdt_ordering');
|
||||
delete_option('wp_jdt_order_row');
|
||||
delete_option('wp_jdt_order_row_sort');
|
||||
delete_option('wp_jdt_searching');
|
||||
$settings = array(
|
||||
'wp_jdt_info',
|
||||
'wp_jdt_paging',
|
||||
'wp_jdt_page_length',
|
||||
'wp_jdt_paging_type',
|
||||
'wp_jdt_b_length_change',
|
||||
'wp_jdt_ordering',
|
||||
'wp_jdt_order_row',
|
||||
'wp_jdt_order_row_sort',
|
||||
'wp_jdt_searching'
|
||||
);
|
||||
|
||||
foreach ($settings as $setting) {
|
||||
delete_option($setting);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path of the locale JSON file if it exists.
|
||||
*
|
||||
* @return string|null File path if valid, or null if skipped/missing.
|
||||
*/
|
||||
function get_jdt_locale_json_file()
|
||||
{
|
||||
// 1. Get the current locale (e.g., 'nl_NL', 'en_US', 'en_GB')
|
||||
$locale = get_user_locale();
|
||||
|
||||
// 2. Exclude en_US specifically as that's the default dataTables language
|
||||
// (en_GB and other English regional locales remain valid)
|
||||
if ($locale === 'en_US') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 3. Format the filename ('nl_NL' -> 'nl-NL.json')
|
||||
$formatted_locale = str_replace('_', '-', $locale);
|
||||
$filename = "{$formatted_locale}.json";
|
||||
|
||||
// 4. Set relative path inside your plugin directory
|
||||
$relative_path = "plug-ins/i18n/{$filename}";
|
||||
|
||||
// 5. Verify file existence on disk
|
||||
if (!file_exists(plugin_dir_path(__FILE__) . $relative_path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 6. Return either the direct URL or the absolute file path
|
||||
return plugin_dir_url(__FILE__) . $relative_path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user