Skip to content

Commit

Permalink
Support pods_register_type registering multiple Pods of a specific ty…
Browse files Browse the repository at this point in the history
…pe; Support pods_register_field registering a field for multiple Pods at a time; Support adding a new meta group for multiple Pods at a time
  • Loading branch information
sc0ttkclark committed Aug 5, 2013
1 parent 013f9a9 commit 72803d1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions classes/PodsMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ public function register ( $type, $pod ) {
if ( !isset( self::$queue[ $type ] ) )
self::$queue[ $type ] = array();

if ( is_array( $pod ) && !empty( $pod ) && !isset( $pod[ 'name' ] ) ) {
$data = array();

foreach ( $pod as $p ) {
$data[] = $this->register( $type, $p );
}

return $data;
}

$pod[ 'type' ] = $pod_type;
$pod = pods_api()->save_pod( $pod, false, self::$object_identifier );

Expand All @@ -314,6 +324,16 @@ public function register ( $type, $pod ) {
}

public function register_field ( $pod, $field ) {
if ( is_array( $pod ) && !empty( $pod ) && !isset( $pod[ 'name' ] ) ) {
$data = array();

foreach ( $pod as $p ) {
$data[] = $this->register_field( $p, $field );
}

return $data;
}

$pod = pods_api()->load_pod( array( 'name' => $pod ), false );

if ( !empty( $pod ) ) {
Expand Down Expand Up @@ -434,6 +454,14 @@ public function cpac_meta_values ( $meta, $fieldtype, $field, $type, $object_id
* @return mixed|void
*/
public function group_add ( $pod, $label, $fields, $context = 'normal', $priority = 'default' ) {
if ( is_array( $pod ) && !empty( $pod ) && !isset( $pod[ 'name' ] ) ) {
foreach ( $pod as $p ) {
$this->group_add( $pod, $label, $fields, $context, $priority );
}

return true;
}

if ( !is_array( $pod ) ) {
$_pod = pods_api()->load_pod( array( 'name' => $pod ), false );

Expand Down

0 comments on commit 72803d1

Please sign in to comment.