From 8d7f75581a63253b818fb13dc5a30058257960e8 Mon Sep 17 00:00:00 2001 From: Girish Panchal <79647963+girishpanchal30@users.noreply.github.com> Date: Sun, 29 Dec 2024 04:57:52 +0530 Subject: [PATCH] feat: adds actions support in custom fields (#1041) Co-authored-by: Hardeep Asrani --- css/settings.css | 22 ++++++++++- includes/admin/feedzy-rss-feeds-actions.php | 10 +++++ includes/admin/feedzy-rss-feeds-import.php | 11 ++++-- includes/views/import-metabox-edit.php | 2 + includes/views/js/import-metabox-edit.js | 15 ++++++- js/ActionPopup/index.js | 43 +++++++++++++++++++++ 6 files changed, 98 insertions(+), 5 deletions(-) diff --git a/css/settings.css b/css/settings.css index 76e8c85d..779c09b2 100644 --- a/css/settings.css +++ b/css/settings.css @@ -2027,7 +2027,8 @@ li.draggable-item .components-panel__body-toggle.components-button{ .fz-action-control .fz-hide-icon .components-panel__arrow { display: none; } -.tagify__filter-icon{ +.tagify__filter-icon, +.fz-action-icon { width: 19px; height: 19px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M14.5 13.8002C13.4 13.8002 12.4 14.5002 12.1 15.6002H4V17.0002H12.1C12.4 18.0002 13.4 18.8002 14.5 18.8002C15.6 18.8002 16.6 18.1002 16.9 17.0002H20V15.5002H16.9C16.6 14.5002 15.6 13.8002 14.5 13.8002ZM11.9 7.0002C11.6 6.0002 10.6 5.2002 9.5 5.2002C8.4 5.2002 7.4 6.0002 7.1 7.0002H4V8.5002H7.1C7.4 9.5002 8.4 10.3002 9.5 10.3002C10.6 10.3002 11.6 9.6002 11.9 8.5002H20V7.0002H11.9Z' fill='%23050505'/%3E%3C/svg%3E"); @@ -2488,6 +2489,25 @@ li.draggable-item .components-panel__body-toggle.components-button{ .fz-panel-tab .fz-panel-tab__content .components-base-control .components-datetime__timezone { display: inline-block; } + +.fz-form-group .custom_fields .fz-form-group { + position: relative; +} +.fz-form-group .custom_fields .fz-form-group .fz-action-icon { + position: absolute; + top: 50%; + right: 2px; + cursor: pointer; + transform: translateY(-50%); + width: 40px; + height: 40px; + display: grid; + place-items: center; +} +.fz-form-group .custom_fields .fz-form-group .fz-action-icon.disabled { + pointer-events: none; + opacity: 0.5; +} .fz-prompt-button { gap: 7px; display: flex; diff --git a/includes/admin/feedzy-rss-feeds-actions.php b/includes/admin/feedzy-rss-feeds-actions.php index 36ff42d7..e64a9e60 100644 --- a/includes/admin/feedzy-rss-feeds-actions.php +++ b/includes/admin/feedzy-rss-feeds-actions.php @@ -597,5 +597,15 @@ function() { } return $dom->saveHTML(); } + + /** + * Get custom field value. + */ + private function custom_field() { + if ( ! empty( $this->result ) ) { + return $this->result; + } + return $this->default_value; + } } } diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index 700187d7..12822197 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -428,8 +428,9 @@ public function feedzy_import_feed_options() { // maybe more options are required from pro? $pro_options = apply_filters( 'feedzy_metabox_options', array(), $post->ID ); - $import_custom_fields = get_post_meta( $post->ID, 'imports_custom_fields', true ); - $import_feed_limit = get_post_meta( $post->ID, 'import_feed_limit', true ); + $import_custom_fields = get_post_meta( $post->ID, 'imports_custom_fields', true ); + $custom_fields_actions = get_post_meta( $post->ID, 'imports_custom_field_actions', true ); + $import_feed_limit = get_post_meta( $post->ID, 'import_feed_limit', true ); if ( empty( $import_feed_limit ) ) { $import_feed_limit = 10; } @@ -1991,7 +1992,11 @@ function( $term ) { } } - do_action( 'feedzy_import_extra', $job, $item_obj, $new_post_id, $import_errors, $import_info ); + do_action( 'feedzy_import_extra', $job, $item_obj, $new_post_id, $import_errors, $import_info, array( + 'translation_lang' => $import_translation_lang, + 'language_code' => $language_code, + 'item' => $item, + ) ); if ( ! empty( $import_featured_img ) && 'attachment' !== $import_post_type ) { $image_source_url = ''; diff --git a/includes/views/import-metabox-edit.php b/includes/views/import-metabox-edit.php index e7bef120..12a507e5 100644 --- a/includes/views/import-metabox-edit.php +++ b/includes/views/import-metabox-edit.php @@ -572,6 +572,8 @@ class="fz-switch-toggle" type="checkbox" value="yes"
+ +