diff --git a/css/settings.css b/css/settings.css index 6c90d49c..d52896b6 100644 --- a/css/settings.css +++ b/css/settings.css @@ -1719,6 +1719,7 @@ span.error-message .components-external-link .components-visually-hidden{ margin-left: auto; padding: 0; height: auto; + box-shadow: none !important; } .fz-action-btn button { display: flex; @@ -1765,7 +1766,7 @@ span.error-message .components-external-link .components-visually-hidden{ position: relative; } .popover-action-list{ - width: 250px; + width: 270px; position: absolute; left: 100%; bottom: 0; @@ -2020,7 +2021,8 @@ li.draggable-item .components-panel__body-toggle.components-button{ .fz-action-panel .fz-chat-cpt-action .components-notice { width: 100%; } -.fz-action-panel .fz-chat-cpt-action .components-panel__row { +.fz-action-panel .fz-chat-cpt-action .components-panel__row, +.fz-action-panel .fz-modify-links .components-panel__row { display: block; } .fz-action-panel .fz-upgrade-notice { @@ -2090,7 +2092,8 @@ li.draggable-item .components-panel__body-toggle.components-button{ cursor: not-allowed !important; } -.fz-action-panel .fz-chat-cpt-action .fz-notice-wrap { +.fz-action-panel .fz-chat-cpt-action .fz-notice-wrap, +.fz-action-panel .fz-modify-links .fz-notice-wrap { padding: 0; } diff --git a/includes/admin/feedzy-rss-feeds-actions.php b/includes/admin/feedzy-rss-feeds-actions.php index a6e8401e..de7950a4 100644 --- a/includes/admin/feedzy-rss-feeds-actions.php +++ b/includes/admin/feedzy-rss-feeds-actions.php @@ -313,6 +313,8 @@ public function action_process() { return $this->summarize_content(); case 'fz_image': return $this->generate_image(); + case 'modify_links': + return $this->modify_links(); default: return $this->default_content(); } @@ -505,5 +507,47 @@ private function generate_image() { $openai = new \Feedzy_Rss_Feeds_Pro_Openai(); return $openai->call_api( $this->settings, $prompt, 'image', array() ); } + + /** + * Modify links. + * + * @return string Item content. + */ + private function modify_links() { + $content = call_user_func( array( $this, $this->current_job->tag ) ); + // Returns item content because it has no HTML tags + if ( $content === wp_strip_all_tags( $content ) ) { + return $content; + } + // Pro version is required to perform this action. + if ( ! feedzy_is_pro() ) { + return $content; + } + + $dom = new DOMDocument(); + libxml_use_internal_errors( true ); + $dom->loadHTML( $content ); + $xpath = new DOMXPath( $dom ); + libxml_clear_errors(); + // Get all anchors tags. + $nodes = $xpath->query( '//a' ); + + if ( ! empty( $this->current_job->data->remove_links ) ) { + foreach ( $nodes as $node ) { + if ( ! empty( $this->current_job->data->remove_links ) ) { + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $node->parentNode->removeChild( $node ); + continue; + } + if ( ! empty( $this->current_job->data->target ) ) { + $node->setAttribute( 'target', $this->current_job->data->target ); + } + if ( ! empty( $this->current_job->data->follow ) && 'yes' === $this->current_job->data->follow ) { + $node->setAttribute( 'rel', 'nofollow' ); + } + } + } + return $dom->saveHTML(); + } } } diff --git a/js/ActionPopup/SortableItem.js b/js/ActionPopup/SortableItem.js index 511b6860..ff65010e 100644 --- a/js/ActionPopup/SortableItem.js +++ b/js/ActionPopup/SortableItem.js @@ -25,7 +25,8 @@ import { Popover, ItemGroup, Item, - ToggleControl + ToggleControl, + SelectControl } from '@wordpress/components'; const DragHandle = sortableHandle(() => ); @@ -297,6 +298,83 @@ const SortableItem = ({ propRef, loopIndex, item }) => { ); } + + if ( 'modify_links' === item.id ) { + return( +
  • +
    + + + + + propRef.onChangeHandler( { 'index': loopIndex, 'remove_links': currentValue ?? '' } ) } + disabled={!feedzyData.isPro} + /> + + { true !== item.data.remove_links && + + propRef.onChangeHandler( { 'index': loopIndex, 'target': currentValue ?? '' } ) } + disabled={!feedzyData.isPro} + /> + + } + { true !== item.data.remove_links && + + propRef.onChangeHandler( { 'index': loopIndex, 'follow': currentValue ?? '' } ) } + options={[ + { + label: __('Default', 'feedzy-rss-feeds'), + value: '', + }, + { + label: __('No', 'feedzy-rss-feeds'), + value: 'no', + }, + { + label: __('Yes', 'feedzy-rss-feeds'), + value: 'yes', + }, + ]} + disabled={!feedzyData.isPro} + /> + + } + + +
    +
    + +
    +
  • + ); + } } export default SortableElement(SortableItem); diff --git a/js/ActionPopup/action-popup.js b/js/ActionPopup/action-popup.js index 77817d28..d96aef4a 100644 --- a/js/ActionPopup/action-popup.js +++ b/js/ActionPopup/action-popup.js @@ -31,7 +31,6 @@ import { const ActionModal = () => { // useRef const userRef = useRef(null); - const feedzyImportRef = useRef(null); // State const [ isOpen, setOpen ] = useState(false); const [ isHideMsg, setHideMeg ] = useState(false); @@ -288,62 +287,71 @@ const ActionModal = () => { { 'item_image' === shortCode ? ([ feedzyData.isPro && ( feedzyData.isBusinessPlan || feedzyData.isAgencyPlan ) ? ( -
  • addAction('fz_image') }>{__( 'Generate with ChatGPT', 'feedzy-rss-feeds' )}
  • +
  • addAction('fz_image') }>{__( 'Generate with ChatGPT', 'feedzy-rss-feeds' )}
  • ) : ( -
  • addAction('fz_image') }>{__( 'Generate with ChatGPT', 'feedzy-rss-feeds' )} PRO
  • +
  • addAction('fz_image') }>{__( 'Generate with ChatGPT', 'feedzy-rss-feeds' )} PRO
  • )] ) : ([ -
  • addAction('trim') }>{__( 'Trim Content', 'feedzy-rss-feeds' )}
  • , +
  • addAction('trim') }>{__( 'Trim Content', 'feedzy-rss-feeds' )}
  • , ( feedzyData.isPro && feedzyData.isAgencyPlan ? ( -
  • addAction('fz_translate') }>{__( 'Translate with Feedzy', 'feedzy-rss-feeds' )}
  • +
  • addAction('fz_translate') }>{__( 'Translate with Feedzy', 'feedzy-rss-feeds' )}
  • ) : ( -
  • addAction('fz_translate') }>{__( 'Translate with Feedzy', 'feedzy-rss-feeds' )} PRO
  • +
  • addAction('fz_translate') }>{__( 'Translate with Feedzy', 'feedzy-rss-feeds' )} PRO
  • + ) + ), +
  • addAction('search_replace') }>{__( 'Search / Replace', 'feedzy-rss-feeds' )}
  • , + ( + 'item_categories' !== shortCode && ( + feedzyData.isPro ? ( +
  • addAction('modify_links') }>{__( 'Modify Links', 'feedzy-rss-feeds' )}
  • + ) : ( +
  • addAction('modify_links') }>{__( 'Modify Links', 'feedzy-rss-feeds' )} PRO
  • + ) ) ), -
  • addAction('search_replace') }>{__( 'Search / Replace', 'feedzy-rss-feeds' )}
  • , ( 'item_categories' !== shortCode && ( feedzyData.isPro && ( feedzyData.isBusinessPlan || feedzyData.isAgencyPlan ) ? ( -
  • addAction('fz_paraphrase') }>{__( 'Paraphrase with Feedzy', 'feedzy-rss-feeds' )}
  • +
  • addAction('fz_paraphrase') }>{__( 'Paraphrase with Feedzy', 'feedzy-rss-feeds' )}
  • ) : ( -
  • addAction('fz_paraphrase') }>{__( 'Paraphrase with Feedzy', 'feedzy-rss-feeds' )} PRO
  • +
  • addAction('fz_paraphrase') }>{__( 'Paraphrase with Feedzy', 'feedzy-rss-feeds' )} PRO
  • ) ) ), ( 'item_categories' !== shortCode && ( feedzyData.isPro && feedzyData.isAgencyPlan ? ( -
  • addAction('spinnerchief') }>{__( 'Spin using SpinnerChief', 'feedzy-rss-feeds' )}
  • +
  • addAction('spinnerchief') }>{__( 'Spin using SpinnerChief', 'feedzy-rss-feeds' )}
  • ) : ( -
  • addAction('spinnerchief') }>{__( 'Spin using SpinnerChief', 'feedzy-rss-feeds' )} PRO
  • +
  • addAction('spinnerchief') }>{__( 'Spin using SpinnerChief', 'feedzy-rss-feeds' )} PRO
  • ) ) ), ( 'item_categories' !== shortCode && ( feedzyData.isPro && feedzyData.isAgencyPlan ? ( -
  • addAction('wordAI') }>{__( 'Spin using WordAI', 'feedzy-rss-feeds' )}
  • +
  • addAction('wordAI') }>{__( 'Spin using WordAI', 'feedzy-rss-feeds' )}
  • ) : ( -
  • addAction('wordAI') }>{__( 'Spin using WordAI', 'feedzy-rss-feeds' )} PRO
  • +
  • addAction('wordAI') }>{__( 'Spin using WordAI', 'feedzy-rss-feeds' )} PRO
  • ) ) ), ( 'item_categories' !== shortCode && ( feedzyData.isPro && ( feedzyData.isBusinessPlan || feedzyData.isAgencyPlan ) ? ( -
  • addAction('chat_gpt_rewrite') }>{__( 'Paraphrase with ChatGPT', 'feedzy-rss-feeds' )}
  • +
  • addAction('chat_gpt_rewrite') }>{__( 'Paraphrase with ChatGPT', 'feedzy-rss-feeds' )}
  • ) : ( -
  • addAction('chat_gpt_rewrite') }>{__( 'Paraphrase with ChatGPT', 'feedzy-rss-feeds' )} PRO
  • +
  • addAction('chat_gpt_rewrite') }>{__( 'Paraphrase with ChatGPT', 'feedzy-rss-feeds' )} PRO
  • ) ) ), ( 'item_categories' !== shortCode && ( feedzyData.isPro && ( feedzyData.isBusinessPlan || feedzyData.isAgencyPlan ) ? ( -
  • addAction('fz_summarize') }>{__( 'Summarize with ChatGPT', 'feedzy-rss-feeds' )}
  • +
  • addAction('fz_summarize') }>{__( 'Summarize with ChatGPT', 'feedzy-rss-feeds' )}
  • ) : ( -
  • addAction('fz_summarize') }>{__( 'Summarize with ChatGPT', 'feedzy-rss-feeds' )} PRO
  • +
  • addAction('fz_summarize') }>{__( 'Summarize with ChatGPT', 'feedzy-rss-feeds' )} PRO
  • ) ) )