Skip to content

Commit

Permalink
better-block-recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
JuhG committed Sep 15, 2017
1 parent 71e2102 commit 739d9cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions classes/class-acf-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ protected function maybe_parse_flexible_content( $meta ) {
# Look for values
$found = false;
foreach( $meta as $t1 => $t2 ) {
if( $key != $t1 && strpos( $t1, $key ) === 0 ) {
if( $key != $t1 && preg_match( '~^' . preg_quote( $key ) . '_\d+~', $t1 ) ) {
$found = true;
$nested = false;

foreach( $repeaters as $rv => $rd ) {
if( strpos( $key, $rv ) === 0 )
if( preg_match( '~^' . preg_quote( $key ) . '_\d+~', $rv ) )
$found = false;
}

Expand Down Expand Up @@ -144,9 +144,9 @@ protected function maybe_parse_flexible_content( $meta ) {
$prefix = $rkey . '_' . $i;
$repeater_data[ $rkey ][ $i . '___type' ] = $type;

if( strpos( $key, $prefix ) === 0 ) {
if( 0 === strpos( $key, $prefix ) ) {
$in_repeater = true;
$repeater_data[ $rkey ][ preg_replace( '~^' . preg_quote( $rkey ) . '_~', '', $key ) ] = $value;
$repeater_data[ $rkey ][ preg_replace( '~^' . preg_quote( $rkey ) . '_(\d+)_~', '$1_', $key ) ] = $value;
$ignored[] = '_' . $key;
break;
}
Expand Down

0 comments on commit 739d9cd

Please sign in to comment.