Permalink
Browse files

Made regexes much more specific so that underscored pod names won't m…

…ess it up
  • Loading branch information...
1 parent 6474dd5 commit cfa28cc7357ebb23d63f19e9f60ff77f77538871 @mikedamage mikedamage committed Aug 1, 2012
Showing with 8 additions and 8 deletions.
  1. +8 −8 classes/PodsAPI.php
View
@@ -879,7 +879,7 @@ public function save_pod ( $params ) {
foreach ( $pod[ 'options' ] as $key => $val ) {
if ( 0 === strpos( $key, 'built_in_post', 0 ) ) {
// KLUDGE: ugly regex munge. fix if able.
- preg_match( '/_([^_]+)$/', $key, $key_matches );
+ preg_match( '/built_in_post_types_(.+)$/', $key, $key_matches );
$post_type_name = $key_matches[1];
$tax_name = $pod[ 'name' ];
$search_val = 1 ^ $val;
@@ -893,9 +893,9 @@ public function save_pod ( $params ) {
$results = pods_query($query);
if ( 0 < count( $results ) ) {
- $post_type_id = $results[0]->ID;
- delete_post_meta($post_type_id, "built_in_taxonomies_{$tax_name}");
- add_post_meta($post_type_id, "built_in_taxonomies_{$tax_name}", (int) $val);
+ $post_type_id = $results[ 0 ]->ID;
+ delete_post_meta( $post_type_id, "built_in_taxonomies_{$tax_name}" );
+ add_post_meta( $post_type_id, "built_in_taxonomies_{$tax_name}", (int) $val );
}
}
}
@@ -904,7 +904,7 @@ public function save_pod ( $params ) {
foreach ( $pod[ 'options' ] as $key => $val ) {
if ( 0 === strpos( $key, 'built_in_taxonomies', 0 ) ) {
// KLUDGE: same thing
- preg_match( '/_([^_]+)$/', $key, $key_matches );
+ preg_match( '/built_in_taxonomies_(.+)$/', $key, $key_matches );
$tax_name = $key_matches[1];
$post_type_name = $pod[ 'name' ];
$search_val = 1 ^ $val;
@@ -918,9 +918,9 @@ public function save_pod ( $params ) {
$results = pods_query($query);
if ( 0 < count( $results ) ) {
- $tax_id = $results[0]->ID;
- delete_post_meta($tax_id, "built_in_post_types_{$post_type_name}");
- add_post_meta($tax_id, "built_in_post_types_{$post_type_name}", (int) $val);
+ $tax_id = $results[ 0 ]->ID;
+ delete_post_meta( $tax_id, "built_in_post_types_{$post_type_name}" );
+ add_post_meta( $tax_id, "built_in_post_types_{$post_type_name}", (int) $val );
}
}
}

0 comments on commit cfa28cc

Please sign in to comment.