Pods – Custom Content Types and Fields - Version 2.9.7

Version Description

  • September 23rd, 2022 =

  • Enhancement: You can now toggle every checkbox at once on the Packages > Export screen instead of just by section. (@sc0ttkclark)

  • Enhancement: The Field object now has a new is_file() method to determine whether the field is a recognized file field type (file or avatar). (@sc0ttkclark)

  • Tweak: Post Type Objects and Taxonomy Objects are now available through Relationships and have been moved from the Advanced Relationships component. (@sc0ttkclark)

  • Fixed: Resolve issue with some sites having an asset issue with the Pods Template editor. #6924 #6921 (@JoryHogeveen)

  • Fixed: Code-based file fields now work correctly with the plupload AJAX handler. (@sc0ttkclark)

  • Fixed: Code-based relationship fields now lookup their data correctly in more places like in Pods::field(). (@sc0ttkclark)

Download this release

Release Info

Developer sc0ttkclark
Plugin Icon 128x128 Pods – Custom Content Types and Fields
Version 2.9.7
Comparing to
See all releases

Code changes from version 2.9.6 to 2.9.7

changelog.txt CHANGED
@@ -2,6 +2,15 @@ Found a bug? Have a great feature idea? Get on GitHub and tell us about it and w
2
 
3
  Our GitHub has the full list of all prior releases of Pods: https://github.com/pods-framework/pods/releases
4
 
 
 
 
 
 
 
 
 
 
5
  = 2.9.6 - September 22nd, 2022 =
6
 
7
  * Fixed: Resolve issue with autocomplete nonce check and autocomplete method. #6919 (@sc0ttkclark)
2
 
3
  Our GitHub has the full list of all prior releases of Pods: https://github.com/pods-framework/pods/releases
4
 
5
+ = 2.9.7 - September 23rd, 2022 =
6
+
7
+ * Enhancement: You can now toggle every checkbox at once on the Packages > Export screen instead of just by section. (@sc0ttkclark)
8
+ * Enhancement: The `Field` object now has a new `is_file()` method to determine whether the field is a recognized file field type (file or avatar). (@sc0ttkclark)
9
+ * Tweak: Post Type Objects and Taxonomy Objects are now available through Relationships and have been moved from the Advanced Relationships component. (@sc0ttkclark)
10
+ * Fixed: Resolve issue with some sites having an asset issue with the Pods Template editor. #6924 #6921 (@JoryHogeveen)
11
+ * Fixed: Code-based file fields now work correctly with the plupload AJAX handler. (@sc0ttkclark)
12
+ * Fixed: Code-based relationship fields now lookup their data correctly in more places like in `Pods::field()`. (@sc0ttkclark)
13
+
14
  = 2.9.6 - September 22nd, 2022 =
15
 
16
  * Fixed: Resolve issue with autocomplete nonce check and autocomplete method. #6919 (@sc0ttkclark)
