FETCHMEDITATION
in package
Class FETCHMEDITATION
Table of Contents
Constants
- DEFAULT_BOOK = 'JFT'
- DEFAULT_LANGUAGE = 'English'
- DEFAULT_LAYOUT = 'block'
- DEFAULT_THEME = 'default'
- PLUG_SLUG = 'fetch-meditation'
- SETTINGS_GROUP = 'fetch-meditation-group'
Properties
- $instance : null|self
- Singleton instance of the class.
Methods
- __construct() : mixed
- Constructor method for initializing the plugin.
- create_menu() : void
- draw_settings() : void
- enqueue_backend_files() : void
- enqueue_frontend_files() : void
- get_instance() : self
- plugin_setup() : void
- Setup method for initializing the plugin.
- register_settings() : void
- render_jft_shortcode() : string
- Render JFT shortcode with book defaulted to 'jft' and theme to 'jft-style'
- render_shortcode() : string
- render_spad_shortcode() : string
- Render SPAD shortcode with book defaulted to 'spad' and theme to 'spad-style'
- settings_link() : array<string|int, mixed>
- build_layout() : string
- determine_option() : string
- Determines the option value based on the provided attributes or fallbacks to a default value.
- enqueue_theme_css() : void
- Enqueue the appropriate CSS file based on theme
- enum_case_to_code() : string
- Convert enum case name to language code
- enum_case_to_display() : string
- Convert enum case name to display name
- get_available_languages() : array<string|int, mixed>
- Get available languages for a book type
- get_language_enum() : JFTLanguage|SPADLanguage
- Get the appropriate language enum based on book type and language code
- get_user_friendly_message() : string
- Get a user-friendly error message based on the technical error.
- normalize_language_name() : string
- Normalize language name to match enum case names
- render_error_message() : string
- Render a user-friendly error message with fallback content.
- render_select_option() : string
Constants
DEFAULT_BOOK
private
mixed
DEFAULT_BOOK
= 'JFT'
DEFAULT_LANGUAGE
private
mixed
DEFAULT_LANGUAGE
= 'English'
DEFAULT_LAYOUT
private
mixed
DEFAULT_LAYOUT
= 'block'
DEFAULT_THEME
private
mixed
DEFAULT_THEME
= 'default'
PLUG_SLUG
private
mixed
PLUG_SLUG
= 'fetch-meditation'
SETTINGS_GROUP
private
mixed
SETTINGS_GROUP
= 'fetch-meditation-group'
Properties
$instance
Singleton instance of the class.
private
static null|self
$instance
= null
Methods
__construct()
Constructor method for initializing the plugin.
public
__construct() : mixed
create_menu()
public
static create_menu() : void
draw_settings()
public
static draw_settings() : void
enqueue_backend_files()
public
enqueue_backend_files(string $hook) : void
Parameters
- $hook : string
enqueue_frontend_files()
public
enqueue_frontend_files() : void
get_instance()
public
static get_instance() : self
Return values
selfplugin_setup()
Setup method for initializing the plugin.
public
plugin_setup() : void
This method checks if the current context is in the admin dashboard or not. If in the admin dashboard, it registers admin-related actions and settings. If not in the admin dashboard, it sets up a shortcode and associated actions.
register_settings()
public
static register_settings() : void
render_jft_shortcode()
Render JFT shortcode with book defaulted to 'jft' and theme to 'jft-style'
public
static render_jft_shortcode([string|array<string|int, mixed> $attrs = [] ]) : string
Parameters
- $attrs : string|array<string|int, mixed> = []
-
Shortcode attributes
Return values
string —Rendered shortcode content
render_shortcode()
public
static render_shortcode([string|array<string|int, mixed> $attrs = [] ]) : string
Parameters
- $attrs : string|array<string|int, mixed> = []
Return values
stringrender_spad_shortcode()
Render SPAD shortcode with book defaulted to 'spad' and theme to 'spad-style'
public
static render_spad_shortcode([string|array<string|int, mixed> $attrs = [] ]) : string
Parameters
- $attrs : string|array<string|int, mixed> = []
-
Shortcode attributes
Return values
string —Rendered shortcode content
settings_link()
public
static settings_link(array<string|int, mixed> $links) : array<string|int, mixed>
Parameters
- $links : array<string|int, mixed>
Return values
array<string|int, mixed>build_layout()
private
static build_layout(object $entry, bool $in_block) : string
Parameters
- $entry : object
- $in_block : bool
Return values
stringdetermine_option()
Determines the option value based on the provided attributes or fallbacks to a default value.
private
static determine_option(string|array<string|int, mixed> $attrs, string $option) : string
Parameters
- $attrs : string|array<string|int, mixed>
-
An string or associative array of attributes where the key is the option name.
- $option : string
-
The specific option to fetch (e.g., 'language', 'book', 'layout', 'theme').
Return values
string —Sanitized and lowercased value of the determined option.
enqueue_theme_css()
Enqueue the appropriate CSS file based on theme
private
static enqueue_theme_css(string $theme) : void
Parameters
- $theme : string
-
The theme to use
enum_case_to_code()
Convert enum case name to language code
private
static enum_case_to_code(string $case_name) : string
Parameters
- $case_name : string
-
The enum case name (e.g., 'PortuguesePT')
Return values
string —The language code (e.g., 'portuguese-pt')
enum_case_to_display()
Convert enum case name to display name
private
static enum_case_to_display(string $case_name) : string
Parameters
- $case_name : string
-
The enum case name (e.g., 'PortuguesePT')
Return values
string —The display name (e.g., 'Portuguese (PT)')
get_available_languages()
Get available languages for a book type
private
static get_available_languages(string $book) : array<string|int, mixed>
Parameters
- $book : string
-
The book type (jft or spad)
Return values
array<string|int, mixed> —Associative array of language code => display name
get_language_enum()
Get the appropriate language enum based on book type and language code
private
static get_language_enum(string $book, string $language) : JFTLanguage|SPADLanguage
Parameters
- $book : string
-
The book type (jft or spad)
- $language : string
-
The language code
Return values
JFTLanguage|SPADLanguage —The language enum
get_user_friendly_message()
Get a user-friendly error message based on the technical error.
private
static get_user_friendly_message(string $error_message, string $book, string $language) : string
Parameters
- $error_message : string
-
The technical error message
- $book : string
-
The book type
- $language : string
-
The selected language
Return values
string —User-friendly message
normalize_language_name()
Normalize language name to match enum case names
private
static normalize_language_name(string $language) : string
Parameters
- $language : string
-
The language code (e.g., 'portuguese-pt')
Return values
string —The normalized name (e.g., 'PortuguesePT')
render_error_message()
Render a user-friendly error message with fallback content.
private
static render_error_message(string $error_message, string $book, string $language) : string
Parameters
- $error_message : string
-
The error message from the library
- $book : string
-
The book type (jft or spad)
- $language : string
-
The selected language
Return values
string —HTML formatted error message
render_select_option()
private
static render_select_option(string $name, string $selected_value, array<string|int, mixed> $options) : string
Parameters
- $name : string
- $selected_value : string
- $options : array<string|int, mixed>