diff --git a/.eslintrc.json b/.eslintrc.json index cc0bb24..5e3911a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,20 +8,25 @@ "ecmaVersion": "latest" }, "rules": { - "no-prototype-builtins": 0 + "no-prototype-builtins": 0, + "no-unused-vars": 1, + "no-undef": 1 }, "globals": { - "wpulivesearch_before_filter_insertion":true, - "wpulivesearch_clean_item_data":true, - "wpulivesearch_datas": true, + "wpulivesearch_options": true, + "wpulivesearch_settings": true, "wpulivesearch_datas_keys": true, - "wpulivesearch_delete_result":true, + "wpulivesearch_clean_item_data": true, + "wpulivesearch_delete_result": true, "wpulivesearch_filters": true, + "wpulivesearch_datas": true, + "wpulivesearch_before_filter_insertion": true, + "wpulivesearch_get_filled_template__before_items": true, + "wpulivesearch_get_filled_template__before_item": true, "wpulivesearch_get_filled_template__after_item": true, "wpulivesearch_get_filled_template__after_items": true, - "wpulivesearch_get_filled_template__before_item": true, - "wpulivesearch_get_filled_template__before_items": true, - "wpulivesearch_settings": true, - "wpulivesearch_tpl": true + "wpulivesearch_tpl": true, + "wp": true, + "jQuery": true } } diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index 03f7180..d3191e8 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -2,16 +2,16 @@ name: ESLint on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - 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 9ad9df7..aa092ae 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@v4 - name: PHP Lint uses: michaelw90/PHP-Lint@2.1.0 diff --git a/LICENSE b/LICENSE index de4b3ac..f144cd3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 WordPressUtilities +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 diff --git a/inc/.htaccess b/inc/.htaccess new file mode 100644 index 0000000..8d2f256 --- /dev/null +++ b/inc/.htaccess @@ -0,0 +1 @@ +deny from all 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 50e01f9..5f900c1 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.6.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)) { @@ -170,7 +176,7 @@ public function plugins_api($res, $action, $args) { return false; } - if ('github-' . $this->github_project !== $args->slug) { + if ('github-' . $this->github_project !== $args->slug && $this->github_project !== $args->slug) { return $res; } @@ -179,7 +185,20 @@ public function plugins_api($res, $action, $args) { return (object) $plugin_info; } - return false; + $plugin_details = array( + 'name' => $this->github_project, + 'slug' => $this->github_project + ); + + $parent_plugin = __DIR__ . '/../../' . $this->github_project . '.php'; + if (file_exists($parent_plugin)) { + $plugin_name = get_plugin_data($parent_plugin); + if (isset($plugin_name['Name'])) { + $plugin_details['name'] = $plugin_name['Name']; + } + } + + return (object) $plugin_details; } 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'=>['Live Search datas'=>'Recherche live de données','View all'=>'Voir tout','Reset'=>'Réinitialiser','Search'=>'Rechercher','Filter values'=>'Filtrer les valeurs','Load more'=>'Afficher plus','No results for this query, sorry'=>'Désolé, il n\'y a aucun résultat pour cette requête','%s results'=>'%s résultats','%s result'=>'%s résultat'],'language'=>'fr_FR','x-generator'=>'Poedit 3.4']; \ No newline at end of file diff --git a/uninstall.php b/uninstall.php new file mode 100644 index 0000000..5d66b3c --- /dev/null +++ b/uninstall.php @@ -0,0 +1,5 @@ +plugin_description = __('Live Search datas', 'wpulivesearch'); + } + + public function plugins_loaded() { /* Updater */ require_once __DIR__ . '/inc/WPUBaseUpdate/WPUBaseUpdate.php';