gutenberg
3 years ago
gutenbergComponents
3 years ago
autoupdate_banner.js
3 years ago
banner_main.js
3 years ago
circle-progress.js
3 years ago
datatables.min.js
4 years ago
jquery.multi-select.js
4 years ago
jquery.tagsinput.min.js
4 years ago
referral_program.js
3 years ago
sidebar-plugin.js
3 years ago
speed.js
3 years ago
two_admin.js
1 year ago
two_admin_bar.js
4 years ago
two_bf_countdown.js
3 years ago
two_deactivate_plugin.js
3 years ago
two_elementor_editor.js
2 years ago
two_preview.js
3 years ago
two_update_white_label.js
1 year ago
two_white_label.js
2 years ago
sidebar-plugin.js
106 lines
| 1 | import {Optimized} from "./gutenbergComponents/optimized"; |
| 2 | import {Optimizing} from "./gutenbergComponents/optimizing"; |
| 3 | import {NotOptimized} from "./gutenbergComponents/notOptimized"; |
| 4 | import {set_scoreData} from "./gutenbergComponents/set_scoreData"; |
| 5 | |
| 6 | const { registerPlugin } = wp.plugins; |
| 7 | const { __ } = wp.i18n; |
| 8 | const { PluginDocumentSettingPanel, PluginSidebarMoreMenuItem, PluginSidebar } = wp.editPost; |
| 9 | const { PanelRow} = wp.components; |
| 10 | const { Fragment} = wp.element; |
| 11 | |
| 12 | const BoosterSidebarPanel = () => { |
| 13 | const postType = wp.data.select('core/editor').getCurrentPostType(); |
| 14 | const allowedPostTypes = ['post', 'page']; |
| 15 | if (!allowedPostTypes.includes(postType) || wp.data.select('core/editor').getCurrentPost().status != "publish") { |
| 16 | return ''; |
| 17 | } |
| 18 | return( |
| 19 | <Fragment> |
| 20 | <PluginSidebarMoreMenuItem target='awp-custom-sidebar'>{__('10Web Booster', 'tenweb-speed-optimizer')}</PluginSidebarMoreMenuItem> |
| 21 | <PluginSidebar |
| 22 | title={__('10Web Booster', 'tenweb-speed-optimizer')}> |
| 23 | <BoosterPanelRow/> |
| 24 | </PluginSidebar> |
| 25 | </Fragment> |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | const BoosterSettingPanel = () => { |
| 30 | const postType = wp.data.select('core/editor').getCurrentPostType(); |
| 31 | const allowedPostTypes = ['post', 'page']; |
| 32 | if (!allowedPostTypes.includes(postType) || wp.data.select('core/editor').getCurrentPost().status != "publish") { |
| 33 | return ''; |
| 34 | } |
| 35 | return( |
| 36 | <Fragment> |
| 37 | <PluginDocumentSettingPanel |
| 38 | name="awp-custom-sidebar" |
| 39 | title={__('10Web Booster', 'tenweb-speed-optimizer')}> |
| 40 | <BoosterPanelRow /> |
| 41 | </PluginDocumentSettingPanel> |
| 42 | </Fragment> |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | const BoosterPanelRow = () => { |
| 47 | var post_id = wp.data.select('core/editor').getCurrentPostId(); |
| 48 | if ( two_speed.front_page_id == post_id ) { |
| 49 | post_id = 'front_page'; |
| 50 | } |
| 51 | const metas = wp.data.select('core/editor').getCurrentPostAttribute('meta'); |
| 52 | let status = 'optimized'; |
| 53 | if ( two_speed.optimizing_in_progress ) { |
| 54 | status = 'optimizing'; |
| 55 | } else if ( !( post_id in two_speed.critical_pages ) ) { |
| 56 | status = 'notOptimized'; |
| 57 | } |
| 58 | |
| 59 | if ( status == "optimized" ) { |
| 60 | let panelRow = <><PanelRow> |
| 61 | <Optimized metas={metas} post_id={post_id}/> |
| 62 | </PanelRow></>; |
| 63 | return panelRow; |
| 64 | } else if ( status == "notOptimized" ) { |
| 65 | return ( |
| 66 | <PanelRow> |
| 67 | <NotOptimized post_id={post_id} /> |
| 68 | </PanelRow>); |
| 69 | } |
| 70 | else { |
| 71 | let optimizingTitle = 'Optimizing...'; |
| 72 | return ( |
| 73 | <PanelRow> |
| 74 | <Optimizing title={optimizingTitle} /> |
| 75 | </PanelRow>); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | |
| 81 | registerPlugin('booster-sidebar-panel', { |
| 82 | render: BoosterSidebarPanel, |
| 83 | icon: <svg className="two-speed-icon" xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26"> |
| 84 | <g id="Group_103139" data-name="Group 103139" transform="translate(0 -0.391)"> |
| 85 | <path id="Path_171039" data-name="Path 171039" |
| 86 | d="M.441,38.127h0a1.445,1.445,0,0,0,2.065-.037l7.924-6.038a.131.131,0,0,0,.033-.18.126.126,0,0,0-.158-.045l-9.409,4a1.426,1.426,0,0,0-.52,2.23Z" |
| 87 | transform="translate(-0.028 -23.443)" fill="#fff"/> |
| 88 | <path id="Path_171040" data-name="Path 171040" |
| 89 | d="M5.434,48.088a1.443,1.443,0,0,1-2.063.039l0,0L.462,45.274l-.034-.029-.06-.063a1.427,1.427,0,0,1,.12-1.992,1.393,1.393,0,0,1,.4-.252L4.295,41.49,3.723,42a1.571,1.571,0,0,0-.163,2.191q.045.054.095.1l1.74,1.7a1.5,1.5,0,0,1,.039,2.1" |
| 90 | transform="translate(-0.014 -30.56)" fill="#9ea3a8"/> |
| 91 | <path id="Path_171041" data-name="Path 171041" |
| 92 | d="M69.869,43.142h0a1.445,1.445,0,0,0-2.065.037l-7.911,6.038a.131.131,0,0,0-.033.18.126.126,0,0,0,.158.045l9.4-4a1.426,1.426,0,0,0,.52-2.23Z" |
| 93 | transform="translate(-44.277 -31.469)" fill="#fff"/> |
| 94 | <path id="Path_171042" data-name="Path 171042" |
| 95 | d="M78,32.276a1.443,1.443,0,0,1,2.063-.039l0,0,2.907,2.851L83,35.12l.06.063a1.427,1.427,0,0,1-.12,1.992,1.393,1.393,0,0,1-.4.252l-3.407,1.448.572-.507a1.571,1.571,0,0,0,.163-2.191q-.045-.054-.095-.1l-1.742-1.7a1.5,1.5,0,0,1-.036-2.1" |
| 96 | transform="translate(-57.411 -23.446)" fill="#9ea3a8"/> |
| 97 | <path id="Path_171043" data-name="Path 171043" |
| 98 | d="M31.607,23.5l5.172-7.19a.126.126,0,0,0,0-.176.121.121,0,0,0-.173,0l-13.2,10.025a.131.131,0,0,0-.03.18.127.127,0,0,0,.106.055h4.143a.136.136,0,0,1,.134.139.138.138,0,0,1-.025.078L22.56,33.8a.126.126,0,0,0,0,.176.121.121,0,0,0,.173,0l13.2-10.025a.131.131,0,0,0,.03-.18.127.127,0,0,0-.106-.055H31.717a.136.136,0,0,1-.134-.139.138.138,0,0,1,.025-.078" |
| 99 | transform="translate(-16.668 -11.879)" fill="#9ea3a8"/> |
| 100 | </g> |
| 101 | </svg> |
| 102 | }); |
| 103 | registerPlugin('booster-settings-panel', { |
| 104 | render: BoosterSettingPanel, |
| 105 | icon: '' |
| 106 | }); |