From 8decd815d04b6fb12152a9e4fe1b3e39d07516a4 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:32:10 +0200 Subject: [PATCH] Add helper for skin translations What a sentence lol --- includes/functions/_helpers-templates.php | 25 +++++++++++++++++++++++ partials/account/_skins.php | 18 ++-------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/includes/functions/_helpers-templates.php b/includes/functions/_helpers-templates.php index 3bed85b9..dea84ac3 100644 --- a/includes/functions/_helpers-templates.php +++ b/includes/functions/_helpers-templates.php @@ -2725,3 +2725,28 @@ if ( FICTIONEER_LIST_SCHEDULED_CHAPTERS ) { add_filter( 'fictioneer_filter_allowed_chapter_permalinks', 'fictioneer_treat_scheduled_chapters_as_published' ); add_action( 'fictioneer_filter_chapters_added_statuses', 'fictioneer_treat_scheduled_chapters_as_published' ); } + +// ============================================================================= +// GET CUSTOM CSS SKIN TRANSLATIONS +// ============================================================================= + +/** + * Returns translations for the custom CSS skins (used in JS) + * + * @since 5.26.0 + * + * @return array The translations. + */ + +function fictioneer_get_skin_translations() { + return array( + 'wrongFileType' => _x( 'Wrong file type. Please upload a valid CSS file.', 'Custom CSS skin.', 'fictioneer' ), + 'invalidCss' => _x( 'Invalid file contents. Please check for missing braces ("{}") or forbidden characters ("<").', 'Custom CSS skin.', 'fictioneer' ), + 'missingMetaData' => _x( 'File is missing the "Name" meta data.', 'Custom CSS skin.', 'fictioneer' ), + 'tooManySkins' => _x( 'You cannot upload more than 3 skins.', 'Custom CSS skin.', 'fictioneer' ), + 'wrongFingerprint' => _x( 'Wrong or missing fingerprint hash.', 'Custom CSS skin.', 'fictioneer' ), + 'fileTooLarge' => _x( 'Maximum file size of 200 KB exceeded.', 'Custom CSS skin.', 'fictioneer' ), + 'invalidJson' => _x( 'Invalid JSON.', 'Custom CSS skin.', 'fictioneer' ), + 'error' => _x( 'Error.', 'Custom CSS skin.', 'fictioneer' ) + ); +} diff --git a/partials/account/_skins.php b/partials/account/_skins.php index a2361f53..98e96e2c 100644 --- a/partials/account/_skins.php +++ b/partials/account/_skins.php @@ -24,18 +24,6 @@ if ( ! isset( $_COOKIE['fcnLoggedIn'] ) ) { // Setup $current_user = $args['user']; -$template_download = esc_url( get_template_directory_uri() . '/css/skin-template.css' ); - -$translations = array( - 'wrongFileType' => _x( 'Wrong file type. Please upload a valid CSS file.', 'Custom CSS skin.', 'fictioneer' ), - 'invalidCss' => _x( 'Invalid file contents. Please check for missing braces ("{}") or forbidden characters ("<").', 'Custom CSS skin.', 'fictioneer' ), - 'missingMetaData' => _x( 'File is missing the "Name" meta data.', 'Custom CSS skin.', 'fictioneer' ), - 'tooManySkins' => _x( 'You cannot upload more than 3 skins.', 'Custom CSS skin.', 'fictioneer' ), - 'wrongFingerprint' => _x( 'Wrong or missing fingerprint hash.', 'Custom CSS skin.', 'fictioneer' ), - 'fileTooLarge' => _x( 'Maximum file size of 200 KB exceeded.', 'Custom CSS skin.', 'fictioneer' ), - 'invalidJson' => _x( 'Invalid JSON.', 'Custom CSS skin.', 'fictioneer' ), - 'error' => _x( 'Error.', 'Custom CSS skin.', 'fictioneer' ) -); ?> @@ -48,7 +36,7 @@ $translations = array(

download this template.', 'fictioneer' ), - $template_download + esc_url( get_template_directory_uri() . '/css/skin-template.css' ) ); ?>

@@ -74,9 +62,7 @@ $translations = array(
- +