From 9ad48f1a56e7e491f279b8b956e17b6dd02d81fe Mon Sep 17 00:00:00 2001 From: xxsimoxx Date: Tue, 3 Dec 2024 14:12:28 +0100 Subject: [PATCH] Fixes for directory --- build.sh | 22 ---------------------- classes/UpdateClient.class.php | 26 ++++++++++++++++++++++---- classes/index.php | 1 + codepotent-registration-honeypot.php | 8 ++++---- includes/constants.php | 6 ++---- 5 files changed, 29 insertions(+), 34 deletions(-) delete mode 100755 build.sh diff --git a/build.sh b/build.sh deleted file mode 100755 index cadec6c..0000000 --- a/build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -e - -git status - -slug='codepotent-registration-honeypot' - -phpfile="${slug}.php" - -version=$(wp --allow-root --skip-plugins eval '$v = get_plugin_data( "'${phpfile}'" ); echo $v["Version"];') - -echo "Going to release : v${version}" - -read -n 1 -s -r -p "If OK, press any key to continue (CTRL-C to exit)." - -echo - -git archive -o "../${slug}-${version}.zip" --prefix ${slug}/ HEAD - -hub release create -d -a "../${slug}-${version}.zip" -m "Registration Honeypot ${version}" "${version}" - -rm "../${slug}-${version}.zip" diff --git a/classes/UpdateClient.class.php b/classes/UpdateClient.class.php index 99c7f91..0cf9bbc 100644 --- a/classes/UpdateClient.class.php +++ b/classes/UpdateClient.class.php @@ -6,7 +6,7 @@ * Author: Simone Fioravanti * Author URI: https://software.gieffeedizioni.it * API Version: 2.0.0 - * Last modified on Update Manager release: 2.4.3 + * Last modified on Update Manager release: 2.5.3 * ----------------------------------------------------------------------------- * This is free software released under the terms of the General Public License, * version 2, or later. It is distributed WITHOUT ANY WARRANTY; without even the @@ -14,7 +14,7 @@ * text of the license is available at https://www.gnu.org/licenses/gpl-2.0.txt. * ----------------------------------------------------------------------------- * Copyright 2021, John Alarcon (Code Potent) - * 2021-2022, Simone Fioravanti + * 2021-2024, Simone Fioravanti * ----------------------------------------------------------------------------- */ @@ -24,6 +24,11 @@ // EDIT: URL where Update Manager is installed; with trailing slash! const UPDATE_SERVER = 'https://software.gieffeedizioni.it/'; +// EDIT: Choose what to do in ClassicPress v.2 and above. +// Set to true to disable UpdateClient if updates are provided +// using the Classicpress Plugin Directory. +const USE_DIRECTORY = true; + // EDIT: Comment this out and fill with the first part of the url // of your Download link to make sure that updates // are served from your trusted source. @@ -69,6 +74,9 @@ class UpdateClient { */ private $component_data = ''; + private $identifier = null; + private $server_slug = null; + /** * Constructor. * @@ -94,6 +102,16 @@ private function __construct() { 'post' => [], ]; + // Should directory take over? + include_once ABSPATH.'wp-admin/includes/plugin.php'; + if ( + USE_DIRECTORY && + version_compare(function_exists('classicpress_version') ? classicpress_version() : '0', '2', '>=') && + is_plugin_active('classicpress-directory-integration/classicpress-directory-integration.php') + ) { + return; + } + // Find and store the latest CP version during update process. $this->cp_latest_version = $this->get_latest_version_number(); @@ -579,7 +597,7 @@ private function get_component_data($action, $component='') { // Initialize the data to be posted. $body = apply_filters('codepotent_update_manager_filter_'.$this->config['id'].'_client_request', $this->config['post']); - + if ($action === 'plugin_information') { // If querying a single plugin, assign it to the post body. @@ -885,4 +903,4 @@ public function get_latest_version_number() { } // Run it! -UpdateClient::get_instance(); \ No newline at end of file +UpdateClient::get_instance(); diff --git a/classes/index.php b/classes/index.php index e69de29..b3d9bbc 100644 --- a/classes/index.php +++ b/classes/index.php @@ -0,0 +1 @@ +'; - echo '
'; + echo '
'; echo ''; echo '

'; } @@ -63,8 +63,8 @@ function append_honeypot_input() { add_action('register_post', __NAMESPACE__.'\check_honeypot_input', 0); add_action('login_form_register', __NAMESPACE__.'\check_honeypot_input', 0); function check_honeypot_input() { - if (empty($_POST['register_additional'])) { + if (empty($_POST['register_additional'])) { //phpcs:ignore WordPress.Security.NonceVerification.Missing return; } - wp_die(esc_html__('Automated registration is disabled.', 'registration-honeypot')); + wp_die(esc_html__('Automated registration is disabled.', 'codepotent-registration-honeypot')); } diff --git a/includes/constants.php b/includes/constants.php index 711bac8..ed23752 100644 --- a/includes/constants.php +++ b/includes/constants.php @@ -33,8 +33,6 @@ // Ex: codepotent const VENDOR_PREFIX = 'codepotent'; -// Ex: Our company is cool! -define(__NAMESPACE__.'\VENDOR_TAGLINE', esc_html__('', 'codepotent-registration-honeypot')); // Ex: plugin-folder-name const PLUGIN_SHORT_SLUG = 'registration-honeypot'; // Ex: dashicons-whatever @@ -58,7 +56,7 @@ // Ex: vendor_plugin_name_settings const PLUGIN_SETTINGS_VAR = PLUGIN_PREFIX.'_settings'; // Get plugin data from header file. -$plugin = get_plugin_data(PLUGIN_FILEPATH, false, false); +$plugin = get_plugin_data(PLUGIN_FILEPATH, false, false); //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited // Ex: My Plugin Name define(__NAMESPACE__.'\PLUGIN_NAME', $plugin['Name']); // Ex: Some plugin description @@ -123,4 +121,4 @@ // Ex: https://mysite.com/wp-content/plugins/my-plugin-name/scripts const URL_SCRIPTS = URL_SELF.'/scripts'; // Ex: https://mysite.com/wp-content/plugins/my-plugin-name/styles -const URL_STYLES = URL_SELF.'/styles'; \ No newline at end of file +const URL_STYLES = URL_SELF.'/styles';