From 3c75b7b340f36f9ff34ded2c03cb80f0b42c2bfb Mon Sep 17 00:00:00 2001 From: Rafael Meneses Date: Fri, 3 Jan 2025 11:47:40 -0300 Subject: [PATCH 1/3] change class name --- functions.php | 13 +++--- includes/block-functions.php | 10 ++--- includes/tag-functions.php | 6 +-- ...tensions.php => CLTTG_BlockExtensions.php} | 6 +-- src/{Customizer.php => CLTTG_Customizer.php} | 16 +++---- ...reSniffer.php => CLTTG_FeatureSniffer.php} | 2 +- ...anel.php => CLTTG_FeatureSnifferPanel.php} | 6 +-- src/{Hooks.php => CLTTG_Hooks.php} | 6 +-- src/{Parser.php => CLTTG_Parser.php} | 4 +- src/{Plugin.php => CLTTG_Plugin.php} | 42 +++++++++---------- src/{Processor.php => CLTTG_Processor.php} | 2 +- ...{ThemeGarden.php => CLTTG_ThemeGarden.php} | 4 +- tumblr-theme-garden.php | 2 + 13 files changed, 61 insertions(+), 58 deletions(-) rename src/{BlockExtensions.php => CLTTG_BlockExtensions.php} (96%) rename src/{Customizer.php => CLTTG_Customizer.php} (97%) rename src/{FeatureSniffer.php => CLTTG_FeatureSniffer.php} (99%) rename src/{FeatureSnifferPanel.php => CLTTG_FeatureSnifferPanel.php} (89%) rename src/{Hooks.php => CLTTG_Hooks.php} (98%) rename src/{Parser.php => CLTTG_Parser.php} (99%) rename src/{Plugin.php => CLTTG_Plugin.php} (73%) rename src/{Processor.php => CLTTG_Processor.php} (92%) rename src/{ThemeGarden.php => CLTTG_ThemeGarden.php} (99%) diff --git a/functions.php b/functions.php index bcebd95..b539d9c 100644 --- a/functions.php +++ b/functions.php @@ -7,18 +7,19 @@ defined( 'ABSPATH' ) || exit; -use CupcakeLabs\TumblrThemeGarden\Plugin; +use CupcakeLabs\TumblrThemeGarden\CLTTG_Plugin; /** * Returns the plugin's main class instance. * - * @since 1.0.0 - * @version 1.0.0 + * @return CLTTG_Plugin + *@version 1.0.0 * - * @return Plugin + * @since 1.0.0 */ -function ttgarden_get_plugin_instance(): Plugin { - return Plugin::get_instance(); +function ttgarden_get_plugin_instance(): CLTTG_Plugin +{ + return CLTTG_Plugin::get_instance(); } /** diff --git a/includes/block-functions.php b/includes/block-functions.php index d57dbb0..65a9130 100644 --- a/includes/block-functions.php +++ b/includes/block-functions.php @@ -751,7 +751,7 @@ function ttgarden_block_quote( $atts, $content = '' ): string { // Stop on the first quote block. if ( 'core/quote' === $block['blockName'] ) { - $processor = new CupcakeLabs\TumblrThemeGarden\Processor( $block['innerHTML'] ); + $processor = new CupcakeLabs\TumblrThemeGarden\CLTTG_Processor( $block['innerHTML'] ); // Set bookmarks to extract HTML positions. while ( $processor->next_tag( @@ -1017,7 +1017,7 @@ function ttgarden_block_audio( $atts, $content = '' ): string { $provider = isset( $block['attrs']['providerName'] ) ? $block['attrs']['providerName'] : ''; $embed_html = isset( $block['attrs']['embedHtml'] ) ? $block['attrs']['embedHtml'] : ''; $embed_url = isset( $block['attrs']['src'] ) ? $block['attrs']['src'] : ''; - $processor = new CupcakeLabs\TumblrThemeGarden\Processor( $block['innerHTML'] ); + $processor = new CupcakeLabs\TumblrThemeGarden\CLTTG_Processor( $block['innerHTML'] ); // Set bookmarks to extract HTML positions. while ( $processor->next_tag( @@ -1218,7 +1218,7 @@ function ttgarden_block_video( $atts, $content = '' ): string { $can_autoplay_on_cellular = isset( $block['attrs']['canAutoplayOnCellular'] ) ? $block['attrs']['canAutoplayOnCellular'] : false; $duration = isset( $block['attrs']['mediaDuration'] ) ? $block['attrs']['mediaDuration'] : 0; - $processor = new CupcakeLabs\TumblrThemeGarden\Processor( $block['innerHTML'] ); + $processor = new CupcakeLabs\TumblrThemeGarden\CLTTG_Processor( $block['innerHTML'] ); // Set bookmarks to extract HTML positions. while ( $processor->next_tag( @@ -1337,7 +1337,7 @@ function ttgarden_block_photo( $atts, $content = '' ): string { $image_src = $image_src[0]; } else { // If the image source is not found, use the block's innerHTML. - $processor = new CupcakeLabs\TumblrThemeGarden\Processor( $block['innerHTML'] ); + $processor = new CupcakeLabs\TumblrThemeGarden\CLTTG_Processor( $block['innerHTML'] ); while ( $processor->next_tag( array( 'tag_name' => 'IMG' ) ) ) { $image_src = $processor->get_attribute( 'src' ); @@ -1408,7 +1408,7 @@ function ttgarden_block_photos( $atts, $content = '' ): string { $image_src = $image_src[0]; } else { // If the image source is not found, use the block's innerHTML. - $processor = new CupcakeLabs\TumblrThemeGarden\Processor( $block['innerHTML'] ); + $processor = new CupcakeLabs\TumblrThemeGarden\CLTTG_Processor( $block['innerHTML'] ); while ( $processor->next_tag( array( 'tag_name' => 'IMG' ) ) ) { $image_src = $processor->get_attribute( 'src' ); diff --git a/includes/tag-functions.php b/includes/tag-functions.php index 56bdb82..0526eef 100644 --- a/includes/tag-functions.php +++ b/includes/tag-functions.php @@ -10,7 +10,7 @@ /** * Handles inline replacement of lang: tags. * - * @see \CupcakeLabs\TumblrThemeGarden\Parser + * @see \CupcakeLabs\TumblrThemeGarden\CLTTG_Parser * * @param array $atts Array of shortcode attributes. * @@ -1118,7 +1118,7 @@ function ttgarden_tag_externalaudiourl(): string { // Test if the current context is an audio post and has a player. if ( isset( $context['audio'], $context['audio']['player'] ) ) { - $processor = new CupcakeLabs\TumblrThemeGarden\Processor( $context['audio']['player'] ); + $processor = new CupcakeLabs\TumblrThemeGarden\CLTTG_Processor( $context['audio']['player'] ); while ( $processor->next_tag( 'AUDIO' ) ) { $src = $processor->get_attribute( 'SRC' ); @@ -1895,7 +1895,7 @@ public function __construct( $id ) { $block ); - $processor = new CupcakeLabs\TumblrThemeGarden\Processor( $block_output ); + $processor = new CupcakeLabs\TumblrThemeGarden\CLTTG_Processor( $block_output ); // The standard block output won't work, we need to extract details from the block. while ( $processor->next_tag( diff --git a/src/BlockExtensions.php b/src/CLTTG_BlockExtensions.php similarity index 96% rename from src/BlockExtensions.php rename to src/CLTTG_BlockExtensions.php index 724c208..0f7ab83 100644 --- a/src/BlockExtensions.php +++ b/src/CLTTG_BlockExtensions.php @@ -1,6 +1,6 @@ admin_url( 'admin.php?page=' . ThemeGarden::ADMIN_MENU_SLUG ), + 'baseUrl' => admin_url( 'admin.php?page=' . CLTTG_ThemeGarden::ADMIN_MENU_SLUG ), ) ), 'before' @@ -80,7 +80,7 @@ public function enqueue_customizer_scripts(): void { */ public function tumblr_html_options( $wp_customize ): void { // Register the feature-sniffer panel type. - $wp_customize->register_panel_type( 'CupcakeLabs\TumblrThemeGarden\FeatureSnifferPanel' ); + $wp_customize->register_panel_type('CupcakeLabs\TumblrThemeGarden\CLTTG_FeatureSnifferPanel'); // Add Theme HTML section. $wp_customize->add_section( @@ -138,7 +138,7 @@ public function tumblr_html_options( $wp_customize ): void { /** * Filters response of WP_Customize_Panel::active(). * - * @param boolean $active Whether the Customizer panel is active. + * @param boolean $active Whether the CLTTG_Customizer panel is active. * @param WP_Customize_Panel $panel WP_Customize_Panel instance. * * @return boolean @@ -177,12 +177,12 @@ public function rename_panels( $wp_customize ): void { */ public function global_options( $wp_customize ): void { // Create a feature sniffer to detect unsupported features. - $features = new FeatureSniffer(); + $features = new CLTTG_FeatureSniffer(); if ( ! empty( $features->get_unsupported_features() ) ) { // Add our feature sniff panel. $wp_customize->add_panel( - new FeatureSnifferPanel( + new CLTTG_FeatureSnifferPanel( $this, 'feature_sniffer', array( diff --git a/src/FeatureSniffer.php b/src/CLTTG_FeatureSniffer.php similarity index 99% rename from src/FeatureSniffer.php rename to src/CLTTG_FeatureSniffer.php index 5d28933..7c5c4b4 100644 --- a/src/FeatureSniffer.php +++ b/src/CLTTG_FeatureSniffer.php @@ -14,7 +14,7 @@ * * @see WP_Customize_Panel */ -class FeatureSniffer { +class CLTTG_FeatureSniffer { /** * Array of (currently) unsupported features, noted by a null dependency. * Also an array of supported features that need an extra plugin to function, noted by a dependency array. diff --git a/src/FeatureSnifferPanel.php b/src/CLTTG_FeatureSnifferPanel.php similarity index 89% rename from src/FeatureSnifferPanel.php rename to src/CLTTG_FeatureSnifferPanel.php index 9b77b68..745bcb9 100644 --- a/src/FeatureSnifferPanel.php +++ b/src/CLTTG_FeatureSnifferPanel.php @@ -14,7 +14,7 @@ * * @see WP_Customize_Panel */ -class FeatureSnifferPanel extends \WP_Customize_Panel { +class CLTTG_FeatureSnifferPanel extends \WP_Customize_Panel { /** * Panel type. * @@ -34,7 +34,7 @@ class FeatureSnifferPanel extends \WP_Customize_Panel { * @since 4.9.0 */ protected function render_template() { - $features = new FeatureSniffer(); + $features = new CLTTG_FeatureSniffer(); ?>
  • {{ data.title }}

    @@ -42,4 +42,4 @@ protected function render_template() {
  • get_unsupported_features( 'plugins' ) ) ) { diff --git a/src/Parser.php b/src/CLTTG_Parser.php similarity index 99% rename from src/Parser.php rename to src/CLTTG_Parser.php index 3f083bc..bf2499d 100644 --- a/src/Parser.php +++ b/src/CLTTG_Parser.php @@ -12,7 +12,7 @@ /** * The Tumblr theme parser. */ -class Parser { +class CLTTG_Parser { /** * Supported keywords in lang: tags that trigger text replacements. @@ -67,7 +67,7 @@ class Parser { public int $position = 0; /** - * Initializes the Theme Parser. + * Initializes the Theme CLTTG_Parser. * * @since 1.0.0 * @version 1.0.0 diff --git a/src/Plugin.php b/src/CLTTG_Plugin.php similarity index 73% rename from src/Plugin.php rename to src/CLTTG_Plugin.php index 69022b4..c899c4e 100644 --- a/src/Plugin.php +++ b/src/CLTTG_Plugin.php @@ -1,6 +1,6 @@ ttgarden_active = 'tumblr-theme-garden' === get_option( 'template' ); // Setup all plugin hooks. - $this->hooks = new Hooks(); + $this->hooks = new CLTTG_Hooks(); $this->hooks->initialize( $this->ttgarden_active ); // Setup the customizer with default and custom theme options. - $this->customizer = new Customizer(); + $this->customizer = new CLTTG_Customizer(); $this->customizer->initialize( $this->ttgarden_active ); - $this->theme_garden = new ThemeGarden(); + $this->theme_garden = new CLTTG_ThemeGarden(); $this->theme_garden->initialize(); - $this->block_extensions = new BlockExtensions(); + $this->block_extensions = new CLTTG_BlockExtensions(); $this->block_extensions->initialize( $this->ttgarden_active ); // In the frontend, setup the parser. if ( ! is_admin() ) { - $this->parser = new Parser(); + $this->parser = new CLTTG_Parser(); $this->parser->initialize(); } } diff --git a/src/Processor.php b/src/CLTTG_Processor.php similarity index 92% rename from src/Processor.php rename to src/CLTTG_Processor.php index 4beb1b1..34c63d3 100644 --- a/src/Processor.php +++ b/src/CLTTG_Processor.php @@ -12,7 +12,7 @@ /** * This is a custom processor that extends the default WP_HTML_Tag_Processor. */ -class Processor extends \WP_HTML_Tag_Processor { +class CLTTG_Processor extends \WP_HTML_Tag_Processor { /** * A function to pull bookmark start and end points in a string. * diff --git a/src/ThemeGarden.php b/src/CLTTG_ThemeGarden.php similarity index 99% rename from src/ThemeGarden.php rename to src/CLTTG_ThemeGarden.php index 19c5b3a..13f9669 100644 --- a/src/ThemeGarden.php +++ b/src/CLTTG_ThemeGarden.php @@ -14,7 +14,7 @@ * * @package CupcakeLabs\TumblrThemeGarden */ -class ThemeGarden { +class CLTTG_ThemeGarden { const THEME_GARDEN_ENDPOINT = 'https://www.tumblr.com/api/v2/theme_garden'; const ADMIN_MENU_SLUG = 'tumblr-themes'; @@ -154,7 +154,7 @@ public function enqueue_assets( string $hook ): void { /** * Enqueues admin CSS. * - * @param string $version Plugin version. + * @param string $version CLTTG_Plugin version. * * @return void */ diff --git a/tumblr-theme-garden.php b/tumblr-theme-garden.php index 305177d..d07c0be 100644 --- a/tumblr-theme-garden.php +++ b/tumblr-theme-garden.php @@ -26,6 +26,8 @@ * Domain Path: /languages **/ +// The prefix CLTTG stands for Cupcake Labs Tumblr Theme Garden + defined( 'ABSPATH' ) || exit; // Define plugin constants. From 9288b730b8c6fdc6d85b6a35f86e748124a579e5 Mon Sep 17 00:00:00 2001 From: Rafael Meneses Date: Fri, 3 Jan 2025 11:55:07 -0300 Subject: [PATCH 2/3] change uppercase prefix --- functions.php | 12 ++++----- includes/tag-functions.php | 4 +-- src/CLTTG_Customizer.php | 6 ++--- src/CLTTG_Hooks.php | 4 +-- src/CLTTG_Parser.php | 16 +++++------ src/CLTTG_ThemeGarden.php | 18 ++++++------- tests/testShortcodeCoverage.php | 8 +++--- theme/tumblr-theme-garden/functions.php | 10 +++---- tumblr-theme-garden.php | 36 ++++++++++++------------- 9 files changed, 57 insertions(+), 57 deletions(-) diff --git a/functions.php b/functions.php index b539d9c..72d862a 100644 --- a/functions.php +++ b/functions.php @@ -31,7 +31,7 @@ function ttgarden_get_plugin_instance(): CLTTG_Plugin * @return string */ function ttgarden_get_plugin_slug(): string { - return sanitize_key( TTGARDEN_METADATA['TextDomain'] ); + return sanitize_key( CLTTG_METADATA['TextDomain'] ); } /** @@ -48,7 +48,7 @@ function ttgarden_get_plugin_slug(): string { * @return array|null */ function ttgarden_get_asset_meta( string $asset_path, ?array $extra_dependencies = null ): ?array { - if ( ! file_exists( $asset_path ) || ! str_starts_with( $asset_path, TTGARDEN_PATH ) ) { + if ( ! file_exists( $asset_path ) || ! str_starts_with( $asset_path, CLTTG_PATH ) ) { return null; } @@ -62,7 +62,7 @@ function ttgarden_get_asset_meta( string $asset_path, ?array $extra_dependencies 'version' => filemtime( $asset_path ), ); if ( false === $asset_meta['version'] ) { // Safeguard against filemtime() returning false. - $asset_meta['version'] = TTGARDEN_METADATA['Version']; + $asset_meta['version'] = CLTTG_METADATA['Version']; } } @@ -137,7 +137,7 @@ function ttgarden_normalize_option_name( $name ): string { str_replace( array_merge( array( ' ' ), - TTGARDEN_OPTIONS + CLTTG_OPTIONS ), '', $name @@ -155,5 +155,5 @@ function ttgarden_get_tumblr_regex(): string { } // Include tag and block hydration functions for each Tumblr Theme tag|block. -require TTGARDEN_PATH . 'includes/block-functions.php'; -require TTGARDEN_PATH . 'includes/tag-functions.php'; +require CLTTG_PATH . 'includes/block-functions.php'; +require CLTTG_PATH . 'includes/tag-functions.php'; diff --git a/includes/tag-functions.php b/includes/tag-functions.php index 0526eef..b3d057a 100644 --- a/includes/tag-functions.php +++ b/includes/tag-functions.php @@ -63,7 +63,7 @@ function ttgarden_tag_lang( $atts ): string { // If keywords are found, return the language string with keyword replacements. return vsprintf( - ( is_array( TTGARDEN_LANG[ $atts['key'] ] ) ) ? TTGARDEN_LANG[ $atts['key'] ][1] : TTGARDEN_LANG[ $atts['key'] ], + ( is_array( CLTTG_LANG[ $atts['key'] ] ) ) ? CLTTG_LANG[ $atts['key'] ][1] : CLTTG_LANG[ $atts['key'] ], array_map( function ( $callback ) { return call_user_func( $callback ); @@ -653,7 +653,7 @@ function ttgarden_tagsasclasses(): string { * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ function ttgarden_tag_pinnedpostlabel(): string { - return esc_html( TTGARDEN_LANG['lang:pinned post'] ); + return esc_html( CLTTG_LANG['lang:pinned post'] ); } add_shortcode( 'tag_pinnedpostlabel', 'ttgarden_tag_pinnedpostlabel' ); diff --git a/src/CLTTG_Customizer.php b/src/CLTTG_Customizer.php index a676989..c3376bd 100644 --- a/src/CLTTG_Customizer.php +++ b/src/CLTTG_Customizer.php @@ -43,11 +43,11 @@ public function initialize( $is_ttgarden_active ): void { * @return void */ public function enqueue_customizer_scripts(): void { - $deps = ttgarden_get_asset_meta( TTGARDEN_PATH . 'assets/js/build/customizer.asset.php' ); + $deps = ttgarden_get_asset_meta( CLTTG_PATH . 'assets/js/build/customizer.asset.php' ); wp_enqueue_script( 'tumblr-theme-garden-customizer', - TTGARDEN_URL . 'assets/js/build/customizer.js', + CLTTG_URL . 'assets/js/build/customizer.js', $deps['dependencies'], $deps['version'], true @@ -55,7 +55,7 @@ public function enqueue_customizer_scripts(): void { wp_enqueue_style( 'tumblr-theme-garden-customizer', - TTGARDEN_URL . 'assets/js/build/customizer.css', + CLTTG_URL . 'assets/js/build/customizer.css', array(), $deps['version'] ); diff --git a/src/CLTTG_Hooks.php b/src/CLTTG_Hooks.php index e6c586c..7547fba 100644 --- a/src/CLTTG_Hooks.php +++ b/src/CLTTG_Hooks.php @@ -116,10 +116,10 @@ public function theme_root( $root ): string { if ( $this->is_ttgarden_active ) { // Register the theme directory if it hasn't been registered yet. if ( null === $registered || false === $registered ) { - $registered = register_theme_directory( TTGARDEN_PATH . 'theme' ); + $registered = register_theme_directory( CLTTG_PATH . 'theme' ); } - return TTGARDEN_PATH . 'theme'; + return CLTTG_PATH . 'theme'; } return $root; diff --git a/src/CLTTG_Parser.php b/src/CLTTG_Parser.php index bf2499d..b3f5ad0 100644 --- a/src/CLTTG_Parser.php +++ b/src/CLTTG_Parser.php @@ -145,10 +145,10 @@ public function apply_modifier( $output, $modifier ): string { * @return string Parsed content. */ public function parse_theme( $content ): string { - $tags = array_map( 'strtolower', TTGARDEN_TAGS ); - $blocks = array_map( 'strtolower', TTGARDEN_BLOCKS ); - $options = array_map( 'strtolower', TTGARDEN_OPTIONS ); - $modifiers = array_map( 'strtolower', TTGARDEN_MODIFIERS ); + $tags = array_map( 'strtolower', CLTTG_TAGS ); + $blocks = array_map( 'strtolower', CLTTG_BLOCKS ); + $options = array_map( 'strtolower', CLTTG_OPTIONS ); + $modifiers = array_map( 'strtolower', CLTTG_MODIFIERS ); /** * Before parsing, clean out comments that could contain tags and cause issues, e.g unbalanced blocks. @@ -178,7 +178,7 @@ function ( $matches ) use ( $tags, $blocks, $options, $modifiers ) { * * @return string */ - if ( array_key_exists( strtolower( $matches[1] ), TTGARDEN_LANG ) ) { + if ( array_key_exists( strtolower( $matches[1] ), CLTTG_LANG ) ) { return $this->language_helper( strtolower( $matches[1] ) ); } @@ -267,7 +267,7 @@ function ( $matches ) use ( $tags, $blocks, $options, $modifiers ) { * Second: Use the new regex to find and replace the unsupported tags and blocks with an empty string. * Third: Run the content through the shortcode parser to kick-off page creation. */ - $pattern = get_shortcode_regex( array_merge( TTGARDEN_MISSING_BLOCKS, TTGARDEN_MISSING_TAGS ) ); + $pattern = get_shortcode_regex( array_merge( CLTTG_MISSING_BLOCKS, CLTTG_MISSING_TAGS ) ); $content = ttgarden_do_shortcode( preg_replace_callback( "/$pattern/", '__return_empty_string', $content ) ); $content = preg_replace( '/(\[\/[a-zA-z\d]*?\])/', '', $content ); @@ -289,7 +289,7 @@ public function block_fixer( $block ): string { error_log( $block . ' is a duplicate block opener. Found at position ' . $this->position . PHP_EOL, 3, - TTGARDEN_PATH . 'parser.log' + CLTTG_PATH . 'parser.log' ); $block = '/' . $block; @@ -323,7 +323,7 @@ public function language_helper( $key ): string { } // If no keywords are found, return the shortcode with a set value. - return '[tag_lang value="' . TTGARDEN_LANG[ $key ] . '"]'; + return '[tag_lang value="' . CLTTG_LANG[ $key ] . '"]'; } /** diff --git a/src/CLTTG_ThemeGarden.php b/src/CLTTG_ThemeGarden.php index 13f9669..c69e03b 100644 --- a/src/CLTTG_ThemeGarden.php +++ b/src/CLTTG_ThemeGarden.php @@ -79,7 +79,7 @@ public function initialize(): void { */ public function enqueue_assets( string $hook ): void { if ( 'appearance_page_' . self::ADMIN_MENU_SLUG === $hook ) { - $deps = ttgarden_get_asset_meta( TTGARDEN_PATH . 'assets/js/build/theme-garden.asset.php' ); + $deps = ttgarden_get_asset_meta( CLTTG_PATH . 'assets/js/build/theme-garden.asset.php' ); $this->enqueue_admin_styles( $deps['version'] ); @@ -90,7 +90,7 @@ public function enqueue_assets( string $hook ): void { wp_enqueue_script( 'tumblr-theme-garden', - TTGARDEN_URL . 'assets/js/build/theme-garden.js', + CLTTG_URL . 'assets/js/build/theme-garden.js', $deps['dependencies'], $deps['version'], true @@ -100,7 +100,7 @@ public function enqueue_assets( string $hook ): void { 'tumblr-theme-garden', 'const themeGardenData = ' . wp_json_encode( array( - 'logoUrl' => TTGARDEN_URL . 'assets/images/tumblr_logo_icon.png', + 'logoUrl' => CLTTG_URL . 'assets/images/tumblr_logo_icon.png', 'customizeUrl' => wp_customize_url(), 'themes' => $themes_and_categories['themes'], 'categories' => $themes_and_categories['categories'], @@ -117,13 +117,13 @@ public function enqueue_assets( string $hook ): void { } if ( 'theme-install.php' === $hook ) { - $deps = ttgarden_get_asset_meta( TTGARDEN_PATH . 'assets/js/build/theme-install.asset.php' ); + $deps = ttgarden_get_asset_meta( CLTTG_PATH . 'assets/js/build/theme-install.asset.php' ); $this->enqueue_admin_styles( $deps['version'] ); wp_enqueue_script( 'tumblr-theme-install', - TTGARDEN_URL . 'assets/js/build/theme-install.js', + CLTTG_URL . 'assets/js/build/theme-install.js', $deps['dependencies'], $deps['version'], true @@ -144,7 +144,7 @@ public function enqueue_assets( string $hook ): void { if ( 'themes.php' === $hook ) { wp_enqueue_style( 'tumblr-theme-garden-admin', - TTGARDEN_URL . 'assets/css/build/themes.css', + CLTTG_URL . 'assets/css/build/themes.css', array(), time() ); @@ -161,7 +161,7 @@ public function enqueue_assets( string $hook ): void { public function enqueue_admin_styles( $version ): void { wp_enqueue_style( 'tumblr-theme-garden', - TTGARDEN_URL . 'assets/css/build/admin.css', + CLTTG_URL . 'assets/css/build/admin.css', array(), $version ); @@ -198,7 +198,7 @@ public function get_theme( string $theme_id ) { */ public function register_rest_routes(): void { register_rest_route( - TTGARDEN_REST_NAMESPACE, + CLTTG_REST_NAMESPACE, '/themes', array( 'methods' => 'GET', @@ -210,7 +210,7 @@ public function register_rest_routes(): void { ); register_rest_route( - TTGARDEN_REST_NAMESPACE, + CLTTG_REST_NAMESPACE, '/theme', array( 'methods' => 'GET', diff --git a/tests/testShortcodeCoverage.php b/tests/testShortcodeCoverage.php index c331c88..4eb60cd 100644 --- a/tests/testShortcodeCoverage.php +++ b/tests/testShortcodeCoverage.php @@ -14,8 +14,8 @@ class TestShortcodeCoverage extends WP_UnitTestCase { * A single example test. */ public function test_tag_coverage() { - $tags = TTGARDEN_TAGS; - $missing_tags = TTGARDEN_MISSING_TAGS; + $tags = CLTTG_TAGS; + $missing_tags = CLTTG_MISSING_TAGS; // Arrays to store tags with and without shortcodes. $tags_with_shortcodes = array(); @@ -56,8 +56,8 @@ public function test_tag_coverage() { } public function test_block_coverage() { - $blocks = TTGARDEN_BLOCKS; - $missing_blocks = TTGARDEN_MISSING_BLOCKS; + $blocks = CLTTG_BLOCKS; + $missing_blocks = CLTTG_MISSING_BLOCKS; // Arrays to store blocks with and without shortcodes. $blocks_with_shortcodes = array(); diff --git a/theme/tumblr-theme-garden/functions.php b/theme/tumblr-theme-garden/functions.php index 22f266f..1345c66 100644 --- a/theme/tumblr-theme-garden/functions.php +++ b/theme/tumblr-theme-garden/functions.php @@ -16,11 +16,11 @@ * @return void */ function ttgarden_enqueue_block_editor_assets(): void { - $deps = ttgarden_get_asset_meta( TTGARDEN_PATH . 'assets/js/build/editor.asset.php' ); + $deps = ttgarden_get_asset_meta( CLTTG_PATH . 'assets/js/build/editor.asset.php' ); wp_enqueue_script( 'cupcakelabs-tumblr-theme-garden', - TTGARDEN_URL . 'assets/js/build/editor.js', + CLTTG_URL . 'assets/js/build/editor.js', $deps['dependencies'], $deps['version'], true @@ -28,7 +28,7 @@ function ttgarden_enqueue_block_editor_assets(): void { wp_enqueue_style( 'cupcakelabs-tumblr-theme-garden', - TTGARDEN_URL . 'assets/js/build/editor.css', + CLTTG_URL . 'assets/js/build/editor.css', array(), $deps['version'] ); @@ -84,9 +84,9 @@ function ttgarden_theme_support(): void { function ttgarden_enqueue_scripts(): void { wp_enqueue_style( 'tumblr-theme-garden-style', - TTGARDEN_URL . 'assets/css/build/index.css', + CLTTG_URL . 'assets/css/build/index.css', array(), - TTGARDEN_METADATA['Version'] + CLTTG_METADATA['Version'] ); } add_action( 'wp_enqueue_scripts', 'ttgarden_enqueue_scripts' ); diff --git a/tumblr-theme-garden.php b/tumblr-theme-garden.php index d07c0be..326210e 100644 --- a/tumblr-theme-garden.php +++ b/tumblr-theme-garden.php @@ -32,40 +32,40 @@ // Define plugin constants. function_exists( 'get_plugin_data' ) || require_once ABSPATH . 'wp-admin/includes/plugin.php'; -define( 'TTGARDEN_METADATA', get_plugin_data( __FILE__, false, false ) ); +define( 'CLTTG_METADATA', get_plugin_data( __FILE__, false, false ) ); -define( 'TTGARDEN_BASENAME', plugin_basename( __FILE__ ) ); -define( 'TTGARDEN_PATH', plugin_dir_path( __FILE__ ) ); -define( 'TTGARDEN_URL', plugin_dir_url( __FILE__ ) ); +define( 'CLTTG_BASENAME', plugin_basename( __FILE__ ) ); +define( 'CLTTG_PATH', plugin_dir_path( __FILE__ ) ); +define( 'CLTTG_URL', plugin_dir_url( __FILE__ ) ); // Define REST API namespace. -define( 'TTGARDEN_REST_NAMESPACE', 'tumblr-theme-garden/v1' ); +define( 'CLTTG_REST_NAMESPACE', 'tumblr-theme-garden/v1' ); // Define tag and block names from Tumblr Theme language. -define( 'TTGARDEN_TAGS', require_once TTGARDEN_PATH . 'includes/tumblr-theme-language/tags.php' ); -define( 'TTGARDEN_BLOCKS', require_once TTGARDEN_PATH . 'includes/tumblr-theme-language/blocks.php' ); -define( 'TTGARDEN_OPTIONS', require_once TTGARDEN_PATH . 'includes/tumblr-theme-language/options.php' ); -define( 'TTGARDEN_MODIFIERS', require_once TTGARDEN_PATH . 'includes/tumblr-theme-language/modifiers.php' ); -define( 'TTGARDEN_MISSING_BLOCKS', require_once TTGARDEN_PATH . 'includes/tumblr-theme-language/missing-blocks.php' ); -define( 'TTGARDEN_MISSING_TAGS', require_once TTGARDEN_PATH . 'includes/tumblr-theme-language/missing-tags.php' ); +define( 'CLTTG_TAGS', require_once CLTTG_PATH . 'includes/tumblr-theme-language/tags.php' ); +define( 'CLTTG_BLOCKS', require_once CLTTG_PATH . 'includes/tumblr-theme-language/blocks.php' ); +define( 'CLTTG_OPTIONS', require_once CLTTG_PATH . 'includes/tumblr-theme-language/options.php' ); +define( 'CLTTG_MODIFIERS', require_once CLTTG_PATH . 'includes/tumblr-theme-language/modifiers.php' ); +define( 'CLTTG_MISSING_BLOCKS', require_once CLTTG_PATH . 'includes/tumblr-theme-language/missing-blocks.php' ); +define( 'CLTTG_MISSING_TAGS', require_once CLTTG_PATH . 'includes/tumblr-theme-language/missing-tags.php' ); -$lang = require_once TTGARDEN_PATH . 'includes/tumblr-theme-language/lang.php'; -define( 'TTGARDEN_LANG', array_change_key_case( $lang, CASE_LOWER ) ); +$lang = require_once CLTTG_PATH . 'includes/tumblr-theme-language/lang.php'; +define( 'CLTTG_LANG', array_change_key_case( $lang, CASE_LOWER ) ); // Load plugin translations so they are available even for the error admin notices. add_action( 'init', static function () { load_plugin_textdomain( - TTGARDEN_METADATA['TextDomain'], + CLTTG_METADATA['TextDomain'], false, - dirname( TTGARDEN_BASENAME ) . TTGARDEN_METADATA['DomainPath'] + dirname( CLTTG_BASENAME ) . CLTTG_METADATA['DomainPath'] ); } ); // Load the autoloader. -if ( ! is_file( TTGARDEN_PATH . '/vendor/autoload.php' ) ) { +if ( ! is_file( CLTTG_PATH . '/vendor/autoload.php' ) ) { add_action( 'admin_notices', static function () { @@ -76,7 +76,7 @@ static function () { ); return; } -require_once TTGARDEN_PATH . '/vendor/autoload.php'; +require_once CLTTG_PATH . '/vendor/autoload.php'; /** * On activation, setup the plugin options. @@ -111,5 +111,5 @@ static function () { } ); -require_once TTGARDEN_PATH . 'functions.php'; +require_once CLTTG_PATH . 'functions.php'; add_action( 'plugins_loaded', array( ttgarden_get_plugin_instance(), 'initialize' ) ); From b88bd7e6bcbb6a6a1c4d556d9736d958733c9e32 Mon Sep 17 00:00:00 2001 From: Rafael Meneses Date: Fri, 3 Jan 2025 12:40:13 -0300 Subject: [PATCH 3/3] change lowercase prefix --- .phpcs.xml | 2 +- assets/js/build/theme-install.js | 2 +- assets/js/src/theme-install.js | 6 +- functions.php | 24 +- includes/block-functions.php | 718 ++++++++++++------------ includes/tag-functions.php | 692 +++++++++++------------ src/CLTTG_BlockExtensions.php | 12 +- src/CLTTG_Customizer.php | 68 +-- src/CLTTG_FeatureSniffer.php | 4 +- src/CLTTG_Hooks.php | 28 +- src/CLTTG_Parser.php | 38 +- src/CLTTG_Plugin.php | 10 +- src/CLTTG_ThemeGarden.php | 26 +- theme/tumblr-theme-garden/comments.php | 2 +- theme/tumblr-theme-garden/functions.php | 46 +- theme/tumblr-theme-garden/index.php | 16 +- tumblr-theme-garden.php | 22 +- 17 files changed, 858 insertions(+), 858 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index 4d4327b..b8799ce 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -89,7 +89,7 @@ - + diff --git a/assets/js/build/theme-install.js b/assets/js/build/theme-install.js index ce7c5a5..f7fd5af 100644 --- a/assets/js/build/theme-install.js +++ b/assets/js/build/theme-install.js @@ -1 +1 @@ -window.addEventListener("DOMContentLoaded",(function(){const t=document.getElementById("wpbody-content").getElementsByClassName("filter-links"),e=function(){window.location=ttgardenInstall.browseUrl};if(t[0]&&"ul"===t[0].tagName.toLowerCase()){const n=t[0],l=document.createElement("li"),a=document.createElement("button");l.setAttribute("class","tumblr-theme-garden-list-item"),a.setAttribute("title",ttgardenInstall.buttonText),a.addEventListener("click",e),a.setAttribute("class","tumblr-theme-garden-link"),l.appendChild(a),n.appendChild(l)}}),!1); \ No newline at end of file +window.addEventListener("DOMContentLoaded",(function(){const t=document.getElementById("wpbody-content").getElementsByClassName("filter-links"),e=function(){window.location=clttgInstall.browseUrl};if(t[0]&&"ul"===t[0].tagName.toLowerCase()){const n=t[0],l=document.createElement("li"),a=document.createElement("button");l.setAttribute("class","tumblr-theme-garden-list-item"),a.setAttribute("title",clttgInstall.buttonText),a.addEventListener("click",e),a.setAttribute("class","tumblr-theme-garden-link"),l.appendChild(a),n.appendChild(l)}}),!1); diff --git a/assets/js/src/theme-install.js b/assets/js/src/theme-install.js index 2139947..7e93086 100644 --- a/assets/js/src/theme-install.js +++ b/assets/js/src/theme-install.js @@ -1,4 +1,4 @@ -/* global ttgardenInstall */ +/* global clttgInstall */ window.addEventListener( 'DOMContentLoaded', function () { @@ -6,7 +6,7 @@ window.addEventListener( const filterLinks = body.getElementsByClassName( 'filter-links' ); const handleClick = function () { - window.location = ttgardenInstall.browseUrl; + window.location = clttgInstall.browseUrl; }; if ( filterLinks[ 0 ] && filterLinks[ 0 ].tagName.toLowerCase() === 'ul' ) { @@ -14,7 +14,7 @@ window.addEventListener( const listItem = document.createElement( 'li' ); const link = document.createElement( 'button' ); listItem.setAttribute( 'class', 'tumblr-theme-garden-list-item' ); - link.setAttribute( 'title', ttgardenInstall.buttonText ); + link.setAttribute( 'title', clttgInstall.buttonText ); link.addEventListener( 'click', handleClick ); link.setAttribute( 'class', 'tumblr-theme-garden-link' ); listItem.appendChild( link ); diff --git a/functions.php b/functions.php index 72d862a..296e10c 100644 --- a/functions.php +++ b/functions.php @@ -17,7 +17,7 @@ * * @since 1.0.0 */ -function ttgarden_get_plugin_instance(): CLTTG_Plugin +function clttg_get_plugin_instance(): CLTTG_Plugin { return CLTTG_Plugin::get_instance(); } @@ -30,7 +30,7 @@ function ttgarden_get_plugin_instance(): CLTTG_Plugin * * @return string */ -function ttgarden_get_plugin_slug(): string { +function clttg_get_plugin_slug(): string { return sanitize_key( CLTTG_METADATA['TextDomain'] ); } @@ -47,7 +47,7 @@ function ttgarden_get_plugin_slug(): string { * * @return array|null */ -function ttgarden_get_asset_meta( string $asset_path, ?array $extra_dependencies = null ): ?array { +function clttg_get_asset_meta( string $asset_path, ?array $extra_dependencies = null ): ?array { if ( ! file_exists( $asset_path ) || ! str_starts_with( $asset_path, CLTTG_PATH ) ) { return null; } @@ -83,7 +83,7 @@ function ttgarden_get_asset_meta( string $asset_path, ?array $extra_dependencies * * @return string The parsed content. */ -function ttgarden_do_shortcode( $content ): string { +function clttg_do_shortcode( $content ): string { global $shortcode_tags; static $pattern = null; @@ -107,9 +107,9 @@ function ttgarden_do_shortcode( $content ): string { * * @return array|null|string The current parse context. */ -function ttgarden_get_parse_context() { - global $ttgarden_parse_context; - return $ttgarden_parse_context; +function clttg_get_parse_context() { + global $clttg_parse_context; + return $clttg_parse_context; } /** @@ -120,9 +120,9 @@ function ttgarden_get_parse_context() { * * @return void */ -function ttgarden_set_parse_context( $key, $value ): void { - global $ttgarden_parse_context; - $ttgarden_parse_context = array( $key => $value ); +function clttg_set_parse_context( $key, $value ): void { + global $clttg_parse_context; + $clttg_parse_context = array( $key => $value ); } /** @@ -132,7 +132,7 @@ function ttgarden_set_parse_context( $key, $value ): void { * * @return string The normalized name. */ -function ttgarden_normalize_option_name( $name ): string { +function clttg_normalize_option_name( $name ): string { return strtolower( str_replace( array_merge( @@ -150,7 +150,7 @@ function ttgarden_normalize_option_name( $name ): string { * * @return string The Tumblr Theme Garden regex. */ -function ttgarden_get_tumblr_regex(): string { +function clttg_get_tumblr_regex(): string { return '/\{([a-zA-Z0-9][a-zA-Z0-9\\-\/=" ]*|font\:[a-zA-Z0-9 ]+|text\:[a-zA-Z0-9 ]+|select\:[a-zA-Z0-9 ]+|image\:[a-zA-Z0-9 ]+|color\:[a-zA-Z0-9 ]+|RGBcolor\:[a-zA-Z0-9 ]+|lang\:[a-zA-Z0-9- ]+|[\/]?block\:[a-zA-Z0-9]+( [a-zA-Z0-9=" ]+)*)\}/i'; } diff --git a/includes/block-functions.php b/includes/block-functions.php index 65a9130..c50a7db 100644 --- a/includes/block-functions.php +++ b/includes/block-functions.php @@ -25,7 +25,7 @@ * * @return string */ -function ttgarden_block_groupmembers( $atts, $content = '' ): string { +function clttg_block_groupmembers( $atts, $content = '' ): string { // Get all users who have published posts $authors = get_users( array( @@ -36,14 +36,14 @@ function ttgarden_block_groupmembers( $atts, $content = '' ): string { // Check if there is more than one author if ( count( $authors ) > 1 ) { - ttgarden_set_parse_context( 'groupmembers', $authors ); - $output = ttgarden_do_shortcode( $content ); - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'groupmembers', $authors ); + $output = clttg_do_shortcode( $content ); + clttg_set_parse_context( 'theme', true ); } return $output; } -add_shortcode( 'block_groupmembers', 'ttgarden_block_groupmembers' ); +add_shortcode( 'block_groupmembers', 'clttg_block_groupmembers' ); /** * Loops over all group members and parses shortcodes within the block. @@ -53,8 +53,8 @@ function ttgarden_block_groupmembers( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_groupmember( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_groupmember( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); $output = ''; if ( isset( $context['groupmembers'] ) ) { @@ -62,16 +62,16 @@ function ttgarden_block_groupmember( $atts, $content = '' ): string { // Loop over each blog author. foreach ( $authors as $author ) { - ttgarden_set_parse_context( 'groupmember', $author ); - $output .= ttgarden_do_shortcode( $content ); + clttg_set_parse_context( 'groupmember', $author ); + $output .= clttg_do_shortcode( $content ); } - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); } return $output; } -add_shortcode( 'block_groupmember', 'ttgarden_block_groupmember' ); +add_shortcode( 'block_groupmember', 'clttg_block_groupmember' ); /** * Outputs content if the twitter username theme set is not empty. @@ -81,10 +81,10 @@ function ttgarden_block_groupmember( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_twitter( $atts, $content = '' ): string { - return ( '' !== get_theme_mod( 'twitter_username', '' ) ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_twitter( $atts, $content = '' ): string { + return ( '' !== get_theme_mod( 'twitter_username', '' ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_twitter', 'ttgarden_block_twitter' ); +add_shortcode( 'block_twitter', 'clttg_block_twitter' ); /** * Boolean check for theme options. @@ -94,7 +94,7 @@ function ttgarden_block_twitter( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_if_theme_option( $atts, $content = '' ): string { +function clttg_block_if_theme_option( $atts, $content = '' ): string { // Parse shortcode attributes. $atts = shortcode_atts( array( @@ -109,9 +109,9 @@ function ttgarden_block_if_theme_option( $atts, $content = '' ): string { return ''; } - return ( get_theme_mod( $atts['name'] ) ) ? ttgarden_do_shortcode( $content ) : ''; + return ( get_theme_mod( $atts['name'] ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_if_theme_option', 'ttgarden_block_if_theme_option' ); +add_shortcode( 'block_if_theme_option', 'clttg_block_if_theme_option' ); /** * Boolean check for theme options. @@ -121,7 +121,7 @@ function ttgarden_block_if_theme_option( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_ifnot_theme_option( $atts, $content = '' ): string { +function clttg_block_ifnot_theme_option( $atts, $content = '' ): string { // Parse shortcode attributes. $atts = shortcode_atts( array( @@ -136,9 +136,9 @@ function ttgarden_block_ifnot_theme_option( $atts, $content = '' ): string { return ''; } - return ( ! get_theme_mod( $atts['name'] ) ) ? ttgarden_do_shortcode( $content ) : ''; + return ( ! get_theme_mod( $atts['name'] ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_ifnot_theme_option', 'ttgarden_block_ifnot_theme_option' ); +add_shortcode( 'block_ifnot_theme_option', 'clttg_block_ifnot_theme_option' ); /** * Conditional check for if we're in the loop. @@ -149,15 +149,15 @@ function ttgarden_block_ifnot_theme_option( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_body( $atts, $content = '' ): string { - return ( in_the_loop() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_body( $atts, $content = '' ): string { + return ( in_the_loop() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_body', 'ttgarden_block_body' ); -add_shortcode( 'block_date', 'ttgarden_block_body' ); -add_shortcode( 'block_postsummary', 'ttgarden_block_body' ); -add_shortcode( 'block_excerpt', 'ttgarden_block_body' ); -add_shortcode( 'block_host', 'ttgarden_block_body' ); -add_shortcode( 'block_author', 'ttgarden_block_body' ); +add_shortcode( 'block_body', 'clttg_block_body' ); +add_shortcode( 'block_date', 'clttg_block_body' ); +add_shortcode( 'block_postsummary', 'clttg_block_body' ); +add_shortcode( 'block_excerpt', 'clttg_block_body' ); +add_shortcode( 'block_host', 'clttg_block_body' ); +add_shortcode( 'block_author', 'clttg_block_body' ); /** * Outputs content if we should stretch the header image. @@ -167,10 +167,10 @@ function ttgarden_block_body( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_stretchheaderimage( $atts, $content = '' ): string { - return ( get_theme_mod( 'stretch_header_image', true ) ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_stretchheaderimage( $atts, $content = '' ): string { + return ( get_theme_mod( 'stretch_header_image', true ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_stretchheaderimage', 'ttgarden_block_stretchheaderimage' ); +add_shortcode( 'block_stretchheaderimage', 'clttg_block_stretchheaderimage' ); /** * Outputs content if we should not stretch the header image. @@ -180,10 +180,10 @@ function ttgarden_block_stretchheaderimage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_nostretchheaderimage( $atts, $content = '' ): string { - return ( get_theme_mod( 'stretch_header_image', true ) ) ? '' : ttgarden_do_shortcode( $content ); +function clttg_block_nostretchheaderimage( $atts, $content = '' ): string { + return ( get_theme_mod( 'stretch_header_image', true ) ) ? '' : clttg_do_shortcode( $content ); } -add_shortcode( 'block_nostretchheaderimage', 'ttgarden_block_nostretchheaderimage' ); +add_shortcode( 'block_nostretchheaderimage', 'clttg_block_nostretchheaderimage' ); /** * Output content if we've chosen to show the site avatar. @@ -193,10 +193,10 @@ function ttgarden_block_nostretchheaderimage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_showavatar( $atts, $content = '' ): string { - return ( get_theme_mod( 'show_avatar', true ) ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_showavatar( $atts, $content = '' ): string { + return ( get_theme_mod( 'show_avatar', true ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_showavatar', 'ttgarden_block_showavatar' ); +add_shortcode( 'block_showavatar', 'clttg_block_showavatar' ); /** * Output content if we've chosen to hide the site avatar. @@ -206,10 +206,10 @@ function ttgarden_block_showavatar( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_hideavatar( $atts, $content = '' ): string { - return ( get_theme_mod( 'show_avatar', true ) ) ? '' : ttgarden_do_shortcode( $content ); +function clttg_block_hideavatar( $atts, $content = '' ): string { + return ( get_theme_mod( 'show_avatar', true ) ) ? '' : clttg_do_shortcode( $content ); } -add_shortcode( 'block_hideavatar', 'ttgarden_block_hideavatar' ); +add_shortcode( 'block_hideavatar', 'clttg_block_hideavatar' ); /** * Output content if we've chosen to show the site title and description. @@ -219,10 +219,10 @@ function ttgarden_block_hideavatar( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_showtitle( $atts, $content = '' ): string { - return display_header_text() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_showtitle( $atts, $content = '' ): string { + return display_header_text() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_showtitle', 'ttgarden_block_showtitle' ); +add_shortcode( 'block_showtitle', 'clttg_block_showtitle' ); /** * Output content if we've chosen to hide the site title and description. @@ -232,10 +232,10 @@ function ttgarden_block_showtitle( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_hidetitle( $atts, $content = '' ): string { - return display_header_text() ? '' : ttgarden_do_shortcode( $content ); +function clttg_block_hidetitle( $atts, $content = '' ): string { + return display_header_text() ? '' : clttg_do_shortcode( $content ); } -add_shortcode( 'block_hidetitle', 'ttgarden_block_hidetitle' ); +add_shortcode( 'block_hidetitle', 'clttg_block_hidetitle' ); /** * Output content if we've chosen to show the site description. @@ -245,10 +245,10 @@ function ttgarden_block_hidetitle( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_showdescription( $atts, $content = '' ): string { - return display_header_text() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_showdescription( $atts, $content = '' ): string { + return display_header_text() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_showdescription', 'ttgarden_block_showdescription' ); +add_shortcode( 'block_showdescription', 'clttg_block_showdescription' ); /** * Output content if we've chosen to hide the site description. @@ -258,10 +258,10 @@ function ttgarden_block_showdescription( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_hidedescription( $atts, $content = '' ): string { - return display_header_text() ? '' : ttgarden_do_shortcode( $content ); +function clttg_block_hidedescription( $atts, $content = '' ): string { + return display_header_text() ? '' : clttg_do_shortcode( $content ); } -add_shortcode( 'block_hidedescription', 'ttgarden_block_hidedescription' ); +add_shortcode( 'block_hidedescription', 'clttg_block_hidedescription' ); /** * Rendered on index pages for posts with Read More breaks. @@ -273,10 +273,10 @@ function ttgarden_block_hidedescription( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_more( $atts, $content = '' ): string { - return in_the_loop() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_more( $atts, $content = '' ): string { + return in_the_loop() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_more', 'ttgarden_block_more' ); +add_shortcode( 'block_more', 'clttg_block_more' ); /** * Rendered if the post has an excerpt. @@ -286,10 +286,10 @@ function ttgarden_block_more( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_description( $atts, $content = '' ): string { - return has_excerpt() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_description( $atts, $content = '' ): string { + return has_excerpt() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_description', 'ttgarden_block_description' ); +add_shortcode( 'block_description', 'clttg_block_description' ); /** * The main posts loop. @@ -299,8 +299,8 @@ function ttgarden_block_description( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_posts( $atts, $content = '' ): string { - ttgarden_set_parse_context( 'posts', true ); +function clttg_block_posts( $atts, $content = '' ): string { + clttg_set_parse_context( 'posts', true ); $output = ''; // Use the content inside this shortcode as a template for each post. @@ -308,15 +308,15 @@ function ttgarden_block_posts( $atts, $content = '' ): string { while ( have_posts() ) { the_post(); - $output .= ttgarden_do_shortcode( $content ); + $output .= clttg_do_shortcode( $content ); } } - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $output; } -add_shortcode( 'block_posts', 'ttgarden_block_posts' ); +add_shortcode( 'block_posts', 'clttg_block_posts' ); /** * Conditional if there are no posts. @@ -326,10 +326,10 @@ function ttgarden_block_posts( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_noposts( $atts, $content = '' ): string { - return have_posts() ? '' : ttgarden_do_shortcode( $content ); +function clttg_block_noposts( $atts, $content = '' ): string { + return have_posts() ? '' : clttg_do_shortcode( $content ); } -add_shortcode( 'block_noposts', 'ttgarden_block_noposts' ); +add_shortcode( 'block_noposts', 'clttg_block_noposts' ); /** * Post tags loop. @@ -339,20 +339,20 @@ function ttgarden_block_noposts( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_tags( $atts, $content = '' ): string { +function clttg_block_tags( $atts, $content = '' ): string { $output = ''; $terms = wp_get_post_terms( get_the_ID() ); foreach ( $terms as $term ) { - ttgarden_set_parse_context( 'term', $term ); - $output .= ttgarden_do_shortcode( $content ); + clttg_set_parse_context( 'term', $term ); + $output .= clttg_do_shortcode( $content ); } - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $output; } -add_shortcode( 'block_tags', 'ttgarden_block_tags' ); +add_shortcode( 'block_tags', 'clttg_block_tags' ); /** * Rendered for each custom page. @@ -362,7 +362,7 @@ function ttgarden_block_tags( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_pages( $atts, $content = '' ): string { +function clttg_block_pages( $atts, $content = '' ): string { $output = ''; $pages_query = new WP_Query( @@ -377,7 +377,7 @@ function ttgarden_block_pages( $atts, $content = '' ): string { while ( $pages_query->have_posts() ) { $pages_query->the_post(); - $output .= ttgarden_do_shortcode( $content ); + $output .= clttg_do_shortcode( $content ); } } @@ -385,7 +385,7 @@ function ttgarden_block_pages( $atts, $content = '' ): string { return $output; } -add_shortcode( 'block_pages', 'ttgarden_block_pages' ); +add_shortcode( 'block_pages', 'clttg_block_pages' ); /** * Boolean check for if we're on a search page. @@ -395,10 +395,10 @@ function ttgarden_block_pages( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_searchpage( $atts, $content = '' ): string { - return is_search() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_searchpage( $atts, $content = '' ): string { + return is_search() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_searchpage', 'ttgarden_block_searchpage' ); +add_shortcode( 'block_searchpage', 'clttg_block_searchpage' ); /** * Render content if there are no search results. @@ -408,12 +408,12 @@ function ttgarden_block_searchpage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_nosearchresults( $atts, $content = '' ): string { +function clttg_block_nosearchresults( $atts, $content = '' ): string { global $wp_query; - return ( is_search() && 0 === $wp_query->found_posts ) ? ttgarden_do_shortcode( $content ) : ''; + return ( is_search() && 0 === $wp_query->found_posts ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_nosearchresults', 'ttgarden_block_nosearchresults' ); +add_shortcode( 'block_nosearchresults', 'clttg_block_nosearchresults' ); /** * Render content if there are search results. @@ -423,12 +423,12 @@ function ttgarden_block_nosearchresults( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_searchresults( $atts, $content = '' ): string { +function clttg_block_searchresults( $atts, $content = '' ): string { global $wp_query; - return ( is_search() && $wp_query->found_posts > 0 ) ? ttgarden_do_shortcode( $content ) : ''; + return ( is_search() && $wp_query->found_posts > 0 ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_searchresults', 'ttgarden_block_searchresults' ); +add_shortcode( 'block_searchresults', 'clttg_block_searchresults' ); /** * Render content if this site is not currently public. @@ -438,10 +438,10 @@ function ttgarden_block_searchresults( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_hidefromsearchenabled( $atts, $content = '' ): string { - return ( '1' !== get_option( 'blog_public' ) ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_hidefromsearchenabled( $atts, $content = '' ): string { + return ( '1' !== get_option( 'blog_public' ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_hidefromsearchenabled', 'ttgarden_block_hidefromsearchenabled' ); +add_shortcode( 'block_hidefromsearchenabled', 'clttg_block_hidefromsearchenabled' ); /** * Boolean check for if we're on a taxonomy page. @@ -451,10 +451,10 @@ function ttgarden_block_hidefromsearchenabled( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_tagpage( $atts, $content = '' ): string { - return ( is_tag() || is_category() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_tagpage( $atts, $content = '' ): string { + return ( is_tag() || is_category() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_tagpage', 'ttgarden_block_tagpage' ); +add_shortcode( 'block_tagpage', 'clttg_block_tagpage' ); /** * Boolean check for if we're on a single post or page. @@ -464,11 +464,11 @@ function ttgarden_block_tagpage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_permalinkpage( $atts, $content = '' ): string { - return ( is_page() || is_single() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_permalinkpage( $atts, $content = '' ): string { + return ( is_page() || is_single() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_permalinkpage', 'ttgarden_block_permalinkpage' ); -add_shortcode( 'block_permalink', 'ttgarden_block_permalinkpage' ); +add_shortcode( 'block_permalinkpage', 'clttg_block_permalinkpage' ); +add_shortcode( 'block_permalink', 'clttg_block_permalinkpage' ); /** * Boolean check for if we're on the home page. @@ -478,10 +478,10 @@ function ttgarden_block_permalinkpage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_indexpage( $atts, $content = '' ): string { - return is_home() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_indexpage( $atts, $content = '' ): string { + return is_home() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_indexpage', 'ttgarden_block_indexpage' ); +add_shortcode( 'block_indexpage', 'clttg_block_indexpage' ); /** * Boolean check for if we're on the "front page". @@ -492,10 +492,10 @@ function ttgarden_block_indexpage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_homepage( $atts, $content = '' ): string { - return is_front_page() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_homepage( $atts, $content = '' ): string { + return is_front_page() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_homepage', 'ttgarden_block_homepage' ); +add_shortcode( 'block_homepage', 'clttg_block_homepage' ); /** * Sets the global parse context so we know we're outputting a post title. @@ -505,10 +505,10 @@ function ttgarden_block_homepage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_title( $atts, $content = '' ): string { - return ! empty( get_the_title() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_title( $atts, $content = '' ): string { + return ! empty( get_the_title() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_title', 'ttgarden_block_title' ); +add_shortcode( 'block_title', 'clttg_block_title' ); /** * If the current page is able to pagination, render the content. @@ -518,10 +518,10 @@ function ttgarden_block_title( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_pagination( $atts, $content = '' ): string { - return ( get_next_posts_page_link() || get_previous_posts_page_link() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_pagination( $atts, $content = '' ): string { + return ( get_next_posts_page_link() || get_previous_posts_page_link() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_pagination', 'ttgarden_block_pagination' ); +add_shortcode( 'block_pagination', 'clttg_block_pagination' ); /** * The Jump pagination block. @@ -531,7 +531,7 @@ function ttgarden_block_pagination( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_jumppagination( $atts, $content = '' ): string { +function clttg_block_jumppagination( $atts, $content = '' ): string { // Parse shortcode attributes. $atts = shortcode_atts( array( @@ -545,16 +545,16 @@ function ttgarden_block_jumppagination( $atts, $content = '' ): string { if ( $atts['length'] > 0 ) { for ( $i = 1; $i <= $atts['length']; $i++ ) { - ttgarden_set_parse_context( 'jumppagination', $i ); - $output .= ttgarden_do_shortcode( $content ); + clttg_set_parse_context( 'jumppagination', $i ); + $output .= clttg_do_shortcode( $content ); } } - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $output; } -add_shortcode( 'block_jumppagination', 'ttgarden_block_jumppagination' ); +add_shortcode( 'block_jumppagination', 'clttg_block_jumppagination' ); /** * The currentpage block inside jumppagination. @@ -565,14 +565,14 @@ function ttgarden_block_jumppagination( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_currentpage( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_currentpage( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); $var = get_query_var( 'paged' ); $paged = $var ? $var : 1; - return ( isset( $context['jumppagination'] ) && $paged === $context['jumppagination'] ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['jumppagination'] ) && $paged === $context['jumppagination'] ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_currentpage', 'ttgarden_block_currentpage' ); +add_shortcode( 'block_currentpage', 'clttg_block_currentpage' ); /** * The jumppage block inside jumppagination. @@ -583,14 +583,14 @@ function ttgarden_block_currentpage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_jumppage( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_jumppage( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); $var = get_query_var( 'paged' ); $paged = $var ? $var : 1; - return ( isset( $context['jumppagination'] ) && $paged !== $context['jumppagination'] ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['jumppagination'] ) && $paged !== $context['jumppagination'] ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_jumppage', 'ttgarden_block_jumppage' ); +add_shortcode( 'block_jumppage', 'clttg_block_jumppage' ); /** * Boolean check for if we're on a single post or page. @@ -600,10 +600,10 @@ function ttgarden_block_jumppage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_posttitle( $atts, $content = '' ): string { - return is_single() ? ttgarden_block_title( $content ) : ''; +function clttg_block_posttitle( $atts, $content = '' ): string { + return is_single() ? clttg_block_title( $content ) : ''; } -add_shortcode( 'block_posttitle', 'ttgarden_block_posttitle' ); +add_shortcode( 'block_posttitle', 'clttg_block_posttitle' ); /** * Rendered if you have defined any custom pages. @@ -613,7 +613,7 @@ function ttgarden_block_posttitle( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_haspages( $atts, $content = '' ): string { +function clttg_block_haspages( $atts, $content = '' ): string { $pages_query = get_posts( array( 'post_type' => 'page', @@ -622,9 +622,9 @@ function ttgarden_block_haspages( $atts, $content = '' ): string { ) ); - return ( ! empty( $pages_query ) ) ? ttgarden_do_shortcode( $content ) : ''; + return ( ! empty( $pages_query ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_haspages', 'ttgarden_block_haspages' ); +add_shortcode( 'block_haspages', 'clttg_block_haspages' ); /** * Rendered if you have "Show header image" enabled. @@ -634,12 +634,12 @@ function ttgarden_block_haspages( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_showheaderimage( $atts, $content = '' ): string { +function clttg_block_showheaderimage( $atts, $content = '' ): string { return ( get_theme_mod( 'show_header_image', true ) && 'remove-header' !== get_theme_mod( 'header_image', 'remove-header' ) ) - ? ttgarden_do_shortcode( $content ) : ''; + ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_showheaderimage', 'ttgarden_block_showheaderimage' ); +add_shortcode( 'block_showheaderimage', 'clttg_block_showheaderimage' ); /** * Rendered if you have "Show header image" disabled. @@ -649,12 +649,12 @@ function ttgarden_block_showheaderimage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_hideheaderimage( $atts, $content = '' ): string { +function clttg_block_hideheaderimage( $atts, $content = '' ): string { return ( ! get_theme_mod( 'show_header_image', true ) || 'remove-header' === get_theme_mod( 'header_image', 'remove-header' ) ) - ? ttgarden_do_shortcode( $content ) : ''; + ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_hideheaderimage', 'ttgarden_block_hideheaderimage' ); +add_shortcode( 'block_hideheaderimage', 'clttg_block_hideheaderimage' ); /** * If a post is not a reblog, render the content. @@ -666,10 +666,10 @@ function ttgarden_block_hideheaderimage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_notreblog( $atts, $content = '' ): string { - return ttgarden_do_shortcode( $content ); +function clttg_block_notreblog( $atts, $content = '' ): string { + return clttg_do_shortcode( $content ); } -add_shortcode( 'block_notreblog', 'ttgarden_block_notreblog' ); +add_shortcode( 'block_notreblog', 'clttg_block_notreblog' ); /** * Rendered if the post has tags. @@ -679,10 +679,10 @@ function ttgarden_block_notreblog( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_hastags( $atts, $content = '' ): string { - return ( has_tag() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_hastags( $atts, $content = '' ): string { + return ( has_tag() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_hastags', 'ttgarden_block_hastags' ); +add_shortcode( 'block_hastags', 'clttg_block_hastags' ); /** * Rendered if the post has comments or comments open. @@ -692,10 +692,10 @@ function ttgarden_block_hastags( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_post_notes( $atts, $content = '' ): string { - return ( is_single() || is_page() ) && ( get_comments_number() || comments_open() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_post_notes( $atts, $content = '' ): string { + return ( is_single() || is_page() ) && ( get_comments_number() || comments_open() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_postnotes', 'ttgarden_block_post_notes' ); +add_shortcode( 'block_postnotes', 'clttg_block_post_notes' ); /** * Always rendered, but only outputs content if the post has comments or comments open. @@ -705,10 +705,10 @@ function ttgarden_block_post_notes( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_notecount( $atts, $content = '' ): string { - return ttgarden_do_shortcode( $content ); +function clttg_block_notecount( $atts, $content = '' ): string { + return clttg_do_shortcode( $content ); } -add_shortcode( 'block_notecount', 'ttgarden_block_notecount' ); +add_shortcode( 'block_notecount', 'clttg_block_notecount' ); /** * Rendered for legacy Text posts and NPF posts. @@ -718,11 +718,11 @@ function ttgarden_block_notecount( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_text( $atts, $content = '' ): string { - return ( false === get_post_format() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_text( $atts, $content = '' ): string { + return ( false === get_post_format() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_text', 'ttgarden_block_text' ); -add_shortcode( 'block_regular', 'ttgarden_block_text' ); +add_shortcode( 'block_text', 'clttg_block_text' ); +add_shortcode( 'block_regular', 'clttg_block_text' ); /** * Rendered for legacy quote posts, or the WordPress quote post format. @@ -734,7 +734,7 @@ function ttgarden_block_text( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_quote( $atts, $content = '' ): string { +function clttg_block_quote( $atts, $content = '' ): string { global $post; // Don't parse all blocks if the post format is not quote. @@ -783,7 +783,7 @@ function ttgarden_block_quote( $atts, $content = '' ): string { } // Set the current context. - ttgarden_set_parse_context( + clttg_set_parse_context( 'quote', array( 'quote' => wp_kses( @@ -801,13 +801,13 @@ function ttgarden_block_quote( $atts, $content = '' ): string { ); // Parse the content of the quote block before resetting the context. - $content = ttgarden_do_shortcode( $content ); + $content = clttg_do_shortcode( $content ); - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $content; } -add_shortcode( 'block_quote', 'ttgarden_block_quote' ); +add_shortcode( 'block_quote', 'clttg_block_quote' ); /** * Tests for a source in the quote post format. @@ -817,18 +817,18 @@ function ttgarden_block_quote( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_source( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_source( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); // Test if the current context is a quote post and has a source. if ( isset( $context['quote'], $context['quote']['source'] ) && ! empty( $context['quote']['source'] ) ) { - return ttgarden_do_shortcode( $content ); + return clttg_do_shortcode( $content ); } // Return nothing if no source is found. return ''; } -add_shortcode( 'block_source', 'ttgarden_block_source' ); +add_shortcode( 'block_source', 'clttg_block_source' ); /** * Rendered for chat posts. @@ -838,7 +838,7 @@ function ttgarden_block_source( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_chat( $atts, $content = '' ): string { +function clttg_block_chat( $atts, $content = '' ): string { global $post; // Don't parse all blocks if the post format is not chat. @@ -856,7 +856,7 @@ function ttgarden_block_chat( $atts, $content = '' ): string { } } - ttgarden_set_parse_context( + clttg_set_parse_context( 'chat', array( 'lines' => $lines, @@ -864,14 +864,14 @@ function ttgarden_block_chat( $atts, $content = '' ): string { ); // Parse the content of the chat block before resetting the context. - $content = ttgarden_do_shortcode( $content ); + $content = clttg_do_shortcode( $content ); - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $content; } -add_shortcode( 'block_chat', 'ttgarden_block_chat' ); -add_shortcode( 'block_conversation', 'ttgarden_block_chat' ); +add_shortcode( 'block_chat', 'clttg_block_chat' ); +add_shortcode( 'block_conversation', 'clttg_block_chat' ); /** * Legacy Chat Post rendered for each line of the post @@ -881,8 +881,8 @@ function ttgarden_block_chat( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_lines( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_lines( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); $output = ''; if ( ! isset( $context['chat']['lines'] ) || empty( $context['chat']['lines'] ) ) { @@ -901,7 +901,7 @@ function ttgarden_block_lines( $atts, $content = '' ): string { $line = $parts[1]; } - ttgarden_set_parse_context( + clttg_set_parse_context( 'chat', array( 'label' => $label, @@ -909,12 +909,12 @@ function ttgarden_block_lines( $atts, $content = '' ): string { ) ); - $output .= ttgarden_do_shortcode( $content ); + $output .= clttg_do_shortcode( $content ); } return $output; } -add_shortcode( 'block_lines', 'ttgarden_block_lines' ); +add_shortcode( 'block_lines', 'clttg_block_lines' ); /** * Legacy Chat Post block:label @@ -924,16 +924,16 @@ function ttgarden_block_lines( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_label( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_label( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['chat']['label'] ) || empty( $context['chat']['label'] ) ) { return ''; } - return ttgarden_do_shortcode( $content ); + return clttg_do_shortcode( $content ); } -add_shortcode( 'block_label', 'ttgarden_block_label' ); +add_shortcode( 'block_label', 'clttg_block_label' ); /** * Rendered for link posts. @@ -943,7 +943,7 @@ function ttgarden_block_label( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_link( $atts, $content = '' ): string { +function clttg_block_link( $atts, $content = '' ): string { global $post; // Don't parse all blocks if the post format is not chat. @@ -963,7 +963,7 @@ function ttgarden_block_link( $atts, $content = '' ): string { } } - ttgarden_set_parse_context( + clttg_set_parse_context( 'link', array( 'url' => $url, @@ -971,13 +971,13 @@ function ttgarden_block_link( $atts, $content = '' ): string { ); // Parse the content of the chat block before resetting the context. - $content = ttgarden_do_shortcode( $content ); + $content = clttg_do_shortcode( $content ); - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $content; } -add_shortcode( 'block_link', 'ttgarden_block_link' ); +add_shortcode( 'block_link', 'clttg_block_link' ); /** * Rendered for audio posts. @@ -987,7 +987,7 @@ function ttgarden_block_link( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_audio( $atts, $content = '' ): string { +function clttg_block_audio( $atts, $content = '' ): string { global $post; // Don't parse all blocks if the post format is not quote. @@ -1057,7 +1057,7 @@ function ttgarden_block_audio( $atts, $content = '' ): string { } // Set the current context. - ttgarden_set_parse_context( + clttg_set_parse_context( 'audio', array( 'player' => $player, @@ -1073,13 +1073,13 @@ function ttgarden_block_audio( $atts, $content = '' ): string { ); // Parse the content of the quote block before resetting the context. - $content = ttgarden_do_shortcode( $content ); + $content = clttg_do_shortcode( $content ); - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $content; } -add_shortcode( 'block_audio', 'ttgarden_block_audio' ); +add_shortcode( 'block_audio', 'clttg_block_audio' ); /** * Rendered for audio posts with an audioplayer block. @@ -1089,13 +1089,13 @@ function ttgarden_block_audio( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_audioplayer( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_audioplayer( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); - return ( isset( $context['audio']['player'] ) && ! empty( $context['audio']['player'] ) ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['audio']['player'] ) && ! empty( $context['audio']['player'] ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_audioplayer', 'ttgarden_block_audioplayer' ); -add_shortcode( 'block_audioembed', 'ttgarden_block_audioplayer' ); +add_shortcode( 'block_audioplayer', 'clttg_block_audioplayer' ); +add_shortcode( 'block_audioembed', 'clttg_block_audioplayer' ); /** * Rendered for audio posts with an external audio block. @@ -1106,12 +1106,12 @@ function ttgarden_block_audioplayer( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_externalaudio( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_externalaudio( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); - return ( isset( $context['audio']['media_id'] ) && 0 === $context['audio']['media_id'] ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['audio']['media_id'] ) && 0 === $context['audio']['media_id'] ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_externalaudio', 'ttgarden_block_externalaudio' ); +add_shortcode( 'block_externalaudio', 'clttg_block_externalaudio' ); /** * Rendered for audio posts with a featured image set. @@ -1121,12 +1121,12 @@ function ttgarden_block_externalaudio( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_albumart( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_albumart( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); - return ( isset( $context['audio']['player'] ) && ! empty( $context['audio']['player'] ) ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['audio']['player'] ) && ! empty( $context['audio']['player'] ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_albumart', 'ttgarden_block_albumart' ); +add_shortcode( 'block_albumart', 'clttg_block_albumart' ); /** * Rendered for audio posts with a track name set. @@ -1136,12 +1136,12 @@ function ttgarden_block_albumart( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_trackname( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_trackname( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); - return ( isset( $context['audio']['trackname'] ) && '' !== $context['audio']['trackname'] ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['audio']['trackname'] ) && '' !== $context['audio']['trackname'] ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_trackname', 'ttgarden_block_trackname' ); +add_shortcode( 'block_trackname', 'clttg_block_trackname' ); /** * Rendered for audio posts with an artist name set. @@ -1151,12 +1151,12 @@ function ttgarden_block_trackname( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_artist( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_artist( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); - return ( isset( $context['audio']['artist'] ) && '' !== $context['audio']['artist'] ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['audio']['artist'] ) && '' !== $context['audio']['artist'] ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_artist', 'ttgarden_block_artist' ); +add_shortcode( 'block_artist', 'clttg_block_artist' ); /** * Rendered for audio posts with an album name set. @@ -1166,12 +1166,12 @@ function ttgarden_block_artist( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_album( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_album( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); - return ( isset( $context['audio']['album'] ) && '' !== $context['audio']['album'] ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['audio']['album'] ) && '' !== $context['audio']['album'] ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_album', 'ttgarden_block_album' ); +add_shortcode( 'block_album', 'clttg_block_album' ); /** * Rendered for video posts. @@ -1181,7 +1181,7 @@ function ttgarden_block_album( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_video( $atts, $content = '' ): string { +function clttg_block_video( $atts, $content = '' ): string { global $post; // Don't parse all blocks if the post format is not quote. @@ -1257,7 +1257,7 @@ function ttgarden_block_video( $atts, $content = '' ): string { } // Set the current context. - ttgarden_set_parse_context( + clttg_set_parse_context( 'video', array( 'player' => $player, @@ -1276,13 +1276,13 @@ function ttgarden_block_video( $atts, $content = '' ): string { ); // Parse the content of the quote block before resetting the context. - $content = ttgarden_do_shortcode( $content ); + $content = clttg_do_shortcode( $content ); - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $content; } -add_shortcode( 'block_video', 'ttgarden_block_video' ); +add_shortcode( 'block_video', 'clttg_block_video' ); /** * Rendered for video posts with a video player and video thumbnail. @@ -1292,13 +1292,13 @@ function ttgarden_block_video( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_videothumbnail( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_videothumbnail( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); - return ( isset( $context['video']['thumbnail'] ) && ! empty( $context['video']['thumbnail'] ) ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['video']['thumbnail'] ) && ! empty( $context['video']['thumbnail'] ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_videothumbnail', 'ttgarden_block_videothumbnail' ); -add_shortcode( 'block_videothumbnails', 'ttgarden_block_videothumbnail' ); +add_shortcode( 'block_videothumbnail', 'clttg_block_videothumbnail' ); +add_shortcode( 'block_videothumbnails', 'clttg_block_videothumbnail' ); /** * Rendered for photo and panorama posts. @@ -1308,7 +1308,7 @@ function ttgarden_block_videothumbnail( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_photo( $atts, $content = '' ): string { +function clttg_block_photo( $atts, $content = '' ): string { global $post; // Don't parse all blocks if the post format is not quote. @@ -1358,7 +1358,7 @@ function ttgarden_block_photo( $atts, $content = '' ): string { } // Set the current context. - ttgarden_set_parse_context( + clttg_set_parse_context( 'image', array( 'highres' => $highres, @@ -1371,13 +1371,13 @@ function ttgarden_block_photo( $atts, $content = '' ): string { ); // Parse the content of the quote block before resetting the context. - $content = ttgarden_do_shortcode( $content ); + $content = clttg_do_shortcode( $content ); - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $content; } -add_shortcode( 'block_photo', 'ttgarden_block_photo' ); +add_shortcode( 'block_photo', 'clttg_block_photo' ); /** * Render each photo in a photoset (gallery) post. @@ -1387,8 +1387,8 @@ function ttgarden_block_photo( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_photos( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_photos( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); $output = ''; if ( ! isset( $context['gallery']['photos'] ) || empty( $context['gallery']['photos'] ) ) { @@ -1417,7 +1417,7 @@ function ttgarden_block_photos( $atts, $content = '' ): string { } // Set the current context. - ttgarden_set_parse_context( + clttg_set_parse_context( 'image', array( 'highres' => $highres, @@ -1429,12 +1429,12 @@ function ttgarden_block_photos( $atts, $content = '' ): string { ); // Parse the content of the quote block before resetting the context. - $output .= ttgarden_do_shortcode( $content ); + $output .= clttg_do_shortcode( $content ); } return $output; } -add_shortcode( 'block_photos', 'ttgarden_block_photos' ); +add_shortcode( 'block_photos', 'clttg_block_photos' ); /** * Rendered for photo and panorama posts which have a link set on the image. @@ -1444,16 +1444,16 @@ function ttgarden_block_photos( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_linkurl( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_linkurl( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['image']['link'] ) ) { return ''; } - return ( true === $context['image']['lightbox'] || 'none' !== $context['image']['link'] ) ? ttgarden_do_shortcode( $content ) : ''; + return ( true === $context['image']['lightbox'] || 'none' !== $context['image']['link'] ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_linkurl', 'ttgarden_block_linkurl' ); +add_shortcode( 'block_linkurl', 'clttg_block_linkurl' ); /** * Rendered for photo and panorama posts which have the image size set as "large" or "fullsize". @@ -1463,12 +1463,12 @@ function ttgarden_block_linkurl( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_highres( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_highres( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); - return ( isset( $context['image']['highres'] ) && true === $context['image']['highres'] ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['image']['highres'] ) && true === $context['image']['highres'] ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_highres', 'ttgarden_block_highres' ); +add_shortcode( 'block_highres', 'clttg_block_highres' ); /** * Rendered render content if the image has exif data. @@ -1478,12 +1478,12 @@ function ttgarden_block_highres( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_exif( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_exif( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); - return ( isset( $context['image']['data'] ) && ! empty( $context['image']['data']['image_meta'] ) ) ? ttgarden_do_shortcode( $content ) : ''; + return ( isset( $context['image']['data'] ) && ! empty( $context['image']['data']['image_meta'] ) ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_exif', 'ttgarden_block_exif' ); +add_shortcode( 'block_exif', 'clttg_block_exif' ); /** * Conditionally load content based on if the image has camera exif data. @@ -1493,8 +1493,8 @@ function ttgarden_block_exif( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_camera( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_camera( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['image']['data']['image_meta']['camera'] ) ) { return ''; @@ -1502,9 +1502,9 @@ function ttgarden_block_camera( $atts, $content = '' ): string { $camera = $context['image']['data']['image_meta']['camera']; - return ( empty( $camera ) || '0' === $camera ) ? '' : ttgarden_do_shortcode( $content ); + return ( empty( $camera ) || '0' === $camera ) ? '' : clttg_do_shortcode( $content ); } -add_shortcode( 'block_camera', 'ttgarden_block_camera' ); +add_shortcode( 'block_camera', 'clttg_block_camera' ); /** * Conditionally load content based on if the image has lens exif data. @@ -1514,8 +1514,8 @@ function ttgarden_block_camera( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_aperture( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_aperture( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['image']['data']['image_meta']['aperture'] ) ) { return ''; @@ -1523,9 +1523,9 @@ function ttgarden_block_aperture( $atts, $content = '' ): string { $aperture = $context['image']['data']['image_meta']['aperture']; - return ( empty( $aperture ) || '0' === $aperture ) ? '' : ttgarden_do_shortcode( $content ); + return ( empty( $aperture ) || '0' === $aperture ) ? '' : clttg_do_shortcode( $content ); } -add_shortcode( 'block_aperture', 'ttgarden_block_aperture' ); +add_shortcode( 'block_aperture', 'clttg_block_aperture' ); /** * Conditionally load content based on if the image has focal length exif data. @@ -1535,8 +1535,8 @@ function ttgarden_block_aperture( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_exposure( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_exposure( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['image']['data']['image_meta']['shutter_speed'] ) ) { return ''; @@ -1544,9 +1544,9 @@ function ttgarden_block_exposure( $atts, $content = '' ): string { $exposure = $context['image']['data']['image_meta']['shutter_speed']; - return ( empty( $exposure ) || '0' === $exposure ) ? '' : ttgarden_do_shortcode( $content ); + return ( empty( $exposure ) || '0' === $exposure ) ? '' : clttg_do_shortcode( $content ); } -add_shortcode( 'block_exposure', 'ttgarden_block_exposure' ); +add_shortcode( 'block_exposure', 'clttg_block_exposure' ); /** * Conditionally load content based on if the image has focal length exif data. @@ -1556,8 +1556,8 @@ function ttgarden_block_exposure( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_focallength( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_focallength( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['image']['data']['image_meta']['focal_length'] ) ) { return ''; @@ -1565,9 +1565,9 @@ function ttgarden_block_focallength( $atts, $content = '' ): string { $focal_length = $context['image']['data']['image_meta']['focal_length']; - return ( empty( $focal_length ) || '0' === $focal_length ) ? '' : ttgarden_do_shortcode( $content ); + return ( empty( $focal_length ) || '0' === $focal_length ) ? '' : clttg_do_shortcode( $content ); } -add_shortcode( 'block_focallength', 'ttgarden_block_focallength' ); +add_shortcode( 'block_focallength', 'clttg_block_focallength' ); /** * Rendered for photoset (gallery) posts. @@ -1577,7 +1577,7 @@ function ttgarden_block_focallength( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_photoset( $atts, $content = '' ): string { +function clttg_block_photoset( $atts, $content = '' ): string { global $post; // Don't parse all blocks if the post format is not quote. @@ -1612,7 +1612,7 @@ function ttgarden_block_photoset( $atts, $content = '' ): string { } // Set the current context. - ttgarden_set_parse_context( + clttg_set_parse_context( 'gallery', array( 'gallery' => $gallery, @@ -1623,13 +1623,13 @@ function ttgarden_block_photoset( $atts, $content = '' ): string { ); // Parse the content of the quote block before resetting the context. - $content = ttgarden_do_shortcode( $content ); + $content = clttg_do_shortcode( $content ); - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $content; } -add_shortcode( 'block_photoset', 'ttgarden_block_photoset' ); +add_shortcode( 'block_photoset', 'clttg_block_photoset' ); /** * Rendered for link posts with a thumbnail image set. @@ -1639,10 +1639,10 @@ function ttgarden_block_photoset( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_thumbnail( $atts, $content = '' ): string { - return has_post_thumbnail() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_thumbnail( $atts, $content = '' ): string { + return has_post_thumbnail() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_thumbnail', 'ttgarden_block_thumbnail' ); +add_shortcode( 'block_thumbnail', 'clttg_block_thumbnail' ); /** * Rendered for photoset (gallery) posts with caption content. @@ -1652,17 +1652,17 @@ function ttgarden_block_thumbnail( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_caption( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_caption( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); $format = get_post_format(); if ( ! isset( $context[ $format ]['caption'] ) ) { return ''; } - return ttgarden_do_shortcode( $content ); + return clttg_do_shortcode( $content ); } -add_shortcode( 'block_caption', 'ttgarden_block_caption' ); +add_shortcode( 'block_caption', 'clttg_block_caption' ); /** * Rendered for legacy Text posts and NPF posts. @@ -1672,10 +1672,10 @@ function ttgarden_block_caption( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_daypage( $atts, $content = '' ): string { - return ( is_day() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_daypage( $atts, $content = '' ): string { + return ( is_day() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_daypage', 'ttgarden_block_daypage' ); +add_shortcode( 'block_daypage', 'clttg_block_daypage' ); /** * Rendered if older posts are available. @@ -1685,10 +1685,10 @@ function ttgarden_block_daypage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_previouspage( $atts, $content = '' ): string { - return ( get_previous_posts_link() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_previouspage( $atts, $content = '' ): string { + return ( get_previous_posts_link() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_previouspage', 'ttgarden_block_previouspage' ); +add_shortcode( 'block_previouspage', 'clttg_block_previouspage' ); /** * Rendered if newer posts are available. @@ -1698,10 +1698,10 @@ function ttgarden_block_previouspage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_nextpage( $atts, $content = '' ): string { - return ( get_next_posts_link() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_nextpage( $atts, $content = '' ): string { + return ( get_next_posts_link() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_nextpage', 'ttgarden_block_nextpage' ); +add_shortcode( 'block_nextpage', 'clttg_block_nextpage' ); /** * Boolean check for if we're on a single post or page. @@ -1711,10 +1711,10 @@ function ttgarden_block_nextpage( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_permalinkpagination( $atts, $content = '' ): string { - return is_single() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_permalinkpagination( $atts, $content = '' ): string { + return is_single() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_permalinkpagination', 'ttgarden_block_permalinkpagination' ); +add_shortcode( 'block_permalinkpagination', 'clttg_block_permalinkpagination' ); /** * Check if there's a previous adjacent post. @@ -1724,10 +1724,10 @@ function ttgarden_block_permalinkpagination( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_previouspost( $atts, $content = '' ): string { - return ( get_previous_post() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_previouspost( $atts, $content = '' ): string { + return ( get_previous_post() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_previouspost', 'ttgarden_block_previouspost' ); +add_shortcode( 'block_previouspost', 'clttg_block_previouspost' ); /** * Check if there's a next adjacent post. @@ -1737,10 +1737,10 @@ function ttgarden_block_previouspost( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_nextpost( $atts, $content = '' ): string { - return ( get_next_post() ) ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_nextpost( $atts, $content = '' ): string { + return ( get_next_post() ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_nextpost', 'ttgarden_block_nextpost' ); +add_shortcode( 'block_nextpost', 'clttg_block_nextpost' ); /** * Rendered if the post has been marked as sticky. @@ -1750,10 +1750,10 @@ function ttgarden_block_nextpost( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_pinnedpostlabel( $atts, $content = '' ): string { - return is_sticky() ? ttgarden_do_shortcode( $content ) : ''; +function clttg_block_pinnedpostlabel( $atts, $content = '' ): string { + return is_sticky() ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_pinnedpostlabel', 'ttgarden_block_pinnedpostlabel' ); +add_shortcode( 'block_pinnedpostlabel', 'clttg_block_pinnedpostlabel' ); /** * Render content if the current language is equal to the specified language. @@ -1764,7 +1764,7 @@ function ttgarden_block_pinnedpostlabel( $atts, $content = '' ): string { * * @return string The parsed content or an empty string. */ -function ttgarden_block_language( $atts, $content, $shortcode_name ): string { +function clttg_block_language( $atts, $content, $shortcode_name ): string { // Map shortcodes to their respective locales $language_map = array( 'block_english' => 'en_US', @@ -1811,50 +1811,50 @@ function ttgarden_block_language( $atts, $content, $shortcode_name ): string { // Check if the shortcode name matches a defined language and compare it with the current locale if ( 0 === strpos( $shortcode_name, 'block_not' ) ) { if ( isset( $language_map[ $shortcode_name ] ) && $language_map[ $shortcode_name ] !== $current_locale ) { - return ttgarden_do_shortcode( $content ); + return clttg_do_shortcode( $content ); } } elseif ( isset( $language_map[ $shortcode_name ] ) && $language_map[ $shortcode_name ] === $current_locale ) { - return ttgarden_do_shortcode( $content ); + return clttg_do_shortcode( $content ); } return ''; } -add_shortcode( 'block_english', 'ttgarden_block_language' ); -add_shortcode( 'block_german', 'ttgarden_block_language' ); -add_shortcode( 'block_french', 'ttgarden_block_language' ); -add_shortcode( 'block_italian', 'ttgarden_block_language' ); -add_shortcode( 'block_turkish', 'ttgarden_block_language' ); -add_shortcode( 'block_spanish', 'ttgarden_block_language' ); -add_shortcode( 'block_russian', 'ttgarden_block_language' ); -add_shortcode( 'block_japanese', 'ttgarden_block_language' ); -add_shortcode( 'block_polish', 'ttgarden_block_language' ); -add_shortcode( 'block_portuguesept', 'ttgarden_block_language' ); -add_shortcode( 'block_portuguesebr', 'ttgarden_block_language' ); -add_shortcode( 'block_dutch', 'ttgarden_block_language' ); -add_shortcode( 'block_korean', 'ttgarden_block_language' ); -add_shortcode( 'block_chinesesimplified', 'ttgarden_block_language' ); -add_shortcode( 'block_chinesetraditional', 'ttgarden_block_language' ); -add_shortcode( 'block_chinesehk', 'ttgarden_block_language' ); -add_shortcode( 'block_indonesian', 'ttgarden_block_language' ); -add_shortcode( 'block_hindi', 'ttgarden_block_language' ); -add_shortcode( 'block_notenglish', 'ttgarden_block_language' ); -add_shortcode( 'block_notgerman', 'ttgarden_block_language' ); -add_shortcode( 'block_notfrench', 'ttgarden_block_language' ); -add_shortcode( 'block_notitalian', 'ttgarden_block_language' ); -add_shortcode( 'block_notturkish', 'ttgarden_block_language' ); -add_shortcode( 'block_notspanish', 'ttgarden_block_language' ); -add_shortcode( 'block_notrussian', 'ttgarden_block_language' ); -add_shortcode( 'block_notjapanese', 'ttgarden_block_language' ); -add_shortcode( 'block_notpolish', 'ttgarden_block_language' ); -add_shortcode( 'block_notportuguesept', 'ttgarden_block_language' ); -add_shortcode( 'block_notportuguesebr', 'ttgarden_block_language' ); -add_shortcode( 'block_notdutch', 'ttgarden_block_language' ); -add_shortcode( 'block_notkorean', 'ttgarden_block_language' ); -add_shortcode( 'block_notchinesesimplified', 'ttgarden_block_language' ); -add_shortcode( 'block_notchinesetraditional', 'ttgarden_block_language' ); -add_shortcode( 'block_notchinesehk', 'ttgarden_block_language' ); -add_shortcode( 'block_notindonesian', 'ttgarden_block_language' ); -add_shortcode( 'block_nothindi', 'ttgarden_block_language' ); +add_shortcode( 'block_english', 'clttg_block_language' ); +add_shortcode( 'block_german', 'clttg_block_language' ); +add_shortcode( 'block_french', 'clttg_block_language' ); +add_shortcode( 'block_italian', 'clttg_block_language' ); +add_shortcode( 'block_turkish', 'clttg_block_language' ); +add_shortcode( 'block_spanish', 'clttg_block_language' ); +add_shortcode( 'block_russian', 'clttg_block_language' ); +add_shortcode( 'block_japanese', 'clttg_block_language' ); +add_shortcode( 'block_polish', 'clttg_block_language' ); +add_shortcode( 'block_portuguesept', 'clttg_block_language' ); +add_shortcode( 'block_portuguesebr', 'clttg_block_language' ); +add_shortcode( 'block_dutch', 'clttg_block_language' ); +add_shortcode( 'block_korean', 'clttg_block_language' ); +add_shortcode( 'block_chinesesimplified', 'clttg_block_language' ); +add_shortcode( 'block_chinesetraditional', 'clttg_block_language' ); +add_shortcode( 'block_chinesehk', 'clttg_block_language' ); +add_shortcode( 'block_indonesian', 'clttg_block_language' ); +add_shortcode( 'block_hindi', 'clttg_block_language' ); +add_shortcode( 'block_notenglish', 'clttg_block_language' ); +add_shortcode( 'block_notgerman', 'clttg_block_language' ); +add_shortcode( 'block_notfrench', 'clttg_block_language' ); +add_shortcode( 'block_notitalian', 'clttg_block_language' ); +add_shortcode( 'block_notturkish', 'clttg_block_language' ); +add_shortcode( 'block_notspanish', 'clttg_block_language' ); +add_shortcode( 'block_notrussian', 'clttg_block_language' ); +add_shortcode( 'block_notjapanese', 'clttg_block_language' ); +add_shortcode( 'block_notpolish', 'clttg_block_language' ); +add_shortcode( 'block_notportuguesept', 'clttg_block_language' ); +add_shortcode( 'block_notportuguesebr', 'clttg_block_language' ); +add_shortcode( 'block_notdutch', 'clttg_block_language' ); +add_shortcode( 'block_notkorean', 'clttg_block_language' ); +add_shortcode( 'block_notchinesesimplified', 'clttg_block_language' ); +add_shortcode( 'block_notchinesetraditional', 'clttg_block_language' ); +add_shortcode( 'block_notchinesehk', 'clttg_block_language' ); +add_shortcode( 'block_notindonesian', 'clttg_block_language' ); +add_shortcode( 'block_nothindi', 'clttg_block_language' ); /** * Rendered if this is post number N (0 - 15) in the loop. @@ -1865,7 +1865,7 @@ function ttgarden_block_language( $atts, $content, $shortcode_name ): string { * * @return string The parsed content or an empty string. */ -function ttgarden_block_post_n( $atts, $content, $shortcode_name ): string { +function clttg_block_post_n( $atts, $content, $shortcode_name ): string { global $wp_query; // Extract the post number from the shortcode name (assuming 'block_postN' where N is a number) @@ -1873,27 +1873,27 @@ function ttgarden_block_post_n( $atts, $content, $shortcode_name ): string { // Check if in the loop and if the current post is the post number N if ( in_the_loop() && absint( $matches[1] - 1 ) === $wp_query->current_post ) { - return ttgarden_do_shortcode( $content ); + return clttg_do_shortcode( $content ); } } return ''; } -add_shortcode( 'block_post1', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post2', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post3', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post4', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post5', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post6', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post7', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post8', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post9', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post10', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post11', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post12', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post13', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post14', 'ttgarden_block_post_n' ); -add_shortcode( 'block_post15', 'ttgarden_block_post_n' ); +add_shortcode( 'block_post1', 'clttg_block_post_n' ); +add_shortcode( 'block_post2', 'clttg_block_post_n' ); +add_shortcode( 'block_post3', 'clttg_block_post_n' ); +add_shortcode( 'block_post4', 'clttg_block_post_n' ); +add_shortcode( 'block_post5', 'clttg_block_post_n' ); +add_shortcode( 'block_post6', 'clttg_block_post_n' ); +add_shortcode( 'block_post7', 'clttg_block_post_n' ); +add_shortcode( 'block_post8', 'clttg_block_post_n' ); +add_shortcode( 'block_post9', 'clttg_block_post_n' ); +add_shortcode( 'block_post10', 'clttg_block_post_n' ); +add_shortcode( 'block_post11', 'clttg_block_post_n' ); +add_shortcode( 'block_post12', 'clttg_block_post_n' ); +add_shortcode( 'block_post13', 'clttg_block_post_n' ); +add_shortcode( 'block_post14', 'clttg_block_post_n' ); +add_shortcode( 'block_post15', 'clttg_block_post_n' ); /** * Render content if the current post is an odd post in the loop. @@ -1903,13 +1903,13 @@ function ttgarden_block_post_n( $atts, $content, $shortcode_name ): string { * * @return string */ -function ttgarden_block_odd( $atts, $content = '' ): string { +function clttg_block_odd( $atts, $content = '' ): string { global $wp_query; // Check if in the loop and if the current post index is odd - return ( in_the_loop() && ( $wp_query->current_post % 2 ) !== 0 ) ? ttgarden_do_shortcode( $content ) : ''; + return ( in_the_loop() && ( $wp_query->current_post % 2 ) !== 0 ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_odd', 'ttgarden_block_odd' ); +add_shortcode( 'block_odd', 'clttg_block_odd' ); /** * Render content if the current post is an even post in the loop. @@ -1919,13 +1919,13 @@ function ttgarden_block_odd( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_even( $atts, $content = '' ): string { +function clttg_block_even( $atts, $content = '' ): string { global $wp_query; // Check if in the loop and if the current post index is even - return ( in_the_loop() && ( $wp_query->current_post % 2 ) === 0 ) ? ttgarden_do_shortcode( $content ) : ''; + return ( in_the_loop() && ( $wp_query->current_post % 2 ) === 0 ) ? clttg_do_shortcode( $content ) : ''; } -add_shortcode( 'block_even', 'ttgarden_block_even' ); +add_shortcode( 'block_even', 'clttg_block_even' ); /** * Test if the blog has featured tags available. @@ -1937,7 +1937,7 @@ function ttgarden_block_even( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_hasfeaturedtags( $atts, $content = '' ): string { +function clttg_block_hasfeaturedtags( $atts, $content = '' ): string { $output = ''; $tags = get_terms( array( @@ -1948,14 +1948,14 @@ function ttgarden_block_hasfeaturedtags( $atts, $content = '' ): string { ); if ( ! empty( $tags ) ) { - ttgarden_set_parse_context( 'hasfeaturedtags', $tags ); - $output = ttgarden_do_shortcode( $content ); - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'hasfeaturedtags', $tags ); + $output = clttg_do_shortcode( $content ); + clttg_set_parse_context( 'theme', true ); } return $output; } -add_shortcode( 'block_hasfeaturedtags', 'ttgarden_block_hasfeaturedtags' ); +add_shortcode( 'block_hasfeaturedtags', 'clttg_block_hasfeaturedtags' ); /** * If the blog has featured tags, render each of them. @@ -1967,8 +1967,8 @@ function ttgarden_block_hasfeaturedtags( $atts, $content = '' ): string { * * @return string */ -function ttgarden_block_featuredtags( $atts, $content = '' ): string { - $context = ttgarden_get_parse_context(); +function clttg_block_featuredtags( $atts, $content = '' ): string { + $context = clttg_get_parse_context(); $output = ''; if ( ! isset( $context['hasfeaturedtags'] ) ) { @@ -1976,12 +1976,12 @@ function ttgarden_block_featuredtags( $atts, $content = '' ): string { } foreach ( $context['hasfeaturedtags'] as $term ) { - ttgarden_set_parse_context( 'term', $term ); - $output .= ttgarden_do_shortcode( $content ); + clttg_set_parse_context( 'term', $term ); + $output .= clttg_do_shortcode( $content ); } - ttgarden_set_parse_context( 'theme', true ); + clttg_set_parse_context( 'theme', true ); return $output; } -add_shortcode( 'block_featuredtags', 'ttgarden_block_featuredtags' ); +add_shortcode( 'block_featuredtags', 'clttg_block_featuredtags' ); diff --git a/includes/tag-functions.php b/includes/tag-functions.php index b3d057a..6d3ade3 100644 --- a/includes/tag-functions.php +++ b/includes/tag-functions.php @@ -16,7 +16,7 @@ * * @return string */ -function ttgarden_tag_lang( $atts ): string { +function clttg_tag_lang( $atts ): string { // Parse shortcode attributes. $atts = shortcode_atts( array( @@ -27,7 +27,7 @@ function ttgarden_tag_lang( $atts ): string { 'tag_lang' ); - $plugin = ttgarden_get_plugin_instance(); + $plugin = clttg_get_plugin_instance(); $keywords = $plugin->parser->supported_keywords; $stack = array(); @@ -72,24 +72,24 @@ function ( $callback ) { ) ); } -add_shortcode( 'tag_lang', 'ttgarden_tag_lang' ); +add_shortcode( 'tag_lang', 'clttg_tag_lang' ); /** * Outputs target attribute for links. * * @return string */ -function ttgarden_tag_target(): string { +function clttg_tag_target(): string { return get_theme_mod( 'target_blank' ) ? 'target="_blank"' : ''; } -add_shortcode( 'tag_target', 'ttgarden_tag_target' ); +add_shortcode( 'tag_target', 'clttg_tag_target' ); /** * Returns the NPF JSON string of the current post. * * @return string The NPF JSON representation of the current post content. */ -function ttgarden_tag_npf(): string { +function clttg_tag_npf(): string { // Get the current post content $post_content = get_the_content(); @@ -99,26 +99,26 @@ function ttgarden_tag_npf(): string { // Convert the content to NPF format return $converter->convert( $post_content ); } -add_shortcode( 'tag_npf', 'ttgarden_tag_npf' ); +add_shortcode( 'tag_npf', 'clttg_tag_npf' ); /** * The author name of the current post. * * @return string Post author name. */ -function ttgarden_tag_postauthorname(): string { +function clttg_tag_postauthorname(): string { return get_the_author(); } -add_shortcode( 'tag_postauthorname', 'ttgarden_tag_postauthorname' ); -add_shortcode( 'tag_author', 'ttgarden_tag_postauthorname' ); +add_shortcode( 'tag_postauthorname', 'clttg_tag_postauthorname' ); +add_shortcode( 'tag_author', 'clttg_tag_postauthorname' ); /** * Returns the group member display name. * * @return string Username or empty. */ -function ttgarden_tag_groupmembername(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_groupmembername(): string { + $context = clttg_get_parse_context(); if ( isset( $context['groupmember'] ) && is_a( $context['groupmember'], 'WP_User' ) ) { return $context['groupmember']->user_nicename; @@ -126,15 +126,15 @@ function ttgarden_tag_groupmembername(): string { return ''; } -add_shortcode( 'tag_groupmembername', 'ttgarden_tag_groupmembername' ); +add_shortcode( 'tag_groupmembername', 'clttg_tag_groupmembername' ); /** * The URL of the group members posts page. * * @return string The URL of the group member. */ -function ttgarden_tag_groupmemberurl(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_groupmemberurl(): string { + $context = clttg_get_parse_context(); if ( isset( $context['groupmember'] ) && is_a( $context['groupmember'], 'WP_User' ) ) { return get_author_posts_url( $context['groupmember']->ID ); @@ -142,7 +142,7 @@ function ttgarden_tag_groupmemberurl(): string { return ''; } -add_shortcode( 'tag_groupmemberurl', 'ttgarden_tag_groupmemberurl' ); +add_shortcode( 'tag_groupmemberurl', 'clttg_tag_groupmemberurl' ); /** * Gets the group member portrait URL. @@ -153,10 +153,10 @@ function ttgarden_tag_groupmemberurl(): string { * * @return string The URL of the group member avatar. */ -function ttgarden_tag_groupmemberportraiturl( $atts, $content, $shortcode_name ): string { +function clttg_tag_groupmemberportraiturl( $atts, $content, $shortcode_name ): string { $size = str_replace( 'tag_groupmemberportraiturl-', '', $shortcode_name ); - $context = ttgarden_get_parse_context(); + $context = clttg_get_parse_context(); if ( isset( $context['groupmember'] ) && is_a( $context['groupmember'], 'WP_User' ) ) { $groupmember_avatar = get_avatar_url( @@ -175,36 +175,36 @@ function ttgarden_tag_groupmemberportraiturl( $atts, $content, $shortcode_name ) return ''; } -add_shortcode( 'tag_groupmemberportraiturl-16', 'ttgarden_tag_groupmemberportraiturl' ); -add_shortcode( 'tag_groupmemberportraiturl-24', 'ttgarden_tag_groupmemberportraiturl' ); -add_shortcode( 'tag_groupmemberportraiturl-30', 'ttgarden_tag_groupmemberportraiturl' ); -add_shortcode( 'tag_groupmemberportraiturl-40', 'ttgarden_tag_groupmemberportraiturl' ); -add_shortcode( 'tag_groupmemberportraiturl-48', 'ttgarden_tag_groupmemberportraiturl' ); -add_shortcode( 'tag_groupmemberportraiturl-64', 'ttgarden_tag_groupmemberportraiturl' ); -add_shortcode( 'tag_groupmemberportraiturl-96', 'ttgarden_tag_groupmemberportraiturl' ); -add_shortcode( 'tag_groupmemberportraiturl-128', 'ttgarden_tag_groupmemberportraiturl' ); +add_shortcode( 'tag_groupmemberportraiturl-16', 'clttg_tag_groupmemberportraiturl' ); +add_shortcode( 'tag_groupmemberportraiturl-24', 'clttg_tag_groupmemberportraiturl' ); +add_shortcode( 'tag_groupmemberportraiturl-30', 'clttg_tag_groupmemberportraiturl' ); +add_shortcode( 'tag_groupmemberportraiturl-40', 'clttg_tag_groupmemberportraiturl' ); +add_shortcode( 'tag_groupmemberportraiturl-48', 'clttg_tag_groupmemberportraiturl' ); +add_shortcode( 'tag_groupmemberportraiturl-64', 'clttg_tag_groupmemberportraiturl' ); +add_shortcode( 'tag_groupmemberportraiturl-96', 'clttg_tag_groupmemberportraiturl' ); +add_shortcode( 'tag_groupmemberportraiturl-128', 'clttg_tag_groupmemberportraiturl' ); /** * The blog title of the post author. * * @return string */ -function ttgarden_tag_postauthortitle(): string { +function clttg_tag_postauthortitle(): string { return esc_attr( get_bloginfo( 'name' ) ); } -add_shortcode( 'tag_postauthortitle', 'ttgarden_tag_postauthortitle' ); -add_shortcode( 'tag_groupmembertitle', 'ttgarden_tag_postauthortitle' ); -add_shortcode( 'tag_postblogname', 'ttgarden_tag_postauthortitle' ); +add_shortcode( 'tag_postauthortitle', 'clttg_tag_postauthortitle' ); +add_shortcode( 'tag_groupmembertitle', 'clttg_tag_postauthortitle' ); +add_shortcode( 'tag_postblogname', 'clttg_tag_postauthortitle' ); /** * The URL of the post author. * * @return string URL to the author archive. */ -function ttgarden_tag_postauthorurl(): string { +function clttg_tag_postauthorurl(): string { return esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); } -add_shortcode( 'tag_postauthorurl', 'ttgarden_tag_postauthorurl' ); +add_shortcode( 'tag_postauthorurl', 'clttg_tag_postauthorurl' ); /** * The portrait URL of the post author. @@ -215,7 +215,7 @@ function ttgarden_tag_postauthorurl(): string { * * @return string The URL of the author portrait. */ -function ttgarden_tag_postauthorportraiturl( $atts, $content, $shortcode_name ): string { +function clttg_tag_postauthorportraiturl( $atts, $content, $shortcode_name ): string { $size = str_replace( 'tag_postauthorportraiturl-', '', $shortcode_name ); $author_id = get_the_author_meta( 'ID' ); $author = get_user_by( 'ID', $author_id ); @@ -237,24 +237,24 @@ function ttgarden_tag_postauthorportraiturl( $atts, $content, $shortcode_name ): return esc_url( $author_avatar ); } -add_shortcode( 'tag_postauthorportraiturl-16', 'ttgarden_tag_postauthorportraiturl' ); -add_shortcode( 'tag_postauthorportraiturl-24', 'ttgarden_tag_postauthorportraiturl' ); -add_shortcode( 'tag_postauthorportraiturl-30', 'ttgarden_tag_postauthorportraiturl' ); -add_shortcode( 'tag_postauthorportraiturl-40', 'ttgarden_tag_postauthorportraiturl' ); -add_shortcode( 'tag_postauthorportraiturl-48', 'ttgarden_tag_postauthorportraiturl' ); -add_shortcode( 'tag_postauthorportraiturl-64', 'ttgarden_tag_postauthorportraiturl' ); -add_shortcode( 'tag_postauthorportraiturl-96', 'ttgarden_tag_postauthorportraiturl' ); -add_shortcode( 'tag_postauthorportraiturl-128', 'ttgarden_tag_postauthorportraiturl' ); +add_shortcode( 'tag_postauthorportraiturl-16', 'clttg_tag_postauthorportraiturl' ); +add_shortcode( 'tag_postauthorportraiturl-24', 'clttg_tag_postauthorportraiturl' ); +add_shortcode( 'tag_postauthorportraiturl-30', 'clttg_tag_postauthorportraiturl' ); +add_shortcode( 'tag_postauthorportraiturl-40', 'clttg_tag_postauthorportraiturl' ); +add_shortcode( 'tag_postauthorportraiturl-48', 'clttg_tag_postauthorportraiturl' ); +add_shortcode( 'tag_postauthorportraiturl-64', 'clttg_tag_postauthorportraiturl' ); +add_shortcode( 'tag_postauthorportraiturl-96', 'clttg_tag_postauthorportraiturl' ); +add_shortcode( 'tag_postauthorportraiturl-128', 'clttg_tag_postauthorportraiturl' ); /** * Outputs the twitter username theme option. * * @return string Attribute safe twitter username. */ -function ttgarden_tag_twitterusername(): string { +function clttg_tag_twitterusername(): string { return esc_attr( get_theme_mod( 'twitter_username' ) ); } -add_shortcode( 'tag_twitterusername', 'ttgarden_tag_twitterusername' ); +add_shortcode( 'tag_twitterusername', 'clttg_tag_twitterusername' ); /** * The current state of a page in nav. @@ -262,11 +262,11 @@ function ttgarden_tag_twitterusername(): string { * * @return string */ -function ttgarden_tag_currentstate(): string { +function clttg_tag_currentstate(): string { return get_the_permalink() === home_url( add_query_arg( null, null ) ) ? 'current-page' : ''; } -add_shortcode( 'tag_currentstate', 'ttgarden_tag_currentstate' ); -add_shortcode( 'tag_externalstate', 'ttgarden_tag_currentstate' ); +add_shortcode( 'tag_currentstate', 'clttg_tag_currentstate' ); +add_shortcode( 'tag_externalstate', 'clttg_tag_currentstate' ); /** * The display shape of your avatar ("circle" or "square"). @@ -275,10 +275,10 @@ function ttgarden_tag_currentstate(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_avatarshape(): string { +function clttg_tag_avatarshape(): string { return esc_html( get_theme_mod( 'avatar_shape', 'circle' ) ); } -add_shortcode( 'tag_avatarshape', 'ttgarden_tag_avatarshape' ); +add_shortcode( 'tag_avatarshape', 'clttg_tag_avatarshape' ); /** * The background color of your blog. @@ -287,10 +287,10 @@ function ttgarden_tag_avatarshape(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_backgroundcolor(): string { +function clttg_tag_backgroundcolor(): string { return '#' . sanitize_hex_color_no_hash( get_theme_mod( 'background_color', '#fff' ) ); } -add_shortcode( 'tag_backgroundcolor', 'ttgarden_tag_backgroundcolor' ); +add_shortcode( 'tag_backgroundcolor', 'clttg_tag_backgroundcolor' ); /** * The accent color of your blog. @@ -299,10 +299,10 @@ function ttgarden_tag_backgroundcolor(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_accentcolor(): string { +function clttg_tag_accentcolor(): string { return '#' . sanitize_hex_color_no_hash( get_theme_mod( 'accent_color', '#0073aa' ) ); } -add_shortcode( 'tag_accentcolor', 'ttgarden_tag_accentcolor' ); +add_shortcode( 'tag_accentcolor', 'clttg_tag_accentcolor' ); /** * The title color of your blog. @@ -311,10 +311,10 @@ function ttgarden_tag_accentcolor(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_titlecolor(): string { +function clttg_tag_titlecolor(): string { return '#' . sanitize_hex_color_no_hash( get_theme_mod( 'header_textcolor', '#000' ) ); } -add_shortcode( 'tag_titlecolor', 'ttgarden_tag_titlecolor' ); +add_shortcode( 'tag_titlecolor', 'clttg_tag_titlecolor' ); /** * Get the title font theme option. @@ -323,10 +323,10 @@ function ttgarden_tag_titlecolor(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_titlefont(): string { +function clttg_tag_titlefont(): string { return esc_html( get_theme_mod( 'title_font', 'Arial' ) ); } -add_shortcode( 'tag_titlefont', 'ttgarden_tag_titlefont' ); +add_shortcode( 'tag_titlefont', 'clttg_tag_titlefont' ); /** * The weight of your title font ("normal" or "bold"). @@ -335,10 +335,10 @@ function ttgarden_tag_titlefont(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_titlefontweight(): string { +function clttg_tag_titlefontweight(): string { return esc_html( get_theme_mod( 'title_font_weight', 'bold' ) ); } -add_shortcode( 'tag_titlefontweight', 'ttgarden_tag_titlefontweight' ); +add_shortcode( 'tag_titlefontweight', 'clttg_tag_titlefontweight' ); /** * Get the header image theme option. @@ -347,10 +347,10 @@ function ttgarden_tag_titlefontweight(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_headerimage(): string { +function clttg_tag_headerimage(): string { return get_theme_mod( 'header_image', 'remove-header' ); } -add_shortcode( 'tag_headerimage', 'ttgarden_tag_headerimage' ); +add_shortcode( 'tag_headerimage', 'clttg_tag_headerimage' ); /** * Get either a post title, or the blog title. @@ -359,14 +359,14 @@ function ttgarden_tag_headerimage(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_title(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_title(): string { + $context = clttg_get_parse_context(); // Consume global context and return the appropriate title. return ( isset( $context['theme'] ) ) ? get_bloginfo( 'name' ) : get_the_title(); } -add_shortcode( 'tag_title', 'ttgarden_tag_title' ); -add_shortcode( 'tag_posttitle', 'ttgarden_tag_title' ); +add_shortcode( 'tag_title', 'clttg_tag_title' ); +add_shortcode( 'tag_posttitle', 'clttg_tag_title' ); /** * The post content. @@ -375,11 +375,11 @@ function ttgarden_tag_title(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_body(): string { +function clttg_tag_body(): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WP core function. return apply_filters( 'the_content', get_the_content() ); } -add_shortcode( 'tag_body', 'ttgarden_tag_body' ); +add_shortcode( 'tag_body', 'clttg_tag_body' ); /** * The post content. @@ -388,12 +388,12 @@ function ttgarden_tag_body(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_excerpt(): string { +function clttg_tag_excerpt(): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WP core function. return wp_strip_all_tags( apply_filters( 'the_content', get_the_content() ) ); } -add_shortcode( 'tag_excerpt', 'ttgarden_tag_excerpt' ); -add_shortcode( 'tag_sharestring', 'ttgarden_tag_excerpt' ); +add_shortcode( 'tag_excerpt', 'clttg_tag_excerpt' ); +add_shortcode( 'tag_sharestring', 'clttg_tag_excerpt' ); /** * The blog description, or subtitle. @@ -402,8 +402,8 @@ function ttgarden_tag_excerpt(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_description(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_description(): string { + $context = clttg_get_parse_context(); // This tag is used as the_content for audio posts. if ( isset( $context['audio'] ) ) { @@ -425,7 +425,7 @@ function ttgarden_tag_description(): string { // We decode the HTML entities to allow for some allowed HTML tags to be rendered return wp_kses_post( wp_specialchars_decode( get_bloginfo( 'description' ) ) ); } -add_shortcode( 'tag_description', 'ttgarden_tag_description' ); +add_shortcode( 'tag_description', 'clttg_tag_description' ); /** * Attribute safe blog description. @@ -434,10 +434,10 @@ function ttgarden_tag_description(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_metadescription(): string { +function clttg_tag_metadescription(): string { return esc_attr( get_bloginfo( 'description' ) ); } -add_shortcode( 'tag_metadescription', 'ttgarden_tag_metadescription' ); +add_shortcode( 'tag_metadescription', 'clttg_tag_metadescription' ); /** * The homepage URL of the blog. @@ -446,10 +446,10 @@ function ttgarden_tag_metadescription(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_blogurl(): string { +function clttg_tag_blogurl(): string { return esc_url( home_url( '/' ) ); } -add_shortcode( 'tag_blogurl', 'ttgarden_tag_blogurl' ); +add_shortcode( 'tag_blogurl', 'clttg_tag_blogurl' ); /** * The RSS feed URL of the blog. @@ -458,10 +458,10 @@ function ttgarden_tag_blogurl(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_rss(): string { +function clttg_tag_rss(): string { return esc_url( get_feed_link() ); } -add_shortcode( 'tag_rss', 'ttgarden_tag_rss' ); +add_shortcode( 'tag_rss', 'clttg_tag_rss' ); /** * The site favicon image URL. @@ -470,10 +470,10 @@ function ttgarden_tag_rss(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_favicon(): string { +function clttg_tag_favicon(): string { return esc_url( get_site_icon_url() ); } -add_shortcode( 'tag_favicon', 'ttgarden_tag_favicon' ); +add_shortcode( 'tag_favicon', 'clttg_tag_favicon' ); /** * The portrait URL of the blog, uses the custom logo if set. @@ -486,7 +486,7 @@ function ttgarden_tag_favicon(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_portraiturl( $atts, $content, $shortcode_name ): string { +function clttg_tag_portraiturl( $atts, $content, $shortcode_name ): string { if ( ! has_custom_logo() ) { return ''; } @@ -507,14 +507,14 @@ function ttgarden_tag_portraiturl( $atts, $content, $shortcode_name ): string { return esc_url( $custom_logo_src[0] ); } -add_shortcode( 'tag_portraiturl-16', 'ttgarden_tag_portraiturl' ); -add_shortcode( 'tag_portraiturl-24', 'ttgarden_tag_portraiturl' ); -add_shortcode( 'tag_portraiturl-30', 'ttgarden_tag_portraiturl' ); -add_shortcode( 'tag_portraiturl-40', 'ttgarden_tag_portraiturl' ); -add_shortcode( 'tag_portraiturl-48', 'ttgarden_tag_portraiturl' ); -add_shortcode( 'tag_portraiturl-64', 'ttgarden_tag_portraiturl' ); -add_shortcode( 'tag_portraiturl-96', 'ttgarden_tag_portraiturl' ); -add_shortcode( 'tag_portraiturl-128', 'ttgarden_tag_portraiturl' ); +add_shortcode( 'tag_portraiturl-16', 'clttg_tag_portraiturl' ); +add_shortcode( 'tag_portraiturl-24', 'clttg_tag_portraiturl' ); +add_shortcode( 'tag_portraiturl-30', 'clttg_tag_portraiturl' ); +add_shortcode( 'tag_portraiturl-40', 'clttg_tag_portraiturl' ); +add_shortcode( 'tag_portraiturl-48', 'clttg_tag_portraiturl' ); +add_shortcode( 'tag_portraiturl-64', 'clttg_tag_portraiturl' ); +add_shortcode( 'tag_portraiturl-96', 'clttg_tag_portraiturl' ); +add_shortcode( 'tag_portraiturl-128', 'clttg_tag_portraiturl' ); /** * Returns the custom CSS option of the theme. @@ -523,10 +523,10 @@ function ttgarden_tag_portraiturl( $atts, $content, $shortcode_name ): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_customcss(): string { +function clttg_tag_customcss(): string { return esc_html( wp_get_custom_css() ); } -add_shortcode( 'tag_customcss', 'ttgarden_tag_customcss' ); +add_shortcode( 'tag_customcss', 'clttg_tag_customcss' ); /** * Identical to {PostTitle}, but will automatically generate a summary if a title doesn't exist. @@ -535,11 +535,11 @@ function ttgarden_tag_customcss(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_postsummary(): string { +function clttg_tag_postsummary(): string { $title = get_the_title(); return ( '' === $title ) ? $title : get_the_excerpt(); } -add_shortcode( 'tag_postsummary', 'ttgarden_tag_postsummary' ); +add_shortcode( 'tag_postsummary', 'clttg_tag_postsummary' ); /** * Character limited version of {PostSummary} that is suitable for Twitter. @@ -548,11 +548,11 @@ function ttgarden_tag_postsummary(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_tweetsummary(): string { - return esc_html( substr( ttgarden_tag_postsummary(), 0, 280 ) ); +function clttg_tag_tweetsummary(): string { + return esc_html( substr( clttg_tag_postsummary(), 0, 280 ) ); } -add_shortcode( 'tag_tweetsummary', 'ttgarden_tag_tweetsummary' ); -add_shortcode( 'tag_mailsummary', 'ttgarden_tag_tweetsummary' ); +add_shortcode( 'tag_tweetsummary', 'clttg_tag_tweetsummary' ); +add_shortcode( 'tag_mailsummary', 'clttg_tag_tweetsummary' ); /** * Various contextual uses, typically outputs a post permalink. @@ -561,8 +561,8 @@ function ttgarden_tag_tweetsummary(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_url(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_url(): string { + $context = clttg_get_parse_context(); // Link post format. if ( isset( $context['link'], $context['link']['url'] ) ) { @@ -576,11 +576,11 @@ function ttgarden_tag_url(): string { return get_permalink(); } -add_shortcode( 'tag_url', 'ttgarden_tag_url' ); -add_shortcode( 'tag_permalink', 'ttgarden_tag_url' ); -add_shortcode( 'tag_relativepermalink', 'ttgarden_tag_url' ); -add_shortcode( 'tag_shorturl', 'ttgarden_tag_url' ); -add_shortcode( 'tag_embedurl', 'ttgarden_tag_url' ); +add_shortcode( 'tag_url', 'clttg_tag_url' ); +add_shortcode( 'tag_permalink', 'clttg_tag_url' ); +add_shortcode( 'tag_relativepermalink', 'clttg_tag_url' ); +add_shortcode( 'tag_shorturl', 'clttg_tag_url' ); +add_shortcode( 'tag_embedurl', 'clttg_tag_url' ); /** * Typically a page title, used in a page loop e.g navigation. @@ -591,8 +591,8 @@ function ttgarden_tag_url(): string { * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables * @see https://www.tumblr.com/docs/en/custom_themes#chat-posts */ -function ttgarden_tag_label(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_label(): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['chat']['label'] ) ) { // By default, return the page title. @@ -601,7 +601,7 @@ function ttgarden_tag_label(): string { return $context['chat']['label']; } -add_shortcode( 'tag_label', 'ttgarden_tag_label' ); +add_shortcode( 'tag_label', 'clttg_tag_label' ); /** * Current line of a legacy chat post. @@ -610,8 +610,8 @@ function ttgarden_tag_label(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#chat-posts */ -function ttgarden_tag_line(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_line(): string { + $context = clttg_get_parse_context(); // Check if we are in a chat context. if ( ! isset( $context['chat']['line'] ) ) { @@ -620,7 +620,7 @@ function ttgarden_tag_line(): string { return $context['chat']['line']; } -add_shortcode( 'tag_line', 'ttgarden_tag_line' ); +add_shortcode( 'tag_line', 'clttg_tag_line' ); /** * Tagsasclasses outputs the tags of a post as HTML-safe classes. @@ -629,7 +629,7 @@ function ttgarden_tag_line(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tagsasclasses(): string { +function clttg_tagsasclasses(): string { $tags = get_the_tags(); if ( ! $tags || is_wp_error( $tags ) ) { @@ -643,7 +643,7 @@ function ttgarden_tagsasclasses(): string { return implode( ' ', $classes ); } -add_shortcode( 'tag_tagsasclasses', 'ttgarden_tagsasclasses' ); +add_shortcode( 'tag_tagsasclasses', 'clttg_tagsasclasses' ); /** * Label in post footer indicating this is a pinned post. @@ -652,10 +652,10 @@ function ttgarden_tagsasclasses(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_pinnedpostlabel(): string { +function clttg_tag_pinnedpostlabel(): string { return esc_html( CLTTG_LANG['lang:pinned post'] ); } -add_shortcode( 'tag_pinnedpostlabel', 'ttgarden_tag_pinnedpostlabel' ); +add_shortcode( 'tag_pinnedpostlabel', 'clttg_tag_pinnedpostlabel' ); /** * Gets the previous post URL (single post pagination) @@ -664,10 +664,10 @@ function ttgarden_tag_pinnedpostlabel(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_previouspost(): string { +function clttg_tag_previouspost(): string { return untrailingslashit( esc_url( get_permalink( get_adjacent_post( false, '', true ) ) ) ); } -add_shortcode( 'tag_previouspost', 'ttgarden_tag_previouspost' ); +add_shortcode( 'tag_previouspost', 'clttg_tag_previouspost' ); /** * Gets the next post URL (single post pagination) @@ -676,10 +676,10 @@ function ttgarden_tag_previouspost(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_nextpost(): string { +function clttg_tag_nextpost(): string { return untrailingslashit( esc_url( get_permalink( get_adjacent_post( false, '', false ) ) ) ); } -add_shortcode( 'tag_nextpost', 'ttgarden_tag_nextpost' ); +add_shortcode( 'tag_nextpost', 'clttg_tag_nextpost' ); /** * Gets the previous posts page URL (pagination) @@ -688,10 +688,10 @@ function ttgarden_tag_nextpost(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_previouspage(): string|null { +function clttg_tag_previouspage(): string|null { return untrailingslashit( esc_url( get_previous_posts_page_link() ) ); } -add_shortcode( 'tag_previouspage', 'ttgarden_tag_previouspage' ); +add_shortcode( 'tag_previouspage', 'clttg_tag_previouspage' ); /** * Gets the next posts page URL (pagination) @@ -700,10 +700,10 @@ function ttgarden_tag_previouspage(): string|null { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_nextpage(): string|null { +function clttg_tag_nextpage(): string|null { return untrailingslashit( esc_url( get_next_posts_page_link() ) ); } -add_shortcode( 'tag_nextpage', 'ttgarden_tag_nextpage' ); +add_shortcode( 'tag_nextpage', 'clttg_tag_nextpage' ); /** * Gets the current page value (pagination) @@ -712,22 +712,22 @@ function ttgarden_tag_nextpage(): string|null { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_currentpage(): string { +function clttg_tag_currentpage(): string { $page = get_query_var( 'paged' ); return ( $page > 0 ) ? (string) $page : '1'; } -add_shortcode( 'tag_currentpage', 'ttgarden_tag_currentpage' ); +add_shortcode( 'tag_currentpage', 'clttg_tag_currentpage' ); /** * The pagenumber tag inside jump pagination. * * @return string */ -function ttgarden_tag_pagenumber(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_pagenumber(): string { + $context = clttg_get_parse_context(); return isset( $context['jumppagination'] ) ? (string) $context['jumppagination'] : ''; } -add_shortcode( 'tag_pagenumber', 'ttgarden_tag_pagenumber' ); +add_shortcode( 'tag_pagenumber', 'clttg_tag_pagenumber' ); /** * Gets the query total pages (pagination) @@ -736,11 +736,11 @@ function ttgarden_tag_pagenumber(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_totalpages(): string { +function clttg_tag_totalpages(): string { global $wp_query; return ( $wp_query->max_num_pages > 0 ) ? (string) $wp_query->max_num_pages : '1'; } -add_shortcode( 'tag_totalpages', 'ttgarden_tag_totalpages' ); +add_shortcode( 'tag_totalpages', 'clttg_tag_totalpages' ); /** * Displays the span of years your blog has existed. @@ -749,7 +749,7 @@ function ttgarden_tag_totalpages(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_copyrightyears(): string { +function clttg_tag_copyrightyears(): string { // Get the oldest post. $oldest_post = get_posts( array( @@ -766,7 +766,7 @@ function ttgarden_tag_copyrightyears(): string { return get_the_date( 'Y', $oldest_post[0] ) . '-' . gmdate( 'Y' ); } -add_shortcode( 'tag_copyrightyears', 'ttgarden_tag_copyrightyears' ); +add_shortcode( 'tag_copyrightyears', 'clttg_tag_copyrightyears' ); /** * The numeric ID for a post. @@ -775,10 +775,10 @@ function ttgarden_tag_copyrightyears(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_postid(): string { +function clttg_tag_postid(): string { return esc_attr( get_the_ID() ); } -add_shortcode( 'tag_postid', 'ttgarden_tag_postid' ); +add_shortcode( 'tag_postid', 'clttg_tag_postid' ); /** * The name of the current legacy post type. @@ -787,11 +787,11 @@ function ttgarden_tag_postid(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_posttype(): string { +function clttg_tag_posttype(): string { $format = get_post_format(); return ( $format ) ? $format : 'text'; } -add_shortcode( 'tag_posttype', 'ttgarden_tag_posttype' ); +add_shortcode( 'tag_posttype', 'clttg_tag_posttype' ); /** * Current tag name in a loop. @@ -800,8 +800,8 @@ function ttgarden_tag_posttype(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_tag(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_tag(): string { + $context = clttg_get_parse_context(); // Check if we are in a tag context. if ( ! isset( $context['term'] ) || ! is_a( $context['term'], 'WP_Term' ) ) { @@ -810,7 +810,7 @@ function ttgarden_tag_tag(): string { return $context['term']->name; } -add_shortcode( 'tag_tag', 'ttgarden_tag_tag' ); +add_shortcode( 'tag_tag', 'clttg_tag_tag' ); /** * Current tag name in a loop. @@ -819,8 +819,8 @@ function ttgarden_tag_tag(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_urlsafetag(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_urlsafetag(): string { + $context = clttg_get_parse_context(); // Check if we are in a tag context. if ( ! isset( $context['term'] ) || ! is_a( $context['term'], 'WP_Term' ) ) { @@ -829,7 +829,7 @@ function ttgarden_tag_urlsafetag(): string { return rawurlencode( $context['term']->name ); } -add_shortcode( 'tag_urlsafetag', 'ttgarden_tag_urlsafetag' ); +add_shortcode( 'tag_urlsafetag', 'clttg_tag_urlsafetag' ); /** * Current tag url in a loop. @@ -838,8 +838,8 @@ function ttgarden_tag_urlsafetag(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_tagurl(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_tagurl(): string { + $context = clttg_get_parse_context(); // Check if we are in a tag context. if ( ! isset( $context['term'] ) || ! is_a( $context['term'], 'WP_Term' ) ) { @@ -848,8 +848,8 @@ function ttgarden_tag_tagurl(): string { return get_term_link( $context['term'] ); } -add_shortcode( 'tag_tagurl', 'ttgarden_tag_tagurl' ); -add_shortcode( 'tag_tagurlchrono', 'ttgarden_tag_tagurl' ); +add_shortcode( 'tag_tagurl', 'clttg_tag_tagurl' ); +add_shortcode( 'tag_tagurlchrono', 'clttg_tag_tagurl' ); /** * The total number of comments on a post. @@ -858,10 +858,10 @@ function ttgarden_tag_tagurl(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_notecount(): int { +function clttg_tag_notecount(): int { return (int) get_comments_number(); } -add_shortcode( 'tag_notecount', 'ttgarden_tag_notecount' ); +add_shortcode( 'tag_notecount', 'clttg_tag_notecount' ); /** * The total number of comments on a post in text form. @@ -870,11 +870,11 @@ function ttgarden_tag_notecount(): int { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_notecountwithlabel(): string { +function clttg_tag_notecountwithlabel(): string { return get_comments_number_text(); } -add_shortcode( 'tag_notecountwithlabel', 'ttgarden_tag_notecountwithlabel' ); -add_shortcode( 'tag_formattednotecount', 'ttgarden_tag_notecountwithlabel' ); +add_shortcode( 'tag_notecountwithlabel', 'clttg_tag_notecountwithlabel' ); +add_shortcode( 'tag_formattednotecount', 'clttg_tag_notecountwithlabel' ); /** * The post comments. @@ -885,7 +885,7 @@ function ttgarden_tag_notecountwithlabel(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_postnotes( $atts ): string { +function clttg_tag_postnotes( $atts ): string { // Parse shortcode attributes. $atts = shortcode_atts( array( @@ -904,9 +904,9 @@ function ttgarden_tag_postnotes( $atts ): string { return $comments; } -add_shortcode( 'tag_postnotes', 'ttgarden_tag_postnotes' ); -add_shortcode( 'tag_postnotes-16', 'ttgarden_tag_postnotes' ); -add_shortcode( 'tag_postnotes-64', 'ttgarden_tag_postnotes' ); +add_shortcode( 'tag_postnotes', 'clttg_tag_postnotes' ); +add_shortcode( 'tag_postnotes-16', 'clttg_tag_postnotes' ); +add_shortcode( 'tag_postnotes-64', 'clttg_tag_postnotes' ); /** * The current search query. @@ -915,10 +915,10 @@ function ttgarden_tag_postnotes( $atts ): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_searchquery(): string { +function clttg_tag_searchquery(): string { return esc_html( get_search_query() ); } -add_shortcode( 'tag_searchquery', 'ttgarden_tag_searchquery' ); +add_shortcode( 'tag_searchquery', 'clttg_tag_searchquery' ); /** * The current search query URL encoded. @@ -927,10 +927,10 @@ function ttgarden_tag_searchquery(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_urlsafesearchquery(): string { +function clttg_tag_urlsafesearchquery(): string { return rawurlencode( get_search_query() ); } -add_shortcode( 'tag_urlsafesearchquery', 'ttgarden_tag_urlsafesearchquery' ); +add_shortcode( 'tag_urlsafesearchquery', 'clttg_tag_urlsafesearchquery' ); /** * The found posts count of the search result. @@ -939,11 +939,11 @@ function ttgarden_tag_urlsafesearchquery(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_searchresultcount(): string { +function clttg_tag_searchresultcount(): string { global $wp_query; return $wp_query->found_posts; } -add_shortcode( 'tag_searchresultcount', 'ttgarden_tag_searchresultcount' ); +add_shortcode( 'tag_searchresultcount', 'clttg_tag_searchresultcount' ); /** * Quote post content. @@ -952,8 +952,8 @@ function ttgarden_tag_searchresultcount(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_quote(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_quote(): string { + $context = clttg_get_parse_context(); // Test if the current context is a quote post and has a source. if ( isset( $context['quote'], $context['quote']['quote'] ) ) { @@ -963,7 +963,7 @@ function ttgarden_tag_quote(): string { // Empty string if no quote block is found. return ''; } -add_shortcode( 'tag_quote', 'ttgarden_tag_quote' ); +add_shortcode( 'tag_quote', 'clttg_tag_quote' ); /** * Quote post source. @@ -972,8 +972,8 @@ function ttgarden_tag_quote(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_source(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_source(): string { + $context = clttg_get_parse_context(); // Test if the current context is a quote post and has a source. if ( isset( $context['quote'], $context['quote']['source'] ) ) { @@ -982,7 +982,7 @@ function ttgarden_tag_source(): string { return ''; } -add_shortcode( 'tag_source', 'ttgarden_tag_source' ); +add_shortcode( 'tag_source', 'clttg_tag_source' ); /** * Quote content length. @@ -992,8 +992,8 @@ function ttgarden_tag_source(): string { * * @see https://github.tumblr.net/Tumblr/tumblr/blob/046755128a6d61010fcaf4459f8efdc895140ad0/app/models/post.php#L7459 */ -function ttgarden_tag_length(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_length(): string { + $context = clttg_get_parse_context(); // Test if the current context is a quote post and has a length. if ( isset( $context['quote'], $context['quote']['length'] ) ) { @@ -1009,7 +1009,7 @@ function ttgarden_tag_length(): string { // Default to long. return 'long'; } -add_shortcode( 'tag_length', 'ttgarden_tag_length' ); +add_shortcode( 'tag_length', 'clttg_tag_length' ); /** * Audioplayer HTML. @@ -1018,8 +1018,8 @@ function ttgarden_tag_length(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_audioplayer(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_audioplayer(): string { + $context = clttg_get_parse_context(); // Test if the current context is an audio post and has a player. if ( isset( $context['audio'], $context['audio']['player'] ) ) { @@ -1028,15 +1028,15 @@ function ttgarden_tag_audioplayer(): string { return ''; } -add_shortcode( 'tag_audioplayer', 'ttgarden_tag_audioplayer' ); -add_shortcode( 'tag_audioembed', 'ttgarden_tag_audioplayer' ); -add_shortcode( 'tag_audioembed-640', 'ttgarden_tag_audioplayer' ); -add_shortcode( 'tag_audioembed-500', 'ttgarden_tag_audioplayer' ); -add_shortcode( 'tag_audioembed-400', 'ttgarden_tag_audioplayer' ); -add_shortcode( 'tag_audioembed-250', 'ttgarden_tag_audioplayer' ); -add_shortcode( 'tag_audioplayerblack', 'ttgarden_tag_audioplayer' ); -add_shortcode( 'tag_audioplayerwhite', 'ttgarden_tag_audioplayer' ); -add_shortcode( 'tag_audioplayergrey', 'ttgarden_tag_audioplayer' ); +add_shortcode( 'tag_audioplayer', 'clttg_tag_audioplayer' ); +add_shortcode( 'tag_audioembed', 'clttg_tag_audioplayer' ); +add_shortcode( 'tag_audioembed-640', 'clttg_tag_audioplayer' ); +add_shortcode( 'tag_audioembed-500', 'clttg_tag_audioplayer' ); +add_shortcode( 'tag_audioembed-400', 'clttg_tag_audioplayer' ); +add_shortcode( 'tag_audioembed-250', 'clttg_tag_audioplayer' ); +add_shortcode( 'tag_audioplayerblack', 'clttg_tag_audioplayer' ); +add_shortcode( 'tag_audioplayerwhite', 'clttg_tag_audioplayer' ); +add_shortcode( 'tag_audioplayergrey', 'clttg_tag_audioplayer' ); /** * Album art URL, uses the featured image if available. @@ -1045,8 +1045,8 @@ function ttgarden_tag_audioplayer(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_albumarturl(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_albumarturl(): string { + $context = clttg_get_parse_context(); // Test if the current context is an audio post and has a player. if ( isset( $context['audio'], $context['audio']['art'] ) ) { @@ -1055,15 +1055,15 @@ function ttgarden_tag_albumarturl(): string { return ''; } -add_shortcode( 'tag_albumarturl', 'ttgarden_tag_albumarturl' ); +add_shortcode( 'tag_albumarturl', 'clttg_tag_albumarturl' ); /** * Renders the audio player track name. * * @return string */ -function ttgarden_tag_trackname(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_trackname(): string { + $context = clttg_get_parse_context(); // Test if the current context is an audio post and has a player. if ( isset( $context['audio'], $context['audio']['trackname'] ) ) { @@ -1072,15 +1072,15 @@ function ttgarden_tag_trackname(): string { return ''; } -add_shortcode( 'tag_trackname', 'ttgarden_tag_trackname' ); +add_shortcode( 'tag_trackname', 'clttg_tag_trackname' ); /** * Renders the audio player artist name. * * @return string */ -function ttgarden_tag_artist(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_artist(): string { + $context = clttg_get_parse_context(); // Test if the current context is an audio post and has a player. if ( isset( $context['audio'], $context['audio']['artist'] ) ) { @@ -1089,15 +1089,15 @@ function ttgarden_tag_artist(): string { return ''; } -add_shortcode( 'tag_artist', 'ttgarden_tag_artist' ); +add_shortcode( 'tag_artist', 'clttg_tag_artist' ); /** * Renders the audio player album name. * * @return string */ -function ttgarden_tag_album(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_album(): string { + $context = clttg_get_parse_context(); // Test if the current context is an audio post and has a player. if ( isset( $context['audio'], $context['audio']['album'] ) ) { @@ -1106,15 +1106,15 @@ function ttgarden_tag_album(): string { return ''; } -add_shortcode( 'tag_album', 'ttgarden_tag_album' ); +add_shortcode( 'tag_album', 'clttg_tag_album' ); /** * Renders the audio player media URL if it's external. * * @return string */ -function ttgarden_tag_externalaudiourl(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_externalaudiourl(): string { + $context = clttg_get_parse_context(); // Test if the current context is an audio post and has a player. if ( isset( $context['audio'], $context['audio']['player'] ) ) { @@ -1131,16 +1131,16 @@ function ttgarden_tag_externalaudiourl(): string { return ''; } -add_shortcode( 'tag_externalaudiourl', 'ttgarden_tag_externalaudiourl' ); -add_shortcode( 'tag_rawaudiourl', 'ttgarden_tag_externalaudiourl' ); +add_shortcode( 'tag_externalaudiourl', 'clttg_tag_externalaudiourl' ); +add_shortcode( 'tag_rawaudiourl', 'clttg_tag_externalaudiourl' ); /** * Renders the post gallery if one was found. * * @return string */ -function ttgarden_tag_photoset(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_photoset(): string { + $context = clttg_get_parse_context(); // Return nothing if no gallery is found. if ( ! isset( $context['gallery']['gallery'] ) || empty( $context['gallery']['gallery'] ) ) { @@ -1150,31 +1150,31 @@ function ttgarden_tag_photoset(): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WP core function. return apply_filters( 'the_content', $context['gallery']['gallery'] ); } -add_shortcode( 'tag_photoset', 'ttgarden_tag_photoset' ); -add_shortcode( 'tag_photoset-700', 'ttgarden_tag_photoset' ); -add_shortcode( 'tag_photoset-540', 'ttgarden_tag_photoset' ); -add_shortcode( 'tag_photoset-500', 'ttgarden_tag_photoset' ); -add_shortcode( 'tag_photoset-400', 'ttgarden_tag_photoset' ); -add_shortcode( 'tag_photoset-250', 'ttgarden_tag_photoset' ); -add_shortcode( 'tag_photoset-100', 'ttgarden_tag_photoset' ); +add_shortcode( 'tag_photoset', 'clttg_tag_photoset' ); +add_shortcode( 'tag_photoset-700', 'clttg_tag_photoset' ); +add_shortcode( 'tag_photoset-540', 'clttg_tag_photoset' ); +add_shortcode( 'tag_photoset-500', 'clttg_tag_photoset' ); +add_shortcode( 'tag_photoset-400', 'clttg_tag_photoset' ); +add_shortcode( 'tag_photoset-250', 'clttg_tag_photoset' ); +add_shortcode( 'tag_photoset-100', 'clttg_tag_photoset' ); /** * Renders the post gallery layout if one was found. * * @return string */ -function ttgarden_tag_photosetlayout(): string { - return ttgarden_tag_photocount(); +function clttg_tag_photosetlayout(): string { + return clttg_tag_photocount(); } -add_shortcode( 'tag_photosetlayout', 'ttgarden_tag_photosetlayout' ); +add_shortcode( 'tag_photosetlayout', 'clttg_tag_photosetlayout' ); /** * Renders the post gallery photo count if one was found. * * @return string */ -function ttgarden_tag_photocount(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_photocount(): string { + $context = clttg_get_parse_context(); // Return nothing if no gallery is found. if ( ! isset( $context['gallery']['photocount'] ) ) { @@ -1183,16 +1183,16 @@ function ttgarden_tag_photocount(): string { return esc_html( $context['gallery']['photocount'] ); } -add_shortcode( 'tag_photocount', 'ttgarden_tag_photocount' ); -add_shortcode( 'tag_photosetlayout', 'ttgarden_tag_photocount' ); +add_shortcode( 'tag_photocount', 'clttg_tag_photocount' ); +add_shortcode( 'tag_photosetlayout', 'clttg_tag_photocount' ); /** * Renders the post gallery caption if one was found. * * @return string */ -function ttgarden_tag_caption(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_caption(): string { + $context = clttg_get_parse_context(); $format = get_post_format(); if ( ! isset( $context[ $format ], $context[ $format ]['caption'] ) ) { @@ -1202,7 +1202,7 @@ function ttgarden_tag_caption(): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WP core function. return apply_filters( 'the_content', $context[ $format ]['caption'] ); } -add_shortcode( 'tag_caption', 'ttgarden_tag_caption' ); +add_shortcode( 'tag_caption', 'clttg_tag_caption' ); /** * Renders the post image URL if one was found. @@ -1213,7 +1213,7 @@ function ttgarden_tag_caption(): string { * * @return string */ -function ttgarden_tag_photourl( $atts, $content, $shortcode_name ): string { +function clttg_tag_photourl( $atts, $content, $shortcode_name ): string { // Parse shortcode attributes. $atts = shortcode_atts( array( @@ -1223,7 +1223,7 @@ function ttgarden_tag_photourl( $atts, $content, $shortcode_name ): string { $shortcode_name ); - $context = ttgarden_get_parse_context(); + $context = clttg_get_parse_context(); // Return nothing if no image is found. if ( ! isset( $context['image']['image'] ) ) { @@ -1232,12 +1232,12 @@ function ttgarden_tag_photourl( $atts, $content, $shortcode_name ): string { return esc_url( $context['image']['image'] ); } -add_shortcode( 'tag_photourl-500', 'ttgarden_tag_photourl' ); -add_shortcode( 'tag_photourl-400', 'ttgarden_tag_photourl' ); -add_shortcode( 'tag_photourl-250', 'ttgarden_tag_photourl' ); -add_shortcode( 'tag_photourl-100', 'ttgarden_tag_photourl' ); -add_shortcode( 'tag_photourl-highres', 'ttgarden_tag_photourl' ); -add_shortcode( 'tag_photourl-75sq', 'ttgarden_tag_photourl' ); +add_shortcode( 'tag_photourl-500', 'clttg_tag_photourl' ); +add_shortcode( 'tag_photourl-400', 'clttg_tag_photourl' ); +add_shortcode( 'tag_photourl-250', 'clttg_tag_photourl' ); +add_shortcode( 'tag_photourl-100', 'clttg_tag_photourl' ); +add_shortcode( 'tag_photourl-highres', 'clttg_tag_photourl' ); +add_shortcode( 'tag_photourl-75sq', 'clttg_tag_photourl' ); /** * Renders the post image thumbnail URL if one was found. @@ -1248,7 +1248,7 @@ function ttgarden_tag_photourl( $atts, $content, $shortcode_name ): string { * * @return string */ -function ttgarden_tag_thumbnail( $atts, $content, $shortcode_name ): string { +function clttg_tag_thumbnail( $atts, $content, $shortcode_name ): string { $sizes = array( 'tag_thumbnail' => 'thumbnail', 'tag_thumbnail-highres' => 'full', @@ -1256,8 +1256,8 @@ function ttgarden_tag_thumbnail( $atts, $content, $shortcode_name ): string { return get_the_post_thumbnail_url( get_the_id(), $sizes[ $shortcode_name ] ); } -add_shortcode( 'tag_thumbnail', 'ttgarden_tag_thumbnail' ); -add_shortcode( 'tag_thumbnail-highres', 'ttgarden_tag_thumbnail' ); +add_shortcode( 'tag_thumbnail', 'clttg_tag_thumbnail' ); +add_shortcode( 'tag_thumbnail-highres', 'clttg_tag_thumbnail' ); /** * Renders the post image link URL if one was found. @@ -1266,8 +1266,8 @@ function ttgarden_tag_thumbnail( $atts, $content, $shortcode_name ): string { * * @return string */ -function ttgarden_tag_linkurl(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_linkurl(): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['image']['link'] ) ) { return ''; @@ -1290,88 +1290,88 @@ function ttgarden_tag_linkurl(): string { return ''; } -add_shortcode( 'tag_linkurl', 'ttgarden_tag_linkurl' ); +add_shortcode( 'tag_linkurl', 'clttg_tag_linkurl' ); /** * Renders the post image link open tag conditionally. * - * @uses ttgarden_tag_linkurl() + * @uses clttg_tag_linkurl() * @return string */ -function ttgarden_tag_linkopentag(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_linkopentag(): string { + $context = clttg_get_parse_context(); - return ( isset( $context['image']['link'] ) && 'none' !== $context['image']['link'] ) ? '' : ''; + return ( isset( $context['image']['link'] ) && 'none' !== $context['image']['link'] ) ? '' : ''; } -add_shortcode( 'tag_linkopentag', 'ttgarden_tag_linkopentag' ); +add_shortcode( 'tag_linkopentag', 'clttg_tag_linkopentag' ); /** * Renders the post image link close tag conditionally. * * @return string */ -function ttgarden_tag_linkclosetag(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_linkclosetag(): string { + $context = clttg_get_parse_context(); return ( isset( $context['image']['link'] ) && 'none' !== $context['image']['link'] ) ? '' : ''; } -add_shortcode( 'tag_linkclosetag', 'ttgarden_tag_linkclosetag' ); +add_shortcode( 'tag_linkclosetag', 'clttg_tag_linkclosetag' ); /** * Renders the post image camera exif data if found. * * @return string */ -function ttgarden_tag_camera(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_camera(): string { + $context = clttg_get_parse_context(); return isset( $context['image']['data']['image_meta']['camera'] ) ? esc_html( $context['image']['data']['image_meta']['camera'] ) : ''; } -add_shortcode( 'tag_camera', 'ttgarden_tag_camera' ); +add_shortcode( 'tag_camera', 'clttg_tag_camera' ); /** * Renders the post image lens exif data if found. * * @return string */ -function ttgarden_tag_aperture(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_aperture(): string { + $context = clttg_get_parse_context(); return isset( $context['image']['data']['image_meta']['aperture'] ) ? esc_html( $context['image']['data']['image_meta']['aperture'] ) : ''; } -add_shortcode( 'tag_aperture', 'ttgarden_tag_aperture' ); +add_shortcode( 'tag_aperture', 'clttg_tag_aperture' ); /** * Renders the post image focal length exif data if found. * * @return string */ -function ttgarden_tag_focallength(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_focallength(): string { + $context = clttg_get_parse_context(); return isset( $context['image']['data']['image_meta']['focal_length'] ) ? esc_html( $context['image']['data']['image_meta']['focal_length'] ) : ''; } -add_shortcode( 'tag_focallength', 'ttgarden_tag_focallength' ); +add_shortcode( 'tag_focallength', 'clttg_tag_focallength' ); /** * Renders the post image shutter speed exif data if found. * * @return string */ -function ttgarden_tag_exposure(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_exposure(): string { + $context = clttg_get_parse_context(); return isset( $context['image']['data']['image_meta']['shutter_speed'] ) ? esc_html( $context['image']['data']['image_meta']['shutter_speed'] ) : ''; } -add_shortcode( 'tag_exposure', 'ttgarden_tag_exposure' ); +add_shortcode( 'tag_exposure', 'clttg_tag_exposure' ); /** * Renders the post image alt text if one was found. * * @return string */ -function ttgarden_tag_photoalt(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_photoalt(): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['image']['image'] ) ) { return ''; @@ -1379,15 +1379,15 @@ function ttgarden_tag_photoalt(): string { return esc_attr( get_post_meta( $context['image']['image'], '_wp_attachment_image_alt', true ) ); } -add_shortcode( 'tag_photoalt', 'ttgarden_tag_photoalt' ); +add_shortcode( 'tag_photoalt', 'clttg_tag_photoalt' ); /** * Renders the post image width if one was found. * * @return string */ -function ttgarden_tag_photowidth(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_photowidth(): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['image']['data'], $context['image']['data']['width'] ) ) { return ''; @@ -1395,19 +1395,19 @@ function ttgarden_tag_photowidth(): string { return (string) $context['image']['data']['width']; } -add_shortcode( 'tag_photowidth-500', 'ttgarden_tag_photowidth' ); -add_shortcode( 'tag_photowidth-400', 'ttgarden_tag_photowidth' ); -add_shortcode( 'tag_photowidth-250', 'ttgarden_tag_photowidth' ); -add_shortcode( 'tag_photowidth-100', 'ttgarden_tag_photowidth' ); -add_shortcode( 'tag_photowidth-highres', 'ttgarden_tag_photowidth' ); +add_shortcode( 'tag_photowidth-500', 'clttg_tag_photowidth' ); +add_shortcode( 'tag_photowidth-400', 'clttg_tag_photowidth' ); +add_shortcode( 'tag_photowidth-250', 'clttg_tag_photowidth' ); +add_shortcode( 'tag_photowidth-100', 'clttg_tag_photowidth' ); +add_shortcode( 'tag_photowidth-highres', 'clttg_tag_photowidth' ); /** * Renders the post image height if one was found. * * @return string */ -function ttgarden_tag_photoheight(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_photoheight(): string { + $context = clttg_get_parse_context(); if ( ! isset( $context['image']['data'], $context['image']['data']['height'] ) ) { return ''; @@ -1415,19 +1415,19 @@ function ttgarden_tag_photoheight(): string { return (string) $context['image']['data']['height']; } -add_shortcode( 'tag_photoheight-500', 'ttgarden_tag_photoheight' ); -add_shortcode( 'tag_photoheight-400', 'ttgarden_tag_photoheight' ); -add_shortcode( 'tag_photoheight-250', 'ttgarden_tag_photoheight' ); -add_shortcode( 'tag_photoheight-100', 'ttgarden_tag_photoheight' ); -add_shortcode( 'tag_photoheight-highres', 'ttgarden_tag_photoheight' ); +add_shortcode( 'tag_photoheight-500', 'clttg_tag_photoheight' ); +add_shortcode( 'tag_photoheight-400', 'clttg_tag_photoheight' ); +add_shortcode( 'tag_photoheight-250', 'clttg_tag_photoheight' ); +add_shortcode( 'tag_photoheight-100', 'clttg_tag_photoheight' ); +add_shortcode( 'tag_photoheight-highres', 'clttg_tag_photoheight' ); /** * Renders the post video player. * * @return string */ -function ttgarden_tag_video(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_video(): string { + $context = clttg_get_parse_context(); // Test if the current context is a video post and has a player. if ( isset( $context['video'], $context['video']['player'] ) ) { @@ -1436,23 +1436,23 @@ function ttgarden_tag_video(): string { return ''; } -add_shortcode( 'tag_video-700', 'ttgarden_tag_video' ); -add_shortcode( 'tag_video-540', 'ttgarden_tag_video' ); -add_shortcode( 'tag_video-500', 'ttgarden_tag_video' ); -add_shortcode( 'tag_video-400', 'ttgarden_tag_video' ); -add_shortcode( 'tag_video-250', 'ttgarden_tag_video' ); -add_shortcode( 'tag_videoembed-700', 'ttgarden_tag_video' ); -add_shortcode( 'tag_videoembed-500', 'ttgarden_tag_video' ); -add_shortcode( 'tag_videoembed-400', 'ttgarden_tag_video' ); -add_shortcode( 'tag_videoembed-250', 'ttgarden_tag_video' ); +add_shortcode( 'tag_video-700', 'clttg_tag_video' ); +add_shortcode( 'tag_video-540', 'clttg_tag_video' ); +add_shortcode( 'tag_video-500', 'clttg_tag_video' ); +add_shortcode( 'tag_video-400', 'clttg_tag_video' ); +add_shortcode( 'tag_video-250', 'clttg_tag_video' ); +add_shortcode( 'tag_videoembed-700', 'clttg_tag_video' ); +add_shortcode( 'tag_videoembed-500', 'clttg_tag_video' ); +add_shortcode( 'tag_videoembed-400', 'clttg_tag_video' ); +add_shortcode( 'tag_videoembed-250', 'clttg_tag_video' ); /** * Renders the post video thumbnail URL. * * @return string */ -function ttgarden_tag_videothumbnailurl(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_videothumbnailurl(): string { + $context = clttg_get_parse_context(); // Test if the current context is a video post and has a player. if ( isset( $context['video'], $context['video']['thumbnail'] ) ) { @@ -1461,29 +1461,29 @@ function ttgarden_tag_videothumbnailurl(): string { return ''; } -add_shortcode( 'tag_videothumbnailurl', 'ttgarden_tag_videothumbnailurl' ); +add_shortcode( 'tag_videothumbnailurl', 'clttg_tag_videothumbnailurl' ); /** * The link post type title (This is also the link URL). * * @return string */ -function ttgarden_tag_name(): string { +function clttg_tag_name(): string { if ( 'link' === get_post_format() ) { return get_the_title( get_the_ID() ); } return get_the_author(); } -add_shortcode( 'tag_name', 'ttgarden_tag_name' ); +add_shortcode( 'tag_name', 'clttg_tag_name' ); /** * Renders the link post host url. * * @return string */ -function ttgarden_tag_host(): string { - $context = ttgarden_get_parse_context(); +function clttg_tag_host(): string { + $context = clttg_get_parse_context(); if ( isset( $context['theme'] ) ) { return esc_url( home_url( '/' ) ); @@ -1501,7 +1501,7 @@ function ttgarden_tag_host(): string { // Return the host of the URL. return esc_url( $parsed_url['host'] ); } -add_shortcode( 'tag_host', 'ttgarden_tag_host' ); +add_shortcode( 'tag_host', 'clttg_tag_host' ); /** * Returns the day of the month without leading zeros. @@ -1510,10 +1510,10 @@ function ttgarden_tag_host(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_dayofmonth(): string { +function clttg_tag_dayofmonth(): string { return get_the_date( 'j' ); } -add_shortcode( 'tag_dayofmonth', 'ttgarden_tag_dayofmonth' ); +add_shortcode( 'tag_dayofmonth', 'clttg_tag_dayofmonth' ); /** * Returns the day of the month with leading zeros. @@ -1522,10 +1522,10 @@ function ttgarden_tag_dayofmonth(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_dayofmonthwithzero(): string { +function clttg_tag_dayofmonthwithzero(): string { return get_the_date( 'd' ); } -add_shortcode( 'tag_dayofmonthwithzero', 'ttgarden_tag_dayofmonthwithzero' ); +add_shortcode( 'tag_dayofmonthwithzero', 'clttg_tag_dayofmonthwithzero' ); /** * Returns the full name of the day of the week. @@ -1534,10 +1534,10 @@ function ttgarden_tag_dayofmonthwithzero(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_dayofweek(): string { +function clttg_tag_dayofweek(): string { return get_the_date( 'l' ); } -add_shortcode( 'tag_dayofweek', 'ttgarden_tag_dayofweek' ); +add_shortcode( 'tag_dayofweek', 'clttg_tag_dayofweek' ); /** * Returns the abbreviated name of the day of the week. @@ -1546,10 +1546,10 @@ function ttgarden_tag_dayofweek(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_shortdayofweek(): string { +function clttg_tag_shortdayofweek(): string { return get_the_date( 'D' ); } -add_shortcode( 'tag_shortdayofweek', 'ttgarden_tag_shortdayofweek' ); +add_shortcode( 'tag_shortdayofweek', 'clttg_tag_shortdayofweek' ); /** * Returns the day of the week as a number (1 for Monday, 7 for Sunday). @@ -1558,10 +1558,10 @@ function ttgarden_tag_shortdayofweek(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_dayofweeknumber(): string { +function clttg_tag_dayofweeknumber(): string { return get_the_date( 'N' ); } -add_shortcode( 'tag_dayofweeknumber', 'ttgarden_tag_dayofweeknumber' ); +add_shortcode( 'tag_dayofweeknumber', 'clttg_tag_dayofweeknumber' ); /** * Returns the English ordinal suffix for the day of the month. @@ -1570,10 +1570,10 @@ function ttgarden_tag_dayofweeknumber(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_dayofmonthsuffix(): string { +function clttg_tag_dayofmonthsuffix(): string { return get_the_date( 'S' ); } -add_shortcode( 'tag_dayofmonthsuffix', 'ttgarden_tag_dayofmonthsuffix' ); +add_shortcode( 'tag_dayofmonthsuffix', 'clttg_tag_dayofmonthsuffix' ); /** * Returns the day of the month with the English ordinal suffix. @@ -1582,7 +1582,7 @@ function ttgarden_tag_dayofmonthsuffix(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_dayofmonthwithsuffix(): string { +function clttg_tag_dayofmonthwithsuffix(): string { return get_the_date( 'jS' ); } @@ -1593,7 +1593,7 @@ function ttgarden_tag_dayofmonthwithsuffix(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_formattedtime(): string { +function clttg_tag_formattedtime(): string { return get_the_date( 'g:i a' ); } @@ -1604,10 +1604,10 @@ function ttgarden_tag_formattedtime(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_dayofyear(): string { +function clttg_tag_dayofyear(): string { return get_the_date( 'z' ) + 1; // Adding 1 because PHP date 'z' is zero-indexed } -add_shortcode( 'tag_dayofyear', 'ttgarden_tag_dayofyear' ); +add_shortcode( 'tag_dayofyear', 'clttg_tag_dayofyear' ); /** * Returns the week of the year (1 to 53). @@ -1616,10 +1616,10 @@ function ttgarden_tag_dayofyear(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_weekofyear(): string { +function clttg_tag_weekofyear(): string { return get_the_date( 'W' ); } -add_shortcode( 'tag_weekofyear', 'ttgarden_tag_weekofyear' ); +add_shortcode( 'tag_weekofyear', 'clttg_tag_weekofyear' ); /** * Returns the full name of the current month. @@ -1628,10 +1628,10 @@ function ttgarden_tag_weekofyear(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_month(): string { +function clttg_tag_month(): string { return get_the_date( 'F' ); } -add_shortcode( 'tag_month', 'ttgarden_tag_month' ); +add_shortcode( 'tag_month', 'clttg_tag_month' ); /** * Returns the abbreviated name of the current month. @@ -1640,10 +1640,10 @@ function ttgarden_tag_month(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_shortmonth(): string { +function clttg_tag_shortmonth(): string { return get_the_date( 'M' ); } -add_shortcode( 'tag_shortmonth', 'ttgarden_tag_shortmonth' ); +add_shortcode( 'tag_shortmonth', 'clttg_tag_shortmonth' ); /** * Returns the numeric representation of the month without leading zeros. @@ -1652,10 +1652,10 @@ function ttgarden_tag_shortmonth(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_monthnumber(): string { +function clttg_tag_monthnumber(): string { return get_the_date( 'n' ); } -add_shortcode( 'tag_monthnumber', 'ttgarden_tag_monthnumber' ); +add_shortcode( 'tag_monthnumber', 'clttg_tag_monthnumber' ); /** * Returns the numeric representation of the month with leading zeros. @@ -1664,10 +1664,10 @@ function ttgarden_tag_monthnumber(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_monthnumberwithzero(): string { +function clttg_tag_monthnumberwithzero(): string { return get_the_date( 'm' ); } -add_shortcode( 'tag_monthnumberwithzero', 'ttgarden_tag_monthnumberwithzero' ); +add_shortcode( 'tag_monthnumberwithzero', 'clttg_tag_monthnumberwithzero' ); /** * Returns the full numeric representation of the year (e.g., 2024). @@ -1676,10 +1676,10 @@ function ttgarden_tag_monthnumberwithzero(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_year(): string { +function clttg_tag_year(): string { return get_the_date( 'Y' ); } -add_shortcode( 'tag_year', 'ttgarden_tag_year' ); +add_shortcode( 'tag_year', 'clttg_tag_year' ); /** * Returns the last two digits of the year (e.g., 24 for 2024). @@ -1688,10 +1688,10 @@ function ttgarden_tag_year(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_shortyear(): string { +function clttg_tag_shortyear(): string { return get_the_date( 'y' ); } -add_shortcode( 'tag_shortyear', 'ttgarden_tag_shortyear' ); +add_shortcode( 'tag_shortyear', 'clttg_tag_shortyear' ); /** * Returns lowercase 'am' or 'pm' based on the time. @@ -1700,10 +1700,10 @@ function ttgarden_tag_shortyear(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_ampm(): string { +function clttg_tag_ampm(): string { return get_the_date( 'a' ); } -add_shortcode( 'tag_ampm', 'ttgarden_tag_ampm' ); +add_shortcode( 'tag_ampm', 'clttg_tag_ampm' ); /** * Returns uppercase 'AM' or 'PM' based on the time. @@ -1712,10 +1712,10 @@ function ttgarden_tag_ampm(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_capitalampm(): string { +function clttg_tag_capitalampm(): string { return get_the_date( 'A' ); } -add_shortcode( 'tag_capitalampm', 'ttgarden_tag_capitalampm' ); +add_shortcode( 'tag_capitalampm', 'clttg_tag_capitalampm' ); /** * Returns the hour in 12-hour format without leading zeros. @@ -1724,10 +1724,10 @@ function ttgarden_tag_capitalampm(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_12hour(): string { +function clttg_tag_12hour(): string { return get_the_date( 'g' ); } -add_shortcode( 'tag_12hour', 'ttgarden_tag_12hour' ); +add_shortcode( 'tag_12hour', 'clttg_tag_12hour' ); /** * Returns the hour in 24-hour format without leading zeros. @@ -1736,10 +1736,10 @@ function ttgarden_tag_12hour(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_24hour(): string { +function clttg_tag_24hour(): string { return get_the_date( 'G' ); } -add_shortcode( 'tag_24hour', 'ttgarden_tag_24hour' ); +add_shortcode( 'tag_24hour', 'clttg_tag_24hour' ); /** * Returns the hour in 12-hour format with leading zeros. @@ -1748,10 +1748,10 @@ function ttgarden_tag_24hour(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_12hourwithzero(): string { +function clttg_tag_12hourwithzero(): string { return get_the_date( 'h' ); } -add_shortcode( 'tag_12hourwithzero', 'ttgarden_tag_12hourwithzero' ); +add_shortcode( 'tag_12hourwithzero', 'clttg_tag_12hourwithzero' ); /** * Returns the hour in 24-hour format with leading zeros. @@ -1760,10 +1760,10 @@ function ttgarden_tag_12hourwithzero(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_24hourwithzero(): string { +function clttg_tag_24hourwithzero(): string { return get_the_date( 'H' ); } -add_shortcode( 'tag_24hourwithzero', 'ttgarden_tag_24hourwithzero' ); +add_shortcode( 'tag_24hourwithzero', 'clttg_tag_24hourwithzero' ); /** * Returns the minutes with leading zeros. @@ -1772,10 +1772,10 @@ function ttgarden_tag_24hourwithzero(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_minutes(): string { +function clttg_tag_minutes(): string { return get_the_date( 'i' ); } -add_shortcode( 'tag_minutes', 'ttgarden_tag_minutes' ); +add_shortcode( 'tag_minutes', 'clttg_tag_minutes' ); /** * Returns the seconds with leading zeros. @@ -1784,10 +1784,10 @@ function ttgarden_tag_minutes(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_seconds(): string { +function clttg_tag_seconds(): string { return get_the_date( 's' ); } -add_shortcode( 'tag_seconds', 'ttgarden_tag_seconds' ); +add_shortcode( 'tag_seconds', 'clttg_tag_seconds' ); /** * Returns the Swatch Internet Time (.beats). @@ -1796,10 +1796,10 @@ function ttgarden_tag_seconds(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_beats(): string { +function clttg_tag_beats(): string { return get_the_date( 'B' ); } -add_shortcode( 'tag_beats', 'ttgarden_tag_beats' ); +add_shortcode( 'tag_beats', 'clttg_tag_beats' ); /** * Returns the Unix timestamp of the post. @@ -1808,10 +1808,10 @@ function ttgarden_tag_beats(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_timestamp(): string { +function clttg_tag_timestamp(): string { return get_the_date( 'U' ); } -add_shortcode( 'tag_timestamp', 'ttgarden_tag_timestamp' ); +add_shortcode( 'tag_timestamp', 'clttg_tag_timestamp' ); /** * Returns the time difference between the post date and now, in human-readable format. @@ -1820,31 +1820,31 @@ function ttgarden_tag_timestamp(): string { * * @see https://www.tumblr.com/docs/en/custom_themes#basic_variables */ -function ttgarden_tag_timeago(): string { +function clttg_tag_timeago(): string { $post_time = get_the_time( 'U' ); $current_time = time(); // Using PHP's time() for a true Unix UTC timestamp $time_diff = human_time_diff( $post_time, $current_time ); return sprintf( '%s ago', $time_diff ); } -add_shortcode( 'tag_timeago', 'ttgarden_tag_timeago' ); +add_shortcode( 'tag_timeago', 'clttg_tag_timeago' ); /** * Returns the noun of the current post type. * * @return string */ -function ttgarden_tag_posttypenoun(): string { +function clttg_tag_posttypenoun(): string { $format = get_post_format(); return ucfirst( ( $format ) ? $format : 'post' ); } -add_shortcode( 'tag_posttypenoun', 'ttgarden_tag_posttypenoun' ); +add_shortcode( 'tag_posttypenoun', 'clttg_tag_posttypenoun' ); /** * Creates a WordPress.com reblog URL for the current post. * * @return string */ -function ttgarden_tag_reblogurl(): string { +function clttg_tag_reblogurl(): string { return esc_url( sprintf( 'https://wordpress.com/post?url=%s?is_post_share=true', @@ -1852,7 +1852,7 @@ function ttgarden_tag_reblogurl(): string { ) ); } -add_shortcode( 'tag_reblogurl', 'ttgarden_tag_reblogurl' ); +add_shortcode( 'tag_reblogurl', 'clttg_tag_reblogurl' ); /** * Creates a like iFrame for the current post. Relies on Jetpack's like button. @@ -1862,7 +1862,7 @@ function ttgarden_tag_reblogurl(): string { * @see https://github.com/Automattic/jetpack/blob/trunk/projects/plugins/jetpack/extensions/blocks/like/like.php * @see https://github.com/Automattic/jetpack/blob/trunk/projects/plugins/jetpack/modules/likes/queuehandler.js#L417 */ -function ttgarden_tag_likebutton(): string { +function clttg_tag_likebutton(): string { if ( ! function_exists( '\Automattic\Jetpack\Extensions\Like\render_block' ) ) { return ''; } @@ -1926,17 +1926,17 @@ public function __construct( $id ) { $data_title ); } -add_shortcode( 'tag_likebutton', 'ttgarden_tag_likebutton' ); +add_shortcode( 'tag_likebutton', 'clttg_tag_likebutton' ); /** * Returns a URL to the post comments HTML partial. * * @return string */ -function ttgarden_tag_postnotesurl(): string { +function clttg_tag_postnotesurl(): string { return sprintf( - '/?p=%d&ttgarden_html_comments=true', + '/?p=%d&clttg_html_comments=true', get_the_ID() ); } -add_shortcode( 'tag_postnotesurl', 'ttgarden_tag_postnotesurl' ); +add_shortcode( 'tag_postnotesurl', 'clttg_tag_postnotesurl' ); diff --git a/src/CLTTG_BlockExtensions.php b/src/CLTTG_BlockExtensions.php index 0f7ab83..8bd7f0f 100644 --- a/src/CLTTG_BlockExtensions.php +++ b/src/CLTTG_BlockExtensions.php @@ -21,19 +21,19 @@ class CLTTG_BlockExtensions { * * @var bool */ - private $is_ttgarden_active; + private $is_clttg_active; /** * Initialize block extensions * - * @param bool $is_ttgarden_active Whether flag is active. + * @param bool $is_clttg_active Whether flag is active. * @return void */ - public function initialize( $is_ttgarden_active ): void { - $this->is_ttgarden_active = $is_ttgarden_active; + public function initialize( $is_clttg_active ): void { + $this->is_clttg_active = $is_clttg_active; // Only run if the TumblrThemeGarden theme is active. - if ( $this->is_ttgarden_active ) { + if ( $this->is_clttg_active ) { add_filter( 'render_block', array( $this, 'tumblr_audio_block_output' ), 10, 2 ); } } @@ -53,7 +53,7 @@ public function tumblr_audio_block_output( $block_content, $block ) { $attrs = $block['attrs']; // Only modify if we have the Tumblr custom attributes - if ( $this->is_ttgarden_active && empty( $attrs['mediaURL'] ) && empty( $attrs['mediaTitle'] ) ) { + if ( $this->is_clttg_active && empty( $attrs['mediaURL'] ) && empty( $attrs['mediaTitle'] ) ) { return $block_content; } diff --git a/src/CLTTG_Customizer.php b/src/CLTTG_Customizer.php index c3376bd..285b07f 100644 --- a/src/CLTTG_Customizer.php +++ b/src/CLTTG_Customizer.php @@ -19,16 +19,16 @@ class CLTTG_Customizer { * @since 1.0.0 * @version 1.0.0 * - * @param boolean $is_ttgarden_active Whether the TumblrThemeGarden theme is active. + * @param boolean $is_clttg_active Whether the TumblrThemeGarden theme is active. * * @return void */ - public function initialize( $is_ttgarden_active ): void { + public function initialize( $is_clttg_active ): void { // CLTTG_Customizer actions to run when this plugin is active. add_action( 'customize_register', array( $this, 'tumblr_html_options' ) ); // Only run the rest of the actions if the TumblrThemeGarden theme is active. - if ( $is_ttgarden_active ) { + if ( $is_clttg_active ) { add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_customizer_scripts' ) ); add_action( 'customize_register', array( $this, 'global_options' ) ); add_action( 'customize_register', array( $this, 'theme_specific_options' ) ); @@ -43,7 +43,7 @@ public function initialize( $is_ttgarden_active ): void { * @return void */ public function enqueue_customizer_scripts(): void { - $deps = ttgarden_get_asset_meta( CLTTG_PATH . 'assets/js/build/customizer.asset.php' ); + $deps = clttg_get_asset_meta( CLTTG_PATH . 'assets/js/build/customizer.asset.php' ); wp_enqueue_script( 'tumblr-theme-garden-customizer', @@ -84,7 +84,7 @@ public function tumblr_html_options( $wp_customize ): void { // Add Theme HTML section. $wp_customize->add_section( - 'ttgarden_html', + 'clttg_html', array( 'title' => __( 'Tumblr Theme HTML', 'tumblr-theme-garden' ), 'priority' => 30, @@ -103,7 +103,7 @@ public function tumblr_html_options( $wp_customize ): void { * @todo lack of sanitization is a security risk. */ $wp_customize->add_setting( - 'ttgarden_theme_html', + 'clttg_theme_html', array( 'type' => 'option', 'capability' => 'edit_theme_options', @@ -115,10 +115,10 @@ public function tumblr_html_options( $wp_customize ): void { // see: https://github.com/WordPress/WordPress/blob/master/wp-includes/customize/class-wp-customize-code-editor-control.php $editor = new \WP_Customize_Code_Editor_Control( $wp_customize, - 'ttgarden_theme_html', + 'clttg_theme_html', array( 'label' => '', - 'section' => 'ttgarden_html', + 'section' => 'clttg_html', 'priority' => 10, ) ); @@ -163,7 +163,7 @@ public function rename_panels( $wp_customize ): void { $panel = $wp_customize->get_panel( 'themes' ); if ( $panel ) { - $external_theme = get_option( 'ttgarden_external_theme' ); + $external_theme = get_option( 'clttg_external_theme' ); $panel->title = $external_theme['title'] ?? 'TumblrThemeGarden'; } } @@ -229,7 +229,7 @@ public function global_options( $wp_customize ): void { 'title_font', array( 'label' => __( 'Title Font', 'tumblr-theme-garden' ), - 'section' => 'ttgarden_font', + 'section' => 'clttg_font', 'type' => 'text', 'priority' => 10, ) @@ -248,7 +248,7 @@ public function global_options( $wp_customize ): void { 'title_font_weight', array( 'label' => __( 'Title Font Weight', 'tumblr-theme-garden' ), - 'section' => 'ttgarden_font', + 'section' => 'clttg_font', 'type' => 'select', 'choices' => array( 'normal' => 'Normal', @@ -271,7 +271,7 @@ public function global_options( $wp_customize ): void { 'avatar_shape', array( 'label' => __( 'Avatar Shape', 'tumblr-theme-garden' ), - 'section' => 'ttgarden_select', + 'section' => 'clttg_select', 'type' => 'select', 'choices' => array( 'circle' => 'Circle', @@ -294,7 +294,7 @@ public function global_options( $wp_customize ): void { 'show_header_image', array( 'label' => __( 'Show Header Image', 'tumblr-theme-garden' ), - 'section' => 'ttgarden_boolean', + 'section' => 'clttg_boolean', 'type' => 'checkbox', 'priority' => 10, ) @@ -313,7 +313,7 @@ public function global_options( $wp_customize ): void { 'stretch_header_image', array( 'label' => __( 'Stretch Header Image', 'tumblr-theme-garden' ), - 'section' => 'ttgarden_boolean', + 'section' => 'clttg_boolean', 'type' => 'checkbox', 'priority' => 10, ) @@ -332,7 +332,7 @@ public function global_options( $wp_customize ): void { 'show_avatar', array( 'label' => __( 'Show Avatar', 'tumblr-theme-garden' ), - 'section' => 'ttgarden_boolean', + 'section' => 'clttg_boolean', 'type' => 'checkbox', 'priority' => 10, ) @@ -351,7 +351,7 @@ public function global_options( $wp_customize ): void { 'target_blank', array( 'label' => __( 'Open Links in New Tab', 'tumblr-theme-garden' ), - 'section' => 'ttgarden_boolean', + 'section' => 'clttg_boolean', 'type' => 'checkbox', 'priority' => 10, ) @@ -370,7 +370,7 @@ public function global_options( $wp_customize ): void { 'twitter_username', array( 'label' => __( 'Twitter Username', 'tumblr-theme-garden' ), - 'section' => 'ttgarden_text', + 'section' => 'clttg_text', 'type' => 'text', 'priority' => 10, ) @@ -389,7 +389,7 @@ public function global_options( $wp_customize ): void { public function theme_specific_options( $wp_customize ): void { // Add select options section. $wp_customize->add_section( - 'ttgarden_select', + 'clttg_select', array( 'title' => __( 'Tumblr Theme Select Options', 'tumblr-theme-garden' ), 'priority' => 30, @@ -398,7 +398,7 @@ public function theme_specific_options( $wp_customize ): void { // Add text options section. $wp_customize->add_section( - 'ttgarden_text', + 'clttg_text', array( 'title' => __( 'Tumblr Theme Text Options', 'tumblr-theme-garden' ), 'priority' => 30, @@ -407,7 +407,7 @@ public function theme_specific_options( $wp_customize ): void { // Add font options section. $wp_customize->add_section( - 'ttgarden_font', + 'clttg_font', array( 'title' => __( 'Tumblr Theme Font Options', 'tumblr-theme-garden' ), 'priority' => 30, @@ -416,7 +416,7 @@ public function theme_specific_options( $wp_customize ): void { // Add boolean options section. $wp_customize->add_section( - 'ttgarden_boolean', + 'clttg_boolean', array( 'title' => __( 'Tumblr Theme Checkbox Options', 'tumblr-theme-garden' ), 'priority' => 30, @@ -425,7 +425,7 @@ public function theme_specific_options( $wp_customize ): void { // Add image options section. $wp_customize->add_section( - 'ttgarden_image', + 'clttg_image', array( 'title' => __( 'Tumblr Theme Image Options', 'tumblr-theme-garden' ), 'priority' => 30, @@ -433,7 +433,7 @@ public function theme_specific_options( $wp_customize ): void { ); // Parse the theme HTML. - $processor = new \WP_HTML_Tag_Processor( get_option( 'ttgarden_theme_html', '' ) ); + $processor = new \WP_HTML_Tag_Processor( get_option( 'clttg_theme_html', '' ) ); $select_options = array(); // Stop on META tags. @@ -452,7 +452,7 @@ public function theme_specific_options( $wp_customize ): void { $label = substr( $name, strlen( 'color:' ) ); // Option names need to be lowercase and without spaces. - $name = ttgarden_normalize_option_name( $name ); + $name = clttg_normalize_option_name( $name ); $wp_customize->add_setting( $name, @@ -490,7 +490,7 @@ public function theme_specific_options( $wp_customize ): void { $label = substr( $name, strlen( 'font:' ) ); // Option names need to be lowercase and without spaces. - $name = ttgarden_normalize_option_name( $name ); + $name = clttg_normalize_option_name( $name ); $wp_customize->add_setting( $name, @@ -505,7 +505,7 @@ public function theme_specific_options( $wp_customize ): void { $name, array( 'label' => $label, - 'section' => 'ttgarden_font', + 'section' => 'clttg_font', 'type' => 'text', 'priority' => 10, ) @@ -527,7 +527,7 @@ public function theme_specific_options( $wp_customize ): void { $label = substr( $name, strlen( 'if:' ) ); // Option names need to be lowercase and without spaces. - $name = ttgarden_normalize_option_name( $name ); + $name = clttg_normalize_option_name( $name ); $wp_customize->add_setting( $name, @@ -542,7 +542,7 @@ public function theme_specific_options( $wp_customize ): void { $name, array( 'label' => $label, - 'section' => 'ttgarden_boolean', + 'section' => 'clttg_boolean', 'type' => 'checkbox', 'priority' => 10, ) @@ -564,7 +564,7 @@ public function theme_specific_options( $wp_customize ): void { $label = substr( $name, strlen( 'text:' ) ); // Option names need to be lowercase and without spaces. - $name = ttgarden_normalize_option_name( $name ); + $name = clttg_normalize_option_name( $name ); $wp_customize->add_setting( $name, @@ -579,7 +579,7 @@ public function theme_specific_options( $wp_customize ): void { $name, array( 'label' => $label, - 'section' => 'ttgarden_text', + 'section' => 'clttg_text', 'type' => 'text', 'priority' => 10, ) @@ -601,7 +601,7 @@ public function theme_specific_options( $wp_customize ): void { $label = substr( $name, strlen( 'image:' ) ); // Option names need to be lowercase and without spaces. - $name = ttgarden_normalize_option_name( $name ); + $name = clttg_normalize_option_name( $name ); $wp_customize->add_setting( $name, @@ -618,7 +618,7 @@ public function theme_specific_options( $wp_customize ): void { $name, array( 'label' => $label, - 'section' => 'ttgarden_image', + 'section' => 'clttg_image', 'settings' => $name, 'priority' => 10, ) @@ -651,7 +651,7 @@ public function theme_specific_options( $wp_customize ): void { $default = ( isset( $options[0], $options[0]['content'] ) ) ? $options[0]['content'] : ''; // Option names need to be lowercase and without spaces. - $name = ttgarden_normalize_option_name( $label ); + $name = clttg_normalize_option_name( $label ); $wp_customize->add_setting( $name, @@ -666,7 +666,7 @@ public function theme_specific_options( $wp_customize ): void { $name, array( 'label' => $label, - 'section' => 'ttgarden_select', + 'section' => 'clttg_select', 'type' => 'select', 'choices' => array_column( $options, 'title', 'content' ), 'priority' => 10, diff --git a/src/CLTTG_FeatureSniffer.php b/src/CLTTG_FeatureSniffer.php index 7c5c4b4..c0e0fa3 100644 --- a/src/CLTTG_FeatureSniffer.php +++ b/src/CLTTG_FeatureSniffer.php @@ -60,7 +60,7 @@ class CLTTG_FeatureSniffer { public function __construct( $html = '' ) { // Define the unsupported features, done in constructor due to dynamic data. $this->unsupported_features = apply_filters( - 'ttgarden_unsupported_features', + 'clttg_unsupported_features', array( '{npf}' => array( 'name' => 'Neue Post Format', @@ -95,7 +95,7 @@ public function __construct( $html = '' ) { */ public function find_unsupported_features(): void { // Load in either the HTML passed to the class constructor or the option value. - $html = ( '' === $this->html ) ? strtolower( get_option( 'ttgarden_theme_html' ) ) : strtolower( $this->html ); + $html = ( '' === $this->html ) ? strtolower( get_option( 'clttg_theme_html' ) ) : strtolower( $this->html ); // Check each unsupported feature. foreach ( $this->unsupported_features as $feature => $data ) { diff --git a/src/CLTTG_Hooks.php b/src/CLTTG_Hooks.php index 7547fba..297424a 100644 --- a/src/CLTTG_Hooks.php +++ b/src/CLTTG_Hooks.php @@ -24,7 +24,7 @@ class CLTTG_Hooks { * * @var bool */ - private $is_ttgarden_active; + private $is_clttg_active; /** * Initializes the CLTTG_Hooks. @@ -32,15 +32,15 @@ class CLTTG_Hooks { * @since 1.0.0 * @version 1.0.0 * - * @param boolean $is_ttgarden_active The TumblrThemeGarden active status. + * @param boolean $is_clttg_active The TumblrThemeGarden active status. * * @return void */ - public function initialize( $is_ttgarden_active ): void { - $this->is_ttgarden_active = $is_ttgarden_active; + public function initialize( $is_clttg_active ): void { + $this->is_clttg_active = $is_clttg_active; // Add actions to the checkbox option that turns on the Tumblr theme. - add_action( 'update_option_ttgarden_use_theme', array( $this, 'update_option_ttgarden_use_theme' ), 10, 2 ); + add_action( 'update_option_clttg_use_theme', array( $this, 'update_option_clttg_use_theme' ), 10, 2 ); // Filter the theme root to use the Tumblr theme directory, if the option is set. add_filter( 'theme_root', array( $this, 'theme_root' ), 10, 2 ); @@ -53,7 +53,7 @@ public function initialize( $is_ttgarden_active ): void { add_action( 'after_plugin_row_meta', array( $this, 'plugin_row_meta' ), 10 ); // Only run these if the TumblrThemeGarden theme is active. - if ( $this->is_ttgarden_active ) { + if ( $this->is_clttg_active ) { add_filter( 'validate_current_theme', '__return_false' ); add_filter( 'wp_prepare_themes_for_js', array( $this, 'prepare_themes_for_js' ) ); } @@ -68,7 +68,7 @@ public function initialize( $is_ttgarden_active ): void { */ public function prepare_themes_for_js( $themes ): array { if ( isset( $themes['tumblr-theme-garden'] ) ) { - $theme_details = get_option( 'ttgarden_external_theme' ); + $theme_details = get_option( 'clttg_external_theme' ); // Prepare the Tumblr theme screenshot. if ( isset( $theme_details['thumbnail'] ) && ! empty( $theme_details['thumbnail'] ) ) { @@ -113,7 +113,7 @@ public function theme_root( $root ): string { } // If TumblrThemeGarden is the active theme, return the Tumblr theme directory. - if ( $this->is_ttgarden_active ) { + if ( $this->is_clttg_active ) { // Register the theme directory if it hasn't been registered yet. if ( null === $registered || false === $registered ) { $registered = register_theme_directory( CLTTG_PATH . 'theme' ); @@ -133,12 +133,12 @@ public function theme_root( $root ): string { * * @return void */ - public function update_option_ttgarden_use_theme( $old_value, $value ): void { + public function update_option_clttg_use_theme( $old_value, $value ): void { if ( '1' === $value ) { - update_option( 'ttgarden_original_theme', get_option( 'template' ) ); + update_option( 'clttg_original_theme', get_option( 'template' ) ); switch_theme( 'tumblr-theme-garden' ); } else { - switch_theme( get_option( 'ttgarden_original_theme' ) ); + switch_theme( get_option( 'clttg_original_theme' ) ); } } @@ -157,9 +157,9 @@ public function switch_theme( $new_name, $new_theme, $old_theme ): void { } if ( 'tumblr-theme-garden' === $old_theme->stylesheet ) { - update_option( 'ttgarden_original_theme', '' ); - update_option( 'ttgarden_use_theme', '' ); - update_option( 'ttgarden_theme_html', '' ); + update_option( 'clttg_original_theme', '' ); + update_option( 'clttg_use_theme', '' ); + update_option( 'clttg_theme_html', '' ); } } diff --git a/src/CLTTG_Parser.php b/src/CLTTG_Parser.php index b3f5ad0..4d64c47 100644 --- a/src/CLTTG_Parser.php +++ b/src/CLTTG_Parser.php @@ -20,20 +20,20 @@ class CLTTG_Parser { * @var array */ public array $supported_keywords = array( - 'currentpage' => 'ttgarden_tag_currentpage', - 'totalpages' => 'ttgarden_tag_totalpages', - 'searchresultcount' => 'ttgarden_tag_searchresultcount', - 'searchquery' => 'ttgarden_tag_searchquery', - 'timeago' => 'ttgarden_tag_timeago', - 'dayofweek' => 'ttgarden_tag_dayofweek', - 'dayofmonth' => 'ttgarden_tag_dayofmonth', - 'dayofmonthwithsuffix' => 'ttgarden_tag_dayofmonthwithsuffix', - 'month' => 'ttgarden_tag_month', - 'year' => 'ttgarden_tag_year', - 'formattedtime' => 'ttgarden_tag_formattedtime', - 'notecount' => 'ttgarden_tag_notecount', - 'postauthorname' => 'ttgarden_tag_postauthorname', - 'posttypenoun' => 'ttgarden_tag_posttypenoun', + 'currentpage' => 'clttg_tag_currentpage', + 'totalpages' => 'clttg_tag_totalpages', + 'searchresultcount' => 'clttg_tag_searchresultcount', + 'searchquery' => 'clttg_tag_searchquery', + 'timeago' => 'clttg_tag_timeago', + 'dayofweek' => 'clttg_tag_dayofweek', + 'dayofmonth' => 'clttg_tag_dayofmonth', + 'dayofmonthwithsuffix' => 'clttg_tag_dayofmonthwithsuffix', + 'month' => 'clttg_tag_month', + 'year' => 'clttg_tag_year', + 'formattedtime' => 'clttg_tag_formattedtime', + 'notecount' => 'clttg_tag_notecount', + 'postauthorname' => 'clttg_tag_postauthorname', + 'posttypenoun' => 'clttg_tag_posttypenoun', 'tag' => '__return_empty_string', 'tagresultcount' => '__return_empty_string', ); @@ -79,7 +79,7 @@ public function initialize(): void { add_filter( 'do_shortcode_tag', array( $this, 'modifiers' ), 10, 3 ); // Parse the Tumblr theme. - add_filter( 'ttgarden_theme_output', array( $this, 'parse_theme' ), 10 ); + add_filter( 'clttg_theme_output', array( $this, 'parse_theme' ), 10 ); } /** @@ -169,7 +169,7 @@ public function parse_theme( $content ): string { * The shortcode system allows for dynamic content inside a post loop, and other areas. */ $content = preg_replace_callback( - ttgarden_get_tumblr_regex(), + clttg_get_tumblr_regex(), function ( $matches ) use ( $tags, $blocks, $options, $modifiers ) { ++$this->position; @@ -230,7 +230,7 @@ function ( $matches ) use ( $tags, $blocks, $options, $modifiers ) { foreach ( $options as $option ) { if ( str_starts_with( $raw_tag, $option ) ) { // Normalize the option name. - $theme_mod = get_theme_mod( ttgarden_normalize_option_name( $raw_tag ) ); + $theme_mod = get_theme_mod( clttg_normalize_option_name( $raw_tag ) ); // Apply the modifier if it exists. if ( '' !== $applied_modifier && $theme_mod ) { @@ -268,7 +268,7 @@ function ( $matches ) use ( $tags, $blocks, $options, $modifiers ) { * Third: Run the content through the shortcode parser to kick-off page creation. */ $pattern = get_shortcode_regex( array_merge( CLTTG_MISSING_BLOCKS, CLTTG_MISSING_TAGS ) ); - $content = ttgarden_do_shortcode( preg_replace_callback( "/$pattern/", '__return_empty_string', $content ) ); + $content = clttg_do_shortcode( preg_replace_callback( "/$pattern/", '__return_empty_string', $content ) ); $content = preg_replace( '/(\[\/[a-zA-z\d]*?\])/', '', $content ); return $content; @@ -350,7 +350,7 @@ public function boolean_helper( $boolean ): string { $shortcode = 'block_' . $condition . '_' . $normalized_attr; // Register the new shortcode on the fly. - add_shortcode( $shortcode, 'ttgarden_block_' . $condition . '_theme_option' ); + add_shortcode( $shortcode, 'clttg_block_' . $condition . '_theme_option' ); return ( str_starts_with( $boolean, '/' ) ) ? '[/' . $shortcode . ']' : '[' . $shortcode . " name=\"$normalized_attr\"]"; } diff --git a/src/CLTTG_Plugin.php b/src/CLTTG_Plugin.php index c899c4e..a5e921b 100644 --- a/src/CLTTG_Plugin.php +++ b/src/CLTTG_Plugin.php @@ -25,7 +25,7 @@ class CLTTG_Plugin { * * @var bool */ - public bool $ttgarden_active = false; + public bool $clttg_active = false; /** * The hooks component. @@ -138,21 +138,21 @@ public static function get_instance(): self { * @return void */ public function initialize(): void { - $this->ttgarden_active = 'tumblr-theme-garden' === get_option( 'template' ); + $this->clttg_active = 'tumblr-theme-garden' === get_option( 'template' ); // Setup all plugin hooks. $this->hooks = new CLTTG_Hooks(); - $this->hooks->initialize( $this->ttgarden_active ); + $this->hooks->initialize( $this->clttg_active ); // Setup the customizer with default and custom theme options. $this->customizer = new CLTTG_Customizer(); - $this->customizer->initialize( $this->ttgarden_active ); + $this->customizer->initialize( $this->clttg_active ); $this->theme_garden = new CLTTG_ThemeGarden(); $this->theme_garden->initialize(); $this->block_extensions = new CLTTG_BlockExtensions(); - $this->block_extensions->initialize( $this->ttgarden_active ); + $this->block_extensions->initialize( $this->clttg_active ); // In the frontend, setup the parser. if ( ! is_admin() ) { diff --git a/src/CLTTG_ThemeGarden.php b/src/CLTTG_ThemeGarden.php index c69e03b..b2d4a37 100644 --- a/src/CLTTG_ThemeGarden.php +++ b/src/CLTTG_ThemeGarden.php @@ -79,14 +79,14 @@ public function initialize(): void { */ public function enqueue_assets( string $hook ): void { if ( 'appearance_page_' . self::ADMIN_MENU_SLUG === $hook ) { - $deps = ttgarden_get_asset_meta( CLTTG_PATH . 'assets/js/build/theme-garden.asset.php' ); + $deps = clttg_get_asset_meta( CLTTG_PATH . 'assets/js/build/theme-garden.asset.php' ); $this->enqueue_admin_styles( $deps['version'] ); $themes_and_categories = $this->get_themes_and_categories(); $theme_details = $this->selected_theme_id ? $this->get_theme( $this->selected_theme_id ) : null; - $is_using_tumblr_theme = get_option( 'ttgarden_use_theme' ); - $active_theme = $is_using_tumblr_theme ? get_option( 'ttgarden_external_theme' ) : null; + $is_using_tumblr_theme = get_option( 'clttg_use_theme' ); + $active_theme = $is_using_tumblr_theme ? get_option( 'clttg_external_theme' ) : null; wp_enqueue_script( 'tumblr-theme-garden', @@ -117,7 +117,7 @@ public function enqueue_assets( string $hook ): void { } if ( 'theme-install.php' === $hook ) { - $deps = ttgarden_get_asset_meta( CLTTG_PATH . 'assets/js/build/theme-install.asset.php' ); + $deps = clttg_get_asset_meta( CLTTG_PATH . 'assets/js/build/theme-install.asset.php' ); $this->enqueue_admin_styles( $deps['version'] ); @@ -259,7 +259,7 @@ public function maybe_activate_theme(): void { return; } // Save theme details to options. - update_option( 'ttgarden_theme_html', $theme->theme ); + update_option( 'clttg_theme_html', $theme->theme ); // Save all external theme details to an option. $external_theme_details = array( @@ -270,8 +270,8 @@ public function maybe_activate_theme(): void { 'author_url' => isset( $theme->author->url ) ? $theme->author->url : '', ); - update_option( 'ttgarden_external_theme', $external_theme_details ); - update_option( 'ttgarden_use_theme', '1' ); + update_option( 'clttg_external_theme', $external_theme_details ); + update_option( 'clttg_use_theme', '1' ); // Setup theme option defaults. $this->option_defaults_helper( maybe_unserialize( $theme->default_params ) ); @@ -331,18 +331,18 @@ function ( $theme ) { * @return void */ public function option_defaults_helper( $default_params ): void { - $ttgarden_mods = get_option( 'theme_mods_tumblr-theme-garden', array() ); + $clttg_mods = get_option( 'theme_mods_tumblr-theme-garden', array() ); - if ( ! is_array( $ttgarden_mods ) ) { - $ttgarden_mods = array(); + if ( ! is_array( $clttg_mods ) ) { + $clttg_mods = array(); } foreach ( $default_params as $key => $value ) { - $normal = ttgarden_normalize_option_name( $key ); - $ttgarden_mods[ $normal ] = ( str_starts_with( $key, 'color:' ) ) ? sanitize_hex_color( $value ) : sanitize_text_field( $value ); + $normal = clttg_normalize_option_name( $key ); + $clttg_mods[ $normal ] = ( str_starts_with( $key, 'color:' ) ) ? sanitize_hex_color( $value ) : sanitize_text_field( $value ); } - update_option( 'theme_mods_tumblr-theme-garden', $ttgarden_mods ); + update_option( 'theme_mods_tumblr-theme-garden', $clttg_mods ); } /** diff --git a/theme/tumblr-theme-garden/comments.php b/theme/tumblr-theme-garden/comments.php index 9fba7f3..4e2969a 100644 --- a/theme/tumblr-theme-garden/comments.php +++ b/theme/tumblr-theme-garden/comments.php @@ -25,7 +25,7 @@ 'style' => 'ol', 'short_ping' => true, 'avatar_size' => 24, - 'callback' => 'ttgarden_comment_markup', + 'callback' => 'clttg_comment_markup', 'max_depth' => 0, ) ); diff --git a/theme/tumblr-theme-garden/functions.php b/theme/tumblr-theme-garden/functions.php index 1345c66..ed9d07c 100644 --- a/theme/tumblr-theme-garden/functions.php +++ b/theme/tumblr-theme-garden/functions.php @@ -15,8 +15,8 @@ * * @return void */ -function ttgarden_enqueue_block_editor_assets(): void { - $deps = ttgarden_get_asset_meta( CLTTG_PATH . 'assets/js/build/editor.asset.php' ); +function clttg_enqueue_block_editor_assets(): void { + $deps = clttg_get_asset_meta( CLTTG_PATH . 'assets/js/build/editor.asset.php' ); wp_enqueue_script( 'cupcakelabs-tumblr-theme-garden', @@ -33,7 +33,7 @@ function ttgarden_enqueue_block_editor_assets(): void { $deps['version'] ); } -add_action( 'enqueue_block_editor_assets', 'ttgarden_enqueue_block_editor_assets' ); +add_action( 'enqueue_block_editor_assets', 'clttg_enqueue_block_editor_assets' ); /** * Filters the block editor settings. @@ -46,18 +46,18 @@ function ttgarden_enqueue_block_editor_assets(): void { * * @return array */ -function ttgarden_disable_post_format_ui( array $settings ): array { +function clttg_disable_post_format_ui( array $settings ): array { $settings['disablePostFormats'] = true; return $settings; } -add_filter( 'block_editor_settings_all', 'ttgarden_disable_post_format_ui' ); +add_filter( 'block_editor_settings_all', 'clttg_disable_post_format_ui' ); /** * Setup theme support. * * @return void */ -function ttgarden_theme_support(): void { +function clttg_theme_support(): void { add_theme_support( 'post-formats', array( 'image', 'gallery', 'link', 'audio', 'video', 'quote', 'chat' ) ); add_theme_support( 'post-thumbnails' ); add_theme_support( 'wp-block-styles' ); @@ -74,14 +74,14 @@ function ttgarden_theme_support(): void { ) ); } -add_action( 'after_setup_theme', 'ttgarden_theme_support' ); +add_action( 'after_setup_theme', 'clttg_theme_support' ); /** * Enqueue theme styles and scripts. * * @return void */ -function ttgarden_enqueue_scripts(): void { +function clttg_enqueue_scripts(): void { wp_enqueue_style( 'tumblr-theme-garden-style', CLTTG_URL . 'assets/css/build/index.css', @@ -89,14 +89,14 @@ function ttgarden_enqueue_scripts(): void { CLTTG_METADATA['Version'] ); } -add_action( 'wp_enqueue_scripts', 'ttgarden_enqueue_scripts' ); +add_action( 'wp_enqueue_scripts', 'clttg_enqueue_scripts' ); /** * Adds a random endpoint to match Tumblr's behavior. * * @return void */ -function ttgarden_rewrite_rules(): void { +function clttg_rewrite_rules(): void { // Handle the Tumblr random endpoint. add_rewrite_rule( '^random/?$', @@ -111,7 +111,7 @@ function ttgarden_rewrite_rules(): void { 'top' ); } -add_action( 'init', 'ttgarden_rewrite_rules' ); +add_action( 'init', 'clttg_rewrite_rules' ); /** * Add a new query variable for Tumblr search. @@ -120,26 +120,26 @@ function ttgarden_rewrite_rules(): void { * * @return array */ -function ttgarden_add_tumblr_search_var( $vars ): array { +function clttg_add_tumblr_search_var( $vars ): array { $vars[] = 'q'; $vars[] = 'random'; - $vars[] = 'ttgarden_html_comments'; + $vars[] = 'clttg_html_comments'; return $vars; } -add_filter( 'query_vars', 'ttgarden_add_tumblr_search_var' ); +add_filter( 'query_vars', 'clttg_add_tumblr_search_var' ); /** * Handles template redirects for Tumblr theme. * * - If 'random' is set, redirect to a random post. * - If 'q' is set, redirect to the core search page. - * - If 'ttgarden_html_comments' is set, redirect to a HTML only comments page. + * - If 'clttg_html_comments' is set, redirect to a HTML only comments page. * * @return void */ -function ttgarden_template_redirects(): void { - // If 'ttgarden_html_comments' is set, redirect to a HTML only comments page. /?p=85&ttgarden_html_comments=true - if ( get_query_var( 'ttgarden_html_comments' ) ) { +function clttg_template_redirects(): void { + // If 'clttg_html_comments' is set, redirect to a HTML only comments page. /?p=85&clttg_html_comments=true + if ( get_query_var( 'clttg_html_comments' ) ) { $post_id = get_query_var( 'p' ); // Ensure this is a valid post, it's published, not private. @@ -161,7 +161,7 @@ function ttgarden_template_redirects(): void { wp_list_comments( array( 'style' => 'ol', - 'callback' => 'ttgarden_comment_markup', + 'callback' => 'clttg_comment_markup', 'echo' => false, 'per_page' => 100, ), @@ -198,7 +198,7 @@ function ttgarden_template_redirects(): void { exit; } } -add_action( 'template_redirect', 'ttgarden_template_redirects', 1 ); +add_action( 'template_redirect', 'clttg_template_redirects', 1 ); /** * Custom comment markup. @@ -208,7 +208,7 @@ function ttgarden_template_redirects(): void { * * @return void */ -function ttgarden_comment_markup( $comment, $args ): void { +function clttg_comment_markup( $comment, $args ): void { ?>
  • @@ -244,7 +244,7 @@ function ttgarden_comment_markup( $comment, $args ): void { * * @return void */ -function ttgarden_disable_emojis(): void { +function clttg_disable_emojis(): void { // Remove the emoji script from the front end and admin remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); @@ -253,4 +253,4 @@ function ttgarden_disable_emojis(): void { remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); } -add_action( 'init', 'ttgarden_disable_emojis' ); +add_action( 'init', 'clttg_disable_emojis' ); diff --git a/theme/tumblr-theme-garden/index.php b/theme/tumblr-theme-garden/index.php index 8cbb5a8..40e5623 100644 --- a/theme/tumblr-theme-garden/index.php +++ b/theme/tumblr-theme-garden/index.php @@ -9,10 +9,10 @@ // Shortcodes don't currently have a doing_shortcode() or similar. // So we need a global to track the context. -ttgarden_set_parse_context( 'theme', true ); +clttg_set_parse_context( 'theme', true ); // Get the parsed theme HTML. -$ttgarden_theme = get_option( 'ttgarden_theme_html', '' ); +$clttg_theme = get_option( 'clttg_theme_html', '' ); /** * Capture wp_head output. @@ -21,11 +21,11 @@ */ ob_start(); wp_head(); -$ttgarden_head = ob_get_contents(); +$clttg_head = ob_get_contents(); ob_end_clean(); // Parse and potentially store the parsed theme HTML. -$ttgarden_theme = apply_filters( 'ttgarden_theme_output', $ttgarden_theme ); +$clttg_theme = apply_filters( 'clttg_theme_output', $clttg_theme ); /** * Capture wp_footer output. @@ -34,13 +34,13 @@ */ ob_start(); wp_footer(); -$ttgarden_footer = ob_get_contents(); +$clttg_footer = ob_get_contents(); ob_end_clean(); // Add the head and footer to the theme. -$ttgarden_theme = str_replace( '', $ttgarden_head . '', $ttgarden_theme ); -$ttgarden_theme = str_replace( '', $ttgarden_footer . '', $ttgarden_theme ); +$clttg_theme = str_replace( '', $clttg_head . '', $clttg_theme ); +$clttg_theme = str_replace( '', $clttg_footer . '', $clttg_theme ); // @todo: Sanitize the theme output?! // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -echo $ttgarden_theme; +echo $clttg_theme; diff --git a/tumblr-theme-garden.php b/tumblr-theme-garden.php index 326210e..058e559 100644 --- a/tumblr-theme-garden.php +++ b/tumblr-theme-garden.php @@ -70,7 +70,7 @@ static function () { 'admin_notices', static function () { $message = __( 'It seems like Tumblr Theme Garden failed to autoload. Run composer i.', 'tumblr-theme-garden' ); - $html_message = wp_sprintf( '
    %s
    ', wpautop( $message ) ); + $html_message = wp_sprintf( '
    %s
    ', wpautop( $message ) ); echo wp_kses_post( $html_message ); } ); @@ -84,10 +84,10 @@ static function () { register_activation_hook( __FILE__, static function () { - update_option( 'ttgarden_original_theme', '' ); - update_option( 'ttgarden_theme_html', '' ); - update_option( 'ttgarden_use_theme', '0' ); - update_option( 'ttgarden_external_theme', array() ); + update_option( 'clttg_original_theme', '' ); + update_option( 'clttg_theme_html', '' ); + update_option( 'clttg_use_theme', '0' ); + update_option( 'clttg_external_theme', array() ); } ); @@ -98,18 +98,18 @@ static function () { __FILE__, static function () { // Switch back to the original theme if one was saved. - $theme = get_option( 'ttgarden_original_theme' ); + $theme = get_option( 'clttg_original_theme' ); if ( $theme ) { switch_theme( $theme ); } // Cleanup options. - delete_option( 'ttgarden_original_theme' ); - delete_option( 'ttgarden_theme_html' ); - delete_option( 'ttgarden_use_theme' ); - delete_option( 'ttgarden_external_theme' ); + delete_option( 'clttg_original_theme' ); + delete_option( 'clttg_theme_html' ); + delete_option( 'clttg_use_theme' ); + delete_option( 'clttg_external_theme' ); } ); require_once CLTTG_PATH . 'functions.php'; -add_action( 'plugins_loaded', array( ttgarden_get_plugin_instance(), 'initialize' ) ); +add_action( 'plugins_loaded', array( clttg_get_plugin_instance(), 'initialize' ) );