/** * Get Advance settings * * @param array $args The parameters array * @param string $content_type The content type */ static function view_get_advanced_settings(&$args, $content_type) { $view_settings = PT_CV_Functions::get_global_variable('view_settings'); $advanced_settings = (array) PT_CV_Functions::setting_value(PT_CV_PREFIX . 'advanced-settings', $view_settings); if ($advanced_settings) { foreach ($advanced_settings as $setting) { switch ($setting) { // Author case 'author': $author_in = PT_CV_Functions::string_to_array(PT_CV_Functions::setting_value(PT_CV_PREFIX . 'author__in', $view_settings)); // Check if using Wordpress version 3.7 or higher $version_gt_37 = PT_CV_Functions::wp_version_compare('3.7'); if ($version_gt_37) { $author_not_in = PT_CV_Functions::string_to_array(PT_CV_Functions::setting_value(PT_CV_PREFIX . 'author__not_in', $view_settings)); // Author in if (!empty($author_in[0])) { $args = array_merge($args, array('author__in' => array_map('intval', $author_in))); } // Author not in if (!empty($author_not_in[0])) { $args = array_merge($args, array('author__not_in' => array_map('intval', $author_not_in))); } } else { // Author = ID if (!empty($author_in[0])) { $args = array_merge($args, array('author' => intval($author_in[0]))); } } break; // Status // Status case 'status': $args = array_merge($args, array('post_status' => PT_CV_Functions::string_to_array(PT_CV_Functions::setting_value(PT_CV_PREFIX . 'post_status', $view_settings, 'publish')))); break; // Search // Search case 'search': if (PT_CV_Functions::setting_value(PT_CV_PREFIX . 's', $view_settings)) { $args = array_merge($args, array('s' => PT_CV_Functions::setting_value(PT_CV_PREFIX . 's', $view_settings))); } break; // Taxonomy // Taxonomy case 'taxonomy': // No taxonomy found if (!PT_CV_Functions::setting_value(PT_CV_PREFIX . 'taxonomy', $view_settings)) { break; } // All settings of taxonomies $taxonomy_setting = array(); // Selected taxonomies $taxonomies = PT_CV_Functions::setting_value(PT_CV_PREFIX . 'taxonomy', $view_settings); // Get Terms & criterias (In, Not in) foreach ($taxonomies as $taxonomy) { if (PT_CV_Functions::setting_value(PT_CV_PREFIX . $taxonomy . '-terms', $view_settings)) { // Get operator $operator = PT_CV_Functions::setting_value(PT_CV_PREFIX . $taxonomy . '-operator', $view_settings, 'IN'); $taxonomy_setting[] = array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => (array) PT_CV_Functions::setting_value(PT_CV_PREFIX . $taxonomy . '-terms', $view_settings), 'operator' => $operator, 'include_children' => apply_filters(PT_CV_PREFIX_ . 'include_children', true)); } } // Get Taxonomy relation if there are more than 1 selected taxonomies | set In & Not in of a taxonomy if (count($taxonomies) > 1 || count($taxonomy_setting) > 1) { $taxonomy_setting['relation'] = PT_CV_Functions::setting_value(PT_CV_PREFIX . 'taxonomy-relation', $view_settings, 'AND'); } // Filter taxonomy with Custom post types $taxonomy_setting_ = apply_filters(PT_CV_PREFIX_ . 'taxonomy_setting', $taxonomy_setting); $args = array_merge($args, array('tax_query' => $taxonomy_setting_)); break; // Order // Order case 'order': $order_settings = apply_filters(PT_CV_PREFIX_ . 'order_setting', array('orderby' => PT_CV_Functions::setting_value(PT_CV_PREFIX . 'orderby', $view_settings), 'order' => PT_CV_Functions::setting_value(PT_CV_PREFIX . 'order', $view_settings))); $args = array_merge($args, $order_settings); break; default: break; } } } }