Merge branch 'main' into pr/60

This commit is contained in:
Tetrakern 2024-10-14 19:02:27 +02:00
commit 9328f155b3
19 changed files with 753 additions and 517 deletions

View File

@ -828,37 +828,81 @@ Fires after opening the `.main-navigation__wrapper` container in the `_navigatio
---
### `do_action( 'fictioneer_post_after_content', $post_id )`
Fires between the article content and featured list (if any) in the `single-post.php` template.
### `do_action( 'fictioneer_post_after_content', $post_id, $args )`
Fires right after the article content in the `_post.php` partial and `single-post.php` template. Mind the render context, which can be `'loop'`, `'shortcode_fictioneer_blog'`, or `'single-post'`.
**Parameters:**
* $post_id (int) Current post ID.
**$args:**
* `context` (string) Render context of the partial.
* `nested` (boolean|null) Optional. Whether the post is nested inside another query.
**Hooked Actions:**
* `fictioneer_post_tags( $post_id )` Tags of the post. Priority 10.
* `fictioneer_post_featured_list( $post_id )` Items featured in the post. Priority 20.
* `fictioneer_post_tags( $post_id, $args )` Tags of the post. Priority 10.
* `fictioneer_post_featured_list( $post_id, $args )` Items featured in the post. Priority 20.
---
### `do_action( 'fictioneer_post_footer_left', $post_id )`
Fires inside the `.post__footer-left` container within the article footer in the `single-post.php` template. Normally includes the sharing modal toggle and feed links.
### `do_action( 'fictioneer_post_article_open', $post_id, $args )`
Fires right after the post article is opened in the `_post.php` partial and `single-post.php` template, before anything else is rendered. Mind the render context, which can be `'loop'`, `'shortcode_fictioneer_blog'`, or `'single-post'`.
**Parameters:**
* $post_id (int) Current post ID.
**Parameter:**
* $post_id (int) The ID of the post.
**Hooked Actions:**
* `fictioneer_post_media_buttons()` Buttons for sharing and webfeeds. Priority 10.
**$args:**
* `context` (string) Render context of the partial.
* `nested` (boolean|null) Optional. Whether the post is nested inside another query.
**Example:**
```php
function child_add_landscape_post_image( $post_id, $args ) {
if ( ( $args['context'] ?? 0 ) !== 'loop' ) {
return;
}
fictioneer_render_thumbnail(
array(
'post_id' => $post_id,
'title' => fictioneer_get_safe_title( $post_id ),
'classes' => 'post-landscape-image',
'lightbox' => 0,
'vertical' => 1
)
);
}
add_action( 'fictioneer_post_article_open', 'child_add_landscape_post_image', 10, 2 );
```
---
### `do_action( 'fictioneer_post_footer_right', $post_id )`
Fires inside the `.post__footer-right` container within the article footer in the `single-post.php` template. Normally includes the subscribe button with popup menu.
### `do_action( 'fictioneer_post_footer_left', $post_id, $args )`
Fires inside the `.post__footer-left` container within the article footer in the `_post.php` partial and `single-post.php` template. Mind the render context, which can be `'loop'`, `'shortcode_fictioneer_blog'`, or `'single-post'`.
**Parameters:**
* $post_id (int) Current post ID.
**$args:**
* `context` (string) Render context of the partial.
* `nested` (boolean|null) Optional. Whether the post is nested inside another query.
**Hooked Actions:**
* `fictioneer_post_subscribe_button()` Subscription popup menu. Priority 10.
* `fictioneer_post_media_buttons( $post_id, $args )` Buttons for sharing and webfeeds. Priority 10.
---
### `do_action( 'fictioneer_post_footer_right', $post_id, $args )`
Fires inside the `.post__footer-right` container within the article footer in the `_post.php` partial and `single-post.php` template. Mind the render context, which can be `'loop'`, `'shortcode_fictioneer_blog'`, or `'single-post'`.
**Parameters:**
* $post_id (int) Current post ID.
**$args:**
* `context` (string) Render context of the partial.
* `nested` (boolean|null) Optional. Whether the post is nested inside another query.
**Hooked Actions:**
* `fictioneer_post_subscribe_button( $post_id, $args )` Subscription popup menu. Priority 10.
---

View File

@ -665,3 +665,64 @@ Custom CSS:
gap: 6px;
}
```
## Add landscape image to blog post index
The blog post index is a rather plain affair by design, but maybe you want to liven it up. You can change the title and meta row via filter or add completely new elements via actions, such as a landscape image on top. Keep in mind that you need to ensure a fitting image is always available.
**References**
* Action: [fictioneer_post_article_open](ACTIONS.md#do_action-fictioneer_post_article_open-post_id-args-)
* Partial: [_post.php](https://github.com/Tetrakern/fictioneer/blob/main/partials/_post.php)
* Template: [single-post.php](https://github.com/Tetrakern/fictioneer/blob/main/single-post.php)
```php
/**
* Adds landscape thumbnail to blog posts on the index page
*
* @since x.x.x
*
* @param int $post_id The post ID.
* @param array $args Additional arguments.
*/
function child_add_landscape_post_image( $post_id, $args ) {
// Check render context
if ( ( $args['context'] ?? 0 ) !== 'loop' ) {
return;
}
// Output thumbnail
fictioneer_render_thumbnail(
array(
'post_id' => $post_id,
'title' => fictioneer_get_safe_title( $post_id ),
'classes' => 'post-landscape-image',
'lightbox' => 0,
'vertical' => 1
)
);
}
add_action( 'fictioneer_post_article_open', 'child_add_landscape_post_image', 10, 2 );
```
Custom CSS:
```css
.post-landscape-image {
display: block;
margin-bottom: 0.75rem;
}
.post-landscape-image img {
border-radius: var(--layout-border-radius-small);
height: 8rem;
width: 100%;
object-fit: cover;
}
/* If you want to remove the horizontal line: */
.blog-posts .post:not(:first-child) {
border-top: 0;
padding-top: 0;
}
```

View File

@ -476,6 +476,47 @@ Filters the intermediate output array of the chapter support links in the `ficti
---
### `apply_filters( 'fictioneer_filter_enable_chapter_list_transients', $bool, $post_id )`
Filters the boolean return value of the `fictioneer_enable_chapter_list_transients()` function. By default, this depends on the `fictioneer_caching_active()` function returning false and the `fictioneer_disable_chapter_list_transients` option being off.
**Parameter:**
* $bool (boolean) Whether the Transients are enabled or not.
* $post_id (int) Post ID of the story.
---
### `apply_filters( 'fictioneer_filter_enable_menu_transients', $bool, $location )`
Filters the boolean return value of the `fictioneer_enable_chapter_list_transients()` function. By default, this depends on the `fictioneer_caching_active()` function returning false and the `fictioneer_disable_chapter_list_transients` option being off. Possible locations are 'nav_menu', 'mobile_nav_menu', and 'footer_menu'.
**Parameter:**
* $bool (boolean) Whether the Transients are enabled or not.
* $location (string) Location identifier of the menu.
---
### `apply_filters( 'fictioneer_filter_enable_shortcode_transients', $bool, $shortcode )`
Filters the boolean return value of the `fictioneer_enable_shortcode_transients()` function. By default, this depends on the `FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION` constant being greater than -1 and the `fictioneer_disable_shortcode_transients` option being off. This can conflict with external object caches.
**Parameter:**
* $bool (boolean) Whether the Transients are enabled or not.
* $shortcode (string|null) The shortcode in question for reference.
**Example:**
```php
function child_enable_shortcode_transients_for_frontpage( $bool ) {
// Specifically turn on Transients on the frontpage (if not cached in ANY way),
// ignoring the setting option.
if ( is_front_page() ) {
return true;
}
return $bool;
}
add_filter( 'fictioneer_filter_enable_shortcode_transients', 'child_enable_shortcode_transients_for_frontpage' );
```
---
### `apply_filters( 'fictioneer_filter_get_support_links', $links, $post_id, $parent_id, $author_id )`
Filters the array of support links returned for the current post (or post ID if provided). First it checks the post meta, then the parent post meta (if any), and finally the author meta if still empty. The first non-empty value is added to the array.
@ -1103,6 +1144,19 @@ Filters the intermediate output array in the `_card-post.php` partial before it
---
### `apply_filters( 'fictioneer_filter_post_header_items', $output, $post_id, $args )`
Filters the intermediate output array of header items in the `_post.php` partial and `single-post.php` template before it is imploded and rendered. Mind the render context, which can be `'loop'`, `'shortcode_fictioneer_blog'`, or `'single-post'`.
**$output:**
* `title` (string) The post title.
* `meta` (string) The post meta row.
**$args:**
* `context` (string) Render context of the partial.
* `nested` (boolean|null) Optional. Whether the post is nested inside another query.
---
### `apply_filters( 'fictioneer_filter_post_meta_items', $output, $args )`
Filters the intermediate output array of the `fictioneer_get_post_meta_items()` function before it is imploded and returned.
@ -1681,14 +1735,6 @@ Filters the WP_Query arguments in the `fictioneer_showcase` shortcode. The optio
---
### `apply_filters( 'fictioneer_filter_enable_shortcode_transients', $bool )`
Filters the boolean return value of the `fictioneer_enable_shortcode_transients()` function. By default, this depends on the `FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION` constant being greater than -1. Because the Transients would interfere with caching. If you exclude a page from caching, it might make sense to turn them on for that page.
**Parameter:**
* $bool (boolean) Whether the Transients are enabled or not by default.
---
### `apply_filters( 'fictioneer_filter_sitemap_page_template_excludes', $excludes )`
Filters the exclusion array of page templates for the custom theme sitemap. By default, these are `'user-profile.php'`, `'singular-bookmarks.php'`, `'singular-bookshelf.php'`, and `'singular-bookshelf-ajax.php'`.

View File

@ -47,15 +47,17 @@ Since 5.20.0, the theme is compatible with the [Elementor](https://elementor.com
## Commissions
I do take commissions for customizations and new features, *within reason.* Just write me on Discord, and we can figure out what is feasible. However, keep in mind that any feature you pay for may be added to the theme for everyone to enjoy. Several features have already been sponsored this way. Sharing is caring.<sup>*</sup>
I do take commissions for customizations and new features, *within reason.* Just write me on Discord, and we can figure out what is feasible. However, keep in mind that any feature you pay for may be added to the theme for everyone to enjoy (exclusivity is generally more expensive). Several features have already been sponsored this way. Sharing is caring.<sup>*</sup>
<sup>* As long as that makes sense and is not detrimental.</sup>
## Support the Development
Fictioneer has mostly been developed by one author, barring [credited](CREDITS.md) code snippets. This was an exhausting effort and is not sustainable, so any help going forward is appreciated. If you are interested, or want to fork your own version, take a look at the [development](DEVELOPMENT.md) guidelines, [action](ACTIONS.md) hooks, and [filter](FILTERS.md) hooks. A theme-related base plugin can be found [here](https://github.com/Tetrakern/fictioneer-base-plugin). You can also join the [Discord](https://discord.gg/tVfDB7EbaP).
Fictioneer has been developed by mostly one author, barring [credited](CREDITS.md) code snippets. Since version 5.24.0, several developers have contributed and any help going forward is appreciated. If you are interested, or want to fork your own version, take a look at the [development](DEVELOPMENT.md) guidelines, [action](ACTIONS.md) hooks, and [filter](FILTERS.md) hooks. A theme-related base plugin can be found [here](https://github.com/Tetrakern/fictioneer-base-plugin). You can also join the [Discord](https://discord.gg/tVfDB7EbaP).
**Translations:** Brazilian Portuguese by [@c-cesar](https://github.com/c-cesar)
<a href="https://github.com/Tetrakern/fictioneer/graphs/contributors">
<img src="https://contrib.rocks/image?repo=Tetrakern/fictioneer" />
</a>
## Screenshots

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,9 +5,9 @@
// =============================================================================
// Version
define( 'FICTIONEER_VERSION', '5.25.0-beta4' );
define( 'FICTIONEER_VERSION', '5.25.0-beta5' );
define( 'FICTIONEER_MAJOR_VERSION', '5' );
define( 'FICTIONEER_RELEASE_TAG', 'v5.25.0-beta4' );
define( 'FICTIONEER_RELEASE_TAG', 'v5.25.0-beta5' );
if ( ! defined( 'CHILD_VERSION' ) ) {
define( 'CHILD_VERSION', null );

View File

@ -238,6 +238,7 @@ if ( ! function_exists( 'fictioneer_get_icon' ) ) {
*
* @since 4.7.0
* @since 5.9.4 - Removed output buffer.
* @since 5.25.0 - Use cache bust string instead of version.
*
* @param string $icon Name of the icon that matches the svg.
* @param string $classes Optional. String of CSS classes.
@ -248,7 +249,7 @@ if ( ! function_exists( 'fictioneer_get_icon' ) ) {
*/
function fictioneer_get_icon( $icon, $classes = '', $id = '', $inserts = '' ) {
return '<svg id="' . $id . '" ' . $inserts . ' class="icon _' . $icon . ' ' . $classes . '">' . '<use xlink:href="' . esc_url( home_url( '/wp-content/themes/fictioneer/img/icon-sprite.svg?ver=' . FICTIONEER_VERSION . '#icon-' . $icon ) ) . '"></use></svg>';
return '<svg id="' . $id . '" ' . $inserts . ' class="icon _' . $icon . ' ' . $classes . '">' . '<use xlink:href="' . esc_url( home_url( '/wp-content/themes/fictioneer/img/icon-sprite.svg?ver=' . fictioneer_get_cache_bust() . '#icon-' . $icon ) ) . '"></use></svg>';
}
}

View File

@ -194,7 +194,7 @@ function fictioneer_enable_menu_transients( $location ) {
}
return apply_filters(
'fictioneer_enable_menu_transients',
'fictioneer_filter_enable_menu_transients',
! get_option( 'fictioneer_disable_menu_transients' ),
$location
);

View File

@ -1643,7 +1643,7 @@ function fictioneer_shortcode_blog( $attr ) {
<?php
while ( $blog_query->have_posts() ) {
$blog_query->the_post();
get_template_part( 'partials/_post', null, array( 'nested' => true ) );
get_template_part( 'partials/_post', null, array( 'nested' => true, 'context' => 'shortcode_fictioneer_blog' ) );
}
wp_reset_postdata();

View File

@ -8,11 +8,18 @@
* Outputs the HTML for the post tags
*
* @since 5.0.0
* @since 5.25.0 - Added $args.
*
* @param int $post_id The post ID.
* @param int $post_id The post ID.
* @param array $args Additional arguments.
*/
function fictioneer_post_tags( $post_id ) {
function fictioneer_post_tags( $post_id, $args ) {
// Check render context
if ( ( $args['context'] ?? 0 ) !== 'single-post' ) {
return;
}
// Setup
$tags = get_the_tags( $post_id );
@ -27,7 +34,7 @@ function fictioneer_post_tags( $post_id ) {
</section>
<?php // <--- End HTML
}
add_action( 'fictioneer_post_after_content', 'fictioneer_post_tags', 10 );
add_action( 'fictioneer_post_after_content', 'fictioneer_post_tags', 10, 2 );
// =============================================================================
// FEATURED
@ -37,11 +44,18 @@ add_action( 'fictioneer_post_after_content', 'fictioneer_post_tags', 10 );
* Outputs the HTML for featured items in the post
*
* @since 5.0.0
* @since 5.25.0 - Added $args.
*
* @param int $post_id The post ID.
* @param int $post_id The post ID.
* @param array $args Additional arguments.
*/
function fictioneer_post_featured_list( $post_id ) {
function fictioneer_post_featured_list( $post_id, $args ) {
// Check render context
if ( ( $args['context'] ?? 0 ) !== 'single-post' ) {
return;
}
global $post;
// Abort if...
@ -106,7 +120,7 @@ function fictioneer_post_featured_list( $post_id ) {
</section>
<?php // <--- End HTML
}
add_action( 'fictioneer_post_after_content', 'fictioneer_post_featured_list', 20 );
add_action( 'fictioneer_post_after_content', 'fictioneer_post_featured_list', 20, 2 );
// =============================================================================
// POST MEDIA BUTTONS
@ -116,18 +130,22 @@ add_action( 'fictioneer_post_after_content', 'fictioneer_post_featured_list', 20
* Outputs the HTML for the post media buttons
*
* @since 5.0.0
* @since 5.25.0 - Added parameters.
*
* @param int $post_id The post ID.
* @param array $args Additional arguments.
*/
function fictioneer_post_media_buttons() {
function fictioneer_post_media_buttons( $post_id, $args ) {
// Abort if...
if ( post_password_required() ) {
if ( post_password_required() || ( $args['context'] ?? 0 ) !== 'single-post' ) {
return;
}
// Render media buttons
echo fictioneer_get_media_buttons();
}
add_action( 'fictioneer_post_footer_left', 'fictioneer_post_media_buttons', 10 );
add_action( 'fictioneer_post_footer_left', 'fictioneer_post_media_buttons', 10, 2 );
// =============================================================================
// POST SUBSCRIBE BUTTONS
@ -137,11 +155,15 @@ add_action( 'fictioneer_post_footer_left', 'fictioneer_post_media_buttons', 10 )
* Outputs the HTML for the post subscribe button with popup menu
*
* @since 5.0.0
* @since 5.25.0 - Added parameters.
*
* @param int $post_id The post ID.
* @param array $args Additional arguments.
*/
function fictioneer_post_subscribe_button() {
function fictioneer_post_subscribe_button( $post_id, $args ) {
// Abort if...
if ( post_password_required() ) {
if ( post_password_required() || ( $args['context'] ?? 0 ) !== 'single-post' ) {
return;
}
@ -157,4 +179,4 @@ function fictioneer_post_subscribe_button() {
<?php // <--- End HTML
}
}
add_action( 'fictioneer_post_footer_right', 'fictioneer_post_subscribe_button', 10 );
add_action( 'fictioneer_post_footer_right', 'fictioneer_post_subscribe_button', 10, 2 );

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@ defined( 'ABSPATH' ) OR exit;
<?php
while ( have_posts() ) {
the_post();
get_template_part( 'partials/_post' );
get_template_part( 'partials/_post', null, array( 'context' => 'loop' ) );
}
$pag_args = array(

View File

@ -10,7 +10,8 @@
* @since 2.0
* @see partials/_loop.php
*
* @internal $args['nested'] Whether the post is nested inside another query. Default null.
* @internal $args['nested'] Whether the post is nested inside another query. Default null.
* @internal $args['context'] Render context of the partial ('loop' or 'shortcode_fictioneer_blog').
*/
@ -35,20 +36,32 @@ if (
<article id="post-<?php echo $post_id; ?>" class="post">
<?php do_action( 'fictioneer_post_article_open', $post_id, $args ); ?>
<header class="post__header">
<h2 class="post__title h1"><a href="<?php the_permalink(); ?>"><?php echo $title; ?></a></h2>
<div class="post__meta layout-links"><?php echo fictioneer_get_post_meta_items(); ?></div>
<?php
$header_items = array(
'title' => '<h2 class="post__title h1"><a href="' . get_the_permalink() . '">' . $title . '</a></h2>',
'meta' => '<div class="post__meta layout-links">' . fictioneer_get_post_meta_items() . '</div>'
);
$header_items = apply_filters( 'fictioneer_filter_post_header_items', $header_items, $post_id, $args );
echo implode( '', $header_items );
?>
</header>
<section class="post__main content-section"><?php echo $content; ?></section>
<?php if ( has_action( 'fictioneer_blog_posts_footers_left' ) || has_action( 'fictioneer_blog_posts_footers_right' ) ) : ?>
<?php do_action( 'fictioneer_post_after_content', $post_id, $args ); ?>
<?php if ( has_action( 'fictioneer_post_footer_left' ) || has_action( 'fictioneer_post_footer_right' ) ) : ?>
<footer class="post__footer">
<div class="post__footer-box post__footer-left">
<?php do_action( 'fictioneer_blog_posts_footers_left', $post_id ); ?>
<?php do_action( 'fictioneer_post_footer_left', $post_id, $args ); ?>
</div>
<div class="post__footer-box post__footer-right">
<?php do_action( 'fictioneer_blog_posts_footers_right', $post_id ); ?>
<?php do_action( 'fictioneer_post_footer_right', $post_id, $args ); ?>
</div>
</footer>
<?php endif; ?>

View File

@ -7,7 +7,7 @@ Contributors: tetrakern
Requires at least: 6.1.0
Tested up to: 6.6.2
Requires PHP: 7.4
Stable tag: 5.25.0-beta4
Stable tag: 5.25.0-beta5
License: GNU General Public License v3.0 or later
License URI: http://www.gnu.org/licenses/gpl.html

View File

@ -34,22 +34,37 @@ get_header();
<article id="post-<?php the_ID(); ?>" class="post__article">
<?php do_action( 'fictioneer_post_article_open', $post->ID, array( 'context' => 'single-post' ) ); ?>
<header class="post__header">
<h1 class="post__title"><?php echo $title; ?></h1>
<div class="post__meta layout-links"><?php echo fictioneer_get_post_meta_items(); ?></div>
<?php
$header_items = array(
'title' => '<h1 class="post__title">' . $title . '</h1>',
'meta' => '<div class="post__meta layout-links">' . fictioneer_get_post_meta_items() . '</div>'
);
$header_items = apply_filters(
'fictioneer_filter_post_header_items',
$header_items,
$post->ID,
array( 'context' => 'single-post' )
);
echo implode( '', $header_items );
?>
</header>
<section class="post__main content-section"><?php the_content(); ?></section>
<?php do_action( 'fictioneer_post_after_content', $post->ID ); ?>
<?php do_action( 'fictioneer_post_after_content', $post->ID, array( 'context' => 'single-post' ) ); ?>
<?php if ( ! $password_required && ( has_action( 'fictioneer_post_footer_left' ) || has_action( 'fictioneer_post_footer_right' ) ) ) : ?>
<footer class="post__footer">
<div class="post__footer-box post__footer-left">
<?php do_action( 'fictioneer_post_footer_left', $post->ID ); ?>
<?php do_action( 'fictioneer_post_footer_left', $post->ID, array( 'context' => 'single-post' ) ); ?>
</div>
<div class="post__footer-box post__footer-right">
<?php do_action( 'fictioneer_post_footer_right', $post->ID ); ?>
<?php do_action( 'fictioneer_post_footer_right', $post->ID, array( 'context' => 'single-post' ) ); ?>
</div>
</footer>
<?php endif; ?>

View File

@ -1,16 +1,9 @@
:is(.blog-posts, .latest-posts) {
.post {
padding-bottom: 1rem;
&:not(:last-child) {
padding-bottom: var(--layout-spacing-vertical);
}
&:not(:first-child) {
.post__header {
border-top: var(--layout-hr-border);
padding-top: var(--layout-spacing-vertical);
}
border-top: var(--layout-hr-border);
padding-top: var(--layout-spacing-vertical);
margin-top: var(--layout-spacing-vertical);
}
}
}

View File

@ -111,11 +111,11 @@ a.modal-tooltip {
:where(h1, h2, h3, h4, h5, h6) {
&:where(:not(:first-child, .cell-title, .card__title, .post__title)) {
margin-top: 2rem;
margin-top: max(2.25rem, var(--paragraph-spacing) - 0.5rem);
}
&:where(:not(:last-child, .cell-title, .card__title, .post__title)) {
margin-bottom: var(--heading-margin-bottom, unquote('max(1.25rem, var(--paragraph-spacing) - 0.25rem)'));
margin-bottom: var(--heading-margin-bottom, min(max(1.25rem, var(--paragraph-spacing) - 0.75rem), 2rem));
}
}
@ -374,7 +374,7 @@ a.modal-tooltip {
font-size: get_relative_clamp(0.75, 0.875, 320, 480, 'vw', 'em');
font-weight: 400;
text-align: center;
margin: unquote("max(1.5rem, var(--paragraph-spacing) * 2)") auto;
margin: max(1.5rem, var(--paragraph-spacing) * 2) auto;
max-width: 35em; // Scale with font size
filter: var(--litrpg-drop-shadow);

View File

@ -11,7 +11,7 @@ License URI: http://www.gnu.org/licenses/gpl.html
Requires at least: 6.1.0
Tested up to: 6.6.2
Requires PHP: 7.4
Version: 5.25.0-beta4
Version: 5.25.0-beta5
Text Domain: fictioneer
Description: Standalone solution for publishing and reading web fictions.