function ce_field_validate($data)
{
    $fields = CE_Fields::get_fields();
    foreach ($fields as $key => $value) {
        if (!$value['field_required']) {
            continue;
        }
        if (isset($value['field_cats'])) {
            $field_cats = $value['field_cats'];
            $cat = $data['tax_input'][CE_AD_CAT];
            $intersec = array_intersect($field_cats, $cat);
            if (!empty($intersec)) {
                if (!isset($data[$value['field_name']]) || !$data[$value['field_name']]) {
                    return new WP_Error('ad_empty_content', sprintf(__("Please complete all required fields.", ET_DOMAIN), $value['field_label']));
                }
            }
        }
    }
    return $data;
}
<div class="wrap-taxs-fields tab hide taxs_tab_div" id="taxs_tab">
	<h5 class=" title font-quicksand"><?php 
_e("List Ad's taxonomies", ET_DOMAIN);
?>
</h5>
	<div id="taxonomy_lists">
		<ul class="pay-plans-list tax-list sortable add-fields ui-sortable">
			<?php 
$taxs = (array) CE_Fields::get_taxs();
$list_tax = array(0 => '');
if (is_array($taxs) && !empty($taxs)) {
    foreach ($taxs as $key => $tax) {
        $status = isset($tax['tax_status']) && $tax['tax_status'] == 1 ? 1 : 0;
        ?>
					<li data="<?php 
        echo $key;
        ?>
" id="tax_key_<?php 
        echo $key;
        ?>
" class="item <?php 
        if (!$status) {
            echo 'off';
        }
        ?>
">
						<div class="sort-handle"></div>
						<span class="tax_label"><?php 
        echo stripcslashes($tax['tax_label']);
        ?>
 </span>
Exemple #3
0
 public function check_field_exitst($field_name, $pos = -1)
 {
     $fields = CE_Fields::get_fields();
     if (is_array($fields) && empty($fields)) {
         foreach ($fields as $key => $field) {
             if ($key == $pos) {
                 continue;
             }
             if ($field['field_name'] == $field_name) {
                 return true;
             }
         }
     }
     return false;
 }
 function ce_show_seller_field($seller)
 {
     $fields = CE_Fields::get_seller_fields();
     if (!empty($fields)) {
         foreach ($fields as $key => $field) {
             $this->render_field_front($field, $seller);
         }
     }
 }
<div class="wrap-meta-fields tab fields_tab_div" id="fields_tab">
	<h5 class=" title font-quicksand"><?php 
_e("List Ad's Fields", ET_DOMAIN);
?>
</h5>
	<div id="fields_lists">
		<ul class="pay-plans-list add-fields fields-list sortable ui-sortable" id="list_ad_fields">
			<?php 
$uri = $_SERVER['QUERY_STRING'];
$fields = (array) CE_Fields::get_fields();
$list_fields = array();
if ($fields) {
    foreach ($fields as $key => $field) {
        if (empty($field)) {
            continue;
        }
        if (isset($field['field_cats'])) {
            $cats = array();
            $terms = $field['field_cats'];
            if (is_array($terms)) {
                foreach ($terms as $key => $value) {
                    $term = get_term($value, CE_AD_CAT);
                    if ($term == null || $term instanceof WP_Error) {
                        continue;
                    }
                    $cats[$key]['id'] = (int) $value;
                    $cats[$key]['name'] = $term->name;
                }
            }
            $field['field_cats'] = $cats;
        }
Exemple #6
0
    function form($instance)
    {
        $taxs = CE_Fields::get_taxs();
        $fname = isset($tax[0]['tax_name']) ? $tax[0]['tax_name'] : '';
        $instance = wp_parse_args((array) $instance, array('tax_select' => $fname, 'title' => '', 'show_count' => false));
        $title = esc_attr($instance['title']);
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
</label> <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo $title;
        ?>
" /></p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('tax_select');
        ?>
"><?php 
        _e('Select taxonomy:');
        ?>
</label>
			<select name="<?php 
        echo $this->get_field_name('tax_select');
        ?>
" id="<?php 
        echo $this->get_field_id('tax_select');
        ?>
" class="widefat">
				<?php 
        foreach ($taxs as $key => $tax) {
            ?>
					<option value="<?php 
            echo $tax['tax_name'];
            ?>
" <?php 
            f_selected($instance['tax_select'], $tax['tax_name']);
            ?>
 > <?php 
            echo $tax['tax_label'];
            ?>
</option>
					<?php 
        }
        ?>
			</select>
		</p>
		<p>

			<input type="checkbox" <?php 
        if ($instance['show_count']) {
            echo 'checked="checked"';
        }
        ?>
 id= "<?php 
        echo $this->get_field_id('show_count');
        ?>
" name="<?php 
        echo $this->get_field_name('show_count');
        ?>
" id="<?php 
        echo $this->get_field_id('tax_select');
        ?>
" class="widefat" />
			<label for="<?php 
        echo $this->get_field_id('show_count');
        ?>
"><?php 
        _e('Show post count:');
        ?>
</label>

		</p>

	<?php 
    }
<div class="wrap-meta-fields tab hide seller_tab_div" id="seller_tab">
	<h5 class=" title font-quicksand"><?php 
_e("List Seller's Fields", ET_DOMAIN);
?>
</h5>
	<div id="sfield_lists">
		<ul class="pay-plans-list seller-fields-list sortable ui-sortable" id="list_seller_fields">
			<?php 
$fields = (array) CE_Fields::get_seller_fields();
$list_seller_fields = array();
if ($fields) {
    foreach ($fields as $key => $field) {
        $name = $field['field_name'];
        $list_seller_fields[$name] = $field;
        $status = isset($field['tax_status']) && $field['tax_status'] == 1 ? 1 : 0;
        ?>
					<li data="<?php 
        echo $name;
        ?>
" id="field_key_<?php 
        echo $name;
        ?>
" class="item" action="abc">
						<div class="sort-handle"></div>
						<span class="field_label"><?php 
        echo $field['field_label'];
        ?>
 </span>
						<?php 
        echo stripcslashes($field['field_des']);
        ?>
 /**
  * Start the element output.
  *
  * @see Walker::start_el()
  *
  * @since 2.1.0
  *
  * @param string $output   Passed by reference. Used to append additional content.
  * @param object $category Category data object.
  * @param int    $depth    Depth of category in reference to parents. Default 0.
  * @param array  $args     An array of arguments. @see wp_list_categories()
  * @param int    $id       ID of the current category.
  */
 function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0)
 {
     extract($args);
     global $wp_query;
     $taxs = CE_Fields::get_taxs();
     $href = esc_url(get_term_link($category));
     $field = $taxs[$category->taxonomy];
     /**
      * process url to filter
      */
     $cat_name = $category->name;
     $tax_slug = $field['tax_slug'];
     $ad_cat = isset($_REQUEST[$tax_slug]) ? $_REQUEST[$tax_slug] : '';
     if (!is_home() && !is_single() && !is_tax($args['taxonomy'])) {
         $href = add_query_arg(array($field['tax_slug'] => $category->slug));
     }
     if (!empty($ad_cat) && $ad_cat == $category->slug) {
         $href = remove_query_arg($field['tax_slug'], $href);
     }
     $link = '<a class="customize_text" href="' . $href . '" ';
     if ($use_desc_for_title == 0 || empty($category->description)) {
         $link .= 'title="' . esc_attr(sprintf(__('View all posts filed under %s'), $cat_name)) . '"';
     } else {
         $link .= 'title="' . esc_attr(strip_tags(apply_filters('category_description', $category->description, $category))) . '"';
     }
     $link .= '>';
     $link .= $cat_name . '</a>';
     if (!empty($feed_image) || !empty($feed)) {
         $link .= ' ';
         if (empty($feed_image)) {
             $link .= '(';
         }
         $link .= '<a href="' . esc_url(get_term_feed_link($category->term_id, $category->taxonomy, $feed_type)) . '"';
         if (empty($feed)) {
             $alt = ' alt="' . sprintf(__('Feed for all posts filed under %s'), $cat_name) . '"';
         } else {
             $title = ' title="' . $feed . '"';
             $alt = ' alt="' . $feed . '"';
             $name = $feed;
             $link .= $title;
         }
         $link .= '>';
         if (empty($feed_image)) {
             $link .= $name;
         } else {
             $link .= "<img src='{$feed_image}'{$alt}{$title}" . ' />';
         }
         $link .= '</a>';
         if (empty($feed_image)) {
             $link .= ')';
         }
     }
     if (!empty($show_count)) {
         $link .= '<span class="cat-count"> (' . intval($category->count) . ')</span>';
     }
     /**
      * check cat is root and has children add icon next
      */
     if ($category->has_child) {
         if ($args['hierarchical']) {
             $link = '<div class="border-bottom" >' . $link . '<i class="fa fa-arrow-right"></i></div>';
         } else {
             $link = '<div class="border-bottom" >' . $link . '</div>';
         }
     } else {
         if ($category->parent == 0) {
             $link = '<div class="border-bottom" >' . $link . '</div>';
         }
     }
     if ('list' == $args['style']) {
         $output .= "\t<li";
         $class = 'cat-item cat-item-' . $category->term_id;
         if ($category->slug == $ad_cat) {
             $class .= ' clicked active';
         }
         if (!empty($current_category)) {
             $_current_category = get_term($current_category, $category->taxonomy);
             if ($category->term_id == $current_category) {
                 $class .= ' clicked active';
             } elseif ($category->term_id == $_current_category->parent) {
                 $class .= ' clicked active';
             }
         }
         // echo $class;
         $output .= ' class="' . $class . '"';
         $output .= ">{$link}\n";
     } else {
         $output .= "\t{$link}<br />\n";
     }
 }
    /**
     * Render Meta Box content.
     *
     * @param WP_Post $post The post object.
     */
    public function render_meta_box_content($post)
    {
        if ($post->post_type != CE_AD_POSTTYPE) {
            return;
        }
        // Add an nonce field so we can check for it later.
        wp_nonce_field('myplugin_inner_custom_box', 'myplugin_inner_custom_box_nonce');
        // Display the form, using the current value.
        echo '<label for="myplugin_new_field">';
        _e('List of fields added through CE Custom Fields.', 'ET_DOMAIN');
        echo '</label> ';
        ?>
		<table class="form-table ad-info">
		<tbody>
			<?php 
        $fields = CE_Fields::get_fields();
        if ($fields) {
            foreach ($fields as $key => $field) {
                $this->show_field($field, $post);
            }
        }
        ?>
		</tbody>
		</table>
		<script type="text/javascript">
			(function($) {
				$(document).ready(function(){
					if($('.ce_field_datepicker').length>0){
						$('.ce_field_datepicker').datepicker({
							dateFormat : edit_ad.dateFormat
							//defaultDate : new Date(jQuery('#et_date').val())
						});
					}


				});
			})(jQuery);
		</script>

		<?php 
    }