Changeset 3462938
- Timestamp:
- 02/16/2026 10:10:44 PM (4 weeks ago)
- Location:
- vectoron/trunk
- Files:
-
- 6 edited
-
includes/shortcodes.php (modified) (8 diffs)
-
integrations/beaver-builder.php (modified) (2 diffs)
-
integrations/divi.php (modified) (3 diffs)
-
integrations/elementor.php (modified) (3 diffs)
-
integrations/wp-bakery.php (modified) (1 diff)
-
vectoron-api.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vectoron/trunk/includes/shortcodes.php
r3448212 r3462938 1 1 <?php 2 2 /** 3 * Vectoron Shortcodesand Asset Loading3 * Vectoron Content Detection and Asset Loading 4 4 * 5 * Provides [vectoron_article] shortcode functionality:6 * - Disables wpautop for shortcodecontent7 * - Wraps content in .vectoron-content container 5 * Detects Vectoron-generated content by .vectoron-content wrapper or .am-article class: 6 * - Disables wpautop for Vectoron content 7 * - Wraps content in .vectoron-content container (render-time fallback for existing posts) 8 8 * - Enqueues CSS/JS for FAQ accordion 9 9 * - Injects universal GA4 tracking script 10 * - Keeps [vectoron_article] shortcode registered for backward compatibility only 10 11 * 11 12 * @package Vectoron … … 18 19 19 20 /** 20 * Check if the vectoron shortcode is present in post content or ACF field. 21 * Check if post contains Vectoron-generated content. 22 * 23 * Detects the .vectoron-content wrapper (added by vectoron-api.php on publish) 24 * or the .am-article class (from json_to_html.py) for existing posts published 25 * before the wrapper was added at save time. 21 26 * 22 27 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 23 * @return bool True if shortcodeis found in post_content or configured ACF field.28 * @return bool True if Vectoron content is found in post_content or configured ACF field. 24 29 */ 25 30 function vectoron_has_shortcode( $post = null ) { … … 29 34 } 30 35 31 // Check main post_content first. 32 if ( has_shortcode( $post->post_content, 'vectoron_article' ) 33 || has_shortcode( $post->post_content, 'marketing_visionary_article' ) ) { 36 // Check for Vectoron content wrapper (added by vectoron-api.php on publish). 37 if ( strpos( $post->post_content, 'vectoron-content' ) !== false ) { 38 return true; 39 } 40 41 // Check for Vectoron-generated HTML (am-article class from json_to_html.py). 42 // Catches existing posts published before the wrapper was added at save time. 43 if ( strpos( $post->post_content, 'class="am-article"' ) !== false ) { 34 44 return true; 35 45 } … … 40 50 $acf_content = get_field( $acf_field, $post->ID ); 41 51 if ( is_string( $acf_content ) && ( 42 has_shortcode( $acf_content, 'vectoron_article' )43 || has_shortcode( $acf_content, 'marketing_visionary_article' )52 strpos( $acf_content, 'vectoron-content' ) !== false 53 || strpos( $acf_content, 'class="am-article"' ) !== false 44 54 ) ) { 45 55 return true; … … 51 61 52 62 /** 53 * Disable wpautop if the shortcode is present63 * Disable wpautop if Vectoron content is present. 54 64 */ 55 65 function vectoron_disable_wpautop( $content ) { 56 if ( has_shortcode( $content, 'vectoron_article' )57 || has_shortcode( $content, 'marketing_visionary_article' )) {66 if ( strpos( $content, 'vectoron-content' ) !== false 67 || strpos( $content, 'class="am-article"' ) !== false ) { 58 68 remove_filter( 'the_content', 'wpautop' ); 59 69 } … … 63 73 64 74 /** 65 * Wrap content in .vectoron-content container when shortcode is present.75 * Wrap content in .vectoron-content container at render time (fallback for existing posts). 66 76 */ 67 77 function vectoron_wrap_content( $content ) { 68 if ( has_shortcode( $content, 'vectoron_article' ) 69 || has_shortcode( $content, 'marketing_visionary_article' ) ) { 78 // Already wrapped — skip. 79 if ( strpos( $content, 'vectoron-content' ) !== false ) { 80 return $content; 81 } 82 // Wrap existing posts that have Vectoron HTML but no wrapper. 83 if ( strpos( $content, 'class="am-article"' ) !== false ) { 70 84 $content = '<div class="vectoron-content">' . $content . '</div>'; 71 85 } … … 310 324 311 325 /** 312 * Shortcode handler - no visible output, just triggers asset loading 326 * Shortcode handler — kept so existing posts with [vectoron_article] don't render raw bracket text. 327 * Detection no longer depends on this shortcode; it uses .vectoron-content / .am-article class instead. 313 328 */ 314 329 function vectoron_shortcode_handler( $atts, $content = null ) { … … 316 331 } 317 332 add_shortcode( 'vectoron_article', 'vectoron_shortcode_handler' ); 318 // Note: 'marketing_visionary_article' shortcode removed - use 'vectoron_article' instead -
vectoron/trunk/integrations/beaver-builder.php
r3448969 r3462938 108 108 // Rich-text module node with the HTML content. 109 109 // Wrap content in .vectoron-content div so CSS styles (FAQ accordions, headings, etc.) work. 110 // Guard against double-wrapping — content from vectoron-api.php may already have the wrapper. 111 $wrapped_text = ( strpos( $html_content, 'vectoron-content' ) !== false ) 112 ? $html_content 113 : '<div class="vectoron-content">' . $html_content . '</div>'; 114 110 115 $module_node = array( 111 116 'node' => $module_id, … … 115 120 'settings' => (object) array( 116 121 'type' => 'rich-text', 117 'text' => '<div class="vectoron-content">' . $html_content . '</div>',122 'text' => $wrapped_text, 118 123 ), 119 124 ); -
vectoron/trunk/integrations/divi.php
r3448969 r3462938 128 128 // Sanitize HTML content to prevent XSS while allowing safe HTML tags. 129 129 // Wrap content in .vectoron-content div so CSS styles (FAQ accordions, headings, etc.) work. 130 // Guard against double-wrapping — content from vectoron-api.php may already have the wrapper. 131 $wrapped_content = ( strpos( $html_content, 'vectoron-content' ) !== false ) 132 ? wp_kses_post( $html_content ) 133 : '<div class="vectoron-content">' . wp_kses_post( $html_content ) . '</div>'; 134 130 135 $shortcode_content = sprintf( 131 136 '[et_pb_section fb_built="1" _builder_version="%1$s" global_colors_info="{}"]' . … … 133 138 '[et_pb_column type="4_4" _builder_version="%1$s" custom_padding="|||" global_colors_info="" custom_padding__hover="|||"]' . 134 139 '[et_pb_text _builder_version="%1$s" background_size="initial" background_position="top_left" background_repeat="repeat" global_colors_info="{}"]' . 135 ' <div class="vectoron-content">%2$s</div>' .140 '%2$s' . 136 141 '[/et_pb_text]' . 137 142 '[/et_pb_column]' . … … 139 144 '[/et_pb_section]', 140 145 esc_attr( $builder_version ), 141 wp_kses_post( $html_content )146 $wrapped_content 142 147 ); 143 148 -
vectoron/trunk/integrations/elementor.php
r3451062 r3462938 93 93 // Check if containers are enabled on this site using centralized helper. 94 94 $use_containers = vectoron_is_elementor_containers_enabled(); 95 96 // Wrap content in .vectoron-content div so CSS styles (FAQ accordions, headings, etc.) work. 97 // Guard against double-wrapping — content from vectoron-api.php may already have the wrapper. 98 $wrapped_content = ( strpos( $html_content, 'vectoron-content' ) !== false ) 99 ? $html_content 100 : '<div class="vectoron-content">' . $html_content . '</div>'; 95 101 96 102 if ( $use_containers ) { … … 116 122 'isInner' => false, 117 123 'settings' => array( 118 // Wrap content in .vectoron-content div so CSS styles (FAQ accordions, headings, etc.) work. 119 'editor' => '<div class="vectoron-content">' . $html_content . '</div>', 124 'editor' => $wrapped_content, 120 125 ), 121 126 'elements' => array(), … … 155 160 'isInner' => false, 156 161 'settings' => array( 157 // Wrap content in .vectoron-content div so CSS styles (FAQ accordions, headings, etc.) work. 158 'editor' => '<div class="vectoron-content">' . $html_content . '</div>', 162 'editor' => $wrapped_content, 159 163 ), 160 164 'elements' => array(), -
vectoron/trunk/integrations/wp-bakery.php
r3448969 r3462938 127 127 // Sanitize HTML content to prevent XSS while allowing safe HTML tags. 128 128 // Wrap content in .vectoron-content div so CSS styles (FAQ accordions, headings, etc.) work. 129 // Guard against double-wrapping — content from vectoron-api.php may already have the wrapper. 130 $wrapped_content = ( strpos( $html_content, 'vectoron-content' ) !== false ) 131 ? wp_kses_post( $html_content ) 132 : '<div class="vectoron-content">' . wp_kses_post( $html_content ) . '</div>'; 133 129 134 $shortcode_content = sprintf( 130 '[vc_row][vc_column][vc_column_text] <div class="vectoron-content">%s</div>[/vc_column_text][/vc_column][/vc_row]',131 wp_kses_post( $html_content )135 '[vc_row][vc_column][vc_column_text]%s[/vc_column_text][/vc_column][/vc_row]', 136 $wrapped_content 132 137 ); 133 138 -
vectoron/trunk/vectoron-api.php
r3459361 r3462938 435 435 $content = sanitize_post_field('post_content', $request->get_param('content'), 0, 'db'); 436 436 437 // Wrap Vectoron content in .vectoron-content div for CSS scoping. 438 // Detects content from json_to_html.py by the am-article class marker. 439 if ( strpos( $content, 'class="am-article"' ) !== false 440 && strpos( $content, 'vectoron-content' ) === false ) { 441 $content = '<div class="vectoron-content">' . $content . '</div>'; 442 } 443 437 444 // Validate and sanitize post status 438 445 $status_input = sanitize_text_field($request->get_param('status')) ?: 'draft'; … … 607 614 // Use sanitize_post for content to preserve shortcodes 608 615 $content = sanitize_post_field('post_content', $request->get_param('content'), $post_id, 'db'); 616 617 // Wrap Vectoron content in .vectoron-content div for CSS scoping. 618 if ( ! empty( $content ) 619 && strpos( $content, 'class="am-article"' ) !== false 620 && strpos( $content, 'vectoron-content' ) === false ) { 621 $content = '<div class="vectoron-content">' . $content . '</div>'; 622 } 609 623 610 624 // Validate and sanitize post status
Note: See TracChangeset
for help on using the changeset viewer.