Skip to content

Commit

Permalink
Merge pull request #54 from pods-framework/1.x
Browse files Browse the repository at this point in the history
limit recursion traversal
  • Loading branch information
quasel authored Jun 5, 2018
2 parents 02d1a4f + 53364b5 commit 7fe3d3a
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 29 deletions.
46 changes: 22 additions & 24 deletions classes/class-pods-beaver-page-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,16 @@ public static function pods_get_settings_fields( $field_options = array() ) {

$field_options['add_pod_name'] = 'true';

$fields = array(
'settings_field' => array(
'type' => 'select',
'label' => __( 'Field from Settings / Current User', 'pods-beaver-builder-themer-add-on' ),
'options' => array(
'' => __( 'No fields found', 'pods-beaver-builder-themer-add-on' ),
)
),
);

if ( $pod_names ) {
$options = array();

Expand All @@ -526,23 +536,10 @@ public static function pods_get_settings_fields( $field_options = array() ) {
$options = array_replace_recursive( $options, self::recurse_pod_fields( $pod_name, $field_options ) );
}

if ( empty( $options ) ) {
$options[''] = __( 'No fields found', 'pods-beaver-builder-themer-add-on' );
if ( ! empty( $options ) ) {
$fields['settings_field']['options'] = $options;
}

$fields = array(
'settings_field' => array(
'type' => 'select',
'label' => __( 'Field from Settings / Current User', 'pods-beaver-builder-themer-add-on' ),
'options' => $options,
),
);
}

if ( empty( $fields ) ) {
$fields['options'] = array(
'' => __( 'No fields found', 'pods-beaver-builder-themer-add-on' ),
);
}

return $fields;
Expand All @@ -560,10 +557,8 @@ public static function pods_get_settings_fields( $field_options = array() ) {
*
* @since 1.0
*/
private static function recurse_pod_fields( $pod_name, $field_options = array(), $prefix = '' ) {
private static function recurse_pod_fields( $pod_name, $field_options = array(), $prefix = '', $pods_fields_visited = array() ) {

static $pods_fields_visited = array();

$fields = array();

if ( empty( $pod_name ) ) {
Expand Down Expand Up @@ -608,12 +603,13 @@ private static function recurse_pod_fields( $pod_name, $field_options = array(),

if ( $linked_pod ) {
$recurse_prefix = $prefix . $field_name . '.';

if ( ! isset( $pods_fields_visited[ $recurse_prefix . $linked_pod ] ) ) {
$visited_fields = self::recurse_pod_fields( $linked_pod, $field_options, $recurse_prefix );

$pods_fields_visited[ $recurse_prefix . $linked_pod ] = $visited_fields;


// stopp recursion - only travers a field of a pod once - fixes #51
if ( ! isset( $pods_fields_visited[ $pod_name . $field_name ] ) ) {

$pods_fields_visited[ $pod_name . $field_name ] = true;
$visited_fields = self::recurse_pod_fields( $linked_pod, $field_options, $recurse_prefix, $pods_fields_visited );

$fields = array_merge( $fields, $visited_fields );
}
}
Expand Down Expand Up @@ -649,6 +645,8 @@ private static function recurse_pod_fields( $pod_name, $field_options = array(),

$fields[ $prefix . $pod_name ]['options'][ $option_name ] = $option_value;
}


}

return $fields;
Expand Down
45 changes: 45 additions & 0 deletions docs/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## Issue Overview
<!-- This is a brief overview of the issue. --->

## Expected Behavior
<!-- If you're describing a bug, tell us what should happen -->
<!-- If you're suggesting a change/improvement, tell us how it should work -->

## Current Behavior
<!-- If describing a bug, tell us what happens instead of the expected behavior -->
<!-- If suggesting a change/improvement, explain the difference from current behavior -->

## Possible Solution
<!-- Not obligatory, but suggest a fix/reason for the bug, -->
<!-- or ideas how to implement the addition or change -->

## Steps to Reproduce (for bugs)
<!-- Provide a link to a live example, or an unambiguous set of steps to -->
<!-- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.

## Pods Package Export (helpful!)
<!-- Please include the Pods Package Export as it will be helpful in reproducing your issues. -->
<!-- To access: Pods Admin, Components, Migrate: Packages, Enable. -->
<!-- Then Pods Admin, Migrate: Packages, Export and Copy and Paste the JSON here OR -->
<!-- Save to a text file and upload to this bug report -->
```
Copy and Paste the JSON Export from **Pods Admin, Migrate: Packages, Export** in WordPress admin here
```

## Related Issues and/or PRs
<!-- List related issues or PRs against other branches: -->

## Todos
- [ ] Tests
- [ ] Documentation

## WordPress Environment
<details>
```
Copy and paste your System Details from **Pods Admin > Settings > Debug Information** in WordPress admin here.
```
</details>
5 changes: 2 additions & 3 deletions pods-beaver-themer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* Plugin Name: Pods Beaver Themer Add-On
* Plugin URI: http://pods.io/
* Description: Integration with Beaver Builder Themer (https://www.wpbeaverbuilder.com). Provides a UI for mapping Field Connections with Pods
* Version: 1.2
* Version: 1.2.1
* Author: Quasel, Pods Framework Team
* Author URI: http://pods.io/about/
* Text Domain: pods-beaver-builder-themer-add-on
* GitHub Plugin URI: https://github.com/pods-framework/pods-beaver-builder-themer-add-on
* GitHub Branch: 1.x
*
* Copyright 2017 Pods Foundation, Inc (email : contact@podsfoundation.org)
*
Expand All @@ -31,7 +30,7 @@
* @package Pods\Beaver Themer
*/

define( 'PODS_BEAVER_VERSION', '1.2' );
define( 'PODS_BEAVER_VERSION', '1.2.1' );
define( 'PODS_BEAVER_FILE', __FILE__ );
define( 'PODS_BEAVER_DIR', plugin_dir_path( PODS_BEAVER_FILE ) );
define( 'PODS_BEAVER_URL', plugin_dir_url( PODS_BEAVER_FILE ) );
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://pods.io/friends-of-pods/
Tags: pods, beaver builder, beaver themer,
Requires at least: 4.4
Tested up to: 4.8
Stable tag: 1.2
Stable tag: 1.2.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -71,10 +71,14 @@ You can use [GitHub Updater](https://github.com/afragen/github-updater). A simpl

== Changelog ==

= 1.2 - November 7th, 2017 =
= 1.2.1 - November 10th, 2017
* Fixed default settings array for setings pods

= 1.2 - November 9th, 2017 =
* Compatibility with BB 2.0+
* Improved error handling
* Fixed Deprecated: Non-static method messages
* Fixed endless recursions #51

= 1.1.1 - June 29th, 2017 =
* Added js to improve usability for all kind of posts modules (thx smarterdigitalltd)
Expand Down

0 comments on commit 7fe3d3a

Please sign in to comment.