classes/Pods.php CHANGED
@@ -1142,9 +1142,9 @@ class Pods implements Iterator {
1142
  $limit = $last_limit;
1143
 
1144
  // Get related IDs.
1145
- if ( isset( $current_field['id'] ) ) {
1146
- $ids = $this->data->api->lookup_related_items( $current_field['id'], $current_field->get_parent_id(), $ids, $current_field );
1147
- }
1148
 
1149
  // No items found.
1150
  if ( empty( $ids ) ) {
1142
  $limit = $last_limit;
1143
 
1144
  // Get related IDs.
1145
+ $lookup_related_items_field = ! empty( $current_field['id'] ) ? $current_field['id'] : $current_field['name'];
1146
+
1147
+ $ids = $this->data->api->lookup_related_items( $lookup_related_items_field, $current_field->get_parent_id(), $ids, $current_field );
1148
 
1149
  // No items found.
1150
  if ( empty( $ids ) ) {
classes/PodsAPI.php CHANGED
@@ -9343,7 +9343,11 @@ class PodsAPI {
9343
  );
9344
 
9345
  if ( ! empty( $params->field_id ) ) {
9346
- $load_params['id'] = $params->field_id;
 
 
 
 
9347
  }
9348
 
9349
  $params->field = $this->load_field( $load_params );
@@ -9358,14 +9362,16 @@ class PodsAPI {
9358
  $related_pick_limit = 0;
9359
 
9360
  if ( ! empty( $params->field ) ) {
9361
- $params->field_id = $params->field['id'];
 
9362
 
9363
  if ( $params->field instanceof Field && empty( $params->pod ) ) {
9364
  $params->pod = $params->field->get_parent_object();
9365
  }
9366
 
9367
  if ( ! empty( $params->pod ) ) {
9368
- $params->pod_id = $params->pod['id'];
 
9369
  }
9370
 
9371
  if ( 'multi' === pods_v( $field_type . '_format_type', $params->field, 'single' ) ) {
@@ -9407,7 +9413,12 @@ class PodsAPI {
9407
  if ( ! is_wp_error( $related ) ) {
9408
  $related_ids = $related;
9409
  }
9410
- } elseif ( ! $params->force_meta && ! pods_tableless() && pods_podsrel_enabled( $params->field, 'lookup' ) ) {
 
 
 
 
 
9411
  $params->field_id = (int) $params->field_id;
9412
 
9413
  $ids_in = implode( ', ', array_fill( 0, count( $params->ids ), '%d' ) );
9343
  );
9344
 
9345
  if ( ! empty( $params->field_id ) ) {
9346
+ if ( is_string( $params->field_id ) && ! is_numeric( $params->field_id ) ) {
9347
+ $load_params['name'] = $params->field_id;
9348
+ } else {
9349
+ $load_params['id'] = $params->field_id;
9350
+ }
9351
  }
9352
 
9353
  $params->field = $this->load_field( $load_params );
9362
  $related_pick_limit = 0;
9363
 
9364
  if ( ! empty( $params->field ) ) {
9365
+ $params->field_id = $params->field['id'];
9366
+ $params->field_name = $params->field['name'];
9367
 
9368
  if ( $params->field instanceof Field && empty( $params->pod ) ) {
9369
  $params->pod = $params->field->get_parent_object();
9370
  }
9371
 
9372
  if ( ! empty( $params->pod ) ) {
9373
+ $params->pod_id = $params->pod['id'];
9374
+ $params->pod_name = $params->pod['id'];
9375
  }
9376
 
9377
  if ( 'multi' === pods_v( $field_type . '_format_type', $params->field, 'single' ) ) {
9413
  if ( ! is_wp_error( $related ) ) {
9414
  $related_ids = $related;
9415
  }
9416
+ } elseif (
9417
+ ! $params->force_meta
9418
+ && ! empty( $params->field_id )
9419
+ && ! pods_tableless()
9420
+ && pods_podsrel_enabled( $params->field, 'lookup' )
9421
+ ) {
9422
  $params->field_id = (int) $params->field_id;
9423
 
9424
  $ids_in = implode( ', ', array_fill( 0, count( $params->ids ), '%d' ) );
classes/fields/file.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
 
3
  use Pods\Whatsit\Field;
 
4
 
5
  /**
6
  * @package Pods\Fields
@@ -367,7 +368,6 @@ class PodsField_File extends PodsField {
367
  * {@inheritdoc}
368
  */
369
  public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
370
-
371
  $options = ( is_array( $options ) || is_object( $options ) ) ? $options : (array) $options;
372
 
373
  $type = pods_v( 'type', $options, static::$type );
@@ -415,7 +415,6 @@ class PodsField_File extends PodsField {
415
  * {@inheritdoc}
416
  */
417
  public function build_dfv_field_options( $options, $args ) {
418
-
419
  if ( ! is_admin() ) {
420
  include_once ABSPATH . '/wp-admin/includes/template.php';
421
 
@@ -484,18 +483,36 @@ class PodsField_File extends PodsField {
484
  if ( 'plupload' === pods_v( static::$type . '_uploader', $options ) ) {
485
  wp_enqueue_script( 'plupload-all' );
486
 
487
- $pod_id = (int) pods_v( 'pod_id', $args->pod, 0 );
488
- $field_id = (int) pods_v( 'id', $options, 0 );
489
- $item_id = (int) pods_v( 'id', $args, 0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
490
 
491
- if ( $is_user_logged_in ) {
492
  $uid = 'user_' . get_current_user_id();
493
  } else {
494
  $uid = pods_session_id();
495
  }
496
 
497
- $uri_hash = wp_create_nonce( 'pods_uri_' . $_SERVER['REQUEST_URI'] );
498
- $field_nonce = wp_create_nonce( 'pods_upload_' . $pod_id . '_' . $uid . '_' . $uri_hash . '_' . $field_id );
 
 
499
 
500
  $plupload_init = [
501
  'runtimes' => 'html5,silverlight,flash,html4',
@@ -514,13 +531,13 @@ class PodsField_File extends PodsField {
514
  'multipart' => true,
515
  'urlstream_upload' => true,
516
  'multipart_params' => [
517
- '_wpnonce' => $field_nonce,
518
- 'action' => 'pods_upload',
519
- 'method' => 'upload',
520
- 'pod' => $pod_id,
521
- 'field' => $field_id,
522
- 'item_id' => $item_id,
523
- 'uri' => $uri_hash,
524
  ],
525
  ];
526
 
@@ -960,11 +977,11 @@ class PodsField_File extends PodsField {
960
  'upload',
961
  );
962
 
963
- if ( ! isset( $params->method ) || ! in_array( $params->method, $methods, true ) || ! isset( $params->pod ) || ! isset( $params->field ) || ! isset( $params->uri ) || empty( $params->uri ) ) {
964
  pods_error( __( 'Invalid AJAX request', 'pods' ), PodsInit::$admin );
965
- } elseif ( ! empty( $params->pod ) && empty( $params->field ) ) {
966
  pods_error( __( 'Invalid AJAX request', 'pods' ), PodsInit::$admin );
967
- } elseif ( empty( $params->pod ) && ! current_user_can( 'upload_files' ) ) {
968
  pods_error( __( 'Invalid AJAX request', 'pods' ), PodsInit::$admin );
969
  }
970
 
@@ -1004,49 +1021,66 @@ class PodsField_File extends PodsField {
1004
  }
1005
  }
1006
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1007
  $uid = pods_session_id();
1008
 
1009
- if ( $is_user_logged_in ) {
1010
  $uid = 'user_' . get_current_user_id();
1011
  }
1012
 
1013
- $nonce_check = 'pods_upload_' . (int) $params->pod . '_' . $uid . '_' . $params->uri . '_' . (int) $params->field;
1014
 
1015
- if ( true === $upload_disabled || ! isset( $params->_wpnonce ) || false === wp_verify_nonce( $params->_wpnonce, $nonce_check ) ) {
1016
  pods_error( __( 'Unauthorized request', 'pods' ), PodsInit::$admin );
1017
  }
1018
 
1019
- $pod = array();
1020
- $field = array(
1021
- 'type' => 'file',
1022
- 'options' => array(),
1023
- );
1024
-
1025
  if ( empty( self::$api ) ) {
1026
  self::$api = pods_api();
1027
  }
1028
 
1029
- self::$api->display_errors = false;
 
 
 
 
 
 
1030
 
1031
- if ( ! empty( $params->pod ) ) {
1032
- $pod = self::$api->load_pod( array( 'id' => (int) $params->pod ) );
1033
- $field = self::$api->load_field( array( 'id' => (int) $params->field ) );
1034
 
1035
- if ( empty( $pod ) || empty( $field ) || (int) $pod['id'] !== (int) $field['pod_id'] || ! isset( $pod['fields'][ $field['name'] ] ) ) {
1036
- pods_error( __( 'Invalid field request', 'pods' ), PodsInit::$admin );
1037
- }
1038
 
1039
- if ( ! in_array( $field['type'], PodsForm::file_field_types(), true ) ) {
1040
- pods_error( __( 'Invalid field', 'pods' ), PodsInit::$admin );
1041
- }
1042
  }
1043
 
 
 
 
 
 
 
1044
  $method = $params->method;
1045
 
1046
  // Cleaning up $params
1047
  unset( $params->action, $params->method, $params->_wpnonce );
1048
 
1049
- $params->item_id = (int) pods_v( 'item_id', $params, 0 );
1050
 
1051
  /**
1052
  * Upload a new file (advanced - returns URL and ID)
@@ -1190,6 +1224,7 @@ class PodsField_File extends PodsField {
1190
 
1191
  // Upload file.
1192
  $post_id = 0;
 
1193
  if ( 'post_type' === pods_v( 'type', $pod, null ) ) {
1194
  $post_id = $params->item_id;
1195
  }
@@ -1388,7 +1423,7 @@ class PodsField_File extends PodsField {
1388
  }
1389
  }
1390
 
1391
- return $this->get_file_mime_types_for_media_type( $media_type, $other_extensions );
1392
  }
1393
 
1394
  /**
@@ -1396,13 +1431,14 @@ class PodsField_File extends PodsField {
1396
  *
1397
  * @since 2.9.0
1398
  *
1399
- * @param string $media_type The media type to use for looking up by mime type.
1400
- * @param string|array $other_extensions The other file extensions that may have been provided.
 
1401
  *
1402
  * @return null|array Null if any are allowed, otherwise an array with the file mime type information including the
1403
  * list of extensions, mime types, and mapping of extensions to mime types.
1404
  */
1405
- public function get_file_mime_types_for_media_type( $media_type, $other_extensions = [] ) {
1406
  if ( 'any' === $media_type ) {
1407
  return null;
1408
  }
@@ -1460,17 +1496,19 @@ class PodsField_File extends PodsField {
1460
  *
1461
  * @since 2.9.0
1462
  *
1463
- * @param null|array $file_extensions Null if any are allowed, otherwise an array with the file mime type
1464
- * information including the list of extensions, mime types, and mapping
1465
- * of extensions to mime types.
1466
- * @param string $media_type The media type to use for looking up by mime type.
1467
- * @param string|array $other_extensions The other file extensions that may have been provided.
 
1468
  */
1469
  $file_extensions = apply_filters(
1470
  'pods_form_ui_field_file_mime_types_for_media_type',
1471
  $file_extensions,
1472
  $media_type,
1473
- $other_extensions
 
1474
  );
1475
 
1476
  return [
1
  <?php
2
 
3
  use Pods\Whatsit\Field;
4
+ use Pods\Whatsit\Pod;
5
 
6
  /**
7
  * @package Pods\Fields
368
  * {@inheritdoc}
369
  */
370
  public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
 
371
  $options = ( is_array( $options ) || is_object( $options ) ) ? $options : (array) $options;
372
 
373
  $type = pods_v( 'type', $options, static::$type );
415
  * {@inheritdoc}
416
  */
417
  public function build_dfv_field_options( $options, $args ) {
 
418
  if ( ! is_admin() ) {
419
  include_once ABSPATH . '/wp-admin/includes/template.php';
420
 
483
  if ( 'plupload' === pods_v( static::$type . '_uploader', $options ) ) {
484
  wp_enqueue_script( 'plupload-all' );
485
 
486
+ if ( is_array( $args->pod ) ) {
487
+ $pod_name = $args->pod['name'];
488
+ } elseif ( $args->pod instanceof Pods ) {
489
+ $pod_name = $args->pod->pod;
490
+ } elseif ( $args->pod instanceof Pod ) {
491
+ $pod_name = $args->pod->get_name();
492
+ } else {
493
+ $pod_name = '';
494
+ }
495
+
496
+ if ( is_array( $options ) ) {
497
+ $field_name = pods_v( 'name', $options );
498
+ } elseif ( $options instanceof Field ) {
499
+ $field_name = $options->get_name();
500
+ } else {
501
+ $field_name = '';
502
+ }
503
+
504
+ $id = (int) $args->id;
505
 
506
+ if ( is_user_logged_in() ) {
507
  $uid = 'user_' . get_current_user_id();
508
  } else {
509
  $uid = pods_session_id();
510
  }
511
 
512
+ $uri_hash = wp_create_nonce( 'pods_uri_' . $_SERVER['REQUEST_URI'] );
513
+
514
+ $nonce_name = 'pods_upload:' . json_encode( compact( 'pod_name', 'field_name', 'uid', 'uri_hash', 'id' ) );
515
+ $field_nonce = wp_create_nonce( $nonce_name );
516
 
517
  $plupload_init = [
518
  'runtimes' => 'html5,silverlight,flash,html4',
531
  'multipart' => true,
532
  'urlstream_upload' => true,
533
  'multipart_params' => [
534
+ 'action' => 'pods_upload',
535
+ 'method' => 'upload',
536
+ 'pod_name' => $pod_name,
537
+ 'field_name' => $field_name,
538
+ 'id' => $id,
539
+ 'uri_hash' => $uri_hash,
540
+ '_wpnonce' => $field_nonce,
541
  ],
542
  ];
543
 
977
  'upload',
978
  );
979
 
980
+ if ( ! isset( $params->method ) || ! in_array( $params->method, $methods, true ) ) {
981
  pods_error( __( 'Invalid AJAX request', 'pods' ), PodsInit::$admin );
982
+ } elseif ( ! empty( $params->pod_name ) && empty( $params->field_name ) ) {
983
  pods_error( __( 'Invalid AJAX request', 'pods' ), PodsInit::$admin );
984
+ } elseif ( empty( $params->pod_name ) && ! current_user_can( 'upload_files' ) ) {
985
  pods_error( __( 'Invalid AJAX request', 'pods' ), PodsInit::$admin );
986
  }
987
 
1021
  }
1022
  }
1023
 
1024
+ if ( true === $upload_disabled ) {
1025
+ pods_error( __( 'Unauthorized request', 'pods' ), PodsInit::$admin );
1026
+ }
1027
+
1028
+ if ( ! isset( $params->_wpnonce, $params->pod_name, $params->field_name, $params->uri_hash, $params->id ) ) {
1029
+ pods_error( __( 'Unauthorized request', 'pods' ), PodsInit::$admin );
1030
+ }
1031
+
1032
+ $_wpnonce = $params->_wpnonce;
1033
+ $pod_name = $params->pod_name;
1034
+ $field_name = $params->field_name;
1035
+ $uri_hash = $params->uri_hash;
1036
+ $id = (int) $params->id;
1037
+
1038
  $uid = pods_session_id();
1039
 
1040
+ if ( is_user_logged_in() ) {
1041
  $uid = 'user_' . get_current_user_id();
1042
  }
1043
 
1044
+ $nonce_name = 'pods_upload:' . json_encode( compact( 'pod_name', 'field_name', 'uid', 'uri_hash', 'id' ) );
1045
 
1046
+ if ( false === wp_verify_nonce( $_wpnonce, $nonce_name ) ) {
1047
  pods_error( __( 'Unauthorized request', 'pods' ), PodsInit::$admin );
1048
  }
1049
 
 
 
 
 
 
 
1050
  if ( empty( self::$api ) ) {
1051
  self::$api = pods_api();
1052
  }
1053
 
1054
+ $pod = self::$api->load_pod( [
1055
+ 'name' => $pod_name,
1056
+ ] );
1057
+
1058
+ if ( ! $pod ) {
1059
+ pods_error( __( 'Invalid Pod configuration', 'pods' ), PodsInit::$admin );
1060
+ }
1061
 
1062
+ $field = $pod->get_field( $field_name );
 
 
1063
 
1064
+ if ( ! $field ) {
1065
+ pods_error( __( 'Invalid Field configuration', 'pods' ), PodsInit::$admin );
1066
+ }
1067
 
1068
+ if ( ! $field->is_file() ) {
1069
+ pods_error( __( 'Invalid field', 'pods' ), PodsInit::$admin );
 
1070
  }
1071
 
1072
+ if ( empty( self::$api ) ) {
1073
+ self::$api = pods_api();
1074
+ }
1075
+
1076
+ self::$api->display_errors = false;
1077
+
1078
  $method = $params->method;
1079
 
1080
  // Cleaning up $params
1081
  unset( $params->action, $params->method, $params->_wpnonce );
1082
 
1083
+ $params->post_id = (int) pods_v( 'post_id', $params, 0 );
1084
 
1085
  /**
1086
  * Upload a new file (advanced - returns URL and ID)
1224
 
1225
  // Upload file.
1226
  $post_id = 0;
1227
+
1228
  if ( 'post_type' === pods_v( 'type', $pod, null ) ) {
1229
  $post_id = $params->item_id;
1230
  }
1423
  }
1424
  }
1425
 
1426
+ return $this->get_file_mime_types_for_media_type( $media_type, $other_extensions, $field );
1427
  }
1428
 
1429
  /**
1431
  *
1432
  * @since 2.9.0
1433
  *
1434
+ * @param string $media_type The media type to use for looking up by mime type.
1435
+ * @param string|array $other_extensions The other file extensions that may have been provided.
1436
+ * @param Field|array|null $field The field to use.
1437
  *
1438
  * @return null|array Null if any are allowed, otherwise an array with the file mime type information including the
1439
  * list of extensions, mime types, and mapping of extensions to mime types.
1440
  */
1441
+ public function get_file_mime_types_for_media_type( $media_type, $other_extensions = [], $field = null ) {
1442
  if ( 'any' === $media_type ) {
1443
  return null;
1444
  }
1496
  *
1497
  * @since 2.9.0
1498
  *
1499
+ * @param null|array $file_extensions Null if any are allowed, otherwise an array with the file mime type
1500
+ * information including the list of extensions, mime types, and mapping
1501
+ * of extensions to mime types.
1502
+ * @param string $media_type The media type to use for looking up by mime type.
1503
+ * @param string|array $other_extensions The other file extensions that may have been provided.
1504
+ * @param Field|array|null $field The field to use.
1505
  */
1506
  $file_extensions = apply_filters(
1507
  'pods_form_ui_field_file_mime_types_for_media_type',
1508
  $file_extensions,
1509
  $media_type,
1510
+ $other_extensions,
1511
+ $field
1512
  );
1513
 
1514
  return [
classes/fields/pick.php CHANGED
@@ -684,6 +684,20 @@ class PodsField_Pick extends PodsField {
684
  'data_callback' => array( $this, 'data_post_stati' ),
685
  );
686
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
687
  do_action( 'pods_form_ui_field_pick_related_objects_other' );
688
 
689
  self::$related_objects['country'] = array(
@@ -3236,6 +3250,83 @@ class PodsField_Pick extends PodsField {
3236
 
3237
  }
3238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3239
  /**
3240
  * Data callback for Countries.
3241
  *
684
  'data_callback' => array( $this, 'data_post_stati' ),
685
  );
686
 
687
+ self::$related_objects['post-types'] = [
688
+ 'label' => __( 'Post Type Objects', 'pods' ),
689
+ 'group' => __( 'Other WP Objects', 'pods' ),
690
+ 'simple' => true,
691
+ 'data_callback' => [ $this, 'data_post_types' ],
692
+ ];
693
+
694
+ self::$related_objects['taxonomies'] = [
695
+ 'label' => __( 'Taxonomy Objects', 'pods' ),
696
+ 'group' => __( 'Other WP Objects', 'pods' ),
697
+ 'simple' => true,
698
+ 'data_callback' => [ $this, 'data_taxonomies' ],
699
+ ];
700
+
701
  do_action( 'pods_form_ui_field_pick_related_objects_other' );
702
 
703
  self::$related_objects['country'] = array(
3250
 
3251
  }
3252
 
3253
+ /**
3254
+ * Data callback for Post Types
3255
+ *
3256
+ * @param string $name The name of the field
3257
+ * @param string|array $value The value of the field
3258
+ * @param array $options Field options
3259
+ * @param array $pod Pod data
3260
+ * @param int $id Item ID
3261
+ *
3262
+ * @return array
3263
+ *
3264
+ * @since 2.3.0
3265
+ */
3266
+ public function data_post_types( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
3267
+
3268
+ $data = array();
3269
+
3270
+ $post_types = get_post_types( array(), 'objects' );
3271
+
3272
+ $ignore = [
3273
+ 'revision',
3274
+ 'nav_menu_item',
3275
+ 'custom_css',
3276
+ 'customize_changeset',
3277
+ 'attachment',
3278
+ 'oembed_cache',
3279
+ 'user_request',
3280
+ 'wp_block',
3281
+ 'wp_template',
3282
+ 'wp_template_part',
3283
+ 'wp_global_styles',
3284
+ 'wp_navigation',
3285
+ ];
3286
+
3287
+ foreach ( $post_types as $post_type ) {
3288
+ if ( in_array( $post_type->name, $ignore, true ) || 0 === strpos( $post_type->name, '_pods_' ) ) {
3289
+ continue;
3290
+ }
3291
+
3292
+ $data[ $post_type->name ] = $post_type->label;
3293
+ }
3294
+
3295
+ return apply_filters( 'pods_form_ui_field_pick_data_post_types', $data, $name, $value, $options, $pod, $id );
3296
+ }
3297
+
3298
+ /**
3299
+ * Data callback for Taxonomies
3300
+ *
3301
+ * @param string $name The name of the field
3302
+ * @param string|array $value The value of the field
3303
+ * @param array $options Field options
3304
+ * @param array $pod Pod data
3305
+ * @param int $id Item ID
3306
+ *
3307
+ * @return array
3308
+ *
3309
+ * @since 2.3.0
3310
+ */
3311
+ public function data_taxonomies( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
3312
+
3313
+ $data = array();
3314
+
3315
+ $taxonomies = get_taxonomies( array(), 'objects' );
3316
+
3317
+ $ignore = array( 'nav_menu', 'post_format' );
3318
+
3319
+ foreach ( $taxonomies as $taxonomy ) {
3320
+ if ( in_array( $taxonomy->name, $ignore, true ) ) {
3321
+ continue;
3322
+ }
3323
+
3324
+ $data[ $taxonomy->name ] = $taxonomy->label;
3325
+ }
3326
+
3327
+ return apply_filters( 'pods_form_ui_field_pick_data_taxonomies', $data, $name, $value, $options, $pod, $id );
3328
+ }
3329
+
3330
  /**
3331
  * Data callback for Countries.
3332
  *
components/Advanced-Relationships.php CHANGED
@@ -79,20 +79,6 @@ class Pods_Advanced_Relationships extends PodsComponent {
79
  'simple' => true,
80
  'data_callback' => array( $this, 'data_sidebars' ),
81
  );
82
-
83
- PodsField_Pick::$related_objects['post-types'] = array(
84
- 'label' => __( 'Post Type Objects', 'pods' ),
85
- 'group' => __( 'Advanced Objects', 'pods' ),
86
- 'simple' => true,
87
- 'data_callback' => array( $this, 'data_post_types' ),
88
- );
89
-
90
- PodsField_Pick::$related_objects['taxonomies'] = array(
91
- 'label' => __( 'Taxonomy Objects', 'pods' ),
92
- 'group' => __( 'Advanced Objects', 'pods' ),
93
- 'simple' => true,
94
- 'data_callback' => array( $this, 'data_taxonomies' ),
95
- );
96
  }
97
 
98
  /**
@@ -191,68 +177,4 @@ class Pods_Advanced_Relationships extends PodsComponent {
191
  return apply_filters( 'pods_form_ui_field_pick_data_sidebars', $data, $name, $value, $options, $pod, $id );
192
  }
193
 
194
- /**
195
- * Data callback for Post Types
196
- *
197
- * @param string $name The name of the field
198
- * @param string|array $value The value of the field
199
- * @param array $options Field options
200
- * @param array $pod Pod data
201
- * @param int $id Item ID
202
- *
203
- * @return array
204
- *
205
- * @since 2.3.0
206
- */
207
- public function data_post_types( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
208
-
209
- $data = array();
210
-
211
- $post_types = get_post_types( array(), 'objects' );
212
-
213
- $ignore = array( 'revision', 'nav_menu_item' );
214
-
215
- foreach ( $post_types as $post_type ) {
216
- if ( in_array( $post_type->name, $ignore, true ) || 0 === strpos( $post_type->name, '_pods_' ) ) {
217
- continue;
218
- }
219
-
220
- $data[ $post_type->name ] = $post_type->label;
221
- }
222
-
223
- return apply_filters( 'pods_form_ui_field_pick_data_post_types', $data, $name, $value, $options, $pod, $id );
224
- }
225
-
226
- /**
227
- * Data callback for Taxonomies
228
- *
229
- * @param string $name The name of the field
230
- * @param string|array $value The value of the field
231
- * @param array $options Field options
232
- * @param array $pod Pod data
233
- * @param int $id Item ID
234
- *
235
- * @return array
236
- *
237
- * @since 2.3.0
238
- */
239
- public function data_taxonomies( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
240
-
241
- $data = array();
242
-
243
- $taxonomies = get_taxonomies( array(), 'objects' );
244
-
245
- $ignore = array( 'nav_menu', 'post_format' );
246
-
247
- foreach ( $taxonomies as $taxonomy ) {
248
- if ( in_array( $taxonomy->name, $ignore, true ) ) {
249
- continue;
250
- }
251
-
252
- $data[ $taxonomy->name ] = $taxonomy->label;
253
- }
254
-
255
- return apply_filters( 'pods_form_ui_field_pick_data_taxonomies', $data, $name, $value, $options, $pod, $id );
256
- }
257
-
258
  }
79
  'simple' => true,
80
  'data_callback' => array( $this, 'data_sidebars' ),
81
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
 
84
  /**
177
  return apply_filters( 'pods_form_ui_field_pick_data_sidebars', $data, $name, $value, $options, $pod, $id );
178
  }
179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  }
components/Migrate-Packages/ui/wizard.php CHANGED
@@ -115,6 +115,10 @@
115
  <div class="pods-wizard-option-content" id="pods-wizard-export">
116
  <div class="pods-wizard-content">
117
  <p><?php _e( 'Packages allow you to import/export your Pods, Groups, Fields, and other settings between any Pods sites.', 'pods' ); ?></p>
 
 
 
 
118
  </div>
119
 
120
  <div class="stuffbox pods-package-import-group">
@@ -460,18 +464,30 @@
460
  $( document ).Pods( 'confirm' );
461
  $( document ).Pods( 'sluggable' );
462
 
463
- const toggle_all = {};
 
 
464
 
465
  $( '.pods-wizard-toggle-all' ).on( 'click', function ( e ) {
466
  e.preventDefault();
467
 
468
- if ( 'undefined' == typeof toggle_all[$( this ).data( 'toggle' )] ) {
469
- toggle_all[$( this ).data( 'toggle' )] = true;
 
 
 
 
 
 
 
 
 
 
470
  }
471
 
472
- $( this ).closest( '.pods-field-option-group' ).find( '.pods-field.pods-boolean input[type="checkbox"]' ).prop( 'checked', (!toggle_all[$( this ).data( 'toggle' )]) );
473
 
474
- toggle_all[$( this ).data( 'toggle' )] = (!toggle_all[$( this ).data( 'toggle' )]);
475
  } );
476
 
477
  const $import_package_reset = $( '#pods-form-ui-import-package-file-reset' );
115
  <div class="pods-wizard-option-content" id="pods-wizard-export">
116
  <div class="pods-wizard-content">
117
  <p><?php _e( 'Packages allow you to import/export your Pods, Groups, Fields, and other settings between any Pods sites.', 'pods' ); ?></p>
118
+
119
+ <p>
120
+ <a href="#toggle" class="button pods-wizard-toggle-all" data-toggle="all"><?php _e( 'Toggle everything on / off', 'pods' ); ?></a>
121
+ </p>
122
  </div>
123
 
124
  <div class="stuffbox pods-package-import-group">
464
  $( document ).Pods( 'confirm' );
465
  $( document ).Pods( 'sluggable' );
466
 
467
+ const toggle_all = {
468
+ all: true
469
+ };
470
 
471
  $( '.pods-wizard-toggle-all' ).on( 'click', function ( e ) {
472
  e.preventDefault();
473
 
474
+ const toggleData = $( this ).data( 'toggle' );
475
+
476
+ if ( 'undefined' == typeof toggle_all[toggleData] ) {
477
+ toggle_all[toggleData] = true;
478
+ }
479
+
480
+ let $parent;
481
+
482
+ if ( 'all' !== toggleData ) {
483
+ $parent = $( this ).closest( '.pods-field-option-group' );
484
+ } else {
485
+ $parent = $( this ).closest( '.pods-wizard-option-content' );
486
  }
487
 
488
+ $parent.find( '.pods-field.pods-boolean input[type="checkbox"]' ).prop( 'checked', (!toggle_all[toggleData]) );
489
 
490
+ toggle_all[toggleData] = (!toggle_all[toggleData]);
491
  } );
492
 
493
  const $import_package_reset = $( '#pods-form-ui-import-package-file-reset' );
components/Templates/Templates.php CHANGED
@@ -191,8 +191,6 @@ class Pods_Templates extends PodsComponent {
191
 
192
  add_action( 'add_meta_boxes_' . $this->object_type, array( $this, 'edit_page_form' ) );
193
 
194
- add_action( 'pods_meta_groups', array( $this, 'add_meta_boxes' ) );
195
-
196
  add_filter( 'get_post_metadata', array( $this, 'get_meta' ), 10, 4 );
197
  add_filter( 'update_post_metadata', array( $this, 'save_meta' ), 10, 4 );
198
 
@@ -432,25 +430,8 @@ class Pods_Templates extends PodsComponent {
432
  return;
433
  }
434
 
435
- add_filter( 'enter_title_here', array( $this, 'set_title_text' ), 10, 2 );
436
- }
437
-
438
- /**
439
- * Add meta boxes to the page
440
- *
441
- * @since 2.0.0
442
- */
443
- public function add_meta_boxes() {
444
- $pod = array(
445
- 'name' => $this->object_type,
446
- 'type' => 'post_type',
447
- );
448
-
449
- if ( isset( PodsMeta::$post_types[ $pod['name'] ] ) ) {
450
- return;
451
- }
452
-
453
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_assets' ), 21 );
 
454
  }
455
 
456
  /**
191
 
192
  add_action( 'add_meta_boxes_' . $this->object_type, array( $this, 'edit_page_form' ) );
193
 
 
 
194
  add_filter( 'get_post_metadata', array( $this, 'get_meta' ), 10, 4 );
195
  add_filter( 'update_post_metadata', array( $this, 'save_meta' ), 10, 4 );
196
 
430
  return;
431
  }
432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_assets' ), 21 );
434
+ add_filter( 'enter_title_here', array( $this, 'set_title_text' ), 10, 2 );
435
  }
436
 
437
  /**
init.php CHANGED
@@ -10,7 +10,7 @@
10
  * Plugin Name: Pods - Custom Content Types and Fields
11
  * Plugin URI: https://pods.io/
12
  * Description: Pods is a framework for creating, managing, and deploying customized content types and fields
13
- * Version: 2.9.6
14
  * Author: Pods Framework Team
15
  * Author URI: https://pods.io/about/
16
  * Text Domain: pods
@@ -43,7 +43,7 @@ if ( defined( 'PODS_VERSION' ) || defined( 'PODS_DIR' ) ) {
43
  add_action( 'init', 'pods_deactivate_pods_ui' );
44
  } else {
45
  // Current version.
46
- define( 'PODS_VERSION', '2.9.6' );
47
 
48
  // Current database version, this is the last version the database changed.
49
  define( 'PODS_DB_VERSION', '2.3.5' );
10
  * Plugin Name: Pods - Custom Content Types and Fields
11
  * Plugin URI: https://pods.io/
12
  * Description: Pods is a framework for creating, managing, and deploying customized content types and fields
13
+ * Version: 2.9.7
14
  * Author: Pods Framework Team
15
  * Author URI: https://pods.io/about/
16
  * Text Domain: pods
43
  add_action( 'init', 'pods_deactivate_pods_ui' );
44
  } else {
45
  // Current version.
46
+ define( 'PODS_VERSION', '2.9.7' );
47
 
48
  // Current database version, this is the last version the database changed.
49
  define( 'PODS_DB_VERSION', '2.3.5' );
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: pods, custom post types, custom taxonomies, content types, custom fields,
5
  Requires at least: 5.7
6
  Tested up to: 6.1
7
  Requires PHP: 5.6
8
- Stable tag: 2.9.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -173,6 +173,15 @@ Pods really wouldn't be where it is without all the contributions from our [dono
173
 
174
  == Changelog ==
175
 
 
 
 
 
 
 
 
 
 
176
  = 2.9.6 - September 22nd, 2022 =
177
 
178
  * Fixed: Resolve issue with autocomplete nonce check and autocomplete method. #6919 (@sc0ttkclark)
5
  Requires at least: 5.7
6
  Tested up to: 6.1
7
  Requires PHP: 5.6
8
+ Stable tag: 2.9.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
173
 
174
  == Changelog ==
175
 
176
+ = 2.9.7 - September 23rd, 2022 =
177
+
178
+ * Enhancement: You can now toggle every checkbox at once on the Packages > Export screen instead of just by section. (@sc0ttkclark)
179
+ * Enhancement: The `Field` object now has a new `is_file()` method to determine whether the field is a recognized file field type (file or avatar). (@sc0ttkclark)
180
+ * Tweak: Post Type Objects and Taxonomy Objects are now available through Relationships and have been moved from the Advanced Relationships component. (@sc0ttkclark)
181
+ * Fixed: Resolve issue with some sites having an asset issue with the Pods Template editor. #6924 #6921 (@JoryHogeveen)
182
+ * Fixed: Code-based file fields now work correctly with the plupload AJAX handler. (@sc0ttkclark)
183
+ * Fixed: Code-based relationship fields now lookup their data correctly in more places like in `Pods::field()`. (@sc0ttkclark)
184
+
185
  = 2.9.6 - September 22nd, 2022 =
186
 
187
  * Fixed: Resolve issue with autocomplete nonce check and autocomplete method. #6919 (@sc0ttkclark)
src/Pods/Whatsit/Field.php CHANGED
@@ -342,6 +342,21 @@ class Field extends Whatsit {
342
  return in_array( $type, $tableless_field_types, true );
343
  }
344
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  /**
346
  * Determine whether this is an autocomplete relationship field.
347
  *
342
  return in_array( $type, $tableless_field_types, true );
343
  }
344
 
345
+ /**
346
+ * Determine whether this is a relationship field (pick/file/etc).
347
+ *
348
+ * @since 2.9.7
349
+ *
350
+ * @return bool Whether this is a relationship field (pick/file/etc).
351
+ */
352
+ public function is_file() {
353
+ $type = $this->get_type();
354
+
355
+ $file_field_types = PodsForm::file_field_types();
356
+
357
+ return in_array( $type, $file_field_types, true );
358
+ }
359
+
360
  /**
361
  * Determine whether this is an autocomplete relationship field.
362
  *