/**
  * Process data when submit form add/edit view
  *
  * @return void
  */
 static function view_submit()
 {
     if (empty($_POST)) {
         return;
     }
     PT_CV_Functions::_nonce_check('form_nonce', 'view_submit');
     /**
      * INSERT VIEW
      */
     // View title
     $title = esc_sql($_POST[PT_CV_PREFIX . 'view-title']);
     // Current post id ( 0 if new view )
     $cur_post_id = esc_sql($_POST[PT_CV_PREFIX . 'post-id']);
     // Insert post
     if (!$cur_post_id) {
         $post_id = PT_CV_Functions::post_insert(array('ID' => $cur_post_id, 'title' => $title));
     } else {
         $post_id = $cur_post_id;
     }
     /**
      * ADD/UPDATE CUSTOM FIELDS
      */
     // Get current view id, = 0 if it is new view
     $cur_view_id = esc_sql($_POST[PT_CV_PREFIX . 'view-id']);
     $view_id = empty($cur_view_id) ? PT_CV_Functions::string_random() : $cur_view_id;
     update_post_meta($post_id, PT_CV_META_ID, $view_id);
     update_post_meta($post_id, PT_CV_META_SETTINGS, (array) $_POST);
     // Update post title
     if (strpos($title, '[ID:') === false) {
         PT_CV_Functions::post_insert(array('ID' => $post_id, 'title' => sprintf('%s [ID: %s]', $title, $view_id)));
     }
     /**
      * redirect to edit page
      */
     $edit_link = PT_CV_Functions::view_link($view_id);
     wp_redirect($edit_link);
     exit;
 }
 /**
  * Print HTML code of field type: input, select, textarea...
  *
  * @param array $param Array of parameters of a setting option
  * @param array $data  Array of stored data
  *
  * @return string
  */
 public static function field_type($param, $data, $value_ = NULL)
 {
     if (!$param || !isset($param['type'])) {
         return '';
     }
     $html = $extend = '';
     $class = 'form-control ' . (isset($param['class']) ? ' ' . PT_CV_PREFIX . $param['class'] : '');
     $type = esc_attr($param['type']);
     $name = !empty($param['name']) ? PT_CV_PREFIX . esc_attr($param['name']) : '';
     $id = !empty($param['id']) ? "id='" . PT_CV_PREFIX . esc_attr($param['id']) . "'" : '';
     $value = isset($value_) ? $value_ : self::field_value($data, $param, $name);
     $description = isset($param['desc']) ? balanceTags($param['desc']) : '';
     // Add extra information of option type
     switch ($type) {
         case 'number':
             $min = !empty($param['min']) ? intval($param['min']) : 0;
             $extend = 'min="' . $min . '"';
             break;
         case 'color':
             $class .= ' ' . PT_CV_PREFIX . 'color';
             break;
         case 'checkbox':
         case 'radio':
             // Remove form-control class in checkbox, radio
             $class = str_replace('form-control', '', $class);
             break;
     }
     $class = esc_attr($class);
     // Show HTML of option type
     switch ($type) {
         case 'group':
             $html .= self::do_settings($param['params'], $data);
             break;
         case 'text':
         case 'email':
         case 'password':
         case 'number':
         case 'url':
             $placeholder = !empty($param['placeholder']) ? $param['placeholder'] : '';
             $append_text = !empty($param['append_text']) ? $param['append_text'] : '';
             $input = "<input type='{$type}' name='{$name}' value='{$value}' class='{$class}' {$id} {$extend} placeholder='{$placeholder}'>";
             if (empty($append_text)) {
                 $html .= $input;
             } else {
                 $html .= "<div class='input-group'>{$input}<span class='input-group-addon'>{$append_text}</span></div>";
             }
             break;
         case 'color':
             $html .= "<input type='text' name='{$name}' value='{$value}' class='{$class}' {$id} {$extend} style='background-color:{$value};'>";
             $html .= "<div class='" . PT_CV_PREFIX . "colorpicker' style='z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;'></div><br>";
             break;
         case 'textarea':
             $html .= "<textarea name='{$name}' class='{$class}' {$id} {$extend}>{$value}</textarea>";
             break;
         case 'checkbox':
         case 'radio':
             if (!isset($param['options'])) {
                 break;
             }
             $settings = isset($param['settings']) ? $param['settings'] : array();
             foreach ($param['options'] as $key => $text) {
                 // Append Html to $text, such as image...
                 if ($settings) {
                     $append = isset($settings['text-append']) ? $settings['text-append'] : '';
                     if ($append == 'image') {
                         $path = isset($settings['path']) ? $settings['path'] : '';
                         if ($path) {
                             $text .= "<br> <img src='" . plugins_url($path . "/{$key}.png", PT_CV_FILE) . "' />";
                         }
                     }
                 }
                 $checked = in_array($key, (array) $value) || $value == 'all' ? 'checked' : '';
                 $html .= "<div class='{$type}'><label><input type='{$type}' name='{$name}' value='{$key}' class='{$class}' {$checked} {$id} {$extend}>{$text}</label></div>";
             }
             break;
         case 'select':
             if (!isset($param['options'])) {
                 break;
             }
             $options = '';
             foreach ($param['options'] as $key => $text) {
                 $selected = in_array($key, (array) $value) || $value == 'all' ? 'selected' : '';
                 $option_class = isset($param['option_class_prefix']) ? sprintf("class='%s'", $param['option_class_prefix'] . esc_attr(sanitize_title($key))) : '';
                 $options .= "<option value='{$key}' {$selected} {$option_class}>{$text}</option>";
             }
             if (empty($options)) {
                 $html .= "<div class='" . PT_CV_PREFIX . "text'>" . __('There is no option', PT_CV_DOMAIN) . '</div>';
             } else {
                 $multiple = '';
                 if (isset($param['multiple']) && $param['multiple'] == '1' || $value == 'all') {
                     $multiple = 'multiple';
                     // Auto add [] to name of select
                     $name .= substr($name, -2) == '[]' ? '' : '[]';
                 }
                 $html .= "<select name='{$name}' class='{$class}' {$multiple} {$id} {$extend}>{$options}</select>";
             }
             break;
         case 'color_picker':
             $html .= self::field_type($param['options'], $data);
             break;
         case 'html':
             if (isset($param['content'])) {
                 $html .= $param['content'];
             }
             break;
         case 'panel_group':
             // In format: key => array of params
             $parent_id = PT_CV_Functions::string_random(true);
             $settings = isset($param['settings']) ? $param['settings'] : array();
             foreach ($param['params'] as $key => $param_group) {
                 $html .= self::sub_panel_group($key, $param_group, $data, $parent_id, $settings);
             }
             break;
         default:
             break;
     }
     $description = apply_filters(PT_CV_PREFIX_ . 'options_description', $description, $param);
     if (!empty($description)) {
         $html .= "<p class='text-muted'>{$description}</p>";
     }
     return $html;
 }
