Plugin Directory

Changeset 3450706


Ignore:
Timestamp:
01/30/2026 08:47:51 PM (6 weeks ago)
Author:
vectoron
Message:

Release 2.10.0: Enhanced Elementor integration with proper metadata and modern container support

  • Added _elementor_template_type meta field (wp-page for pages, wp-post for posts)
  • Added _wp_page_template meta field for pages (required by Elementor)
  • Added _elementor_pro_version meta field when Elementor Pro is installed
  • Smart container detection: uses modern flexbox containers (Elementor 3.6+) when enabled
  • Fallback to legacy section/column structure for older Elementor or when containers disabled
  • Status endpoint now reports containers_enabled and layout_mode for debugging
  • Improved code quality: centralized container detection helper function
Location:
vectoron
Files:
4 edited
16 copied

Legend:

Unmodified
Added
Removed
  • vectoron/tags/2.10.0/integrations/elementor.php

    r3448969 r3450706  
    5656
    5757/**
     58 * Check if Elementor containers feature is enabled.
     59 *
     60 * Containers (introduced in Elementor 3.6) use flexbox-based layout instead of
     61 * the legacy section/column structure. This function checks the experiments
     62 * system to determine if containers are actually enabled on the site.
     63 *
     64 * @return bool True if containers are enabled, false otherwise.
     65 */
     66function vectoron_is_elementor_containers_enabled() {
     67    if ( ! class_exists( '\Elementor\Plugin' ) ) {
     68        return false;
     69    }
     70
     71    if ( ! isset( \Elementor\Plugin::$instance->experiments ) ) {
     72        return false;
     73    }
     74
     75    if ( ! method_exists( \Elementor\Plugin::$instance->experiments, 'is_feature_active' ) ) {
     76        return false;
     77    }
     78
     79    return \Elementor\Plugin::$instance->experiments->is_feature_active( 'container' );
     80}
     81
     82/**
    5883 * Convert HTML content to Elementor JSON data structure.
    5984 *
    6085 * Elementor stores page content as a nested JSON array in _elementor_data.
    61  * Structure: Section -> Column -> Widget (text-editor)
     86 * Uses modern container structure (Elementor 3.6+) when enabled, or legacy
     87 * section/column structure as fallback.
    6288 *
    6389 * @param string $html_content HTML content to convert.
     
    6591 */
    6692function vectoron_html_to_elementor_data( $html_content ) {
     93    // Check if containers are enabled on this site using centralized helper.
     94    $use_containers = vectoron_is_elementor_containers_enabled();
     95
     96    if ( $use_containers ) {
     97        // Modern container-based structure (Elementor 3.6+ with containers enabled).
     98        // Containers use flexbox and don't need the column wrapper.
     99        return array(
     100            array(
     101                'id'       => vectoron_generate_elementor_id(),
     102                'elType'   => 'container',
     103                'isInner'  => false,
     104                'settings' => array(
     105                    'content_width' => 'boxed',
     106                    'boxed_width'   => array(
     107                        'size' => 1140,
     108                        'unit' => 'px',
     109                    ),
     110                ),
     111                'elements' => array(
     112                    array(
     113                        'id'         => vectoron_generate_elementor_id(),
     114                        'elType'     => 'widget',
     115                        'widgetType' => 'text-editor',
     116                        'isInner'    => false,
     117                        '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>',
     120                        ),
     121                        'elements'   => array(),
     122                    ),
     123                ),
     124            ),
     125        );
     126    }
     127
     128    // Fallback: Legacy section/column structure for Elementor < 3.6 or containers disabled.
    67129    return array(
    68130        array(
     
    214276        update_post_meta( $post_id, '_elementor_version', ELEMENTOR_VERSION );
    215277
     278        // Set correct template type based on post_type (REQUIRED for proper Elementor rendering).
     279        // 'wp-page' for pages, 'wp-post' for posts - validated against Elementor source code.
     280        $template_type = ( 'page' === $post->post_type ) ? 'wp-page' : 'wp-post';
     281        update_post_meta( $post_id, '_elementor_template_type', $template_type );
     282
     283        // Set WordPress page template for pages (required for Elementor pages).
     284        if ( 'page' === $post->post_type ) {
     285            update_post_meta( $post_id, '_wp_page_template', 'default' );
     286        }
     287
     288        // Add Elementor Pro version if installed (some themes/features check this).
     289        if ( defined( 'ELEMENTOR_PRO_VERSION' ) ) {
     290            update_post_meta( $post_id, '_elementor_pro_version', ELEMENTOR_PRO_VERSION );
     291        }
     292
     293        // NOTE: We intentionally do NOT set _elementor_page_settings.
     294        // This allows each site's default settings (like hide_title) to apply,
     295        // respecting the site's existing configuration.
     296
    216297        // Clear Elementor CSS cache for this post.
    217298        vectoron_clear_elementor_cache( $post_id );
    218299
    219         vectoron_debug( "[Elementor] Successfully synced post {$post_id}" );
    220 
    221     } catch ( Exception $e ) {
     300        // Determine which layout structure was used for logging (using centralized helper).
     301        $layout_type = vectoron_is_elementor_containers_enabled() ? 'container' : 'section/column';
     302
     303        vectoron_debug( "[Elementor] Successfully synced post {$post_id} (type: {$template_type}, layout: {$layout_type})" );
     304
     305    } catch ( Throwable $e ) {
     306        // Use Throwable to catch both Exception and Error (PHP 7+ fatal errors like TypeError).
    222307        vectoron_debug( '[Elementor] Error: ' . $e->getMessage() );
    223308    } finally {
     
    257342 */
    258343function vectoron_add_elementor_to_status( $response ) {
     344    $installed           = defined( 'ELEMENTOR_VERSION' ) && class_exists( '\Elementor\Plugin' );
     345    $containers_enabled  = vectoron_is_elementor_containers_enabled();
     346
    259347    $response['elementor'] = array(
    260         'installed' => defined( 'ELEMENTOR_VERSION' ) && class_exists( '\Elementor\Plugin' ),
    261         'version'   => defined( 'ELEMENTOR_VERSION' ) ? sanitize_text_field( ELEMENTOR_VERSION ) : null,
    262         'sync_mode' => get_option( 'vectoron_elementor_sync_mode', 'always' ),
     348        'installed'          => $installed,
     349        'version'            => defined( 'ELEMENTOR_VERSION' ) ? sanitize_text_field( ELEMENTOR_VERSION ) : null,
     350        'pro_version'        => defined( 'ELEMENTOR_PRO_VERSION' ) ? sanitize_text_field( ELEMENTOR_PRO_VERSION ) : null,
     351        'containers_enabled' => $containers_enabled,
     352        'layout_mode'        => $containers_enabled ? 'container' : 'section/column',
     353        'sync_mode'          => get_option( 'vectoron_elementor_sync_mode', 'always' ),
    263354    );
    264355    return $response;
  • vectoron/tags/2.10.0/readme.txt

    r3448969 r3450706  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 2.9.9
     7Stable tag: 2.10.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    135135
    136136== Changelog ==
     137
     138= 2.10.0 =
     139* Enhanced Elementor integration with proper metadata and modern container support
     140* Added `_elementor_template_type` meta field (wp-page for pages, wp-post for posts)
     141* Added `_wp_page_template` meta field for pages (required by Elementor)
     142* Added `_elementor_pro_version` meta field when Elementor Pro is installed
     143* Smart container detection: uses modern flexbox containers (Elementor 3.6+) when enabled
     144* Fallback to legacy section/column structure for older Elementor or when containers are disabled
     145* Status endpoint now reports `containers_enabled` and `layout_mode` for debugging
     146* Improved code quality: centralized container detection helper function
    137147
    138148= 2.9.9 =
  • vectoron/tags/2.10.0/vectoron-api.php

    r3448212 r3450706  
    504504        }
    505505
     506        // Set Rank Math SEO metadata if Rank Math is installed
     507        if (function_exists('vectoron_set_rankmath_metadata')) {
     508            vectoron_set_rankmath_metadata($post_id, array(
     509                'meta_description' => $meta_description,
     510                'seo_title' => $seo_title,
     511                'focus_keyword' => $focus_keyword,
     512            ));
     513        }
     514
    506515        // Add tags if provided
    507516        if ($tags = $request->get_param('tags')) {
     
    649658        if (function_exists('vectoron_set_seopress_metadata')) {
    650659            vectoron_set_seopress_metadata($post_id, array(
     660                'meta_description' => $meta_description,
     661                'seo_title' => $seo_title,
     662                'focus_keyword' => $focus_keyword,
     663            ));
     664        }
     665
     666        // Set Rank Math SEO metadata if Rank Math is installed
     667        if (function_exists('vectoron_set_rankmath_metadata')) {
     668            vectoron_set_rankmath_metadata($post_id, array(
    651669                'meta_description' => $meta_description,
    652670                'seo_title' => $seo_title,
  • vectoron/tags/2.10.0/vectoron.php

    r3448969 r3450706  
    33 * Plugin Name:       Vectoron
    44 * Description:       Provides the [vectoron_article] shortcode to disable wpautop and load assets for custom content like the FAQ accordion and GA4 tracking. Includes REST API endpoints for external content management and ACF integration.
    5  * Version:           2.9.9
     5 * Version:           2.10.0
    66 * Author:            Vectoron
    77 * Author URI:        https://vectoron.ai
  • vectoron/trunk/integrations/elementor.php

    r3448969 r3450706  
    5656
    5757/**
     58 * Check if Elementor containers feature is enabled.
     59 *
     60 * Containers (introduced in Elementor 3.6) use flexbox-based layout instead of
     61 * the legacy section/column structure. This function checks the experiments
     62 * system to determine if containers are actually enabled on the site.
     63 *
     64 * @return bool True if containers are enabled, false otherwise.
     65 */
     66function vectoron_is_elementor_containers_enabled() {
     67    if ( ! class_exists( '\Elementor\Plugin' ) ) {
     68        return false;
     69    }
     70
     71    if ( ! isset( \Elementor\Plugin::$instance->experiments ) ) {
     72        return false;
     73    }
     74
     75    if ( ! method_exists( \Elementor\Plugin::$instance->experiments, 'is_feature_active' ) ) {
     76        return false;
     77    }
     78
     79    return \Elementor\Plugin::$instance->experiments->is_feature_active( 'container' );
     80}
     81
     82/**
    5883 * Convert HTML content to Elementor JSON data structure.
    5984 *
    6085 * Elementor stores page content as a nested JSON array in _elementor_data.
    61  * Structure: Section -> Column -> Widget (text-editor)
     86 * Uses modern container structure (Elementor 3.6+) when enabled, or legacy
     87 * section/column structure as fallback.
    6288 *
    6389 * @param string $html_content HTML content to convert.
     
    6591 */
    6692function vectoron_html_to_elementor_data( $html_content ) {
     93    // Check if containers are enabled on this site using centralized helper.
     94    $use_containers = vectoron_is_elementor_containers_enabled();
     95
     96    if ( $use_containers ) {
     97        // Modern container-based structure (Elementor 3.6+ with containers enabled).
     98        // Containers use flexbox and don't need the column wrapper.
     99        return array(
     100            array(
     101                'id'       => vectoron_generate_elementor_id(),
     102                'elType'   => 'container',
     103                'isInner'  => false,
     104                'settings' => array(
     105                    'content_width' => 'boxed',
     106                    'boxed_width'   => array(
     107                        'size' => 1140,
     108                        'unit' => 'px',
     109                    ),
     110                ),
     111                'elements' => array(
     112                    array(
     113                        'id'         => vectoron_generate_elementor_id(),
     114                        'elType'     => 'widget',
     115                        'widgetType' => 'text-editor',
     116                        'isInner'    => false,
     117                        '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>',
     120                        ),
     121                        'elements'   => array(),
     122                    ),
     123                ),
     124            ),
     125        );
     126    }
     127
     128    // Fallback: Legacy section/column structure for Elementor < 3.6 or containers disabled.
    67129    return array(
    68130        array(
     
    214276        update_post_meta( $post_id, '_elementor_version', ELEMENTOR_VERSION );
    215277
     278        // Set correct template type based on post_type (REQUIRED for proper Elementor rendering).
     279        // 'wp-page' for pages, 'wp-post' for posts - validated against Elementor source code.
     280        $template_type = ( 'page' === $post->post_type ) ? 'wp-page' : 'wp-post';
     281        update_post_meta( $post_id, '_elementor_template_type', $template_type );
     282
     283        // Set WordPress page template for pages (required for Elementor pages).
     284        if ( 'page' === $post->post_type ) {
     285            update_post_meta( $post_id, '_wp_page_template', 'default' );
     286        }
     287
     288        // Add Elementor Pro version if installed (some themes/features check this).
     289        if ( defined( 'ELEMENTOR_PRO_VERSION' ) ) {
     290            update_post_meta( $post_id, '_elementor_pro_version', ELEMENTOR_PRO_VERSION );
     291        }
     292
     293        // NOTE: We intentionally do NOT set _elementor_page_settings.
     294        // This allows each site's default settings (like hide_title) to apply,
     295        // respecting the site's existing configuration.
     296
    216297        // Clear Elementor CSS cache for this post.
    217298        vectoron_clear_elementor_cache( $post_id );
    218299
    219         vectoron_debug( "[Elementor] Successfully synced post {$post_id}" );
    220 
    221     } catch ( Exception $e ) {
     300        // Determine which layout structure was used for logging (using centralized helper).
     301        $layout_type = vectoron_is_elementor_containers_enabled() ? 'container' : 'section/column';
     302
     303        vectoron_debug( "[Elementor] Successfully synced post {$post_id} (type: {$template_type}, layout: {$layout_type})" );
     304
     305    } catch ( Throwable $e ) {
     306        // Use Throwable to catch both Exception and Error (PHP 7+ fatal errors like TypeError).
    222307        vectoron_debug( '[Elementor] Error: ' . $e->getMessage() );
    223308    } finally {
     
    257342 */
    258343function vectoron_add_elementor_to_status( $response ) {
     344    $installed           = defined( 'ELEMENTOR_VERSION' ) && class_exists( '\Elementor\Plugin' );
     345    $containers_enabled  = vectoron_is_elementor_containers_enabled();
     346
    259347    $response['elementor'] = array(
    260         'installed' => defined( 'ELEMENTOR_VERSION' ) && class_exists( '\Elementor\Plugin' ),
    261         'version'   => defined( 'ELEMENTOR_VERSION' ) ? sanitize_text_field( ELEMENTOR_VERSION ) : null,
    262         'sync_mode' => get_option( 'vectoron_elementor_sync_mode', 'always' ),
     348        'installed'          => $installed,
     349        'version'            => defined( 'ELEMENTOR_VERSION' ) ? sanitize_text_field( ELEMENTOR_VERSION ) : null,
     350        'pro_version'        => defined( 'ELEMENTOR_PRO_VERSION' ) ? sanitize_text_field( ELEMENTOR_PRO_VERSION ) : null,
     351        'containers_enabled' => $containers_enabled,
     352        'layout_mode'        => $containers_enabled ? 'container' : 'section/column',
     353        'sync_mode'          => get_option( 'vectoron_elementor_sync_mode', 'always' ),
    263354    );
    264355    return $response;
  • vectoron/trunk/readme.txt

    r3448969 r3450706  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 2.9.9
     7Stable tag: 2.10.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    135135
    136136== Changelog ==
     137
     138= 2.10.0 =
     139* Enhanced Elementor integration with proper metadata and modern container support
     140* Added `_elementor_template_type` meta field (wp-page for pages, wp-post for posts)
     141* Added `_wp_page_template` meta field for pages (required by Elementor)
     142* Added `_elementor_pro_version` meta field when Elementor Pro is installed
     143* Smart container detection: uses modern flexbox containers (Elementor 3.6+) when enabled
     144* Fallback to legacy section/column structure for older Elementor or when containers are disabled
     145* Status endpoint now reports `containers_enabled` and `layout_mode` for debugging
     146* Improved code quality: centralized container detection helper function
    137147
    138148= 2.9.9 =
  • vectoron/trunk/vectoron-api.php

    r3448212 r3450706  
    504504        }
    505505
     506        // Set Rank Math SEO metadata if Rank Math is installed
     507        if (function_exists('vectoron_set_rankmath_metadata')) {
     508            vectoron_set_rankmath_metadata($post_id, array(
     509                'meta_description' => $meta_description,
     510                'seo_title' => $seo_title,
     511                'focus_keyword' => $focus_keyword,
     512            ));
     513        }
     514
    506515        // Add tags if provided
    507516        if ($tags = $request->get_param('tags')) {
     
    649658        if (function_exists('vectoron_set_seopress_metadata')) {
    650659            vectoron_set_seopress_metadata($post_id, array(
     660                'meta_description' => $meta_description,
     661                'seo_title' => $seo_title,
     662                'focus_keyword' => $focus_keyword,
     663            ));
     664        }
     665
     666        // Set Rank Math SEO metadata if Rank Math is installed
     667        if (function_exists('vectoron_set_rankmath_metadata')) {
     668            vectoron_set_rankmath_metadata($post_id, array(
    651669                'meta_description' => $meta_description,
    652670                'seo_title' => $seo_title,
  • vectoron/trunk/vectoron.php

    r3448969 r3450706  
    33 * Plugin Name:       Vectoron
    44 * Description:       Provides the [vectoron_article] shortcode to disable wpautop and load assets for custom content like the FAQ accordion and GA4 tracking. Includes REST API endpoints for external content management and ACF integration.
    5  * Version:           2.9.9
     5 * Version:           2.10.0
    66 * Author:            Vectoron
    77 * Author URI:        https://vectoron.ai
Note: See TracChangeset for help on using the changeset viewer.