Rename files for clarity, move some functions

Bringing order to the mess, one commit at a time.
This commit is contained in:
Tetrakern 2024-04-13 16:54:33 +02:00
parent 91da5a6c8a
commit 5df5bc696f
30 changed files with 389 additions and 466 deletions

View File

@ -883,7 +883,7 @@ Fires right after the search form has been rendered.
---
### `do_action( 'fictioneer_search_form_filters', $args )`
Fires after the search form fields for type, match, sort, and order have been rendered. This allows you to render additional fields. Note that any additional fields must also be manually added to the query, see `_search.php` partial.
Fires after the search form fields for type, match, sort, and order have been rendered. This allows you to render additional fields. Note that any additional fields must also be manually added to the query, see `_module-search.php` partial.
**Parameters:**
* $args (array) Arguments passed to the search form.

View File

@ -16,7 +16,7 @@ The assumption here is that you want the normal title to be short, like "WTF 1",
* Filter: [fictioneer_filter_chapter_identity](https://github.com/Tetrakern/fictioneer/blob/main/FILTERS.md#apply_filters-fictioneer_filter_chapter_identity-output-args-)
* Filter: [fictioneer_filter_safe_title](https://github.com/Tetrakern/fictioneer/blob/main/FILTERS.md#apply_filters-fictioneer_filter_safe_title-title-post_id-context-args-)
* Include: [_story_hooks.php](https://github.com/Tetrakern/fictioneer/blob/main/includes/functions/hooks/_story_hooks.php)
* Include: [_shortcodes.php](https://github.com/Tetrakern/fictioneer/blob/main/includes/functions/_shortcodes.php)
* Include: [_setup-shortcodes.php](https://github.com/Tetrakern/fictioneer/blob/main/includes/functions/_setup-shortcodes.php)
* Partial: [_chapter-header.php](https://github.com/Tetrakern/fictioneer/blob/main/partials/_chapter-header.php)
```php
@ -105,12 +105,12 @@ add_filter( 'fictioneer_filter_safe_title', 'child_modify_chapter_list_title', 1
## Only show a specific advanced meta field
Maybe you want only one specific advanced meta field. You can achieve this by manually adding the desired field and saving procedure, similar to how it is done in the [_meta_fields.php](https://github.com/Tetrakern/fictioneer/blob/main/includes/functions/_meta_fields.php). The following example adds the Co-Authors field to stories, which can be adapted for chapters as well. Just make sure to change the {dynamic_parts} and the meta keys.
Maybe you want only one specific advanced meta field. You can achieve this by manually adding the desired field and saving procedure, similar to how it is done in the [_setup-meta-fields.php](https://github.com/Tetrakern/fictioneer/blob/main/includes/functions/_setup-meta-fields.php). The following example adds the Co-Authors field to stories, which can be adapted for chapters as well. Just make sure to change the {dynamic_parts} and the meta keys.
**References**
* Filter: [fictioneer_filter_metabox_{meta_box}](https://github.com/Tetrakern/fictioneer/blob/main/FILTERS.md#apply_filters-fictioneer_filter_metabox_meta_box-output-post-)
* Filter: [fictioneer_filter_metabox_updates_{type}](https://github.com/Tetrakern/fictioneer/blob/main/FILTERS.md#apply_filters-fictioneer_filter_metabox_updates_type-fields-post_id-)
* Include: [_meta_fields.php](https://github.com/Tetrakern/fictioneer/blob/main/includes/functions/_meta_fields.php)
* Include: [_setup-meta-fields.php](https://github.com/Tetrakern/fictioneer/blob/main/includes/functions/_setup-meta-fields.php)
```php
/**
@ -210,7 +210,7 @@ The formatting of chapters is left to the visitor. Because customizing the forma
**References**
* Filter: [fictioneer_filter_chapter_default_formatting](FILTERS.md#apply_filters-fictioneer_filter_chapter_default_formatting-formatting-)
* Include: [_theme_setup.php](https://github.com/Tetrakern/fictioneer/blob/main/includes/functions/_theme_setup.php)
* Include: [_setup-theme.php](https://github.com/Tetrakern/fictioneer/blob/main/includes/functions/_setup-theme.php)
```php
/**

View File

@ -325,7 +325,7 @@ Fictioneer is cache aware. This means the theme provides an interface to aid cac
*"There are only two hard things in Computer Science: cache invalidation and naming things" — Phil Karlton.*
### References
* See [_caching_and_transients.php](includes/functions/_caching_and_transients.php)
* See [_service-caching.php](includes/functions/_service-caching.php)
* [Cache Purge All Hook](ACTIONS.md#do_action-fictioneer_cache_purge_all-): `fictioneer_cache_purge_all`
* [Cache Purge Post Hook](ACTIONS.md#do_action-fictioneer_cache_purge_post-post_id-): `fictioneer_cache_purge_post`

View File

@ -553,7 +553,7 @@ Filters the intermediate output array in the `fictioneer_get_list_chapter_meta_r
---
### `apply_filters( 'fictioneer_filter_metabox_{meta_box}', $output, $post )`
Filters the intermediate output array for meta box fields before it is imploded and rendered, see `_meta_fields.php`. The dynamic part of the hook can be `story_meta`, `story_data`, `story_epub`, `chapter_meta`, `chapter_data`, `advanced`, `support_links`, `post_data`, `collection_data`, and `recommendation_data`.
Filters the intermediate output array for meta box fields before it is imploded and rendered, see `_setup-meta-fields.php`. The dynamic part of the hook can be `story_meta`, `story_data`, `story_epub`, `chapter_meta`, `chapter_data`, `advanced`, `support_links`, `post_data`, `collection_data`, and `recommendation_data`.
**Parameters:**
* $output (array) Captured HTML of meta fields to be rendered.
@ -562,7 +562,7 @@ Filters the intermediate output array for meta box fields before it is imploded
---
### `apply_filters( 'fictioneer_filter_metabox_updates_{type}', $fields, $post_id )`
Filters the sanitized POST meta box fields before they are saved, see `_meta_fields.php`. The dynamic part of the hook can be `story`, `chapter`, `advanced`, `support_links`, `post`, `collection`, and `recommendation`.
Filters the sanitized POST meta box fields before they are saved, see `_setup-meta-fields.php`. The dynamic part of the hook can be `story`, `chapter`, `advanced`, `support_links`, `post`, `collection`, and `recommendation`.
**Parameters:**
* $fields (array) Meta fields to be saved.

View File

@ -416,7 +416,7 @@ if ( ! defined( 'FICTIONEER_EXAMPLE_CHAPTER_ICONS' ) ) {
// cannot use any actions and filters not loaded at this point.
// =============================================================================
require_once __DIR__ . '/includes/functions/_fast_requests.php';
require_once __DIR__ . '/includes/functions/_fast-requests.php';
// =============================================================================
// GLOBAL
@ -432,13 +432,13 @@ require_once __DIR__ . '/includes/functions/_utility.php';
* Modify WordPress functions via hooks.
*/
require_once __DIR__ . '/includes/functions/_wordpress_mods.php';
require_once __DIR__ . '/includes/functions/_setup-wordpress.php';
/**
* Actions whenever a post is created or updated.
*/
require_once __DIR__ . '/includes/functions/_post_updates.php';
require_once __DIR__ . '/includes/functions/_service-posts.php';
/**
* Set up the theme customizer.
@ -454,57 +454,57 @@ if ( is_customize_preview() ) {
* Set up the theme.
*/
require_once __DIR__ . '/includes/functions/_theme_setup.php';
require_once __DIR__ . '/includes/functions/_setup-theme.php';
/**
* Add custom post types.
*/
require_once __DIR__ . '/includes/functions/_cpt_and_taxonomies.php';
require_once __DIR__ . '/includes/functions/_setup-types-and-terms.php';
/**
* Caches and Transients.
* Cache plugins and Transients.
*/
require_once __DIR__ . '/includes/functions/_caching_and_transients.php';
require_once __DIR__ . '/includes/functions/_service-caching.php';
/**
* Add custom shortcodes.
*/
require_once __DIR__ . '/includes/functions/_shortcodes.php';
require_once __DIR__ . '/includes/functions/_setup-shortcodes.php';
/**
* Generate sitemap.
*/
require_once __DIR__ . '/includes/functions/_sitemap.php';
require_once __DIR__ . '/includes/functions/_module-sitemap.php';
/**
* Add SEO features to the site.
*/
require_once __DIR__ . '/includes/functions/_seo.php';
require_once __DIR__ . '/includes/functions/_module-seo.php';
/**
* Communicate with the Discord API.
*/
require_once __DIR__ . '/includes/functions/_discord.php';
require_once __DIR__ . '/includes/functions/_module-discord.php';
/**
* Generate ePUBs for stories.
*/
if ( get_option( 'fictioneer_enable_epubs' ) ) {
require_once __DIR__ . '/includes/functions/_epub.php';
require_once __DIR__ . '/includes/functions/_module-epub.php';
}
/**
* Log-in and register subscribers via OAuth 2.0.
*/
require_once __DIR__ . '/includes/functions/_oauth.php';
require_once __DIR__ . '/includes/functions/_module-oauth.php';
/**
* Handle comments.
@ -583,25 +583,25 @@ if ( get_option( 'fictioneer_enable_bookmarks' ) && is_admin() ) {
* Add content helper functions.
*/
require_once __DIR__ . '/includes/functions/_content_helpers.php';
require_once __DIR__ . '/includes/functions/_helpers-templates.php';
/**
* Add content query functions.
*/
require_once __DIR__ . '/includes/functions/_query_helpers.php';
require_once __DIR__ . '/includes/functions/_helpers-query.php';
/**
* Add role functions.
*/
require_once __DIR__ . '/includes/functions/_roles.php';
require_once __DIR__ . '/includes/functions/_setup-roles.php';
/**
* Add forms.
*/
require_once __DIR__ . '/includes/functions/_forms.php';
require_once __DIR__ . '/includes/functions/_module-forms.php';
/**
* Add API.
@ -615,14 +615,14 @@ if ( get_option( 'fictioneer_enable_storygraph_api' ) ) {
* Add search.
*/
require_once __DIR__ . '/includes/functions/_search.php';
require_once __DIR__ . '/includes/functions/_module-search.php';
/**
* Generate SEO schema graphs.
*/
if ( get_option( 'fictioneer_enable_seo' ) && ! fictioneer_seo_plugin_active() ) {
require_once __DIR__ . '/includes/functions/_schemas.php';
require_once __DIR__ . '/includes/functions/_module-schemas.php';
}
// =============================================================================
@ -635,7 +635,7 @@ if ( is_admin() ) {
* Functions only required in the admin panel.
*/
require_once __DIR__ . '/includes/functions/_admin.php';
require_once __DIR__ . '/includes/functions/_setup-admin.php';
}

View File

@ -464,5 +464,3 @@ if ( ! function_exists( 'fictioneer_api_request_stories' ) ) {
return rest_ensure_response( $graph );
}
}
?>

View File

@ -1,58 +0,0 @@
<?php
// =============================================================================
// THEME DEACTIVATION
// =============================================================================
/**
* Clean up when the theme is deactivated
*
* Always deletes all theme-related Transients in the database. If the option to
* delete all settings and theme mods is activated, these will be removed as
* well but otherwise preserved.
*
* @since 4.7.0
* @since 5.7.4 - Updated to use SQL queries.
* @since 5.10.0 - Updated for font manager.
* @since 5.11.0 - Updated for all cached files.
*
* @global wpdb $wpdb WordPress database object.
*/
function fictioneer_theme_deactivation() {
global $wpdb;
// Delete all theme Transients
fictioneer_delete_transients_like( 'fictioneer_' );
// Delete cached files
$cache_dir = WP_CONTENT_DIR . '/themes/fictioneer/cache/';
$files = glob( $cache_dir . '*' );
foreach ( $files as $file ) {
if ( is_file( $file ) ) {
unlink( $file );
}
}
// Only continue if the user wants to delete all options/mods
if ( get_option( 'fictioneer_delete_theme_options_on_deactivation', false ) ) {
// Remove theme mods
remove_theme_mods();
// SQL to delete all options starting with "fictioneer_"
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'fictioneer_%'" );
// SQL to delete all user meta starting with "fictioneer_"
$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'fictioneer_%'" );
// SQL to delete all comment meta starting with "fictioneer_"
$wpdb->query("DELETE FROM {$wpdb->commentmeta} WHERE meta_key LIKE 'fictioneer_%'");
// Reset user roles
remove_role( 'fcn_moderator' );
}
}
add_action( 'switch_theme', 'fictioneer_theme_deactivation' );
?>

View File

@ -2552,5 +2552,3 @@ function fictioneer_add_customizers( $manager ) {
);
}
add_action( 'customize_register', 'fictioneer_add_customizers', 20 );
?>

View File

@ -1118,5 +1118,3 @@ if ( ! function_exists( 'fictioneer_get_fading_gradient' ) ) {
return $gradient;
}
}
?>

View File

@ -65,22 +65,22 @@ function fictioneer_do_fast_ajax() {
// Include required files
require_once __DIR__ . '/_utility.php';
require_once __DIR__ . '/_query_helpers.php';
require_once __DIR__ . '/_caching_and_transients.php';
require_once __DIR__ . '/_cpt_and_taxonomies.php';
require_once __DIR__ . '/_helpers-query.php';
require_once __DIR__ . '/_service-caching.php';
require_once __DIR__ . '/_setup-types-and-terms.php';
if ( get_option( 'fictioneer_enable_follows' ) && strpos( $action, '_follow' ) !== false ) {
require_once __DIR__ . '/_content_helpers.php';
require_once __DIR__ . '/_helpers-templates.php';
require_once __DIR__ . '/users/_follows.php';
}
if ( get_option( 'fictioneer_enable_reminders' ) && strpos( $action, '_reminder' ) !== false ) {
require_once __DIR__ . '/_content_helpers.php';
require_once __DIR__ . '/_helpers-templates.php';
require_once __DIR__ . '/users/_reminders.php';
}
if ( get_option( 'fictioneer_enable_checkmarks' ) && strpos( $action, '_checkmark' ) !== false ) {
require_once __DIR__ . '/_content_helpers.php';
require_once __DIR__ . '/_helpers-templates.php';
require_once __DIR__ . '/users/_checkmarks.php';
}
@ -94,11 +94,11 @@ function fictioneer_do_fast_ajax() {
require_once __DIR__ . '/users/_reminders.php';
require_once __DIR__ . '/users/_checkmarks.php';
require_once __DIR__ . '/users/_bookmarks.php';
require_once __DIR__ . '/_content_helpers.php';
require_once __DIR__ . '/_helpers-templates.php';
}
if ( strpos( $action, '_list' ) !== false ) {
require_once __DIR__ . '/_wordpress_mods.php';
require_once __DIR__ . '/_setup-wordpress.php';
}
if ( strpos( $action, '_fingerprint' ) !== false ) {
@ -127,12 +127,12 @@ function fictioneer_do_fast_ajax() {
}
if ( $action === 'fictioneer_ajax_query_relationship_posts' ) {
require_once __DIR__ . '/_content_helpers.php';
require_once __DIR__ . '/_admin.php';
require_once __DIR__ . '/_helpers-templates.php';
require_once __DIR__ . '/_setup-admin.php';
}
if ( $action === 'fictioneer_ajax_fcnen_search_content' ) {
require_once __DIR__ . '/_content_helpers.php';
require_once __DIR__ . '/_helpers-templates.php';
}
// Function exists?
@ -196,19 +196,19 @@ function fictioneer_do_fast_comment_ajax() {
// Include required files
require_once __DIR__ . '/_utility.php'; // Obviously
require_once __DIR__ . '/_wordpress_mods.php'; // Depends
require_once __DIR__ . '/_roles.php'; // Depends
require_once __DIR__ . '/_caching_and_transients.php'; // Maybe?
require_once __DIR__ . '/_content_helpers.php'; // Safe title
require_once __DIR__ . '/_setup-wordpress.php'; // Depends
require_once __DIR__ . '/_setup-roles.php'; // Depends
require_once __DIR__ . '/_service-caching.php'; // Maybe?
require_once __DIR__ . '/_helpers-templates.php'; // Safe title
require_once __DIR__ . '/comments/_comments_controller.php'; // Obviously
require_once __DIR__ . '/comments/_comments_moderation.php'; // Obviously
require_once __DIR__ . '/comments/_comments_ajax.php'; // Obviously
// Moderating needs less, otherwise include everything related to comments
if ( strpos( $action, '_moderate_comment' ) === false ) {
require_once __DIR__ . '/_discord.php'; // Notifications
require_once __DIR__ . '/_cpt_and_taxonomies.php'; // Depends
require_once __DIR__ . '/_oauth.php'; // Login buttons
require_once __DIR__ . '/_module-discord.php'; // Notifications
require_once __DIR__ . '/_setup-types-and-terms.php'; // Depends
require_once __DIR__ . '/_module-oauth.php'; // Login buttons
require_once __DIR__ . '/users/_user_data.php'; // Obviously
require_once __DIR__ . '/users/_avatars.php'; // Obviously
require_once __DIR__ . '/comments/_comments_form.php'; // Obviously
@ -250,8 +250,8 @@ if (
) {
// Include required files
require_once __DIR__ . '/_utility.php';
require_once __DIR__ . '/_wordpress_mods.php';
require_once __DIR__ . '/_roles.php';
require_once __DIR__ . '/_setup-wordpress.php';
require_once __DIR__ . '/_setup-roles.php';
require_once __DIR__ . '/users/_user_data.php';
require_once __DIR__ . '/users/_avatars.php';
require_once __DIR__ . '/comments/_comments_controller.php';
@ -272,5 +272,3 @@ if (
// Terminate in case something goes wrong
die();
}
?>

View File

@ -356,5 +356,3 @@ function fictioneer_allow_falsy_story_hidden( $allowed ) {
if ( get_option( 'fictioneer_disable_extended_story_list_meta_queries' ) ) {
add_filter( 'fictioneer_filter_falsy_meta_allow_list', 'fictioneer_allow_falsy_story_hidden' );
}
?>

View File

@ -1,7 +1,7 @@
<?php
// =============================================================================
// GET LONG EXCERPT
// GET EXCERPTS
// =============================================================================
if ( ! function_exists( 'fictioneer_get_excerpt' ) ) {
@ -22,23 +22,6 @@ if ( ! function_exists( 'fictioneer_get_excerpt' ) ) {
}
}
/**
* Replace excerpt ellipsis
*
* @since 5.2.5
*
* @return string The ellipsis ().
*/
function fictioneer_excerpt_ellipsis() {
return '…';
}
add_filter( 'excerpt_more', 'fictioneer_excerpt_ellipsis' );
// =============================================================================
// GET EXCERPT WITH MAXIMUM LENGTH (CHARACTERS)
// =============================================================================
if ( ! function_exists( 'fictioneer_get_limited_excerpt' ) ) {
/**
* Returns excerpt with maximum length in characters
@ -64,10 +47,6 @@ if ( ! function_exists( 'fictioneer_get_limited_excerpt' ) ) {
}
}
// =============================================================================
// GET FIRST PARAGRAPH AS EXCERPT
// =============================================================================
if ( ! function_exists( 'fictioneer_first_paragraph_as_excerpt' ) ) {
/**
* Returns the first paragraph of the content as excerpt
@ -82,14 +61,11 @@ if ( ! function_exists( 'fictioneer_first_paragraph_as_excerpt' ) ) {
function fictioneer_first_paragraph_as_excerpt( $content ) {
$excerpt = strip_shortcodes( $content );
$excerpt = substr( $excerpt, 0, strpos( $excerpt, '</p>' ) + 4 );
return wp_strip_all_tags( $excerpt, true );
}
}
// =============================================================================
// GET FORCED EXCERPT EVEN IF POST IS PROTECTED
// =============================================================================
if ( ! function_exists( 'fictioneer_get_forced_excerpt' ) ) {
/**
* Returns the excerpt even if the post is protected
@ -124,7 +100,7 @@ if ( ! function_exists( 'fictioneer_get_forced_excerpt' ) ) {
}
// =============================================================================
// AUTHOR NODE
// GET AUTHOR NODE(S)
// =============================================================================
if ( ! function_exists( 'fictioneer_get_author_node' ) ) {
@ -152,6 +128,82 @@ if ( ! function_exists( 'fictioneer_get_author_node' ) ) {
}
}
if ( ! function_exists( 'fictioneer_get_multi_author_nodes' ) ) {
/**
* Returns the HTML for the authors
*
* @since 5.0.0
*
* @param array $authors Array of authors to process.
*
* @return string HTML for the author nodes.
*/
function fictioneer_get_multi_author_nodes( $authors ) {
// Setup
$author_nodes = [];
// If no author was found...
if ( empty( $authors ) ) {
return __( 'Unknown', 'No story author(s) were found.', 'fictioneer' );
}
// The meta field returns an array of IDs
foreach ( $authors as $author ) {
$author_nodes[] = fictioneer_get_author_node( $author );
}
// Remove empty items
$author_nodes = array_filter( $author_nodes );
// Build and return HTML
return implode( ', ', array_unique( $author_nodes ) );
}
}
if ( ! function_exists( 'fictioneer_get_story_author_nodes' ) ) {
/**
* Returns the HTML for the authors on story pages
*
* @since 5.0.0
*
* @param int $story_id The story ID.
*
* @return string HTML for the author nodes.
*/
function fictioneer_get_story_author_nodes( $story_id ) {
// Setup
$all_authors = fictioneer_get_post_author_ids( $story_id );
$all_authors = is_array( $all_authors ) ? $all_authors : [];
// Return author nodes
return fictioneer_get_multi_author_nodes( $all_authors );
}
}
if ( ! function_exists( 'fictioneer_get_chapter_author_nodes' ) ) {
/**
* Returns the HTML for the authors on chapter pages
*
* @since 5.0.0
*
* @param int $chapter_id The chapter ID.
*
* @return string HTML for the author nodes.
*/
function fictioneer_get_chapter_author_nodes( $chapter_id ) {
// Setup
$all_authors = get_post_meta( $chapter_id, 'fictioneer_chapter_co_authors', true ) ?? [];
$all_authors = is_array( $all_authors ) ? $all_authors : [];
array_unshift( $all_authors, get_post_field( 'post_author', $chapter_id ) );
// Return author nodes
return fictioneer_get_multi_author_nodes( $all_authors );
}
}
// =============================================================================
// GET ICON HTML
// =============================================================================
@ -198,7 +250,7 @@ if ( ! function_exists( 'fictioneer_get_icon' ) ) {
}
// =============================================================================
// GET TITLE AND ACCOUNT FOR EMPTY
// GET SAFE TITLE
// =============================================================================
if ( ! function_exists( 'fictioneer_get_safe_title' ) ) {
@ -237,6 +289,7 @@ if ( ! function_exists( 'fictioneer_get_safe_title' ) ) {
$title = apply_filters( 'fictioneer_filter_safe_title', $title, $post_id, $context, $args );
}
// Return final title
return $title;
}
}
@ -299,7 +352,7 @@ add_filter( 'fictioneer_filter_safe_title', 'fictioneer_prefix_protected_safe_ti
function fictioneer_prefix_draft_safe_title( $title, $id ) {
// Prepend icon to titles of drafts
if ( get_post_status( $id ) === 'draft' ) {
return 'Draft: ' . $title;
return sprintf( _x( 'Draft: %s', 'Safe title prefix.', 'fictioneer' ), $title );
}
// Continue filter
@ -308,7 +361,7 @@ function fictioneer_prefix_draft_safe_title( $title, $id ) {
add_filter( 'fictioneer_filter_safe_title', 'fictioneer_prefix_draft_safe_title', 10, 2 );
// =============================================================================
// GET READING TIME NODES HTML
// GET READING TIME NODES
// =============================================================================
if ( ! function_exists( 'fictioneer_get_reading_time_nodes' ) ) {
@ -375,7 +428,7 @@ if ( ! function_exists( 'fictioneer_get_reading_time_nodes' ) ) {
}
// =============================================================================
// GET FOOTER COPYRIGHT NOTE HTML
// GET FOOTER COPYRIGHT NOTE
// =============================================================================
if ( ! function_exists( 'fictioneer_get_footer_copyright_note' ) ) {
@ -425,7 +478,7 @@ function fictioneer_get_version() {
}
// =============================================================================
// GET BREADCRUMBS HTML
// GET BREADCRUMBS
// =============================================================================
if ( ! function_exists( 'fictioneer_get_breadcrumbs' ) ) {
@ -490,74 +543,12 @@ if ( ! function_exists( 'fictioneer_get_breadcrumbs' ) ) {
}
// =============================================================================
// GET AUTHORS HTML
// =============================================================================
if ( ! function_exists( 'fictioneer_get_multi_author_nodes' ) ) {
/**
* Returns the HTML for the authors
*
* @since 5.0.0
*
* @param array $authors Array of authors to process.
*
* @return string HTML for the author nodes.
*/
function fictioneer_get_multi_author_nodes( $authors ) {
// Setup
$author_nodes = [];
// If no author was found...
if ( empty( $authors ) ) {
return __( 'Unknown', 'No story author(s) were found.', 'fictioneer' );
}
// The meta field returns an array of IDs
foreach ( $authors as $author ) {
$author_nodes[] = fictioneer_get_author_node( $author );
}
// Remove empty items
$author_nodes = array_filter( $author_nodes );
// Build and return HTML
return implode( ', ', array_unique( $author_nodes ) );
}
}
// =============================================================================
// GET STORY AUTHORS HTML
// =============================================================================
if ( ! function_exists( 'fictioneer_get_story_author_nodes' ) ) {
/**
* Returns the HTML for the authors on story pages
*
* @since 5.0.0
*
* @param int $story_id The story ID.
*
* @return string HTML for the author nodes.
*/
function fictioneer_get_story_author_nodes( $story_id ) {
// Setup
$all_authors = fictioneer_get_post_author_ids( $story_id );
$all_authors = is_array( $all_authors ) ? $all_authors : [];
// Return author nodes
return fictioneer_get_multi_author_nodes( $all_authors );
}
}
// =============================================================================
// GET STORY PAGE THUMBNAIL HTML
// GET COVERS (THUMBNAIL)
// =============================================================================
if ( ! function_exists( 'fictioneer_get_story_page_cover' ) ) {
/**
* Returns the HTML for thumbnail on story pages
* Returns the HTML for cover image on story pages
*
* @since 5.0.0
* @since 5.9.4 - Removed output buffer.
@ -565,7 +556,7 @@ if ( ! function_exists( 'fictioneer_get_story_page_cover' ) ) {
* @param array $story Collection of story data.
* @param array $args Optional. Additional arguments.
*
* @return string HTML for the thumbnail.
* @return string HTML for the cover image.
*/
function fictioneer_get_story_page_cover( $story, $args = [] ) {
@ -586,22 +577,52 @@ if ( ! function_exists( 'fictioneer_get_story_page_cover' ) ) {
}
}
// =============================================================================
// GET SUBSCRIBE BUTTONS HTML
// =============================================================================
if ( ! function_exists( 'fictioneer_get_subscribe_options' ) ) {
if ( ! function_exists( 'fictioneer_get_recommendation_page_cover' ) ) {
/**
* Returns the HTML for the subscribe buttons
* Returns the HTML for cover image on recommendation pages
*
* @since 5.0.0
* @since 5.9.4 - Removed output buffer.
*
* @param int|null $post_id The post ID the buttons are for. Defaults to current.
* @param int|null $author_id The author ID the buttons are for. Defaults to current.
* @param WP_Post $recommendation The post object.
*
* @return string HTML for the cover image.
*/
function fictioneer_get_recommendation_page_cover( $recommendation ) {
return sprintf(
'<figure class="recommendation__thumbnail"><a href="%s" %s>%s</a></figure>',
get_the_post_thumbnail_url( $recommendation->ID, 'full' ),
fictioneer_get_lightbox_attribute(),
get_the_post_thumbnail( $recommendation->ID, array( 200, 300 ), array(
'alt' => esc_attr(
sprintf(
__( '%s Cover', 'fictioneer' ),
fictioneer_get_safe_title( $recommendation->ID )
)
),
'class' => 'webfeedsFeaturedVisual recommendation__thumbnail-image'
))
);
}
}
// =============================================================================
// GET SUBSCRIBE BUTTONS
// =============================================================================
if ( ! function_exists( 'fictioneer_get_subscribe_options' ) ) {
/**
* Returns the HTML for the subscribe options (links)
*
* @since 5.0.0
* @since 5.9.4 - Removed output buffer.
*
* @param int|null $post_id The post ID the links are for. Defaults to current.
* @param int|null $author_id The author ID the links are for. Defaults to current.
* @param string|null $feed RSS feed link. Default determined by post type.
*
* @return string HTML for subscribe buttons.
* @return string HTML for subscribe links.
*/
function fictioneer_get_subscribe_options( $post_id = null, $author_id = null, $feed = null ) {
@ -704,7 +725,7 @@ if ( ! function_exists( 'fictioneer_get_subscribe_options' ) ) {
}
// =============================================================================
// GET STORY BUTTONS HTML
// GET STORY BUTTONS
// =============================================================================
if ( ! function_exists( 'fictioneer_get_story_buttons' ) ) {
@ -803,33 +824,7 @@ if ( ! function_exists( 'fictioneer_get_story_buttons' ) ) {
}
// =============================================================================
// GET CHAPTER AUTHORS HTML
// =============================================================================
if ( ! function_exists( 'fictioneer_get_chapter_author_nodes' ) ) {
/**
* Returns the HTML for the authors on chapter pages
*
* @since 5.0.0
*
* @param int $chapter_id The chapter ID.
*
* @return string HTML for the author nodes.
*/
function fictioneer_get_chapter_author_nodes( $chapter_id ) {
// Setup
$all_authors = get_post_meta( $chapter_id, 'fictioneer_chapter_co_authors', true ) ?? [];
$all_authors = is_array( $all_authors ) ? $all_authors : [];
array_unshift( $all_authors, get_post_field( 'post_author', $chapter_id ) );
// Return author nodes
return fictioneer_get_multi_author_nodes( $all_authors );
}
}
// =============================================================================
// GET CHAPTER MICRO MENU HTML
// GET CHAPTER MICRO MENU
// =============================================================================
if ( ! function_exists( 'fictioneer_get_chapter_micro_menu' ) ) {
@ -849,6 +844,7 @@ if ( ! function_exists( 'fictioneer_get_chapter_micro_menu' ) ) {
*/
function fictioneer_get_chapter_micro_menu( $args ) {
// Setup
$micro_menu = [];
// Only if there is a story...
@ -924,7 +920,7 @@ if ( ! function_exists( 'fictioneer_get_chapter_micro_menu' ) ) {
}
// =============================================================================
// GET SIMPLE CHAPTER LIST HTML
// GET SIMPLE CHAPTER LIST
// =============================================================================
if ( ! function_exists( 'fictioneer_get_chapter_list_items' ) ) {
@ -1024,41 +1020,88 @@ if ( ! function_exists( 'fictioneer_get_chapter_list_items' ) ) {
}
// =============================================================================
// GET RECOMMENDATION PAGE THUMBNAIL HTML
// GET CHAPTER LIST META ROW
// =============================================================================
if ( ! function_exists( 'fictioneer_get_recommendation_page_cover' ) ) {
if ( ! function_exists( 'fictioneer_get_list_chapter_meta_row' ) ) {
/**
* Returns the HTML for thumbnail on recommendation pages
* Returns HTML for list chapter meta row
*
* @since 5.0.0
* @since 5.1.2
* @since 5.9.4 - Removed output buffer.
*
* @param WP_Post $recommendation The post object.
* @param array $data Chapter data for the meta row.
* @param array $args Optional arguments.
*
* @return string HTML for the thumbnail.
* @return string HTML of the list chapter meta row.
*/
function fictioneer_get_recommendation_page_cover( $recommendation ) {
return sprintf(
'<figure class="recommendation__thumbnail"><a href="%s" %s>%s</a></figure>',
get_the_post_thumbnail_url( $recommendation->ID, 'full' ),
fictioneer_get_lightbox_attribute(),
get_the_post_thumbnail( $recommendation->ID, array( 200, 300 ), array(
'alt' => esc_attr(
sprintf(
__( '%s Cover', 'fictioneer' ),
fictioneer_get_safe_title( $recommendation->ID )
)
),
'class' => 'webfeedsFeaturedVisual recommendation__thumbnail-image'
))
);
function fictioneer_get_list_chapter_meta_row( $data, $args = [] ) {
// Setup
$output = [];
$has_grid_view = ! empty( $args['grid'] );
// Password
if ( ! empty( $data['password'] ) ) {
$output['protected'] = '<i class="fa-solid fa-lock chapter-group__list-item-protected list-view"></i>';
}
// Warning
if ( ! empty( $data['warning'] ) ) {
$output['warning'] = sprintf(
'<span class="chapter-group__list-item-warning list-view">%s</span>',
sprintf( __( '<b>Warning:</b> %s', 'fictioneer' ), $data['warning'] )
);
}
// Date
if ( $has_grid_view ) {
$output['date'] = sprintf(
'<time datetime="%s" class="chapter-group__list-item-date"><span class="list-view">%s</span><span class="grid-view">%s</span></time>',
esc_attr( $data['timestamp'] ),
$data['list_date'],
$data['grid_date']
);
} else {
$output['date'] = sprintf(
'<time datetime="%s" class="chapter-group__list-item-date">%s</time>',
esc_attr( $data['timestamp'] ),
$data['list_date']
);
}
// Words
if ( $has_grid_view ) {
$short_words = fictioneer_shorten_number( $data['words'] );
$output['words'] = sprintf(
'<span class="chapter-group__list-item-words" data-number-switch="%s">%s</span>',
esc_attr( $short_words ),
sprintf(
_x( '%s Words', 'Word count in chapter list.', 'fictioneer' ),
number_format_i18n( $data['words'] )
)
);
} else {
$output['words'] = sprintf(
'<span class="chapter-group__list-item-words">%s</span>',
sprintf(
_x( '%s Words', 'Word count in chapter list.', 'fictioneer' ),
number_format_i18n( $data['words'] )
)
);
}
// Apply filters
$output = apply_filters( 'fictioneer_filter_list_chapter_meta_row', $output, $data, $args );
// Implode and return HTML
return '<div class="chapter-group__list-item-subrow truncate _1-1">' . implode( ' ', $output ) . '</div>';
}
}
// =============================================================================
// GET TAXONOMY PILLS HTML
// GET TAXONOMY PILLS
// =============================================================================
if ( ! function_exists( 'fictioneer_get_taxonomy_pills' ) ) {
@ -1164,7 +1207,7 @@ if ( ! function_exists( 'fictioneer_get_rss_link' ) ) {
}
// =============================================================================
// GET USER SUBMENU ITEMS HTML
// GET USER SUBMENU ITEMS
// =============================================================================
if ( ! function_exists( 'fictioneer_user_menu_items' ) ) {
@ -1235,7 +1278,7 @@ if ( ! function_exists( 'fictioneer_user_menu_items' ) ) {
}
// =============================================================================
// GET POST META ITEMS HTML
// GET POST META ITEMS
// =============================================================================
if ( ! function_exists( 'fictioneer_get_post_meta_items' ) ) {
@ -1304,7 +1347,7 @@ if ( ! function_exists( 'fictioneer_get_post_meta_items' ) ) {
}
// =============================================================================
// GET CARD CONTROLS HTML
// GET CARD CONTROLS
// =============================================================================
if ( ! function_exists( 'fictioneer_get_card_controls' ) ) {
@ -1602,87 +1645,6 @@ if ( ! function_exists( 'fictioneer_get_support_links' ) ) {
}
}
// =============================================================================
// GET CHAPTER LIST SUBROW HTML
// =============================================================================
if ( ! function_exists( 'fictioneer_get_list_chapter_meta_row' ) ) {
/**
* Returns HTML for list chapter meta row
*
* @since 5.1.2
* @since 5.9.4 - Removed output buffer.
*
* @param array $data Chapter data for the meta row.
* @param array $args Optional arguments.
*
* @return string HTML of the list chapter meta row.
*/
function fictioneer_get_list_chapter_meta_row( $data, $args = [] ) {
// Setup
$output = [];
$has_grid_view = ! empty( $args['grid'] );
// Password
if ( ! empty( $data['password'] ) ) {
$output['protected'] = '<i class="fa-solid fa-lock chapter-group__list-item-protected list-view"></i>';
}
// Warning
if ( ! empty( $data['warning'] ) ) {
$output['warning'] = sprintf(
'<span class="chapter-group__list-item-warning list-view">%s</span>',
sprintf( __( '<b>Warning:</b> %s', 'fictioneer' ), $data['warning'] )
);
}
// Date
if ( $has_grid_view ) {
$output['date'] = sprintf(
'<time datetime="%s" class="chapter-group__list-item-date"><span class="list-view">%s</span><span class="grid-view">%s</span></time>',
esc_attr( $data['timestamp'] ),
$data['list_date'],
$data['grid_date']
);
} else {
$output['date'] = sprintf(
'<time datetime="%s" class="chapter-group__list-item-date">%s</time>',
esc_attr( $data['timestamp'] ),
$data['list_date']
);
}
// Words
if ( $has_grid_view ) {
$short_words = fictioneer_shorten_number( $data['words'] );
$output['words'] = sprintf(
'<span class="chapter-group__list-item-words" data-number-switch="%s">%s</span>',
esc_attr( $short_words ),
sprintf(
_x( '%s Words', 'Word count in chapter list.', 'fictioneer' ),
number_format_i18n( $data['words'] )
)
);
} else {
$output['words'] = sprintf(
'<span class="chapter-group__list-item-words">%s</span>',
sprintf(
_x( '%s Words', 'Word count in chapter list.', 'fictioneer' ),
number_format_i18n( $data['words'] )
)
);
}
// Apply filters
$output = apply_filters( 'fictioneer_filter_list_chapter_meta_row', $output, $data, $args );
// Implode and return HTML
return '<div class="chapter-group__list-item-subrow truncate _1-1">' . implode( ' ', $output ) . '</div>';
}
}
// =============================================================================
// GET STORY BLOG POSTS
// =============================================================================
@ -1766,4 +1728,41 @@ if ( ! function_exists( 'fictioneer_get_story_blog_posts' ) ) {
}
}
?>
// =============================================================================
// GET STORY CHANGELOG
// =============================================================================
/**
* Returns story changelog
*
* @since 5.7.5
*
* @param int $story_id The story post ID.
*
* @return array Array with logged chapter changes since initialization.
*/
function fictioneer_get_story_changelog( $story_id ) {
$story_id = absint( $story_id );
if ( empty( $story_id ) ) {
return [];
}
// Setup
$changelog = get_post_meta( $story_id, 'fictioneer_story_changelog', true );
$changelog = is_array( $changelog ) ? $changelog : [];
// Initialize
if ( empty( $changelog ) ) {
$changelog[] = array(
time(),
_x( 'Initialized.', 'Story changelog initialized.', 'fictioneer' )
);
update_post_meta( $story_id, 'fictioneer_story_changelog', $changelog );
}
// Return
return $changelog;
}

View File

@ -373,5 +373,3 @@ if ( ! empty( get_option( 'fictioneer_discord_channel_chapters_webhook' ) ) ) {
// // Send to Discord
// fictioneer_discord_send_message( $webhook, $message );
// }
?>

View File

@ -1222,5 +1222,3 @@ if ( get_option( 'fictioneer_enable_epubs' ) ) {
add_action( 'wp_ajax_fictioneer_ajax_download_epub', 'fictioneer_ajax_download_epub' );
add_action( 'wp_ajax_nopriv_fictioneer_ajax_download_epub', 'fictioneer_ajax_download_epub' );
}
?>

View File

@ -5,7 +5,7 @@
// =============================================================================
/**
* Submit comment form via AJAX
* Submit contact form via AJAX
*
* @since 5.0.0
* @link https://developer.wordpress.org/reference/functions/wp_send_json_error/
@ -226,5 +226,3 @@ function fictioneer_ajax_submit_contact_form() {
}
add_action( 'wp_ajax_fictioneer_ajax_submit_contact_form', 'fictioneer_ajax_submit_contact_form' );
add_action( 'wp_ajax_nopriv_fictioneer_ajax_submit_contact_form', 'fictioneer_ajax_submit_contact_form' );
?>

View File

@ -1084,5 +1084,3 @@ if ( ! function_exists( 'fictioneer_delete_expired_oauth_transients' ) ) {
}
}
}
?>

View File

@ -372,5 +372,3 @@ function fictioneer_output_schemas( $post_id = null ) {
if ( get_option( 'fictioneer_enable_seo' ) && ! fictioneer_seo_plugin_active() ) {
add_action( 'wp_head', 'fictioneer_output_schemas' );
}
?>

View File

@ -445,5 +445,3 @@ function fictioneer_extend_search_query( $query ) {
if ( ! get_option( 'fictioneer_disable_theme_search' ) ) {
add_action( 'pre_get_posts' ,'fictioneer_extend_search_query', 11 );
}
?>

View File

@ -793,5 +793,3 @@ if ( get_option( 'fictioneer_enable_seo' ) && ! fictioneer_seo_plugin_active() )
remove_action( 'wp_head', 'rel_canonical' ); // Re-added in the new action
add_action( 'wp_head', 'fictioneer_output_head_seo', 5 );
}
?>

View File

@ -272,5 +272,3 @@ function fictioneer_create_sitemap() {
fwrite( $file_path, $sitemap );
fclose( $file_path );
}
?>

View File

@ -757,4 +757,3 @@ function fictioneer_purge_nav_menu_transients() {
delete_transient( 'fictioneer_footer_menu_html' );
}
add_action( 'wp_update_nav_menu', 'fictioneer_purge_nav_menu_transients' );
?>

View File

@ -150,41 +150,6 @@ add_action( 'save_post', 'fictioneer_store_original_publish_date', 10, 2 );
// STORY CHANGELOG
// =============================================================================
/**
* Returns story changelog
*
* @since 5.7.5
*
* @param int $story_id The story post ID.
*
* @return array Array with logged chapter changes since initialization.
*/
function fictioneer_get_story_changelog( $story_id ) {
$story_id = absint( $story_id );
if ( empty( $story_id ) ) {
return [];
}
// Setup
$changelog = get_post_meta( $story_id, 'fictioneer_story_changelog', true );
$changelog = is_array( $changelog ) ? $changelog : [];
// Initialize
if ( empty( $changelog ) ) {
$changelog[] = array(
time(),
_x( 'Initialized.', 'Story changelog initialized.', 'fictioneer' )
);
update_post_meta( $story_id, 'fictioneer_story_changelog', $changelog );
}
// Return
return $changelog;
}
/**
* Logs changes to story chapters
*
@ -374,16 +339,14 @@ function fictioneer_chapter_to_draft( $post ) {
return;
}
// Remove filter
// Temporarily remove filter
remove_filter( 'fictioneer_filter_safe_title', 'fictioneer_prefix_draft_safe_title' );
// Remove chapter from story
fictioneer_remove_chapter_from_story( $post->ID );
// Add filter
// Re-add filter
add_filter( 'fictioneer_filter_safe_title', 'fictioneer_prefix_draft_safe_title', 10, 2 );
}
add_action( 'publish_to_draft', 'fictioneer_chapter_to_draft' );
add_action( 'private_to_draft', 'fictioneer_chapter_to_draft' );
?>

View File

@ -4,12 +4,6 @@
// ADMIN INCLUDES
// =============================================================================
/**
* Remove obsolete data and clean up when the theme is deactivated/deleted.
*/
require_once __DIR__ . '/_cleanup.php';
/**
* Add setting page for the theme.
*/
@ -20,7 +14,7 @@ require_once __DIR__ . '/settings/_settings.php';
* Add meta fields to editor.
*/
require_once __DIR__ . '/_meta_fields.php';
require_once __DIR__ . '/_setup-meta-fields.php';
/**
* Extend user profile in admin panel.
@ -596,4 +590,57 @@ function fictioneer_ajax_reset_theme_colors() {
}
add_action( 'wp_ajax_fictioneer_ajax_reset_theme_colors', 'fictioneer_ajax_reset_theme_colors' );
?>
// =============================================================================
// THEME DEACTIVATION
// =============================================================================
/**
* Clean up when the theme is deactivated
*
* Always deletes all theme-related Transients in the database. If the option to
* delete all settings and theme mods is activated, these will be removed as
* well but otherwise preserved.
*
* @since 4.7.0
* @since 5.7.4 - Updated to use SQL queries.
* @since 5.10.0 - Updated for font manager.
* @since 5.11.0 - Updated for all cached files.
*
* @global wpdb $wpdb WordPress database object.
*/
function fictioneer_theme_deactivation() {
global $wpdb;
// Delete all theme Transients
fictioneer_delete_transients_like( 'fictioneer_' );
// Delete cached files
$cache_dir = WP_CONTENT_DIR . '/themes/fictioneer/cache/';
$files = glob( $cache_dir . '*' );
foreach ( $files as $file ) {
if ( is_file( $file ) ) {
unlink( $file );
}
}
// Only continue if the user wants to delete all options/mods
if ( get_option( 'fictioneer_delete_theme_options_on_deactivation', false ) ) {
// Remove theme mods
remove_theme_mods();
// SQL to delete all options starting with "fictioneer_"
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'fictioneer_%'" );
// SQL to delete all user meta starting with "fictioneer_"
$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'fictioneer_%'" );
// SQL to delete all comment meta starting with "fictioneer_"
$wpdb->query( "DELETE FROM {$wpdb->commentmeta} WHERE meta_key LIKE 'fictioneer_%'" );
// Reset user roles
remove_role( 'fcn_moderator' );
}
}
add_action( 'switch_theme', 'fictioneer_theme_deactivation' );

View File

@ -4010,5 +4010,3 @@ function fictioneer_save_recommendation_metaboxes( $post_id ) {
}
}
add_action( 'save_post', 'fictioneer_save_recommendation_metaboxes' );
?>

View File

@ -1485,5 +1485,3 @@ if ( ! current_user_can( 'manage_options' ) ) {
add_action( 'admin_footer-post-new.php', 'fictioneer_classic_editor_js_restrictions' );
}
}
?>

View File

@ -1500,5 +1500,3 @@ function fictioneer_shortcode_article_cards( $attr ) {
return $html;
}
add_shortcode( 'fictioneer_article_cards', 'fictioneer_shortcode_article_cards' );
?>

View File

@ -1532,5 +1532,3 @@ function fictioneer_output_head_translations() {
echo "<script id='fictioneer-translations' type='text/javascript' data-no-optimize='1' data-no-defer='1' data-no-minify='1'>const fictioneer_tl = " . json_encode( fictioneer_get_js_translations() ) . ";</script>";
}
add_action( 'wp_head', 'fictioneer_output_head_translations' );
?>

View File

@ -143,7 +143,7 @@ function fictioneer_fcn_story_post_type() {
'label' => __( 'Story', 'fictioneer' ),
'description' => __( 'Holds stories and details about them.', 'fictioneer' ),
'labels' => $labels,
'menu_icon' => 'dashicons-book',
'menu_icon' => 'dashicons-book',
'supports' => ['title', 'author', 'editor', 'excerpt', 'thumbnail', 'revisions'],
'taxonomies' => ['category', 'post_tag', 'fcn_fandom', 'fcn_character', 'fcn_genre', 'fcn_content_warning'],
'hierarchical' => false,
@ -160,8 +160,8 @@ function fictioneer_fcn_story_post_type() {
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => ['fcn_story', 'fcn_stories'],
'capabilities' => array_combine( FICTIONEER_WP_CAPABILITIES, FICTIONEER_STORY_CAPABILITIES ),
'map_meta_cap' => true
'capabilities' => array_combine( FICTIONEER_WP_CAPABILITIES, FICTIONEER_STORY_CAPABILITIES ),
'map_meta_cap' => true
);
register_post_type( 'fcn_story', $args );
@ -212,7 +212,7 @@ function fictioneer_fcn_chapter_post_type() {
'label' => __( 'Chapter', 'fictioneer' ),
'description' => __( 'Holds chapters and details about them.', 'fictioneer' ),
'labels' => $labels,
'menu_icon' => 'dashicons-text-page',
'menu_icon' => 'dashicons-text-page',
'supports' => ['title', 'author', 'editor', 'excerpt', 'thumbnail', 'comments', 'revisions'],
'taxonomies' => ['category', 'post_tag', 'fcn_fandom', 'fcn_character', 'fcn_genre', 'fcn_content_warning'],
'hierarchical' => false,
@ -229,8 +229,8 @@ function fictioneer_fcn_chapter_post_type() {
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => ['fcn_chapter', 'fcn_chapters'],
'capabilities' => array_combine( FICTIONEER_WP_CAPABILITIES, FICTIONEER_CHAPTER_CAPABILITIES ),
'map_meta_cap' => true
'capabilities' => array_combine( FICTIONEER_WP_CAPABILITIES, FICTIONEER_CHAPTER_CAPABILITIES ),
'map_meta_cap' => true
);
register_post_type( 'fcn_chapter', $args );
@ -281,7 +281,7 @@ function fictioneer_fcn_collection_post_type() {
'label' => __( 'Collection', 'fictioneer' ),
'description' => __( 'Collections of stories, chapters, and recommendations.', 'fictioneer' ),
'labels' => $labels,
'menu_icon' => 'dashicons-category',
'menu_icon' => 'dashicons-category',
'supports' => ['title', 'author', 'editor', 'thumbnail'],
'taxonomies' => ['category', 'post_tag', 'fcn_fandom', 'fcn_character', 'fcn_genre', 'fcn_content_warning'],
'hierarchical' => false,
@ -298,8 +298,8 @@ function fictioneer_fcn_collection_post_type() {
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => ['fcn_collection', 'fcn_collections'],
'capabilities' => array_combine( FICTIONEER_WP_CAPABILITIES, FICTIONEER_COLLECTION_CAPABILITIES ),
'map_meta_cap' => true
'capabilities' => array_combine( FICTIONEER_WP_CAPABILITIES, FICTIONEER_COLLECTION_CAPABILITIES ),
'map_meta_cap' => true
);
register_post_type( 'fcn_collection', $args );
@ -350,7 +350,7 @@ function fictioneer_fcn_recommendation_post_type() {
'label' => __( 'Recommendation', 'fictioneer' ),
'description' => __( 'Recommendations for external stories.', 'fictioneer' ),
'labels' => $labels,
'menu_icon' => 'dashicons-star-filled',
'menu_icon' => 'dashicons-star-filled',
'supports' => ['title', 'author', 'editor', 'excerpt', 'thumbnail'],
'taxonomies' => ['category', 'post_tag', 'fcn_fandom', 'fcn_character', 'fcn_genre', 'fcn_content_warning'],
'hierarchical' => false,
@ -367,8 +367,8 @@ function fictioneer_fcn_recommendation_post_type() {
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => ['fcn_recommendation', 'fcn_recommendations'],
'capabilities' => array_combine( FICTIONEER_WP_CAPABILITIES, FICTIONEER_RECOMMENDATION_CAPABILITIES ),
'map_meta_cap' => true
'capabilities' => array_combine( FICTIONEER_WP_CAPABILITIES, FICTIONEER_RECOMMENDATION_CAPABILITIES ),
'map_meta_cap' => true
);
register_post_type( 'fcn_recommendation', $args );
@ -409,10 +409,10 @@ function fictioneer_add_genre_taxonomy() {
'query_var' => true,
'rewrite' => array( 'slug' => 'genre' ),
'capabilities' => array(
'manage_terms' => 'manage_fcn_genres',
'edit_terms' => 'edit_fcn_genres',
'delete_terms' => 'delete_fcn_genres',
'assign_terms' => 'assign_fcn_genres'
'manage_terms' => 'manage_fcn_genres',
'edit_terms' => 'edit_fcn_genres',
'delete_terms' => 'delete_fcn_genres',
'assign_terms' => 'assign_fcn_genres'
)
);
@ -454,10 +454,10 @@ function fictioneer_add_fandom_taxonomy() {
'query_var' => true,
'rewrite' => array( 'slug' => 'fandom' ),
'capabilities' => array(
'manage_terms' => 'manage_fcn_fandoms',
'edit_terms' => 'edit_fcn_fandoms',
'delete_terms' => 'delete_fcn_fandoms',
'assign_terms' => 'assign_fcn_fandoms'
'manage_terms' => 'manage_fcn_fandoms',
'edit_terms' => 'edit_fcn_fandoms',
'delete_terms' => 'delete_fcn_fandoms',
'assign_terms' => 'assign_fcn_fandoms'
)
);
@ -499,10 +499,10 @@ function fictioneer_add_character_taxonomy() {
'query_var' => true,
'rewrite' => array( 'slug' => 'character' ),
'capabilities' => array(
'manage_terms' => 'manage_fcn_characters',
'edit_terms' => 'edit_fcn_characters',
'delete_terms' => 'delete_fcn_characters',
'assign_terms' => 'assign_fcn_characters'
'manage_terms' => 'manage_fcn_characters',
'edit_terms' => 'edit_fcn_characters',
'delete_terms' => 'delete_fcn_characters',
'assign_terms' => 'assign_fcn_characters'
)
);
@ -544,10 +544,10 @@ function fictioneer_add_content_warning_taxonomy() {
'query_var' => true,
'rewrite' => array( 'slug' => 'content-warning' ),
'capabilities' => array(
'manage_terms' => 'manage_fcn_content_warnings',
'edit_terms' => 'edit_fcn_content_warnings',
'delete_terms' => 'delete_fcn_content_warnings',
'assign_terms' => 'assign_fcn_content_warnings'
'manage_terms' => 'manage_fcn_content_warnings',
'edit_terms' => 'edit_fcn_content_warnings',
'delete_terms' => 'delete_fcn_content_warnings',
'assign_terms' => 'assign_fcn_content_warnings'
)
);
@ -799,5 +799,3 @@ function fictioneer_filter_chapters_by_story( $query ) {
if ( is_admin() ) {
add_action( 'pre_get_posts', 'fictioneer_filter_chapters_by_story' );
}
?>

View File

@ -53,7 +53,7 @@ if ( get_option( 'fictioneer_enable_sitemap' ) && ! fictioneer_seo_plugin_active
}
// =============================================================================
// CUSTOM EXCERPT LENGTH
// CUSTOMIZE EXCERPTS
// =============================================================================
/**
@ -69,6 +69,19 @@ function fictioneer_custom_excerpt_length( $length ) {
}
add_filter( 'excerpt_length', 'fictioneer_custom_excerpt_length' );
/**
* Replace excerpt ellipsis
*
* @since 5.2.5
*
* @return string The ellipsis ().
*/
function fictioneer_excerpt_ellipsis() {
return '…';
}
add_filter( 'excerpt_more', 'fictioneer_excerpt_ellipsis' );
// =============================================================================
// CUSTOMIZE ADMIN BAR
// =============================================================================
@ -1268,5 +1281,3 @@ function fictioneer_disable_font_library( $editor_settings ) {
return $editor_settings;
}
add_filter( 'block_editor_settings_all', 'fictioneer_disable_font_library' );
?>

View File

@ -2814,5 +2814,3 @@ if ( ! function_exists( 'fictioneer_get_async_css_loading_pattern' ) ) {
return 'media="all"';
}
}
?>