Example #3
0
				</a>
			</li>
			<?php 
do_action(PT_CV_PREFIX_ . 'setting_tabs_header', $settings);
?>
		</ul>

		<!-- Tab panes -->
		<div class="tab-content">
			<!-- Filter Settings -->
			<div class="tab-pane active" id="<?php 
echo esc_attr(PT_CV_PREFIX);
?>
filter-settings">
				<?php 
$options = array(array('label' => array('text' => __('Content type', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'radio', 'name' => 'content-type', 'options' => PT_CV_Values::post_types(), 'std' => 'post'))), !get_option('pt_cv_version_pro') ? PT_CV_Settings::get_cvpro(__('Filter custom post type (product, event...) ?', PT_CV_TEXTDOMAIN), 10) : '', apply_filters(PT_CV_PREFIX_ . 'custom_filters', array()), array('label' => array('text' => __('Common filters', PT_CV_TEXTDOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => array(apply_filters(PT_CV_PREFIX_ . 'sticky_posts_setting', array()), array('label' => array('text' => __('Include only', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'text', 'name' => 'post__in', 'std' => '', 'desc' => apply_filters(PT_CV_PREFIX_ . 'setting_post_in', __('List of post IDs to display (comma-separated values, e.g. 1,2,3)', PT_CV_TEXTDOMAIN))))), apply_filters(PT_CV_PREFIX_ . 'include_extra_settings', array()), array('label' => array('text' => __('Exclude', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'text', 'name' => 'post__not_in', 'std' => '', 'desc' => apply_filters(PT_CV_PREFIX_ . 'setting_post_not_in', __('List of post IDs to exclude (comma-separated values, e.g. 1,2,3)', PT_CV_TEXTDOMAIN))))), apply_filters(PT_CV_PREFIX_ . 'exclude_extra_settings', array()), array('label' => array('text' => __('Parent page', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'number', 'name' => 'post_parent', 'std' => '', 'desc' => __('Enter ID of parent page to query child pages', PT_CV_TEXTDOMAIN))), 'dependence' => array('content-type', 'page')), apply_filters(PT_CV_PREFIX_ . 'post_parent_settings', array()), array('label' => array('text' => __('Limit', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'number', 'name' => 'limit', 'std' => '10', 'min' => '1', 'desc' => __('The number of posts to show. Set empty to show all found posts (which match all filter settings)', PT_CV_TEXTDOMAIN)))), apply_filters(PT_CV_PREFIX_ . 'after_limit_option', PT_CV_Settings::get_cvpro(__('Skip some posts ?', PT_CV_TEXTDOMAIN), 12)))))), array('label' => array('text' => __('Advanced filters', PT_CV_TEXTDOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class(), 'wrap-id' => PT_CV_Html::html_group_id('advanced-params'))), 'params' => array(array('type' => 'group', 'params' => array(array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'checkbox', 'name' => 'advanced-settings[]', 'options' => PT_CV_Values::advanced_settings(), 'std' => '', 'class' => 'advanced-settings-item'))))))), array('label' => array('text' => ''), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_panel_group_class(), 'wrap-id' => PT_CV_Html::html_panel_group_id(PT_CV_Functions::string_random()))), 'params' => array(array('type' => 'panel_group', 'params' => apply_filters(PT_CV_PREFIX_ . 'advanced_settings_panel', array('taxonomy' => array(array('label' => array('text' => __('Taxonomies', PT_CV_TEXTDOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_PREFIX . 'taxonomies')), 'params' => array(array('type' => 'checkbox', 'name' => 'taxonomy[]', 'options' => PT_CV_Values::taxonomy_list(), 'std' => '', 'class' => 'taxonomy-item', 'desc' => __('Tick checkbox of taxonomies to filter posts by their terms', PT_CV_TEXTDOMAIN)))), !get_option('pt_cv_version_pro') ? PT_CV_Settings::get_cvpro(__('Filter by custom taxonomies ?', PT_CV_TEXTDOMAIN), 10) : '', array('label' => array('text' => __('Terms', PT_CV_TEXTDOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_panel_group_class() . ' terms', 'wrap-id' => PT_CV_Html::html_panel_group_id(PT_CV_Functions::string_random()))), 'params' => array(array('type' => 'panel_group', 'settings' => array('nice_name' => PT_CV_Values::taxonomy_list()), 'params' => PT_CV_Settings::terms_of_taxonomies()))), array('label' => array('text' => __('Relation', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'select', 'name' => 'taxonomy-relation', 'options' => PT_CV_Values::taxonomy_relation(), 'std' => PT_CV_Functions::array_get_first_key(PT_CV_Values::taxonomy_relation()), 'class' => 'taxonomy-relation', 'desc' => __('Select AND to show posts which match ALL settings of selected taxonomies.<br>Select OR to show posts which match settings of at least one selected taxonomy', PT_CV_TEXTDOMAIN)))), apply_filters(PT_CV_PREFIX_ . 'taxonomies_custom_settings', array())), 'order' => array(array('label' => array('text' => __('Order by', PT_CV_TEXTDOMAIN)), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'panel_group', 'settings' => array('show_all' => 1), 'params' => PT_CV_Settings::orderby())))), 'author' => apply_filters(PT_CV_PREFIX_ . 'author_settings', array(array('label' => array('text' => __('Written by', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'select', 'name' => 'author__in[]', 'options' => PT_CV_Values::user_list(), 'std' => '', 'class' => 'select2', 'multiple' => $version_gt_37 ? '1' : '0'))), $version_gt_37 ? array('label' => array('text' => __('Not written by', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'select', 'name' => 'author__not_in[]', 'options' => PT_CV_Values::user_list(), 'std' => '', 'class' => 'select2', 'multiple' => $version_gt_37 ? '1' : '0'))) : array())), 'status' => array(array('label' => array('text' => __('Status', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'select', 'name' => 'post_status', 'options' => PT_CV_Values::post_statuses(), 'std' => 'publish', 'class' => 'select2', 'multiple' => '1', 'desc' => __('Select status of posts', PT_CV_TEXTDOMAIN))))), 'search' => array(array('label' => array('text' => __('Keyword', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'text', 'name' => 's', 'std' => '', 'desc' => __('Enter the keyword to searching for posts.', PT_CV_TEXTDOMAIN) . apply_filters(PT_CV_PREFIX_ . 'searchby_keyword_desc', '')))))))))));
echo PT_Options_Framework::do_settings($options, $settings);
?>
			</div>
			<!-- end Filter Settings -->

			<!-- Display Settings -->
			<div class="tab-pane" id="<?php 
