示例#1
0
							<?php 
$order_by_start = $base->getVar($grid['params'], 'sorting-order-by-start', 'none');
?>
							<select name="sorting-order-by-start" class="eg-tooltip-wrap" title="<?php 
_e('Sorting at Loading', EG_TEXTDOMAIN);
?>
">
								<option value="none"<?php 
selected('none' == $order_by_start, true);
?>
><?php 
_e('None', EG_TEXTDOMAIN);
?>
</option>
								<?php 
if (Essential_Grid_Woocommerce::is_woo_exists()) {
    $wc_sorts = Essential_Grid_Woocommerce::get_arr_sort_by();
    if (!empty($wc_sorts)) {
        foreach ($wc_sorts as $wc_handle => $wc_name) {
            ?>
											<option value="<?php 
            echo $wc_handle;
            ?>
"<?php 
            selected(in_array($wc_handle, $order_by), true);
            if (strpos($wc_handle, 'opt_disabled_') !== false) {
                echo ' disabled="disabled"';
            }
            ?>
><?php 
            echo $wc_name;
 private function translate_demo_filter($name)
 {
     $post = Essential_Grid_Item_Element::getPostElementsArray();
     $event = Essential_Grid_Item_Element::getEventElementsArray();
     $woocommerce = array();
     if (Essential_Grid_Woocommerce::is_woo_exists()) {
         $tmp_wc = Essential_Grid_Woocommerce::get_meta_array();
         foreach ($tmp_wc as $handle => $wc_name) {
             $woocommerce[$handle]['name'] = $wc_name;
         }
     }
     if (array_key_exists($name, $post)) {
         return $post[$name]['name'];
     }
     if (array_key_exists($name, $event)) {
         return $event[$name]['name'];
     }
     if (array_key_exists($name, $woocommerce)) {
         return $woocommerce[$name]['name'];
     }
     return ucwords($name);
 }
 /**
  * create css from settings
  */
 public static function get_existing_elements($only_styles = false)
 {
     $styles = array('font-size' => array('value' => 'int', 'type' => 'text-slider', 'values' => array('min' => '6', 'max' => '120', 'step' => '1', 'default' => '12'), 'style' => 'idle', 'unit' => 'px'), 'line-height' => array('value' => 'int', 'type' => 'text-slider', 'values' => array('min' => '7', 'max' => '150', 'step' => '1', 'default' => '14'), 'style' => 'idle', 'unit' => 'px'), 'color' => array('value' => 'string', 'type' => 'colorpicker', 'values' => array('default' => '#000'), 'style' => 'idle', 'unit' => ''), 'font-family' => array('value' => 'string', 'values' => array('default' => ''), 'style' => 'idle', 'type' => 'text', 'unit' => ''), 'font-weight' => array('value' => 'string', 'values' => array('default' => '400'), 'style' => 'idle', 'type' => 'select', 'unit' => ''), 'text-decoration' => array('value' => 'string', 'values' => array('default' => 'none'), 'style' => 'idle', 'type' => 'select', 'unit' => ''), 'font-style' => array('value' => 'string', 'values' => array('default' => false), 'style' => 'idle', 'type' => 'checkbox', 'unit' => ''), 'text-transform' => array('value' => 'string', 'values' => array('default' => 'none'), 'style' => 'idle', 'type' => 'select', 'unit' => ''), 'display' => array('value' => 'string', 'values' => array('default' => 'inline-block'), 'style' => 'idle', 'type' => 'select', 'unit' => ''), 'float' => array('value' => 'string', 'values' => array('default' => 'none'), 'style' => 'idle', 'type' => 'select', 'unit' => ''), 'text-align' => array('value' => 'string', 'values' => array('default' => 'center'), 'style' => 'idle', 'type' => 'select', 'unit' => ''), 'clear' => array('value' => 'string', 'values' => array('default' => 'none'), 'style' => 'idle', 'type' => 'select', 'unit' => ''), 'margin' => array('value' => 'int', 'type' => 'multi-text', 'values' => array('default' => '0'), 'style' => 'idle', 'unit' => 'px'), 'padding' => array('value' => 'int', 'type' => 'multi-text', 'values' => array('default' => '0'), 'style' => 'idle', 'unit' => 'px'), 'border' => array('value' => 'int', 'type' => 'multi-text', 'values' => array('default' => '0'), 'style' => 'idle', 'unit' => 'px'), 'border-radius' => array('value' => 'int', 'type' => 'multi-text', 'values' => array('default' => '0'), 'style' => 'idle', 'unit' => array('px', 'percentage')), 'border-color' => array('value' => 'string', 'values' => array('default' => 'transparent'), 'style' => 'idle', 'type' => 'colorpicker', 'unit' => ''), 'border-style' => array('value' => 'string', 'values' => array('default' => 'solid'), 'style' => 'idle', 'type' => 'select', 'unit' => ''), 'background-color' => array('value' => 'string', 'type' => 'colorpicker', 'values' => array('default' => '#FFF'), 'style' => 'idle', 'unit' => ''), 'bg-alpha' => array('value' => 'string', 'values' => array('min' => '0', 'max' => '100', 'step' => '1', 'default' => '100'), 'style' => 'false', 'type' => 'text-slider', 'unit' => ''), 'shadow-color' => array('value' => 'string', 'type' => 'colorpicker', 'values' => array('default' => '#000'), 'style' => 'false', 'unit' => ''), 'shadow-alpha' => array('value' => 'string', 'values' => array('min' => '0', 'max' => '100', 'step' => '1', 'default' => '100'), 'style' => 'false', 'type' => 'text-slider', 'unit' => ''), 'box-shadow' => array('value' => 'int', 'type' => 'multi-text', 'values' => array('default' => '0'), 'style' => 'idle', 'unit' => 'px'), 'position' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => 'relative'), 'style' => 'idle', 'unit' => ''), 'top-bottom' => array('value' => 'int', 'type' => 'text', 'values' => array('default' => '0'), 'style' => 'false', 'unit' => 'px'), 'left-right' => array('value' => 'int', 'type' => 'text', 'values' => array('default' => '0'), 'style' => 'false', 'unit' => 'px'));
     $hover_styles = array('font-size-hover' => array('value' => 'int', 'type' => 'text-slider', 'values' => array('min' => '6', 'max' => '120', 'step' => '1', 'default' => '12'), 'style' => 'hover', 'unit' => 'px'), 'line-height-hover' => array('value' => 'int', 'type' => 'text-slider', 'values' => array('min' => '7', 'max' => '150', 'step' => '1', 'default' => '14'), 'style' => 'hover', 'unit' => 'px'), 'color-hover' => array('value' => 'string', 'type' => 'colorpicker', 'values' => array('default' => '#000'), 'style' => 'hover', 'unit' => ''), 'font-family-hover' => array('value' => 'string', 'values' => array('default' => ''), 'style' => 'hover', 'type' => 'text', 'unit' => ''), 'font-weight-hover' => array('value' => 'string', 'values' => array('default' => '400'), 'style' => 'hover', 'type' => 'select', 'unit' => ''), 'text-decoration-hover' => array('value' => 'string', 'values' => array('default' => 'none'), 'style' => 'hover', 'type' => 'select', 'unit' => ''), 'font-style-hover' => array('value' => 'string', 'values' => array('default' => false), 'style' => 'hover', 'type' => 'checkbox', 'unit' => ''), 'text-transform-hover' => array('value' => 'string', 'values' => array('default' => 'none'), 'style' => 'hover', 'type' => 'select', 'unit' => ''), 'border-hover' => array('value' => 'int', 'type' => 'multi-text', 'values' => array('default' => '0'), 'style' => 'hover', 'unit' => 'px'), 'border-radius-hover' => array('value' => 'int', 'type' => 'multi-text', 'values' => array('default' => '0'), 'style' => 'hover', 'unit' => array('px', 'percentage')), 'border-color-hover' => array('value' => 'string', 'values' => array('default' => 'transparent'), 'style' => 'hover', 'type' => 'colorpicker', 'unit' => ''), 'border-style-hover' => array('value' => 'string', 'values' => array('default' => 'solid'), 'style' => 'hover', 'type' => 'select', 'unit' => ''), 'background-color-hover' => array('value' => 'string', 'type' => 'colorpicker', 'values' => array('default' => '#FFF'), 'style' => 'hover', 'unit' => ''), 'bg-alpha-hover' => array('value' => 'string', 'values' => array('min' => '0', 'max' => '100', 'step' => '1', 'default' => '100'), 'style' => 'false', 'type' => 'text-slider', 'unit' => ''), 'shadow-color-hover' => array('value' => 'string', 'type' => 'colorpicker', 'values' => array('default' => '#000'), 'style' => 'false', 'unit' => ''), 'shadow-alpha-hover' => array('value' => 'string', 'values' => array('min' => '0', 'max' => '100', 'step' => '1', 'default' => '100'), 'style' => 'false', 'type' => 'text-slider', 'unit' => ''), 'box-shadow-hover' => array('value' => 'int', 'type' => 'multi-text', 'values' => array('default' => '0'), 'style' => 'hover', 'unit' => 'px'));
     $other = array();
     if (!$only_styles) {
         $other = array('source' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => 'post'), 'style' => 'false', 'unit' => ''), 'transition' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => 'fade'), 'style' => 'attribute', 'unit' => ''), 'source-separate' => array('value' => 'string', 'type' => 'text', 'values' => array('default' => ','), 'style' => 'attribute', 'unit' => ''), 'source-function' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => 'link'), 'style' => 'attribute', 'unit' => ''), 'limit-type' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => 'none'), 'style' => 'attribute', 'unit' => ''), 'limit-num' => array('value' => 'string', 'type' => 'text', 'values' => array('default' => '10'), 'style' => 'attribute', 'unit' => ''), 'transition-type' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => ''), 'style' => 'false', 'unit' => ''), 'delay' => array('value' => 'string', 'type' => 'text-slider', 'values' => array('min' => '0', 'max' => '60', 'step' => '1', 'default' => '10'), 'style' => 'attribute', 'unit' => ''), 'link-type' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => 'none'), 'style' => 'false', 'unit' => ''), 'hideunder' => array('value' => 'string', 'type' => 'text', 'values' => array('default' => '0'), 'style' => 'false', 'unit' => ''), 'hideunderheight' => array('value' => 'string', 'type' => 'text', 'values' => array('default' => '0'), 'style' => 'false', 'unit' => ''), 'hidetype' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => 'visibility'), 'style' => 'false', 'unit' => ''), 'hide-on-video' => array('value' => 'string', 'type' => 'checkbox', 'values' => array('default' => false), 'style' => 'false', 'unit' => ''), 'enable-hover' => array('value' => 'string', 'type' => 'checkbox', 'values' => array('default' => false), 'style' => 'false', 'unit' => ''), 'attribute' => array('value' => 'string', 'type' => 'text', 'values' => array('default' => ''), 'style' => 'false', 'unit' => ''), 'class' => array('value' => 'string', 'type' => 'text', 'values' => array('default' => ''), 'style' => 'false', 'unit' => ''), 'rel' => array('value' => 'string', 'type' => 'text', 'values' => array('default' => ''), 'style' => 'false', 'unit' => ''), 'tag-type' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => 'div'), 'style' => 'false', 'unit' => ''), 'force-important' => array('value' => 'string', 'type' => 'checkbox', 'values' => array('default' => true), 'style' => 'false', 'unit' => ''), 'align' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => 't_l'), 'style' => 'false', 'unit' => ''), 'link-target' => array('value' => 'string', 'type' => 'select', 'values' => array('default' => '_self'), 'style' => 'false', 'unit' => ''), 'source-text-style-disable' => array('value' => 'string', 'type' => 'checkbox', 'values' => array('default' => false), 'style' => 'false', 'unit' => ''));
         if (Essential_Grid_Woocommerce::is_woo_exists()) {
             $other['show-on-sale'] = array('value' => 'string', 'type' => 'checkbox', 'values' => array('default' => false), 'style' => 'false', 'unit' => '');
             $other['show-if-featured'] = array('value' => 'string', 'type' => 'checkbox', 'values' => array('default' => false), 'style' => 'false', 'unit' => '');
         }
     }
     $styles = array_merge($styles, $other, $hover_styles);
     return $styles;
 }
