Skip to content

Commit

Permalink
Normalize object_type for get_table_info() and related method
Browse files Browse the repository at this point in the history
Slightly related to #7007 but does not resolve the UI issue there
  • Loading branch information
sc0ttkclark committed Feb 20, 2023
1 parent d7cfc53 commit 74ba85d
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions classes/PodsAPI.php
Expand Up @@ -9916,6 +9916,8 @@ public function get_table_info_load( $object_type, $object, $name = null, $pod =
}
}
} elseif ( ! empty( $pod ) ) {
$object_type = pods_v( 'type', $pod, $object_type, true );

$info['pod'] = $pod;
}

Expand Down Expand Up @@ -10002,6 +10004,16 @@ public function get_table_info( $object_type, $object, $name = null, $pod = null

// @todo Handle $object arrays for Post Types, Taxonomies, Comments (table pulled from first object in array)

if ( empty( $object_type ) ) {
$object_type = 'post_type';
$object = 'post';
} elseif ( empty( $object ) && in_array( $object_type, array( 'user', 'media', 'comment' ), true ) ) {
$object = $object_type;
} elseif ( 'post_type' === $object_type && 'attachment' === $object ) {
$object_type = 'media';
$object = $object_type;
}

$info = array(
//'select' => '`t`.*',
'object_type' => $object_type,
Expand Down Expand Up @@ -10041,16 +10053,6 @@ public function get_table_info( $object_type, $object, $name = null, $pod = null
'recurse' => false
);

if ( empty( $object_type ) ) {
$object_type = 'post_type';
$object = 'post';
} elseif ( empty( $object ) && in_array( $object_type, array( 'user', 'media', 'comment' ), true ) ) {
$object = $object_type;
} elseif ( 'post_type' === $object_type && 'attachment' === $object ) {
$object_type = 'media';
$object = $object_type;
}

$pod_name = $pod;

if ( is_array( $pod_name ) || $pod_name instanceof Pods\Whatsit ) {
Expand Down Expand Up @@ -10111,6 +10113,13 @@ public function get_table_info( $object_type, $object, $name = null, $pod = null
$object_type = $_info['type'];
}
$info = array_merge( $info, $_info );

// Attempt to normalize the object type.
if ( ! empty( $info['pod']['type'] ) ) {
$object_type = $info['pod']['type'];

$info['object_type'] = $object_type;
}
}

if (
Expand Down

0 comments on commit 74ba85d

Please sign in to comment.