echo esc_attr(PT_CV_PREFIX);
?>
display-settings">
				<?php 
$options = array(array('label' => array('text' => __('View type (Layout)', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'radio', 'name' => 'view-type', 'options' => PT_CV_Values::view_type(), 'std' => PT_CV_Functions::array_get_first_key(PT_CV_Values::view_type())))), array('label' => array('text' => __('View type settings', PT_CV_TEXTDOMAIN)), 'params' => array(array('type' => 'panel_group', 'settings' => array('no_panel' => 1, 'show_only_one' => 1), 'params' => PT_CV_Values::view_type_settings()))), apply_filters(PT_CV_PREFIX_ . 'responsive_settings', array()), array('label' => array('text' => __('Layout format', PT_CV_TEXTDOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => array(array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'radio', 'name' => 'layout-format', 'options' => PT_CV_Values::layout_format(), 'std' => PT_CV_Functions::array_get_first_key(PT_CV_Values::layout_format()), 'desc' => __('This is layout format of output for each post', PT_CV_TEXTDOMAIN)))), array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'checkbox', 'name' => 'lf-mobile-disable', 'options' => PT_CV_Values::yes_no('yes', __('Disable 2 columns format on mobile devices & extra small screens', PT_CV_TEXTDOMAIN)), 'std' => '')), 'dependence' => array('layout-format', '2-col')))))), array('label' => array('text' => __('Fields settings', PT_CV_TEXTDOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class(), 'wrap-id' => PT_CV_Html::html_group_id('field-settings'))), 'params' => array(array('type' => 'group', 'params' => PT_CV_Settings::field_settings()))), array('label' => array('text' => __('Pagination settings', PT_CV_TEXTDOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => PT_CV_Settings::settings_pagination()))), array('label' => array('text' => __('Other settings', PT_CV_TEXTDOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => PT_CV_Settings::settings_other()))));
$options = apply_filters(PT_CV_PREFIX_ . 'display_settings', $options);
echo PT_Options_Framework::do_settings($options, $settings);
?>
        /**
         * Print inline css code
         *
         * @param string $css The css code
         *
         * @return string
         */
        static function inline_style($css, $prefix = 'inline')
        {
            // Generate random id for style tag
            $random_id = PT_CV_Functions::string_random();
            ob_start();
            ?>
			<style type="text/css" id="<?php 
            echo esc_attr(PT_CV_PREFIX . $prefix . '-style-' . $random_id);
            ?>
"><?php 
            echo '' . $css;
            ?>
</style>
			<?php 
            return ob_get_clean();
        }
