Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare Release v2.0.6 #229

Merged
merged 13 commits into from
Jan 15, 2025
50 changes: 43 additions & 7 deletions .assets/js/wp-content-pilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* Licensed under the GPLv2+ license.
*/

/*jslint browser: true */
/*global jQuery:false */
/*global confirm:false */
/*global wpcp_logger_offset:false */
/*global wp_content_pilot_i10n:false */
/* jslint browser: true */
/* global jQuery:false */
/* global confirm:false */
/* global wpcp_logger_offset:false */
/* global wp_content_pilot_i10n:false */
jQuery(document).ready(function ($) {
'use strict';
$.wp_content_pilot = {
Expand Down Expand Up @@ -206,13 +206,49 @@ jQuery(document).ready(function ($) {
polylang_language_code_field.hide();
}
}).change();
}

},
};
$.wp_content_pilot.init();
$.wp_content_pilot.youtube();
$('#wpcp-delete-campaign-posts').on('click', $.wp_content_pilot.deleteCampaignPosts);
$('#wpcp-clear-logs').on('click', $.wp_content_pilot.clearLogs);
$('#wpcp-run-campaign').on('click', $.wp_content_pilot.handle_manual_campaign);
$.wp_content_pilot.polylang();

// Remove cached link.
$(document).on('click', '.wpcp_remove_cached_link', function (e) {
e.preventDefault();

var $el = $(this);
var link = $el.data('link');

// Disable the button and update its text immediately to indicate processing.
$el.prop('disabled', true).text('Removing...');

$el.prop('disabled', true)
.text('Removing...')
.css({
'pointer-events': 'none',
'opacity': '0.6',
'cursor': 'not-allowed'
});

// Send the AJAX request.
wp.ajax.send('wpcp_remove_cached_link', {
data: {
link: link,
nonce: wp_content_pilot_i10n.nonce
},
success: function (response) {
// Update the button text to 'Removed'
$el.text('Removed');
alert('The link has been successfully removed from the database.');
},
error: function (error) {
// Revert its text if the request fails
$el.text('Error occurred');
alert('Failed to remove the link. ' + (error || 'An unknown error occurred.'));
}
});
});
});
82 changes: 48 additions & 34 deletions i18n/languages/wp-content-pilot.pot
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Copyright (C) 2024 PluginEver
# Copyright (C) 2025 PluginEver
# This file is distributed under the GPL v2 or later.
msgid ""
msgstr ""
"Project-Id-Version: WP Content Pilot 2.0.5\n"
"Project-Id-Version: WP Content Pilot 2.0.6\n"
"Report-Msgid-Bugs-To: https://pluginever.com/support/\n"
"POT-Creation-Date: 2024-12-30 09:59:48+00:00\n"
"POT-Creation-Date: 2025-01-15 09:14:06+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2024-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2025-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: en\n"
Expand All @@ -24,11 +24,11 @@ msgstr ""
"X-Textdomain-Support: yes\n"
"X-Generator: grunt-wp-i18n 1.0.3\n"

#: includes/action-functions.php:12 includes/action-functions.php:280
#: includes/action-functions.php:12 includes/action-functions.php:309
msgid "No Cheating"
msgstr ""

#: includes/action-functions.php:22 includes/action-functions.php:320
#: includes/action-functions.php:22 includes/action-functions.php:349
msgid "Invalid post action"
msgstr ""

Expand All @@ -41,23 +41,23 @@ msgstr ""
msgid "Reached campaign post limit. So campaign stopping publish new post"
msgstr ""

#: includes/action-functions.php:243
#: includes/action-functions.php:272
msgid "Post Publish"
msgstr ""

#: includes/action-functions.php:305 includes/action-functions.php:362
#: includes/action-functions.php:334 includes/action-functions.php:391
msgid "Cheating?"
msgstr ""

#: includes/action-functions.php:327
#: includes/action-functions.php:356
msgid "Campaign <strong>%s</strong> manually initiated by <strong>%s</strong>"
msgstr ""

#: includes/action-functions.php:341
#: includes/action-functions.php:370
msgid "A post successfully created by campaign %s titled %s"
msgstr ""

#: includes/action-functions.php:375
#: includes/action-functions.php:404
msgid "Something wrong, please try again."
msgstr ""

Expand Down Expand Up @@ -1950,7 +1950,7 @@ msgid "Failed readability reason [%s] changing to different link"
msgstr ""

#: includes/modules/class-wpcp-article.php:259
#: includes/modules/class-wpcp-envato.php:376
#: includes/modules/class-wpcp-envato.php:388
#: includes/modules/class-wpcp-flickr.php:303
#: includes/modules/class-wpcp-youtube.php:353
msgid "Cleaning title"
Expand All @@ -1962,7 +1962,7 @@ msgid "Making article content from response"
msgstr ""

