Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
PUM_Admin_Upgrade_Routine_4::parse_conditions( array $targeting_conditions = array() )
Converts old condition keys into new condition arrays.
Description Description
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Parameters Parameters
- $targeting_conditions
-
(Optional)
Default value: array()
Return Return
(array)
Source Source
File: includes/admin/upgrades/class-pum-admin-upgrade-routine-4.php
public static function parse_conditions( $targeting_conditions = array() ) { $conditions = array(); $targeting_conditions = array_keys( $targeting_conditions ); foreach ( $targeting_conditions as $index => $key ) { $condition = null; // Front Page if ( strpos( $key, 'on_home' ) !== false ) { $condition = array( 'target' => 'is_front_page', ); } // Blog Index elseif ( strpos( $key, 'on_blog' ) !== false ) { $condition = array( 'target' => 'is_home', ); } // Search Pages elseif ( strpos( $key, 'on_search' ) !== false ) { $condition = array( 'target' => 'is_search', ); } // 404 Pages elseif ( strpos( $key, 'on_404' ) !== false ) { $condition = array( 'target' => 'is_404', ); } // WooCommerce Pages elseif ( strpos( $key, 'on_woocommerce' ) !== false ) { $condition = array( 'target' => 'is_woocommerce', ); } // WooCommerce Shop Pages elseif ( strpos( $key, 'on_shop' ) !== false ) { $condition = array( 'target' => 'is_shop', ); } if ( $condition ) { unset( $targeting_conditions[ $index ] ); $conditions[] = $condition; } } foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $name => $post_type ) { $pt_conditions = PUM_Admin_Upgrade_Routine_4::filter_conditions( $targeting_conditions, '_' . $name ); if ( empty( $pt_conditions ) ) { continue; } if ( in_array( "on_{$name}s", $pt_conditions ) && ! in_array( "on_specific_{$name}s", $pt_conditions ) ) { $conditions[] = array( 'target' => $name . '_all', ); continue; } // Remove non ID keys unset( $pt_conditions["on_{$name}s"] ); unset( $pt_conditions["on_specific_{$name}s"] ); $ids = array(); // Convert the rest of the keys to post IDs. foreach ( $pt_conditions as $key ) { $id = intval( preg_replace( '/[^0-9]+/', '', $key ), 10 ); if ( $id > 0 ) { $ids[] = $id; } } // Create a new post_type_selected condition with the ids. $conditions[] = array( 'target' => $name . '_selected', 'selected' => $ids, ); } foreach ( get_taxonomies( array( 'public' => true ), 'objects' ) as $tax_name => $taxonomy ) { $tax_conditions = PUM_Admin_Upgrade_Routine_4::filter_conditions( $targeting_conditions, '_' . $tax_name ); if ( empty( $tax_conditions ) ) { continue; } if ( in_array( "on_{$tax_name}s", $tax_conditions ) && ! in_array( "on_specific_{$tax_name}s", $tax_conditions ) ) { $conditions[] = array( 'target' => 'tax_' . $tax_name . '_all', ); continue; } // Remove non ID keys unset( $tax_conditions["on_{$tax_name}s"] ); unset( $tax_conditions["on_specific_{$tax_name}s"] ); $ids = array(); // Convert the rest of the keys to post IDs. foreach ( $tax_conditions as $key ) { $id = intval( preg_replace( '/[^0-9]+/', '', $key ), 10 ); if ( $id > 0 ) { $ids[] = $id; } } // Create a new post_type_selected condition with the ids. $conditions[] = array( 'target' => 'tax_' . $tax_name . '_selected', 'selected' => $ids, ); } return $conditions; }
Expand full source code Collapse full source code View on Trac