Example #5
0
				</a>
			</li>
			<?php 
do_action(PT_CV_PREFIX_ . 'setting_tabs_header', $settings);
?>
		</ul>

		<!-- Tab panes -->
		<div class="tab-content">
			<!-- Filter Settings -->
			<div class="tab-pane active" id="<?php 
echo esc_attr(PT_CV_PREFIX);
?>
filter-settings">
				<?php 
$options = array(array('label' => array('text' => __('Content type', 'content-views-query-and-display-post-page')), 'params' => array(apply_filters(PT_CV_PREFIX_ . 'contenttype_setting', array('type' => 'radio', 'name' => 'content-type', 'options' => PT_CV_Values::post_types(), 'std' => 'post')))), !get_option('pt_cv_version_pro') ? PT_CV_Settings::get_cvpro(__('Filter custom post type (product, event...)', 'content-views-query-and-display-post-page')) : '', apply_filters(PT_CV_PREFIX_ . 'custom_filters', array()), array('label' => array('text' => __('Common filters', 'content-views-query-and-display-post-page')), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => array(apply_filters(PT_CV_PREFIX_ . 'sticky_posts_setting', array()), array('label' => array('text' => __('Include only', 'content-views-query-and-display-post-page')), 'params' => array(array('type' => 'text', 'name' => 'post__in', 'std' => '', 'desc' => apply_filters(PT_CV_PREFIX_ . 'setting_post_in', __('List of post IDs to show (comma-separated values, for example: 1,2,3)', 'content-views-query-and-display-post-page'))))), apply_filters(PT_CV_PREFIX_ . 'include_extra_settings', array()), array('label' => array('text' => __('Exclude', 'content-views-query-and-display-post-page')), 'params' => array(array('type' => 'text', 'name' => 'post__not_in', 'std' => '', 'desc' => apply_filters(PT_CV_PREFIX_ . 'setting_post_not_in', __('List of post IDs to exclude (comma-separated values, for example: 1,2,3)', 'content-views-query-and-display-post-page')))), 'dependence' => array('post__in', '')), apply_filters(PT_CV_PREFIX_ . 'exclude_extra_settings', array()), array('label' => array('text' => __('Parent page', 'content-views-query-and-display-post-page')), 'params' => array(array('type' => 'number', 'name' => 'post_parent', 'std' => '', 'desc' => apply_filters(PT_CV_PREFIX_ . 'setting_parent_page', __('Enter ID of parent page to show its children', 'content-views-query-and-display-post-page')))), 'dependence' => array('content-type', 'page')), apply_filters(PT_CV_PREFIX_ . 'post_parent_settings', array()), array('label' => array('text' => __('Limit', 'content-views-query-and-display-post-page')), 'params' => array(array('type' => 'number', 'name' => 'limit', 'std' => '10', 'min' => '1', 'desc' => __('The number of posts to show. Set empty to show all found posts', 'content-views-query-and-display-post-page')))), apply_filters(PT_CV_PREFIX_ . 'after_limit_option', PT_CV_Settings::get_cvpro(__('Skip some posts', 'content-views-query-and-display-post-page'), 12)))))), array('label' => array('text' => __('Advanced filters', 'content-views-query-and-display-post-page')), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class(), 'wrap-id' => PT_CV_Html::html_group_id('advanced-params'))), 'params' => array(array('type' => 'group', 'params' => array(array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'checkbox', 'name' => 'advanced-settings[]', 'options' => PT_CV_Values::advanced_settings(), 'std' => '', 'class' => 'advanced-settings-item'))))))), array('label' => array('text' => ''), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_panel_group_class(), 'wrap-id' => PT_CV_Html::html_panel_group_id(PT_CV_Functions::string_random()))), 'params' => array(array('type' => 'panel_group', 'params' => apply_filters(PT_CV_PREFIX_ . 'advanced_settings_panel', array('taxonomy' => array('parent_label' => sprintf(__('Filter by %s', 'content-views-query-and-display-post-page'), __('Taxonomy', 'content-views-query-and-display-post-page')), array('label' => array('text' => __('Select taxonomy', 'content-views-query-and-display-post-page')), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_PREFIX . 'taxonomies')), 'params' => array(array('type' => 'checkbox', 'name' => 'taxonomy[]', 'options' => PT_CV_Values::taxonomy_list(), 'std' => '', 'class' => 'taxonomy-item'))), !get_option('pt_cv_version_pro') ? PT_CV_Settings::get_cvpro(__('Filter by custom taxonomies', 'content-views-query-and-display-post-page')) : '', array('label' => array('text' => ''), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_panel_group_class() . ' terms', 'wrap-id' => PT_CV_Html::html_panel_group_id(PT_CV_Functions::string_random()))), 'params' => array(array('type' => 'panel_group', 'settings' => array('nice_name' => PT_CV_Values::taxonomy_list()), 'params' => PT_CV_Settings::terms_of_taxonomies()))), array('label' => array('text' => __('Relation', 'content-views-query-and-display-post-page')), 'params' => array(array('type' => 'select', 'name' => 'taxonomy-relation', 'options' => PT_CV_Values::taxonomy_relation(), 'std' => PT_CV_Functions::array_get_first_key(PT_CV_Values::taxonomy_relation()), 'class' => 'taxonomy-relation'))), !get_option('pt_cv_version_pro') ? PT_CV_Settings::get_cvpro(sprintf('<br>' . __('When you select any term above, it will not replace posts layout in term page (for example: %s) with layout of this View', 'content-views-query-and-display-post-page'), '<code style="font-size: 11px;">http://yourdomain/category/selected_term/</code>'), 10, null, true) : '', apply_filters(PT_CV_PREFIX_ . 'taxonomies_custom_settings', array())), 'order' => array('parent_label' => __('Sort by', 'content-views-query-and-display-post-page'), array('label' => array('text' => __('Sort by', 'content-views-query-and-display-post-page')), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'panel_group', 'settings' => array('show_all' => 1), 'params' => PT_CV_Settings::orderby())))), 'author' => apply_filters(PT_CV_PREFIX_ . 'author_settings', array('parent_label' => sprintf(__('Filter by %s', 'content-views-query-and-display-post-page'), __('Author')), array('label' => array('text' => __('By author', 'content-views-query-and-display-post-page')), 'params' => array(array('type' => 'select', 'name' => 'author__in[]', 'options' => PT_CV_Values::user_list(), 'std' => '', 'class' => 'select2', 'multiple' => $version_gt_37 ? '1' : '0'))), $version_gt_37 ? array('label' => array('text' => __('Not by author', 'content-views-query-and-display-post-page')), 'params' => array(array('type' => 'select', 'name' => 'author__not_in[]', 'options' => PT_CV_Values::user_list(), 'std' => '', 'class' => 'select2', 'multiple' => $version_gt_37 ? '1' : '0'))) : array())), 'status' => array('parent_label' => sprintf(__('Filter by %s', 'content-views-query-and-display-post-page'), __('Status')), array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'select', 'name' => 'post_status', 'options' => PT_CV_Values::post_statuses(), 'std' => 'publish', 'class' => 'select2', 'multiple' => '1', 'desc' => __('Select post status', 'content-views-query-and-display-post-page'))))), 'search' => array('parent_label' => sprintf(__('Filter by %s', 'content-views-query-and-display-post-page'), __('Keyword')), array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'text', 'name' => 's', 'std' => '', 'desc' => __('Enter keyword to searching for posts', 'content-views-query-and-display-post-page') . apply_filters(PT_CV_PREFIX_ . 'searchby_keyword_desc', '')))))))))));
echo PT_Options_Framework::do_settings($options, $settings);
?>
			</div>
			<!-- end Filter Settings -->

			<!-- Display Settings -->
			<div class="tab-pane" id="<?php 
