Skip to content

Commit 3a72022

Browse files
committed
Merge branch 'develop' into feat/more-guided-tours
# Conflicts: # src/welcome/getting-started.scss
2 parents 44e5774 + 9338467 commit 3a72022

File tree

41 files changed

+1077
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1077
-215
lines changed

plugin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ function is_frontend() {
288288
require_once( plugin_dir_path( __FILE__ ) . 'src/plugins/global-settings/block-styles/index.php' );
289289
require_once( plugin_dir_path( __FILE__ ) . 'src/css-optimize.php' );
290290
require_once( plugin_dir_path( __FILE__ ) . 'src/compatibility/index.php' );
291+
291292
if ( ! is_admin() ) {
292293
require_once( plugin_dir_path( __FILE__ ) . 'src/lightbox/index.php' );
293294
require_once( plugin_dir_path( __FILE__ ) . 'src/block/accordion/index.php' );
@@ -314,6 +315,7 @@ function is_frontend() {
314315
*/
315316
require_once( plugin_dir_path( __FILE__ ) . 'src/welcome/getting-started.php' );
316317
if ( is_admin() ) {
318+
require_once( plugin_dir_path( __FILE__ ) . 'src/welcome/useful-plugins.php' ); // For cross-marketing
317319
require_once( plugin_dir_path( __FILE__ ) . 'src/welcome/index.php' );
318320
require_once( plugin_dir_path( __FILE__ ) . 'src/welcome/news.php' );
319321
require_once( plugin_dir_path( __FILE__ ) . 'src/welcome/freemius.php' );

src/compatibility/ewww.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77

88
if ( ! function_exists( 'stackable_load_image_optimizer_polyfill_frontend_script' ) ) {
9-
function stackable_load_image_optimizer_polyfill_frontend_script( $block_content, $block ) {
9+
function stackable_load_image_optimizer_polyfill_frontend_script( $block_content ) {
1010
// If Easy IO setting is activated for EWWW Image Optimizer, dynamic images becomes blurry.
1111
// Load the script to fix the issue.
1212
if ( ! is_admin() ) {
@@ -26,7 +26,7 @@ function stackable_load_image_optimizer_polyfill_frontend_script( $block_content
2626
function stackable_ewww_image_optimzer_plugin_checker() {
2727
if ( ! is_admin() && defined( 'EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE' ) ) {
2828
// Load the script in the frontend if EWWW Image Optimizer is active.
29-
add_action( 'stackable/enqueue_scripts', 'stackable_load_image_optimizer_polyfill_frontend_script', 10, 2 );
29+
add_action( 'stackable/enqueue_scripts', 'stackable_load_image_optimizer_polyfill_frontend_script' );
3030
}
3131
}
3232

src/components/design-library-list/favorite-button.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/components/design-library-list/images/heart-fill.svg

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/components/design-library-list/images/heart.svg

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/components/image-control2/index.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Button from '../button'
1111
* External dependencies
1212
*/
1313
import classnames from 'classnames'
14-
import { i18n } from 'stackable'
14+
import { i18n, cimo } from 'stackable'
1515
import {
1616
useAttributeName, useBlockAttributesContext, useBlockSetAttributesContext,
1717
} from '~stackable/hooks'
@@ -20,8 +20,11 @@ import {
2020
* WordPress dependencies
2121
*/
2222
import { __ } from '@wordpress/i18n'
23-
import { Fragment, memo } from '@wordpress/element'
23+
import {
24+
Fragment, memo, useEffect, useState,
25+
} from '@wordpress/element'
2426
import { MediaUpload } from '@wordpress/block-editor'
27+
import { currentUserHasCapability } from '~stackable/util'
2528

2629
const ImageControl = memo( props => {
2730
const attrNameId = useAttributeName( `${ props.attribute }Id`, props.responsive, props.hover )
@@ -81,7 +84,37 @@ const ImageControl = memo( props => {
8184
} )
8285
}
8386

84-
return (
87+
const [ CimoDownloadNotice, setCimoDownloadNotice ] = useState( null )
88+
89+
useEffect( () => {
90+
// Skip displaying the Cimo notice if the plugin is already activated or the user has chosen to hide the notice
91+
if ( ! cimo || cimo.hideNotice || cimo.status === 'activated' ) {
92+
return
93+
}
94+
95+
const userCanInstall = currentUserHasCapability( 'install_plugins' )
96+
const userCanActivate = currentUserHasCapability( 'activate_plugins' )
97+
// Show the Cimo notice only if the user has permissions to install or activate plugins
98+
if ( ( cimo.status === 'not_installed' && userCanInstall ) || ( cimo.status === 'installed' && userCanActivate ) ) {
99+
const loadNotice = async () => {
100+
try {
101+
// Import the Cimo notice component with explicit chunk naming
102+
const { default: CimoNoticeComponent } = await import(
103+
/* webpackChunkName: "cimo-download-notice" */
104+
/* webpackMode: "lazy" */
105+
'../../lazy-components/cimo'
106+
)
107+
setCimoDownloadNotice( () => CimoNoticeComponent )
108+
} catch ( err ) {
109+
// eslint-disable-next-line no-console
110+
console.error( 'Failed to load Cimo download notice component:', err )
111+
}
112+
}
113+
loadNotice()
114+
}
115+
}, [] )
116+
117+
return ( <>
85118
<AdvancedControl
86119
{ ...controlProps }
87120
valueCheckAttribute={ props.attribute + 'Url' }
@@ -112,7 +145,7 @@ const ImageControl = memo( props => {
112145
/>
113146
) }
114147
{ type === 'image' && (
115-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
148+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
116149
<img
117150
className="ugb-image-preview"
118151
draggable="false"
@@ -172,6 +205,8 @@ const ImageControl = memo( props => {
172205
hasPanelModifiedIndicator={ props.hasPanelModifiedIndicator }
173206
/>
174207
</AdvancedControl>
208+
{ CimoDownloadNotice && <CimoDownloadNotice onDismiss={ () => setCimoDownloadNotice( null ) } /> }
209+
</>
175210
)
176211
} )
177212

src/components/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export { default as SortControl } from './sort-control'
2020
export { default as PanelAdvancedSettings } from './panel-advanced-settings'
2121
export { default as PanelDesignLibrary } from './panel-design-library'
2222
export { default as InspectorPanelControls } from './panel-tabs/inspector-panel-controls'
23-
export { default as DesignLibraryList } from './design-library-list'
2423
export { default as PanelTabs } from './panel-tabs'
2524
export { default as Button } from './button'
2625
export { default as DesignPanelBody } from './design-panel-body'

src/components/modal-design-library/index.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
/**
2-
* Internal dependencies
3-
*/
4-
import { ModalDesignLibrary } from './modal'
5-
61
/**
72
* WordPress dependencies
83
*/
94
import { applyFilters } from '@wordpress/hooks'
10-
import { useMemo, useCallback } from '@wordpress/element'
5+
import {
6+
useMemo, useCallback, Suspense, lazy,
7+
} from '@wordpress/element'
118
import { useLocalStorage } from '~stackable/util'
129

1310
export const Switcher = props => {
@@ -21,19 +18,25 @@ export const Switcher = props => {
2118
// disabled, always default to the first version
2219
const apiVersion = versions.includes( _apiVersion ) ? _apiVersion : versions[ 0 ]
2320

21+
// Lazy-load the ModalDesignLibrary to reduce initial bundle size
22+
// Note: We import the named export and set it as default for React.lazy
23+
const LazyModalDesignLibrary = lazy( () => import( /* webpackChunkName: "design-library" */ '~stackable/lazy-components/design-library' ) )
24+
2425
const ModalComponent = useMemo( () => {
25-
return applyFilters( 'stackable.design-library.modal-component', ModalDesignLibrary, apiVersion )
26+
return applyFilters( 'stackable.design-library.modal-component', LazyModalDesignLibrary, apiVersion )
2627
}, [ apiVersion ] )
2728

2829
const onChangeApiVersion = useCallback( v => setApiVersion( v ), [] )
2930

3031
return (
31-
<ModalComponent
32-
hasVersionSwitcher={ versions.length > 1 }
33-
apiVersion={ apiVersion }
34-
onChangeApiVersion={ onChangeApiVersion }
35-
{ ...props }
36-
/>
32+
<Suspense fallback={ null }>
33+
<ModalComponent
34+
hasVersionSwitcher={ versions.length > 1 }
35+
apiVersion={ apiVersion }
36+
onChangeApiVersion={ onChangeApiVersion }
37+
{ ...props }
38+
/>
39+
</Suspense>
3740
)
3841
}
3942

src/design-library/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ export const fetchDesignLibrary = async ( forceReset = false, version = '', type
2929
designLibrary[ type ] = designsPerType
3030

3131
if ( type === 'patterns' ) {
32-
designs = designsPerType[ LATEST_API_VERSION ]
32+
designs = designsPerType[ LATEST_API_VERSION ] ?? {}
3333
} else {
34-
pages = designsPerType[ LATEST_API_VERSION ]
34+
pages = designsPerType[ LATEST_API_VERSION ] ?? {}
3535
}
3636
}
3737

38-
return designLibrary[ type ][ version || LATEST_API_VERSION ]
38+
return designLibrary[ type ]?.[ version || LATEST_API_VERSION ] ?? designLibrary[ type ]
3939
}
4040

4141
export const fetchDesign = async designId => {
@@ -63,6 +63,13 @@ export const getDesigns = async ( {
6363
} ) => {
6464
const designLibrary = await fetchDesignLibrary( reset, LATEST_API_VERSION, type )
6565

66+
if ( designLibrary.wp_remote_get_error || designLibrary.content_error ) {
67+
const error = designLibrary.wp_remote_get_error ?? designLibrary.content_error
68+
// eslint-disable-next-line no-console
69+
console.error( 'Stackable: ', error )
70+
return { error }
71+
}
72+
6673
// pre-fetch patterns
6774
if ( type === 'pages' ) {
6875
await fetchDesignLibrary()

0 commit comments

Comments
 (0)