Changeset 3457626
- Timestamp:
- 02/10/2026 03:37:36 AM (4 weeks ago)
- Location:
- repeaters-relationships-connector-acf-elementor
- Files:
-
- 6 edited
- 1 copied
-
tags/1.1.0 (copied) (copied from repeaters-relationships-connector-acf-elementor/trunk)
-
tags/1.1.0/includes/modify_query_results.php (modified) (4 diffs)
-
tags/1.1.0/includes/register_controls.php (modified) (2 diffs)
-
tags/1.1.0/readme.txt (modified) (3 diffs)
-
trunk/includes/modify_query_results.php (modified) (4 diffs)
-
trunk/includes/register_controls.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
repeaters-relationships-connector-acf-elementor/tags/1.1.0/includes/modify_query_results.php
r3386803 r3457626 5 5 if ( ! \defined( 'ABSPATH' ) ) { 6 6 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 */ 16 function 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; 7 22 } 8 23 … … 21 36 } 22 37 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 ); 24 40 if ( ! $repeater_data || ! is_array( $repeater_data ) ) { 25 41 $query->posts = []; … … 33 49 foreach ( $repeater_data as $index => $row ) { 34 50 $post = new \stdClass(); 35 $post->ID = \get_the_ID() . '-' . $index;51 $post->ID = ( \is_numeric( $acf_post_id ) ? $acf_post_id : 0 ) . '-' . $index; 36 52 $post->post_title = isset( $row['title'] ) ? $row['title'] : 'Item ' . ( $index + 1 ); 37 53 $post->post_content = isset( $row['content'] ) ? $row['content'] : ''; … … 66 82 } 67 83 68 $relation_posts = \get_field( $relation_name, \get_the_ID() );84 $relation_posts = \get_field( $relation_name, resolve_acf_post_id( $widget ) ); 69 85 70 86 if ( empty( $relation_posts ) || ! is_array( $relation_posts ) ) { -
repeaters-relationships-connector-acf-elementor/tags/1.1.0/includes/register_controls.php
r3386803 r3457626 32 32 'condition' => [ 33 33 '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' ], 34 44 ], 35 45 ]; … … 106 116 return $relation_fields; 107 117 } 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 } 108 134 } 109 135 -
repeaters-relationships-connector-acf-elementor/tags/1.1.0/readme.txt
r3387195 r3457626 3 3 Requires at least: 5.8 4 4 Tested up to: 6.8 5 Stable tag: 1. 0.15 Stable tag: 1.1.0 6 6 Requires PHP: 7.4 7 7 License: GPLv2 or later … … 66 66 67 67 **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.68 Yes! 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. 69 69 70 70 **Why isn't my ACF field showing up in the dropdown?** … … 81 81 == Changelog == 82 82 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 83 86 = 1.0.0 = 84 87 * Initial release. -
repeaters-relationships-connector-acf-elementor/trunk/includes/modify_query_results.php
r3386803 r3457626 5 5 if ( ! \defined( 'ABSPATH' ) ) { 6 6 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 */ 16 function 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; 7 22 } 8 23 … … 21 36 } 22 37 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 ); 24 40 if ( ! $repeater_data || ! is_array( $repeater_data ) ) { 25 41 $query->posts = []; … … 33 49 foreach ( $repeater_data as $index => $row ) { 34 50 $post = new \stdClass(); 35 $post->ID = \get_the_ID() . '-' . $index;51 $post->ID = ( \is_numeric( $acf_post_id ) ? $acf_post_id : 0 ) . '-' . $index; 36 52 $post->post_title = isset( $row['title'] ) ? $row['title'] : 'Item ' . ( $index + 1 ); 37 53 $post->post_content = isset( $row['content'] ) ? $row['content'] : ''; … … 66 82 } 67 83 68 $relation_posts = \get_field( $relation_name, \get_the_ID() );84 $relation_posts = \get_field( $relation_name, resolve_acf_post_id( $widget ) ); 69 85 70 86 if ( empty( $relation_posts ) || ! is_array( $relation_posts ) ) { -
repeaters-relationships-connector-acf-elementor/trunk/includes/register_controls.php
r3386803 r3457626 32 32 'condition' => [ 33 33 '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' ], 34 44 ], 35 45 ]; … … 106 116 return $relation_fields; 107 117 } 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 } 108 134 } 109 135 -
repeaters-relationships-connector-acf-elementor/trunk/readme.txt
r3387195 r3457626 3 3 Requires at least: 5.8 4 4 Tested up to: 6.8 5 Stable tag: 1. 0.15 Stable tag: 1.1.0 6 6 Requires PHP: 7.4 7 7 License: GPLv2 or later … … 66 66 67 67 **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.68 Yes! 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. 69 69 70 70 **Why isn't my ACF field showing up in the dropdown?** … … 81 81 == Changelog == 82 82 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 83 86 = 1.0.0 = 84 87 * Initial release.
Note: See TracChangeset
for help on using the changeset viewer.