echo esc_attr(PT_CV_PREFIX);
?>
display-settings">
				<?php 
$options = array(array('label' => array('text' => __('View type (Layout)', 'content-views-query-and-display-post-page')), 'params' => array(apply_filters(PT_CV_PREFIX_ . 'viewtype_setting', array('type' => 'radio', 'name' => 'view-type', 'options' => PT_CV_Values::view_type(), 'std' => PT_CV_Functions::array_get_first_key(PT_CV_Values::view_type()))))), array('label' => array('text' => ''), 'params' => array(array('type' => 'panel_group', 'settings' => array('no_panel' => 1, 'show_only_one' => 1), 'params' => PT_CV_Values::view_type_settings()))), apply_filters(PT_CV_PREFIX_ . 'responsive_settings', array()), array('label' => array('text' => __('Layout format', 'content-views-query-and-display-post-page')), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => array(array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'radio', 'name' => 'layout-format', 'options' => PT_CV_Values::layout_format(), 'std' => PT_CV_Functions::array_get_first_key(PT_CV_Values::layout_format())))), array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'checkbox', 'name' => 'lf-mobile-disable', 'options' => PT_CV_Values::yes_no('yes', __('Disable this format on mobile devices & extra small screens', 'content-views-query-and-display-post-page')), 'std' => '')), 'dependence' => array('layout-format', '2-col')))))), array('label' => array('text' => __('Fields settings', 'content-views-query-and-display-post-page')), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class(), 'wrap-id' => PT_CV_Html::html_group_id('field-settings'))), 'params' => array(array('type' => 'group', 'params' => PT_CV_Settings::field_settings()))), array('label' => array('text' => __('Pagination', 'content-views-query-and-display-post-page')), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => PT_CV_Settings::settings_pagination()))), array('label' => array('text' => __('Others', 'content-views-query-and-display-post-page')), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => PT_CV_Settings::settings_other()))));
$options = apply_filters(PT_CV_PREFIX_ . 'display_settings', $options);
echo PT_Options_Framework::do_settings($options, $settings);
?>
Example #6
0
 /**
  * Check duplicated View
  * @return bool
  */
 static function duplicate_process($view_id, $settings)
 {
     if (!defined('PT_CV_DOING_PAGINATION') && apply_filters(PT_CV_PREFIX_ . 'check_duplicate', 0, $view_id, $settings)) {
         global $pt_cv_glb, $pt_cv_views;
         // Generate unnique ID for current shortcode
         $sc_params = isset($pt_cv_glb[$view_id]['shortcode_params']) ? $pt_cv_glb[$view_id]['shortcode_params'] : PT_CV_Functions::string_random();
         $vid = $view_id . '-' . md5(serialize($sc_params));
         if (!empty($pt_cv_views[$vid])) {
             return true;
         } else {
             $pt_cv_views[$vid] = 1;
         }
     }
     return false;
 }
				</a>
			</li>
			<?php 
