Add filter to change default chapter formatting
This commit is contained in:
parent
258e2f8d1b
commit
49478efc77
18
FILTERS.md
18
FILTERS.md
@ -137,6 +137,24 @@ Filters the intermediate output array in the `_card-chapter.php` partial before
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### `apply_filters( 'fictioneer_filter_chapter_default_formatting', $formatting )`
|
||||||
|
Filters the default chapter formatting settings. The passed array is empty because the default values are also set on the frontend. You only need this filter if you want to change that. Note that the values for font-color, font-name, and site-width should not be overridden.
|
||||||
|
|
||||||
|
**$formatting:**
|
||||||
|
* $formatting\['font-saturation'] (int) – Start value of the font saturation. Default 0.
|
||||||
|
* $formatting\['font-size'] (int) – Start value of the font size. Default 100.
|
||||||
|
* $formatting\['letter-spacing'] (float) – Start value of the letter spacing. Default 0.
|
||||||
|
* $formatting\['line-height'] (float) – Start value of the line height. Default 1.7.
|
||||||
|
* $formatting\['paragraph-spacing'] (float) – Start value of the paragraph spacing. Default 1.5.
|
||||||
|
* $formatting\['indent'] (boolean) – Whether the text has an indent. Default true.
|
||||||
|
* $formatting\['justify'] (boolean) – Whether the text is justified. Default false.
|
||||||
|
* $formatting\['show-chapter-notes'] (boolean) – Whether chapter notes are shown. Default true.
|
||||||
|
* $formatting\['show-paragraph-tools'] (boolean) – Whether the paragraph tools can be toggled. Default true.
|
||||||
|
* $formatting\['show-comments'] (boolean) – Whether the comment section is shown. Default true.
|
||||||
|
* $formatting\['show-sensitive-content'] (boolean) – Whether sensitive content is shown. Default true.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### `apply_filters( 'fictioneer_filter_chapter_identity', $output, $args )`
|
### `apply_filters( 'fictioneer_filter_chapter_identity', $output, $args )`
|
||||||
Filters the intermediate output array in the `_chapter_-header.php` partial before it is imploded and rendered. Contains the HTML for the story link, chapter title (safe), and author meta nodes (see `fictioneer_get_chapter_author_nodes()`). Any of these items may be missing depending on the chapter’s configuration.
|
Filters the intermediate output array in the `_chapter_-header.php` partial before it is imploded and rendered. Contains the HTML for the story link, chapter title (safe), and author meta nodes (see `fictioneer_get_chapter_author_nodes()`). Any of these items may be missing depending on the chapter’s configuration.
|
||||||
|
|
||||||
|
@ -362,6 +362,29 @@ function fictioneer_root_attributes() {
|
|||||||
$output['data-font-weight'] = 'default';
|
$output['data-font-weight'] = 'default';
|
||||||
$output['data-primary-font'] = FICTIONEER_PRIMARY_FONT_CSS;
|
$output['data-primary-font'] = FICTIONEER_PRIMARY_FONT_CSS;
|
||||||
|
|
||||||
|
if ( get_post_type( $post ) === 'fcn_chapter' ) {
|
||||||
|
// Also set on the frontend, this is only for customization.
|
||||||
|
$formatting = array(
|
||||||
|
// 'font-saturation' => 0,
|
||||||
|
// 'font-size' => 100,
|
||||||
|
// 'letter-spacing' => 0,
|
||||||
|
// 'line-height' => 1.7,
|
||||||
|
// 'paragraph-spacing' => 1.5,
|
||||||
|
// 'indent' => false,
|
||||||
|
// 'show-sensitive-content' => true,
|
||||||
|
// 'show-chapter-notes' => true,
|
||||||
|
// 'justify' => false,
|
||||||
|
// 'show-comments' => true,
|
||||||
|
// 'show-paragraph-tools' => true
|
||||||
|
);
|
||||||
|
|
||||||
|
$formatting = apply_filters( 'fictioneer_filter_chapter_default_formatting', $formatting );
|
||||||
|
|
||||||
|
if ( ! empty( $formatting ) ) {
|
||||||
|
$output['data-default-formatting'] = json_encode( $formatting );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$conditions = array(
|
$conditions = array(
|
||||||
'data-age-confirmation' => get_option( 'fictioneer_enable_site_age_confirmation' ),
|
'data-age-confirmation' => get_option( 'fictioneer_enable_site_age_confirmation' ),
|
||||||
'data-caching-active' => fictioneer_caching_active( 'root_attribute' ),
|
'data-caching-active' => fictioneer_caching_active( 'root_attribute' ),
|
||||||
|
2
js/chapter.min.js
vendored
2
js/chapter.min.js
vendored
File diff suppressed because one or more lines are too long
@ -337,21 +337,24 @@ function fcn_getFormatting() {
|
|||||||
|
|
||||||
function fcn_defaultFormatting() {
|
function fcn_defaultFormatting() {
|
||||||
return {
|
return {
|
||||||
'font-saturation': 0,
|
...{
|
||||||
'font-color': fictioneer_font_colors[0].css, // Set with wp_localize_script()
|
'font-saturation': 0,
|
||||||
'font-name': fictioneer_fonts[0].css, // Set with wp_localize_script()
|
'font-color': fictioneer_font_colors[0].css, // Set with wp_localize_script()
|
||||||
'font-size': 100,
|
'font-name': fictioneer_fonts[0].css, // Set with wp_localize_script()
|
||||||
'letter-spacing': 0.0,
|
'font-size': 100,
|
||||||
'line-height': 1.7,
|
'letter-spacing': 0.0,
|
||||||
'paragraph-spacing': 1.5,
|
'line-height': 1.7,
|
||||||
'site-width': fcn_theRoot.dataset.siteWidthDefault ?? '960',
|
'paragraph-spacing': 1.5,
|
||||||
'indent': true,
|
'site-width': fcn_theRoot.dataset.siteWidthDefault ?? '960',
|
||||||
'show-sensitive-content': true,
|
'indent': true,
|
||||||
'show-chapter-notes': true,
|
'show-sensitive-content': true,
|
||||||
'justify': false,
|
'show-chapter-notes': true,
|
||||||
'show-comments': true,
|
'justify': false,
|
||||||
'show-paragraph-tools': true,
|
'show-comments': true,
|
||||||
'timestamp': 1664797604825 // Used to force resets on script updates
|
'show-paragraph-tools': true,
|
||||||
|
'timestamp': 1664797604825 // Used to force resets on script updates
|
||||||
|
},
|
||||||
|
...JSON.parse(fcn_theRoot.dataset.defaultFormatting ?? '{}')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user