Add page_background Elementor location

This commit is contained in:
Tetrakern 2024-06-14 12:30:50 +02:00
parent 72ff8bc522
commit c773cf835d
6 changed files with 39 additions and 8 deletions

View File

@ -1149,9 +1149,26 @@ Renders the theme sidebar (not displayed anywhere by default). Requires the "Dis
## Elementor
If you have the Elementor plugin installed, consider using the [Fictioneer 002 Elementor Control](https://github.com/Tetrakern/fictioneer/blob/main/INSTALLATION.md#recommended-must-use-plugins) plugin if you only need it for the Canvas page templates. If you have the Pro version and want to use the theme builder, this may not be an option, but you can customize the following locations: `header`, `footer`, `nav_bar`, `nav_menu`, `mobile_nav_menu`, and `story_header`.
If you have the Elementor plugin installed, consider using the [Fictioneer 002 Elementor Control](https://github.com/Tetrakern/fictioneer/blob/main/INSTALLATION.md#recommended-must-use-plugins) plugin if you only need it for the Canvas page templates. If you have the Pro version and want to use the theme builder, this may not be an option, but you can customize the following locations: `header`, `footer`, `nav_bar`, `nav_menu`, `mobile_nav_menu`, `story_header`, and `page_background`.
**Notes:**
**Page Background**
This location can be confusing. The page background is actually a separate element in the theme, positioned under the content container and made inaccessible. This allows for various styling shenanigans without ever affecting the content, such as clip-paths and masks applied to an inner `::before` pseudo-element. The page styles from the Customizer make heavy use of this. If you overwrite this location, you must ensure to properly move it to the background. The base default CSS is as follows:
```css
.main__background {
pointer-events: none;
user-select: none;
position: absolute;
inset: var(--page-inset-top) 0 0 0;
z-index: 0;
background-color: var(--page-bg-color);
box-shadow: var(--page-box-shadow);
contain: layout style;
}
```
**Hints:**
* The `nav_bar` location also overwrites the `nav_menu` location.
* Trying to overwrite the default navigation is generally a poor life choice, but you do you.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2078,10 +2078,13 @@ add_action( 'fictioneer_main', 'fictioneer_main_observer', 1 );
*/
function fictioneer_page_background( $context = null ) {
// Setup
$background = '<div class="main__background polygon polygon--main background-texture"></div>';
// Elementor?
if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'page_background' ) ) {
// Setup
$background = '<div class="main__background polygon polygon--main background-texture"></div>';
// Render
echo apply_filters( 'fictioneer_filter_page_background', $background );
// Render
echo apply_filters( 'fictioneer_filter_page_background', $background );
}
}
add_action( 'fictioneer_main', 'fictioneer_page_background' );

View File

@ -1800,6 +1800,15 @@ function fictioneer_elementor_register_locations( $elementor_theme_manager ) {
'edit_in_content' => true
)
);
$elementor_theme_manager->register_location(
'page_background',
array(
'label' => esc_html__( 'Page Background', 'fictioneer' ),
'multiple' => false,
'edit_in_content' => false
)
);
}
/**

View File

@ -47,6 +47,8 @@
// Allows for semi-transparent and clipped backgrounds without affecting the content
&__background {
pointer-events: none;
user-select: none;
position: absolute;
inset: var(--page-inset-top) 0 0 0;
z-index: 0;