do_action(PT_CV_PREFIX_ . 'setting_tabs_header', $settings);
?>
		</ul>

		<!-- Tab panes -->
		<div class="tab-content">
			<!-- Filter Settings -->
			<div class="tab-pane active" id="<?php 
echo esc_attr(PT_CV_PREFIX);
?>
filter-settings">
				<?php 
$options = array(array('label' => array('text' => __('Content type', PT_CV_DOMAIN)), 'params' => array(array('type' => 'radio', 'name' => 'content-type', 'options' => PT_CV_Values::post_types(), 'std' => 'post'))), !get_option('pt_cv_version_pro') ? array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 10)), 'params' => array(array('type' => 'html', 'content' => sprintf('<p class="text-muted">&rarr; %s</p>', __('Filter custom content type (or post type) ?', PT_CV_DOMAIN) . sprintf(' <a href="%s" target="_blank">%s</a>', esc_url('http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view'), __('Please upgrade to Pro', PT_CV_DOMAIN)))))) : '', apply_filters(PT_CV_PREFIX_ . 'custom_filters', array()), array('label' => array('text' => __('Common filters', PT_CV_DOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => array(apply_filters(PT_CV_PREFIX_ . 'sticky_posts_setting', array()), array('label' => array('text' => __('In list', PT_CV_DOMAIN)), 'params' => array(array('type' => 'text', 'name' => 'post__in', 'std' => '', 'desc' => __('List of post ids to retrieve (comma-separated values, e.g. 1,2,3)<br>A post is displayed only if its ID is equal to any of the values IN this list', PT_CV_DOMAIN)))), apply_filters(PT_CV_PREFIX_ . 'include_extra_settings', array()), array('label' => array('text' => __('Excludes', PT_CV_DOMAIN)), 'params' => array(array('type' => 'text', 'name' => 'post__not_in', 'std' => '', 'desc' => __('List of post ids to exclude (comma-separated values, e.g. 1,2,3)', PT_CV_DOMAIN)))), apply_filters(PT_CV_PREFIX_ . 'exclude_extra_settings', array()), array('label' => array('text' => __('Parent page', PT_CV_DOMAIN)), 'params' => array(array('type' => 'number', 'name' => 'post_parent', 'std' => '', 'desc' => __('Enter ID of parent page to query child pages', PT_CV_DOMAIN))), 'dependence' => array('content-type', 'page')), apply_filters(PT_CV_PREFIX_ . 'post_parent_settings', array()), array('label' => array('text' => __('Limit', PT_CV_DOMAIN)), 'params' => array(array('type' => 'number', 'name' => 'limit', 'std' => '10', 'min' => '1', 'append_text' => '1 &rarr; 999', 'desc' => __('The number of posts to show. Set empty to show all found posts (which match all filter settings)', PT_CV_DOMAIN)))), apply_filters(PT_CV_PREFIX_ . 'after_limit_option', array()))))), array('label' => array('text' => __('Advanced filters', PT_CV_DOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class(), 'wrap-id' => PT_CV_Html::html_group_id('advanced-params'))), 'params' => array(array('type' => 'group', 'params' => array(array('label' => array('text' => ''), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'checkbox', 'name' => 'advanced-settings[]', 'options' => PT_CV_Values::advanced_settings(), 'std' => '', 'class' => 'advanced-settings-item'))))))), array('label' => array('text' => ''), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_panel_group_class(), 'wrap-id' => PT_CV_Html::html_panel_group_id(PT_CV_Functions::string_random()))), 'params' => array(array('type' => 'panel_group', 'params' => apply_filters(PT_CV_PREFIX_ . 'advanced_settings_panel', array('taxonomy' => array(array('label' => array('text' => __('Taxonomies', PT_CV_DOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_PREFIX . 'taxonomies')), 'params' => array(array('type' => 'checkbox', 'name' => 'taxonomy[]', 'options' => PT_CV_Values::taxonomy_list(), 'std' => '', 'class' => 'taxonomy-item', 'desc' => __('Check checkbox of taxonomies to filter posts by their terms', PT_CV_DOMAIN)))), array('label' => array('text' => __('Terms', PT_CV_DOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_panel_group_class() . ' terms', 'wrap-id' => PT_CV_Html::html_panel_group_id(PT_CV_Functions::string_random()))), 'params' => array(array('type' => 'panel_group', 'settings' => array('nice_name' => PT_CV_Values::taxonomy_list()), 'params' => PT_CV_Settings::terms_of_taxonomies()))), array('label' => array('text' => __('Relation', PT_CV_DOMAIN)), 'params' => array(array('type' => 'select', 'name' => 'taxonomy-relation', 'options' => PT_CV_Values::taxonomy_relation(), 'std' => PT_CV_Functions::array_get_first_key(PT_CV_Values::taxonomy_relation()), 'class' => 'taxonomy-relation', 'desc' => __('Select AND to show posts which match ALL settings of selected taxonomies<br>Select OR to show posts which match settings of at least one selected taxonomy', PT_CV_DOMAIN)))), apply_filters(PT_CV_PREFIX_ . 'taxonomies_custom_settings', array())), 'order' => array(array('label' => array('text' => __('Order by', PT_CV_DOMAIN)), 'extra_setting' => array('params' => array('width' => 12)), 'params' => array(array('type' => 'panel_group', 'settings' => array('show_all' => 1), 'params' => PT_CV_Settings::orderby())))), 'author' => apply_filters(PT_CV_PREFIX_ . 'author_settings', array(array('label' => array('text' => __('Written by', PT_CV_DOMAIN)), 'params' => array(array('type' => 'select', 'name' => 'author__in[]', 'options' => PT_CV_Values::user_list(), 'std' => '', 'class' => 'select2', 'multiple' => $version_gt_37 ? '1' : '0'))), $version_gt_37 ? array('label' => array('text' => __('Not written by', PT_CV_DOMAIN)), 'params' => array(array('type' => 'select', 'name' => 'author__not_in[]', 'options' => PT_CV_Values::user_list(), 'std' => '', 'class' => 'select2', 'multiple' => $version_gt_37 ? '1' : '0'))) : array())), 'status' => array(array('label' => array('text' => __('Status', PT_CV_DOMAIN)), 'params' => array(array('type' => 'select', 'name' => 'post_status', 'options' => PT_CV_Values::post_statuses(), 'std' => 'publish', 'class' => 'select2', 'multiple' => '1', 'desc' => __('Select status of posts', PT_CV_DOMAIN))))), 'search' => array(array('label' => array('text' => __('Keyword', PT_CV_DOMAIN)), 'params' => array(array('type' => 'text', 'name' => 's', 'std' => '', 'desc' => __('Enter the keyword to searching for posts', PT_CV_DOMAIN) . apply_filters(PT_CV_PREFIX_ . 'searchby_keyword_desc', '')))))))))));
echo balanceTags(PT_Options_Framework::do_settings($options, $settings));
?>
			</div>
			<!-- end Filter Settings -->

			<!-- Display Settings -->
			<div class="tab-pane" id="<?php 
