diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..0f0968c --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es2021": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": "latest" + }, + "rules": { + "no-prototype-builtins": 0, + "no-console": 1, + "no-unused-vars": 1, + "no-undef": 1 + }, + "globals": { + "tinyMCE": true, + "qTranslateConfig": true, + "wputaxometas_options": true, + "wp": true, + "jQuery": true + } +} diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml new file mode 100644 index 0000000..301b432 --- /dev/null +++ b/.github/workflows/js.yml @@ -0,0 +1,17 @@ +name: ESLint + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install modules + 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 9ad9df7..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: @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: PHP Lint uses: michaelw90/PHP-Lint@2.1.0 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/global.js b/assets/global.js index 848f241..65fd2ec 100644 --- a/assets/global.js +++ b/assets/global.js @@ -1,4 +1,3 @@ -/*global jQuery:false, wp:false */ 'use strict'; jQuery(document).ready(function() { @@ -89,7 +88,7 @@ var wputh_taxometas_set_media = function() { unset_media(jQuery(this)); }); - jQuery('body').on('unset_media', '.wputaxometas_add_media', function(e) { + jQuery('body').on('unset_media', '.wputaxometas_add_media', function() { unset_media(jQuery(this)); }); diff --git a/assets/qtranslatex.js b/assets/qtranslatex.js index 3aa2090..94e724e 100644 --- a/assets/qtranslatex.js +++ b/assets/qtranslatex.js @@ -1,4 +1,4 @@ -jQuery(document).ready(function($) { +jQuery(document).ready(function() { wputh_taxometas_set_qtranslate(); }); @@ -24,4 +24,4 @@ function wputh_taxometas_set_qtranslate() { function wputh_taxometas_qt_display_lang(lang) { jQuery('[data-wputaxometaslang]').hide(); jQuery('[data-wputaxometaslang="' + lang + '"]').show(); -} \ No newline at end of file +} diff --git a/inc/WPUBaseUpdate/.htaccess b/inc/WPUBaseUpdate/.htaccess new file mode 100644 index 0000000..8d2f256 --- /dev/null +++ b/inc/WPUBaseUpdate/.htaccess @@ -0,0 +1 @@ +deny from all 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 8bc4938..6943b29 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/inc/WPUBaseUpdate/index.php b/inc/WPUBaseUpdate/index.php new file mode 100644 index 0000000..194cdb1 --- /dev/null +++ b/inc/WPUBaseUpdate/index.php @@ -0,0 +1 @@ +NULL,'plural-forms'=>NULL,'messages'=>['Add a picture'=>'Ajouter une image','Change this picture'=>'Modifier cette image','Select a value'=>'Sélectionner une valeur','Simple admin for taxo metas'=>'Administration simple pour les taxo metas','No'=>'Non','Yes'=>'Oui'],'language'=>'fr_FR','x-generator'=>'Poedit 3.2.2']; \ No newline at end of file diff --git a/wputaxometas.php b/wputaxometas.php index e07d762..9a70ad3 100644 --- a/wputaxometas.php +++ b/wputaxometas.php @@ -5,13 +5,14 @@ Plugin URI: https://github.com/WordPressUtilities/wputaxometas Update URI: https://github.com/WordPressUtilities/wputaxometas Description: Simple admin for taxo metas -Version: 0.22.1 +Version: 0.23.0 Author: Darklg Author URI: https://darklg.me/ Text Domain: wputaxometas Domain Path: /lang Requires at least: 6.2 Requires PHP: 8.0 +Network: Optional License: MIT License License URI: https://opensource.org/licenses/MIT */ @@ -19,7 +20,7 @@ defined('ABSPATH') or die(':('); class WPUTaxoMetas { - public $plugin_version = '0.22.1'; + public $plugin_version = '0.23.0'; public $qtranslate = false; public $qtranslatex = false; public $fields = array(); @@ -41,7 +42,7 @@ public function __construct($hooks = true) { public function set_hooks() { /* Auto-updater */ - include __DIR__ . '/inc/WPUBaseUpdate/WPUBaseUpdate.php'; + require_once __DIR__ . '/inc/WPUBaseUpdate/WPUBaseUpdate.php'; $this->settings_update = new \wputaxometas\WPUBaseUpdate( 'WordPressUtilities', 'wputaxometas',