From 7feda84622af5e6346abc59350f45dafba2b4ddf Mon Sep 17 00:00:00 2001 From: Bogdan Preda Date: Wed, 3 Jul 2024 14:11:14 +0300 Subject: [PATCH 01/31] chore: allow translations download from own domain --- src/Loader.php | 1 + src/Modules/Translations.php | 161 +++++++++++++++++++++++++++++++++++ start.php | 1 + 3 files changed, 163 insertions(+) create mode 100644 src/Modules/Translations.php diff --git a/src/Loader.php b/src/Loader.php index ab6bbbab..f83d924c 100644 --- a/src/Loader.php +++ b/src/Loader.php @@ -53,6 +53,7 @@ final class Loader { 'licenser', 'logger', 'translate', + 'translations', 'review', 'recommendation', 'notification', diff --git a/src/Modules/Translations.php b/src/Modules/Translations.php new file mode 100644 index 00000000..12ba2e89 --- /dev/null +++ b/src/Modules/Translations.php @@ -0,0 +1,161 @@ +is_from_partner( $product ) ) { + return false; + } + + if ( $product->is_wordpress_available() ) { + return false; + } + + if ( ! $product->is_plugin() ) { + return false; + } + + $lang = $this->get_user_locale(); + + if ( 'en_US' === $lang ) { + return false; + } + + return apply_filters( $product->get_slug() . '_sdk_enable_private_translations', true ); + } + + /** + * Load module logic. + * + * @param Product $product Product to load. + * + * @return Translations Module instance. + */ + public function load( $product ) { + + $this->product = $product; + + add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'add_translations' ], 11 ); + + return $this; + } + + /** + * Get the user's locale. + */ + private function get_user_locale() { + global $wp_version; + if ( version_compare( $wp_version, '4.7.0', '>=' ) ) { + return get_user_locale(); + } + $user = wp_get_current_user(); + if ( $user ) { + $locale = $user->locale; + } + + return $locale ? $locale : get_locale(); + } + + /** + * Get translations from API. + * + * @return mixed + */ + private function get_api_translations() { + $translation_data = $this->get_translation_data(); + if ( empty( $translation_data ) ) { + return false; + } + + return $translation_data; + } + + /** + * Get translation data from API. + * + * @return mixed + */ + private function get_translation_data() { + $response = $this->safe_get( + sprintf( + '%stranslations', + Translations::API_URL, + ), + array( + 'timeout' => 15, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout, Inherited by wp_remote_get only, for vip environment we use defaults. + 'sslverify' => false, + ) + ); + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { + return false; + } + $data = json_decode( wp_remote_retrieve_body( $response ) ); + if ( ! is_object( $data ) ) { + return false; + } + + return $data; + } + + /** + * Append translations that are available via API. + * + * @param $_transient_data + * + * @return mixed + */ + public function add_translations( $_transient_data ) { + $locales = array_values( get_available_languages() ); + $locales = apply_filters( 'plugins_update_check_locales', $locales ); + $locales = array_unique( $locales ); + + // append translations via API call + $translations = $this->get_api_translations(); + if ( is_wp_error( $translations ) ) { + return $_transient_data; + } + + if ( ! is_array( $translations ) ) { + return $_transient_data; + } + + foreach ( $translations as $translation ) { + if ( isset( $translation['language'] ) && in_array( $translation['language'], $locales, true ) ) { + $_transient_data->translations[] = $translation; + } + } + + return $_transient_data; + } +} diff --git a/start.php b/start.php index 84235d04..32ccd24b 100644 --- a/start.php +++ b/start.php @@ -31,6 +31,7 @@ $themeisle_library_path . '/src/Modules/Notification.php', $themeisle_library_path . '/src/Modules/Logger.php', $themeisle_library_path . '/src/Modules/Translate.php', + $themeisle_library_path . '/src/Modules/Translations.php', $themeisle_library_path . '/src/Modules/Review.php', $themeisle_library_path . '/src/Modules/Recommendation.php', $themeisle_library_path . '/src/Modules/Promotions.php', From d8b00d7718afd3167f2935a33eff2af5eb74914d Mon Sep 17 00:00:00 2001 From: Bogdan Preda Date: Wed, 3 Jul 2024 14:14:55 +0300 Subject: [PATCH 02/31] chore: code style --- src/Modules/Translations.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Modules/Translations.php b/src/Modules/Translations.php index 12ba2e89..fe536625 100644 --- a/src/Modules/Translations.php +++ b/src/Modules/Translations.php @@ -110,7 +110,7 @@ private function get_translation_data() { $response = $this->safe_get( sprintf( '%stranslations', - Translations::API_URL, + self::API_URL ), array( 'timeout' => 15, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout, Inherited by wp_remote_get only, for vip environment we use defaults. @@ -131,7 +131,7 @@ private function get_translation_data() { /** * Append translations that are available via API. * - * @param $_transient_data + * @param array $_transient_data The transient data. * * @return mixed */ From b9ffd28746da46a67919a8479614b82c47dc52a5 Mon Sep 17 00:00:00 2001 From: Bogdan Preda Date: Wed, 3 Jul 2024 16:44:21 +0300 Subject: [PATCH 03/31] chore: allow proper download of zip --- src/Modules/Translations.php | 46 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/Modules/Translations.php b/src/Modules/Translations.php index fe536625..e76f5a1d 100644 --- a/src/Modules/Translations.php +++ b/src/Modules/Translations.php @@ -24,7 +24,7 @@ */ class Translations extends Abstract_Module { - const API_URL = 'https://translation-themeisle.test/wp-json/gpb-themeisle/'; + const API_URL = 'https://translate-themeisle.test/wp-json/gpb-themeisle/'; /** * Check if we should load module for this. @@ -46,12 +46,6 @@ public function can_load( $product ) { return false; } - $lang = $this->get_user_locale(); - - if ( 'en_US' === $lang ) { - return false; - } - return apply_filters( $product->get_slug() . '_sdk_enable_private_translations', true ); } @@ -68,23 +62,20 @@ public function load( $product ) { add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'add_translations' ], 11 ); - return $this; - } - - /** - * Get the user's locale. - */ - private function get_user_locale() { - global $wp_version; - if ( version_compare( $wp_version, '4.7.0', '>=' ) ) { - return get_user_locale(); - } - $user = wp_get_current_user(); - if ( $user ) { - $locale = $user->locale; - } + // Allow external downloads for this API. + add_filter( + 'http_request_host_is_external', + function ( $external, $host, $url ) { + if ( strpos( $url, self::API_URL ) === 0 ) { + return true; + } + return $external; + }, + 10, + 3 + ); - return $locale ? $locale : get_locale(); + return $this; } /** @@ -121,11 +112,11 @@ private function get_translation_data() { return false; } $data = json_decode( wp_remote_retrieve_body( $response ) ); - if ( ! is_object( $data ) ) { + if ( ! is_array( $data ) ) { return false; } - return $data; + return (array) $data; } /** @@ -150,7 +141,12 @@ public function add_translations( $_transient_data ) { return $_transient_data; } + if ( empty( $_transient_data->translations ) ) { + return $_transient_data; + } + foreach ( $translations as $translation ) { + $translation = (array) $translation; if ( isset( $translation['language'] ) && in_array( $translation['language'], $locales, true ) ) { $_transient_data->translations[] = $translation; } From aa60d7a31bafd58b319c67d867428e9e64739abc Mon Sep 17 00:00:00 2001 From: selul Date: Tue, 9 Jul 2024 16:20:37 +0300 Subject: [PATCH 04/31] Change product name for ROP --- assets/js/build/promos/index.asset.php | 2 +- assets/js/build/promos/index.js | 2 +- assets/js/src/rop.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/build/promos/index.asset.php b/assets/js/build/promos/index.asset.php index 567d0284..d7d40307 100644 --- a/assets/js/build/promos/index.asset.php +++ b/assets/js/build/promos/index.asset.php @@ -1 +1 @@ - array('react', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => '81a0945a0f941cfc90fa'); + array('wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => '31389f13ab50545028ec'); diff --git a/assets/js/build/promos/index.js b/assets/js/build/promos/index.js index 4d08eb27..35593cd8 100644 --- a/assets/js/build/promos/index.js +++ b/assets/js/build/promos/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,t={689:()=>{const e=window.React,t=window.wp.blockEditor,o=window.wp.components,n=window.wp.compose,i=window.wp.data,s=window.wp.element,r=window.wp.hooks,a=()=>{const{createNotice:e}=(0,i.dispatch)("core/notices"),[t,o]=(0,s.useState)({}),[n,r]=(0,s.useState)("loading");return(0,i.useSelect)((e=>{if(Object.keys(t).length)return;const{getEntityRecord:n}=e("core"),i=n("root","site");i&&(r("loaded"),o(i))}),[]),[e=>t?.[e],async(t,n,i="Settings saved.")=>{const s={[t]:n};try{const t=await fetch("/wp-json/wp/v2/settings",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":wpApiSettings.nonce},body:JSON.stringify(s)});t.ok||(r("error"),e("error","Could not save the settings.",{isDismissible:!0,type:"snackbar"}));const n=await t.json();r("loaded"),e("success",i,{isDismissible:!0,type:"snackbar"}),o(n)}catch(e){console.error("Error updating option:",e)}},n]},l=(e,t=!1)=>new Promise((o=>{wp.updates.ajax(!0===t?"install-theme":"install-plugin",{slug:e,success:()=>{o({success:!0})},error:e=>{o({success:!1,code:e.errorCode})}})})),m=e=>new Promise((t=>{jQuery.get(e).done((()=>{t({success:!0})})).fail((()=>{t({success:!1})}))})),c=(e,t)=>{const o={};return Object.keys(t).forEach((function(e){"innerBlocks"!==e&&(o[e]=t[e])})),e.push(o),Array.isArray(t.innerBlocks)?(o.innerBlocks=t.innerBlocks.map((e=>e.id)),t.innerBlocks.reduce(c,e)):e},d={button:{display:"flex",justifyContent:"center",width:"100%"},image:{padding:"20px 0"},skip:{container:{display:"flex",flexDirection:"column",alignItems:"center"},button:{fontSize:"9px"},poweredby:{fontSize:"9px",textTransform:"uppercase"}}},p={"blocks-css":{title:"Custom CSS",description:"Enable Otter Blocks to add Custom CSS for this block.",image:"css.jpg"},"blocks-animation":{title:"Animations",description:"Enable Otter Blocks to add Animations for this block.",image:"animation.jpg"},"blocks-conditions":{title:"Visibility Conditions",description:"Enable Otter Blocks to add Visibility Conditions for this block.",image:"conditions.jpg"}},u=({onClick:t})=>(0,e.createElement)("div",{style:d.skip.container},(0,e.createElement)(o.Button,{style:d.skip.button,variant:"tertiary",onClick:t},"Skip for now"),(0,e.createElement)("span",{style:d.skip.poweredby},"Recommended by ",window.themeisleSDKPromotions.product)),h=(0,n.createHigherOrderComponent)((n=>i=>{if(i.isSelected&&Boolean(window.themeisleSDKPromotions.showPromotion)){const[r,c]=(0,s.useState)(!1),[h,w]=(0,s.useState)("default"),[g,E]=(0,s.useState)(!1),[k,y,f]=a(),P=async()=>{c(!0),await l("otter-blocks"),y("themeisle_sdk_promotions_otter_installed",!Boolean(k("themeisle_sdk_promotions_otter_installed"))),await m(window.themeisleSDKPromotions.otterActivationUrl),c(!1),w("installed")},S=()=>"installed"===h?(0,e.createElement)("p",null,(0,e.createElement)("strong",null,"Awesome! Refresh the page to see Otter Blocks in action.")):(0,e.createElement)(o.Button,{variant:"secondary",onClick:P,isBusy:r,style:d.button},"Install & Activate Otter Blocks"),b=()=>{const e={...window.themeisleSDKPromotions.option};e[window.themeisleSDKPromotions.showPromotion]=(new Date).getTime()/1e3|0,y("themeisle_sdk_promotions",JSON.stringify(e)),window.themeisleSDKPromotions.showPromotion=!1};return(0,s.useEffect)((()=>{g&&b()}),[g]),g?(0,e.createElement)(n,{...i}):(0,e.createElement)(s.Fragment,null,(0,e.createElement)(n,{...i}),(0,e.createElement)(t.InspectorControls,null,Object.keys(p).map((t=>{if(t===window.themeisleSDKPromotions.showPromotion){const n=p[t];return(0,e.createElement)(o.PanelBody,{key:t,title:n.title,initialOpen:!1},(0,e.createElement)("p",null,n.description),(0,e.createElement)(S,null),(0,e.createElement)("img",{style:d.image,src:window.themeisleSDKPromotions.assets+n.image}),(0,e.createElement)(u,{onClick:()=>E(!0)}))}}))))}return(0,e.createElement)(n,{...i})}),"withInspectorControl");(0,i.select)("core/edit-site")||(0,r.addFilter)("editor.BlockEdit","themeisle-sdk/with-inspector-controls",h);const w=window.wp.plugins,g=window.wp.editPost;function E({stacked:t=!1,noImage:n=!1,type:i,onDismiss:r,onSuccess:c,initialStatus:d=null}){const{assets:p,title:u,email:h,option:w,optionKey:g,labels:E,optimoleActivationUrl:k,optimoleApi:y,optimoleDash:f,nonce:P}=window.themeisleSDKPromotions,[S,b]=(0,s.useState)(!1),[v,D]=(0,s.useState)(h||""),[B,_]=(0,s.useState)(!1),[N,K]=(0,s.useState)(d),[C,O]=a(),A=async()=>{_(!0);const e={...w};e[i]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await O(g,JSON.stringify(e)),r&&r()},x=()=>{b(!S)},j=e=>{D(e.target.value)},R=async e=>{e.preventDefault(),K("installing"),await l("optimole-wp"),K("activating"),await m(k),O("themeisle_sdk_promotions_optimole_installed",!Boolean(C("themeisle_sdk_promotions_optimole_installed"))),K("connecting");try{await fetch(y,{method:"POST",headers:{"X-WP-Nonce":P,"Content-Type":"application/json"},body:JSON.stringify({email:v})}),c&&c(),K("done")}catch(e){K("done")}};if(B)return null;const I=()=>"done"===N?(0,e.createElement)("div",{className:"done"},(0,e.createElement)("p",null," ",E.optimole.all_set),(0,e.createElement)(o.Button,{icon:"external",isPrimary:!0,href:f,target:"_blank"},E.optimole.gotodash)):N?(0,e.createElement)("p",{className:"om-progress"},(0,e.createElement)("span",{className:"dashicons dashicons-update spin"}),(0,e.createElement)("span",null,"installing"===N&&E.optimole.installing,"activating"===N&&E.optimole.activating,"connecting"===N&&E.optimole.connecting,"…")):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("span",null,"Enter your email address to create & connect your account"),(0,e.createElement)("form",{onSubmit:R},(0,e.createElement)("input",{defaultValue:v,type:"email",onChange:j,placeholder:E.optimole.email_placeholder}),(0,e.createElement)(o.Button,{isPrimary:!0,type:"submit"},E.optimole.start_cta))),T=()=>(0,e.createElement)(o.Button,{disabled:N&&"done"!==N,onClick:A,isLink:!0,className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},E.optimole.dismisscta));return t?(0,e.createElement)("div",{className:"ti-om-stack-wrap"},(0,e.createElement)("div",{className:"om-stack-notice"},T(),(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("h2",null,E.optimole.heading),(0,e.createElement)("p",null,"om-editor"===i||"om-image-block"===i?E.optimole.message1:E.optimole.message2),!S&&"done"!==N&&(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x,className:"cta"},E.optimole.gst),(S||"done"===N)&&I(),(0,e.createElement)("i",null,u))):(0,e.createElement)(e.Fragment,null,T(),(0,e.createElement)("div",{className:"content"},!n&&(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("div",null,(0,e.createElement)("p",null,u),(0,e.createElement)("p",{className:"description"},"om-media"===i?E.optimole.message3:E.optimole.message4),!S&&(0,e.createElement)("div",{className:"actions"},(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x},E.optimole.gst),(0,e.createElement)(o.Button,{isLink:!0,target:"_blank",href:"https://wordpress.org/plugins/optimole-wp"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null," ",E.optimole.learnmore))),S&&(0,e.createElement)("div",{className:"form-wrap"},I()))))}const k=()=>{const[t,o]=(0,s.useState)(!0),{getBlocks:n}=(0,i.useSelect)((e=>{const{getBlocks:t}=e("core/block-editor");return{getBlocks:t}}));var r;if((r=n(),"core/image",r.reduce(c,[]).filter((e=>"core/image"===e.name))).length<2)return null;const a="ti-sdk-optimole-post-publish "+(t?"":"hidden");return(0,e.createElement)(g.PluginPostPublishPanel,{className:a},(0,e.createElement)(E,{stacked:!0,type:"om-editor",onDismiss:()=>{o(!1)}}))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(this.debug)this.runAll();else switch(this.promo){case"om-attachment":this.runAttachmentPromo();break;case"om-media":this.runMediaPromo();break;case"om-editor":this.runEditorPromo();break;case"om-image-block":this.runImageBlockPromo();break;case"om-elementor":this.runElementorPromo()}}runAttachmentPromo(){wp.media.view.Attachment.Details.prototype.on("ready",(()=>{setTimeout((()=>{this.removeAttachmentPromo(),this.addAttachmentPromo()}),100)})),wp.media.view.Modal.prototype.on("close",(()=>{setTimeout(this.removeAttachmentPromo,100)}))}runMediaPromo(){if(window.themeisleSDKPromotions.option["om-media"])return;const t=document.querySelector("#ti-optml-notice");t&&(0,s.render)((0,e.createElement)(E,{type:"om-media",onDismiss:()=>{t.style.opacity=0}}),t)}runImageBlockPromo(){if(window.themeisleSDKPromotions.option["om-image-block"])return;let o=!0,i=null;const a=(0,n.createHigherOrderComponent)((n=>r=>"core/image"===r.name&&o?(0,e.createElement)(s.Fragment,null,(0,e.createElement)(n,{...r}),(0,e.createElement)(t.InspectorControls,null,(0,e.createElement)(E,{stacked:!0,type:"om-image-block",initialStatus:i,onDismiss:()=>{o=!1},onSuccess:()=>{i="done"}}))):(0,e.createElement)(n,{...r})),"withImagePromo");(0,r.addFilter)("editor.BlockEdit","optimole-promo/image-promo",a,99)}runEditorPromo(){window.themeisleSDKPromotions.option["om-editor"]||(0,w.registerPlugin)("optimole-promo",{render:k})}runElementorPromo(){if(!window.elementor)return;const e=this;elementor.on("preview:loaded",(()=>{elementor.panel.currentView.on("set:page:editor",(t=>{e.domRef&&(0,s.unmountComponentAtNode)(e.domRef),t.activeSection&&"section_image"===t.activeSection&&e.runElementorActions(e)}))}))}addAttachmentPromo(){if(this.domRef&&(0,s.unmountComponentAtNode)(this.domRef),window.themeisleSDKPromotions.option["om-attachment"])return;const t=document.querySelector("#ti-optml-notice-helper");t&&(this.domRef=t,(0,s.render)((0,e.createElement)("div",{className:"notice notice-info ti-sdk-om-notice",style:{margin:0}},(0,e.createElement)(E,{noImage:!0,type:"om-attachment",onDismiss:()=>{t.style.opacity=0}})),t))}removeAttachmentPromo(){const e=document.querySelector("#ti-optml-notice-helper");e&&(0,s.unmountComponentAtNode)(e)}runElementorActions(t){if(window.themeisleSDKPromotions.option["om-elementor"])return;const o=document.querySelector("#elementor-panel__editor__help"),n=document.createElement("div");n.id="ti-optml-notice",t.domRef=n,o&&(o.parentNode.insertBefore(n,o),(0,s.render)((0,e.createElement)(E,{stacked:!0,type:"om-elementor",onDismiss:()=>{n.style.opacity=0}}),n))}runAll(){this.runAttachmentPromo(),this.runMediaPromo(),this.runEditorPromo(),this.runImageBlockPromo(),this.runElementorPromo()}};const y=({onDismiss:t=(()=>{})})=>{const[n,i]=(0,s.useState)(""),[r,c]=a();return(0,e.createElement)(s.Fragment,null,(0,e.createElement)(o.Button,{disabled:"installing"===n,onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["rop-posts"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await c(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),t&&t()},variant:"link",className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Boost your content's reach effortlessly! Introducing ",(0,e.createElement)("b",null,"Revive Old Posts"),", a cutting-edge plugin from the makers of ",window.themeisleSDKPromotions.product,". Seamlessly auto-share old & new content across social media, driving traffic like never before."),(0,e.createElement)("div",{className:"rop-notice-actions"},"installed"!==n?(0,e.createElement)(o.Button,{variant:"primary",isBusy:"installing"===n,onClick:async()=>{i("installing"),await l("tweet-old-post"),await m(window.themeisleSDKPromotions.ropActivationUrl),c("themeisle_sdk_promotions_rop_installed",!Boolean(r("themeisle_sdk_promotions_rop_installed"))),i("installed")}},"Install & Activate"):(0,e.createElement)(o.Button,{variant:"primary",href:window.themeisleSDKPromotions.ropDash},"Visit Dashboard"),(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:"https://wordpress.org/plugins/tweet-old-post/"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["rop-posts"])return;const t=document.querySelector("#ti-rop-notice");t&&(0,s.render)((0,e.createElement)(y,{onDismiss:()=>{t.style.display="none"}}),t)}};const f=({onDismiss:t=(()=>{})})=>{const[n,i]=a(),{neveFSEMoreUrl:r}=window.themeisleSDKPromotions;return(0,e.createElement)(s.Fragment,null,(0,e.createElement)(o.Button,{onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["neve-fse-themes-popular"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await i(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),t&&t()},className:"notice-dismiss"},(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Meet ",(0,e.createElement)("b",null,"Neve FSE")," from the makers of ",window.themeisleSDKPromotions.product,". A theme that makes full site editing on WordPress straightforward and user-friendly."),(0,e.createElement)("div",{className:"neve-fse-notice-actions"},(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:r},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["neve-fse-themes-popular"])return;const t=document.querySelector("#ti-neve-fse-notice");t&&(0,s.render)((0,e.createElement)(f,{onDismiss:()=>{t.style.display="none"}}),t)}}}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var s=o[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.m=t,e=[],n.O=(t,o,i,s)=>{if(!o){var r=1/0;for(c=0;c=s)&&Object.keys(n.O).every((e=>n.O[e](o[l])))?o.splice(l--,1):(a=!1,s0&&e[c-1][2]>s;c--)e[c]=e[c-1];e[c]=[o,i,s]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={57:0,350:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var i,s,[r,a,l]=o,m=0;if(r.some((t=>0!==e[t]))){for(i in a)n.o(a,i)&&(n.m[i]=a[i]);if(l)var c=l(n)}for(t&&t(o);mn(689)));i=n.O(i)})(); \ No newline at end of file +(()=>{"use strict";var e,t={165:()=>{const e=window.wp.element,t=window.wp.blockEditor,o=window.wp.components,n=window.wp.compose,i=window.wp.data,s=window.wp.hooks,r=()=>{const{createNotice:t}=(0,i.dispatch)("core/notices"),[o,n]=(0,e.useState)({}),[s,r]=(0,e.useState)("loading");return(0,i.useSelect)((e=>{if(Object.keys(o).length)return;const{getEntityRecord:t}=e("core"),i=t("root","site");i&&(r("loaded"),n(i))}),[]),[e=>null==o?void 0:o[e],async function(e,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Settings saved.";const s={[e]:o};try{const e=await fetch("/wp-json/wp/v2/settings",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":wpApiSettings.nonce},body:JSON.stringify(s)});e.ok||(r("error"),t("error","Could not save the settings.",{isDismissible:!0,type:"snackbar"}));const o=await e.json();r("loaded"),t("success",i,{isDismissible:!0,type:"snackbar"}),n(o)}catch(e){console.error("Error updating option:",e)}},s]},l=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((o=>{wp.updates.ajax(!0===t?"install-theme":"install-plugin",{slug:e,success:()=>{o({success:!0})},error:e=>{o({success:!1,code:e.errorCode})}})}))},a=e=>new Promise((t=>{jQuery.get(e).done((()=>{t({success:!0})})).fail((()=>{t({success:!1})}))})),m=(e,t)=>{const o={};return Object.keys(t).forEach((function(e){"innerBlocks"!==e&&(o[e]=t[e])})),e.push(o),Array.isArray(t.innerBlocks)?(o.innerBlocks=t.innerBlocks.map((e=>e.id)),t.innerBlocks.reduce(m,e)):e},c={button:{display:"flex",justifyContent:"center",width:"100%"},image:{padding:"20px 0"},skip:{container:{display:"flex",flexDirection:"column",alignItems:"center"},button:{fontSize:"9px"},poweredby:{fontSize:"9px",textTransform:"uppercase"}}},d={"blocks-css":{title:"Custom CSS",description:"Enable Otter Blocks to add Custom CSS for this block.",image:"css.jpg"},"blocks-animation":{title:"Animations",description:"Enable Otter Blocks to add Animations for this block.",image:"animation.jpg"},"blocks-conditions":{title:"Visibility Conditions",description:"Enable Otter Blocks to add Visibility Conditions for this block.",image:"conditions.jpg"}},p=t=>{let{onClick:n}=t;return(0,e.createElement)("div",{style:c.skip.container},(0,e.createElement)(o.Button,{style:c.skip.button,variant:"tertiary",onClick:n},"Skip for now"),(0,e.createElement)("span",{style:c.skip.poweredby},"Recommended by ",window.themeisleSDKPromotions.product))},u=(0,n.createHigherOrderComponent)((n=>i=>{if(i.isSelected&&Boolean(window.themeisleSDKPromotions.showPromotion)){const[s,m]=(0,e.useState)(!1),[u,h]=(0,e.useState)("default"),[w,g]=(0,e.useState)(!1),[E,k,y]=r(),f=async()=>{m(!0),await l("otter-blocks"),k("themeisle_sdk_promotions_otter_installed",!Boolean(E("themeisle_sdk_promotions_otter_installed"))),await a(window.themeisleSDKPromotions.otterActivationUrl),m(!1),h("installed")},S=()=>"installed"===u?(0,e.createElement)("p",null,(0,e.createElement)("strong",null,"Awesome! Refresh the page to see Otter Blocks in action.")):(0,e.createElement)(o.Button,{variant:"secondary",onClick:f,isBusy:s,style:c.button},"Install & Activate Otter Blocks"),P=()=>{const e={...window.themeisleSDKPromotions.option};e[window.themeisleSDKPromotions.showPromotion]=(new Date).getTime()/1e3|0,k("themeisle_sdk_promotions",JSON.stringify(e)),window.themeisleSDKPromotions.showPromotion=!1};return(0,e.useEffect)((()=>{w&&P()}),[w]),w?(0,e.createElement)(n,i):(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,i),(0,e.createElement)(t.InspectorControls,null,Object.keys(d).map((t=>{if(t===window.themeisleSDKPromotions.showPromotion){const n=d[t];return(0,e.createElement)(o.PanelBody,{key:t,title:n.title,initialOpen:!1},(0,e.createElement)("p",null,n.description),(0,e.createElement)(S,null),(0,e.createElement)("img",{style:c.image,src:window.themeisleSDKPromotions.assets+n.image}),(0,e.createElement)(p,{onClick:()=>g(!0)}))}}))))}return(0,e.createElement)(n,i)}),"withInspectorControl");(0,i.select)("core/edit-site")||(0,s.addFilter)("editor.BlockEdit","themeisle-sdk/with-inspector-controls",u);const h=window.wp.plugins,w=window.wp.editPost;function g(t){let{stacked:n=!1,noImage:i=!1,type:s,onDismiss:m,onSuccess:c,initialStatus:d=null}=t;const{assets:p,title:u,email:h,option:w,optionKey:g,labels:E,optimoleActivationUrl:k,optimoleApi:y,optimoleDash:f,nonce:S}=window.themeisleSDKPromotions,[P,v]=(0,e.useState)(!1),[b,D]=(0,e.useState)(h||""),[B,_]=(0,e.useState)(!1),[N,K]=(0,e.useState)(d),[C,O]=r(),A=async()=>{_(!0);const e={...w};e[s]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await O(g,JSON.stringify(e)),m&&m()},x=()=>{v(!P)},j=e=>{D(e.target.value)},I=async e=>{e.preventDefault(),K("installing"),await l("optimole-wp"),K("activating"),await a(k),O("themeisle_sdk_promotions_optimole_installed",!Boolean(C("themeisle_sdk_promotions_optimole_installed"))),K("connecting");try{await fetch(y,{method:"POST",headers:{"X-WP-Nonce":S,"Content-Type":"application/json"},body:JSON.stringify({email:b})}),c&&c(),K("done")}catch(e){K("done")}};if(B)return null;const R=()=>"done"===N?(0,e.createElement)("div",{className:"done"},(0,e.createElement)("p",null," ",E.optimole.all_set),(0,e.createElement)(o.Button,{icon:"external",isPrimary:!0,href:f,target:"_blank"},E.optimole.gotodash)):N?(0,e.createElement)("p",{className:"om-progress"},(0,e.createElement)("span",{className:"dashicons dashicons-update spin"}),(0,e.createElement)("span",null,"installing"===N&&E.optimole.installing,"activating"===N&&E.optimole.activating,"connecting"===N&&E.optimole.connecting,"…")):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("span",null,"Enter your email address to create & connect your account"),(0,e.createElement)("form",{onSubmit:I},(0,e.createElement)("input",{defaultValue:b,type:"email",onChange:j,placeholder:E.optimole.email_placeholder}),(0,e.createElement)(o.Button,{isPrimary:!0,type:"submit"},E.optimole.start_cta))),T=()=>(0,e.createElement)(o.Button,{disabled:N&&"done"!==N,onClick:A,isLink:!0,className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},E.optimole.dismisscta));return n?(0,e.createElement)("div",{className:"ti-om-stack-wrap"},(0,e.createElement)("div",{className:"om-stack-notice"},T(),(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("h2",null,E.optimole.heading),(0,e.createElement)("p",null,"om-editor"===s||"om-image-block"===s?E.optimole.message1:E.optimole.message2),!P&&"done"!==N&&(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x,className:"cta"},E.optimole.gst),(P||"done"===N)&&R(),(0,e.createElement)("i",null,u))):(0,e.createElement)(e.Fragment,null,T(),(0,e.createElement)("div",{className:"content"},!i&&(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("div",null,(0,e.createElement)("p",null,u),(0,e.createElement)("p",{className:"description"},"om-media"===s?E.optimole.message3:E.optimole.message4),!P&&(0,e.createElement)("div",{className:"actions"},(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x},E.optimole.gst),(0,e.createElement)(o.Button,{isLink:!0,target:"_blank",href:"https://wordpress.org/plugins/optimole-wp"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null," ",E.optimole.learnmore))),P&&(0,e.createElement)("div",{className:"form-wrap"},R()))))}const E=()=>{const[t,o]=(0,e.useState)(!0),{getBlocks:n}=(0,i.useSelect)((e=>{const{getBlocks:t}=e("core/block-editor");return{getBlocks:t}}));var s;if((s=n(),"core/image",s.reduce(m,[]).filter((e=>"core/image"===e.name))).length<2)return null;const r="ti-sdk-optimole-post-publish "+(t?"":"hidden");return(0,e.createElement)(w.PluginPostPublishPanel,{className:r},(0,e.createElement)(g,{stacked:!0,type:"om-editor",onDismiss:()=>{o(!1)}}))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(this.debug)this.runAll();else switch(this.promo){case"om-attachment":this.runAttachmentPromo();break;case"om-media":this.runMediaPromo();break;case"om-editor":this.runEditorPromo();break;case"om-image-block":this.runImageBlockPromo();break;case"om-elementor":this.runElementorPromo()}}runAttachmentPromo(){wp.media.view.Attachment.Details.prototype.on("ready",(()=>{setTimeout((()=>{this.removeAttachmentPromo(),this.addAttachmentPromo()}),100)})),wp.media.view.Modal.prototype.on("close",(()=>{setTimeout(this.removeAttachmentPromo,100)}))}runMediaPromo(){if(window.themeisleSDKPromotions.option["om-media"])return;const t=document.querySelector("#ti-optml-notice");t&&(0,e.render)((0,e.createElement)(g,{type:"om-media",onDismiss:()=>{t.style.opacity=0}}),t)}runImageBlockPromo(){if(window.themeisleSDKPromotions.option["om-image-block"])return;let o=!0,i=null;const r=(0,n.createHigherOrderComponent)((n=>s=>"core/image"===s.name&&o?(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,s),(0,e.createElement)(t.InspectorControls,null,(0,e.createElement)(g,{stacked:!0,type:"om-image-block",initialStatus:i,onDismiss:()=>{o=!1},onSuccess:()=>{i="done"}}))):(0,e.createElement)(n,s)),"withImagePromo");(0,s.addFilter)("editor.BlockEdit","optimole-promo/image-promo",r,99)}runEditorPromo(){window.themeisleSDKPromotions.option["om-editor"]||(0,h.registerPlugin)("optimole-promo",{render:E})}runElementorPromo(){if(!window.elementor)return;const t=this;elementor.on("preview:loaded",(()=>{elementor.panel.currentView.on("set:page:editor",(o=>{t.domRef&&(0,e.unmountComponentAtNode)(t.domRef),o.activeSection&&"section_image"===o.activeSection&&t.runElementorActions(t)}))}))}addAttachmentPromo(){if(this.domRef&&(0,e.unmountComponentAtNode)(this.domRef),window.themeisleSDKPromotions.option["om-attachment"])return;const t=document.querySelector("#ti-optml-notice-helper");t&&(this.domRef=t,(0,e.render)((0,e.createElement)("div",{className:"notice notice-info ti-sdk-om-notice",style:{margin:0}},(0,e.createElement)(g,{noImage:!0,type:"om-attachment",onDismiss:()=>{t.style.opacity=0}})),t))}removeAttachmentPromo(){const t=document.querySelector("#ti-optml-notice-helper");t&&(0,e.unmountComponentAtNode)(t)}runElementorActions(t){if(window.themeisleSDKPromotions.option["om-elementor"])return;const o=document.querySelector("#elementor-panel__editor__help"),n=document.createElement("div");n.id="ti-optml-notice",t.domRef=n,o&&(o.parentNode.insertBefore(n,o),(0,e.render)((0,e.createElement)(g,{stacked:!0,type:"om-elementor",onDismiss:()=>{n.style.opacity=0}}),n))}runAll(){this.runAttachmentPromo(),this.runMediaPromo(),this.runEditorPromo(),this.runImageBlockPromo(),this.runElementorPromo()}};const k=t=>{let{onDismiss:n=(()=>{})}=t;const[i,s]=(0,e.useState)(""),[m,c]=r();return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.Button,{disabled:"installing"===i,onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["rop-posts"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await c(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),n&&n()},variant:"link",className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Boost your content's reach effortlessly! Introducing ",(0,e.createElement)("b",null,"Revive Social"),", a cutting-edge plugin from the makers of ",window.themeisleSDKPromotions.product,". Seamlessly auto-share old & new content across social media, driving traffic like never before."),(0,e.createElement)("div",{className:"rop-notice-actions"},"installed"!==i?(0,e.createElement)(o.Button,{variant:"primary",isBusy:"installing"===i,onClick:async()=>{s("installing"),await l("tweet-old-post"),await a(window.themeisleSDKPromotions.ropActivationUrl),c("themeisle_sdk_promotions_rop_installed",!Boolean(m("themeisle_sdk_promotions_rop_installed"))),s("installed")}},"Install & Activate"):(0,e.createElement)(o.Button,{variant:"primary",href:window.themeisleSDKPromotions.ropDash},"Visit Dashboard"),(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:"https://wordpress.org/plugins/tweet-old-post/"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["rop-posts"])return;const t=document.querySelector("#ti-rop-notice");t&&(0,e.render)((0,e.createElement)(k,{onDismiss:()=>{t.style.display="none"}}),t)}};const y=t=>{let{onDismiss:n=(()=>{})}=t;const[i,s]=r(),{neveFSEMoreUrl:l}=window.themeisleSDKPromotions;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.Button,{onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["neve-fse-themes-popular"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await s(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),n&&n()},className:"notice-dismiss"},(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Meet ",(0,e.createElement)("b",null,"Neve FSE")," from the makers of ",window.themeisleSDKPromotions.product,". A theme that makes full site editing on WordPress straightforward and user-friendly."),(0,e.createElement)("div",{className:"neve-fse-notice-actions"},(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:l},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["neve-fse-themes-popular"])return;const t=document.querySelector("#ti-neve-fse-notice");t&&(0,e.render)((0,e.createElement)(y,{onDismiss:()=>{t.style.display="none"}}),t)}}}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var s=o[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.m=t,e=[],n.O=(t,o,i,s)=>{if(!o){var r=1/0;for(c=0;c=s)&&Object.keys(n.O).every((e=>n.O[e](o[a])))?o.splice(a--,1):(l=!1,s0&&e[c-1][2]>s;c--)e[c]=e[c-1];e[c]=[o,i,s]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={826:0,431:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var i,s,r=o[0],l=o[1],a=o[2],m=0;if(r.some((t=>0!==e[t]))){for(i in l)n.o(l,i)&&(n.m[i]=l[i]);if(a)var c=a(n)}for(t&&t(o);mn(165)));i=n.O(i)})(); \ No newline at end of file diff --git a/assets/js/src/rop.js b/assets/js/src/rop.js index 4f3186d2..68dea3fd 100644 --- a/assets/js/src/rop.js +++ b/assets/js/src/rop.js @@ -30,7 +30,7 @@ const ROPNotice = ({ onDismiss = () => {} }) => { Dismiss this notice. -

Boost your content's reach effortlessly! Introducing Revive Old Posts, a cutting-edge plugin from the makers of { window.themeisleSDKPromotions.product }. Seamlessly auto-share old & new content across social media, driving traffic like never before.

+

Boost your content's reach effortlessly! Introducing Revive Social, a cutting-edge plugin from the makers of { window.themeisleSDKPromotions.product }. Seamlessly auto-share old & new content across social media, driving traffic like never before.

{ 'installed' !== status ? ( From 2e374ced60f78f09e2baca414db92a0869da6896 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Fri, 12 Jul 2024 12:22:16 +0530 Subject: [PATCH 05/31] chore: remove duplicate feed url --- src/Modules/Dashboard_widget.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Modules/Dashboard_widget.php b/src/Modules/Dashboard_widget.php index d55e068c..b2ec4c00 100644 --- a/src/Modules/Dashboard_widget.php +++ b/src/Modules/Dashboard_widget.php @@ -82,7 +82,6 @@ public function load( $product ) { 'themeisle_sdk_dashboard_widget_feeds', [ 'https://themeisle.com/blog/feed', - 'https://www.codeinwp.com/blog/feed', 'https://wpshout.com/feed', ] ); From f5e61a2c84e87b3ae5d801846114c8fa6406f1ff Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Tue, 23 Jul 2024 15:00:38 +0530 Subject: [PATCH 06/31] Update developers list --- src/Modules/Review.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Modules/Review.php b/src/Modules/Review.php index 80c47806..1246605c 100644 --- a/src/Modules/Review.php +++ b/src/Modules/Review.php @@ -54,16 +54,10 @@ public function can_load( $product ) { public function add_notification( $all_notifications ) { $developers = [ - 'Bogdan', 'Marius', 'Hardeep', - 'Rodica', - 'Stefan', - 'Uriahs', - 'Madalin', - 'Cristi', - 'Silviu', 'Andrei', + 'Robert', ]; $link = 'https://wordpress.org/support/' . $this->product->get_type() . '/' . $this->product->get_slug() . '/reviews/#wporg-footer'; From 87c7c396907693e53db6cbab83ec2860b00f1623 Mon Sep 17 00:00:00 2001 From: abaicus Date: Wed, 24 Jul 2024 14:39:34 +0300 Subject: [PATCH 07/31] fix: JS error in editor [closes #1663] --- assets/js/build/promos/index.asset.php | 2 +- assets/js/build/promos/index.js | 2 +- assets/js/src/otter.js | 154 +++++++++++++------------ 3 files changed, 80 insertions(+), 78 deletions(-) diff --git a/assets/js/build/promos/index.asset.php b/assets/js/build/promos/index.asset.php index d7d40307..92a973c6 100644 --- a/assets/js/build/promos/index.asset.php +++ b/assets/js/build/promos/index.asset.php @@ -1 +1 @@ - array('wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => '31389f13ab50545028ec'); + array('react', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => 'e6fc8535cbd330147dce'); diff --git a/assets/js/build/promos/index.js b/assets/js/build/promos/index.js index 35593cd8..a541e4ce 100644 --- a/assets/js/build/promos/index.js +++ b/assets/js/build/promos/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,t={165:()=>{const e=window.wp.element,t=window.wp.blockEditor,o=window.wp.components,n=window.wp.compose,i=window.wp.data,s=window.wp.hooks,r=()=>{const{createNotice:t}=(0,i.dispatch)("core/notices"),[o,n]=(0,e.useState)({}),[s,r]=(0,e.useState)("loading");return(0,i.useSelect)((e=>{if(Object.keys(o).length)return;const{getEntityRecord:t}=e("core"),i=t("root","site");i&&(r("loaded"),n(i))}),[]),[e=>null==o?void 0:o[e],async function(e,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Settings saved.";const s={[e]:o};try{const e=await fetch("/wp-json/wp/v2/settings",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":wpApiSettings.nonce},body:JSON.stringify(s)});e.ok||(r("error"),t("error","Could not save the settings.",{isDismissible:!0,type:"snackbar"}));const o=await e.json();r("loaded"),t("success",i,{isDismissible:!0,type:"snackbar"}),n(o)}catch(e){console.error("Error updating option:",e)}},s]},l=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((o=>{wp.updates.ajax(!0===t?"install-theme":"install-plugin",{slug:e,success:()=>{o({success:!0})},error:e=>{o({success:!1,code:e.errorCode})}})}))},a=e=>new Promise((t=>{jQuery.get(e).done((()=>{t({success:!0})})).fail((()=>{t({success:!1})}))})),m=(e,t)=>{const o={};return Object.keys(t).forEach((function(e){"innerBlocks"!==e&&(o[e]=t[e])})),e.push(o),Array.isArray(t.innerBlocks)?(o.innerBlocks=t.innerBlocks.map((e=>e.id)),t.innerBlocks.reduce(m,e)):e},c={button:{display:"flex",justifyContent:"center",width:"100%"},image:{padding:"20px 0"},skip:{container:{display:"flex",flexDirection:"column",alignItems:"center"},button:{fontSize:"9px"},poweredby:{fontSize:"9px",textTransform:"uppercase"}}},d={"blocks-css":{title:"Custom CSS",description:"Enable Otter Blocks to add Custom CSS for this block.",image:"css.jpg"},"blocks-animation":{title:"Animations",description:"Enable Otter Blocks to add Animations for this block.",image:"animation.jpg"},"blocks-conditions":{title:"Visibility Conditions",description:"Enable Otter Blocks to add Visibility Conditions for this block.",image:"conditions.jpg"}},p=t=>{let{onClick:n}=t;return(0,e.createElement)("div",{style:c.skip.container},(0,e.createElement)(o.Button,{style:c.skip.button,variant:"tertiary",onClick:n},"Skip for now"),(0,e.createElement)("span",{style:c.skip.poweredby},"Recommended by ",window.themeisleSDKPromotions.product))},u=(0,n.createHigherOrderComponent)((n=>i=>{if(i.isSelected&&Boolean(window.themeisleSDKPromotions.showPromotion)){const[s,m]=(0,e.useState)(!1),[u,h]=(0,e.useState)("default"),[w,g]=(0,e.useState)(!1),[E,k,y]=r(),f=async()=>{m(!0),await l("otter-blocks"),k("themeisle_sdk_promotions_otter_installed",!Boolean(E("themeisle_sdk_promotions_otter_installed"))),await a(window.themeisleSDKPromotions.otterActivationUrl),m(!1),h("installed")},S=()=>"installed"===u?(0,e.createElement)("p",null,(0,e.createElement)("strong",null,"Awesome! Refresh the page to see Otter Blocks in action.")):(0,e.createElement)(o.Button,{variant:"secondary",onClick:f,isBusy:s,style:c.button},"Install & Activate Otter Blocks"),P=()=>{const e={...window.themeisleSDKPromotions.option};e[window.themeisleSDKPromotions.showPromotion]=(new Date).getTime()/1e3|0,k("themeisle_sdk_promotions",JSON.stringify(e)),window.themeisleSDKPromotions.showPromotion=!1};return(0,e.useEffect)((()=>{w&&P()}),[w]),w?(0,e.createElement)(n,i):(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,i),(0,e.createElement)(t.InspectorControls,null,Object.keys(d).map((t=>{if(t===window.themeisleSDKPromotions.showPromotion){const n=d[t];return(0,e.createElement)(o.PanelBody,{key:t,title:n.title,initialOpen:!1},(0,e.createElement)("p",null,n.description),(0,e.createElement)(S,null),(0,e.createElement)("img",{style:c.image,src:window.themeisleSDKPromotions.assets+n.image}),(0,e.createElement)(p,{onClick:()=>g(!0)}))}}))))}return(0,e.createElement)(n,i)}),"withInspectorControl");(0,i.select)("core/edit-site")||(0,s.addFilter)("editor.BlockEdit","themeisle-sdk/with-inspector-controls",u);const h=window.wp.plugins,w=window.wp.editPost;function g(t){let{stacked:n=!1,noImage:i=!1,type:s,onDismiss:m,onSuccess:c,initialStatus:d=null}=t;const{assets:p,title:u,email:h,option:w,optionKey:g,labels:E,optimoleActivationUrl:k,optimoleApi:y,optimoleDash:f,nonce:S}=window.themeisleSDKPromotions,[P,v]=(0,e.useState)(!1),[b,D]=(0,e.useState)(h||""),[B,_]=(0,e.useState)(!1),[N,K]=(0,e.useState)(d),[C,O]=r(),A=async()=>{_(!0);const e={...w};e[s]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await O(g,JSON.stringify(e)),m&&m()},x=()=>{v(!P)},j=e=>{D(e.target.value)},I=async e=>{e.preventDefault(),K("installing"),await l("optimole-wp"),K("activating"),await a(k),O("themeisle_sdk_promotions_optimole_installed",!Boolean(C("themeisle_sdk_promotions_optimole_installed"))),K("connecting");try{await fetch(y,{method:"POST",headers:{"X-WP-Nonce":S,"Content-Type":"application/json"},body:JSON.stringify({email:b})}),c&&c(),K("done")}catch(e){K("done")}};if(B)return null;const R=()=>"done"===N?(0,e.createElement)("div",{className:"done"},(0,e.createElement)("p",null," ",E.optimole.all_set),(0,e.createElement)(o.Button,{icon:"external",isPrimary:!0,href:f,target:"_blank"},E.optimole.gotodash)):N?(0,e.createElement)("p",{className:"om-progress"},(0,e.createElement)("span",{className:"dashicons dashicons-update spin"}),(0,e.createElement)("span",null,"installing"===N&&E.optimole.installing,"activating"===N&&E.optimole.activating,"connecting"===N&&E.optimole.connecting,"…")):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("span",null,"Enter your email address to create & connect your account"),(0,e.createElement)("form",{onSubmit:I},(0,e.createElement)("input",{defaultValue:b,type:"email",onChange:j,placeholder:E.optimole.email_placeholder}),(0,e.createElement)(o.Button,{isPrimary:!0,type:"submit"},E.optimole.start_cta))),T=()=>(0,e.createElement)(o.Button,{disabled:N&&"done"!==N,onClick:A,isLink:!0,className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},E.optimole.dismisscta));return n?(0,e.createElement)("div",{className:"ti-om-stack-wrap"},(0,e.createElement)("div",{className:"om-stack-notice"},T(),(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("h2",null,E.optimole.heading),(0,e.createElement)("p",null,"om-editor"===s||"om-image-block"===s?E.optimole.message1:E.optimole.message2),!P&&"done"!==N&&(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x,className:"cta"},E.optimole.gst),(P||"done"===N)&&R(),(0,e.createElement)("i",null,u))):(0,e.createElement)(e.Fragment,null,T(),(0,e.createElement)("div",{className:"content"},!i&&(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("div",null,(0,e.createElement)("p",null,u),(0,e.createElement)("p",{className:"description"},"om-media"===s?E.optimole.message3:E.optimole.message4),!P&&(0,e.createElement)("div",{className:"actions"},(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x},E.optimole.gst),(0,e.createElement)(o.Button,{isLink:!0,target:"_blank",href:"https://wordpress.org/plugins/optimole-wp"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null," ",E.optimole.learnmore))),P&&(0,e.createElement)("div",{className:"form-wrap"},R()))))}const E=()=>{const[t,o]=(0,e.useState)(!0),{getBlocks:n}=(0,i.useSelect)((e=>{const{getBlocks:t}=e("core/block-editor");return{getBlocks:t}}));var s;if((s=n(),"core/image",s.reduce(m,[]).filter((e=>"core/image"===e.name))).length<2)return null;const r="ti-sdk-optimole-post-publish "+(t?"":"hidden");return(0,e.createElement)(w.PluginPostPublishPanel,{className:r},(0,e.createElement)(g,{stacked:!0,type:"om-editor",onDismiss:()=>{o(!1)}}))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(this.debug)this.runAll();else switch(this.promo){case"om-attachment":this.runAttachmentPromo();break;case"om-media":this.runMediaPromo();break;case"om-editor":this.runEditorPromo();break;case"om-image-block":this.runImageBlockPromo();break;case"om-elementor":this.runElementorPromo()}}runAttachmentPromo(){wp.media.view.Attachment.Details.prototype.on("ready",(()=>{setTimeout((()=>{this.removeAttachmentPromo(),this.addAttachmentPromo()}),100)})),wp.media.view.Modal.prototype.on("close",(()=>{setTimeout(this.removeAttachmentPromo,100)}))}runMediaPromo(){if(window.themeisleSDKPromotions.option["om-media"])return;const t=document.querySelector("#ti-optml-notice");t&&(0,e.render)((0,e.createElement)(g,{type:"om-media",onDismiss:()=>{t.style.opacity=0}}),t)}runImageBlockPromo(){if(window.themeisleSDKPromotions.option["om-image-block"])return;let o=!0,i=null;const r=(0,n.createHigherOrderComponent)((n=>s=>"core/image"===s.name&&o?(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,s),(0,e.createElement)(t.InspectorControls,null,(0,e.createElement)(g,{stacked:!0,type:"om-image-block",initialStatus:i,onDismiss:()=>{o=!1},onSuccess:()=>{i="done"}}))):(0,e.createElement)(n,s)),"withImagePromo");(0,s.addFilter)("editor.BlockEdit","optimole-promo/image-promo",r,99)}runEditorPromo(){window.themeisleSDKPromotions.option["om-editor"]||(0,h.registerPlugin)("optimole-promo",{render:E})}runElementorPromo(){if(!window.elementor)return;const t=this;elementor.on("preview:loaded",(()=>{elementor.panel.currentView.on("set:page:editor",(o=>{t.domRef&&(0,e.unmountComponentAtNode)(t.domRef),o.activeSection&&"section_image"===o.activeSection&&t.runElementorActions(t)}))}))}addAttachmentPromo(){if(this.domRef&&(0,e.unmountComponentAtNode)(this.domRef),window.themeisleSDKPromotions.option["om-attachment"])return;const t=document.querySelector("#ti-optml-notice-helper");t&&(this.domRef=t,(0,e.render)((0,e.createElement)("div",{className:"notice notice-info ti-sdk-om-notice",style:{margin:0}},(0,e.createElement)(g,{noImage:!0,type:"om-attachment",onDismiss:()=>{t.style.opacity=0}})),t))}removeAttachmentPromo(){const t=document.querySelector("#ti-optml-notice-helper");t&&(0,e.unmountComponentAtNode)(t)}runElementorActions(t){if(window.themeisleSDKPromotions.option["om-elementor"])return;const o=document.querySelector("#elementor-panel__editor__help"),n=document.createElement("div");n.id="ti-optml-notice",t.domRef=n,o&&(o.parentNode.insertBefore(n,o),(0,e.render)((0,e.createElement)(g,{stacked:!0,type:"om-elementor",onDismiss:()=>{n.style.opacity=0}}),n))}runAll(){this.runAttachmentPromo(),this.runMediaPromo(),this.runEditorPromo(),this.runImageBlockPromo(),this.runElementorPromo()}};const k=t=>{let{onDismiss:n=(()=>{})}=t;const[i,s]=(0,e.useState)(""),[m,c]=r();return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.Button,{disabled:"installing"===i,onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["rop-posts"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await c(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),n&&n()},variant:"link",className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Boost your content's reach effortlessly! Introducing ",(0,e.createElement)("b",null,"Revive Social"),", a cutting-edge plugin from the makers of ",window.themeisleSDKPromotions.product,". Seamlessly auto-share old & new content across social media, driving traffic like never before."),(0,e.createElement)("div",{className:"rop-notice-actions"},"installed"!==i?(0,e.createElement)(o.Button,{variant:"primary",isBusy:"installing"===i,onClick:async()=>{s("installing"),await l("tweet-old-post"),await a(window.themeisleSDKPromotions.ropActivationUrl),c("themeisle_sdk_promotions_rop_installed",!Boolean(m("themeisle_sdk_promotions_rop_installed"))),s("installed")}},"Install & Activate"):(0,e.createElement)(o.Button,{variant:"primary",href:window.themeisleSDKPromotions.ropDash},"Visit Dashboard"),(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:"https://wordpress.org/plugins/tweet-old-post/"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["rop-posts"])return;const t=document.querySelector("#ti-rop-notice");t&&(0,e.render)((0,e.createElement)(k,{onDismiss:()=>{t.style.display="none"}}),t)}};const y=t=>{let{onDismiss:n=(()=>{})}=t;const[i,s]=r(),{neveFSEMoreUrl:l}=window.themeisleSDKPromotions;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.Button,{onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["neve-fse-themes-popular"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await s(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),n&&n()},className:"notice-dismiss"},(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Meet ",(0,e.createElement)("b",null,"Neve FSE")," from the makers of ",window.themeisleSDKPromotions.product,". A theme that makes full site editing on WordPress straightforward and user-friendly."),(0,e.createElement)("div",{className:"neve-fse-notice-actions"},(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:l},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["neve-fse-themes-popular"])return;const t=document.querySelector("#ti-neve-fse-notice");t&&(0,e.render)((0,e.createElement)(y,{onDismiss:()=>{t.style.display="none"}}),t)}}}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var s=o[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.m=t,e=[],n.O=(t,o,i,s)=>{if(!o){var r=1/0;for(c=0;c=s)&&Object.keys(n.O).every((e=>n.O[e](o[a])))?o.splice(a--,1):(l=!1,s0&&e[c-1][2]>s;c--)e[c]=e[c-1];e[c]=[o,i,s]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={826:0,431:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var i,s,r=o[0],l=o[1],a=o[2],m=0;if(r.some((t=>0!==e[t]))){for(i in l)n.o(l,i)&&(n.m[i]=l[i]);if(a)var c=a(n)}for(t&&t(o);mn(165)));i=n.O(i)})(); \ No newline at end of file +(()=>{"use strict";var e,t={689:()=>{const e=window.React,t=window.wp.blockEditor,o=window.wp.components,n=window.wp.compose,i=window.wp.data,s=window.wp.element,r=window.wp.hooks,a=()=>{const{createNotice:e}=(0,i.dispatch)("core/notices"),[t,o]=(0,s.useState)({}),[n,r]=(0,s.useState)("loading");return(0,i.useSelect)((e=>{if(Object.keys(t).length)return;const{getEntityRecord:n}=e("core"),i=n("root","site");i&&(r("loaded"),o(i))}),[]),[e=>t?.[e],async(t,n,i="Settings saved.")=>{const s={[t]:n};try{const t=await fetch("/wp-json/wp/v2/settings",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":wpApiSettings.nonce},body:JSON.stringify(s)});t.ok||(r("error"),e("error","Could not save the settings.",{isDismissible:!0,type:"snackbar"}));const n=await t.json();r("loaded"),e("success",i,{isDismissible:!0,type:"snackbar"}),o(n)}catch(e){console.error("Error updating option:",e)}},n]},l=(e,t=!1)=>new Promise((o=>{wp.updates.ajax(!0===t?"install-theme":"install-plugin",{slug:e,success:()=>{o({success:!0})},error:e=>{o({success:!1,code:e.errorCode})}})})),m=e=>new Promise((t=>{jQuery.get(e).done((()=>{t({success:!0})})).fail((()=>{t({success:!1})}))})),c=(e,t)=>{const o={};return Object.keys(t).forEach((function(e){"innerBlocks"!==e&&(o[e]=t[e])})),e.push(o),Array.isArray(t.innerBlocks)?(o.innerBlocks=t.innerBlocks.map((e=>e.id)),t.innerBlocks.reduce(c,e)):e},d={button:{display:"flex",justifyContent:"center",width:"100%"},image:{padding:"20px 0"},skip:{container:{display:"flex",flexDirection:"column",alignItems:"center"},button:{fontSize:"9px"},poweredby:{fontSize:"9px",textTransform:"uppercase"}}},p={"blocks-css":{title:"Custom CSS",description:"Enable Otter Blocks to add Custom CSS for this block.",image:"css.jpg"},"blocks-animation":{title:"Animations",description:"Enable Otter Blocks to add Animations for this block.",image:"animation.jpg"},"blocks-conditions":{title:"Visibility Conditions",description:"Enable Otter Blocks to add Visibility Conditions for this block.",image:"conditions.jpg"}},u=({onClick:t})=>(0,e.createElement)("div",{style:d.skip.container},(0,e.createElement)(o.Button,{style:d.skip.button,variant:"tertiary",onClick:t},"Skip for now"),(0,e.createElement)("span",{style:d.skip.poweredby},"Recommended by ",window.themeisleSDKPromotions.product)),h=(0,n.createHigherOrderComponent)((n=>i=>{const[r,c]=(0,s.useState)(!1),[h,w]=(0,s.useState)("default"),[g,E]=(0,s.useState)(!1),[k,y,f]=a();if((0,s.useEffect)((()=>{g&&(()=>{const e={...window.themeisleSDKPromotions.option};e[window.themeisleSDKPromotions.showPromotion]=(new Date).getTime()/1e3|0,y("themeisle_sdk_promotions",JSON.stringify(e)),window.themeisleSDKPromotions.showPromotion=!1})()}),[g]),!i.isSelected||!Boolean(window.themeisleSDKPromotions.showPromotion))return(0,e.createElement)(n,{...i});const S=async()=>{c(!0),await l("otter-blocks"),y("themeisle_sdk_promotions_otter_installed",!Boolean(k("themeisle_sdk_promotions_otter_installed"))),await m(window.themeisleSDKPromotions.otterActivationUrl),c(!1),w("installed")},P=()=>"installed"===h?(0,e.createElement)("p",null,(0,e.createElement)("strong",null,"Awesome! Refresh the page to see Otter Blocks in action.")):(0,e.createElement)(o.Button,{variant:"secondary",onClick:S,isBusy:r,style:d.button},"Install & Activate Otter Blocks");return g?(0,e.createElement)(n,{...i}):(0,e.createElement)(s.Fragment,null,(0,e.createElement)(n,{...i}),(0,e.createElement)(t.InspectorControls,null,Object.keys(p).map((t=>{if(t===window.themeisleSDKPromotions.showPromotion){const n=p[t];return(0,e.createElement)(o.PanelBody,{key:t,title:n.title,initialOpen:!1},(0,e.createElement)("p",null,n.description),(0,e.createElement)(P,null),(0,e.createElement)("img",{style:d.image,src:window.themeisleSDKPromotions.assets+n.image}),(0,e.createElement)(u,{onClick:()=>E(!0)}))}}))))}),"withInspectorControl");(0,i.select)("core/edit-site")||(0,r.addFilter)("editor.BlockEdit","themeisle-sdk/with-inspector-controls",h);const w=window.wp.plugins,g=window.wp.editPost;function E({stacked:t=!1,noImage:n=!1,type:i,onDismiss:r,onSuccess:c,initialStatus:d=null}){const{assets:p,title:u,email:h,option:w,optionKey:g,labels:E,optimoleActivationUrl:k,optimoleApi:y,optimoleDash:f,nonce:S}=window.themeisleSDKPromotions,[P,b]=(0,s.useState)(!1),[v,D]=(0,s.useState)(h||""),[B,_]=(0,s.useState)(!1),[N,K]=(0,s.useState)(d),[C,O]=a(),A=async()=>{_(!0);const e={...w};e[i]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await O(g,JSON.stringify(e)),r&&r()},x=()=>{b(!P)},j=e=>{D(e.target.value)},R=async e=>{e.preventDefault(),K("installing"),await l("optimole-wp"),K("activating"),await m(k),O("themeisle_sdk_promotions_optimole_installed",!Boolean(C("themeisle_sdk_promotions_optimole_installed"))),K("connecting");try{await fetch(y,{method:"POST",headers:{"X-WP-Nonce":S,"Content-Type":"application/json"},body:JSON.stringify({email:v})}),c&&c(),K("done")}catch(e){K("done")}};if(B)return null;const I=()=>"done"===N?(0,e.createElement)("div",{className:"done"},(0,e.createElement)("p",null," ",E.optimole.all_set),(0,e.createElement)(o.Button,{icon:"external",isPrimary:!0,href:f,target:"_blank"},E.optimole.gotodash)):N?(0,e.createElement)("p",{className:"om-progress"},(0,e.createElement)("span",{className:"dashicons dashicons-update spin"}),(0,e.createElement)("span",null,"installing"===N&&E.optimole.installing,"activating"===N&&E.optimole.activating,"connecting"===N&&E.optimole.connecting,"…")):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("span",null,"Enter your email address to create & connect your account"),(0,e.createElement)("form",{onSubmit:R},(0,e.createElement)("input",{defaultValue:v,type:"email",onChange:j,placeholder:E.optimole.email_placeholder}),(0,e.createElement)(o.Button,{isPrimary:!0,type:"submit"},E.optimole.start_cta))),T=()=>(0,e.createElement)(o.Button,{disabled:N&&"done"!==N,onClick:A,isLink:!0,className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},E.optimole.dismisscta));return t?(0,e.createElement)("div",{className:"ti-om-stack-wrap"},(0,e.createElement)("div",{className:"om-stack-notice"},T(),(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("h2",null,E.optimole.heading),(0,e.createElement)("p",null,"om-editor"===i||"om-image-block"===i?E.optimole.message1:E.optimole.message2),!P&&"done"!==N&&(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x,className:"cta"},E.optimole.gst),(P||"done"===N)&&I(),(0,e.createElement)("i",null,u))):(0,e.createElement)(e.Fragment,null,T(),(0,e.createElement)("div",{className:"content"},!n&&(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("div",null,(0,e.createElement)("p",null,u),(0,e.createElement)("p",{className:"description"},"om-media"===i?E.optimole.message3:E.optimole.message4),!P&&(0,e.createElement)("div",{className:"actions"},(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x},E.optimole.gst),(0,e.createElement)(o.Button,{isLink:!0,target:"_blank",href:"https://wordpress.org/plugins/optimole-wp"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null," ",E.optimole.learnmore))),P&&(0,e.createElement)("div",{className:"form-wrap"},I()))))}const k=()=>{const[t,o]=(0,s.useState)(!0),{getBlocks:n}=(0,i.useSelect)((e=>{const{getBlocks:t}=e("core/block-editor");return{getBlocks:t}}));var r;if((r=n(),"core/image",r.reduce(c,[]).filter((e=>"core/image"===e.name))).length<2)return null;const a="ti-sdk-optimole-post-publish "+(t?"":"hidden");return(0,e.createElement)(g.PluginPostPublishPanel,{className:a},(0,e.createElement)(E,{stacked:!0,type:"om-editor",onDismiss:()=>{o(!1)}}))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(this.debug)this.runAll();else switch(this.promo){case"om-attachment":this.runAttachmentPromo();break;case"om-media":this.runMediaPromo();break;case"om-editor":this.runEditorPromo();break;case"om-image-block":this.runImageBlockPromo();break;case"om-elementor":this.runElementorPromo()}}runAttachmentPromo(){wp.media.view.Attachment.Details.prototype.on("ready",(()=>{setTimeout((()=>{this.removeAttachmentPromo(),this.addAttachmentPromo()}),100)})),wp.media.view.Modal.prototype.on("close",(()=>{setTimeout(this.removeAttachmentPromo,100)}))}runMediaPromo(){if(window.themeisleSDKPromotions.option["om-media"])return;const t=document.querySelector("#ti-optml-notice");t&&(0,s.render)((0,e.createElement)(E,{type:"om-media",onDismiss:()=>{t.style.opacity=0}}),t)}runImageBlockPromo(){if(window.themeisleSDKPromotions.option["om-image-block"])return;let o=!0,i=null;const a=(0,n.createHigherOrderComponent)((n=>r=>"core/image"===r.name&&o?(0,e.createElement)(s.Fragment,null,(0,e.createElement)(n,{...r}),(0,e.createElement)(t.InspectorControls,null,(0,e.createElement)(E,{stacked:!0,type:"om-image-block",initialStatus:i,onDismiss:()=>{o=!1},onSuccess:()=>{i="done"}}))):(0,e.createElement)(n,{...r})),"withImagePromo");(0,r.addFilter)("editor.BlockEdit","optimole-promo/image-promo",a,99)}runEditorPromo(){window.themeisleSDKPromotions.option["om-editor"]||(0,w.registerPlugin)("optimole-promo",{render:k})}runElementorPromo(){if(!window.elementor)return;const e=this;elementor.on("preview:loaded",(()=>{elementor.panel.currentView.on("set:page:editor",(t=>{e.domRef&&(0,s.unmountComponentAtNode)(e.domRef),t.activeSection&&"section_image"===t.activeSection&&e.runElementorActions(e)}))}))}addAttachmentPromo(){if(this.domRef&&(0,s.unmountComponentAtNode)(this.domRef),window.themeisleSDKPromotions.option["om-attachment"])return;const t=document.querySelector("#ti-optml-notice-helper");t&&(this.domRef=t,(0,s.render)((0,e.createElement)("div",{className:"notice notice-info ti-sdk-om-notice",style:{margin:0}},(0,e.createElement)(E,{noImage:!0,type:"om-attachment",onDismiss:()=>{t.style.opacity=0}})),t))}removeAttachmentPromo(){const e=document.querySelector("#ti-optml-notice-helper");e&&(0,s.unmountComponentAtNode)(e)}runElementorActions(t){if(window.themeisleSDKPromotions.option["om-elementor"])return;const o=document.querySelector("#elementor-panel__editor__help"),n=document.createElement("div");n.id="ti-optml-notice",t.domRef=n,o&&(o.parentNode.insertBefore(n,o),(0,s.render)((0,e.createElement)(E,{stacked:!0,type:"om-elementor",onDismiss:()=>{n.style.opacity=0}}),n))}runAll(){this.runAttachmentPromo(),this.runMediaPromo(),this.runEditorPromo(),this.runImageBlockPromo(),this.runElementorPromo()}};const y=({onDismiss:t=(()=>{})})=>{const[n,i]=(0,s.useState)(""),[r,c]=a();return(0,e.createElement)(s.Fragment,null,(0,e.createElement)(o.Button,{disabled:"installing"===n,onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["rop-posts"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await c(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),t&&t()},variant:"link",className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Boost your content's reach effortlessly! Introducing ",(0,e.createElement)("b",null,"Revive Social"),", a cutting-edge plugin from the makers of ",window.themeisleSDKPromotions.product,". Seamlessly auto-share old & new content across social media, driving traffic like never before."),(0,e.createElement)("div",{className:"rop-notice-actions"},"installed"!==n?(0,e.createElement)(o.Button,{variant:"primary",isBusy:"installing"===n,onClick:async()=>{i("installing"),await l("tweet-old-post"),await m(window.themeisleSDKPromotions.ropActivationUrl),c("themeisle_sdk_promotions_rop_installed",!Boolean(r("themeisle_sdk_promotions_rop_installed"))),i("installed")}},"Install & Activate"):(0,e.createElement)(o.Button,{variant:"primary",href:window.themeisleSDKPromotions.ropDash},"Visit Dashboard"),(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:"https://wordpress.org/plugins/tweet-old-post/"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["rop-posts"])return;const t=document.querySelector("#ti-rop-notice");t&&(0,s.render)((0,e.createElement)(y,{onDismiss:()=>{t.style.display="none"}}),t)}};const f=({onDismiss:t=(()=>{})})=>{const[n,i]=a(),{neveFSEMoreUrl:r}=window.themeisleSDKPromotions;return(0,e.createElement)(s.Fragment,null,(0,e.createElement)(o.Button,{onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["neve-fse-themes-popular"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await i(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),t&&t()},className:"notice-dismiss"},(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Meet ",(0,e.createElement)("b",null,"Neve FSE")," from the makers of ",window.themeisleSDKPromotions.product,". A theme that makes full site editing on WordPress straightforward and user-friendly."),(0,e.createElement)("div",{className:"neve-fse-notice-actions"},(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:r},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["neve-fse-themes-popular"])return;const t=document.querySelector("#ti-neve-fse-notice");t&&(0,s.render)((0,e.createElement)(f,{onDismiss:()=>{t.style.display="none"}}),t)}}}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var s=o[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.m=t,e=[],n.O=(t,o,i,s)=>{if(!o){var r=1/0;for(c=0;c=s)&&Object.keys(n.O).every((e=>n.O[e](o[l])))?o.splice(l--,1):(a=!1,s0&&e[c-1][2]>s;c--)e[c]=e[c-1];e[c]=[o,i,s]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={57:0,350:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var i,s,[r,a,l]=o,m=0;if(r.some((t=>0!==e[t]))){for(i in a)n.o(a,i)&&(n.m[i]=a[i]);if(l)var c=l(n)}for(t&&t(o);mn(689)));i=n.O(i)})(); \ No newline at end of file diff --git a/assets/js/src/otter.js b/assets/js/src/otter.js index 43d678fc..df96f200 100644 --- a/assets/js/src/otter.js +++ b/assets/js/src/otter.js @@ -68,90 +68,92 @@ const Footer = ({onClick}) => { const withInspectorControls = createHigherOrderComponent((BlockEdit) => { return (props) => { - if (props.isSelected && Boolean(window.themeisleSDKPromotions.showPromotion)) { - - const [isLoading, setLoading] = useState(false); - const [installStatus, setInstallStatus] = useState('default'); - const [hasSkipped, setHasSkipped] = useState(false); - - const [getOption, updateOption, status] = useSettings(); - - const install = async () => { - setLoading(true); - await installPluginOrTheme('otter-blocks'); - updateOption('themeisle_sdk_promotions_otter_installed', !Boolean(getOption('themeisle_sdk_promotions_otter_installed'))); - await activatePlugin(window.themeisleSDKPromotions.otterActivationUrl); - setLoading(false); - setInstallStatus('installed'); - }; - - const Install = () => { - if ('installed' === installStatus) { - return

Awesome! Refresh the page to see Otter Blocks in action.

; - } - - return ( - - ); - }; - - const onSkip = () => { - const option = {...window.themeisleSDKPromotions.option}; - option[window.themeisleSDKPromotions.showPromotion] = new Date().getTime() / 1000 | 0; - updateOption('themeisle_sdk_promotions', JSON.stringify(option)); - window.themeisleSDKPromotions.showPromotion = false; - }; - - useEffect(() => { - if (hasSkipped) { - onSkip(); - } - }, [hasSkipped]); + const [isLoading, setLoading] = useState(false); + const [installStatus, setInstallStatus] = useState('default'); + const [hasSkipped, setHasSkipped] = useState(false); + const [getOption, updateOption, status] = useSettings(); + + + const onSkip = () => { + const option = {...window.themeisleSDKPromotions.option}; + option[window.themeisleSDKPromotions.showPromotion] = new Date().getTime() / 1000 | 0; + updateOption('themeisle_sdk_promotions', JSON.stringify(option)); + window.themeisleSDKPromotions.showPromotion = false; + }; + + useEffect(() => { if (hasSkipped) { - return ; + onSkip(); + } + }, [hasSkipped]); + + + + if (! props.isSelected || ! Boolean(window.themeisleSDKPromotions.showPromotion)) { + return ; + } + + const install = async () => { + setLoading(true); + await installPluginOrTheme('otter-blocks'); + updateOption('themeisle_sdk_promotions_otter_installed', !Boolean(getOption('themeisle_sdk_promotions_otter_installed'))); + await activatePlugin(window.themeisleSDKPromotions.otterActivationUrl); + setLoading(false); + setInstallStatus('installed'); + }; + + const Install = () => { + if ('installed' === installStatus) { + return

Awesome! Refresh the page to see Otter Blocks in action.

; } return ( - - - - - {Object.keys(upsells).map(key => { - if (key === window.themeisleSDKPromotions.showPromotion) { - const upsell = upsells[key]; - - return ( - -

{upsell.description}

- - - - - -