diff --git a/.assets/js/wp-content-pilot.js b/.assets/js/wp-content-pilot.js index 88608eb..dd9a9d9 100644 --- a/.assets/js/wp-content-pilot.js +++ b/.assets/js/wp-content-pilot.js @@ -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 = { @@ -206,8 +206,7 @@ jQuery(document).ready(function ($) { polylang_language_code_field.hide(); } }).change(); - } - + }, }; $.wp_content_pilot.init(); $.wp_content_pilot.youtube(); @@ -215,4 +214,41 @@ jQuery(document).ready(function ($) { $('#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.')); + } + }); + }); }); diff --git a/i18n/languages/wp-content-pilot.pot b/i18n/languages/wp-content-pilot.pot index 152fc6b..30b6157 100644 --- a/i18n/languages/wp-content-pilot.pot +++ b/i18n/languages/wp-content-pilot.pot @@ -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 \n" "Language-Team: LANGUAGE \n" "Language: en\n" @@ -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 "" @@ -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 %s manually initiated by %s" 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 "" @@ -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" @@ -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 @@ -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: %s" +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 "" @@ -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 "" @@ -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 "" @@ -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 "" diff --git a/includes/action-functions.php b/includes/action-functions.php index ab58ed7..88d3632 100644 --- a/includes/action-functions.php +++ b/includes/action-functions.php @@ -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' ) ) : diff --git a/includes/admin/metabox-functions.php b/includes/admin/metabox-functions.php index d30e974..84838d9 100644 --- a/includes/admin/metabox-functions.php +++ b/includes/admin/metabox-functions.php @@ -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 ) { ?>
@@ -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 ) { ?>
diff --git a/includes/admin/views/tables/class-wpcp-logs-table.php b/includes/admin/views/tables/class-wpcp-logs-table.php index ca7a47d..558a704 100644 --- a/includes/admin/views/tables/class-wpcp-logs-table.php +++ b/includes/admin/views/tables/class-wpcp-logs-table.php @@ -254,7 +254,7 @@ public function column_default( $item, $column_name ) { case 'level': return $item->level ? sprintf( '%s', sanitize_html_class( strtolower( $item->level ) ), $item->level ) : '—'; case 'log': - return $item->message ? wp_strip_all_tags( $item->message ) : '—'; + return $item->message ? wp_kses_post( $item->message ) : '—'; case 'date': return $item->created_at; default: diff --git a/includes/class-wpcp-logger.php b/includes/class-wpcp-logger.php index 93860f7..5598f07 100644 --- a/includes/class-wpcp-logger.php +++ b/includes/class-wpcp-logger.php @@ -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' ); diff --git a/includes/class-wpcp-notices.php b/includes/class-wpcp-notices.php index 35831cb..8822dd1 100644 --- a/includes/class-wpcp-notices.php +++ b/includes/class-wpcp-notices.php @@ -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', ); /** diff --git a/includes/core-functions.php b/includes/core-functions.php index 6b1c28a..5946d5c 100644 --- a/includes/core-functions.php +++ b/includes/core-functions.php @@ -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' ), ) diff --git a/includes/modules/class-wpcp-article.php b/includes/modules/class-wpcp-article.php index 9cbc986..bb701f7 100644 --- a/includes/modules/class-wpcp-article.php +++ b/includes/modules/class-wpcp-article.php @@ -118,18 +118,18 @@ public function add_campaign_option_fields( $post ) { ) ); -// phpcs:disable -// echo WPCP_HTML::select_input( array( -// 'name' => '_article_language', -// 'label' => __( 'Select language to search article', 'wp-content-pilot' ), -// 'options' => $this->get_article_language(), -// 'default' => 'en', -// 'wrapper_class' => 'pro', -// 'attrs' => array( -// 'disabled' => 'disabled', -// ) -// ) ); -// phpcs:enable + //phpcs:disable + //echo WPCP_HTML::select_input( array( + // 'name' => '_article_language', + // 'label' => __( 'Select language to search article', 'wp-content-pilot' ), + // 'options' => $this->get_article_language(), + // 'default' => 'en', + // 'wrapper_class' => 'pro', + // 'attrs' => array( + // 'disabled' => 'disabled', + // ) + //) ); + //phpcs:enable echo WPCP_HTML::end_double_columns(); } @@ -400,6 +400,17 @@ protected function discover_links( $campaign_id, $keyword ) { } if ( wpcp_is_duplicate_url( $link ) ) { + wpcp_logger()->info( + sprintf( + /* translators: %s URL, %s URL, %s Remove */ + __( 'The link [%s] is already in database, skipping. Remove it from database: %s', 'wp-content-pilot' ), + esc_url( $link ), + esc_url( $link ), + __( 'Remove', 'wp-content-pilot' ) + ), + $campaign_id + ); + continue; } diff --git a/includes/modules/class-wpcp-envato.php b/includes/modules/class-wpcp-envato.php index 26662b9..f1c79b8 100644 --- a/includes/modules/class-wpcp-envato.php +++ b/includes/modules/class-wpcp-envato.php @@ -310,6 +310,18 @@ public function get_post( $campaign_id ) { wpcp_logger()->info( __( 'Checking duplicate links in store...', 'wp-content-pilot' ), $campaign_id ); if ( wpcp_is_duplicate_url( $item->url ) ) { wpcp_update_post_meta( $campaign_id, $page_key, $page_number + 1 ); + + wpcp_logger()->info( + sprintf( + /* translators: %s URL, %s URL, %s Remove */ + __( 'The link [%s] is already in database, skipping. Remove it from database: %s', 'wp-content-pilot' ), + esc_url( $item->url ), + esc_url( $item->url ), + __( 'Remove', 'wp-content-pilot' ) + ), + $campaign_id + ); + continue; } diff --git a/includes/modules/class-wpcp-feed.php b/includes/modules/class-wpcp-feed.php index a9ec21b..cb38d1a 100644 --- a/includes/modules/class-wpcp-feed.php +++ b/includes/modules/class-wpcp-feed.php @@ -213,6 +213,8 @@ public function get_post( $campaign_id ) { } /** + * Discover links + * * @param $source * @param $campaign_id * @@ -278,7 +280,17 @@ function wpcp_force_feed( $rss ) { $is_duplicate_url = apply_filters( 'wpcp_is_duplicate_url', empty( wpcp_is_duplicate_url( $url ) ) ? false : true, $url, $campaign_id ); wpcp_logger()->info( sprintf( __( 'Checking the duplicate status: [%s]', 'wp-content-pilot' ), $is_duplicate_url ), $campaign_id ); if ( $is_duplicate_url ) { - wpcp_logger()->info( sprintf( __( 'The link [%s] is already in database, skipping', 'wp-content-pilot' ), $url ), $campaign_id ); + wpcp_logger()->info( + sprintf( + /* translators: %s URL, %s URL, %s Remove */ + __( 'The link [%s] is already in database, skipping. Remove it from database: %s', 'wp-content-pilot' ), + esc_url( $url ), + esc_url( $url ), + __( 'Remove', 'wp-content-pilot' ) + ), + $campaign_id + ); + continue; } diff --git a/includes/modules/class-wpcp-youtube.php b/includes/modules/class-wpcp-youtube.php index 7d278ee..8d0ea35 100644 --- a/includes/modules/class-wpcp-youtube.php +++ b/includes/modules/class-wpcp-youtube.php @@ -509,6 +509,17 @@ protected function discover_links( $campaign_id, $source ) { } if ( wpcp_is_duplicate_url( $url ) ) { + wpcp_logger()->info( + sprintf( + /* translators: %s URL, %s URL, %s Remove */ + __( 'The link [%s] is already in database, skipping. Remove it from database: %s', 'wp-content-pilot' ), + esc_url( $url ), + esc_url( $url ), + __( 'Remove', 'wp-content-pilot' ) + ), + $campaign_id + ); + continue; } diff --git a/package-lock.json b/package-lock.json index 9512a5f..6db13f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wp-content-pilot", - "version": "2.0.5", + "version": "2.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wp-content-pilot", - "version": "2.0.5", + "version": "2.0.6", "license": "GPL-v2.0-or-later", "devDependencies": { "@lodder/time-grunt": "^4.0.0", diff --git a/package.json b/package.json index e1d6d42..eb2a6cb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "wp-content-pilot", "title": "WP Content Pilot", - "version": "2.0.5", + "version": "2.0.6", "description": "WP Content Pilot automatically posts contents from various sources based on the predefined keywords.", "homepage": "https://pluginever.com", "license": "GPL-v2.0-or-later", diff --git a/readme.txt b/readme.txt index 3cda9c2..d5277f0 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: pluginever,manikmist09 Tags: autoblog, rss aggregator, news aggregator, rss import, youtube feed, feed import, content curation, feed to post, rss to post, rss feeds, auto post Requires at least: 5.0 Tested up to: 6.7 -Stable tag: 2.0.5 +Stable tag: 2.0.6 Requires PHP: 7.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -130,6 +130,11 @@ No, WP Content Pilot does not support multisite WordPress installation. We would love to hear your suggestions! Feel free to open a new issue [here](https://github.com/pluginever/wp-content-pilot/issues) as the feature request. == Changelog == += 2.0.6 (January 15, 2025) = +* New - Feature to remove cached links if in case needed. +* Fix - Few known issues fixed. +* Remove - Removed the unused code. + = 2.0.5 (December 30, 2024) = * Fix - Few broken links are fixed. diff --git a/wp-content-pilot.php b/wp-content-pilot.php index 608be27..1821a79 100644 --- a/wp-content-pilot.php +++ b/wp-content-pilot.php @@ -3,7 +3,7 @@ * Plugin Name: WP Content Pilot * Plugin URI: https://wpcontentpilot.com * Description: WP Content Pilot automatically posts contents from various sources based on the predefined keywords. - * Version: 2.0.5 + * Version: 2.0.6 * Requires at least: 5.0 * Requires PHP: 7.4 * Author: PluginEver @@ -16,7 +16,7 @@ * * @package WPContentPilot * - * Copyright (c) 2024 PluginEver (email : support@pluginever.com) + * Copyright (c) 2025 PluginEver (email : support@pluginever.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 or, at @@ -38,6 +38,7 @@ /** * Main ContentPilot Class. * + * @since 1.0.0 * @class ContentPilot */ final class ContentPilot { @@ -46,7 +47,7 @@ final class ContentPilot { * * @var string */ - protected $version = '2.0.5'; + protected $version = '2.0.6'; /** * The single instance of the class.