Skip to content

Commit

Permalink
v 0.27.0
Browse files Browse the repository at this point in the history
- Update dependencies.
- Update Github actions.
- Move to « main » branch.
- Better protection.
- Add better translation method.
- Fiw WP 6.7 lang loading.
  • Loading branch information
Darklg committed Dec 1, 2024
1 parent f73f264 commit b4d7487
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 29 deletions.
23 changes: 14 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
8 changes: 4 additions & 4 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: PHP Lint

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

jobs:
phplint:
Expand All @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: PHP Lint
uses: michaelw90/[email protected]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions inc/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
1 change: 1 addition & 0 deletions inc/WPUBaseUpdate/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
2 changes: 1 addition & 1 deletion inc/WPUBaseUpdate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
31 changes: 25 additions & 6 deletions inc/WPUBaseUpdate/WPUBaseUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;

}

Expand Down
1 change: 1 addition & 0 deletions inc/WPUBaseUpdate/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
1 change: 1 addition & 0 deletions inc/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
1 change: 1 addition & 0 deletions lang/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
1 change: 1 addition & 0 deletions lang/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
2 changes: 2 additions & 0 deletions lang/wpulivesearch-fr_FR.l10n.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
return ['domain'=>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'];
5 changes: 5 additions & 0 deletions uninstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
defined('ABSPATH') || die;
if (!defined('WP_UNINSTALL_PLUGIN')) {
die;
}
17 changes: 12 additions & 5 deletions wpulivesearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
Description: Live Search datas
Plugin URI: https://github.com/WordPressUtilities/wpulivesearch
Update URI: https://github.com/WordPressUtilities/wpulivesearch
Version: 0.26.3
Version: 0.27.0
Author: Darklg
Author URI: https://darklg.me/
Text Domain: wpulivesearch
Domain Path: /lang
Requires at least: 6.2
Requires PHP: 8.0
Network: Optional
License: MIT License
License URI: https://opensource.org/licenses/MIT
*/

class WPULiveSearch {
private $plugin_version = '0.26.3';
private $plugin_version = '0.27.0';
public $plugin_description;
public $settings_update;
private $settings = array(
Expand Down Expand Up @@ -47,18 +48,24 @@ class WPULiveSearch {

public function __construct() {
add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
add_action('init', array(&$this, 'load_translation'));
add_action('wp', array(&$this, 'wp'));
add_action('wp_enqueue_scripts', array(&$this, 'wp_enqueue_scripts'));
add_action('wpulivesearch_form', array(&$this, 'display_form'), 10, 4);
}

public function plugins_loaded() {
/* Translation */
public function load_translation() {
$lang_dir = dirname(plugin_basename(__FILE__)) . '/lang/';
if (!load_plugin_textdomain('wpulivesearch', false, $lang_dir)) {
if (strpos(__DIR__, 'mu-plugins') !== false) {
load_muplugin_textdomain('wpulivesearch', $lang_dir);
} else {
load_plugin_textdomain('wpulivesearch', false, $lang_dir);
}

$this->plugin_description = __('Live Search datas', 'wpulivesearch');
}

public function plugins_loaded() {

/* Updater */
require_once __DIR__ . '/inc/WPUBaseUpdate/WPUBaseUpdate.php';
Expand Down

0 comments on commit b4d7487

Please sign in to comment.