Skip to content

Commit

Permalink
fix: if OceanWP theme is used, initially use the theme's margin to fo…
Browse files Browse the repository at this point in the history
…llow its layout
  • Loading branch information
Arukuen committed Feb 10, 2025
1 parent 7d8b5e2 commit b20abc4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/block-components/typography/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ export const Controls = props => {

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

// OceanWP compatibility.
// If OceanWP theme is used, initially use the theme's margin to follow its layout
useEffect( () => {
if ( hasRemoveMargins ) {
const value = getAttribute( 'useThemeTextMargins' )
updateAttribute( 'useThemeTextMargins', applyFilters( 'stackable.heading.edit.useThemeTextMargins', value ) )
}
}, [] )

return (
<>
{ applyFilters( 'stackable.block-component.typography.before', null, props ) }
Expand Down
1 change: 1 addition & 0 deletions src/compatibility/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import './kadence-theme'
import './wp-6-2'
import './oceanwp'
26 changes: 26 additions & 0 deletions src/compatibility/oceanwp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Kadence Theme compatibility.
*/

/**
* External dependencies
*/
import { currentTheme } from 'stackable'

/**
* WordPress dependencies
*/
import { addFilter } from '@wordpress/hooks'

addFilter( 'stackable.heading.edit.useThemeTextMargins', 'stackable/compatibility/oceanwp', value => {
if ( currentTheme !== 'oceanwp' ) {
return value
}

// If no value has been set, default to true to use OceanWP margins
if ( value === '' ) {
return true
}

return value
} )

0 comments on commit b20abc4

Please sign in to comment.