-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Meta GPT Generator | ||
|
||
Plugin WordPress qui génère automatiquement les meta titles et descriptions avec ChatGPT. | ||
|
||
## Description | ||
|
||
Ce plugin permet de : | ||
- Générer automatiquement les meta titles et descriptions | ||
- Configuration simple de l'API ChatGPT | ||
- Interface d'administration intuitive | ||
- Génération automatique ou manuelle des metas | ||
|
||
## Installation | ||
|
||
1. Téléchargez le plugin | ||
2. Activez-le dans WordPress | ||
3. Configurez votre clé API ChatGPT | ||
4. C'est prêt ! | ||
|
||
## Changelog | ||
|
||
### 1.1 | ||
- Ajout de l'auto-updater | ||
- Amélioration de la génération automatique | ||
|
||
### 1.0 | ||
- Version initiale |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
/** | ||
* Plugin Update Checker - Add to your main plugin file | ||
*/ | ||
|
||
// Prevent direct access | ||
if (!defined('ABSPATH')) exit; | ||
|
||
class PluginGitHubUpdater { | ||
private $file; | ||
private $plugin; | ||
private $basename; | ||
private $active; | ||
private $username; | ||
private $repository; | ||
private $github_response; | ||
|
||
public function __construct($file) { | ||
$this->file = $file; | ||
add_action('admin_init', array($this, 'set_plugin_properties')); | ||
|
||
// Add filters for plugin updates | ||
add_filter('pre_set_site_transient_update_plugins', array($this, 'modify_transient'), 10, 1); | ||
add_filter('plugins_api', array($this, 'plugin_popup'), 10, 3); | ||
add_filter('upgrader_post_install', array($this, 'after_install'), 10, 3); | ||
} | ||
|
||
public function set_plugin_properties() { | ||
$this->plugin = get_plugin_data($this->file); | ||
$this->basename = plugin_basename($this->file); | ||
$this->active = is_plugin_active($this->basename); | ||
} | ||
|
||
public function set_username($username) { | ||
$this->username = $username; | ||
} | ||
|
||
public function set_repository($repository) { | ||
$this->repository = $repository; | ||
} | ||
|
||
private function get_repository_info() { | ||
if (is_null($this->github_response)) { | ||
$request_uri = sprintf('https://api.github.com/repos/%s/%s/releases/latest', | ||
$this->username, | ||
$this->repository | ||
); | ||
|
||
$response = wp_remote_get($request_uri); | ||
|
||
if (is_wp_error($response)) { | ||
return false; | ||
} | ||
|
||
$response = json_decode(wp_remote_retrieve_body($response)); | ||
|
||
if ($response) { | ||
$this->github_response = $response; | ||
} | ||
} | ||
} | ||
|
||
public function modify_transient($transient) { | ||
if (property_exists($transient, 'checked')) { | ||
if ($checked = $transient->checked) { | ||
$this->get_repository_info(); | ||
|
||
$out_of_date = version_compare( | ||
$this->github_response->tag_name, | ||
$checked[$this->basename], | ||
'gt' | ||
); | ||
|
||
if ($out_of_date) { | ||
$new_files = $this->github_response->zipball_url; | ||
$slug = current(explode('/', $this->basename)); | ||
|
||
$plugin = array( | ||
'url' => $this->plugin["PluginURI"], | ||
'slug' => $slug, | ||
'package' => $new_files, | ||
'new_version' => $this->github_response->tag_name | ||
); | ||
|
||
$transient->response[$this->basename] = (object) $plugin; | ||
} | ||
} | ||
} | ||
|
||
return $transient; | ||
} | ||
|
||
public function plugin_popup($result, $action, $args) { | ||
if ($action !== 'plugin_information') { | ||
return false; | ||
} | ||
|
||
if (!empty($args->slug)) { | ||
if ($args->slug == current(explode('/', $this->basename))) { | ||
$this->get_repository_info(); | ||
|
||
$plugin = array( | ||
'name' => $this->plugin["Name"], | ||
'slug' => $this->basename, | ||
'version' => $this->github_response->tag_name, | ||
'author' => $this->plugin["AuthorName"], | ||
'author_profile' => $this->plugin["AuthorURI"], | ||
'last_updated' => $this->github_response->published_at, | ||
'homepage' => $this->plugin["PluginURI"], | ||
'short_description' => $this->plugin["Description"], | ||
'sections' => array( | ||
'Description' => $this->plugin["Description"], | ||
'Updates' => $this->github_response->body | ||
), | ||
'download_link' => $this->github_response->zipball_url | ||
); | ||
|
||
return (object) $plugin; | ||
} | ||
} | ||
return $result; | ||
} | ||
|
||
public function after_install($response, $hook_extra, $result) { | ||
global $wp_filesystem; | ||
|
||
$install_directory = plugin_dir_path($this->file); | ||
$wp_filesystem->move($result['destination'], $install_directory); | ||
$result['destination'] = $install_directory; | ||
|
||
if ($this->active) { | ||
activate_plugin($this->basename); | ||
} | ||
|
||
return $result; | ||
} | ||
} |