/** * 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; } } } }
/** * Register and enqueue admin-specific JavaScript. * * @since 1.0.0 * * @return null Return early if no settings page is registered. */ public function enqueue_admin_scripts() { if (!isset($this->plugin_screen_hook_suffix)) { return; } $screen = get_current_screen(); if ($this->plugin_screen_hook_suffix == $screen->id || in_array($screen->id, $this->plugin_sub_screen_hook_suffix)) { // WP assets wp_enqueue_script('wp-color-picker'); wp_enqueue_script('jquery-ui-sortable'); // Main admin script PT_CV_Asset::enqueue('admin', 'script', array('src' => plugins_url('assets/js/admin.js', __FILE__), 'deps' => array('jquery'))); // Localize strings PT_CV_Asset::localize_script('admin', PT_CV_PREFIX_UPPER . 'ADMIN', array('_prefix' => PT_CV_PREFIX, '_group_prefix' => PT_CV_Html::html_group_class() . '-', '_nonce' => wp_create_nonce(PT_CV_PREFIX_ . 'ajax_nonce'), 'supported_version' => PT_CV_Functions::wp_version_compare('3.5'), 'text' => array('no_taxonomy' => __('There is no taxonomy for selected content type', 'content-views-query-and-display-post-page'), 'pagination_disable' => __('Pagination is disabled when Limit = -1', 'content-views-query-and-display-post-page'), 'prevent_click' => __('Opening a link is prevented in preview box', 'content-views-query-and-display-post-page')), 'btn' => array('preview' => array('show' => __('Show Preview', 'content-views-query-and-display-post-page'), 'hide' => __('Hide Preview', 'content-views-query-and-display-post-page'), 'update' => __('Update Preview', 'content-views-query-and-display-post-page'))), 'data' => array('post_types_vs_taxonomies' => PT_CV_Values::post_types_vs_taxonomies()))); // Bootstrap for Admin PT_CV_Asset::enqueue('bootstrap-admin', 'script', array('src' => plugins_url('assets/bootstrap/js/bootstrap.full.js', PT_CV_FILE))); // For Preview PT_CV_Html::frontend_scripts(); PT_CV_Asset::enqueue('select2'); } }
/** * Setting options for Field = Thumbnail */ static function field_thumbnail_settings($prefix) { $result = array(array('label' => array('text' => __('Thumbnail size', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'select', 'name' => $prefix . 'thumbnail-size', 'options' => PT_CV_Values::field_thumbnail_sizes(), 'std' => 'medium'))), !PT_CV_Functions::wp_version_compare('4.4') ? '' : array('label' => array('text' => ''), 'extra_setting' => array('params' => array('wrap-class' => 'checkbox-inline')), 'params' => array(array('type' => 'checkbox', 'name' => $prefix . 'thumbnail-nowprpi', 'options' => PT_CV_Values::yes_no('yes', __('Disable responsive image of WordPress 4.4', PT_CV_TEXTDOMAIN)), 'std' => '', 'desc' => __('Check this option if thumbnail looks blurry', PT_CV_TEXTDOMAIN))))); $result = apply_filters(PT_CV_PREFIX_ . 'field_thumbnail_settings', $result, $prefix); return $result; }
<?php /** * Add / Edit Content Views * * @package PT_Content_Views_Admin * @author PT Guy <*****@*****.**> * @license GPL-2.0+ * @link http://www.contentviewspro.com/ * @copyright 2014 PT Guy */ // Check if using Wordpress version 3.7 or higher $version_gt_37 = PT_CV_Functions::wp_version_compare('3.7'); $settings = array(); // Id of current view $id = 0; // Check if this is edit View page if (!empty($_GET['id'])) { $id = esc_sql($_GET['id']); if ($id) { // Get View settings global $pt_cv_admin_settings; $pt_cv_admin_settings = $settings = PT_CV_Functions::view_get_settings($id); } } // Submit handle PT_CV_Functions::view_submit(); ?> <div class="wrap form-horizontal pt-wrap"> <?php
/** * Setting options for Field = Thumbnail */ static function field_thumbnail_settings($prefix) { $result = array(array('label' => array('text' => __('Size')), 'params' => array(array('type' => 'select', 'name' => $prefix . 'thumbnail-size', 'options' => PT_CV_Values::field_thumbnail_sizes(), 'std' => 'medium'))), !PT_CV_Functions::wp_version_compare('4.4') ? '' : 'disable-wp44-resimg' => array('label' => array('text' => ''), 'extra_setting' => array('params' => array('wrap-class' => 'checkbox-inline')), 'params' => array(array('type' => 'checkbox', 'name' => $prefix . 'thumbnail-nowprpi', 'options' => PT_CV_Values::yes_no('yes', __('Disable responsive image of WordPress 4.4', 'content-views-query-and-display-post-page')), 'std' => '', 'desc' => __('Check this option if thumbnail looks blurry', 'content-views-query-and-display-post-page')))), !get_option('pt_cv_version_pro') ? PT_CV_Settings::get_cvpro(sprintf(__('In this lite version, thumbnail is only shown if post has %s', 'content-views-query-and-display-post-page'), sprintf('<a target="_blank" href="https://codex.wordpress.org/Post_Thumbnails">%s</a>', __('Featured Image'))), 10, null, true) : ''); $result = apply_filters(PT_CV_PREFIX_ . 'field_thumbnail_settings', $result, $prefix); return $result; }