Code Duplication    Length = 26-26 lines in 2 locations

classes/PodsMeta.php 2 locations

@@ 1427-1452 (lines=26) @@
1424
        $id = $post_id;
1425
        $pod = null;
1426
1427
        foreach ( $groups as $group ) {
1428
            if ( empty( $group[ 'fields' ] ) )
1429
                continue;
1430
1431
			if ( null === $pod || ( is_object( $pod ) && $pod->id() != $id ) ) {
1432
				if ( !is_object( self::$current_pod ) || self::$current_pod->pod != $group[ 'pod' ][ 'name' ] )
1433
					self::$current_pod = pods( $group[ 'pod' ][ 'name' ], $id, true );
1434
				elseif ( self::$current_pod->id() != $id )
1435
					self::$current_pod->fetch( $id );
1436
1437
				$pod = self::$current_pod;
1438
			}
1439
1440
            foreach ( $group[ 'fields' ] as $field ) {
1441
1442
                if ( false === PodsForm::permission( $field[ 'type' ], $field[ 'name' ], $field, $group[ 'fields' ], $pod, $id ) ) {
1443
                    if ( !pods_var( 'hidden', $field[ 'options' ], false ) )
1444
                        continue;
1445
                }
1446
1447
                $data[ $field[ 'name' ] ] = '';
1448
1449
                if ( isset( $_POST[ 'pods_meta_' . $field[ 'name' ] ] ) )
1450
                    $data[ $field[ 'name' ] ] = $_POST[ 'pods_meta_' . $field[ 'name' ] ];
1451
            }
1452
        }
1453
1454
        do_action( 'pods_meta_save_pre_media', $data, $pod, $id, $groups, $post, $attachment );
1455
@@ 2218-2243 (lines=26) @@
2215
        $id = $comment_id;
2216
        $pod = null;
2217
2218
        foreach ( $groups as $group ) {
2219
            if ( empty( $group[ 'fields' ] ) )
2220
                continue;
2221
2222
			if ( null === $pod || ( is_object( $pod ) && $pod->id() != $id ) ) {
2223
				if ( !is_object( self::$current_pod ) || self::$current_pod->pod != $group[ 'pod' ][ 'name' ] )
2224
					self::$current_pod = pods( $group[ 'pod' ][ 'name' ], $id, true );
2225
				elseif ( self::$current_pod->id() != $id )
2226
					self::$current_pod->fetch( $id );
2227
2228
				$pod = self::$current_pod;
2229
			}
2230
2231
            foreach ( $group[ 'fields' ] as $field ) {
2232
                if ( false === PodsForm::permission( $field[ 'type' ], $field[ 'name' ], $field, $group[ 'fields' ], $pod, $id ) ) {
2233
                    if ( !pods_var( 'hidden', $field[ 'options' ], false ) )
2234
                        continue;
2235
                }
2236
2237
                $data[ $field[ 'name' ] ] = '';
2238
2239
                if ( isset( $_POST[ 'pods_meta_' . $field[ 'name' ] ] ) )
2240
                    $data[ $field[ 'name' ] ] = $_POST[ 'pods_meta_' . $field[ 'name' ] ];
2241
            }
2242
        }
2243
2244
        do_action( 'pods_meta_save_pre_comment', $data, $pod, $id, $groups );
2245
2246
        if ( !empty( $pod ) ) {