Skip to content

Commit 0268154

Browse files
committed
merge in 1.13.3
1 parent cbec951 commit 0268154

File tree

5 files changed

+63
-33
lines changed

5 files changed

+63
-33
lines changed

custom-post-type-ui.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Plugin URI: https://github.com/WebDevStudios/custom-post-type-ui/
1717
* Description: Admin panel for creating custom post types and custom taxonomies in WordPress
1818
* Author: WebDevStudios
19-
* Version: 1.13.2
19+
* Version: 1.13.3
2020
* Author URI: https://webdevstudios.com/
2121
* Text Domain: custom-post-type-ui
2222
* Domain Path: /languages
@@ -33,8 +33,8 @@
3333
exit;
3434
}
3535

36-
define( 'CPT_VERSION', '1.13.2' ); // Left for legacy purposes.
37-
define( 'CPTUI_VERSION', '1.13.2' );
36+
define( 'CPT_VERSION', '1.13.3' ); // Left for legacy purposes.
37+
define( 'CPTUI_VERSION', '1.13.3' );
3838
define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
3939

4040
/**

inc/post-types.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,10 @@ function cptui_update_post_type( $data = [] ) {
20302030
$data['cpt_supports'] = [];
20312031
}
20322032

2033+
if ( empty( $data['cpt_labels'] ) || ! is_array( $data['cpt_labels'] ) ) {
2034+
$data['cpt_labels'] = [];
2035+
}
2036+
20332037
foreach ( $data['cpt_labels'] as $key => $label ) {
20342038
if ( empty( $label ) ) {
20352039
unset( $data['cpt_labels'][ $key ] );
@@ -2045,8 +2049,9 @@ function cptui_update_post_type( $data = [] ) {
20452049
}
20462050
}
20472051

2048-
if ( empty( $data['cpt_custom_post_type']['menu_icon'] ) ) {
2049-
$data['cpt_custom_post_type']['menu_icon'] = null;
2052+
$menu_icon = trim( $data['cpt_custom_post_type']['menu_icon'] );
2053+
if ( '' === $data['cpt_custom_post_type']['menu_icon'] ) {
2054+
$menu_icon = null;
20502055
}
20512056

20522057
$register_meta_box_cb = trim( $data['cpt_custom_post_type']['register_meta_box_cb'] );
@@ -2081,7 +2086,6 @@ function cptui_update_post_type( $data = [] ) {
20812086
$query_var_slug = trim( $data['cpt_custom_post_type']['query_var_slug'] );
20822087
$menu_position = trim( $data['cpt_custom_post_type']['menu_position'] );
20832088
$show_in_menu_string = trim( $data['cpt_custom_post_type']['show_in_menu_string'] );
2084-
$menu_icon = trim( $data['cpt_custom_post_type']['menu_icon'] );
20852089
$custom_supports = trim( $data['cpt_custom_post_type']['custom_supports'] );
20862090
$enter_title_here = trim( $data['cpt_custom_post_type']['enter_title_here'] );
20872091

@@ -2347,7 +2351,7 @@ function cptui_process_post_type() {
23472351
} elseif ( isset( $_POST['cpt_delete'] ) ) {
23482352
check_admin_referer( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
23492353

2350-
$filtered_data = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
2354+
$filtered_data = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
23512355
$result = cptui_delete_post_type( $filtered_data );
23522356
add_filter( 'cptui_post_type_deleted', '__return_true' );
23532357
}
@@ -2390,8 +2394,8 @@ function cptui_do_convert_post_type_posts() {
23902394
if ( apply_filters( 'cptui_convert_post_type_posts', false ) ) {
23912395
check_admin_referer( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
23922396

2393-
$original = filter_input( INPUT_POST, 'cpt_original', FILTER_SANITIZE_STRING );
2394-
$new = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
2397+
$original = filter_input( INPUT_POST, 'cpt_original', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
2398+
$new = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
23952399

23962400
// Return early if either fails to successfully validate.
23972401
if ( ! $original || ! $new ) {
@@ -2451,7 +2455,7 @@ function cptui_filtered_post_type_post_global() {
24512455

24522456
$items_arrays = array_merge( $default_arrays, $third_party_items_arrays );
24532457
foreach ( $items_arrays as $item ) {
2454-
$first_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
2458+
$first_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
24552459

24562460
if ( $first_result ) {
24572461
$filtered_data[ $item ] = $first_result;
@@ -2471,7 +2475,7 @@ function cptui_filtered_post_type_post_global() {
24712475
$items_string = array_merge( $default_strings, $third_party_items_strings );
24722476

24732477
foreach ( $items_string as $item ) {
2474-
$second_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_STRING );
2478+
$second_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_FULL_SPECIAL_CHARS );
24752479
if ( $second_result ) {
24762480
$filtered_data[ $item ] = $second_result;
24772481
}

inc/taxonomies.php

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,10 @@ function cptui_update_taxonomy( $data = [] ) {
16201620
return 'error';
16211621
}
16221622

1623+
if ( empty( $data['cpt_tax_labels'] ) || ! is_array( $data['cpt_tax_labels'] ) ) {
1624+
$data['cpt_tax_labels'] = [];
1625+
}
1626+
16231627
foreach ( $data['cpt_tax_labels'] as $key => $label ) {
16241628
if ( empty( $label ) ) {
16251629
unset( $data['cpt_tax_labels'][ $key ] );
@@ -1972,7 +1976,7 @@ function cptui_process_taxonomy() {
19721976
} elseif ( isset( $_POST['cpt_delete'] ) ) {
19731977
check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
19741978

1975-
$filtered_data = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
1979+
$filtered_data = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
19761980
$result = cptui_delete_taxonomy( $filtered_data );
19771981
add_filter( 'cptui_taxonomy_deleted', '__return_true' );
19781982
}
@@ -2012,8 +2016,8 @@ function cptui_do_convert_taxonomy_terms() {
20122016
if ( apply_filters( 'cptui_convert_taxonomy_terms', false ) ) {
20132017
check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
20142018

2015-
$original = filter_input( INPUT_POST, 'tax_original', FILTER_SANITIZE_STRING );
2016-
$new = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
2019+
$original = filter_input( INPUT_POST, 'tax_original', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
2020+
$new = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
20172021

20182022
// Return early if either fails to successfully validate.
20192023
if ( ! $original || ! $new ) {
@@ -2058,28 +2062,40 @@ function cptui_updated_taxonomy_slug_exists( $slug_exists, $taxonomy_slug = '',
20582062
function cptui_filtered_taxonomy_post_global() {
20592063
$filtered_data = [];
20602064

2061-
foreach (
2062-
[
2063-
'cpt_custom_tax',
2064-
'cpt_tax_labels',
2065-
'cpt_post_types',
2066-
'update_taxonomy',
2067-
] as $item
2068-
) {
2069-
$first_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
2065+
$default_arrays = [
2066+
'cpt_custom_tax',
2067+
'cpt_tax_labels',
2068+
'cpt_post_types',
2069+
'update_taxonomy',
2070+
];
2071+
2072+
$third_party_items_arrays = apply_filters(
2073+
'cptui_filtered_taxonomy_post_global_arrays',
2074+
(array) [] // phpcs:ignore.
2075+
);
2076+
2077+
$items_arrays = array_merge( $default_arrays, $third_party_items_arrays );
2078+
foreach ( $items_arrays as $item ) {
2079+
$first_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
20702080

20712081
if ( $first_result ) {
20722082
$filtered_data[ $item ] = $first_result;
20732083
}
20742084
}
20752085

2076-
foreach (
2077-
[
2078-
'tax_original',
2079-
'cpt_tax_status',
2080-
] as $item
2081-
) {
2082-
$second_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_STRING );
2086+
$default_strings = [
2087+
'tax_original',
2088+
'cpt_tax_status',
2089+
];
2090+
2091+
$third_party_items_strings = apply_filters(
2092+
'cptui_filtered_taxonomy_post_global_strings',
2093+
(array) [] // phpcs:ignore.
2094+
);
2095+
2096+
$items_strings = array_merge( $default_strings, $third_party_items_strings );
2097+
foreach ( $items_strings as $item ) {
2098+
$second_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_FULL_SPECIAL_CHARS );
20832099
if ( $second_result ) {
20842100
$filtered_data[ $item ] = $second_result;
20852101
}

inc/utility.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,14 +593,14 @@ function cptui_admin_notices_helper( $message = '', $success = true ) {
593593
*/
594594
function cptui_get_object_from_post_global() {
595595
if ( isset( $_POST['cpt_custom_post_type']['name'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
596-
$type_item = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
596+
$type_item = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
597597
if ( $type_item ) {
598598
return sanitize_text_field( $type_item['name'] );
599599
}
600600
}
601601

602602
if ( isset( $_POST['cpt_custom_tax']['name'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
603-
$tax_item = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
603+
$tax_item = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
604604
if ( $tax_item ) {
605605
return sanitize_text_field( $tax_item['name'] );
606606
}

readme.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
44
Tags: custom post types, CPT, CMS, post, types, post type, taxonomy, tax, custom, content types, post types
55
Requires at least: 5.9
66
Tested up to: 6.1.1
7-
Stable tag: 1.13.2
7+
Stable tag: 1.13.3
88
License: GPL-2.0+
99
Requires PHP: 5.6
1010

@@ -36,6 +36,11 @@ Custom Post Type UI development is managed on GitHub, with official releases pub
3636

3737
== Changelog ==
3838

39+
= 1.13.3 - 2022-12-15 =
40+
* Fixed: Multiple PHP8 compatibility notices and warnings.
41+
* Fixed: "Invalid argument for foreach" based notices around labels.
42+
* Updated: Added taxonomy PHP global sanitization for 3rd party parameters.
43+
3944
= 1.13.2 - 2022-11-29 =
4045
* Fixed: Removed forcing of underscores in place of dashes for taxonomy slugs. Yay!
4146
* Updated: tested up to WP 6.1.1
@@ -83,6 +88,11 @@ Custom Post Type UI development is managed on GitHub, with official releases pub
8388

8489
== Upgrade Notice ==
8590

91+
= 1.13.3 - 2022-12-15 =
92+
* Fixed: Multiple PHP8 compatibility notices and warnings.
93+
* Fixed: "Invalid argument for foreach" based notices around labels.
94+
* Updated: Added taxonomy PHP global sanitization for 3rd party parameters.
95+
8696
= 1.13.2 - 2022-11-29 =
8797
* Fixed: Removed forcing of underscores in place of dashes for taxonomy slugs. Yay!
8898
* Updated: tested up to WP 6.1.1

0 commit comments

Comments
 (0)