Astra_Target_Rules_Fields::get_location_selections( bool $consider_type = false )
Get location selection options.
Description
Parameters
- $consider_type
-
(bool) (Optional) Consider type for dealing with ruleset options.
Default value: false
Return
(array)
Source
File: classes/modules/target-rule/class-astra-target-rules-fields.php
public static function get_location_selections() { $args = array( 'public' => true, '_builtin' => true, ); $post_types = get_post_types( $args, 'objects' ); unset( $post_types['attachment'] ); $args['_builtin'] = false; $custom_post_type = get_post_types( $args, 'objects' ); $post_types = apply_filters( 'astra_location_rule_post_types', array_merge( $post_types, $custom_post_type ) ); $special_pages = array( 'special-404' => __( '404 Page', 'astra-addon' ), 'special-search' => __( 'Search Page', 'astra-addon' ), 'special-blog' => __( 'Blog / Posts Page', 'astra-addon' ), 'special-front' => __( 'Front Page', 'astra-addon' ), 'special-date' => __( 'Date Archive', 'astra-addon' ), 'special-author' => __( 'Author Archive', 'astra-addon' ), ); if ( class_exists( 'WooCommerce' ) ) { $special_pages['special-woo-shop'] = __( 'WooCommerce Shop Page', 'astra-addon' ); } $selection_options = array( 'basic' => array( 'label' => __( 'Basic', 'astra-addon' ), 'value' => array( 'basic-global' => __( 'Entire Website', 'astra-addon' ), 'basic-singulars' => __( 'All Singulars', 'astra-addon' ), 'basic-archives' => __( 'All Archives', 'astra-addon' ), ), ), 'special-pages' => array( 'label' => __( 'Special Pages', 'astra-addon' ), 'value' => $special_pages, ), ); $args = array( 'public' => true, ); $taxonomies = get_taxonomies( $args, 'objects' ); if ( ! empty( $taxonomies ) ) { foreach ( $taxonomies as $taxonomy ) { // skip post format taxonomy. if ( 'post_format' == $taxonomy->name ) { continue; } foreach ( $post_types as $post_type ) { $post_opt = self::get_post_target_rule_options( $post_type, $taxonomy ); if ( isset( $selection_options[ $post_opt['post_key'] ] ) ) { if ( ! empty( $post_opt['value'] ) && is_array( $post_opt['value'] ) ) { foreach ( $post_opt['value'] as $key => $value ) { if ( ! in_array( $value, $selection_options[ $post_opt['post_key'] ]['value'] ) ) { $selection_options[ $post_opt['post_key'] ]['value'][ $key ] = $value; } } } } else { $selection_options[ $post_opt['post_key'] ] = array( 'label' => $post_opt['label'], 'value' => $post_opt['value'], ); } } } } $selection_options['specific-target'] = array( 'label' => __( 'Specific Target', 'astra-addon' ), 'value' => array( 'specifics' => __( 'Specific Pages / Posts / Taxonomies, etc.', 'astra-addon' ), ), ); /** * Filter options displayed in the display conditions select field of Display conditions. * * @since 1.5.0 */ return apply_filters( 'astra_display_on_list', $selection_options ); }
Expand full source code Collapse full source code View on Trac