Plugin Directory

Changeset 3465976


Ignore:
Timestamp:
02/20/2026 05:56:20 PM (42 hours ago)
Author:
a1tools
Message:

v1.4.13: Fix shortcodes not resolving inside href attributes (tel:, mailto: links)

Location:
a1-tools/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • a1-tools/trunk/a1-tools.php

    r3462867 r3465976  
    44 * Plugin URI:        https://tools.a-1chimney.com
    55 * Description:       Connects your WordPress site to the A1 Tools platform for centralized management of contact information, social media links, and business details.
    6  * Version:           1.4.12
     6 * Version:           1.4.13
    77 * Requires at least: 5.0
    88 * Requires PHP:      7.4
     
    2121
    2222// Plugin constants.
    23 define( 'A1TOOLS_VERSION', '1.4.12' );
     23define( 'A1TOOLS_VERSION', '1.4.13' );
    2424define( 'A1TOOLS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2525define( 'A1TOOLS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     
    126126// SHORTCODES
    127127// ============================================================================
     128
     129/**
     130 * Process A1 Tools shortcodes inside HTML attributes (href, src, etc.).
     131 *
     132 * WordPress does not run do_shortcode() inside HTML attributes. This filter
     133 * finds occurrences like href="tel:[a1tools_var key="phone_primary"]"
     134 * or href="mailto:[a1tools_var ...]" and resolves them before normal rendering.
     135 *
     136 * @since 1.4.13
     137 * @param string $content Post content.
     138 * @return string Content with shortcodes resolved inside attributes.
     139 */
     140function a1tools_process_shortcodes_in_attributes( $content ) {
     141    // Match href="...anything with [a1tools_ shortcode..." (handles HTML-encoded quotes too)
     142    $content = preg_replace_callback(
     143        '/(?<=href=["\'])([^"\']*\[a1tools_[^\]]*\][^"\']*)/i',
     144        function ( $matches ) {
     145            // Decode HTML entities so shortcode parser can read the attributes
     146            $decoded = html_entity_decode( $matches[1], ENT_QUOTES, 'UTF-8' );
     147            // Process any shortcodes found inside the href value
     148            return do_shortcode( $decoded );
     149        },
     150        $content
     151    );
     152
     153    return $content;
     154}
     155add_filter( 'the_content', 'a1tools_process_shortcodes_in_attributes', 7 );
     156add_filter( 'widget_text', 'a1tools_process_shortcodes_in_attributes', 7 );
    128157
    129158/**
     
    381410 * Get SVG markup for icons not available in Font Awesome 5.
    382411 *
    383  * @since 1.4.12
     412 * @since 1.4.13
    384413 * @param string $icon_key The SVG icon key (e.g. 'svg-x').
    385414 * @return string SVG markup or empty string.
     
    395424 * Get icon HTML (SVG or Font Awesome <i> tag).
    396425 *
    397  * @since 1.4.12
     426 * @since 1.4.13
    398427 * @param string $icon Icon class or SVG key.
    399428 * @return string HTML markup for the icon.
  • a1-tools/trunk/readme.txt

    r3462867 r3465976  
    44Requires at least: 5.0
    55Tested up to: 6.9
    6 Stable tag: 1.4.12
     6Stable tag: 1.4.13
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    151151
    152152== Changelog ==
     153
     154= 1.4.13 =
     155* Fixed shortcodes not resolving inside link href attributes (e.g., tel:[a1tools_var key="phone_primary"])
     156* Added content filter to process A1 Tools shortcodes in href values before rendering
    153157
    154158= 1.4.12 =
Note: See TracChangeset for help on using the changeset viewer.