#: includes/modules/class-wpcp-article.php:276
#: includes/modules/class-wpcp-envato.php:418
#: includes/modules/class-wpcp-envato.php:430
#: includes/modules/class-wpcp-feed.php:203
#: includes/modules/class-wpcp-flickr.php:344
#: includes/modules/class-wpcp-youtube.php:392
Expand Down Expand Up @@ -1996,10 +1996,28 @@ msgid "Getting banned hosts for skipping links"
msgstr ""

#: includes/modules/class-wpcp-article.php:386
#: includes/modules/class-wpcp-feed.php:252
#: includes/modules/class-wpcp-feed.php:254
msgid "Finding links from response and inserting into database"
msgstr ""

#: includes/modules/class-wpcp-article.php:406
#: includes/modules/class-wpcp-envato.php:317
#: includes/modules/class-wpcp-feed.php:286
#: includes/modules/class-wpcp-youtube.php:515
#. translators: %s URL, %s URL, %s Remove
msgid ""
"The link [%s] is already in database, skipping. Remove it from database: <a "
"href=\"#remove-cached-link\" class=\"wpcp_remove_cached_link\" "
"data-link=\"%s\">%s</a>"
msgstr ""

#: includes/modules/class-wpcp-article.php:409
#: includes/modules/class-wpcp-envato.php:320
#: includes/modules/class-wpcp-feed.php:289
#: includes/modules/class-wpcp-youtube.php:518
msgid "Remove"
msgstr ""

#: includes/modules/class-wpcp-envato.php:38
msgid "Item classification"
msgstr ""
Expand Down Expand Up @@ -2208,35 +2226,35 @@ msgstr ""
msgid "Checking duplicate links in store..."
msgstr ""

#: includes/modules/class-wpcp-envato.php:322
#: includes/modules/class-wpcp-envato.php:334
msgid "Finding images from item preview"
msgstr ""

#: includes/modules/class-wpcp-envato.php:348
#: includes/modules/class-wpcp-envato.php:360
msgid "Making affiliate url"
msgstr ""

#: includes/modules/class-wpcp-envato.php:363
#: includes/modules/class-wpcp-envato.php:375
msgid "Extracting tags from item"
msgstr ""

#: includes/modules/class-wpcp-envato.php:370
#: includes/modules/class-wpcp-envato.php:382
msgid "Generating envato article from [ %s ]"
msgstr ""

#: includes/modules/class-wpcp-envato.php:384
#: includes/modules/class-wpcp-envato.php:396
msgid "Extracting categories from response"
msgstr ""

#: includes/modules/class-wpcp-envato.php:390
#: includes/modules/class-wpcp-envato.php:402
msgid "Extracting tags from response"
msgstr ""

#: includes/modules/class-wpcp-envato.php:396
#: includes/modules/class-wpcp-envato.php:408
msgid "Combining all parts for article"
msgstr ""

#: includes/modules/class-wpcp-envato.php:421
#: includes/modules/class-wpcp-envato.php:433
msgid "Inserting link into store..."
msgstr ""

Expand Down Expand Up @@ -2299,32 +2317,28 @@ msgstr ""
msgid "Cleaning post title"
msgstr ""

#: includes/modules/class-wpcp-feed.php:229
#: includes/modules/class-wpcp-feed.php:231
msgid "Failed fetching feeds [%s]"
msgstr ""

#: includes/modules/class-wpcp-feed.php:231
#: includes/modules/class-wpcp-feed.php:233
msgid "Checking for force feed and initiating force feed"
msgstr ""

#: includes/modules/class-wpcp-feed.php:245
#: includes/modules/class-wpcp-feed.php:247
#: includes/modules/class-wpcp-feed.php:249
msgid "Could not find any article, waiting..."
msgstr ""

#: includes/modules/class-wpcp-feed.php:279
msgid "Checking the duplicate status: [%s]"
msgstr ""

#: includes/modules/class-wpcp-feed.php:281
msgid "The link [%s] is already in database, skipping"
msgid "Checking the duplicate status: [%s]"
msgstr ""

#: includes/modules/class-wpcp-feed.php:288
#: includes/modules/class-wpcp-feed.php:300
msgid "The title [%s] is already in used, skipping"
msgstr ""

#: includes/modules/class-wpcp-feed.php:303
#: includes/modules/class-wpcp-feed.php:315
msgid "Total found links [%d] and accepted [%d] and reject [%d]"
msgstr ""

Expand Down Expand Up @@ -2813,11 +2827,11 @@ msgstr ""
msgid "Finding links from response and storing....."
msgstr ""

#: includes/modules/class-wpcp-youtube.php:532
#: includes/modules/class-wpcp-youtube.php:543
msgid "Total found links [%d] and accepted [%d] and rejected [%d]"
msgstr ""

