Skip to content

Commit

Permalink
Revert "closes #71"
Browse files Browse the repository at this point in the history
This reverts commit 5d375c0.
  • Loading branch information
gardenboi committed Nov 25, 2023
1 parent 5d375c0 commit b70b768
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 150 deletions.
61 changes: 0 additions & 61 deletions admin/CF7_AntiSpam_Admin_Customizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use CF7_AntiSpam\Core\CF7_AntiSpam;
use CF7_AntiSpam\Core\CF7_Antispam_Geoip;
use WP_Query;

/**
* The plugin settings.
*
Expand Down Expand Up @@ -461,15 +459,6 @@ public function cf7a_options_init() {
'cf7a_honeyform'
);

/* Honeyform excluded pages */
add_settings_field(
'honeyform_excluded_pages',
__( 'Add pages you wish shouldn\'t have a Honeyform', 'cf7-antispam' ),
array( $this, 'cf7a_honeyform_excluded_pages_callback' ),
'cf7a-settings',
'cf7a_honeyform'
);

/* Identity Protection */
add_settings_section(
'cf7a_identity_protection',
Expand Down Expand Up @@ -1102,7 +1091,6 @@ public function cf7a_sanitize_options( $input ) {
/* honeyform */
$new_input['check_honeyform'] = isset( $input['check_honeyform'] ) ? 1 : 0;
$new_input['honeyform_position'] = ! empty( $input['honeyform_position'] ) ? sanitize_title( $input['honeyform_position'] ) : 'wp_body_open';
$new_input['honeyform_excluded_pages'] = ! empty( $input['honeyform_excluded_pages'] ) ? array_map('number_format', $input['honeyform_excluded_pages']) : '';

/* honeyform */
$new_input['identity_protection_user'] = isset( $input['identity_protection_user'] ) ? 1 : 0;
Expand Down Expand Up @@ -1474,55 +1462,6 @@ public function cf7a_honeyform_position_callback() {
);
}

public function cf7a_honeyform_excluded_pages_callback() {
$args = array(
'post_type' => 'page', // change this to the post type you're querying
'fields' => 'ids', // get all posts
);
$query = new WP_Query($args);

$options = '';

if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$options .= '<option value="' . get_the_ID() . '">' . get_the_title() . '</option>';
}
}

$admin_options = get_option( 'cf7a_options' );
$excluded = $admin_options['honeyform_excluded_pages'];
$str_excluded = '';
if ( is_array($excluded) ) {
foreach ($excluded as $entry) {
$str_excluded .= '<option selected="true" value="' . $entry . '">' . get_the_title($entry) . '</option>';
}
}
wp_reset_postdata();
printf(
'<div class="honeyform-container">
<div class="row">
<div class="add">
<select name="add" multiple class="form-control add-select">
%s
</select>
<br/>
<div class="add-list">Add ></div>
</div>
<div class="remove">
<select id="honeyform_excluded_pages" name="cf7a_options[honeyform_excluded_pages][]" multiple="multiple" class="form-control remove-select" >
%s
</select>
<br/>
<div class="remove-list">< Remove</div>
</div>
</div>
</div>',
$options,
$str_excluded
);
}

/** It creates a checkbox with the id of "cf7a_identity_protection_user_callback" */
public function cf7a_identity_protection_user_callback() {
printf(
Expand Down
11 changes: 1 addition & 10 deletions core/CF7_AntiSpam_Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,13 @@ public function cf7a_honeyform( $content ) {
* @param array $option an array of pages id where cf7-antispam won't insert the honeyform.
*/
$excluded_ids = apply_filters( 'cf7a_honeyform_excluded_id', array() );
$current_id = get_the_ID();

// Check if the current post ID is in the excluded IDs array
if ( in_array( $current_id, $excluded_ids ) ) {
if ( in_array( get_the_ID(), $excluded_ids ) ) {
// If the current post ID is excluded, return the original content
return $content;
}

$cf7a_options = get_option('cf7a_options');
if ( in_array( $current_id, $cf7a_options['honeyform_excluded_pages'] ) ) {
// If the current post ID is excluded, return the original content
return $content;
}



/* $html will store the honeyform html */
$html = '';

Expand Down
1 change: 0 additions & 1 deletion engine/CF7_AntiSpam_Activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public static function init_vars() {
'bad_user_agent_list' => array(),
'dnsbl_list' => array(),
'honeypot_input_names' => array(),
'honeyform_excluded_pages' => array(),
'languages' => array(
'allowed' => array(),
'disallowed' => array(),
Expand Down
56 changes: 0 additions & 56 deletions src/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,62 +77,6 @@ window.onload = function () {
AdvSettingsFormEl.classList.add( 'hidden' );
}
};

// Honeyform page exlusion
if ( document.body.classList.contains( 'cf7-antispam-admin' ) ) {
const addListButton = document.querySelector('.add-list');
const addSelect = document.querySelector('.add-select');
const removeListButton = document.querySelector('.remove-list');
const removeSelect = document.querySelector('.remove-select');

for (const remove of removeSelect) {
for (const add of addSelect) {
if (remove.value === add.value) {
addSelect.removeChild(add);
}
}
}

addListButton.addEventListener('click', () => {
for (const option of addSelect.options) {
if (option.selected) {
const name = option.textContent;
const value = option.value;

if (!removeSelect.options[value]) {
const newOption = document.createElement('option');
newOption.setAttribute('selected', true);
newOption.value = value;
newOption.textContent = name;

removeSelect.appendChild(newOption);
}
option.remove();
}
}
});

removeListButton.addEventListener('click', () => {

for (const option of removeSelect.options) {
if (option.selected) {
console.log("2")
const name = option.textContent;
const value = option.value;

if (!removeSelect.options[value]) {
const newOption = document.createElement('option');
newOption.value = value;
newOption.textContent = name;

addSelect.appendChild(newOption);
}
option.remove();
}
}
});
}

/* on click show advanced options */
document
.getElementById( 'enable_advanced_settings' )
Expand Down
22 changes: 0 additions & 22 deletions src/settings/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,6 @@ $color__info: $color__blue;
}
}

// Style for honeyform exclude pages
.honeyform-container {

.row {
display: flex;
flex-wrap: wrap;

.add,
.remove {
flex: 1;
select {
width: 100%;
min-height: 120px;
}
div {
text-align: center;
border: #8c8f94 solid 1px;
}
}
}
}

.blacklist-table {
display: block;
max-width: 100%;
Expand Down

0 comments on commit b70b768

Please sign in to comment.