echo esc_attr(PT_CV_PREFIX);
?>
display-settings">
				<?php 
$options = array(array('label' => array('text' => __('View type', PT_CV_DOMAIN)), 'params' => array(array('type' => 'radio', 'name' => 'view-type', 'options' => PT_CV_Values::view_type(), 'std' => PT_CV_Functions::array_get_first_key(PT_CV_Values::view_type())))), array('label' => array('text' => __('View type settings', PT_CV_DOMAIN)), 'params' => array(array('type' => 'panel_group', 'settings' => array('no_panel' => 1, 'no_animation' => 1, 'show_only_one' => 1), 'params' => PT_CV_Values::view_type_settings()))), apply_filters(PT_CV_PREFIX_ . 'responsive_settings', array()), array('label' => array('text' => __('Layout format', PT_CV_DOMAIN)), 'params' => array(array('type' => 'radio', 'name' => 'layout-format', 'options' => PT_CV_Values::layout_format(), 'std' => PT_CV_Functions::array_get_first_key(PT_CV_Values::layout_format()), 'desc' => __('This is layout format of output for each post', PT_CV_DOMAIN)))), array('label' => array('text' => __('Fields settings', PT_CV_DOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class(), 'wrap-id' => PT_CV_Html::html_group_id('field-settings'))), 'params' => array(array('type' => 'group', 'params' => PT_CV_Settings::field_settings()))), array('label' => array('text' => __('Pagination settings', PT_CV_DOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => PT_CV_Settings::settings_pagination()))), array('label' => array('text' => __('Other settings', PT_CV_DOMAIN)), 'extra_setting' => array('params' => array('wrap-class' => PT_CV_Html::html_group_class())), 'params' => array(array('type' => 'group', 'params' => PT_CV_Settings::settings_other()))));
$options = apply_filters(PT_CV_PREFIX_ . 'display_settings', $options);
echo balanceTags(PT_Options_Framework::do_settings($options, $settings));
?>
 /**
  * Wrap content of Scrollable list
  *
  * @param array $content_items The array of Raw HTML output (is not wrapped) of each item
  * @param array $content       The output array
  *
  * @return array Array of rows, each row contains columns
  */
 static function scrollable_wrapper($content_items, &$content)
 {
     $dargs = PT_CV_Functions::get_global_variable('dargs');
     // ID for the wrapper of scrollable list
     $wrapper_id = PT_CV_Functions::string_random();
     // Store all output of Scrollale list (indicators, content, controls)
     $scrollable_html = array();
     $scrollable_content_data = self::scrollable_content($content_items);
     $count_slides = $scrollable_content_data['count_slides'];
     $scrollable_content = $scrollable_content_data['scrollable_content'];
     // Js code
     $interval = apply_filters(PT_CV_PREFIX_ . 'scrollable_interval', 'false');
     $js = "\$('#{$wrapper_id}').carousel({ interval : {$interval} })";
     $scrollable_html[] = PT_CV_Html::inline_script($js);
     // Default value off setting options
     $enable = apply_filters(PT_CV_PREFIX_ . 'scrollable_fields_enable', 1);
     // Indicator html
     $show_indicator = isset($dargs['view-type-settings']['indicator']) ? $dargs['view-type-settings']['indicator'] : $enable;
     $scrollable_html[] = self::scrollable_indicator($show_indicator, $wrapper_id, $count_slides);
     // Content html
     $scrollable_html[] = $scrollable_content;
     // Control html
     $show_navigation = isset($dargs['view-type-settings']['navigation']) ? $dargs['view-type-settings']['navigation'] : $enable;
     $scrollable_html[] = self::scrollable_control($show_navigation, $wrapper_id, $count_slides);
     // Get wrapper class scrollable
     $scrollable_class = apply_filters(PT_CV_PREFIX_ . 'scrollable_class', 'carousel slide');
     $content[] = sprintf('<div id="%s" class="%s" data-ride="carousel">%s</div>', esc_attr($wrapper_id), esc_attr($scrollable_class), implode("\n", $scrollable_html));
 }
Example #9
0
    case '1-col':
        foreach ($fields_html as $field_html) {
            $html[] = $field_html;
        }
        break;
    case '2-col':
        // Thumbnail html
        $thumbnail_html = $fields_html['thumbnail'];
        // Other fields html
        unset($fields_html['thumbnail']);
        $others_html = implode("\n", $fields_html);
        $html[] = $thumbnail_html;
        $html[] = $others_html;
        break;
}
$random_id = PT_CV_Functions::string_random();
?>
<div class="panel panel-default pt-cv-content-item">
	<?php 
echo apply_filters(PT_CV_PREFIX_ . 'collapsible_before_heading', '');
?>
	<div class="panel-heading">
		<a class="panel-title" data-toggle="collapse" data-parent="#<?php 
echo esc_attr(PT_CV_PREFIX_UPPER . 'ID');
?>
" href="#<?php 
echo esc_attr($random_id);
?>
">
			<?php 
echo strip_tags($heading);