示例#4
0
 /**
  * replace all metas with corresponding text
  */
 public function replace_all_meta_in_text($post_id, $text)
 {
     if (trim($text) === '' || intval($post_id) === 0) {
         return '';
     }
     $base = new Essential_Grid_Base();
     $meta_link = new Essential_Grid_Meta_Linking();
     $cmeta = $this->get_all_meta();
     //process meta tags:
     $arr_matches = array();
     preg_match_all("/%[^%]*%/", $text, $arr_matches);
     if (!empty($arr_matches)) {
         $my_post = get_post($post_id, ARRAY_A);
         foreach ($arr_matches as $matches) {
             if (is_array($matches)) {
                 foreach ($matches as $match) {
                     $meta = trim(str_replace('%', '', $match));
                     $meta_value = get_post_meta($post_id, $meta, true);
                     if (!empty($cmeta)) {
                         foreach ($cmeta as $me) {
                             if ('eg-' . $me['handle'] == $meta) {
                                 if ($me['type'] == 'image') {
                                     if (intval($meta_value) > 0) {
                                         //get URL to Image
                                         $img = wp_get_attachment_image_src($meta_value, 'full');
                                         if ($img !== false) {
                                             $meta_value = $img[0];
                                         } else {
                                             $meta_value = '';
                                         }
                                     } else {
                                         $meta_value = '';
                                     }
                                 }
                                 if ($meta_value == '' && isset($me['default'])) {
                                     $meta_value = $me['default'];
                                 }
                                 break;
                             }
                         }
                     }
                     //check woocommerce
                     if (Essential_Grid_Woocommerce::is_woo_exists()) {
                         $wc_text = Essential_Grid_Woocommerce::get_value_by_meta($post_id, $meta);
                         if ($wc_text !== '') {
                             $meta_value = $wc_text;
                         }
                     }
                     if (empty($meta_value) && !empty($my_post)) {
                         //try to get from post
                         switch ($meta) {
                             //Post elements
                             case 'post_url':
                                 $post_id = $base->getVar($my_post, 'ID', '');
                                 $meta_value = get_permalink($post_id);
                                 break;
                             case 'post_id':
                                 $meta_value = $base->getVar($my_post, 'ID', '');
                                 break;
                             case 'title':
                                 $meta_value = $base->getVar($my_post, 'post_title', '');
                                 break;
                             case 'excerpt':
                                 $meta_value = trim($base->getVar($my_post, 'post_excerpt'));
                                 if (empty($meta_value)) {
                                     $meta_value = trim($base->getVar($my_post, 'post_content'));
                                 }
                                 $meta_value = strip_tags($meta_value);
                                 //,"<b><br><br/><i><strong><small>"
                                 break;
                             case 'meta':
                                 $m = new Essential_Grid_Meta();
                                 $meta_value = $m->get_meta_value_by_handle($my_post['ID'], $meta);
                                 break;
                             case 'alias':
                                 $meta_value = $base->getVar($my_post, 'post_name');
                                 break;
                             case 'content':
                                 $meta_value = $base->getVar($my_post, 'post_content');
                                 break;
                             case 'link':
                                 $meta_value = get_permalink($my_post['ID']);
                                 break;
                             case 'date':
                                 $postDate = $base->getVar($my_post, "post_date_gmt");
                                 $meta_value = $base->convert_post_date($postDate);
                                 break;
                             case 'date_modified':
                                 $dateModified = $base->getVar($my_post, "post_modified");
                                 $meta_value = $base->convert_post_date($dateModified);
                                 break;
                             case 'author_name':
                                 $authorID = $base->getVar($my_post, 'post_author');
                                 $meta_value = get_the_author_meta('display_name', $authorID);
                                 break;
                             case 'num_comments':
                                 $meta_value = $base->getVar($my_post, 'comment_count');
                                 break;
                             case 'cat_list':
                                 $use_taxonomies = false;
                                 $postCatsIDs = $base->getVar($my_post, 'post_category');
                                 if (empty($postCatsIDs) && isset($my_post['post_type'])) {
                                     $postCatsIDs = array();
                                     $obj = get_object_taxonomies($my_post['post_type']);
                                     if (!empty($obj) && is_array($obj)) {
                                         foreach ($obj as $tax) {
                                             $use_taxonomies[] = $tax;
                                             $new_terms = get_the_terms($my_post['ID'], $tax);
                                             if (is_array($new_terms) && !empty($new_terms)) {
                                                 foreach ($new_terms as $term) {
                                                     $postCatsIDs[$term->term_id] = $term->term_id;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 $meta_value = $base->get_categories_html_list($postCatsIDs, true, ',', $use_taxonomies);
                                 break;
                             case 'tag_list':
                                 $meta_value = $base->get_tags_html_list($my_post['ID']);
                                 break;
                             default:
                                 $meta_value = apply_filters('essgrid_post_meta_content', $meta_value, $meta, $my_post['ID'], $my_post);
                                 break;
                                 break;
                         }
                         if (empty($meta_value)) {
                             //check if its linking
                             $meta_value = $meta_link->get_link_meta_value_by_handle($my_post['ID'], $meta);
                         }
                     }
                     $text = str_replace($match, $meta_value, $text);
                 }
             }
         }
     }
     return $text;
 }
示例#5
0
    /**
     * Meta Dialog
     * @since    1.0.0
     */
    public static function meta_dialog()
    {
        $m = new Essential_Grid_Meta();
        $item_ele = new Essential_Grid_Item_Element();
        $post_items = $item_ele->getPostElementsArray();
        $metas = $m->get_all_meta();
        ?>
		<div id="meta-dialog-wrap" class="essential-dialog-wrap" title="<?php 
        _e('Meta', EG_TEXTDOMAIN);
        ?>
"  style="display: none; padding:20px !important;">
			<table>
				<tr class="eg-table-title"><td><?php 
        _e('Meta Handle', EG_TEXTDOMAIN);
        ?>
</td><td><?php 
        _e('Description', EG_TEXTDOMAIN);
        ?>
			<?php 
        if (!empty($post_items)) {
            foreach ($post_items as $phandle => $pitem) {
                echo '<tr class="eg-add-meta-to-textarea"><td>%' . $phandle . '%</td><td>' . $pitem['name'] . '</td></tr>';
            }
        }
        if (!empty($metas)) {
            foreach ($metas as $meta) {
                if ($meta['m_type'] == 'link') {
                    echo '<tr class="eg-add-meta-to-textarea"><td>%egl-' . $meta['handle'] . '%</td><td>' . $meta['name'] . '</td></tr>';
                } else {
                    echo '<tr class="eg-add-meta-to-textarea"><td>%eg-' . $meta['handle'] . '%</td><td>' . $meta['name'] . '</td></tr>';
                }
            }
        }
        if (Essential_Grid_Woocommerce::is_woo_exists()) {
            $metas = Essential_Grid_Woocommerce::get_meta_array();
            foreach ($metas as $meta => $name) {
                echo '<tr><td>%' . $meta . '%</td><td>' . $name . '</td></tr>';
            }
        }
        ?>
			</table>
		</div>
		<?php 
    }
示例#6
0
 public function prepare_sorting_array_by_post($post, $order_by)
 {
     $base = new Essential_Grid_Base();
     $link_meta = new Essential_Grid_Meta_Linking();
     $meta = new Essential_Grid_Meta();
     $m = $meta->get_all_meta(false);
     $lm = $link_meta->get_all_link_meta(false);
     $sorts = array();
     foreach ($order_by as $order) {
         switch ($order) {
             case 'date':
                 $sorts['date'] = strtotime($base->getVar($post, 'post_date'));
                 break;
             case 'title':
                 $sorts['title'] = substr($base->getVar($post, 'post_title', ''), 0, 10);
                 break;
             case 'excerpt':
                 $sorts['excerpt'] = substr(strip_tags($base->getVar($post, 'post_excerpt', '')), 0, 10);
                 break;
             case 'id':
                 $sorts['id'] = $base->getVar($post, 'ID');
                 break;
             case 'slug':
                 $sorts['slug'] = $base->getVar($post, 'post_name');
                 break;
             case 'author':
                 $authorID = $base->getVar($post, 'post_author');
                 $sorts['author'] = get_the_author_meta('display_name', $authorID);
                 break;
             case 'last-modified':
                 $sorts['last-modified'] = strtotime($base->getVar($post, 'post_modified'));
                 break;
             case 'number-of-comments':
                 $sorts['number-of-comments'] = $base->getVar($post, 'comment_count');
                 break;
             case 'random':
                 $sorts['random'] = rand(0, 9999);
                 break;
             default:
                 //check if meta. If yes, add meta values
                 if (strpos($order, 'eg-') === 0) {
                     if (!empty($m)) {
                         foreach ($m as $me) {
                             if ('eg-' . $me['handle'] == $order) {
                                 $sorts[$order] = $meta->get_meta_value_by_handle($post['ID'], $order);
                                 break;
                             }
                         }
                     }
                 } elseif (strpos($order, 'egl-') === 0) {
                     if (!empty($lm)) {
                         foreach ($lm as $me) {
                             if ('egl-' . $me['handle'] == $order) {
                                 $sorts[$order] = $link_meta->get_link_meta_value_by_handle($post['ID'], $order);
                                 break;
                             }
                         }
                     }
                 }
                 break;
         }
     }
     //add woocommerce sortings
     if (Essential_Grid_Woocommerce::is_woo_exists()) {
         $product = get_product($post['ID']);
         if (!empty($product)) {
             foreach ($order_by as $order) {
                 switch ($order) {
                     case 'meta_num_total_sales':
                         $sorts['total-sales'] = get_post_meta($post['ID'], $order, true);
                         break;
                     case 'meta_num__regular_price':
                         $sorts['regular-price'] = $product->get_price();
                         break;
                         //case 'meta_num__sale_price':
                         //	$sorts['sale-price'] = $product->get_sale_price();
                         //break;
                     //case 'meta_num__sale_price':
                     //	$sorts['sale-price'] = $product->get_sale_price();
                     //break;
                     case 'meta__featured':
                         $sorts['featured'] = $product->is_featured() ? '1' : '0';
                         break;
                     case 'meta__sku':
                         $sorts['sku'] = $product->get_sku();
                         break;
                     case 'meta_num_stock':
                         $sorts['in-stock'] = $product->get_stock_quantity();
                         break;
                 }
             }
         }
     }
     return $sorts;
 }
 /**
  * Retrieve the value of woocommerce elements
  */
 public function get_woocommerce_value($meta, $separator)
 {
     $text = '';
     if (isset($this->post['ID'])) {
         if (Essential_Grid_Woocommerce::is_woo_exists()) {
             $base = new Essential_Grid_Base();
             $m = new Essential_Grid_Meta();
             $text = Essential_Grid_Woocommerce::get_value_by_meta($this->post['ID'], $meta, $separator);
         }
     }
     return $text;
 }