Skip to content

Commit b20abc4

Browse files
committed
fix: if OceanWP theme is used, initially use the theme's margin to follow its layout
1 parent 7d8b5e2 commit b20abc4

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/block-components/typography/edit.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ export const Controls = props => {
100100

101101
const onChangeContent = useCallback( text => setDebouncedText( escapeHTML( text ) ), [] )
102102

103+
// OceanWP compatibility.
104+
// If OceanWP theme is used, initially use the theme's margin to follow its layout
105+
useEffect( () => {
106+
if ( hasRemoveMargins ) {
107+
const value = getAttribute( 'useThemeTextMargins' )
108+
updateAttribute( 'useThemeTextMargins', applyFilters( 'stackable.heading.edit.useThemeTextMargins', value ) )
109+
}
110+
}, [] )
111+
103112
return (
104113
<>
105114
{ applyFilters( 'stackable.block-component.typography.before', null, props ) }

src/compatibility/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import './kadence-theme'
22
import './wp-6-2'
3+
import './oceanwp'

src/compatibility/oceanwp/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Kadence Theme compatibility.
3+
*/
4+
5+
/**
6+
* External dependencies
7+
*/
8+
import { currentTheme } from 'stackable'
9+
10+
/**
11+
* WordPress dependencies
12+
*/
13+
import { addFilter } from '@wordpress/hooks'
14+
15+
addFilter( 'stackable.heading.edit.useThemeTextMargins', 'stackable/compatibility/oceanwp', value => {
16+
if ( currentTheme !== 'oceanwp' ) {
17+
return value
18+
}
19+
20+
// If no value has been set, default to true to use OceanWP margins
21+
if ( value === '' ) {
22+
return true
23+
}
24+
25+
return value
26+
} )

0 commit comments

Comments
 (0)