#: includes/modules/class-wpcp-youtube.php:629
#: includes/modules/class-wpcp-youtube.php:640
msgid "Youtube campaign wont run because you did not set the API details yet."
msgstr ""

Expand Down
29 changes: 29 additions & 0 deletions includes/action-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,35 @@ function wpcp_clear_logs() {

add_action( 'wp_ajax_wpcp_clear_logs', 'wpcp_clear_logs' );

/**
* Remove cached link.
*
* @since 2.0.6
* @return void
*/
function wpcp_remove_cached_link() {
if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( $_REQUEST['nonce'], 'ajax_action' ) ) {
wp_send_json_error( 'Unauthorized!!!' );
}

$link = isset( $_REQUEST['link'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['link'] ) ) : '';
if ( empty( $link ) ) {
wp_send_json_error( 'Invalid link to process' );
}

global $wpdb;
$link_deleted = $wpdb->delete( $wpdb->wpcp_links, array( 'url' => $link ) );

if ( ! $link_deleted ) {
wp_send_json_error( 'Maybe link is not found in the database' );
}

wp_send_json_success( 'success' );
exit();
}

add_action( 'wp_ajax_wpcp_remove_cached_link', 'wpcp_remove_cached_link' );


// TODO: Keyword Suggestion https://www.google.com/complete/search?q=w&cp=1&client=psy-ab&xssi=t&gs_ri=gws-wiz&hl=en-BD&authuser=0&psi=4oO9XIj8ONm89QOY2LCgDA.1555923942084&ei=4oO9XIj8ONm89QOY2LCgDA.
if ( ! function_exists( 'wpcp_pro_get_keyword_suggestion' ) ) :
Expand Down
4 changes: 1 addition & 3 deletions includes/admin/metabox-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,9 @@ function wpcp_not_save_featured_image_field() {
add_action( 'wpcp_campaign_options_meta_fields', 'wpcp_external_link_field', 20 );
add_action( 'wpcp_campaign_options_meta_fields', 'wpcp_featured_image_random_field', 20 );
add_action( 'wpcp_campaign_options_meta_fields', 'wpcp_canonical_link_field', 20 );
add_action( 'wpcp_campaign_options_meta_fields', 'wpcp_target_rel_field', 20 );
// add_action( 'wpcp_campaign_options_meta_fields', 'wpcp_target_rel_field', 20 ); // not used this, because of not working properly.
add_action( 'wpcp_campaign_options_meta_fields', 'wpcp_not_save_featured_image_field', 20 );


function wpcp_search_replace_metafield( $post ) {
?>
<div class="wpcp-repeater form-field wpcp-field _wpcp_custom_meta_fields-field pro">
Expand Down Expand Up @@ -396,7 +395,6 @@ function wpcp_search_replace_metafield( $post ) {

add_action( 'wpcp_advanced_settings_metabox', 'wpcp_search_replace_metafield' );


function wpcp_post_meta_metafield( $post ) {
?>
<div class="wpcp-repeater form-field wpcp-field _wpcp_custom_meta_fields-field pro">
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/views/tables/class-wpcp-logs-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function column_default( $item, $column_name ) {
case 'level':
return $item->level ? sprintf( '<span class="%s">%s</span>', sanitize_html_class( strtolower( $item->level ) ), $item->level ) : '&mdash;';
case 'log':
return $item->message ? wp_strip_all_tags( $item->message ) : '&mdash;';
return $item->message ? wp_kses_post( $item->message ) : '&mdash;';
case 'date':
return $item->created_at;
default:
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wpcp-logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function write_log( $message, $severity, $campaign_id = 0 ) {
// Grab time.
$time = gmdate( $this->params['dateFormat'] );
// Write time, url, & message to end of file.
fwrite( $this->file, wp_strip_all_tags( "[$time] : [$severity] - $message" ) . PHP_EOL );
fwrite( $this->file, wp_kses_post( "[$time] : [$severity] - $message" ) . PHP_EOL );
}

$severities = array( 'INFO', 'WARNING', 'ERROR' );
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wpcp-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class WPCP_Admin_Notices {
* @since 1.0.0
*/
private static $predefined_notices = array(
'upgrade_notice' => 'upgrade_notice',
'article_notice' => 'article_notice',
'upgrade_notice' => 'upgrade_notice',
'article_notice' => 'article_notice',
);

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function wpcp_insert_log( $message, $level = 'info', $camp_id = '0' ) {
array(
'camp_id' => $camp_id,
'level' => $level,
'message' => wp_strip_all_tags( $message ),
'message' => wp_kses_post( $message ),
'instance_id' => defined( 'WPCP_CAMPAIGN_INSTANCE' ) && WPCP_CAMPAIGN_INSTANCE ? WPCP_CAMPAIGN_INSTANCE : null,
'created_at' => current_time( 'mysql' ),
)
Expand Down
Loading
Loading