Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WordPress 6.7 compatibility #329

Merged
merged 22 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f8562ec
fixed function _load_textdomain_just_in_time called incorrectly (#325)
Fellan-91 Nov 22, 2024
52c9482
moved all files connections to the init hook
Fellan-91 Nov 22, 2024
9f8d62c
Improved the text domain connection
Fellan-91 Nov 26, 2024
3c8b427
Merge branch 'master' into wp-6.7-compat-fixes
nk-o Nov 27, 2024
972bfb6
remove matrix from e2e since there is no much tests available yet
nk-o Nov 27, 2024
816b9bb
fix some components deprecated notices
nk-o Nov 28, 2024
8f05ba7
improve export page checkbox styles
nk-o Nov 28, 2024
220775d
style fixes and improvements for constructor ui
nk-o Nov 28, 2024
2f22338
build
nk-o Nov 28, 2024
5f51e6a
Merge branch 'master' into wp-6.7-compat-fixes
nk-o Nov 29, 2024
7e536b0
build
nk-o Nov 29, 2024
a3882fd
fixed block preview infinite loading state
nk-o Dec 2, 2024
924e4ec
build
nk-o Dec 2, 2024
ed2865e
returned domain text registration to init hook
Fellan-91 Dec 2, 2024
b9517df
fixed the control registration by implementing it through an internal…
Fellan-91 Dec 2, 2024
fb3d853
fixed the checkbox control definition in the e2e test
Fellan-91 Dec 2, 2024
a43afd2
fixed usage of __nextHasNoMarginBottom in radio controls
nk-o Dec 2, 2024
a74aed0
Merge branch 'wp-6.7-compat-fixes' of https://github.com/nk-crew/lazy…
nk-o Dec 2, 2024
9438664
fixed block slug filling in e2e block creation test
Fellan-91 Dec 2, 2024
c3e07a6
fixed useEffect mounted states in dev build
nk-o Dec 3, 2024
e6b26f6
changed Add New item label in menu
nk-o Dec 3, 2024
bf5f9d3
build
nk-o Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@ concurrency:

jobs:
playwright:
name: Playwright - ${{ matrix.part }}
name: Playwright
runs-on: ubuntu-latest
if: ${{ github.repository == 'nk-crew/lazy-blocks' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
part: [1, 2, 3, 4]
totalParts: [4]

steps:
- uses: actions/checkout@v4
Expand All @@ -45,4 +40,4 @@ jobs:

- name: Run the tests
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e -- --shard=${{ matrix.part }}/${{ matrix.totalParts }}
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e
6 changes: 5 additions & 1 deletion assets/admin/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data';
import { useEntityProp } from '@wordpress/core-data';
import { PanelRow, SelectControl } from '@wordpress/components';
import { useDebounce } from '@wordpress/compose';
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { PluginDocumentSettingPanel } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -182,6 +182,8 @@ function UpdateEditor() {
onChange={(value) => {
updateMeta('_lzb_template_post_types', value);
}}
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
</div>
</PanelRow>
Expand All @@ -194,6 +196,8 @@ function UpdateEditor() {
onChange={(value) => {
updateMeta('_lzb_template_lock', value);
}}
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
</div>
</PanelRow>
Expand Down
13 changes: 13 additions & 0 deletions assets/admin/tools/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
background-color: #f1f1f1;
border: 1px solid #ccd0d4;
border-radius: 4px;

.components-toggle-control__label {
padding-top: 3px;
margin-left: 0 !important;

> span {
margin-top: -3px;
}
}

.components-toggle-control > .components-base-control__field > .components-flex {
align-items: start;
}
}

.lzb-export-textarea {
Expand Down
6 changes: 5 additions & 1 deletion assets/admin/tools/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function Templates() {
return (
<>
<div className="lzb-export-select-items">
<BaseControl>
<BaseControl __nextHasNoMarginBottom>
<ToggleControl
label={__('Select all', 'lazy-blocks')}
checked={
Expand Down Expand Up @@ -140,6 +140,7 @@ export default function Templates() {
setDisabledTemplates(newDisabled);
}
}}
__nextHasNoMarginBottom
/>
{data[type].map((item) => {
const isSelected =
Expand Down Expand Up @@ -215,6 +216,7 @@ export default function Templates() {
setDisabledTemplates(newDisabled);
}
}}
__nextHasNoMarginBottom
/>
);
})}
Expand All @@ -228,6 +230,8 @@ export default function Templates() {
className="lzb-export-code"
readOnly
value={getPHPStringCode(type)}
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
</div>
<div className="lzb-export-buttons">
Expand Down
6 changes: 4 additions & 2 deletions assets/components/block-slug/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
white-space: nowrap;
padding: 6px 8px;
padding-right: 10px;
height: 32px;
height: 40px;
border: 1px solid #949494;
line-height: normal;
color: $gray-800;
Expand All @@ -39,7 +39,9 @@
flex: 1;
margin-bottom: 0 !important;

input {
input.components-text-control__input {
padding-left: 5px;
padding-right: 5px;
margin-left: 0;
border-left: none;
border-top-left-radius: 0;
Expand Down
8 changes: 7 additions & 1 deletion assets/components/block-slug/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import { __ } from '@wordpress/i18n';

export default function BlockSlug(props) {
return (
<BaseControl id={props.label} label={props.label || ''}>
<BaseControl
id={props.label}
label={props.label || ''}
__nextHasNoMarginBottom
>
<div className="lazyblocks-component-block-slug">
<Dropdown
className="lazyblocks-component-block-slug-prefix-dropdown"
Expand Down Expand Up @@ -61,6 +65,8 @@ export default function BlockSlug(props) {
...props,
...{ label: '' },
}}
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
</div>
</BaseControl>
Expand Down
2 changes: 2 additions & 0 deletions assets/components/document-tabs/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
display: flex;
margin-bottom: -1px;
background-color: #fff;
padding: 0;
z-index: 2;

> ul {
Expand All @@ -21,6 +22,7 @@

button {
position: relative;
padding: 12px 16px;
height: 48px;
font-weight: 500;
outline: none;
Expand Down
9 changes: 8 additions & 1 deletion assets/components/icon-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ function IconPickerDropdown(props) {
onChange={(searchVal) => setSearch(searchVal)}
placeholder={__('Type to Search…', 'lazy-blocks')}
autoComplete="off"
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
</Fragment>
),
Expand Down Expand Up @@ -297,7 +299,12 @@ function IconPickerDropdown(props) {
);

return label ? (
<BaseControl id={label} label={label} className={className}>
<BaseControl
id={label}
label={label}
className={className}
__nextHasNoMarginBottom
>
{dropdown}
</BaseControl>
) : (
Expand Down
11 changes: 6 additions & 5 deletions assets/components/preview-server-callback/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@ export default function PreviewServerCallback(props) {

// When the component unmounts, set isMountedRef to false. This will
// let the async fetch callbacks know when to stop.
useEffect(
() => () => {
useEffect(() => {
isMountedRef.current = true;

return () => {
isMountedRef.current = false;
},
[]
);
};
}, []);

// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(() => {
Expand Down
6 changes: 5 additions & 1 deletion assets/components/pro-notice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function ProNotice() {
id="lazyblocks-pro-notice"
label={__('Lazy Blocks Pro', 'lazy-blocks')}
className="lazyblocks-component-pro-notice"
__nextHasNoMarginBottom
>
<div>
<a
Expand All @@ -34,7 +35,10 @@ export default function ProNotice() {
</a>
<ul className="ul-square">
<li>
{__('Custom Slugs and Collections', 'lazy-blocks')}
{__(
'Custom block collections and slug namespaces',
'lazy-blocks'
)}
</li>
<li>
{__('Controls Conditional Logic', 'lazy-blocks')}
Expand Down
2 changes: 1 addition & 1 deletion assets/components/tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BaseControl, TabPanel } from '@wordpress/components';

export default function Tabs({ tabs, children }) {
return (
<BaseControl>
<BaseControl __nextHasNoMarginBottom>
<TabPanel tabs={tabs} className="lazyblocks-component-tabs">
{children}
</TabPanel>
Expand Down
2 changes: 2 additions & 0 deletions assets/editor-constructor/boxes/code-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ export default function CodePreview(props) {
const $frameObserver = iframeObserver.current;
const $frame = iframeRef.current;

isMountedRef.current = true;

return () => {
$frameObserver.disconnect();
$frame.removeEventListener('load', setIframeHeight);
Expand Down
12 changes: 9 additions & 3 deletions assets/editor-constructor/boxes/code/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export default function CustomCodeSettings(props) {
value={data.code_output_method || 'html'}
onChange={(value) => updateData({ code_output_method: value })}
isAdaptiveWidth
__next40pxDefaultSize
__nextHasNoMarginBottom
>
<ToggleGroupControlOption
value="html"
Expand Down Expand Up @@ -128,7 +130,7 @@ export default function CustomCodeSettings(props) {
data.code_output_method !== 'template' ? (
<>
<PanelBody>
<BaseControl>
<BaseControl __nextHasNoMarginBottom>
{tabs.length > 1 ? (
<TabPanel
className="lazyblocks-control-tabs"
Expand All @@ -153,7 +155,7 @@ export default function CustomCodeSettings(props) {
}}
/>
</BaseControl>
<BaseControl>
<BaseControl __nextHasNoMarginBottom>
{!showInfo ? (
<Button
isLink
Expand Down Expand Up @@ -209,7 +211,7 @@ export default function CustomCodeSettings(props) {
</PanelBody>

<PanelBody>
<BaseControl>
<BaseControl __nextHasNoMarginBottom>
<ToggleControl
label={__(
'Single output code for Frontend and Editor',
Expand All @@ -219,6 +221,7 @@ export default function CustomCodeSettings(props) {
onChange={(value) =>
updateData({ code_single_output: value })
}
__nextHasNoMarginBottom
/>
</BaseControl>
</PanelBody>
Expand Down Expand Up @@ -287,6 +290,7 @@ export default function CustomCodeSettings(props) {
<BaseControl
id="lazyblocks-settings-output-in-editor"
label={__('Code Output in Editor', 'lazy-blocks')}
__nextHasNoMarginBottom
>
<SelectControl
id="lazyblocks-settings-output-in-editor"
Expand Down Expand Up @@ -318,6 +322,8 @@ export default function CustomCodeSettings(props) {
onChange={(value) =>
updateData({ code_show_preview: value })
}
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
</BaseControl>
</PanelBody>,
Expand Down
58 changes: 37 additions & 21 deletions assets/editor-constructor/boxes/condition/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,46 @@ export default function ConditionSettings(props) {
const [postTypes, setPostTypes] = useState(false);

useEffect(() => {
let isMounted = true;
const controller =
typeof AbortController === 'undefined'
? undefined
: new AbortController();

apiFetch({
path: '/lazy-blocks/v1/get-post-types/?args[show_ui]=1&output=object',
}).then((resp) => {
if (resp && resp.response) {
const result = {};
Object.keys(resp.response).forEach((name) => {
const post = resp.response[name];
signal: controller?.signal,
})
.then((resp) => {
if (isMounted && resp && resp.response) {
const result = {};
Object.keys(resp.response).forEach((name) => {
const post = resp.response[name];

if (
![
'lazyblocks',
'lazyblocks_templates',
'attachment',
'wp_block',
'wp_navigation',
'ghostkit_template',
].includes(post.name)
) {
result[post.name] = post.label;
}
});
if (
![
'lazyblocks',
'lazyblocks_templates',
'attachment',
'wp_block',
'wp_navigation',
'ghostkit_template',
].includes(post.name)
) {
result[post.name] = post.label;
}
});

setPostTypes(result);
}
})
.catch(() => {});

setPostTypes(result);
}
});
// Cleanup.
return () => {
isMounted = false;
controller?.abort();
};
}, []);

const { condition_post_types: conditionPostTypes } = data;
Expand All @@ -50,6 +65,7 @@ export default function ConditionSettings(props) {
<BaseControl
id="lazyblocks-boxes-condition-posts"
label={__('Show in posts', 'lazy-blocks')}
__nextHasNoMarginBottom
>
<Select
id="lazyblocks-boxes-condition-posts"
Expand Down
Loading
Loading