diff --git a/cypress.config.js b/cypress.config.js index fb34a570..0d519295 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -84,4 +84,7 @@ module.exports = defineConfig({ specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}', pageLoadTimeout : 300000, }, + blockHosts: [ + 'app.formbricks.com' + ], }) diff --git a/cypress/e2e/default/import_feed_free.js b/cypress/e2e/default/import_feed_free.js index 830c976e..c8f5246f 100644 --- a/cypress/e2e/default/import_feed_free.js +++ b/cypress/e2e/default/import_feed_free.js @@ -22,7 +22,72 @@ describe('Test Free - Import Feed', function() { cy.get('.fz-tabs-menu li a').should('have.length', settings.tabs); }) - it('Create/Verify/Run import', function() { + it('Check chained actions insertion for title', function() { + // Create a new import. + cy.visit('/wp-admin/post-new.php?post_type=feedzy_imports'); + + // Fill up the form + cy.get('#post_title').clear().type( 'Chained actions: ' + feed.url ); + cy.get('#feedzy-import-source').clear().type( feed.url ); + cy.get('#feedzy-import-source').next('.fz-input-group-append').find('.add-outside-tags').click(); + + // Open the Map Content tab + cy.get('#fz-import-map-content > .feedzy-accordion-item__button').click(); + + // Clear the title field. + cy.get(':nth-child(4) > .fz-right > .fz-form-group > .fz-input-group > .fz-input-group-left > .fz-group > .tagify > .tagify__input').type('{selectall}{backspace}'); + + // Add chained actions for title field. + cy.get(':nth-child(4) > .fz-right > .fz-form-group > .fz-input-group > .fz-input-group-right > .dropdown > .btn').click(); + cy.get(':nth-child(4) > .fz-right > .fz-form-group > .fz-input-group > .fz-input-group-right > .dropdown > .dropdown-menu > [data-field-tag="item_title"] > small').click(); // Select the [#item_title] tag. + + // Add a chained action. + cy.get('.fz-action-relative > .components-button').click(); + cy.get('.popover-action-list > ul > :nth-child(1)').click(); // Select the "Trim content" action. + + // Add another chained action. + cy.get('.fz-action-relative > .components-button').click(); + cy.get('.popover-action-list > ul > :nth-child(3)').click(); // Select the "Search and Replace" action. + + // Save actions. + cy.get('.fz-save-action').click(); + + // Save the serialized data directly to the input field. (The Tagify lib used for UI does not update the input field based on Cypress click actions). + cy.get('.tagify__input > .tagify__tag a').invoke('attr', 'data-actions').then((serializedActions) => { + cy.get('[name="feedzy_meta_data[import_post_title]"]').clear({force: true}).invoke('val', '[[{"value": "' + serializedActions + '"}]]' ).blur({force: true}); + }); + + // Save the import. + cy.get('button[type="submit"][name="save"]').scrollIntoView().click({force:true}); + + // Reopen the import. + cy.visit('/wp-admin/edit.php?post_type=feedzy_imports'); + cy.get('tr:nth-of-type(1) .row-title').click(); + + // Open the Map Content tab + cy.get('#fz-import-map-content > .feedzy-accordion-item__button').click(); + + // Check the saved actions. + cy.get('.tagify__input > .tagify__tag').should('be.visible'); + cy.get('.tagify__input > .tagify__tag a').invoke('attr', 'data-actions').then((serializedActions) => { + expect(serializedActions).to.include('item_title'); + expect(serializedActions).to.include('trim'); + expect(serializedActions).to.include('search_replace'); + + // Check if we have right actions. + const actions = JSON.parse(decodeURIComponent(serializedActions)); + + expect(actions).to.have.length(2); + expect(actions[0].id).to.equal('trim'); + expect(actions[0].tag).to.equal('item_title'); + + expect(actions[1].id).to.equal('search_replace'); + expect(actions[1].tag).to.equal('item_title'); + } ); + + }) + + it('Check the Create/Verify/Run workflow for feed import', function() { // 1. CREATE cy.visit('/wp-admin/post-new.php?post_type=feedzy_imports'); @@ -84,18 +149,15 @@ describe('Test Free - Import Feed', function() { // show a notice. //cy.get('div.notice.feedzy-error-critical').should('be.visible'); - }) - - it('Update the new import with VALID url', function() { + cy.visit('/wp-admin/edit.php?post_type=feedzy_imports'); cy.get('tr:nth-of-type(1) .row-title').click(); + // fill up the form cy.get('#post_title').clear().type( feed.url ); - cy.get('#feedzy-import-source').clear().type( feed.url ); - cy.get('#feedzy-import-source').next('.fz-input-group-append').find('.add-outside-tags').click(); - + cy.get('button[type="submit"][name="save"]').scrollIntoView().click({force:true}); // check if the import has been setup @@ -117,7 +179,7 @@ describe('Test Free - Import Feed', function() { cy.get('#feedzy_post_terms').invoke('show').then( () => { cy.get('#feedzy_post_terms option:selected').should('have.length', feed.taxonomy.length); }); - + cy.get('[name="feedzy_meta_data[import_post_title]"]').should('have.value', PREFIX + feed.title); cy.get('[name="feedzy_meta_data[import_post_content]"]').should('have.value', PREFIX + feed.fullcontent.content + feed.content + '\n'); @@ -254,6 +316,4 @@ describe('Test Free - Import Feed', function() { cy.get('.wp-block-post-author-name .wp-block-post-author-name__link:contains("wordpress")').should('exist'); }) - - }) diff --git a/includes/admin/feedzy-rss-feeds-actions.php b/includes/admin/feedzy-rss-feeds-actions.php index d981edfa..d3dc7cdb 100644 --- a/includes/admin/feedzy-rss-feeds-actions.php +++ b/includes/admin/feedzy-rss-feeds-actions.php @@ -23,11 +23,11 @@ class Feedzy_Rss_Feeds_Actions { private static $instance; /** - * Content actions. + * Serialized content actions. It can contain a mix of magic tags and simple text. * - * @var string $actions Content actions. + * @var string $raw_serialized_actions Content actions. */ - private $actions; + private $raw_serialized_actions; /** * Setting options. @@ -39,7 +39,7 @@ class Feedzy_Rss_Feeds_Actions { /** * Extract tags. * - * @var string $extract_tags Extract tags. + * @var array $extract_tags Extract tags. */ private $extract_tags; @@ -72,11 +72,11 @@ class Feedzy_Rss_Feeds_Actions { public $result = ''; /** - * Post content. + * The field content (title, description, post content, date, etc.) * - * @var string $post_content + * @var string $field_content */ - public $post_content = ''; + public $field_content = ''; /** * Default value. @@ -129,13 +129,13 @@ public static function instance() { /** * Run actions. * - * @param string $actions Item content actions. - * @return string + * @param string $raw_serialized_actions Item content actions. + * @return string|array */ - public function set_actions( $actions = '' ) { - $this->actions = $actions; - if ( empty( $this->actions ) ) { - return $this->actions; + public function set_raw_serialized_actions( $raw_serialized_actions = '' ) { + $this->raw_serialized_actions = $raw_serialized_actions; + if ( empty( $this->raw_serialized_actions ) ) { + return $this->raw_serialized_actions; } $this->extract_tags = $this->extract_magic_tags(); return $this->extract_tags; @@ -154,10 +154,23 @@ public function set_settings( $options ) { /** * Extract magic tags. * - * @return string + * @return array|array[] */ public function extract_magic_tags() { - preg_match_all( '/\[\[\{(.*)\}\]\]/U', $this->actions, $item_magic_tags, PREG_PATTERN_ORDER ); + /** + * Transform the serialized string of magic tags to array. + * + * Input(string): [[{"value":"[{"id":"chat_gpt_rewrite","tag":"item_title","data":{"ChatGPT":"Create a long description: {content}"}},{"id":"fz_summarize","tag":"item_title","data":{"fz_summarize":true}}]"}]] with a nice weather. + * + * Output: + * [ + * [ + * [replace_to] => [[{"value":"[{"id":"chat_gpt_rewrite","tag":"item_title","data":{"ChatGPT":"Create a long description: {content}"}},{"id":"fz_summarize","tag":"item_title","data":{"fz_summarize":true}}]"}]] + * [replace_with] => [{"id":"chat_gpt_rewrite","tag":"item_title","data":{"ChatGPT":"Create a long description: {content}"}},{"id":"fz_summarize","tag":"item_title","data":{"fz_summarize":true}}] + * ] + * ] + */ + preg_match_all( '/\[\[\{(.*)\}\]\]/U', $this->raw_serialized_actions, $item_magic_tags, PREG_PATTERN_ORDER ); $extract_tags = array(); if ( ! empty( $item_magic_tags[0] ) ) { $extract_tags = array_map( @@ -175,12 +188,14 @@ function( $tag ) { } /** - * Get magic tags. + * Get the extracted serialized actions from the Tagify tags. The actions can be a mix of Tagify tags and simple text. + * + * @return string The serialized actions. */ - public function get_tags() { + public function get_serialized_actions() { $replace_to = array_column( $this->get_extract_tags(), 'replace_to' ); $replace_with = array_column( $this->get_extract_tags(), 'replace_with' ); - return str_replace( $replace_to, $replace_with, $this->actions ); + return str_replace( $replace_to, $replace_with, $this->raw_serialized_actions ); } /** @@ -191,17 +206,21 @@ public function get_extract_tags() { } /** - * Get actions. + * Get actions. Return pairs of serialized actions and their deserialized versions. + * + * Deserialized version is used to run the action job. While serialized version is used to replace the job result in the input content. + * + * @return array */ public function get_actions() { $replace_with = array_column( $this->get_extract_tags(), 'replace_with' ); $actions = array_map( - function( $action ) { - $replace_with = json_decode( $action ); - if ( $replace_with ) { + function( $serialized_actions ) { + $job_actions = json_decode( $serialized_actions ); + if ( $job_actions ) { return array( - 'replace_to' => wp_json_encode( $replace_with ), - 'replace_with' => $replace_with, + 'serialized_actions' => $serialized_actions, + 'job_actions' => $job_actions, ); } return false; @@ -214,7 +233,7 @@ function( $action ) { /** * Run action job. * - * @param string $post_content Post content. + * @param string $field_content Field content. It can contain a mix of magic tags and simple text. * @param string $import_translation_lang Translation language code. * @param object $job Post object. * @param string $language_code Feed language code. @@ -222,38 +241,39 @@ function( $action ) { * @param string $default_value Default value. * @return string */ - public function run_action_job( $post_content, $import_translation_lang, $job, $language_code, $item, $default_value = '' ) { + public function run_action_job( $field_content, $import_translation_lang, $job, $language_code, $item, $default_value = '' ) { $this->item = $item; $this->job = $job; $this->language_code = $language_code; $this->translation_lang = $import_translation_lang; - $this->post_content = $post_content; + $this->field_content = $field_content; $this->default_value = $default_value; $actions = $this->get_actions(); if ( ! empty( $actions ) ) { foreach ( $actions as $key => $jobs ) { - if ( ! isset( $jobs['replace_with'] ) ) { + if ( ! isset( $jobs['job_actions'] ) ) { continue; } + $this->result = null; - $replace_with = isset( $jobs['replace_with'] ) ? $jobs['replace_with'] : array(); - $replace_to = isset( $jobs['replace_to'] ) ? $jobs['replace_to'] : ''; - foreach ( $replace_with as $job ) { + $jobs_actions = $jobs['job_actions']; + $replace_to = isset( $jobs['serialized_actions'] ) ? $jobs['serialized_actions'] : ''; + foreach ( $jobs_actions as $job ) { $this->current_job = $job; $this->result = $this->action_process(); } if ( 'item_image' === $this->type ) { - $this->post_content = str_replace( $replace_to, $this->result, wp_json_encode( $replace_with ) ); + $this->field_content = str_replace( $replace_to, $this->result, wp_json_encode( $jobs_actions ) ); } else { - $this->post_content = str_replace( $replace_to, $this->result, $this->post_content ); + $this->field_content = str_replace( $replace_to, $this->result, $this->field_content ); } } } if ( empty( $actions ) && 'item_image' === $this->type ) { return $default_value; } - return $this->post_content; + return $this->field_content; } /** diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index f9e036d5..68c30c22 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1416,15 +1416,16 @@ private function run_job( $job, $max ) { $item_date = date( get_option( 'date_format' ) . ' at ' . get_option( 'time_format' ), $item['item_date'] ); $item_date = $item['item_date_formatted']; - // Transform any structure like [[{"value":"[#item_title]"}]] to [#item_title]. - $import_title = preg_replace( '/\[\[\{"value":"(\[#[^]]+\])"\}\]\]/', '$1', $import_title ); - // Get translated item title. $translated_title = ''; if ( $import_auto_translation && ( false !== strpos( $import_title, '[#translated_title]' ) || false !== strpos( $post_excerpt, '[#translated_title]' ) ) ) { $translated_title = apply_filters( 'feedzy_invoke_auto_translate_services', $item['item_title'], '[#translated_title]', $import_translation_lang, $job, $language_code, $item ); } + $import_title = rawurldecode( $import_title ); + $import_title = str_replace( PHP_EOL, "\r\n", $import_title ); + $import_title = trim( $import_title ); + $post_title = str_replace( array( '[#item_title]', @@ -1447,6 +1448,10 @@ private function run_job( $job, $max ) { $import_title ); + // Run all the actions stored for the embedded/serialized tags in the title field. + $title_action = $this->get_actions_runner( $post_title, 'item_title' ); + $post_title = $title_action->run_action_job( $title_action->get_serialized_actions(), $translated_title, $job, $language_code, $item ); + if ( $this->feedzy_is_business() ) { $post_title = apply_filters( 'feedzy_parse_custom_tags', $post_title, $item_obj ); } @@ -1546,8 +1551,8 @@ private function run_job( $job, $max ) { $post_content = apply_filters( 'feedzy_invoke_services', $post_content, 'full_content', $full_content, $job ); } // Item content action. - $content_action = $this->handle_content_actions( $post_content, 'item_content' ); - $post_content = $content_action->get_tags(); + $content_action = $this->get_actions_runner( $post_content, 'item_content' ); + $post_content = $content_action->get_serialized_actions(); // Item content action process. $post_content = $content_action->run_action_job( $post_content, $import_translation_lang, $job, $language_code, $item ); // Parse custom tags. @@ -1832,7 +1837,7 @@ function( $term ) { // Item image action. $import_featured_img = rawurldecode( $import_featured_img ); $import_featured_img = trim( $import_featured_img ); - $img_action = $this->handle_content_actions( $import_featured_img, 'item_image' ); + $img_action = $this->get_actions_runner( $import_featured_img, 'item_image' ); // Item image action process. $image_source_url = $img_action->run_action_job( $import_featured_img, $import_translation_lang, $job, $language_code, $item, $image_source_url ); @@ -2349,8 +2354,8 @@ public function render_magic_tags( $default, $tags, $type ) { $disabled[ str_replace( ':disabled', '', $tag ) ] = $label; continue; } - if ( in_array( $type, array( 'import_post_content', 'import_post_featured_img' ), true ) ) { - if ( in_array( $tag, array( 'item_content', 'item_description', 'item_full_content', 'item_categories', 'item_image' ), true ) ) { + if ( in_array( $type, array( 'import_post_content', 'import_post_featured_img', 'import_post_title' ), true ) ) { + if ( in_array( $tag, array( 'item_content', 'item_description', 'item_full_content', 'item_categories', 'item_image', 'item_title' ), true ) ) { $default .= '' . $label . ' [#' . $tag . ']'; continue; } @@ -2956,16 +2961,16 @@ private function wizard_import_feed() { } /** - * Handle item content actions. + * Get the content action runner used for processing the chained actions from the tags. * * @param string $actions Item content actions. * @param string $type Action type. * @return Feedzy_Rss_Feeds_Actions Instance of Feedzy_Rss_Feeds_Actions. */ - public function handle_content_actions( $actions = '', $type = '' ) { + public function get_actions_runner( $actions = '', $type = '' ) { $action_instance = Feedzy_Rss_Feeds_Actions::instance(); $action_instance->type = $type; - $action_instance->set_actions( $actions ); + $action_instance->set_raw_serialized_actions( $actions ); $action_instance->set_settings( $this->settings ); return $action_instance; } diff --git a/includes/gutenberg/build/block.js b/includes/gutenberg/build/block.js index 2f16463e..3dacd7f4 100644 --- a/includes/gutenberg/build/block.js +++ b/includes/gutenberg/build/block.js @@ -1,6 +1,6 @@ -!function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=294)}({17:function(e,t,r){var n; +!function(e){var t={};function r(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(a,n,function(t){return e[t]}.bind(null,n));return a},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=294)}({17:function(e,t,r){var a; /*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e=[],t=0;t{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return(e,r,n)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};case"comma":case"separator":return(t,r,n)=>{const a="string"==typeof r&&r.includes(e.arrayFormatSeparator),o="string"==typeof r&&!a&&u(r,e).includes(e.arrayFormatSeparator);r=o?u(r,e):r;const s=a||o?r.split(e.arrayFormatSeparator).map(t=>u(t,e)):null===r?r:u(r,e);n[t]=s};case"bracket-separator":return(t,r,n)=>{const a=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!a)return void(n[t]=r?u(r,e):r);const o=null===r?[]:r.split(e.arrayFormatSeparator).map(t=>u(t,e));void 0!==n[t]?n[t]=[].concat(n[t],o):n[t]=o};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t),n=Object.create(null);if("string"!=typeof e)return n;if(!(e=e.trim().replace(/^[?#&]/,"")))return n;for(const a of e.split("&")){if(""===a)continue;let[e,s]=o(t.decode?a.replace(/\+/g," "):a,"=");s=void 0===s?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?s:u(s,t),r(u(e,t),s,n)}for(const e of Object.keys(n)){const r=n[e];if("object"==typeof r&&null!==r)for(const e of Object.keys(r))r[e]=d(r[e],t);else n[e]=d(r,t)}return!1===t.sort?n:(!0===t.sort?Object.keys(n).sort():Object.keys(n).sort(t.sort)).reduce((e,t)=>{const r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort((e,t)=>Number(e)-Number(t)).map(e=>t[e]):t}(r):e[t]=r,e},Object.create(null))}t.extract=c,t.parse=m,t.stringify=(e,t)=>{if(!e)return"";i((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const r=r=>t.skipNull&&null==e[r]||t.skipEmptyString&&""===e[r],n=function(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const a=r.length;return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[l(t,e),"[",a,"]"].join("")]:[...r,[l(t,e),"[",l(a,e),"]=",l(n,e)].join("")]};case"bracket":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[l(t,e),"[]"].join("")]:[...r,[l(t,e),"[]=",l(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return r=>(n,a)=>void 0===a||e.skipNull&&null===a||e.skipEmptyString&&""===a?n:(a=null===a?"":a,0===n.length?[[l(r,e),t,l(a,e)].join("")]:[[n,l(a,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,l(t,e)]:[...r,[l(t,e),"=",l(n,e)].join("")]}}(t),a={};for(const t of Object.keys(e))r(t)||(a[t]=e[t]);const o=Object.keys(a);return!1!==t.sort&&o.sort(t.sort),o.map(r=>{const a=e[r];return void 0===a?"":null===a?l(r,t):Array.isArray(a)?0===a.length&&"bracket-separator"===t.arrayFormat?l(r,t)+"[]":a.reduce(n(r),[]).join("&"):l(r,t)+"="+l(a,t)}).filter(e=>e.length>0).join("&")},t.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[r,n]=o(e,"#");return Object.assign({url:r.split("?")[0]||"",query:m(c(e),t)},t&&t.parseFragmentIdentifier&&n?{fragmentIdentifier:u(n,t)}:{})},t.stringifyUrl=(e,r)=>{r=Object.assign({encode:!0,strict:!0},r);const n=p(e.url).split("?")[0]||"",a=t.extract(e.url),o=t.parse(a,{sort:!1}),s=Object.assign(o,e.query);let i=t.stringify(s,r);i&&(i="?"+i);let u=function(e){let t="";const r=e.indexOf("#");return-1!==r&&(t=e.slice(r)),t}(e.url);return e.fragmentIdentifier&&(u="#"+l(e.fragmentIdentifier,r)),`${n}${i}${u}`},t.pick=(e,r,n)=>{n=Object.assign({parseFragmentIdentifier:!0},n);const{url:a,query:o,fragmentIdentifier:i}=t.parseUrl(e,n);return t.stringifyUrl({url:a,query:s(o,r),fragmentIdentifier:i},n)},t.exclude=(e,r,n)=>{const a=Array.isArray(r)?e=>!r.includes(e):(e,t)=>!r(e,t);return t.pick(e,a,n)}},286:function(e,t,r){"use strict";e.exports=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())},287:function(e,t,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),a=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],o(r),o(n))}function s(e){try{return decodeURIComponent(e)}catch(a){for(var t=e.match(n),r=1;r{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},289:function(e,t,r){"use strict";e.exports=function(e,t){for(var r={},n=Object.keys(e),a=Array.isArray(t),o=0;o0&&void 0!==arguments[0]?arguments[0]:"",t="",r=[];return""!==e&&e.replace(/[^a-zA-Z]/g,"").length<=500&&(e.split(",").forEach((function(e){""!==(e=e.trim())&&(e=e.split("+").map((function(e){return"(?=.*"+(e=e.trim())+")"})),r.push(e.join("")))})),t="^"+(t=r.join("|"))+".*$",t=new RegExp(t,"i")),t};function H(e){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function V(){return(V=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&(s=jQuery(".feedzy-source input",o.contents())),s.autocomplete({disabled:!1}).autocomplete({classes:{"ui-autocomplete":"feedzy-ui-autocomplete"},source:n,minLength:0,select:function(e,t){a.props.setAttributes({feeds:t.item.label})}})})).fail((function(e){return e}))}},{key:"metaExists",value:function(e){return 0<=this.props.attributes.metafields.replace(/\s/g,"").split(",").indexOf(e)||""===this.props.attributes.metafields}},{key:"multipleMetaExists",value:function(e){return 0<=this.props.attributes.multiple_meta.replace(/\s/g,"").split(",").indexOf(e)||""===this.props.attributes.multiple_meta}},{key:"getImageURL",value:function(e,t){var r=e.thumbnail?e.thumbnail:this.props.attributes.default?this.props.attributes.default.url:feedzyjs.imagepath+"feedzy.svg";switch(this.props.attributes.http){case"default":-1===r.indexOf("https")&&0===r.indexOf("http")&&(r=this.props.attributes.default?this.props.attributes.default.url:feedzyjs.imagepath+"feedzy.svg");break;case"https":r=r.replace(/http:/g,"https:")}return t&&(r='url("'+r+'")'),r}},{key:"onChangeFeed",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-url-feed",{feature:"block-url-feed",featureValue:e}),this.props.setAttributes({feeds:e})}},{key:"onChangeMax",value:function(e){this.props.setAttributes({max:e?Number(e):5})}},{key:"onChangeOffset",value:function(e){this.props.setAttributes({offset:Number(e)})}},{key:"onToggleFeedTitle",value:function(e){this.props.setAttributes({feed_title:!this.props.attributes.feed_title})}},{key:"onRefresh",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-caching",{feature:"block-caching-refresh",featureValue:e}),this.props.setAttributes({refresh:e})}},{key:"onSort",value:function(e){this.props.setAttributes({sort:e})}},{key:"onTarget",value:function(e){this.props.setAttributes({target:e})}},{key:"onTitle",value:function(e){""!==e&&(e=Number(e))<0&&(e=0),this.props.setAttributes({title:e})}},{key:"onChangeMeta",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-meta",{feature:"block-meta-fields",featureValue:e}),this.props.setAttributes({metafields:e})}},{key:"onChangeMultipleMeta",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-multiple-meta",{feature:"block-multiple-meta-fields",featureValue:e}),this.props.setAttributes({multiple_meta:e})}},{key:"onToggleSummary",value:function(e){this.props.setAttributes({summary:!this.props.attributes.summary})}},{key:"onToggleLazy",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-lazy-loading",{feature:"block-lazy-loading-feed",featureValue:e}),this.props.setAttributes({lazy:!this.props.attributes.lazy})}},{key:"onSummaryLength",value:function(e){this.props.setAttributes({summarylength:Number(e)})}},{key:"onKeywordsTitle",value:function(e){this.props.setAttributes({keywords_title:e})}},{key:"onKeywordsBan",value:function(e){this.props.setAttributes({keywords_ban:e})}},{key:"onThumb",value:function(e){this.props.setAttributes({thumb:e})}},{key:"onDefault",value:function(e){this.props.setAttributes({default:e}),this.setState({route:"reload"})}},{key:"onSize",value:function(e){this.props.setAttributes({size:e?Number(e):150})}},{key:"onHTTP",value:function(e){this.props.setAttributes({http:e}),this.setState({route:"reload"})}},{key:"onReferralURL",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").add({feature:"block-referral-url"}),this.props.setAttributes({referral_url:e})}},{key:"onColumns",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-columns",{feature:"block-columns",featureValue:e}),this.props.setAttributes({columns:e})}},{key:"onTemplate",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-template",{feature:"block-template",featureValue:e}),this.props.setAttributes({template:e})}},{key:"onTogglePrice",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-price",{feature:"block-price",featureValue:!this.props.attributes.price}),this.props.setAttributes({price:!this.props.attributes.price})}},{key:"onKeywordsIncludeOn",value:function(e){this.props.setAttributes({keywords_inc_on:e})}},{key:"onKeywordsExcludeOn",value:function(e){this.props.setAttributes({keywords_exc_on:e})}},{key:"onFromDateTime",value:function(e){this.props.setAttributes({from_datetime:e})}},{key:"onToDateTime",value:function(e){this.props.setAttributes({to_datetime:e})}},{key:"feedzyCategoriesList",value:function(e){var t=jQuery('iframe[name="editor-canvas"]'),r=jQuery(".feedzy-source input");t.length>0&&(r=jQuery(".feedzy-source input",t.contents())),r.autocomplete({disabled:!1}).autocomplete("search","")}},{key:"getValidateURL",value:function(){var e="https://validator.w3.org/feed/";return this.props.attributes.feeds&&(e+="check.cgi?url="+this.props.attributes.feeds),e}},{key:"onToggleItemTitle",value:function(e){this.props.setAttributes({itemTitle:!this.props.attributes.itemTitle})}},{key:"onToggleDisableStyle",value:function(e){this.props.setAttributes({disableStyle:!this.props.attributes.disableStyle})}},{key:"onLinkNoFollow",value:function(e){this.props.setAttributes({follow:e})}},{key:"onErrorEmpty",value:function(e){this.props.setAttributes({error_empty:e})}},{key:"onclassName",value:function(e){this.props.setAttributes({className:e})}},{key:"onDryRun",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").add({feature:"block-dry-run"}),this.props.setAttributes({_dryrun_:e})}},{key:"onDryRunTags",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-dry-run-tags",{feature:"block-dry-run-tags",featureValue:e}),this.props.setAttributes({_dry_run_tags_:e})}},{key:"handleKeyUp",value:function(e){13===e.keyCode&&this.loadFeed()}},{key:"render",value:function(){var e,t,r,n,a,o,s,i,l,u,p=this;return["fetched"===this.state.route&&wp.element.createElement(M,V({edit:this,state:this.state},this.props)),"home"===this.state.route&&wp.element.createElement("div",{className:this.props.className},wp.element.createElement(le,{key:"placeholder",icon:"rss",label:te("Feedzy RSS Feeds")},this.state.loading?wp.element.createElement("div",{key:"loading",className:"wp-block-embed is-loading"},wp.element.createElement(ce,null),wp.element.createElement("p",null,te("Fetching..."))):[wp.element.createElement("div",{className:"feedzy-source-wrap"},wp.element.createElement(ue,{type:"url",className:"feedzy-source",placeholder:te("Enter URL or category of your feed here..."),onChange:this.onChangeFeed,onKeyUp:this.handleKeyUp,value:this.props.attributes.feeds}),wp.element.createElement("span",{className:"dashicons dashicons-arrow-down-alt2",onClick:this.feedzyCategoriesList})),wp.element.createElement(pe,{isLarge:!0,isPrimary:!0,type:"submit",onClick:this.loadFeed},te("Load Feed")),wp.element.createElement(ie,{href:this.getValidateURL(),title:te("Validate Feed ")},te("Validate ")),!feedzyjs.isPro&&wp.element.createElement("div",{className:"fz-source-upgrade-alert"},wp.element.createElement("strong",null,te("NEW!")," "),te("Enable Amazon Product Advertising feeds to generate affiliate revenue by "),wp.element.createElement(ie,{href:"https://themeisle.com/plugins/feedzy-rss-feeds/upgrade/?utm_source=wpadmin&utm_medium=blockeditor&utm_campaign=keywordsfilter&utm_content=feedzy-rss-feeds"},te("upgrading to Feedzy Pro."))),this.state.error&&wp.element.createElement("div",null,te("Feed URL is invalid or unreachable by WordPress SimplePie and will NOT display items.")),wp.element.createElement("p",null,te("Enter the full URL of the feed source you wish to display here, or the name of a category you've created. Also you can add multiple URLs just separate them with a comma. You can manage your categories feed from")," ",wp.element.createElement("a",{href:"edit.php?post_type=feedzy_categories",title:te("feedzy categories "),target:"_blank"},te("here ")))])),!("fetched"!==this.state.route||void 0===this.props.attributes.feedData)&&wp.element.createElement("div",{className:"feedzy-rss"},this.props.attributes.feed_title&&null!==this.props.attributes.feedData.channel&&wp.element.createElement("div",{className:"rss_header"},wp.element.createElement("h2",null,wp.element.createElement("a",{className:"rss_title"},K(this.props.attributes.feedData.channel.title)),wp.element.createElement("span",{className:"rss_description"}," "+K(this.props.attributes.feedData.channel.description)))),wp.element.createElement("ul",{className:"feedzy-".concat(this.props.attributes.template)},(e=this.props.attributes.feedData.items,t=this.props.attributes.sort,r=B(this.props.attributes.keywords_title),n=B(this.props.attributes.keywords_ban),a=this.props.attributes.max,o=this.props.attributes.offset,s=this.props.attributes.keywords_inc_on,i=this.props.attributes.keywords_exc_on,l=this.props.attributes.from_datetime,u=this.props.attributes.to_datetime,s="author"===s?"creator":s,i="author"===i?"creator":i,l=""!==l&&void 0!==l&&moment(l).format("X"),u=""!==u&&void 0!==u&&moment(u).format("X"),e=Array.from(e).sort((function(e,r){var n,a;return"date_desc"===t||"date_asc"===t?(n=e.pubDate,a=r.pubDate):"title_desc"!==t&&"title_asc"!==t||(n=e.title.toUpperCase(),a=r.title.toUpperCase()),na?"date_desc"===t||"title_desc"===t?-1:1:0})).filter((function(e){return!r||r.test(e[s])})).filter((function(e){return!n||!n.test(e[i])})).filter((function(e){var t=e.date+" "+e.time;return t=moment(new Date(t)).format("X"),!l||!u||l<=t&&t<=u})).slice(o,a+o)).map((function(e,t){var r=(e.date||"")+" "+(e.time||"")+" UTC +0000",n=K(e.date)||"",a=K(e.time)||"",o=K(e.categories)||"";if(p.metaExists("tz=local")){var s=new Date(r);s=s.toUTCString(),n=moment.utc(s).format("MMMM D, YYYY"),a=moment.utc(s).format("h:mm A")}var i=e.creator&&p.metaExists("author")?e.creator:"";""!==p.props.attributes.multiple_meta&&"no"!==p.props.attributes.multiple_meta&&((p.multipleMetaExists("source")||p.multipleMetaExists("yes"))&&""!==i&&""!==e.source?i=i+" ("+e.source+")":(p.multipleMetaExists("source")||p.multipleMetaExists("yes"))&&""!==e.source&&(i=e.source)),""===e.thumbnail&&"auto"===p.props.attributes.thumb&&(e.thumbnail=e.default_img);var l=new Object;return l.author=te("by")+" "+i,l.date=te("on")+" "+K(n),l.time=te("at")+" "+K(a),l.categories=te("in")+" "+K(o),wp.element.createElement("li",{key:t,style:{padding:"15px 0 25px"},className:"rss_item feedzy-rss-col-".concat(p.props.attributes.columns)},(e.thumbnail&&"auto"===p.props.attributes.thumb||"yes"===p.props.attributes.thumb)&&wp.element.createElement("div",{className:"rss_image",style:{width:p.props.attributes.size+"px",height:p.props.attributes.size+"px"}},wp.element.createElement("a",{title:K(e.title),style:{width:p.props.attributes.size+"px",height:p.props.attributes.size+"px"}},wp.element.createElement("span",{className:"fetched",style:{width:p.props.attributes.size+"px",height:p.props.attributes.size+"px",backgroundImage:p.getImageURL(e,!0)},title:K(e.title)}))),wp.element.createElement("div",{className:"rss_content_wrap"},p.props.attributes.itemTitle&&0!==p.props.attributes.title?wp.element.createElement("span",{className:"title"},wp.element.createElement("a",null,p.props.attributes.title&&K(e.title).length>p.props.attributes.title?K(e.title).substring(0,p.props.attributes.title)+"...":K(e.title))):"",wp.element.createElement("div",{className:"rss_content"},"no"!==p.props.attributes.metafields&&wp.element.createElement("small",{className:"meta"},function(e,t){var r="";""===t&&(t="author, date, time");for(var n=t.replace(/\s/g,"").split(","),a=0;ap.props.attributes.summarylength?K(e.description).substring(0,p.props.attributes.summarylength)+" [...]":K(e.description)),feedzyjs.isPro&&e.media&&e.media.src&&wp.element.createElement("audio",{controls:!0,controlsList:"nodownload"},wp.element.createElement("source",{src:e.media.src,type:e.media.type}),te("Your browser does not support the audio element. But you can check this for the original link: "),wp.element.createElement("a",{href:e.media.src},e.media.src)),feedzyjs.isPro&&p.props.attributes.price&&e.price&&"default"!==p.props.attributes.template&&wp.element.createElement("div",{className:"price-wrap"},wp.element.createElement("a",null,wp.element.createElement("button",{className:"price"},e.price))))))}))))]}}])&&Q(t.prototype,r),n&&Q(t,n),Object.defineProperty(t,"prototype",{writable:!1}),l}(oe)),me=wp.i18n.__,fe=wp.blocks.registerBlockType;t.default=fe("feedzy-rss-feeds/feedzy-block",{title:me("Feedzy RSS Feeds"),category:"common",icon:"rss",keywords:[me("Feedzy RSS Feeds"),me("RSS"),me("Feeds")],supports:{html:!1},attributes:n,edit:de,save:function(){return null}})}}); \ No newline at end of file +*/!function(){"use strict";var r={}.hasOwnProperty;function n(){for(var e=[],t=0;t{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===a[e]&&(a[e]={}),a[e][t[1]]=r):a[e]=r};case"bracket":return(e,r,a)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==a[e]?a[e]=[].concat(a[e],r):a[e]=[r]:a[e]=r};case"comma":case"separator":return(t,r,a)=>{const n="string"==typeof r&&r.includes(e.arrayFormatSeparator),o="string"==typeof r&&!n&&u(r,e).includes(e.arrayFormatSeparator);r=o?u(r,e):r;const s=n||o?r.split(e.arrayFormatSeparator).map(t=>u(t,e)):null===r?r:u(r,e);a[t]=s};case"bracket-separator":return(t,r,a)=>{const n=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!n)return void(a[t]=r?u(r,e):r);const o=null===r?[]:r.split(e.arrayFormatSeparator).map(t=>u(t,e));void 0!==a[t]?a[t]=[].concat(a[t],o):a[t]=o};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t),a=Object.create(null);if("string"!=typeof e)return a;if(!(e=e.trim().replace(/^[?#&]/,"")))return a;for(const n of e.split("&")){if(""===n)continue;let[e,s]=o(t.decode?n.replace(/\+/g," "):n,"=");s=void 0===s?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?s:u(s,t),r(u(e,t),s,a)}for(const e of Object.keys(a)){const r=a[e];if("object"==typeof r&&null!==r)for(const e of Object.keys(r))r[e]=m(r[e],t);else a[e]=m(r,t)}return!1===t.sort?a:(!0===t.sort?Object.keys(a).sort():Object.keys(a).sort(t.sort)).reduce((e,t)=>{const r=a[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=function e(t){return Array.isArray(t)?t.sort():"object"==typeof t?e(Object.keys(t)).sort((e,t)=>Number(e)-Number(t)).map(e=>t[e]):t}(r):e[t]=r,e},Object.create(null))}t.extract=c,t.parse=d,t.stringify=(e,t)=>{if(!e)return"";i((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const r=r=>t.skipNull&&null==e[r]||t.skipEmptyString&&""===e[r],a=function(e){switch(e.arrayFormat){case"index":return t=>(r,a)=>{const n=r.length;return void 0===a||e.skipNull&&null===a||e.skipEmptyString&&""===a?r:null===a?[...r,[l(t,e),"[",n,"]"].join("")]:[...r,[l(t,e),"[",l(n,e),"]=",l(a,e)].join("")]};case"bracket":return t=>(r,a)=>void 0===a||e.skipNull&&null===a||e.skipEmptyString&&""===a?r:null===a?[...r,[l(t,e),"[]"].join("")]:[...r,[l(t,e),"[]=",l(a,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return r=>(a,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?a:(n=null===n?"":n,0===a.length?[[l(r,e),t,l(n,e)].join("")]:[[a,l(n,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,a)=>void 0===a||e.skipNull&&null===a||e.skipEmptyString&&""===a?r:null===a?[...r,l(t,e)]:[...r,[l(t,e),"=",l(a,e)].join("")]}}(t),n={};for(const t of Object.keys(e))r(t)||(n[t]=e[t]);const o=Object.keys(n);return!1!==t.sort&&o.sort(t.sort),o.map(r=>{const n=e[r];return void 0===n?"":null===n?l(r,t):Array.isArray(n)?0===n.length&&"bracket-separator"===t.arrayFormat?l(r,t)+"[]":n.reduce(a(r),[]).join("&"):l(r,t)+"="+l(n,t)}).filter(e=>e.length>0).join("&")},t.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[r,a]=o(e,"#");return Object.assign({url:r.split("?")[0]||"",query:d(c(e),t)},t&&t.parseFragmentIdentifier&&a?{fragmentIdentifier:u(a,t)}:{})},t.stringifyUrl=(e,r)=>{r=Object.assign({encode:!0,strict:!0},r);const a=p(e.url).split("?")[0]||"",n=t.extract(e.url),o=t.parse(n,{sort:!1}),s=Object.assign(o,e.query);let i=t.stringify(s,r);i&&(i="?"+i);let u=function(e){let t="";const r=e.indexOf("#");return-1!==r&&(t=e.slice(r)),t}(e.url);return e.fragmentIdentifier&&(u="#"+l(e.fragmentIdentifier,r)),`${a}${i}${u}`},t.pick=(e,r,a)=>{a=Object.assign({parseFragmentIdentifier:!0},a);const{url:n,query:o,fragmentIdentifier:i}=t.parseUrl(e,a);return t.stringifyUrl({url:n,query:s(o,r),fragmentIdentifier:i},a)},t.exclude=(e,r,a)=>{const n=Array.isArray(r)?e=>!r.includes(e):(e,t)=>!r(e,t);return t.pick(e,n,a)}},286:function(e,t,r){"use strict";e.exports=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())},287:function(e,t,r){"use strict";var a=new RegExp("%[a-f0-9]{2}","gi"),n=new RegExp("(%[a-f0-9]{2})+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),a=e.slice(t);return Array.prototype.concat.call([],o(r),o(a))}function s(e){try{return decodeURIComponent(e)}catch(n){for(var t=e.match(a),r=1;r{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},289:function(e,t,r){"use strict";e.exports=function(e,t){for(var r={},a=Object.keys(e),n=Array.isArray(t),o=0;o0&&void 0!==arguments[0]?arguments[0]:"",t="",r=[];return""!==e&&e.replace(/[^a-zA-Z]/g,"").length<=500&&(e.split(",").forEach((function(e){""!==(e=e.trim())&&(e=e.split("+").map((function(e){return"(?=.*"+(e=e.trim())+")"})),r.push(e.join("")))})),t="^"+(t=r.join("|"))+".*$",t=new RegExp(t,"i")),t};function B(e){return(B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function H(){return(H=Object.assign||function(e){for(var t=1;t0&&(s=jQuery(".feedzy-source input",o.contents())),s.autocomplete({disabled:!1}).autocomplete({classes:{"ui-autocomplete":"feedzy-ui-autocomplete"},source:a,minLength:0,select:function(e,t){n.props.setAttributes({feeds:t.item.label})}})})).fail((function(e){return e}))}},{key:"metaExists",value:function(e){return 0<=this.props.attributes.metafields.replace(/\s/g,"").split(",").indexOf(e)||""===this.props.attributes.metafields}},{key:"multipleMetaExists",value:function(e){return 0<=this.props.attributes.multiple_meta.replace(/\s/g,"").split(",").indexOf(e)||""===this.props.attributes.multiple_meta}},{key:"getImageURL",value:function(e,t){var r=e.thumbnail?e.thumbnail:this.props.attributes.default?this.props.attributes.default.url:feedzyjs.imagepath+"feedzy.svg";switch(this.props.attributes.http){case"default":-1===r.indexOf("https")&&0===r.indexOf("http")&&(r=this.props.attributes.default?this.props.attributes.default.url:feedzyjs.imagepath+"feedzy.svg");break;case"https":r=r.replace(/http:/g,"https:")}return t&&(r='url("'+r+'")'),r}},{key:"onChangeFeed",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-url-feed",{feature:"block-url-feed",featureValue:e}),this.props.setAttributes({feeds:e})}},{key:"onChangeMax",value:function(e){this.props.setAttributes({max:e?Number(e):5})}},{key:"onChangeOffset",value:function(e){this.props.setAttributes({offset:Number(e)})}},{key:"onToggleFeedTitle",value:function(e){this.props.setAttributes({feed_title:!this.props.attributes.feed_title})}},{key:"onRefresh",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-caching",{feature:"block-caching-refresh",featureValue:e}),this.props.setAttributes({refresh:e})}},{key:"onSort",value:function(e){this.props.setAttributes({sort:e})}},{key:"onTarget",value:function(e){this.props.setAttributes({target:e})}},{key:"onTitle",value:function(e){""!==e&&(e=Number(e))<0&&(e=0),this.props.setAttributes({title:e})}},{key:"onChangeMeta",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-meta",{feature:"block-meta-fields",featureValue:e}),this.props.setAttributes({metafields:e})}},{key:"onChangeMultipleMeta",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-multiple-meta",{feature:"block-multiple-meta-fields",featureValue:e}),this.props.setAttributes({multiple_meta:e})}},{key:"onToggleSummary",value:function(e){this.props.setAttributes({summary:!this.props.attributes.summary})}},{key:"onToggleLazy",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-lazy-loading",{feature:"block-lazy-loading-feed",featureValue:e}),this.props.setAttributes({lazy:!this.props.attributes.lazy})}},{key:"onSummaryLength",value:function(e){this.props.setAttributes({summarylength:Number(e)})}},{key:"onKeywordsTitle",value:function(e){this.props.setAttributes({keywords_title:e})}},{key:"onKeywordsBan",value:function(e){this.props.setAttributes({keywords_ban:e})}},{key:"onThumb",value:function(e){this.props.setAttributes({thumb:e})}},{key:"onDefault",value:function(e){this.props.setAttributes({default:e}),this.setState({route:"reload"})}},{key:"onSize",value:function(e){this.props.setAttributes({size:e?Number(e):150})}},{key:"onHTTP",value:function(e){this.props.setAttributes({http:e}),this.setState({route:"reload"})}},{key:"onReferralURL",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").add({feature:"block-referral-url"}),this.props.setAttributes({referral_url:e})}},{key:"onColumns",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-columns",{feature:"block-columns",featureValue:e}),this.props.setAttributes({columns:e})}},{key:"onTemplate",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-template",{feature:"block-template",featureValue:e}),this.props.setAttributes({template:e})}},{key:"onTogglePrice",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-price",{feature:"block-price",featureValue:!this.props.attributes.price}),this.props.setAttributes({price:!this.props.attributes.price})}},{key:"onKeywordsIncludeOn",value:function(e){this.props.setAttributes({keywords_inc_on:e})}},{key:"onKeywordsExcludeOn",value:function(e){this.props.setAttributes({keywords_exc_on:e})}},{key:"onFromDateTime",value:function(e){this.props.setAttributes({from_datetime:e})}},{key:"onToDateTime",value:function(e){this.props.setAttributes({to_datetime:e})}},{key:"feedzyCategoriesList",value:function(e){var t=jQuery('iframe[name="editor-canvas"]'),r=jQuery(".feedzy-source input");t.length>0&&(r=jQuery(".feedzy-source input",t.contents())),r.autocomplete({disabled:!1}).autocomplete("search","")}},{key:"getValidateURL",value:function(){var e="https://validator.w3.org/feed/";return this.props.attributes.feeds&&(e+="check.cgi?url="+this.props.attributes.feeds),e}},{key:"onToggleItemTitle",value:function(e){this.props.setAttributes({itemTitle:!this.props.attributes.itemTitle})}},{key:"onToggleDisableStyle",value:function(e){this.props.setAttributes({disableStyle:!this.props.attributes.disableStyle})}},{key:"onLinkNoFollow",value:function(e){this.props.setAttributes({follow:e})}},{key:"onErrorEmpty",value:function(e){this.props.setAttributes({error_empty:e})}},{key:"onclassName",value:function(e){this.props.setAttributes({className:e})}},{key:"onDryRun",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").add({feature:"block-dry-run"}),this.props.setAttributes({_dryrun_:e})}},{key:"onDryRunTags",value:function(e){var t;null===(t=window.tiTrk)||void 0===t||t.with("feedzy").set("feedzy-dry-run-tags",{feature:"block-dry-run-tags",featureValue:e}),this.props.setAttributes({_dry_run_tags_:e})}},{key:"handleKeyUp",value:function(e){13===e.keyCode&&this.loadFeed()}},{key:"render",value:function(){var e,t,r,a,n,o,s,i,l,u,p=this;return["fetched"===this.state.route&&wp.element.createElement(I,H({edit:this,state:this.state},this.props)),"home"===this.state.route&&wp.element.createElement("div",{className:this.props.className},wp.element.createElement(se,{key:"placeholder",icon:"rss",label:J("Feedzy RSS Feeds")},this.state.loading?wp.element.createElement("div",{key:"loading",className:"wp-block-embed is-loading"},wp.element.createElement(ue,null),wp.element.createElement("p",null,J("Fetching..."))):[wp.element.createElement("div",{className:"feedzy-source-wrap"},wp.element.createElement(ie,{type:"url",className:"feedzy-source",placeholder:J("Enter URL or category of your feed here..."),onChange:this.onChangeFeed,onKeyUp:this.handleKeyUp,value:this.props.attributes.feeds}),wp.element.createElement("span",{className:"dashicons dashicons-arrow-down-alt2",onClick:this.feedzyCategoriesList})),wp.element.createElement(le,{isLarge:!0,isPrimary:!0,type:"submit",onClick:this.loadFeed},J("Load Feed")),wp.element.createElement(oe,{href:this.getValidateURL(),title:J("Validate Feed ")},J("Validate ")),!feedzyjs.isPro&&wp.element.createElement("div",{className:"fz-source-upgrade-alert"},wp.element.createElement("strong",null,J("NEW!")," "),J("Enable Amazon Product Advertising feeds to generate affiliate revenue by "),wp.element.createElement(oe,{href:"https://themeisle.com/plugins/feedzy-rss-feeds/upgrade/?utm_source=wpadmin&utm_medium=blockeditor&utm_campaign=keywordsfilter&utm_content=feedzy-rss-feeds"},J("upgrading to Feedzy Pro."))),this.state.error&&wp.element.createElement("div",null,J("Feed URL is invalid or unreachable by WordPress SimplePie and will NOT display items.")),wp.element.createElement("p",null,J("Enter the full URL of the feed source you wish to display here, or the name of a category you've created. Also you can add multiple URLs just separate them with a comma. You can manage your categories feed from")," ",wp.element.createElement("a",{href:"edit.php?post_type=feedzy_categories",title:J("feedzy categories "),target:"_blank"},J("here ")))])),!("fetched"!==this.state.route||void 0===this.props.attributes.feedData)&&wp.element.createElement("div",{className:"feedzy-rss"},this.props.attributes.feed_title&&null!==this.props.attributes.feedData.channel&&wp.element.createElement("div",{className:"rss_header"},wp.element.createElement("h2",null,wp.element.createElement("a",{className:"rss_title"},M(this.props.attributes.feedData.channel.title)),wp.element.createElement("span",{className:"rss_description"}," "+M(this.props.attributes.feedData.channel.description)))),wp.element.createElement("ul",{className:"feedzy-".concat(this.props.attributes.template)},(e=this.props.attributes.feedData.items,t=this.props.attributes.sort,r=K(this.props.attributes.keywords_title),a=K(this.props.attributes.keywords_ban),n=this.props.attributes.max,o=this.props.attributes.offset,s=this.props.attributes.keywords_inc_on,i=this.props.attributes.keywords_exc_on,l=this.props.attributes.from_datetime,u=this.props.attributes.to_datetime,s="author"===s?"creator":s,i="author"===i?"creator":i,l=""!==l&&void 0!==l&&moment(l).format("X"),u=""!==u&&void 0!==u&&moment(u).format("X"),e=Array.from(e).sort((function(e,r){var a,n;return"date_desc"===t||"date_asc"===t?(a=e.pubDate,n=r.pubDate):"title_desc"!==t&&"title_asc"!==t||(a=e.title.toUpperCase(),n=r.title.toUpperCase()),an?"date_desc"===t||"title_desc"===t?-1:1:0})).filter((function(e){return!r||r.test(e[s])})).filter((function(e){return!a||!a.test(e[i])})).filter((function(e){var t=e.date+" "+e.time;return t=moment(new Date(t)).format("X"),!l||!u||l<=t&&t<=u})).slice(o,n+o)).map((function(e,t){var r=(e.date||"")+" "+(e.time||"")+" UTC +0000",a=M(e.date)||"",n=M(e.time)||"",o=M(e.categories)||"";if(p.metaExists("tz=local")){var s=new Date(r);s=s.toUTCString(),a=moment.utc(s).format("MMMM D, YYYY"),n=moment.utc(s).format("h:mm A")}var i=e.creator&&p.metaExists("author")?e.creator:"";""!==p.props.attributes.multiple_meta&&"no"!==p.props.attributes.multiple_meta&&((p.multipleMetaExists("source")||p.multipleMetaExists("yes"))&&""!==i&&""!==e.source?i=i+" ("+e.source+")":(p.multipleMetaExists("source")||p.multipleMetaExists("yes"))&&""!==e.source&&(i=e.source)),""===e.thumbnail&&"auto"===p.props.attributes.thumb&&(e.thumbnail=e.default_img);var l=new Object;return l.author=J("by")+" "+i,l.date=J("on")+" "+M(a),l.time=J("at")+" "+M(n),l.categories=J("in")+" "+M(o),wp.element.createElement("li",{key:t,style:{padding:"15px 0 25px"},className:"rss_item feedzy-rss-col-".concat(p.props.attributes.columns)},(e.thumbnail&&"auto"===p.props.attributes.thumb||"yes"===p.props.attributes.thumb)&&wp.element.createElement("div",{className:"rss_image",style:{width:p.props.attributes.size+"px",height:p.props.attributes.size+"px"}},wp.element.createElement("a",{title:M(e.title),style:{width:p.props.attributes.size+"px",height:p.props.attributes.size+"px"}},wp.element.createElement("span",{className:"fetched",style:{width:p.props.attributes.size+"px",height:p.props.attributes.size+"px",backgroundImage:p.getImageURL(e,!0)},title:M(e.title)}))),wp.element.createElement("div",{className:"rss_content_wrap"},p.props.attributes.itemTitle&&0!==p.props.attributes.title?wp.element.createElement("span",{className:"title"},wp.element.createElement("a",null,p.props.attributes.title&&M(e.title).length>p.props.attributes.title?M(e.title).substring(0,p.props.attributes.title)+"...":M(e.title))):"",wp.element.createElement("div",{className:"rss_content"},"no"!==p.props.attributes.metafields&&wp.element.createElement("small",{className:"meta"},function(e,t){var r="";""===t&&(t="author, date, time");for(var a=t.replace(/\s/g,"").split(","),n=0;np.props.attributes.summarylength?M(e.description).substring(0,p.props.attributes.summarylength)+" [...]":M(e.description)),feedzyjs.isPro&&e.media&&e.media.src&&wp.element.createElement("audio",{controls:!0,controlsList:"nodownload"},wp.element.createElement("source",{src:e.media.src,type:e.media.type}),J("Your browser does not support the audio element. But you can check this for the original link: "),wp.element.createElement("a",{href:e.media.src},e.media.src)),feedzyjs.isPro&&p.props.attributes.price&&e.price&&"default"!==p.props.attributes.template&&wp.element.createElement("div",{className:"price-wrap"},wp.element.createElement("a",null,wp.element.createElement("button",{className:"price"},e.price))))))}))))]}}])&&W(t.prototype,r),a&&W(t,a),l}(ae)),ce=wp.i18n.__,me=wp.blocks.registerBlockType;t.default=me("feedzy-rss-feeds/feedzy-block",{title:ce("Feedzy RSS Feeds"),category:"common",icon:"rss",keywords:[ce("Feedzy RSS Feeds"),ce("RSS"),ce("Feeds")],supports:{html:!1},attributes:a,edit:pe,save:function(){return null}})}}); \ No newline at end of file diff --git a/includes/views/import-metabox-edit.php b/includes/views/import-metabox-edit.php index ecf69cc4..60218942 100644 --- a/includes/views/import-metabox-edit.php +++ b/includes/views/import-metabox-edit.php @@ -389,7 +389,7 @@ class="dashicons dashicons-arrow-down-alt2"> ?> -
+