Plugin Directory

Changeset 3457626


Ignore:
Timestamp:
02/10/2026 03:37:36 AM (4 weeks ago)
Author:
soliddigital
Message:

Update to version 1.1.0 from GitHub

Location:
repeaters-relationships-connector-acf-elementor
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • repeaters-relationships-connector-acf-elementor/tags/1.1.0/includes/modify_query_results.php

    r3386803 r3457626  
    55if ( ! \defined( 'ABSPATH' ) ) {
    66    exit; // Exit if accessed directly.
     7}
     8
     9/**
     10 * Resolves the ACF post ID based on the widget's data source setting.
     11 *
     12 * @param \Elementor\Widget_Base $widget The widget instance.
     13 *
     14 * @return int|string The post ID or options page identifier.
     15 */
     16function resolve_acf_post_id( $widget ) {
     17    $data_source = $widget->get_settings( 'post_query_acf_data_source' );
     18    if ( empty( $data_source ) || 'current_post' === $data_source ) {
     19        return \get_the_ID();
     20    }
     21    return $data_source;
    722}
    823
     
    2136    }
    2237
    23     $repeater_data = \get_field( $repeater_name, \get_the_ID() );
     38    $acf_post_id   = resolve_acf_post_id( $widget );
     39    $repeater_data = \get_field( $repeater_name, $acf_post_id );
    2440    if ( ! $repeater_data || ! is_array( $repeater_data ) ) {
    2541        $query->posts       = [];
     
    3349    foreach ( $repeater_data as $index => $row ) {
    3450        $post                    = new \stdClass();
    35         $post->ID                = \get_the_ID() . '-' . $index;
     51        $post->ID                = ( \is_numeric( $acf_post_id ) ? $acf_post_id : 0 ) . '-' . $index;
    3652        $post->post_title        = isset( $row['title'] ) ? $row['title'] : 'Item ' . ( $index + 1 );
    3753        $post->post_content      = isset( $row['content'] ) ? $row['content'] : '';
     
    6682    }
    6783
    68     $relation_posts = \get_field( $relation_name, \get_the_ID() );
     84    $relation_posts = \get_field( $relation_name, resolve_acf_post_id( $widget ) );
    6985
    7086    if ( empty( $relation_posts ) || ! is_array( $relation_posts ) ) {
  • repeaters-relationships-connector-acf-elementor/tags/1.1.0/includes/register_controls.php

    r3386803 r3457626  
    3232                'condition' => [
    3333                    'post_type' => 'acf_relation',
     34                ],
     35            ];
     36
     37            $fields['acf_data_source'] = [
     38                'label'     => \esc_html__( 'Data Source', 'repeaters-relationships-connector-acf-elementor' ),
     39                'type'      => \Elementor\Controls_Manager::SELECT,
     40                'default'   => 'current_post',
     41                'options'   => $this->get_acf_data_source_options(),
     42                'condition' => [
     43                    'post_type' => [ 'acf_repeater', 'acf_relation' ],
    3444                ],
    3545            ];
     
    106116            return $relation_fields;
    107117        }
     118
     119        private function get_acf_data_source_options() {
     120            $options = [
     121                'current_post' => \__( 'Current Post/Page', 'repeaters-relationships-connector-acf-elementor' ),
     122            ];
     123            if ( \function_exists( 'acf_get_options_pages' ) ) {
     124                $options_pages = \acf_get_options_pages();
     125                if ( ! empty( $options_pages ) && \is_array( $options_pages ) ) {
     126                    foreach ( $options_pages as $page ) {
     127                        $post_id = isset( $page['post_id'] ) ? $page['post_id'] : 'options';
     128                        $options[ $post_id ] = $page['page_title'];
     129                    }
     130                }
     131            }
     132            return $options;
     133        }
    108134    }
    109135
  • repeaters-relationships-connector-acf-elementor/tags/1.1.0/readme.txt

    r3387195 r3457626  
    33Requires at least: 5.8
    44Tested up to: 6.8
    5 Stable tag: 1.0.1
     5Stable tag: 1.1.0
    66Requires PHP: 7.4
    77License: GPLv2 or later
     
    6666
    6767**Can I get data from a repeater on a site-wide options page?**
    68 Currently, the plugin retrieves data from ACF fields attached to the current post or page being viewed. Support for ACF Options Pages is a potential future enhancement.
     68Yes! When you select "ACF Repeater" or "ACF Relationship" as your source, a "Data Source" dropdown appears. It lists "Current Post/Page" (the default) along with any registered ACF Options Pages. Select the options page that contains your field, then choose the field name as usual.
    6969
    7070**Why isn't my ACF field showing up in the dropdown?**
     
    8181== Changelog ==
    8282
     83= 1.1.0 =
     84* Added ACF Options Page support. A new "Data Source" dropdown lets you pull Repeater and Relationship data from any registered options page instead of only the current post/page.
     85
    8386= 1.0.0 =
    8487* Initial release.
  • repeaters-relationships-connector-acf-elementor/trunk/includes/modify_query_results.php

    r3386803 r3457626  
    55if ( ! \defined( 'ABSPATH' ) ) {
    66    exit; // Exit if accessed directly.
     7}
     8
     9/**
     10 * Resolves the ACF post ID based on the widget's data source setting.
     11 *
     12 * @param \Elementor\Widget_Base $widget The widget instance.
     13 *
     14 * @return int|string The post ID or options page identifier.
     15 */
     16function resolve_acf_post_id( $widget ) {
     17    $data_source = $widget->get_settings( 'post_query_acf_data_source' );
     18    if ( empty( $data_source ) || 'current_post' === $data_source ) {
     19        return \get_the_ID();
     20    }
     21    return $data_source;
    722}
    823
     
    2136    }
    2237
    23     $repeater_data = \get_field( $repeater_name, \get_the_ID() );
     38    $acf_post_id   = resolve_acf_post_id( $widget );
     39    $repeater_data = \get_field( $repeater_name, $acf_post_id );
    2440    if ( ! $repeater_data || ! is_array( $repeater_data ) ) {
    2541        $query->posts       = [];
     
    3349    foreach ( $repeater_data as $index => $row ) {
    3450        $post                    = new \stdClass();
    35         $post->ID                = \get_the_ID() . '-' . $index;
     51        $post->ID                = ( \is_numeric( $acf_post_id ) ? $acf_post_id : 0 ) . '-' . $index;
    3652        $post->post_title        = isset( $row['title'] ) ? $row['title'] : 'Item ' . ( $index + 1 );
    3753        $post->post_content      = isset( $row['content'] ) ? $row['content'] : '';
     
    6682    }
    6783
    68     $relation_posts = \get_field( $relation_name, \get_the_ID() );
     84    $relation_posts = \get_field( $relation_name, resolve_acf_post_id( $widget ) );
    6985
    7086    if ( empty( $relation_posts ) || ! is_array( $relation_posts ) ) {
  • repeaters-relationships-connector-acf-elementor/trunk/includes/register_controls.php

    r3386803 r3457626  
    3232                'condition' => [
    3333                    'post_type' => 'acf_relation',
     34                ],
     35            ];
     36
     37            $fields['acf_data_source'] = [
     38                'label'     => \esc_html__( 'Data Source', 'repeaters-relationships-connector-acf-elementor' ),
     39                'type'      => \Elementor\Controls_Manager::SELECT,
     40                'default'   => 'current_post',
     41                'options'   => $this->get_acf_data_source_options(),
     42                'condition' => [
     43                    'post_type' => [ 'acf_repeater', 'acf_relation' ],
    3444                ],
    3545            ];
     
    106116            return $relation_fields;
    107117        }
     118
     119        private function get_acf_data_source_options() {
     120            $options = [
     121                'current_post' => \__( 'Current Post/Page', 'repeaters-relationships-connector-acf-elementor' ),
     122            ];
     123            if ( \function_exists( 'acf_get_options_pages' ) ) {
     124                $options_pages = \acf_get_options_pages();
     125                if ( ! empty( $options_pages ) && \is_array( $options_pages ) ) {
     126                    foreach ( $options_pages as $page ) {
     127                        $post_id = isset( $page['post_id'] ) ? $page['post_id'] : 'options';
     128                        $options[ $post_id ] = $page['page_title'];
     129                    }
     130                }
     131            }
     132            return $options;
     133        }
    108134    }
    109135
  • repeaters-relationships-connector-acf-elementor/trunk/readme.txt

    r3387195 r3457626  
    33Requires at least: 5.8
    44Tested up to: 6.8
    5 Stable tag: 1.0.1
     5Stable tag: 1.1.0
    66Requires PHP: 7.4
    77License: GPLv2 or later
     
    6666
    6767**Can I get data from a repeater on a site-wide options page?**
    68 Currently, the plugin retrieves data from ACF fields attached to the current post or page being viewed. Support for ACF Options Pages is a potential future enhancement.
     68Yes! When you select "ACF Repeater" or "ACF Relationship" as your source, a "Data Source" dropdown appears. It lists "Current Post/Page" (the default) along with any registered ACF Options Pages. Select the options page that contains your field, then choose the field name as usual.
    6969
    7070**Why isn't my ACF field showing up in the dropdown?**
     
    8181== Changelog ==
    8282
     83= 1.1.0 =
     84* Added ACF Options Page support. A new "Data Source" dropdown lets you pull Repeater and Relationship data from any registered options page instead of only the current post/page.
     85
    8386= 1.0.0 =
    8487* Initial release.
Note: See TracChangeset for help on using the changeset viewer.