diff --git a/.eslintrc.json b/.eslintrc.json
index 03b88e0..5d6c3f7 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -8,7 +8,9 @@
"ecmaVersion": "latest"
},
"rules": {
- "no-prototype-builtins": 0
+ "no-prototype-builtins": 0,
+ "no-unused-vars": 1,
+ "no-undef": 1
},
"globals": {
"wp": true,
diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml
index 03f7180..301b432 100644
--- a/.github/workflows/js.yml
+++ b/.github/workflows/js.yml
@@ -2,9 +2,9 @@ name: ESLint
on:
push:
- branches: [ master ]
+ branches: [ main ]
pull_request:
- branches: [ master ]
+ branches: [ main ]
jobs:
build:
@@ -12,6 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install modules
- run: npm install -g eslint
+ run: npm install -g eslint@^8
- name: Run ESLint
run: eslint assets/ --ext .js
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index 1901d23..c55b4e3 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -2,9 +2,9 @@ name: PHP Lint
on:
push:
- branches: [ master ]
+ branches: [ main ]
pull_request:
- branches: [ master ]
+ branches: [ main ]
jobs:
phplint:
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f144cd3
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 WPUtilities
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/assets/events.js b/assets/events.js
index 4b4f559..0106f6c 100644
--- a/assets/events.js
+++ b/assets/events.js
@@ -17,11 +17,20 @@ jQuery(document).ready(function() {
var wputh_options_set_exportcheck = function() {
'use strict';
- jQuery('.wpu-export-section').on('change', '.wpu-export-title-checkbox', function() {
- var $this = jQuery(this),
- $parent = $this.closest('.wpu-export-section');
- $parent.find('.wpu-export-boxes-check').prop("checked", $this.prop('checked'));
+ jQuery('.wpu-export-section').each(function() {
+ var $section = jQuery(this),
+ $masterCheck = $section.find('.wpu-export-title-checkbox'),
+ $checkboxes = $section.find('.wpu-export-boxes-check');
+
+ $masterCheck.on('change', function() {
+ $checkboxes.prop("checked", $masterCheck.prop('checked'));
+ });
+
+ $checkboxes.on('change', function() {
+ $masterCheck.prop("checked", $checkboxes.filter(':checked').length == $checkboxes.length);
+ });
});
+
};
/* ----------------------------------------------------------
@@ -44,8 +53,9 @@ var wputh_options_set_wp_link = function() {
var src_json = {};
try {
src_json = JSON.parse($textarea.val());
+ } catch (e) {
+ console.log('Could not parse');
}
- catch (e) {console.log('Could not parse');}
if (typeof src_json == 'object') {
if (src_json.href) {
jQuery('#wp-link-url').val(src_json.href);
@@ -216,8 +226,7 @@ var wputh_options_set_media = function() {
att = attachment.url;
att = att.replace($preview.data('removethis'), '');
previewContent += '
' + att + '
';
- }
- else {
+ } else {
previewContent += '';
}
previewContent += '';
@@ -261,8 +270,7 @@ var wputh_options_set_accordion = function() {
// Set opened box
if (window.location.hash && jQuery(window.location.hash).length > 0) {
jQuery(window.location.hash).trigger('click');
- }
- else {
+ } else {
boxes.eq(0).removeClass('is-closed');
}
diff --git a/inc/WPUBaseUpdate/README.md b/inc/WPUBaseUpdate/README.md
index 2cf0ab5..6743039 100644
--- a/inc/WPUBaseUpdate/README.md
+++ b/inc/WPUBaseUpdate/README.md
@@ -6,7 +6,7 @@ Update your Github WordPress plugin from the plugins page admin.
## Insert in the INIT hook
```php
-include dirname( __FILE__ ) . '/inc/WPUBaseUpdate/WPUBaseUpdate.php';
+require_once __DIR__ . '/inc/WPUBaseUpdate/WPUBaseUpdate.php';
$this->settings_update = new \PLUGINID\WPUBaseUpdate(
'WordPressUtilities',
'PLUGINID',
diff --git a/inc/WPUBaseUpdate/WPUBaseUpdate.php b/inc/WPUBaseUpdate/WPUBaseUpdate.php
index 1a41b5e..88f8678 100644
--- a/inc/WPUBaseUpdate/WPUBaseUpdate.php
+++ b/inc/WPUBaseUpdate/WPUBaseUpdate.php
@@ -4,7 +4,7 @@
/*
Class Name: WPU Base Update
Description: A class to handle plugin update from github
-Version: 0.4.5
+Version: 0.5.0
Class URI: https://github.com/WordPressUtilities/wpubaseplugin
Author: Darklg
Author URI: https://darklg.me/
@@ -26,6 +26,7 @@ class WPUBaseUpdate {
private $plugin_id;
private $plugin_dir;
private $details;
+ private $is_tracked = false;
public function __construct($github_username = false, $github_project = false, $current_version = false, $details = array()) {
$this->init($github_username, $github_project, $current_version, $details);
@@ -47,9 +48,7 @@ public function init($github_username = false, $github_project = false, $current
$this->plugin_dir = (defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins') . '/' . $this->plugin_id;
$gitpath = dirname($this->plugin_dir) . '/.git';
- if (is_dir($gitpath) || file_exists($gitpath)) {
- return;
- }
+ $this->is_tracked = (is_dir($gitpath) || file_exists($gitpath));
if (!is_array($details)) {
$details = array();
@@ -125,6 +124,13 @@ public function get_new_plugin_info() {
'sections' => array()
);
+ /* Disable download link if plugin is tracked */
+ if ($this->is_tracked) {
+ $plugin_info['trunk'] = '';
+ $plugin_info['download_link'] = '';
+ $plugin_info['package'] = '';
+ }
+
/* Fetch plugin data */
$plugin_data = array();
if (file_exists($this->plugin_dir)) {
diff --git a/lang/wpuoptions-fr_FR.l10n.php b/lang/wpuoptions-fr_FR.l10n.php
new file mode 100644
index 0000000..7f7f410
--- /dev/null
+++ b/lang/wpuoptions-fr_FR.l10n.php
@@ -0,0 +1,2 @@
+NULL,'plural-forms'=>NULL,'messages'=>['Friendly interface for website options'=>'Interface conviviale pour les options de site','Site options'=>'Options du site','Import'=>'Importer','Export'=>'Exporter','Options'=>'Options','Warning : The saved options may be different than yours. Maybe someone changed them while you were editing ?'=>'Avertissement : Les options enregistrées peuvent être différentes des vôtres. Peut-être ont-elles été modifiées pendant que vous éditiez ?','No fields for the moment'=>'Aucun champ pour le moment','Click below to download a .json file containing all your website\'s options.'=>'Cliquez ci-dessous pour télécharger un fichier .json contenant toutes les options de votre site.','Default box'=>'Box par défaut','Export options'=>'Exporter les options','The file has been successfully imported.'=>'Le fichier a été importé avec succès.','The file has not been imported.'=>'Le fichier n’a pas été importé.','Upload a .json file (generated by WPU Options) to import your website\'s options.'=>'Transférez un fichier .json (généré par WPU Options) pour importer les options de votre site.','Import options file'=>'Importer le fichier d\'options','Error in the form.'=>'Erreur dans le formulaire.','The field "%s" must not be empty'=>'Le champ "%s" ne doit pas être vide','The field "%s" has been updated.'=>'Le champ "%s" a été mis à jour.','The field "%s" has not been updated, because it\'s not valid.'=>'Le champ "%s" n’a pas été mis à jour, car il est invalide.','Success!'=>'Succès !','Fail!'=>'Echec !','Update'=>'Mettre à jour','Edit this text'=>'Modifier ce texte','Cancel edition'=>'Annuler l\'édition','Add a picture'=>'Ajouter une image','Change this picture'=>'Modifier cette image','Do you really want to remove this image ?'=>'Voulez-vous vraiment retirer cette image ?','Add a file'=>'Ajouter un fichier','Change this file'=>'Modifier ce fichier','Do you really want to remove this file ?'=>'Voulez-vous vraiment retirer ce fichier ?','maleSelect a %s'=>'Sélectionner un %s','femaleSelect a %s'=>'Sélectionner une %s','Select some %s'=>'Sélectionnez des %s','Select a value'=>'Sélectionner une valeur','Edit link'=>'Modifier le lien','No'=>'Non','Yes'=>'Oui','Edit Site:'=>'Modifier le site :','Incorrect site ID.'=>'ID de site incorrect.','The requested site does not exist.'=>'Le site recherché n\'existe pas.'],'language'=>'fr_FR','x-generator'=>'Poedit 3.5'];
\ No newline at end of file
diff --git a/lang/wpuoptions-fr_FR.mo b/lang/wpuoptions-fr_FR.mo
index 902cf2d..ddc4ec6 100644
Binary files a/lang/wpuoptions-fr_FR.mo and b/lang/wpuoptions-fr_FR.mo differ
diff --git a/lang/wpuoptions-fr_FR.po b/lang/wpuoptions-fr_FR.po
index 7815c51..01e9c04 100644
--- a/lang/wpuoptions-fr_FR.po
+++ b/lang/wpuoptions-fr_FR.po
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: WPU Options\n"
-"POT-Creation-Date: 2023-02-13 11:39+0100\n"
+"POT-Creation-Date: 2024-09-21 06:51+0200\n"
"PO-Revision-Date: \n"
"Last-Translator: Darklg \n"
"Language-Team: \n"
@@ -9,33 +9,33 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 3.2.2\n"
+"X-Generator: Poedit 3.5\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_n:1,2;esc_attr__\n"
"X-Poedit-SearchPath-0: ../.\n"
-#: .././wpuoptions.php:69
+#: .././wpuoptions.php:80
msgid "Friendly interface for website options"
msgstr "Interface conviviale pour les options de site"
-#: .././wpuoptions.php:76
+#: .././wpuoptions.php:87
msgid "Site options"
msgstr "Options du site"
-#: .././wpuoptions.php:188 .././wpuoptions.php:404
+#: .././wpuoptions.php:241 .././wpuoptions.php:454
msgid "Import"
msgstr "Importer"
-#: .././wpuoptions.php:191 .././wpuoptions.php:367
+#: .././wpuoptions.php:244 .././wpuoptions.php:417
msgid "Export"
msgstr "Exporter"
-#: .././wpuoptions.php:206
+#: .././wpuoptions.php:259
msgid "Options"
msgstr "Options"
-#: .././wpuoptions.php:267
+#: .././wpuoptions.php:320
msgid ""
"Warning : The saved options may be different than yours. Maybe someone "
"changed them while you were editing ?"
@@ -43,34 +43,34 @@ msgstr ""
"Avertissement : Les options enregistrées peuvent être différentes des "
"vôtres. Peut-être ont-elles été modifiées pendant que vous éditiez ?"
-#: .././wpuoptions.php:302
+#: .././wpuoptions.php:355 .././wpuoptions.php:1256
msgid "No fields for the moment"
msgstr "Aucun champ pour le moment"
-#: .././wpuoptions.php:370
+#: .././wpuoptions.php:420
msgid ""
"Click below to download a .json file containing all your website's options."
msgstr ""
"Cliquez ci-dessous pour télécharger un fichier .json contenant toutes les "
"options de votre site."
-#: .././wpuoptions.php:389
+#: .././wpuoptions.php:439
msgid "Default box"
msgstr "Box par défaut"
-#: .././wpuoptions.php:394
+#: .././wpuoptions.php:444
msgid "Export options"
msgstr "Exporter les options"
-#: .././wpuoptions.php:413
+#: .././wpuoptions.php:463
msgid "The file has been successfully imported."
msgstr "Le fichier a été importé avec succès."
-#: .././wpuoptions.php:415
+#: .././wpuoptions.php:465
msgid "The file has not been imported."
msgstr "Le fichier n’a pas été importé."
-#: .././wpuoptions.php:419
+#: .././wpuoptions.php:469
msgid ""
"Upload a .json file (generated by WPU Options) to import your website's "
"options."
@@ -78,105 +78,117 @@ msgstr ""
"Transférez un fichier .json (généré par WPU Options) pour importer les "
"options de votre site."
-#: .././wpuoptions.php:423
+#: .././wpuoptions.php:473
msgid "Import options file"
msgstr "Importer le fichier d'options"
-#: .././wpuoptions.php:445
+#: .././wpuoptions.php:500
msgid "Error in the form."
msgstr "Erreur dans le formulaire."
-#: .././wpuoptions.php:491
+#: .././wpuoptions.php:550
#, php-format
msgid "The field \"%s\" must not be empty"
msgstr "Le champ \"%s\" ne doit pas être vide"
-#: .././wpuoptions.php:498
+#: .././wpuoptions.php:557
#, php-format
msgid "The field \"%s\" has been updated."
msgstr "Le champ \"%s\" a été mis à jour."
-#: .././wpuoptions.php:501
+#: .././wpuoptions.php:560
#, php-format
msgid "The field \"%s\" has not been updated, because it's not valid."
msgstr "Le champ \"%s\" n’a pas été mis à jour, car il est invalide."
-#: .././wpuoptions.php:509
+#: .././wpuoptions.php:568
msgid "Success!"
msgstr "Succès !"
-#: .././wpuoptions.php:512
+#: .././wpuoptions.php:571
msgid "Fail!"
msgstr "Echec !"
-#: .././wpuoptions.php:579
+#: .././wpuoptions.php:649
msgid "Update"
msgstr "Mettre à jour"
-#: .././wpuoptions.php:714
+#: .././wpuoptions.php:792
msgid "Edit this text"
msgstr "Modifier ce texte"
-#: .././wpuoptions.php:715
+#: .././wpuoptions.php:793
msgid "Cancel edition"
msgstr "Annuler l'édition"
-#: .././wpuoptions.php:723
+#: .././wpuoptions.php:801
msgid "Add a picture"
msgstr "Ajouter une image"
-#: .././wpuoptions.php:724
+#: .././wpuoptions.php:802
msgid "Change this picture"
msgstr "Modifier cette image"
-#: .././wpuoptions.php:725
+#: .././wpuoptions.php:803
msgid "Do you really want to remove this image ?"
msgstr "Voulez-vous vraiment retirer cette image ?"
-#: .././wpuoptions.php:727
+#: .././wpuoptions.php:805
msgid "Add a file"
msgstr "Ajouter un fichier"
-#: .././wpuoptions.php:728
+#: .././wpuoptions.php:806
msgid "Change this file"
msgstr "Modifier ce fichier"
-#: .././wpuoptions.php:729
+#: .././wpuoptions.php:807
msgid "Do you really want to remove this file ?"
msgstr "Voulez-vous vraiment retirer ce fichier ?"
-#: .././wpuoptions.php:771 .././wpuoptions.php:820
+#: .././wpuoptions.php:849 .././wpuoptions.php:898
#, php-format
msgctxt "male"
msgid "Select a %s"
msgstr "Sélectionner un %s"
-#: .././wpuoptions.php:773 .././wpuoptions.php:822
+#: .././wpuoptions.php:851 .././wpuoptions.php:900
#, php-format
msgctxt "female"
msgid "Select a %s"
msgstr "Sélectionner une %s"
-#: .././wpuoptions.php:835
+#: .././wpuoptions.php:913
#, php-format
msgid "Select some %s"
msgstr "Sélectionnez des %s"
-#: .././wpuoptions.php:849
+#: .././wpuoptions.php:927
msgid "Select a value"
msgstr "Sélectionner une valeur"
-#: .././wpuoptions.php:881
+#: .././wpuoptions.php:959
msgid "Edit link"
msgstr "Modifier le lien"
-#: .././wpuoptions.php:924
+#: .././wpuoptions.php:1004
msgid "No"
msgstr "Non"
-#: .././wpuoptions.php:925
+#: .././wpuoptions.php:1005
msgid "Yes"
msgstr "Oui"
+#: .././wpuoptions.php:1273
+msgid "Edit Site:"
+msgstr "Modifier le site :"
+
+#: .././wpuoptions.php:1294
+msgid "Incorrect site ID."
+msgstr "ID de site incorrect."
+
+#: .././wpuoptions.php:1298
+msgid "The requested site does not exist."
+msgstr "Le site recherché n'existe pas."
+
#~ msgid "Select a %s"
#~ msgstr "Sélectionner un %s"
diff --git a/wpuoptions.php b/wpuoptions.php
index b2aca80..35defd1 100644
--- a/wpuoptions.php
+++ b/wpuoptions.php
@@ -4,7 +4,7 @@
Plugin Name: WPU Options
Plugin URI: https://github.com/WordPressUtilities/wpuoptions
Update URI: https://github.com/WordPressUtilities/wpuoptions
-Version: 7.1.0
+Version: 8.0.0
Description: Friendly interface for website options
Author: Darklg
Author URI: https://darklg.me/
@@ -12,6 +12,7 @@
Domain Path: /lang
Requires at least: 6.2
Requires PHP: 8.0
+Network: Optional
License: MIT License
License URI: https://opensource.org/licenses/MIT
*/
@@ -28,7 +29,7 @@ class WPUOptions {
private $main_url;
private $options = array(
'plugin_name' => 'WPU Options',
- 'plugin_version' => '7.1.0',
+ 'plugin_version' => '8.0.0',
'plugin_userlevel' => 'manage_categories',
'plugin_menutype' => 'admin.php',
'plugin_pageslug' => 'wpuoptions-settings'
@@ -407,11 +408,8 @@ public function admin_export_page_postAction() {
/* Return JSON file */
- header('Content-disposition: attachment; filename=' . $filename);
- header('Content-type: application/json');
echo $this->generate_export($boxes);
- die;
}
public function admin_export_page() {
@@ -1034,21 +1032,24 @@ private function generate_export($boxes = array()) {
// Array of fields:values
foreach ($this->fields as $id => $field) {
$opt_field = $field;
-
- // If this field has i18n
- if (isset($opt_field['lang']) && !empty($languages)) {
- foreach ($languages as $lang => $name) {
- $options[$lang . '___' . $id] = get_option($lang . '___' . $id);
- }
- }
if (!isset($opt_field['box']) || $opt_field['box'] == 'default' || empty($opt_field['box']) || !array_key_exists($opt_field['box'], $this->boxes)) {
$opt_field['box'] = 'default';
}
if ($import_all_boxes || in_array($opt_field['box'], $boxes)) {
$options[$id] = get_option($id);
+ // If this field has i18n
+ if (isset($opt_field['lang']) && !empty($languages)) {
+ foreach ($languages as $lang => $name) {
+ $options[$lang . '___' . $id] = get_option($lang . '___' . $id);
+ }
+ }
}
}
- return json_encode($options);
+
+ header('Content-disposition: attachment; filename=' . $filename);
+ header('Content-type: application/json');
+ echo json_encode($options);
+ die;
}
/**
@@ -1212,7 +1213,7 @@ public function get_current_admin_language() {
/**
* Handle Tabs in multisite settings
*/
- function network_edit_site_nav_links($tabs) {
+ public function network_edit_site_nav_links($tabs) {
/* Hide settings tab */
unset($tabs['site-settings']);
@@ -1226,14 +1227,14 @@ function network_edit_site_nav_links($tabs) {
}
/* Create new page */
- function network_admin_menu() {
+ public function network_admin_menu() {
add_submenu_page('', $this->options['plugin_name'], $this->options['plugin_name'], 'manage_network_options', 'wpuoptions-settings', array(&$this,
'network_admin_page'
));
}
/* Page content */
- function network_admin_page() {
+ public function network_admin_page() {
$id = $this->get_current_site_id();
global $title;
@@ -1259,7 +1260,7 @@ function network_admin_page() {
echo '';
}
- function check_screen_access() {
+ public function check_screen_access() {
if (!$this->is_network_wputools_admin()) {
return;
}
@@ -1272,7 +1273,7 @@ function check_screen_access() {
$title = __('Edit Site:') . ' ' . $blog_details->blogname;
}
- function is_network_wputools_admin() {
+ public function is_network_wputools_admin() {
if (!function_exists('get_current_screen')) {
return false;
}
@@ -1283,7 +1284,7 @@ function is_network_wputools_admin() {
return true;
}
- function get_current_site_id($id = false) {
+ public function get_current_site_id($id = false) {
if (!$id) {
$id = isset($_REQUEST['id']) ? absint($_REQUEST['id']) : 0;
@@ -1301,7 +1302,7 @@ function get_current_site_id($id = false) {
}
- function is_item_visible($item) {
+ public function is_item_visible($item) {
if (is_network_admin() && !$item['visibility_network']) {
return false;
}
@@ -1313,7 +1314,7 @@ function is_item_visible($item) {
}
/* Handle attachments in multisite */
- function ajax_query_attachments_args($args) {
+ public function ajax_query_attachments_args($args) {
/* Check if ajax query origin is in a network admin page */
$referer_url = wp_get_referer();
if (!$referer_url || strpos($referer_url, network_site_url()) === false) {