Cleanup
This commit is contained in:
parent
d52d56d37d
commit
15eb144b48
@ -120,7 +120,9 @@ if ( FICTIONEER_FILTER_STORY_CHAPTERS ) {
|
||||
|
||||
function fictioneer_update_post_relationships( $post_id ) {
|
||||
// Only posts...
|
||||
if ( get_post_type( $post_id ) != 'post' ) return;
|
||||
if ( get_post_type( $post_id ) != 'post' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup
|
||||
$registry = fictioneer_get_relationship_registry();
|
||||
@ -144,13 +146,17 @@ function fictioneer_update_post_relationships( $post_id ) {
|
||||
// Check for and remove outdated direct references
|
||||
foreach ( $registry as $key => $entry ) {
|
||||
// Skip if...
|
||||
if ( absint( $key ) < 1 || ! is_array( $entry ) || in_array( $key, $featured ) ) continue;
|
||||
if ( absint( $key ) < 1 || ! is_array( $entry ) || in_array( $key, $featured ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Unset if in array
|
||||
unset( $registry[ $key ][ $post_id ] );
|
||||
|
||||
// Remove node if empty
|
||||
if ( empty( $registry[ $key ] ) ) unset( $registry[ $key ] );
|
||||
if ( empty( $registry[ $key ] ) ) {
|
||||
unset( $registry[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
// Update database
|
||||
|
@ -121,13 +121,17 @@ if ( ! function_exists( 'fictioneer_check_for_updates' ) ) {
|
||||
curl_close( $ch );
|
||||
|
||||
// Abort if request failed
|
||||
if ( empty( $response ) ) return false;
|
||||
if ( empty( $response ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decode JSON to array
|
||||
$release = json_decode( $response, true );
|
||||
|
||||
// Abort if request did not return expected data
|
||||
if ( ! isset( $release['tag_name'] ) ) return false;
|
||||
if ( ! isset( $release['tag_name'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remember latest version
|
||||
update_option( 'fictioneer_latest_version', $release['tag_name'] );
|
||||
@ -151,10 +155,14 @@ function fictioneer_admin_update_notice() {
|
||||
$is_updates_page = $pagenow == 'update-core.php';
|
||||
|
||||
// Show only once every n seconds
|
||||
if ( $last_notice + FICTIONEER_UPDATE_CHECK_TIMEOUT > time() && ! $is_updates_page ) return;
|
||||
if ( $last_notice + FICTIONEER_UPDATE_CHECK_TIMEOUT > time() && ! $is_updates_page ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update?
|
||||
if ( ! fictioneer_check_for_updates() ) return;
|
||||
if ( ! fictioneer_check_for_updates() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Render notice
|
||||
$message = sprintf(
|
||||
@ -410,7 +418,9 @@ if ( ! function_exists( 'fictioneer_convert_taxonomies' ) ) {
|
||||
foreach ( $items as $item ) {
|
||||
$source_tax = get_the_terms( $item, $source );
|
||||
|
||||
if ( ! $source_tax ) continue;
|
||||
if ( ! $source_tax ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$source_tax = array_map( 'terms_to_array', $source_tax );
|
||||
|
||||
|
@ -21,7 +21,9 @@ if ( ! function_exists( 'fictioneer_api_get_story_node' ) ) {
|
||||
$data = fictioneer_get_story_data( $story_id, false ); // Does not refresh comment count!
|
||||
|
||||
// Abort if...
|
||||
if ( empty( $data ) ) return false;
|
||||
if ( empty( $data ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup
|
||||
$author_id = get_post_field( 'post_author', $story_id );
|
||||
@ -131,7 +133,9 @@ if ( ! function_exists( 'fictioneer_api_get_story_node' ) ) {
|
||||
$chapter_id = get_the_ID();
|
||||
|
||||
// Skip not visible chapters
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) continue;
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Data
|
||||
$author_id = get_the_author_meta( 'id' );
|
||||
|
@ -106,7 +106,9 @@ if ( ! function_exists( 'fictioneer_get_forced_excerpt' ) ) {
|
||||
function fictioneer_get_forced_excerpt( $post_id, $limit = 256, $default = false ) {
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( ! $default && $post->post_excerpt != '' ) return $post->post_excerpt;
|
||||
if ( ! $default && $post->post_excerpt != '' ) {
|
||||
return $post->post_excerpt;
|
||||
}
|
||||
|
||||
$excerpt = $post->post_content;
|
||||
$excerpt = preg_replace( ' (\[.*?\])', '', $excerpt );
|
||||
@ -397,13 +399,17 @@ if ( ! function_exists( 'fictioneer_get_breadcrumbs' ) ) {
|
||||
! is_array( $args['breadcrumbs'] ) ||
|
||||
count( $args['breadcrumbs'] ) < 1 ||
|
||||
is_front_page()
|
||||
) return '';
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Setup
|
||||
$count = count( $args['breadcrumbs'] );
|
||||
|
||||
// Abort if array does not have two or more items
|
||||
if ( $count < 2 ) return '';
|
||||
if ( $count < 2 ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Filter breadcrumbs array
|
||||
$args['breadcrumbs'] = apply_filters( 'fictioneer_filter_breadcrumbs_array', $args['breadcrumbs'], $args );
|
||||
@ -1001,14 +1007,18 @@ if ( ! function_exists( 'fictioneer_get_taxonomy_pills' ) ) {
|
||||
|
||||
function fictioneer_get_taxonomy_pills( $taxonomy_groups, $classes = '' ) {
|
||||
// Abort conditions
|
||||
if ( ! is_array( $taxonomy_groups ) || count( $taxonomy_groups ) < 1) return '';
|
||||
if ( ! is_array( $taxonomy_groups ) || count( $taxonomy_groups ) < 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
// Loop over all groups...
|
||||
foreach ( $taxonomy_groups as $group ) {
|
||||
// Check for empty group
|
||||
if ( ! $group || ! is_array( $group ) || count( $group ) < 1 ) continue;
|
||||
if ( ! $group || ! is_array( $group ) || count( $group ) < 1 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Process group
|
||||
foreach ( $group as $taxonomy ) {
|
||||
@ -1040,7 +1050,9 @@ if ( ! function_exists( 'fictioneer_get_rss_link' ) ) {
|
||||
|
||||
function fictioneer_get_rss_link( $post_type = null, $post_id = null ) {
|
||||
// Abort conditions
|
||||
if ( ! get_option( 'fictioneer_enable_theme_rss' ) ) return false;
|
||||
if ( ! get_option( 'fictioneer_enable_theme_rss' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup
|
||||
$post_type = $post_type ? $post_type : get_post_type();
|
||||
@ -1345,7 +1357,9 @@ if ( ! function_exists( 'fictioneer_get_card_controls' ) ) {
|
||||
$menu = apply_filters( 'fictioneer_filter_card_control_menu', $menu, $story_id, $chapter_id );
|
||||
|
||||
// Abort if...
|
||||
if ( count( $icons ) < 1 || count( $menu ) < 1 ) return '';
|
||||
if ( count( $icons ) < 1 || count( $menu ) < 1 ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
// Start HTML ---> ?>
|
||||
|
@ -213,7 +213,9 @@ if ( ! function_exists( 'fictioneer_hsl_code' ) ) {
|
||||
function fictioneer_hsl_code( $hex, $output = 'default' ) {
|
||||
$hsl_array = fictioneer_rgb_to_hsl( fictioneer_hex_to_rgb( $hex ), 2 );
|
||||
|
||||
if ( $output == 'values' ) return "$hsl_array[0] $hsl_array[1] $hsl_array[2]";
|
||||
if ( $output == 'values' ) {
|
||||
return "$hsl_array[0] $hsl_array[1] $hsl_array[2]";
|
||||
}
|
||||
|
||||
$deg = 'calc(' . $hsl_array[0] . 'deg + var(--hue-rotate))';
|
||||
$saturation = 'calc(' . $hsl_array[1] . '% * var(--saturation))';
|
||||
@ -221,7 +223,9 @@ if ( ! function_exists( 'fictioneer_hsl_code' ) ) {
|
||||
$max = $hsl_array[2] + (100 - $hsl_array[2]) / 2;
|
||||
$lightness = 'clamp('. $min . '%, ' . $hsl_array[2] . '% * var(--darken), ' . $max . '%)';
|
||||
|
||||
if ( $output == 'free' ) return "$deg $saturation $lightness";
|
||||
if ( $output == 'free' ) {
|
||||
return "$deg $saturation $lightness";
|
||||
}
|
||||
|
||||
return "hsl($deg $saturation $lightness)";
|
||||
}
|
||||
|
@ -36,7 +36,9 @@ if ( ! function_exists( 'fictioneer_download_epub' ) ) {
|
||||
$story_id = $story_id ? $story_id : get_query_var( FICTIONEER_EPUB_ENDPOINT, null );
|
||||
|
||||
// Abort if...
|
||||
if ( is_null( $story_id ) ) return;
|
||||
if ( is_null( $story_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate story ID again
|
||||
$story_id = fictioneer_validate_id( $story_id, 'fcn_story' );
|
||||
@ -243,7 +245,9 @@ if ( ! function_exists( 'fictioneer_add_epub_cover' ) ) {
|
||||
|
||||
function fictioneer_add_epub_cover( $dir, $epub_dir, $story_id ) {
|
||||
// Abort if the story has no cover image...
|
||||
if ( ! has_post_thumbnail( $story_id ) ) return;
|
||||
if ( ! has_post_thumbnail( $story_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup
|
||||
$path_parts = pathinfo( get_the_post_thumbnail_url( $story_id, 'full' ) );
|
||||
@ -444,7 +448,9 @@ if ( ! function_exists( 'fictioneer_add_epub_chapters' ) ) {
|
||||
$alt = urldecode( $img->getAttribute( 'alt' ) );
|
||||
|
||||
// Abort if...
|
||||
if ( ! $url ) continue;
|
||||
if ( ! $url ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Prepare path (remove unwanted extensions, e.g. '.jpg?_i=AA')
|
||||
$path_parts = pathinfo( $url );
|
||||
@ -525,7 +531,9 @@ if ( ! function_exists( 'fictioneer_add_epub_chapters' ) ) {
|
||||
}
|
||||
|
||||
// Terminate script if no chapter has been added
|
||||
if ( $index == 0 ) exit();
|
||||
if ( $index == 0 ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return lists
|
||||
return array(
|
||||
@ -580,7 +588,7 @@ if ( ! function_exists( 'fictioneer_generate_epub_opf' ) ) {
|
||||
$guide = $opf->getElementsByTagName( 'guide' )->item( 0 );
|
||||
|
||||
// Cover node (if any)
|
||||
if( has_post_thumbnail( $story_id ) ) {
|
||||
if ( has_post_thumbnail( $story_id ) ) {
|
||||
$path_parts = pathinfo( get_the_post_thumbnail_url( $story_id, 'full' ) );
|
||||
$path_extension = isset( $path_parts['extension'] ) ? $path_parts['extension'] : 'jpg';
|
||||
$extension = preg_replace( '/(?<=\.jpg|jpeg|png|gif|webp|svg|avif|apng).+/', '', '.' . $path_extension );
|
||||
@ -960,7 +968,9 @@ function fictioneer_generate_epub() {
|
||||
$story_id = get_query_var( FICTIONEER_EPUB_ENDPOINT, null );
|
||||
|
||||
// Abort if this is not an /download-epub/ URL...
|
||||
if ( is_null( $story_id ) ) return;
|
||||
if ( is_null( $story_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Abort if no story ID provided or ePUB download is disabled...
|
||||
if (
|
||||
@ -1088,7 +1098,9 @@ function fictioneer_generate_epub() {
|
||||
$zip->addFile( $mimetype_path, substr( $mimetype_path, strlen( $directory ) + 1) );
|
||||
|
||||
foreach ( $files as $name => $file ) {
|
||||
if ( $name == 'mimetype' ) continue;
|
||||
if ( $name == 'mimetype' ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! $file->isDir() ) {
|
||||
$filePath = $file->getRealPath();
|
||||
|
@ -122,7 +122,9 @@ function fictioneer_ajax_submit_contact_form() {
|
||||
$field_label = sanitize_text_field( $_POST[ "check_label_$i" ] ?? '' );
|
||||
|
||||
// Skip if label is missing
|
||||
if ( empty( $field_label ) ) continue;
|
||||
if ( empty( $field_label ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Strip HTML for good measure
|
||||
$field_label = wp_strip_all_tags( $field_label );
|
||||
|
@ -179,7 +179,9 @@ if ( ! function_exists( 'fictioneer_get_oauth_links' ) ) {
|
||||
|
||||
function fictioneer_handle_oauth() {
|
||||
// Check whether this is the OAuth2 route
|
||||
if ( is_null( get_query_var( FICTIONEER_OAUTH_ENDPOINT, null ) ) ) return;
|
||||
if ( is_null( get_query_var( FICTIONEER_OAUTH_ENDPOINT, null ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup
|
||||
fictioneer_set_oauth_constants();
|
||||
@ -864,8 +866,12 @@ if ( ! function_exists( 'fictioneer_get_oauth_client_credentials' ) ) {
|
||||
*/
|
||||
|
||||
function fictioneer_get_oauth_client_credentials( $channel, $type = 'id' ) {
|
||||
if ( ! $channel ) return null;
|
||||
if ( ! $channel ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$it = get_option( "fictioneer_{$channel}_client_{$type}" );
|
||||
|
||||
return $it ? $it : null;
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +314,10 @@ if ( ! function_exists( 'fictioneer_get_seo_title' ) ) {
|
||||
|
||||
// Cached title?
|
||||
$cache = get_post_meta( $post_id, 'fictioneer_seo_title_cache', true );
|
||||
if ( ! empty( $cache ) && ! $skip_cache ) return $cache;
|
||||
|
||||
if ( ! empty( $cache ) && ! $skip_cache ) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
// Start building...
|
||||
$seo_title = get_post_meta( $post_id, 'fictioneer_seo_title', true );
|
||||
@ -470,7 +473,10 @@ if ( ! function_exists( 'fictioneer_get_seo_description' ) ) {
|
||||
|
||||
// Cached description?
|
||||
$cache = get_post_meta( $post_id, 'fictioneer_seo_description_cache', true );
|
||||
if ( ! empty( $cache ) && ! $skip_cache ) return $cache;
|
||||
|
||||
if ( ! empty( $cache ) && ! $skip_cache ) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
// Start building...
|
||||
$seo_description = get_post_meta( $post_id, 'fictioneer_seo_description', true );
|
||||
@ -549,7 +555,10 @@ if ( ! function_exists( 'fictioneer_get_seo_image' ) ) {
|
||||
// Cached image? Except for site default, which can globally change!
|
||||
if ( ! $use_default ) {
|
||||
$cache = get_post_meta( $post_id, 'fictioneer_seo_og_image_cache', true );
|
||||
if ( $cache ) return $cache;
|
||||
|
||||
if ( $cache ) {
|
||||
return $cache;
|
||||
}
|
||||
}
|
||||
|
||||
// Get image ID if not yet set
|
||||
|
@ -270,7 +270,9 @@ function fictioneer_get_shortcode_tax_query( $args ) {
|
||||
|
||||
function fictioneer_shortcode_showcase( $attr ) {
|
||||
// Abort if...
|
||||
if ( empty( $attr['for'] ) ) return '';
|
||||
if ( empty( $attr['for'] ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Setup
|
||||
$count = max( 1, intval( $attr['count'] ?? 8 ) );
|
||||
|
@ -108,7 +108,11 @@ function fictioneer_create_sitemap( $last_saved_id ) {
|
||||
|
||||
foreach( $pages as $post ) {
|
||||
$template = get_page_template_slug( $post->ID );
|
||||
if ( in_array( $template, ['user-profile.php', 'single-bookmarks.php'] ) ) continue;
|
||||
|
||||
if ( in_array( $template, ['user-profile.php', 'single-bookmarks.php'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$frequency = 'yearly';
|
||||
$lastmod = get_the_modified_date( 'c', $post->ID );
|
||||
$sitemap .= fictioneer_url_node( get_permalink( $post->ID ), $lastmod, 'yearly' );
|
||||
|
@ -722,7 +722,9 @@ add_action( 'wp_enqueue_scripts', 'fictioneer_load_script_translations', 99 );
|
||||
|
||||
function fictioneer_remove_jquery_migrate( $scripts ) {
|
||||
// Abort if...
|
||||
if ( ! isset( $scripts->registered['jquery'] ) ) return;
|
||||
if ( ! isset( $scripts->registered['jquery'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup
|
||||
$script = $scripts->registered['jquery'];
|
||||
|
@ -6,18 +6,20 @@
|
||||
|
||||
if ( ! function_exists( 'fictioneer_url_exists' ) ) {
|
||||
/**
|
||||
* Checks whether an URL exists.
|
||||
* Checks whether an URL exists
|
||||
*
|
||||
* @since Fictioneer 4.0
|
||||
* @link https://www.geeksforgeeks.org/how-to-check-the-existence-of-url-in-php/
|
||||
* @link https://www.geeksforgeeks.org/how-to-check-the-existence-of-url-in-php/
|
||||
*
|
||||
* @param string $url The URL to check.
|
||||
*
|
||||
* @return boolean True if the URL exists and false otherwise.
|
||||
* @return boolean True if the URL exists and false otherwise. Probably.
|
||||
*/
|
||||
|
||||
function fictioneer_url_exists( $url ) {
|
||||
if ( ! $url ) return false;
|
||||
if ( ! $url ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$curl = curl_init( $url );
|
||||
curl_setopt( $curl, CURLOPT_NOBODY, true );
|
||||
@ -512,7 +514,7 @@ if ( ! function_exists( 'fictioneer_shorten_number' ) ) {
|
||||
if ( ! function_exists( 'fictioneer_validate_id' ) ) {
|
||||
/**
|
||||
* Ensures an ID is a valid integer and positive; optionally checks whether the
|
||||
* associated post is of a certain types (or among an array of types).
|
||||
* associated post is of a certain types (or among an array of types)
|
||||
*
|
||||
* @since Fictioneer 4.7
|
||||
*
|
||||
@ -625,37 +627,6 @@ if ( ! function_exists( 'fictioneer_replace_key_value' ) ) {
|
||||
// CHECK USER CAPABILITIES
|
||||
// =============================================================================
|
||||
|
||||
if ( ! function_exists( 'fictioneer_has_role' ) ) {
|
||||
/**
|
||||
* Checks if an user has a specific role
|
||||
*
|
||||
* @since Fictioneer 5.0
|
||||
*
|
||||
* @param WP_User|int $user The user object or ID to check.
|
||||
* @param string $role The role to check for.
|
||||
*
|
||||
* @return boolean To be or not to be.
|
||||
*/
|
||||
|
||||
function fictioneer_has_role( $user, $role ) {
|
||||
// Setup
|
||||
$user = is_int( $user ) ? get_user_by( 'ID', $user ) : $user;
|
||||
|
||||
// Abort conditions
|
||||
if ( ! $user || ! $role ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if user has role...
|
||||
if ( in_array( $role, (array) $user->roles ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Else...
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'fictioneer_is_admin' ) ) {
|
||||
/**
|
||||
* Checks if an user is an administrator
|
||||
@ -873,7 +844,10 @@ if ( ! function_exists( 'fictioneer_get_consent' ) && get_option( 'fictioneer_co
|
||||
*/
|
||||
|
||||
function fictioneer_get_consent() {
|
||||
if ( ! isset( $_COOKIE['fcn_cookie_consent'] ) || $_COOKIE['fcn_cookie_consent'] === '' ) return false;
|
||||
if ( ! isset( $_COOKIE['fcn_cookie_consent'] ) || $_COOKIE['fcn_cookie_consent'] === '' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strval( $_COOKIE['fcn_cookie_consent'] );
|
||||
}
|
||||
}
|
||||
@ -883,23 +857,37 @@ if ( ! function_exists( 'fictioneer_get_consent' ) && get_option( 'fictioneer_co
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Sanitizes an integer with options for default, minimum, and maximum
|
||||
* Sanitizes an integer with options for default, minimum, and maximum.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @param int $value The integer to be sanitized.
|
||||
* @param int $default Default value if an invalid integer. Default 0.
|
||||
* @param int|boolean $minimum Optional. Minimum value of the integer. Default false.
|
||||
* @param int|boolean $maximum Optional. Maximum value of the integer. Default false.
|
||||
* @param mixed $value The value to be sanitized.
|
||||
* @param int $default Default value if an invalid integer is provided. Default 0.
|
||||
* @param int $min Optional. Minimum value for the integer. Default is no minimum.
|
||||
* @param int $max Optional. Maximum value for the integer. Default is no maximum.
|
||||
*
|
||||
* @return int The sanitized integer.
|
||||
*/
|
||||
|
||||
function fictioneer_sanitize_integer( $value, $default = 0, $minimum = false, $maximum = false ) {
|
||||
function fictioneer_sanitize_integer( $value, $default = 0, $min = null, $max = null ) {
|
||||
// Ensure $value is numeric in the first place
|
||||
if ( ! is_numeric( $value ) ) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
// Cast to integer
|
||||
$value = (int) $value;
|
||||
if ( ! is_int( $value ) ) $value = $default;
|
||||
if ( $minimum !== false ) $value = max( $value, $minimum );
|
||||
if ( $maximum !== false ) $value = min( $value, $maximum );
|
||||
|
||||
// Apply minimum limit if specified
|
||||
if ( $min !== null && $value < $min ) {
|
||||
return $min;
|
||||
}
|
||||
|
||||
// Apply maximum limit if specified
|
||||
if ( $max !== null && $value > $max ) {
|
||||
return $max;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
@ -996,6 +984,7 @@ function fictioneer_ajax_get_auth() {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( get_option( 'fictioneer_enable_ajax_authentication' ) ) {
|
||||
add_action( 'wp_ajax_fictioneer_ajax_get_auth', 'fictioneer_ajax_get_auth' );
|
||||
add_action( 'wp_ajax_nopriv_fictioneer_ajax_get_auth', 'fictioneer_ajax_get_auth' );
|
||||
|
@ -62,7 +62,7 @@ if ( get_option( 'fictioneer_enable_sitemap' ) && ! fictioneer_seo_plugin_active
|
||||
function fictioneer_custom_excerpt_length( $length ) {
|
||||
return 64;
|
||||
}
|
||||
add_filter( 'excerpt_length', 'fictioneer_custom_excerpt_length', 999 );
|
||||
add_filter( 'excerpt_length', 'fictioneer_custom_excerpt_length' );
|
||||
|
||||
// =============================================================================
|
||||
// FIX EXCERPT FORMATTING
|
||||
@ -571,12 +571,16 @@ function fictioneer_add_lightbox_to_post_images( $content ) {
|
||||
if (
|
||||
str_contains( $classes . $parent_classes, 'no-auto-lightbox' ) ||
|
||||
$parent->hasAttribute( 'target' )
|
||||
) continue;
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
$parent->hasAttribute( 'href' ) &&
|
||||
! preg_match( '/(?<=\.jpg|jpeg|png|gif|webp|svg|avif|apng|tiff|ico)(?:$|[#?])/', $parent_href )
|
||||
) continue;
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$src = $img->getAttribute( 'src' );
|
||||
$id = preg_match( '/wp-image-([0-9]+)/i', $classes, $class_id );
|
||||
@ -680,7 +684,9 @@ if ( get_option( 'fictioneer_remove_wp_svg_filters' ) ) {
|
||||
*/
|
||||
|
||||
function fictioneer_embed_consent_wrappers( $content ) {
|
||||
if( empty( $content ) ) return $content;
|
||||
if ( empty( $content ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
libxml_use_internal_errors( true );
|
||||
$dom = new DOMDocument();
|
||||
|
@ -18,7 +18,9 @@ if ( ! function_exists( 'fictioneer_get_comment_toolbar' ) ) {
|
||||
if (
|
||||
! get_option( 'fictioneer_enable_comment_toolbar' ) ||
|
||||
get_option( 'fictioneer_disable_comment_bbcodes' )
|
||||
) return '';
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
// Start HTML ---> ?>
|
||||
|
@ -336,7 +336,9 @@ if ( ! function_exists( 'fictioneer_get_comment_action_link' ) ) {
|
||||
$comment_id = fictioneer_validate_id( $comment_id );
|
||||
|
||||
// Validation
|
||||
if ( ! $comment_id ) return false;
|
||||
if ( ! $comment_id ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Data
|
||||
$template = '<a class="comment-' . $action . '-link" href="%1$s">%2$s</a>';
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
function fictioneer_comment_login_to_reply( $link, $args, $comment, $post ) {
|
||||
// Return default if OAuth authentication is disabled
|
||||
if ( ! get_option( 'fictioneer_enable_oauth' ) ) return $link;
|
||||
if ( ! get_option( 'fictioneer_enable_oauth' ) ) {
|
||||
return $link;
|
||||
}
|
||||
|
||||
// Reply link or login modal toggle
|
||||
if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
|
||||
|
@ -100,7 +100,9 @@ function fictioneer_chapter_foreword( $args ) {
|
||||
$foreword = fictioneer_get_content_field( 'fictioneer_chapter_foreword', $args['chapter_id'] );
|
||||
|
||||
// Abort conditions
|
||||
if ( empty( $foreword ) || post_password_required() ) return '';
|
||||
if ( empty( $foreword ) || post_password_required() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Start HTML ---> ?>
|
||||
<section id="chapter-foreword" class="chapter__foreword infobox polygon clearfix"><?php echo $foreword; ?></section>
|
||||
@ -126,7 +128,9 @@ function fictioneer_chapter_warnings( $args ) {
|
||||
$warning_notes = fictioneer_get_field( 'fictioneer_chapter_warning_notes', $args['chapter_id'] );
|
||||
|
||||
// Abort conditions
|
||||
if ( ( ! $warning && ! $warning_notes ) || post_password_required() ) return '';
|
||||
if ( ( ! $warning && ! $warning_notes ) || post_password_required() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Start HTML ---> ?>
|
||||
<section id="chapter-warning" class="chapter__warning infobox infobox--warning polygon clearfix">
|
||||
@ -354,7 +358,9 @@ add_action( 'fictioneer_chapter_actions_bottom_center', 'fictioneer_chapter_inde
|
||||
|
||||
function fictioneer_chapter_bookmark_jump_button() {
|
||||
// Check if available
|
||||
if ( ! get_option( 'fictioneer_enable_bookmarks' ) ) return;
|
||||
if ( ! get_option( 'fictioneer_enable_bookmarks' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Start HTML ---> ?>
|
||||
<button type="button" class="button _secondary button--bookmark hidden">
|
||||
@ -405,7 +411,9 @@ function fictioneer_chapter_afterword( $args ) {
|
||||
$afterword = fictioneer_get_content_field( 'fictioneer_chapter_afterword', $args['chapter_id'] ); // ACF formatted output
|
||||
|
||||
// Abort conditions
|
||||
if ( empty( $afterword ) || post_password_required() ) return '';
|
||||
if ( empty( $afterword ) || post_password_required() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Start HTML ---> ?>
|
||||
<section id="chapter-afterword" class="chapter__afterword infobox polygon clearfix"><?php echo $afterword; ?></section>
|
||||
@ -500,7 +508,9 @@ function fictioneer_chapter_support_links( $args ) {
|
||||
$support_links = apply_filters( 'fictioneer_filter_chapter_support_links', $support_links, $args );
|
||||
|
||||
// Abort if no support links
|
||||
if ( count( $support_links ) < 1 ) return;
|
||||
if ( count( $support_links ) < 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Support message
|
||||
$support_message = get_the_author_meta( 'fictioneer_support_message', $author_id ) ? get_the_author_meta( 'fictioneer_support_message', $author_id ) : __( 'You can support the author on', 'fictioneer' );
|
||||
@ -614,7 +624,9 @@ add_action( 'fictioneer_chapter_after_main', 'fictioneer_chapter_paragraph_tools
|
||||
|
||||
function fictioneer_chapter_suggestion_tools() {
|
||||
// Abort if...
|
||||
if ( fictioneer_get_field( 'fictioneer_disable_commenting' ) || ! comments_open() ) return;
|
||||
if ( fictioneer_get_field( 'fictioneer_disable_commenting' ) || ! comments_open() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Start HTML ---> ?>
|
||||
<div id="selection-tools" class="invisible suggestion-tools">
|
||||
|
@ -146,7 +146,9 @@ function fictioneer_recommendation_links( $args ) {
|
||||
$links = fictioneer_get_field( 'fictioneer_recommendation_urls', $args['recommendation_id'] );
|
||||
|
||||
// Abort conditions...
|
||||
if ( ! $links ) return;
|
||||
if ( ! $links ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare
|
||||
$links = array_filter( explode( "\n", $links ) );
|
||||
@ -188,7 +190,9 @@ function fictioneer_recommendation_support_links( $args ) {
|
||||
$links = fictioneer_get_field( 'fictioneer_recommendation_support', $args['recommendation_id'] );
|
||||
|
||||
// Abort conditions...
|
||||
if ( ! $links ) return;
|
||||
if ( ! $links ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare
|
||||
$links = array_filter( explode( "\n", $links ) );
|
||||
|
@ -53,7 +53,9 @@ if ( ! function_exists( 'fictioneer_build_chapter_schema' ) ) {
|
||||
|
||||
function fictioneer_build_chapter_schema( $post_id ) {
|
||||
// Abort if...
|
||||
if ( ! $post_id ) return '';
|
||||
if ( ! $post_id ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Setup
|
||||
$schema = fictioneer_get_schema_node_root();
|
||||
|
@ -66,7 +66,9 @@ if ( ! function_exists( 'fictioneer_build_chapters_schema' ) ) {
|
||||
|
||||
function fictioneer_build_chapters_schema( $post_id ) {
|
||||
// Abort if...
|
||||
if ( ! $post_id ) return '';
|
||||
if ( ! $post_id ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prepare query arguments
|
||||
$query_args = array (
|
||||
|
@ -66,7 +66,9 @@ if ( ! function_exists( 'fictioneer_build_collections_schema' ) ) {
|
||||
|
||||
function fictioneer_build_collections_schema( $post_id ) {
|
||||
// Abort if...
|
||||
if ( ! $post_id ) return '';
|
||||
if ( ! $post_id ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prepare query arguments
|
||||
$query_args = array (
|
||||
|
@ -49,7 +49,9 @@ if ( ! function_exists( 'fictioneer_build_post_schema' ) ) {
|
||||
|
||||
function fictioneer_build_post_schema( $post_id ) {
|
||||
// Abort if...
|
||||
if ( ! $post_id ) return '';
|
||||
if ( ! $post_id ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Setup
|
||||
$schema = fictioneer_get_schema_node_root();
|
||||
|
@ -49,7 +49,9 @@ if ( ! function_exists( 'fictioneer_build_recommendation_schema' ) ) {
|
||||
|
||||
function fictioneer_build_recommendation_schema( $post_id ) {
|
||||
// Abort if...
|
||||
if ( ! $post_id ) return '';
|
||||
if ( ! $post_id ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Setup
|
||||
$schema = fictioneer_get_schema_node_root();
|
||||
|
@ -66,7 +66,9 @@ if ( ! function_exists( 'fictioneer_build_recommendations_schema' ) ) {
|
||||
|
||||
function fictioneer_build_recommendations_schema( $post_id ) {
|
||||
// Abort if...
|
||||
if ( ! $post_id ) return '';
|
||||
if ( ! $post_id ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prepare query arguments
|
||||
$query_args = array (
|
||||
|
@ -66,7 +66,9 @@ if ( ! function_exists( 'fictioneer_build_stories_schema' ) ) {
|
||||
|
||||
function fictioneer_build_stories_schema( $post_id ) {
|
||||
// Abort if...
|
||||
if ( ! $post_id ) return '';
|
||||
if ( ! $post_id ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prepare query arguments
|
||||
$query_args = array (
|
||||
|
@ -59,7 +59,9 @@ if ( ! function_exists( 'fictioneer_build_story_schema' ) ) {
|
||||
|
||||
function fictioneer_build_story_schema( $post_id ) {
|
||||
// Abort if...
|
||||
if ( ! $post_id ) return '';
|
||||
if ( ! $post_id ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Setup
|
||||
$schema = fictioneer_get_schema_node_root();
|
||||
|
@ -1043,7 +1043,9 @@ function fictioneer_validate_phrase_cookie_consent_banner( $input ) {
|
||||
$default = __( 'We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. Some features are not available without, but you can limit the site to strictly necessary cookies only. See <a href="[[privacy_policy_url]]" target="_blank" tabindex="1">Privacy Policy</a>.', 'fictioneer' );
|
||||
|
||||
// Return default if input is empty
|
||||
if ( ! is_string( $input ) ) return $default;
|
||||
if ( ! is_string( $input ) ) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
// Temporarily allow tabindex attribute
|
||||
$allowedtags['a']['tabindex'] = [];
|
||||
|
@ -229,7 +229,9 @@ function fictioneer_update_my_user_profile( $updated_user_id ) {
|
||||
$sender_is_owner = $sender_id === $updated_user_id;
|
||||
|
||||
// Make sure the sender is the profile owner unless it's an administrator
|
||||
if ( ! $sender_is_owner && ! $sender_is_admin ) return false;
|
||||
if ( ! $sender_is_owner && ! $sender_is_admin ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Profile flags...
|
||||
if ( $sender_is_owner || $sender_is_admin ) {
|
||||
|
@ -61,12 +61,18 @@ $hook_args = array(
|
||||
);
|
||||
|
||||
// Cached?
|
||||
if ( fictioneer_caching_active() && ! fictioneer_private_caching_active() ) $card_args['cache'] = true;
|
||||
if ( fictioneer_caching_active() && ! fictioneer_private_caching_active() ) {
|
||||
$card_args['cache'] = true;
|
||||
}
|
||||
|
||||
// Special conditions for chapters...
|
||||
if ( $type == 'fcn_chapter' ) {
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_no_chapter' ) ) continue;
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) continue;
|
||||
if (
|
||||
fictioneer_get_field( 'fictioneer_chapter_no_chapter' ) ||
|
||||
fictioneer_get_field( 'fictioneer_chapter_hidden' )
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Echo correct card
|
||||
|
@ -109,8 +109,12 @@ if ( ! empty( $items ) ) {
|
||||
|
||||
if ( ! empty( $chapters ) ) {
|
||||
foreach ( $chapters as $chapter ) {
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_no_chapter', $chapter->ID ) ) continue;
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter->ID ) ) continue;
|
||||
if (
|
||||
fictioneer_get_field( 'fictioneer_chapter_no_chapter', $chapter->ID ) ||
|
||||
fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter->ID )
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! in_array( $chapter->ID, $processed_ids ) ) {
|
||||
$chapter_count += 1;
|
||||
|
@ -95,7 +95,9 @@ $entries = fictioneer_shortcode_query( $query_args );
|
||||
$urls = array_filter( $urls );
|
||||
|
||||
// Abort if no links found
|
||||
if ( empty( $urls ) ) continue;
|
||||
if ( empty( $urls ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Extract first link
|
||||
$url = $urls[0];
|
||||
|
@ -96,19 +96,26 @@ $entries = fictioneer_shortcode_query( $query_args );
|
||||
$chapter_title; // Set inside inner loop
|
||||
|
||||
// Skip if no chapters
|
||||
if ( $story['chapter_count'] < 1 ) continue;
|
||||
if ( $story['chapter_count'] < 1 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Search for viable chapters...
|
||||
$search_list = array_reverse( $story['chapter_ids'] );
|
||||
|
||||
foreach ( $search_list as $chapter_id ) {
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter_id ) ) continue;
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter_id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$chapter_list[] = $chapter_id;
|
||||
break; // Only one needed
|
||||
}
|
||||
|
||||
// No viable chapters
|
||||
if ( count( $chapter_list ) < 1 ) continue;
|
||||
if ( count( $chapter_list ) < 1 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Count actually rendered cards to account for buffer
|
||||
if ( ++$card_counter > $args['count'] ) break;
|
||||
|
@ -96,22 +96,34 @@ $entries = fictioneer_shortcode_query( $query_args );
|
||||
$chapter_list = [];
|
||||
|
||||
// Skip if no chapters
|
||||
if ( $story['chapter_count'] < 1 ) continue;
|
||||
if ( $story['chapter_count'] < 1 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Search for viable chapters...
|
||||
$search_list = array_reverse( $story['chapter_ids'] );
|
||||
|
||||
foreach ( $search_list as $chapter_id ) {
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter_id ) ) continue;
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter_id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$chapter_list[] = $chapter_id;
|
||||
if ( count( $chapter_list ) > 1 ) break; // Max two
|
||||
|
||||
if ( count( $chapter_list ) > 1 ) {
|
||||
break; // Max two
|
||||
}
|
||||
}
|
||||
|
||||
// No viable chapters
|
||||
if ( count( $chapter_list ) < 1 ) continue;
|
||||
if ( count( $chapter_list ) < 1 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Count actually rendered cards to account for buffer
|
||||
if ( ++$card_counter > $args['count'] ) break;
|
||||
if ( ++$card_counter > $args['count'] ) {
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="card _small">
|
||||
|
@ -115,7 +115,9 @@ $disable_folding = fictioneer_get_field( 'fictioneer_story_disable_collapse' );
|
||||
$index = 1;
|
||||
|
||||
foreach ( $tab_pages as $page ) {
|
||||
if ( empty( $page[1] ) ) continue;
|
||||
if ( empty( $page[1] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
?>
|
||||
<section id="tab-page-<?php echo $index; ?>" class="story__tab-page padding-left padding-right content-section background-texture">
|
||||
@ -171,7 +173,9 @@ $disable_folding = fictioneer_get_field( 'fictioneer_story_disable_collapse' );
|
||||
$chapter_id = get_the_ID();
|
||||
|
||||
// Skip not visible chapters (redundant for paranoia)
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) continue;
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Data
|
||||
$group = fictioneer_get_field( 'fictioneer_chapter_group' );
|
||||
|
@ -23,7 +23,9 @@ defined( 'ABSPATH' ) OR exit;
|
||||
$current_user = $args['user'];
|
||||
|
||||
// Do not show for roles above subscriber
|
||||
if ( ! current_user_can( 'fcn_allow_self_delete' ) ) return;
|
||||
if ( ! current_user_can( 'fcn_allow_self_delete' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
@ -631,5 +631,39 @@ if ( get_option( 'fictioneer_enable_bookmarks' ) ) {
|
||||
add_action( 'wp_ajax_fictioneer_ajax_get_bookmarks', 'fictioneer_ajax_get_bookmarks' );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// CHECK USER CAPABILITIES
|
||||
// =============================================================================
|
||||
|
||||
if ( ! function_exists( 'fictioneer_has_role' ) ) {
|
||||
/**
|
||||
* Checks if an user has a specific role
|
||||
*
|
||||
* @since Fictioneer 5.0
|
||||
*
|
||||
* @param WP_User|int $user The user object or ID to check.
|
||||
* @param string $role The role to check for.
|
||||
*
|
||||
* @return boolean To be or not to be.
|
||||
*/
|
||||
|
||||
function fictioneer_has_role( $user, $role ) {
|
||||
// Setup
|
||||
$user = is_int( $user ) ? get_user_by( 'ID', $user ) : $user;
|
||||
|
||||
// Abort conditions
|
||||
if ( ! $user || ! $role ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if user has role...
|
||||
if ( in_array( $role, (array) $user->roles ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Else...
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -211,7 +211,9 @@ if ( $show_advanced ) {
|
||||
|
||||
foreach ( $queried_terms as $quad ) {
|
||||
// Skip if nothing has been queried
|
||||
if ( empty( $quad[0] ) ) continue;
|
||||
if ( empty( $quad[0] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Open wrapper
|
||||
echo "<span class='search-form__current-{$quad[2]}'>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user