Skip to content

Commit

Permalink
Fixes for directory
Browse files Browse the repository at this point in the history
  • Loading branch information
xxsimoxx committed Dec 3, 2024
1 parent 3c60a0d commit 9ad48f1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 34 deletions.
22 changes: 0 additions & 22 deletions build.sh

This file was deleted.

26 changes: 22 additions & 4 deletions classes/UpdateClient.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* 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
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Full
* 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
* -----------------------------------------------------------------------------
*/

Expand All @@ -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.
Expand Down Expand Up @@ -69,6 +74,9 @@ class UpdateClient {
*/
private $component_data = '';

private $identifier = null;
private $server_slug = null;

/**
* Constructor.
*
Expand All @@ -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();

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -885,4 +903,4 @@ public function get_latest_version_number() {
}

// Run it!
UpdateClient::get_instance();
UpdateClient::get_instance();
1 change: 1 addition & 0 deletions classes/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
8 changes: 4 additions & 4 deletions codepotent-registration-honeypot.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* -----------------------------------------------------------------------------
* Plugin Name: Registration Honeypot
* Description: Add a honeypot input to the ClassicPress registration form to prevent spambots from creating accounts.
* Version: 1.1.2
* Version: 1.1.3
* Requires CP: 1.0
* Requires PHP: 5.6
* Author: Simone Fioravanti
Expand Down Expand Up @@ -54,7 +54,7 @@ function enqueue_login_style() {
add_action('register_form', __NAMESPACE__.'\append_honeypot_input');
function append_honeypot_input() {
echo '<p class="register_additional">';
echo '<label for="register_additional">'.esc_html__('Leave this field empty.', 'registration-honeypot').'</label><br />';
echo '<label for="register_additional">'.esc_html__('Leave this field empty.', 'codepotent-registration-honeypot').'</label><br />';
echo '<input type="text" name="register_additional" id="register_additional" value="" autocomplete="off" /></label>';
echo '</p>';
}
Expand All @@ -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'));
}
6 changes: 2 additions & 4 deletions includes/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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';
const URL_STYLES = URL_SELF.'/styles';

0 comments on commit 9ad48f1

Please sign in to comment.