From fe5b5e1c8e41d5d89ce37677257c74cbb375522b Mon Sep 17 00:00:00 2001 From: Mikhail Kobzarev Date: Tue, 28 Nov 2023 15:33:12 +0300 Subject: [PATCH] Release 1.7.2 --- mihdan-lite-youtube-embed.php | 4 ++-- readme.txt | 6 +++++- src/Options.php | 6 +++++- src/Settings.php | 22 +++++++++++++++++++++- uninstall.php | 21 ++++++++++++++++++++- 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/mihdan-lite-youtube-embed.php b/mihdan-lite-youtube-embed.php index 372fc95..f7ff100 100644 --- a/mihdan-lite-youtube-embed.php +++ b/mihdan-lite-youtube-embed.php @@ -2,7 +2,7 @@ /** * Plugin Name: Lite Video Embed * Description: A faster YouTube/RuTube embed. Renders faster than a sneeze. - * Version: 1.7.1 + * Version: 1.7.2 * Author: Mikhail Kobzarev * Author URI: https://www.kobzarev.com/ * Plugin URI: https://wordpress.org/plugins/mihdan-lite-youtube-embed/ @@ -18,7 +18,7 @@ exit; } -define( 'MIHDAN_LITE_YOUTUBE_EMBED_VERSION', '1.7.1' ); +define( 'MIHDAN_LITE_YOUTUBE_EMBED_VERSION', '1.7.2' ); define( 'MIHDAN_LITE_YOUTUBE_EMBED_SLUG', 'mihdan-lite-youtube-embed' ); define( 'MIHDAN_LITE_YOUTUBE_EMBED_NAME', 'Lite Video Embed' ); define( 'MIHDAN_LITE_YOUTUBE_EMBED_DIR', __DIR__ ); diff --git a/readme.txt b/readme.txt index 41f8ae7..b5b43d4 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.kobzarev.com/donate/ Tags: youtube, wordpress, seo-friendly, seo, cache, embed Requires at least: 5.0 Tested up to: 6.4 -Stable tag: 1.7.1 +Stable tag: 1.7.2 Requires PHP: 7.4 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -54,6 +54,10 @@ e.g. == Changelog == += 1.7.2 (28.11.2023) = +* Added setting to clean up the database when the plugin is uninstalled +* Fixed a fatal error occurring when deleting the cache + = 1.7.1 (17.11.2023) = * Fixed the hook `mlye/youtube/render` diff --git a/src/Options.php b/src/Options.php index 6403fae..35accc5 100644 --- a/src/Options.php +++ b/src/Options.php @@ -207,7 +207,7 @@ function admin_init() { foreach ( $this->sections_array as $section ) { if ( false == get_option( $section['id'] ) ) { // Add a new field as section ID. - add_option( $section['id'] ); + add_option( $section['id'], [] ); } // Deals with sections description. @@ -950,6 +950,10 @@ function script() { #mlye_plugins .form-table > tr > th, #mlye_plugins .form-table > tbody > tr > th { display: none; + } + #submit_mlye_contacts, + #submit_mlye_plugins { + display: none; } wposa->add_field( + 'mlye_tools', + [ + 'id' => 'delete_plugin_data', + 'type' => 'checkbox', + 'name' => __( 'Delete plugin data', 'mihdan-lite-youtube-embed' ), + 'desc' => __( 'Delete plugin data upon uninstall.', 'mihdan-lite-youtube-embed' ), + ] + ); + $this->wposa->add_section( array( 'id' => 'mlye_contacts', @@ -256,7 +266,17 @@ public function setup_fields() { 'id' => 'description', 'type' => 'html', 'name' => __( 'Telegram', 'mihdan-lite-youtube-embed' ), - 'desc' => __( 'Связаться со мной можно в телеграм чате поддержки', 'mihdan-lite-youtube-embed' ), + 'desc' => __( '🆘 Связаться со мной можно в телеграм чате поддержки.', 'mihdan-lite-youtube-embed' ), + ) + ); + + $this->wposa->add_field( + 'mlye_contacts', + array( + 'id' => 'donate', + 'type' => 'html', + 'name' => __( 'Donate', 'mihdan-lite-youtube-embed' ), + 'desc' => __( '❤️ Помочь в развитии проекта можно на официальнос сайте', 'mihdan-lite-youtube-embed' ), ) ); diff --git a/uninstall.php b/uninstall.php index 25d2d2c..c3a9f12 100644 --- a/uninstall.php +++ b/uninstall.php @@ -18,17 +18,36 @@ class Uninstall { */ public function __construct() { $this->clear_oembed_cache(); + + $tools = get_option( 'mlye_tools' ); + + // Delete plugin data upon uninstall. + if ( isset( $tools['delete_plugin_data'] ) && $tools['delete_plugin_data'] === 'on' ) { + $this->delete_plugin_data(); + } } /** * Clear oembed cache. */ - public function clear_oembed_cache() { + public function clear_oembed_cache(): void { global $wpdb; $sql = "DELETE FROM {$wpdb->postmeta} WHERE LEFT(meta_key, 8) = '_oembed_'"; $wpdb->query( $sql ); } + + /** + * Delete plugin data upon uninstall. + * + * @return void + */ + public function delete_plugin_data(): void { + global $wpdb; + + $sql = "DELETE FROM {$wpdb->options} WHERE LEFT(option_name, 5) = 'mlye_'"; + $wpdb->query( $sql ); + } } new Uninstall(); \ No newline at end of file