$atts Attributes, exactly as the callback expects them. * @return string Shortcode output, or an empty string when unavailable. */ public static function run( string $tag, array $atts ): string { if ( ! self::exists( $tag ) ) { return ''; } $output = call_user_func( $GLOBALS['shortcode_tags'][ $tag ], $atts, null, $tag ); return is_string( $output ) ? $output : ''; } /** * Retrieve the object a shortcode callback is bound to. * * WCDP registers most shortcodes as instance methods but exposes no * accessor for those instances; the shortcode registry is the only public * route to them. * * @param string $tag Shortcode tag. * @return object|null */ public static function get_handler( string $tag ) { if ( ! isset( $GLOBALS['shortcode_tags'][ $tag ] ) ) { return null; } $callback = $GLOBALS['shortcode_tags'][ $tag ]; if ( is_array( $callback ) && isset( $callback[0] ) && is_object( $callback[0] ) ) { return $callback[0]; } return null; } /** * Remove every `#is', '', $html ); return null === $clean ? $html : $clean; } /** * Remove `:root` custom-property blocks while keeping other inline CSS. * * Used where WCDP's inline CSS carries both page-global variables and * genuinely needed rules. * * @param string $html Markup to clean. * @return string */ public static function strip_root_variables( string $html ): string { $clean = preg_replace( '#:root\s*\{[^}]*\}#i', '', $html ); return null === $clean ? $html : $clean; } }