' . esc_attr__('CHOOSE YOUR ITEM', ESG_TEXTDOMAIN) . '
');
}
/**
* return all current set filter as array
*/
public function insert_masonry_layer($demo = false, $style = false, $is_video = false, $grid_ids = '', $post_ids = '')
{
$base = new Essential_Grid_Base();
$content_class = ' eg-' . esc_attr($this->handle) . '-content';
do_action('essgrid_insert_masonry_layer_pre', $demo, $style, $is_video);
echo '
' . "\n";
if (!empty($this->layers)) {
foreach ($this->layers as $layer) {
if (!isset($layer['container']) || $layer['container'] != 'm') continue;
$link_to = $base->getVar($layer, array('settings', 'link-type'), 'none');
$hide_on_video = $base->getVar($layer, array('settings', 'hide-on-video'), 'false');
if ($link_to != 'embedded_video' && $hide_on_video == 'true' && $is_video == true) continue; //this element is hidden if media is video
if ($link_to != 'embedded_video' && $hide_on_video == 'show' && $is_video == false) continue; //this element is only shown if media is video
if ($demo === false) {
//show element only if it is on sale or if featured
if (Essential_Grid_Woocommerce::is_woo_exists()) {
$show_on_sale = $base->getVar($layer, array('settings', 'show-on-sale'), 'false');
if ($show_on_sale == 'true') {
$sale = Essential_Grid_Woocommerce::check_if_on_sale($this->post['ID']);
if (!$sale) continue;
}
$show_if_featured = $base->getVar($layer, array('settings', 'show-if-featured'), 'false');
if ($show_if_featured == 'true') {
$featured = Essential_Grid_Woocommerce::check_if_is_featured($this->post['ID']);
if (!$featured) continue;
}
}
}
if ($demo == 'overview' || $demo == 'skinchoose' || $demo == 'custom') {
self::insert_layer($layer, $demo, true, $grid_ids, $post_ids);
} else {
self::insert_layer($layer, false, true, $grid_ids, $post_ids);
}
}
}
echo '
';
do_action('essgrid_insert_masonry_layer_post', $demo, $style, $is_video);
}
/**
* return all current set filter as array
*/
public function get_filter_array()
{
return apply_filters('essgrid_get_filter_array', $this->filter);
}
/**
* set all post values for post output
*/
public function set_post_values($post)
{
$this->post = apply_filters('essgrid_set_post_values', $post);
$this->set_post_meta_values();
}
/**
* set all post values for post output
*/
public function set_layer_values($values)
{
$this->layer_values = apply_filters('essgrid_set_layer_values', $values);
}
/**
* get all post values / layer values at custom grid
* @since: 2.1.0
*/
public function get_layer_values()
{
return apply_filters('essgrid_get_layer_values', $this->layer_values);
}
/**
* set custom post meta values for post output
*/
public function set_post_meta_values()
{
if (empty($this->post)) return false;
$values = isset($this->post['ID']) ? get_post_custom($this->post['ID']) : false;
if (!empty($values)) {
$eg_settings_custom_meta_skin = isset($values['eg_settings_custom_meta_skin']) ? unserialize($values['eg_settings_custom_meta_skin'][0]) : "";
$eg_settings_custom_meta_element = isset($values['eg_settings_custom_meta_element']) ? unserialize($values['eg_settings_custom_meta_element'][0]) : "";
$eg_settings_custom_meta_setting = isset($values['eg_settings_custom_meta_setting']) ? unserialize($values['eg_settings_custom_meta_setting'][0]) : "";
$eg_settings_custom_meta_style = isset($values['eg_settings_custom_meta_style']) ? unserialize($values['eg_settings_custom_meta_style'][0]) : "";
} /* 2.2.6 */
else {
$values = $this->post;
$eg_settings_custom_meta_skin = isset($values['eg_settings_custom_meta_skin']) ? $values['eg_settings_custom_meta_skin'] : "";
$eg_settings_custom_meta_element = isset($values['eg_settings_custom_meta_element']) ? $values['eg_settings_custom_meta_element'] : "";
$eg_settings_custom_meta_setting = isset($values['eg_settings_custom_meta_setting']) ? $values['eg_settings_custom_meta_setting'] : "";
$eg_settings_custom_meta_style = isset($values['eg_settings_custom_meta_style']) ? $values['eg_settings_custom_meta_style'] : "";
}
$eg_meta = array();
if (!empty($eg_settings_custom_meta_skin)) {
foreach ($eg_settings_custom_meta_skin as $key => $val) {
$eg_meta[$key]['skin'] = @$val;
$eg_meta[$key]['element'] = @$eg_settings_custom_meta_element[$key];
$eg_meta[$key]['setting'] = @$eg_settings_custom_meta_setting[$key];
$eg_meta[$key]['style'] = @$eg_settings_custom_meta_style[$key];
}
}
unset($values['eg_settings_custom_meta_skin']);
unset($values['eg_settings_custom_meta_element']);
unset($values['eg_settings_custom_meta_setting']);
unset($values['eg_settings_custom_meta_style']);
$values['eg-meta-style'] = $eg_meta;
$this->post_meta = apply_filters('essgrid_set_post_meta_values', $values);
}
/**
* check if element has custom information set in post, if yes, return it
*/
public function set_meta_element_changes($layer_id, $class)
{
if (!empty($this->post_meta) && !empty($this->post_meta['eg-meta-style'])) {
//get all allowed meta keys
$item_ele = new Essential_Grid_Item_Element();
$metas = $item_ele->get_allowed_meta();
foreach ($this->post_meta['eg-meta-style'] as $entry) {
if ($entry['skin'] == $this->id && $entry['element'] == $layer_id) {
$found = false;
foreach ($metas as $meta) {
if ($meta['name']['handle'] == $entry['setting']) {
//found, check if style, anim or layout, we only need style here
if ($meta['container'] == 'style') $found = true;
break;
}
}
if ($found) {
//only add if it is a style
if (strpos($entry['setting'], '-hover') !== false) {
//check if we are hover or not
$style = 'hover';
$entry['setting'] = str_replace('-hover', '', $entry['setting']);
} else {
$style = 'idle';
}
if ($entry['setting'] == 'box-shadow') {
$this->layers_meta_css[$style][$class]['-moz-' . $entry['setting']] = $entry['style'];
$this->layers_meta_css[$style][$class]['-webkit-' . $entry['setting']] = $entry['style'];
$this->layers_meta_css[$style][$class][$entry['setting']] = $entry['style'];
} else {
$this->layers_meta_css[$style][$class][$entry['setting']] = $entry['style'];
}
}
}
}
}
}
/**
* check if layout has custom information set in post, if yes, return it
*/
public function get_meta_layout_change($setting)
{
$found = false;
if (!empty($this->post_meta) && !empty($this->post_meta['eg-meta-style'])) {
//get all allowed meta keys
$item_ele = new Essential_Grid_Item_Element();
$metas = $item_ele->get_allowed_meta();
foreach ($this->post_meta['eg-meta-style'] as $entry) {
if ($entry['skin'] == $this->id) {
foreach ($metas as $meta) {
if ($meta['name']['handle'] == $entry['setting'] && $setting == $entry['setting']) { //found, check if layout
if ($meta['container'] == 'layout') { //we only want layout here
$found = $entry['style'];
}
break;
}
}
}
}
}
return $found;
}
/**
* check if layout has custom information set in post, if yes, return it
*/
public function get_meta_element_change($layer_id, $setting)
{
$found = false;
if (!empty($this->post_meta) && !empty($this->post_meta['eg-meta-style'])) {
//get all allowed meta keys
$item_ele = new Essential_Grid_Item_Element();
$metas = $item_ele->get_allowed_meta();
foreach ($this->post_meta['eg-meta-style'] as $entry) {
if ($entry['skin'] == $this->id && $entry['element'] == $layer_id) {
foreach ($metas as $meta) {
if ($meta['name']['handle'] == $entry['setting'] && $setting == $entry['setting']) {
$found = $entry['style'];
break;
}
}
}
}
}
return $found;
}
public function get_media_attributes($order)
{
$base = new Essential_Grid_Base();
$img_dim = '';
$img_settings = array(
'image-fit' => $base->getVar($this->params, 'image-fit', 'cover'),
'image-repeat' => $base->getVar($this->params, 'image-repeat', 'no-repeat'),
'image-align-horizontal' => $base->getVar($this->params, 'image-align-horizontal', 'center'),
'image-align-vertical' => $base->getVar($this->params, 'image-align-vertical', 'center')
);
if ($order !== false) {
if (isset($this->media_sources[$order . '-width']) && intval($this->media_sources[$order . '-width']) > 0 && isset($this->media_sources[$order . '-height']) && intval($this->media_sources[$order . '-height']) > 0) {
$img_dim = ' width="' . $this->media_sources[$order . '-width'] . '" height="' . $this->media_sources[$order . '-height'] . '"';
}
} else {
$img_dim = (!empty($this->default_image_attr) && isset($this->default_image_attr[0]) && isset($this->default_image_attr[1])) ? ' width="' . $this->default_image_attr[0] . '" height="' . $this->default_image_attr[1] . '"' : '';
}
if (isset($this->media_sources['image-fit']) && $this->media_sources['image-fit'] !== '' && $this->media_sources['image-fit'] !== $img_settings['image-fit']) {
$img_dim .= ' data-bgsize="' . esc_attr($this->media_sources['image-fit']) . '"';
}
if (isset($this->media_sources['image-repeat']) && $this->media_sources['image-repeat'] !== '' && $this->media_sources['image-repeat'] !== $img_settings['image-repeat']) {
$img_dim .= ' data-bgrepeat="' . esc_attr($this->media_sources['image-repeat']) . '"';
}
$img_hor = (isset($this->media_sources['image-align-horizontal']) &&
$this->media_sources['image-align-horizontal'] !== '' &&
$this->media_sources['image-align-horizontal'] !== $img_settings['image-align-horizontal']
) ? $this->media_sources['image-align-horizontal'] : '';
$img_ver = (isset($this->media_sources['image-align-vertical']) &&
$this->media_sources['image-align-vertical'] !== '' &&
$this->media_sources['image-align-vertical'] !== $img_settings['image-align-vertical']
) ? $this->media_sources['image-align-vertical'] : '';
if ($img_hor !== '' || $img_ver !== '') {
if ($img_hor == '') $img_hor = $img_settings['image-align-horizontal'];
if ($img_ver == '') $img_ver = $img_settings['image-align-vertical'];
$img_dim .= ' data-bgposition="' . $img_hor . ' ' . $img_ver . '"';
}
return $img_dim;
}
/**
* check if element is absolute positioned
*/
public function is_absolute_position($ele_class)
{
if (!empty($this->layers_css[$this->id]['idle'])) {
foreach ($this->layers_css[$this->id]['idle'] as $class => $settings) {
if ($class == $ele_class) {
if (!empty($settings)) {
foreach ($settings as $style => $value) {
if ($style == 'position') {
if ($value == 'absolute') {
return true;
}
return false;
}
}
}
return false;
}
}
}
return false;
}
/**
* clean styles that are not needed
* @since: 1.5.4
*/
public function clean_up_styles($styles)
{
if (isset($styles['display'])) {
if ($styles['display'] == 'block') {
if (isset($styles['float'])) unset($styles['float']);
}
if ($styles['display'] == 'inline-block') {
if (isset($styles['text-align'])) unset($styles['text-align']);
}
}
return $styles;
}
/**
* return all styles from all elements
*/
public function generate_element_css($demo = false)
{
$base = new Essential_Grid_Base();
$allowed_wrap_styles = Essential_Grid_Item_Element::get_allowed_styles_for_wrap();
$wait_for_styles = Essential_Grid_Item_Element::get_wait_until_output_styles();
if (!empty($this->layers_css)) {
foreach ($this->layers_css as $layers_css) {
if (!empty($layers_css['idle'])) {
echo '' . "\n";
}
if (!empty($layers_css['hover'])) {
echo '' . "\n";
}
//check for custom css on tags
if (!empty($this->add_css_tags)) {
$allowed_styles = Essential_Grid_Item_Element::get_allowed_styles_for_tags();
foreach ($this->add_css_tags as $class => $tags) {
if (!empty($layers_css['idle'][$class])) {
// we write the idle styles
$d_i = $layers_css['settings'][$class]['important']; //add important or not
foreach ($tags as $tag => $do) {
echo '' . "\n";
}
}
if (!empty($layers_css['hover'][$class])) {
// we write the hover styles
$d_i = $layers_css['settings'][$class]['important']; //add important or not
foreach ($tags as $tag => $do) {
echo '' . "\n";
}
}
}
}
//check for custom css on wrappers for example
if (!empty($this->add_css_wrap)) {
$allowed_cat_tag_styles = Essential_Grid_Item_Element::get_allowed_styles_for_cat_tag();
foreach ($this->add_css_wrap as $class => $tags) {
if (!empty($layers_css['idle'][$class])) {
// we write the idle styles
$d_i = $layers_css['settings'][$class]['important']; //add important or not
foreach ($tags as $tag => $do) {
echo '' . "\n";
}
}
}
}
}
}
if (!empty($this->media_css)) {
foreach ($this->media_css as $skin_id => $media_css) {
if (!empty($media_css)) {
echo '' . "\n";
}
}
}
if (!empty($this->cover_css)) {
foreach ($this->cover_css as $skin_id => $cover_css) {
if (!empty($cover_css) && !empty($this->loaded_skins[$skin_id]['handle'])) {
echo '' . "\n";
}
}
}
if (!empty($this->content_css)) {
foreach ($this->content_css as $skin_id => $content_css) {
if (!empty($content_css) && !empty($this->loaded_skins[$skin_id]['handle'])) {
echo '' . "\n";
}
}
}
if (!empty($this->wrapper_css)) {
foreach ($this->wrapper_css as $skin_id => $wrapper_css) {
if (!empty($wrapper_css) && !empty($this->loaded_skins[$skin_id]['handle'])) {
echo '' . "\n";
}
}
}
if (!empty($this->media_poster_css)) {
foreach ($this->media_poster_css as $skin_id => $media_poster_css) {
if (!empty($media_poster_css) && !empty($this->loaded_skins[$skin_id]['handle'])) {
echo '' . "\n";
}
}
}
}
public function output_element_css_by_meta($id = false, $grid_preview = false)
{
$base = new Essential_Grid_Base();
$disallowed = array('transition', 'transition-delay');
$allowed_wrap_styles = Essential_Grid_Item_Element::get_allowed_styles_for_wrap();
$p_class = ($id === false) ? '' : '.eg-post-' . $id;
if (!empty($this->layers_meta_css['idle'])) {
echo '' . "\n";
}
if (!empty($this->layers_meta_css['hover'])) {
echo '' . "\n";
}
//check for custom css on tags
if (!empty($this->add_css_tags)) {
$allowed_styles = Essential_Grid_Item_Element::get_allowed_styles_for_tags();
foreach ($this->add_css_tags as $class => $tags) {
if (!empty($this->layers_meta_css['idle'][$class])) { // we write the idle styles
$d_i = $this->layers_css[$this->id]['settings'][$class]['important']; //add important or not
foreach ($tags as $tag => $do) {
echo '' . "\n";
}
}
if (!empty($this->layers_meta_css['hover'][$class])) { // we write the hover styles
$d_i = $this->layers_css[$this->id]['settings'][$class]['important']; //add important or not
foreach ($tags as $tag => $do) {
echo '' . "\n";
}
}
}
}
//check for custom css on wrappers for example
if (!empty($this->add_css_wrap)) {
$allowed_cat_tag_styles = Essential_Grid_Item_Element::get_allowed_styles_for_cat_tag();
foreach ($this->add_css_wrap as $class => $tags) {
if (!empty($this->layers_meta_css['idle'][$class])) { // we write the idle styles
$d_i = $this->layers_css[$this->id]['settings'][$class]['important']; //add important or not
foreach ($tags as $tag => $do) {
echo '' . "\n";
}
}
}
}
$this->layers_meta_css = array();
}
/**
* register skin css styles, added for multiskin in one grid + load more
* @since: 2.0
*/
public function register_skin_css()
{
$base = new Essential_Grid_Base();
/* 2.1.6 */
$container_background_color = $base->getVar($this->params, 'container-background-color', '#000');
$contentBgColor = $base->getVar($this->params, 'content-bg-color', '#FFF');
$fullBgColor = $base->getVar($this->params, 'full-bg-color', '#FFF');
if (class_exists('ESGColorpicker')) {
$container_background_color = ESGColorpicker::get($container_background_color);
$contentBgColor = ESGColorpicker::get($contentBgColor);
$fullBgColor = ESGColorpicker::get($fullBgColor);
}
$this->cover_css[$this->id]['background'] = $container_background_color;
$cover_background_image_id = $base->getVar($this->params, 'cover-background-image', 0, 'i');
$cover_background_image_size = $base->getVar($this->params, 'cover-background-size', 'cover');
$cover_background_image_repeat = $base->getVar($this->params, 'cover-background-repeat', 'no-repeat');
$cover_background_image_url = false;
if ($cover_background_image_id > 0) {
$cover_background_image_url = wp_get_attachment_image_src($cover_background_image_id, $this->media_sources_type);
if ($cover_background_image_url !== false) {
$this->cover_css[$this->id]['background-image'] = 'url(' . $cover_background_image_url[0] . ')';
$this->cover_css[$this->id]['background-size'] = $cover_background_image_size;
$this->cover_css[$this->id]['background-repeat'] = $cover_background_image_repeat;
}
}
$this->wrapper_css[$this->id]['background'] = $fullBgColor;
$this->wrapper_css[$this->id]['padding'] = implode('px ', $base->getVar($this->params, 'full-padding', array('0'))) . 'px';
$this->wrapper_css[$this->id]['border-width'] = implode('px ', $base->getVar($this->params, 'full-border', array('0'))) . 'px';
$border_type = $base->getVar($this->params, 'full-border-radius-type', 'px');
$this->wrapper_css[$this->id]['border-radius'] = implode($border_type . ' ', $base->getVar($this->params, 'full-border-radius', array('0'))) . $border_type;
$this->wrapper_css[$this->id]['border-color'] = $base->getVar($this->params, 'full-border-color', '#FFF');
$this->wrapper_css[$this->id]['border-style'] = $base->getVar($this->params, 'full-border-style', 'none');
$overflow = $base->getVar($this->params, 'full-overflow-hidden', 'false');
if ($overflow == 'true') $this->wrapper_css[$this->id]['overflow'] = 'hidden';
$this->media_poster_css[$this->id]['background-size'] = $base->getVar($this->params, 'image-fit', 'cover');
$this->media_poster_css[$this->id]['background-position'] = $base->getVar($this->params, 'image-align-vertical', 'center') . ' ' . $base->getVar($this->params, 'image-align-horizontal', 'center');
$this->media_poster_css[$this->id]['background-repeat'] = $base->getVar($this->params, 'image-repeat', 'no-repeat');
$this->content_css[$this->id]['background'] = $contentBgColor;
$this->content_css[$this->id]['padding'] = implode('px ', $base->getVar($this->params, 'content-padding', array('0'))) . 'px';
$this->content_css[$this->id]['border-width'] = implode('px ', $base->getVar($this->params, 'content-border', array('0'))) . 'px';
$border_type = $base->getVar($this->params, 'content-border-radius-type', 'px');
$this->content_css[$this->id]['border-radius'] = implode($border_type . ' ', $base->getVar($this->params, 'content-border-radius', array('0'))) . $border_type;
$this->content_css[$this->id]['border-color'] = $base->getVar($this->params, 'content-border-color', '#FFF');
$this->content_css[$this->id]['border-style'] = $base->getVar($this->params, 'content-border-style', 'none');
$this->content_css[$this->id]['text-align'] = $base->getVar($this->params, 'content-align', 'left');
$shadow_place = $base->getVar($this->params, 'all-shadow-used', 'none');
$shadow_values = implode('px ', $base->getVar($this->params, 'content-box-shadow', array('0', '0', '0', '0'))) . 'px';
/* 2.1.6 */
$shadow_rgba = $base->getVar($this->params, 'content-shadow-color', '#000000');
/* 2.2.6 */
$shadow_anim = $base->getVar($this->params, 'content-box-shadow-hover', 'false') == 'true';
$inset = $base->getVar($this->params, 'content-box-shadow-inset', 'false') == 'true' ? 'inset ' : '';
if ($shadow_place == 'media') {
if (!$shadow_anim) {
$this->media_css[$this->id]['box-shadow'] = $inset . $shadow_values . ' ' . $shadow_rgba;
} else {
$this->media_css[$this->id]['box-shadow'] = 'none';
$this->media_shadow[$this->id] = $inset . $shadow_values . ' ' . $shadow_rgba;
}
} else if ($shadow_place == 'content') {
if (!$shadow_anim) {
$this->content_css[$this->id]['box-shadow'] = $inset . $shadow_values . ' ' . $shadow_rgba;
} else {
$this->content_css[$this->id]['box-shadow'] = 'none';
$this->content_shadow[$this->id] = $inset . $shadow_values . ' ' . $shadow_rgba;
}
} else if ($shadow_place == 'both') {
if (!$shadow_anim) {
$this->wrapper_css[$this->id]['box-shadow'] = $inset . $shadow_values . ' ' . $shadow_rgba;
} else {
$this->wrapper_css[$this->id]['box-shadow'] = 'none';
$this->wrapper_shadow[$this->id] = $inset . $shadow_values . ' ' . $shadow_rgba;
}
} else if ($shadow_place == 'cover') {
/* 2.2.6 */
$cover_direction = $base->getVar($this->params, 'cover-animation-center-type', '');
$cover_type = $base->getVar($this->params, 'cover-type', 'full');
if ($cover_type === 'content') $shadow_anim = false;
if (!$shadow_anim || $cover_direction === 'out') {
$this->cover_css[$this->id]['box-shadow'] = 'inset ' . $shadow_values . ' ' . $shadow_rgba;
}
if ($shadow_anim) {
if ($cover_direction !== 'out') {
$this->cover_css[$this->id]['box-shadow'] = 'none';
$this->cover_shadow[$this->id] = 'inset ' . $shadow_values . ' ' . $shadow_rgba;
} else {
$this->cover_shadow[$this->id] = 'none';
}
}
}
}
/**
* register layer css styles, added for multiskin in one grid + load more
* @since: 2.0
*/
public function register_layer_css($layer = false, $demo = false)
{
$base = new Essential_Grid_Base();
if ($layer === false) {
if (!empty($this->layers)) {
foreach ($this->layers as $layer) {
$this->register_layer_css($layer, $demo);
}
}
} else {
$is_post = (!empty($this->layer_values)) ? false : true;
if (isset($layer['id'])) $unique_class = 'eg-' . esc_attr($this->handle) . '-element-' . $layer['id'];
else $unique_class = "";
$special_item = $base->getVar($layer, array('settings', 'special'), 'false');
if ($special_item != 'true') {
$this->add_element_css(@$layer['settings'], $unique_class); //add css to queue
}
/**
* not that elegant since code already existed and is now split but currently there is no better implementation than this
* $text is now parsed two times for each layer because of this to get if there is an a tag in the text -> settings display styles correctly...
* NOTE: most of the if(isset($layer['settings']['source'])){} could be removed if it is sure, that there can not be ANY tag in it. Then it can just be replaced with a placeholdertext
*/
$m = new Essential_Grid_Meta();
$text = '';
$do_limit = true;
$do_display = true;
$do_full = false;
$do_ignore_styles = false;
if (isset($layer['settings']['source'])) {
$separator = $base->getVar($layer, array('settings', 'source-separate'), ',');
$catmax = $base->getVar($layer, array('settings', 'source-catmax'), '-1');
$meta = $base->getVar($layer, array('settings', 'source-meta'), '');
$func = $base->getVar($layer, array('settings', 'source-function'), 'link');
$taxonomy = $base->getVar($layer, array('settings', 'source-taxonomy'), '');
switch ($layer['settings']['source']) {
case 'post':
if ($demo === false) {
if ($is_post)
$text = $this->get_post_value($layer['settings']['source-post'], $separator, $func, $meta, $catmax, $taxonomy);
else
$text = $this->get_custom_element_value($layer['settings']['source-post'], $separator, $meta);
} elseif ($demo === 'custom') {
$text = $this->get_custom_element_value($layer['settings']['source-post'], $separator, $meta);
} else {
$post_text = Essential_Grid_Item_Element::getPostElementsArray();
if (array_key_exists(@$layer['settings']['source-post'], $post_text)) $text = $post_text[@$layer['settings']['source-post']]['name'];
if ($layer['settings']['source-post'] == 'date') {
$da = get_option('date_format');
if ($da !== false)
$text = date(get_option('date_format'));
else
$text = date('Y.m.d');
}
}
if ($layer['settings']['source-post'] == 'cat_list' || $layer['settings']['source-post'] == 'tag_list') {
//no limiting if category or tag list
$do_limit = true;
$do_display = false;
$do_full = true;
}
$post_id = (isset($this->post) && isset($this->post['ID'])) ? $this->post['ID'] : '';
$text = apply_filters('essgrid_post_meta_content', $text, $layer['settings']['source-post'], $post_id, $this->post);
break;
case 'woocommerce':
if (Essential_Grid_Woocommerce::is_woo_exists()) {
if ($demo === false) {
if ($is_post)
$text = $this->get_woocommerce_value($layer['settings']['source-woocommerce'], $separator, $catmax);
else
$text = $this->get_custom_element_value($layer['settings']['source-woocommerce'], $separator, '');
if ($layer['settings']['source-woocommerce'] == 'wc_categories') {
$do_limit = false;
$do_display = false;
$do_full = true;
} elseif ($layer['settings']['source-woocommerce'] == 'wc_add_to_cart_button') {
$do_limit = false;
}
} elseif ($demo === 'custom') {
$text = $this->get_custom_element_value($layer['settings']['source-woocommerce'], $separator, '');
if ($layer['settings']['source-woocommerce'] == 'wc_categories') {
$do_limit = false;
$do_display = false;
$do_full = true;
} elseif ($layer['settings']['source-woocommerce'] == 'wc_add_to_cart_button') {
$do_limit = false;
}
} else {
$tmp_wc = Essential_Grid_Woocommerce::get_meta_array();
foreach ($tmp_wc as $handle => $name) {
$woocommerce[$handle]['name'] = $name;
}
if (array_key_exists(@$layer['settings']['source-woocommerce'], $woocommerce)) $text = $woocommerce[@$layer['settings']['source-woocommerce']]['name'];
}
}
break;
case 'icon':
$text = '';
break;
case 'text':
$text = @$layer['settings']['source-text'];
if ($demo === false) {
//check for metas by %meta%
if ($is_post) {
if (isset($this->post['ID']))
$text = $m->replace_all_meta_in_text(@$this->post['ID'], $text);
} else {
$_a = (!empty($this->layer_values)) ? $this->layer_values : array();
$_b = (!empty($this->media_sources)) ? $this->media_sources : array();
$_values = array_merge($_a, $_b);
$text = $m->replace_all_custom_element_meta_in_text($_values, $text);
}
}
$do_display = false;
if (isset($layer['settings']['source-text-style-disable']) && @$layer['settings']['source-text-style-disable'])
$do_ignore_styles = true;
break;
}
if ($do_limit) {
$limit_by = $base->getVar($layer, array('settings', 'limit-type'), 'none');
if ($limit_by !== 'none') {
switch ($layer['settings']['source']) {
case 'post':
case 'event':
case 'woocommerce':
$text = $base->get_text_intro($text, $base->getVar($layer, array('settings', 'limit-num'), 10, 'i'), $limit_by);
break;
}
}
}
// 2.2.6
$min_height = $base->getVar($layer, array('settings', 'min-height'), '0');
$max_height = $base->getVar($layer, array('settings', 'max-height'), 'none');
if ($min_height != '0' || $max_height !== 'none') {
$span = '' . $text . '';
}
}
$link_to = $base->getVar($layer, array('settings', 'link-type'), 'none');
if ($link_to !== 'none') $do_display = true;
//very basic in relation to original, just add a tag around text so that it works (note: href is mandatory here! Not sure why though)
switch ($link_to) {
case 'post':
case 'url':
case 'meta':
case 'javascript':
case 'lightbox':
case 'sharefacebook':
case 'sharetwitter':
case 'sharepinterest':
case 'likepost':
$text = '' . $text . '';
break;
case 'embedded_video':
case 'ajax':
break;
}
if ($base->text_has_certain_tag($text, 'a') && !$do_ignore_styles) {
$this->add_css_wrap[$unique_class]['a']['display'] = $do_display; //do_display defines if we should write display: block;
$this->add_css_wrap[$unique_class]['a']['full'] = $do_full; //do full styles (for categories and tags separator)
}
}
}
/**
* add all styles from an element to queue
*/
public function add_element_css($settings, $element_class)
{
//check if element_class already set, only proceed if it is not set
if (isset($this->layers_css[$this->id]['idle'][$element_class])) return true;
$idle = array();
$hover = array();
$do_hover = false;
$do_important = '';
if (isset($settings['enable-hover']) && $settings['enable-hover'] == 'on') $do_hover = true;
if (isset($settings['force-important']) && $settings['force-important'] == 'true') $do_important = ' !important';
if (!empty($settings)) {
$attributes = Essential_Grid_Item_Element::get_existing_elements(true);
foreach ($attributes as $style => $attr) {
if ($attr['style'] == 'hover' && !$do_hover) continue;
if (!isset($settings[$style]) || empty($settings[$style]) || $settings[$style] == '') continue;
if ($attr['style'] != 'idle' && $attr['style'] != 'hover') continue;
$set_style = ($attr['style'] == 'idle') ? $style : str_replace('-hover', '', $style);
if ($attr['type'] == 'multi-text') {
if (!isset($settings[$style . '-unit'])) $settings[$style . '-unit'] = 'px';
$set_unit = $settings[$style . '-unit'];
if ($set_style == 'box-shadow' || $set_style == 'background-color') {
$multi_string = '';
foreach ($settings[$style] as $val) {
$multi_string .= $val . $set_unit . ' ';
}
//get box shadow color
$shadow_color = ($attr['style'] == 'idle') ? $settings['shadow-color'] : $settings['shadow-color-hover'];
$multi_string .= ' ' . $shadow_color;
if ($attr['style'] == 'idle') {
$idle['-moz-' . $set_style] = $multi_string;
$idle['-webkit-' . $set_style] = $multi_string;
$idle[$set_style] = $multi_string;
} else {
$hover['-moz-' . $set_style] = $multi_string;
$hover['-webkit-' . $set_style] = $multi_string;
$hover[$set_style] = $multi_string;
}
} elseif ($set_style == 'border') {
if ($attr['style'] == 'idle') {
$idle['border-top-width'] = (isset($settings[$style][0])) ? $settings[$style][0] . $set_unit : '0' . $set_unit;
$idle['border-right-width'] = (isset($settings[$style][1])) ? $settings[$style][1] . $set_unit : '0' . $set_unit;
$idle['border-bottom-width'] = (isset($settings[$style][2])) ? $settings[$style][2] . $set_unit : '0' . $set_unit;
$idle['border-left-width'] = (isset($settings[$style][3])) ? $settings[$style][3] . $set_unit : '0' . $set_unit;
} else {
$hover['border-top-width'] = (isset($settings[$style][0])) ? $settings[$style][0] . $set_unit : '0' . $set_unit;
$hover['border-right-width'] = (isset($settings[$style][1])) ? $settings[$style][1] . $set_unit : '0' . $set_unit;
$hover['border-bottom-width'] = (isset($settings[$style][2])) ? $settings[$style][2] . $set_unit : '0' . $set_unit;
$hover['border-left-width'] = (isset($settings[$style][3])) ? $settings[$style][3] . $set_unit : '0' . $set_unit;
}
} else {
$multi_string = '';
foreach ($settings[$style] as $val) {
$multi_string .= $val . $set_unit . ' ';
}
if ($attr['style'] == 'idle') {
$idle[$set_style] = $multi_string;
} else {
$hover[$set_style] = $multi_string;
}
}
} else {
if ($set_style == 'background-color' || $set_style == 'background') {
$bg_color_rgba = $settings[$style];
if (class_exists('ESGColorpicker')) $bg_color_rgba = ESGColorpicker::get($bg_color_rgba);
if ($attr['style'] == 'idle') {
$idle['background'] = $bg_color_rgba;
} else {
$hover['background'] = $bg_color_rgba;
}
} else {
if ($set_style == 'border') {
if ($attr['style'] == 'idle') {
$idle['border-style'] = 'solid';
} else {
$hover['border-style'] = 'solid';
}
}
if ($set_style == 'font-style' && $settings[$style] == 'true') $settings[$style] = 'italic';
$set_unit = @$attributes[$style]['unit'];
if ($attr['style'] == 'idle') {
$idle[$set_style] = $settings[$style] . $set_unit;
if ($set_style == 'position' && $settings[$style] == 'absolute') {
$idle['height'] = 'auto';
$idle['width'] = 'auto';
switch ($settings['align']) {
case 't_l':
$idle['top'] = $settings['top-bottom'] . $settings['absolute-unit'];
$idle['left'] = $settings['left-right'] . $settings['absolute-unit'];
break;
case 't_r':
$idle['top'] = $settings['top-bottom'] . $settings['absolute-unit'];
$idle['right'] = $settings['left-right'] . $settings['absolute-unit'];
break;
case 'b_l':
$idle['bottom'] = $settings['top-bottom'] . $settings['absolute-unit'];
$idle['left'] = $settings['left-right'] . $settings['absolute-unit'];
break;
case 'b_r':
$idle['bottom'] = $settings['top-bottom'] . $settings['absolute-unit'];
$idle['right'] = $settings['left-right'] . $settings['absolute-unit'];
break;
}
}
} else {
$hover[$set_style] = $settings[$style] . $set_unit;
}
}
}
}
}
$this->layers_css[$this->id]['idle'][$element_class] = $idle;
$this->layers_css[$this->id]['hover'][$element_class] = $hover;
$this->layers_css[$this->id]['settings'][$element_class]['important'] = $do_important;
}
/**
* set all demo filter categories like Post Title, WooCommerce, Event Calendar and even/masonry
*/
public function set_filter($filter)
{
$this->filter = $filter;
}
/**
* set all demo filter categories like Post Title, WooCommerce, Event Calendar and even/masonry
*/
public function set_demo_filter()
{
$filter = array();
if (isset($this->params['choose-layout'])) {
$filter[] = array('slug' => $this->params['choose-layout']); //even || masonry
}
if (!empty($this->layers)) {
foreach ($this->layers as $layer) {
if (!isset($layer['settings']) || !isset($layer['settings']['source'])) continue;
switch ($layer['settings']['source']) {
case 'post':
case 'woocommerce':
case 'event':
if (!in_array($layer['settings']['source'], $filter)) $filter[] = array('slug' => $layer['settings']['source']);
break;
}
}
}
$this->filter = $filter;
}
/**
* set all demo filter categories like Post Title, WooCommerce, Event Calendar and even/masonry
*/
public function set_skin_choose_filter()
{
$filter = array();
if (isset($this->params['choose-layout'])) {
$filter[] = array('slug' => $this->params['choose-layout']); //even || masonry
}
$this->filter = $filter;
}
/**
* set demo image
*/
public function set_image($img)
{
$this->cover_image = $img;
}
/**
* set default image by id
* @since: 1.2.0
*/
public function set_default_image_by_id($img_id)
{
$img = wp_get_attachment_image_src($img_id, 'full');
/* 2.1.5 */
if ($img === false) {
$img = get_option('tp_eg_global_default_img', '');
$img = !empty($img) ? wp_get_attachment_image_src($img, 'full') : false;
}
if ($img !== false) {
$this->default_image = $img[0];
$this->default_image_attr = array($img[1], $img[2]);
}
}
/**
* set grid item animation
* @since: 2.1.6.2
*/
public function set_grid_item_animation($base, $params)
{
$this->grid_item_animation = $base->getVar($params, 'grid-item-animation', 'none');
$this->grid_item_animation_other = $base->getVar($params, 'grid-item-animation-other', 'none');
$this->grid_item_animation_zoomin = $base->getVar($params, 'grid-item-animation-zoomin', '125');
$this->grid_item_other_zoomin = $base->getVar($params, 'grid-item-other-zoomin', '125');
$this->grid_item_animation_zoomout = $base->getVar($params, 'grid-item-animation-zoomout', '75');
$this->grid_item_other_zoomout = $base->getVar($params, 'grid-item-other-zoomout', '75');
$this->grid_item_animation_fade = $base->getVar($params, 'grid-item-animation-fade', '75');
$this->grid_item_other_fade = $base->getVar($params, 'grid-item-other-fade', '75');
$this->grid_item_animation_blur = $base->getVar($params, 'grid-item-animation-blur', '5');
$this->grid_item_other_blur = $base->getVar($params, 'grid-item-other-blur', '5');
$this->grid_item_animation_shift = $base->getVar($params, 'grid-item-animation-shift', 'top');
$this->grid_item_other_shift = $base->getVar($params, 'grid-item-other-shift', 'top');
$this->grid_item_animation_shift_amount = $base->getVar($params, 'grid-item-animation-shift-amount', '10');
$this->grid_item_other_shift_amount = $base->getVar($params, 'grid-item-other-shift-amount', '10');
$this->grid_item_animation_rotate = $base->getVar($params, 'grid-item-animation-rotate', '30');
$this->grid_item_other_rotate = $base->getVar($params, 'grid-item-other-rotate', '30');
}
/**
* set default image
* @since: 1.2.0
*/
public function set_default_image($img)
{
$this->default_image = $img;
}
/**
* set youtube default image by id
* @since: 2.1.0
*/
public function set_default_youtube_image_by_id($img_id)
{
$img = wp_get_attachment_image_src($img_id, 'full');
if ($img !== false) {
$this->default_youtube_image = $img[0];
}
}
/**
* set youtube default image by id
* @since: 2.1.0
*/
public function set_default_vimeo_image_by_id($img_id)
{
$img = wp_get_attachment_image_src($img_id, 'full');
if ($img !== false) {
$this->default_vimeo_image = $img[0];
}
}
/**
* set youtube default image by id
* @since: 2.1.0
*/
public function set_default_html_image_by_id($img_id)
{
$img = wp_get_attachment_image_src($img_id, 'full');
if ($img !== false) {
$this->default_html_image = $img[0];
}
}
/**
* set demo image
*/
public function set_media_sources($sources)
{
$this->media_sources = apply_filters('essgrid_item_skin_set_media_sources', $sources, $this->grid_id, $this->grid_params);
}
/**
* set demo image
*/
public function set_media_sources_type($sources_type)
{
$this->media_sources_type = apply_filters('essgrid_item_skin_set_media_sources_type', $sources_type);
}
/**
* set google fonts
*/
private function import_google_fonts()
{
$base = new Essential_Grid_Base();
$this->google_fonts = $base->getVar($this->params, 'google-fonts', '');
}
/**
* return if lightbox needs to be loaded
*/
public function do_lightbox_loading()
{
return $this->load_lightbox;
}
/**
* return if lightbox needs to be loaded
*/
public function output_lighbox_css($css_id, $params)
{
$base = new Essential_Grid_Base();
$override_colors = $base->getVar($params, 'lightbox-override-ui-colors', 'off');
if ('on' !== $override_colors) return;
$css = "
.esgbox-container-%CSS_ID%.esgbox-is-open .esgbox-bg {opacity: 1}
.esgbox-container-%CSS_ID% .esgbox-bg {background: %OVERLAY_COLOR% }
.esgbox-container-%CSS_ID% .esgbox-button {background: %UI_BG_COLOR% !important}
.esgbox-container-%CSS_ID% .esgbox-button svg path {fill: %UI_COLOR%}
.esgbox-container-%CSS_ID% .esgbox-button:hover {background: %UI_HOVER_BG_COLOR% !important}
.esgbox-container-%CSS_ID% .esgbox-button:hover svg path {fill: %UI_HOVER_COLOR%}
.esgbox-container-%CSS_ID% .esgbox-caption {color: %UI_TEXT_COLOR%}
";
$overlay_color = $base->getVar($params, 'lightbox-overlay-bg-color', 'rgba(30,30,30,0.9)');
$ui_bg_color = $base->getVar($params, 'lightbox-ui-bg-color', '#28303d');
$ui_color = $base->getVar($params, 'lightbox-ui-color', '#ffffff');
$ui_hover_bg_color = $base->getVar($params, 'lightbox-ui-hover-bg-color', '#000000');
$ui_hover_color = $base->getVar($params, 'lightbox-ui-hover-color', '#ffffff');
$ui_text_color = $base->getVar($params, 'lightbox-ui-text-color', '#eeeeee');
$css = str_replace(
array('%CSS_ID%', '%OVERLAY_COLOR%', '%UI_BG_COLOR%', '%UI_COLOR%', '%UI_HOVER_BG_COLOR%', '%UI_HOVER_COLOR%', '%UI_TEXT_COLOR%'),
array($css_id, $overlay_color, $ui_bg_color, $ui_color, $ui_hover_bg_color, $ui_hover_color, $ui_text_color),
$css
);
$n = '';
if ($css !== false) {
$n = '' . "\n";
}
return apply_filters('essgrid_output_lighbox_css', $n, $params);
}
/**
* register google fonts to header
*/
public function register_google_fonts()
{
$http = (is_ssl()) ? 'https' : 'http';
if (!empty($this->google_fonts)) {
foreach ($this->google_fonts as $font) {
if ($font !== '') {
wp_register_style('eg-google-font-' . sanitize_title($font), $http . '://fonts.googleapis.com/css?family=' . strip_tags($font));
wp_enqueue_style('eg-google-font-' . sanitize_title($font));
}
}
}
}
/**
* Check Advanced Rules of layer to see if should be shown or not
* @since: 1.5.0
*/
public function check_advanced_rules($layer, $post)
{
$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);
$is_post = (!empty($this->layer_values)) ? false : true;
$rules = $base->getVar($layer, array('settings', 'adv-rules'), array());
$show = $base->getVar($rules, 'ar-show', 'show');
$logic = $base->getVar($rules, 'ar-logic', array('and', 'and', 'and', 'and', 'and', 'and'));
$logic_glob = $base->getVar($rules, 'ar-logic-glob', array('and', 'and'));
//define return values. They change depending on if we want to show or hide if values meet requirements
$suc = ($show == 'show') ? true : false;
$fail = ($show == 'show') ? false : true;
if (!empty($rules)) {
foreach ($rules['ar-type'] as $key => $value) {
$delete = false;
switch ($value) {
case 'meta':
if (trim($rules['ar-meta'][$key]) == '')
$delete = true;
break;
case 'off':
$delete = true;
break;
}
if ($delete === false) {
//check if operator between. If yes and value or value-2 empty, delete
if ($rules['ar-operator'][$key] == 'between') {
if (trim($rules['ar-value'][$key]) == '' || trim($rules['ar-value-2'][$key]) == '') $delete = true;
}
}
if ($delete) {
unset($rules['ar-value'][$key]);
unset($rules['ar-operator'][$key]);
unset($rules['ar-type'][$key]);
unset($rules['ar-meta'][$key]);
unset($rules['ar-value-2'][$key]);
}
}
$results = array();
if (!empty($rules['ar-type'])) {
foreach ($rules['ar-type'] as $key => $value) {
$my_val = '';
switch ($value) {
case 'meta':
if ($is_post) {
if (strpos($rules['ar-meta'][$key], 'eg-') === 0) {
if (!empty($m)) {
foreach ($m as $me) {
if ('eg-' . $me['handle'] == $rules['ar-meta'][$key]) {
$my_val = $meta->get_meta_value_by_handle($post['ID'], $rules['ar-meta'][$key]);
break;
}
}
}
} elseif (strpos($rules['ar-meta'][$key], 'egl-') === 0) {
if (!empty($lm)) {
foreach ($lm as $me) {
if ('egl-' . $me['handle'] == $rules['ar-meta'][$key]) {
$my_val = $link_meta->get_link_meta_value_by_handle($post['ID'], $rules['ar-meta'][$key]);
break;
}
}
}
} else {
$my_val = get_post_meta($post['ID'], $rules['ar-meta'][$key], true);
}
} else {
$my_val = @$this->layer_values[$rules['ar-meta'][$key]];
}
break;
case 'featured-image':
case 'alternate-image':
case 'content-image':
case 'youtube':
case 'vimeo':
case 'wistia':
case 'soundcloud':
case 'content-youtube':
case 'content-vimeo':
case 'content-wistia':
case 'content-soundcloud':
case 'iframe':
case 'content-iframe':
if ($this->item_media_type == $value) {
$my_val = @$this->media_sources[$value];
}
break;
case 'html5':
case 'content-html5':
if ($this->item_media_type == $value) {
$my_val = @$this->media_sources[$value]['mp4'] . @$this->media_sources[$value]['webm'] . @$this->media_sources[$value]['ogv'];
}
break;
default:
if ($this->item_media_type == $value) {
$my_val = apply_filters('essgrid_set_media_source', $my_val, $value, @$this->media_sources);
}
break;
}
switch ($rules['ar-operator'][$key]) {
case 'lt':
$results[$key] = ($my_val < $rules['ar-value'][$key]) ? true : false;
break;
case 'lte':
$results[$key] = ($my_val <= $rules['ar-value'][$key]) ? true : false;
break;
case 'gt':
$results[$key] = ($my_val > $rules['ar-value'][$key]) ? true : false;
break;
case 'gte':
$results[$key] = ($my_val >= $rules['ar-value'][$key]) ? true : false;
break;
case 'equal':
$results[$key] = ($my_val === $rules['ar-value'][$key]) ? true : false;
break;
case 'notequal':
$results[$key] = ($my_val !== $rules['ar-value'][$key]) ? true : false;
break;
case 'between':
$results[$key] = ($my_val > $rules['ar-value'][$key] && $my_val < $rules['ar-value-2'][$key]) ? true : false;
break;
case 'isset':
$results[$key] = (trim($my_val) !== '' || !empty($my_val)) ? true : false;
break;
case 'empty':
$results[$key] = (trim($my_val) === '') ? true : false;
break;
}
}
}
if (!empty($results)) {
$part = array();
$pnr = 0;
$log = 0;
for ($i = 0; $i < 9; $i = $i + 3) {
$first = (isset($results[$i])) ? true : false;
$second = (isset($results[$i + 1])) ? true : false;
$third = (isset($results[$i + 2])) ? true : false;
if ($first && $second) {
if ($third) { //all three exist
if ($logic[$log] == 'and' && $logic[$log + 1] == 'and') {
$part[$pnr] = ($results[$i] === true && $results[$i + 1] === true && $results[$i + 2] === true) ? true : false;
} elseif ($logic[$log] == 'and' && $logic[$log + 1] == 'or') {
$part[$pnr] = ($results[$i] === true && $results[$i + 1] === true || $results[$i + 2] === true) ? true : false;
} elseif ($logic[$log] == 'or' && $logic[$log + 1] == 'and') {
$part[$pnr] = ($results[$i] === true || $results[$i + 1] === true && $results[$i + 2] === true) ? true : false;
} elseif ($logic[$log] == 'or' && $logic[$log + 1] == 'or') {
$part[$pnr] = ($results[$i] === true || $results[$i + 1] === true || $results[$i + 2] === true) ? true : false;
}
} else {
//only first and second exist
if ($logic[$log] == 'and') {
$part[$pnr] = ($results[$i] === true && $results[$i + 1] === true) ? true : false;
} else {
$part[$pnr] = ($results[$i] === true || $results[$i + 1] === true) ? true : false;
}
}
} else {
if ($first) {
if ($first && $third) {
if ($logic[$log + 1] == 'and') {
$part[$pnr] = ($results[$i] === true && $results[$i + 2] === true) ? true : false;
} else {
$part[$pnr] = ($results[$i] === true || $results[$i + 2] === true) ? true : false;
}
} else {
//only first exist
$part[$pnr] = ($results[$i] === true) ? true : false;
}
} elseif ($second) {
if ($second && $third) {
if ($logic[$log + 1] == 'and') {
$part[$pnr] = ($results[$i + 1] === true && $results[$i + 2] === true) ? true : false;
} else {
$part[$pnr] = ($results[$i + 1] === true || $results[$i + 2] === true) ? true : false;
}
} else {
//only second exist
$part[$pnr] = ($results[$i + 1] === true) ? true : false;
}
} elseif ($third) {
//only third exists
$part[$pnr] = ($results[$i + 2] === true) ? true : false;
} else {
//nothing exists, ignore this part
//do nothing
}
}
$pnr++;
$log += 2;
}
if (!empty($part)) {
//start the && and || operations here
if (isset($part[0]) && isset($part[1]) && isset($part[2])) {
//all three exist
if ($logic_glob[0] == 'and' && $logic[1] == 'and') {
return ($part[0] === true && $part[1] === true && $part[2] === true) ? $suc : $fail;
} elseif ($logic[0] == 'and' && $logic[1] == 'or') {
return ($part[0] === true && $part[1] === true || $part[2] === true) ? $suc : $fail;
} elseif ($logic[0] == 'or' && $logic[1] == 'and') {
return ($part[0] === true || $part[1] === true && $part[2] === true) ? $suc : $fail;
} elseif ($logic[0] == 'or' && $logic[1] == 'or') {
return ($part[0] === true || $part[1] === true || $part[2] === true) ? $suc : $fail;
}
} elseif (isset($part[0]) && isset($part[1])) {
//first two
if ($logic_glob[0] == 'and') {
return ($part[0] === true && $part[1] === true) ? $suc : $fail;
} else {
return ($part[0] === true || $part[1] === true) ? $suc : $fail;
}
} elseif (isset($part[0]) && isset($part[2])) {
//first and last
if ($logic_glob[1] == 'and') {
return ($part[0] === true && $part[2] === true) ? $suc : $fail;
} else {
return ($part[0] === true || $part[2] === true) ? $suc : $fail;
}
} elseif (isset($part[1]) && isset($part[2])) {
//second and last
if ($logic_glob[1] == 'and') {
return ($part[1] === true && $part[2] === true) ? $suc : $fail;
} else {
return ($part[1] === true || $part[2] === true) ? $suc : $fail;
}
} elseif (isset($part[0])) {
//only first
return ($part[0] === true) ? $suc : $fail;
} elseif (isset($part[1])) {
//only second
return ($part[1] === true) ? $suc : $fail;
} elseif (isset($part[2])) {
//only third
return ($part[2] === true) ? $suc : $fail;
}
}
return $fail;
}
}
return $suc;
}
/**
* insert layer
*/
public function insert_layer($layer, $demo = false, $masonry = false, $grid_ids = '', $post_ids = '')
{
$base = new Essential_Grid_Base();
$m = new Essential_Grid_Meta();
$enable_youtube_nocookie = get_option('tp_eg_enable_youtube_nocookie', 'false');
$is_post = (!empty($this->layer_values)) ? false : true;
if ($demo === false) {
$post = $this->post;
$layer_values = $this->layer_values;
} else {
$post['ID'] = '0'; //set default if we are in demo mode
}
//check advanced rules
$show = $this->check_advanced_rules($layer, $post);
if ($show === false) return false;
$position = $base->getVar($layer, 'container', 'tl');
$class = 'top';
switch ($position) {
case 'tl':
$class = 'top';
break;
case 'br':
$class = 'bottom';
break;
case 'c':
$class = 'center';
break;
case 'm':
$class = 'content';
break;
}
if (!isset($layer['settings'])) return false;
$this->register_layer_css($layer, $demo);
if (isset($layer['id'])) $unique_class = 'eg-' . esc_attr($this->handle) . '-element-' . $layer['id'];
else $unique_class = '';
$special_item = $base->getVar($layer, array('settings', 'special'), 'false');
$special_item_type = $base->getVar($layer, array('settings', 'special-type'), 'line-break');
//check if absolute positioned, remove class depending on it
$absolute = $this->is_absolute_position($unique_class);
if ($absolute) {
$class = 'absolute';
}
$hideunderHTML = '';
$hideunderClass = '';
$hideunder = $base->getVar($layer, array('settings', 'hideunder'), 0, 'i');
$hideunderheight = $base->getVar($layer, array('settings', 'hideunderheight'), 0, 'i');
$hideundertype = $base->getVar($layer, array('settings', 'hidetype'), 'visibility');
if ($hideunder > 0) {
$hideunderHTML .= ' data-hideunder="' . $hideunder . '"';
$hideunderClass = 'eg-handlehideunder ';
}
if ($hideunderheight > 0) {
$hideunderHTML .= ' data-hideunderheight="' . $hideunderheight . '"';
$hideunderClass = 'eg-handlehideunder ';
}
if ($hideunderHTML !== '') {
$hideunderHTML .= ' data-hidetype="' . esc_attr($hideundertype) . '"';
}
$delay = '';
$duration = '';
$transition_split = '';
if ($masonry) {
$transition = '';
$data_transition_transition = '';
} else {
$transition = 'esg-' . esc_attr($base->getVar($layer, array('settings', 'transition'), 'fade')) . esc_attr($base->getVar($layer, array('settings', 'transition-type'), ''));
if (isset($layer['id'])) $meta_tran = esc_attr($this->get_meta_element_change($layer['id'], 'transition')); //check if we have meta transition set
else $meta_tran = false;
if ($meta_tran !== false && trim($meta_tran) !== '') $transition = ' esg-' . $meta_tran;
if ($transition == 'esg-none' || $transition == 'esg-noneout' || $base->getVar($layer, array('settings', 'transition-type'), '') == 'always') {
//no transition
$transition = '';
} else {
$delay = ' data-delay="' . round($base->getVar($layer, array('settings', 'delay'), 0) / 100, 2) . '"';
$duration = ' data-duration="' . $base->getVar($layer, array('settings', 'duration'), 'default') . '"';
if (isset($layer['id'])) $meta_tran_delay = $this->get_meta_element_change($layer['id'], 'transition-delay'); //check if we have meta transition-delay set
else $meta_tran_delay = false;
if ($meta_tran_delay !== false)
$delay = ' data-delay="' . round($meta_tran_delay / 100, 2) . '"';
}
// 2.2.5
if ($transition) {
$data_transition_transition = ' data-transition="' . trim($transition) . '"';
$transition = ' esg-transition';
} else {
$data_transition_transition = '';
}
}
$text = '';
$do_limit = true;
$do_display = true;
$do_full = false;
$do_ignore_styles = false;
$is_woo_cats = false;
$is_woo_button = false;
$is_html_source = false;
$is_filter_cat = false;
$demo_element_type = ' data-custom-type="%s"';
if (isset($layer['settings']['source'])) {
$separator = $base->getVar($layer, array('settings', 'source-separate'), ',');
$catmax = $base->getVar($layer, array('settings', 'source-catmax'), '-1');
$meta = $base->getVar($layer, array('settings', 'source-meta'), '');
$func = $base->getVar($layer, array('settings', 'source-function'), 'link');
$taxonomy = $base->getVar($layer, array('settings', 'source-taxonomy'), '');
switch ($layer['settings']['source']) {
case 'post':
if ($demo === false) {
if ($is_post)
$text = $this->get_post_value($layer['settings']['source-post'], $separator, $func, $meta, $catmax, $taxonomy);
else
$text = $this->get_custom_element_value($layer['settings']['source-post'], $separator, $meta);
if ($func == 'filter') $is_filter_cat = true;
} elseif ($demo === 'custom') {
$text = $this->get_custom_element_value($layer['settings']['source-post'], $separator, $meta);
} else {
$post_text = Essential_Grid_Item_Element::getPostElementsArray();
if (array_key_exists(@$layer['settings']['source-post'], $post_text)) $text = $post_text[@$layer['settings']['source-post']]['name'];
if ($layer['settings']['source-post'] == 'date') {
$da = get_option('date_format');
if ($da !== false)
$text = date(get_option('date_format'));
else
$text = date('Y.m.d');
}
}
$demo_element_type = str_replace('%s', $layer['settings']['source-post'], $demo_element_type);
if ($layer['settings']['source-post'] == 'cat_list' || $layer['settings']['source-post'] == 'tag_list') { //no limiting if category or tag list
$do_limit = false;
$do_display = false;
$do_full = true;
}
$text = apply_filters('essgrid_post_meta_content', $text, $layer['settings']['source-post'], $base->getVar($this->post, 'ID'), $this->post);
break;
case 'event':
if ($demo === false) {
} else {
$event = Essential_Grid_Item_Element::getEventElementsArray();
if (array_key_exists(@$layer['settings']['source-event'], $event)) $text = $event[@$layer['settings']['source-event']]['name'];
}
$demo_element_type = str_replace('%s', $layer['settings']['source-event'], $demo_element_type);
break;
case 'woocommerce':
//check if woocommerce is installed
if ($demo === false) {
if (Essential_Grid_Woocommerce::is_woo_exists()) {
if ($is_post)
$text = $this->get_woocommerce_value($layer['settings']['source-woocommerce'], $separator, $catmax);
else
$text = $this->get_custom_element_value($layer['settings']['source-woocommerce'], $separator, '');
if ($layer['settings']['source-woocommerce'] == 'wc_categories') {
$do_limit = false;
$do_display = false;
$do_full = true;
$is_woo_cats = true;
} elseif ($layer['settings']['source-woocommerce'] == 'wc_add_to_cart_button') {
$do_limit = false;
$is_woo_button = true;
}
}
} elseif ($demo === 'custom') {
if (Essential_Grid_Woocommerce::is_woo_exists()) {
$text = $this->get_custom_element_value($layer['settings']['source-woocommerce'], $separator, '');
if ($layer['settings']['source-woocommerce'] == 'wc_categories') {
$do_limit = false;
$do_display = false;
$do_full = true;
$is_woo_cats = true;
} elseif ($layer['settings']['source-woocommerce'] == 'wc_add_to_cart_button') {
$do_limit = false;
$is_woo_button = true;
}
}
} else {
if (Essential_Grid_Woocommerce::is_woo_exists()) {
$tmp_wc = Essential_Grid_Woocommerce::get_meta_array();
foreach ($tmp_wc as $handle => $name) {
$woocommerce[$handle]['name'] = $name;
}
if (array_key_exists(@$layer['settings']['source-woocommerce'], $woocommerce)) $text = $woocommerce[@$layer['settings']['source-woocommerce']]['name'];
}
}
$demo_element_type = str_replace('%s', $layer['settings']['source-woocommerce'], $demo_element_type);
break;
case 'icon':
$text = '';
$demo_element_type = '';
break;
case 'text':
$text = @$layer['settings']['source-text'];
if ($demo === false) {
//check for metas by %meta%
if ($is_post) {
$text = $m->replace_all_meta_in_text($this->post['ID'], $text);
} else {
$_a = (!empty($this->layer_values)) ? $this->layer_values : array();
$_b = (!empty($this->media_sources)) ? $this->media_sources : array();
$_values = array_merge($_a, $_b);
$text = $m->replace_all_custom_element_meta_in_text($_values, $text);
}
}
//run shortcodes before apply libxml fix, because it break shortcodes in attributes
$text = do_shortcode($text);
// Fix html tags
libxml_use_internal_errors(true);
$text_xml = "";
if (class_exists('DOMDocument') && defined('LIBXML_HTML_NOIMPLIED') && defined('LIBXML_HTML_NODEFDTD')) {
$dom = new DOMDocument();
$dom->loadHTML('' . mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8') . '', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$text_xml = substr($dom->saveHTML(), 6, -8);
}
if (!empty($text_xml)) $text = $text_xml;
if ($demo == 'overview' || $demo == 'skinchoose' || $demo == 'skin-editor') $text = esc_attr($text); // added so that Item Skin Editor can be still used even if wrong formated HTML was added as a layer
if (isset($layer['settings']['source-text-style-disable']) && @$layer['settings']['source-text-style-disable'])
$do_ignore_styles = true;
$do_display = false;
$demo_element_type = '';
$is_html_source = true;
break;
default:
$demo_element_type = '';
}
if ($do_limit) {
$limit_by = $base->getVar($layer, array('settings', 'limit-type'), 'none');
if ($limit_by !== 'none') {
switch ($layer['settings']['source']) {
case 'post':
case 'event':
case 'woocommerce':
if (!in_array($base->getVar($layer, array('settings', 'source-post'), ''), array('taxonomy', 'cat_list', 'tag_list')))
$text = $base->get_text_intro($text, $base->getVar($layer, array('settings', 'limit-num'), 10, 'i'), $limit_by);
break;
}
}
}
// 2.2.6
$min_height = $base->getVar($layer, array('settings', 'min-height'), '0');
$max_height = $base->getVar($layer, array('settings', 'max-height'), 'none');
if ($min_height != '0' || $max_height !== 'none') {
$span = '' . $text . '';
}
}
$link_to = $base->getVar($layer, array('settings', 'link-type'), 'none');
$link_target = $base->getVar($layer, array('settings', 'link-target'), '_self');
if ($link_target !== 'disabled')
$link_target = ' target="' . esc_attr($link_target) . '"';
else
$link_target = '';
$link_rel_nofollow = $base->getVar($layer, array('settings', 'rel-nofollow'), 'false');
if ($link_rel_nofollow === 'true')
$link_rel_nofollow = ' rel="nofollow"';
else
$link_rel_nofollow = '';
$video_play = '';
$ajax_class = '';
$ajax_attr = '';
$lb_class = '';
switch ($link_to) {
case 'post':
if ($demo === false) {
if ($is_post) {
$text = '' . $text . '';
} else {
$get_link = $this->get_custom_element_value('post-link', $separator, ''); //get the post link
/* 2.1.5 */
// fix for grids populated with WP Media Galleries
if ($get_link == '') {
if (isset($this->layer_values['custom-image']) && !empty($this->layer_values['custom-image'])) {
$text = '' . $text . '';
} else {
$text = '' . $text . '';
}
} else {
/* 2.1.6 append "http" to manually written links starting with "www" */
$get_link = esc_attr($get_link);
if (strpos($get_link, '://') === false) {
$get_link = !is_ssl() ? 'http://' . $get_link : 'https://' . $get_link;
}
$text = '' . preg_replace('/(.*?)<\/a>/', "\\2", $text) . '';
}
}
} else {
$text = '' . $text . '';
}
break;
case 'url':
$lurl = $base->getVar($layer, array('settings', 'link-type-url'), 'javascript:void(0);');
if (strpos($lurl, '://') === false && trim($lurl) !== '' && $lurl !== 'javascript:void(0);') {
$lurl = (is_ssl()) ? 'https://' . $lurl : 'http://' . $lurl;
}
$text = '' . $text . '';
break;
case 'meta':
if ($demo === false) {
if ($is_post) {
$meta_key = $base->getVar($layer, array('settings', 'link-type-meta'), 'javascript:void(0);');
$meta_link = $m->get_meta_value_by_handle($post['ID'], $meta_key);
if ($meta_link == '') {
// if empty, link to nothing
$text = '' . $text . '';
} else {
/* 2.1.6 append "http" to manually written links starting with "www" */
$meta_link = esc_attr($meta_link);
if ((strpos($meta_link, '://') === false) && (strpos($meta_link, 'mailto:') === false)) {
$meta_link = !is_ssl() ? 'http://' . $meta_link : 'https://' . $meta_link;
}
$text = '' . $text . '';
}
} else {
$meta_key = $base->getVar($layer, array('settings', 'link-type-meta'), '');
//get the post link
$get_link = $this->get_custom_element_value('post-link', $separator, $meta_key);
if ($get_link == '') {
$text = '' . $text . '';
} else {
/* 2.1.6 append "http" to manually written links starting with "www" */
$get_link = esc_attr($get_link);
if (strpos($get_link, '://') === false) {
$get_link = !is_ssl() ? 'http://' . $get_link : 'https://' . $get_link;
}
$text = '' . $text . '';
}
}
} else {
$text = '' . $text . '';
}
break;
case 'javascript':
$text = '' . $text . ''; //javascript-link
break;
case 'lightbox':
$opt = get_option('tp_eg_use_lightbox', 'false');
if ($opt !== 'disabled') {
//enqueue only if default LightBox is selected
wp_enqueue_script('esg-tp-boxext');
wp_enqueue_style('esg-tp-boxextcss');
}
$lb_source = 'javascript:void(0);';
$lb_addition = '';
$lb_rel = ($this->lb_rel !== false) ? ' data-esgbox="' . esc_attr($this->lb_rel) . '"' : '';
$lb_data = '';
$lb_featured = '';
$lb_post_title = '';
$lb_owidth = '';
$lb_oheight = '';
if (!empty($this->default_lightbox_source_order)) {
//only show if something is checked
foreach ($this->default_lightbox_source_order as $order) {
//go through the order and set media as wished
$val = isset($this->media_sources[$order]) && $this->media_sources[$order] !== '' && $this->media_sources[$order] !== false;
if ($order === 'post-content' || !empty($val)) {
//found entry
$do_continue = false;
$is_video = false;
if (!empty($this->lightbox_additions['items']) && $this->lightbox_additions['base'] == 'on') {
$lb_source = $this->lightbox_additions['items'][0];
$lb_class = ' esgbox';
} else {
switch ($order) {
case 'featured-image':
case 'alternate-image':
case 'content-image':
// 2.2.5
$imgsource = explode('-', $order);
$imgsource = $imgsource[0];
if ($order == 'content-image') $lb_source = $this->media_sources[$order];
else $lb_source = $this->media_sources[$order . '-full'];
$lb_class = ' esgbox';
if (isset($this->media_sources[$imgsource . '-image-full-width'])) $lb_owidth = ' data-width="' . $this->media_sources[$imgsource . '-image-full-width'] . '" ';
if (isset($this->media_sources[$imgsource . '-image-full-height'])) $lb_oheight = ' data-height="' . $this->media_sources[$imgsource . '-image-full-height'] . '" ';
break;
case 'youtube':
$http = (is_ssl()) ? 'https' : 'http';
$enable_youtube_nocookie = get_option('tp_eg_enable_youtube_nocookie', 'false');
$lb_source = $enable_youtube_nocookie != 'false' ? $http . '://www.youtube-nocookie.com/embed/' . $this->media_sources[$order] : $lb_source = $http . '://www.youtube.com/watch?v=' . $this->media_sources[$order];
$lb_class = ' esgbox';
$is_video = true;
$lb_addition = ($this->video_ratios['youtube'] == '1') ? '' : ' data-ratio="4:3"';
break;
case 'vimeo':
$http = (is_ssl()) ? 'https' : 'http';
$lb_source = $http . '://vimeo.com/' . $this->media_sources[$order];
$lb_class = ' esgbox';
$is_video = true;
$lb_addition = ($this->video_ratios['vimeo'] == '1') ? '' : ' data-ratio="4:3"';
break;
case 'wistia':
$lb_source = '//fast.wistia.net/embed/iframe/' . $this->media_sources[$order];
$lb_class = ' esgbox';
$lb_data .= ' data-type="iframe"';
$lb_addition = ($this->video_ratios['wistia'] == '1') ? '' : ' data-ratio="4:3"';
break;
case 'soundcloud':
$lb_source = '//w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' . $this->media_sources[$order] . '&color=%23ff5500&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true';
$lb_class = ' esgbox';
$lb_data .= ' data-type="iframe"';
break;
case 'iframe':
$lb_source = addslashes($this->media_sources[$order]);
$lb_class = ' esgbox';
$lb_data .= ' data-type="iframe"';
break;
case 'html5':
if (trim($this->media_sources[$order]['mp4']) === '' && trim($this->media_sources[$order]['ogv']) === '' && trim($this->media_sources[$order]['webm'] === '')) {
$do_continue = true;
} else {
//check for video poster image
$video_poster_src = '';
if (!empty($this->default_video_poster_order)) {
foreach ($this->default_video_poster_order as $n_order) {
if ($n_order == 'no-image') {
//do not show image so set image empty
$video_poster_src = '';
break;
}
if (isset($this->media_sources[$n_order]) && $this->media_sources[$n_order] !== '' && $this->media_sources[$n_order] !== false) { //found entry
$video_poster_src = $this->media_sources[$n_order];
break;
}
}
}
$lb_mp4 = $this->media_sources[$order]['mp4'];
$lb_ogv = $this->media_sources[$order]['ogv'];
$lb_webm = $this->media_sources[$order]['webm'];
$vid_ratio = ($this->video_ratios['html5'] == '1') ? '' : ' data-ratio="4:3"';
$lb_source = ""; //Leave it Empty, other way HTML5 Video will not work !!
if (!empty($lb_mp4)) {
$lb_source = $lb_mp4;
} elseif (!empty($lb_ogv)) {
$lb_source = $lb_ogv;
} elseif (!empty($lb_webm)) {
$lb_source = $lb_webm;
}
$text = '' . $text;
$lb_class = ' esgbox esgboxhtml5';
$lb_addition = ' data-mp4="' . esc_attr($lb_mp4) . '" data-ogv="' . esc_attr($lb_ogv) . '" data-webm="' . esc_attr($lb_webm) . '"' . $vid_ratio;
$is_video = true;
}
break;
case 'revslider':
$lb_source = 'javascript:void(0);';
$lb_class = ' esgbox esgbox-post';
$lb_data = ' data-post="' . $post_ids . '"';
$lb_data .= ' data-revslider="' . $this->media_sources[$order] . '"';
$lb_data .= ' data-gridid="' . $grid_ids . '" data-ispost="' . $is_post . '"';
break;
case 'essgrid':
$lb_source = 'javascript:void(0);';
$lb_class = ' esgbox esgbox-post';
$lb_data = ' data-post="' . $post_ids . '"';
$lb_data .= ' data-lbesg="' . $this->media_sources[$order] . '"';
$lb_data .= ' data-gridid="' . $grid_ids . '" data-ispost="' . $is_post . '"';
break;
case 'post-content':
$lb_source = 'javascript:void(0);';
$lb_class = ' esgbox esgbox-post';
$lb_data = ' data-post="' . $post_ids . '"';
$lb_data .= ' data-gridid="' . $grid_ids . '" data-ispost="' . $is_post . '"';
$lb_post_title = $is_post ? $base->getVar($this->post, 'post_title', '') : $this->get_custom_element_value('title', $separator, '');
$lb_post_title = ' data-posttitle="' . $lb_post_title . '"';
// if featured full is available
if (isset($this->media_sources['featured-image-full']) && !empty($this->media_sources['featured-image-full'])) {
$lb_featured = ' data-featured="' . esc_attr($this->media_sources['featured-image-full']) . '"';
} // if featured regular size is available
else if (isset($this->media_sources['featured-image']) && !empty($this->media_sources['featured-image'])) {
$lb_featured = ' data-featured="' . esc_attr($this->media_sources['featured-image']) . '"';
} // if global image is available
else if (!empty($this->default_image)) {
$lb_featured = ' data-featured="' . esc_attr($this->default_image) . '"';
}
break;
default:
$do_continue = true;
break;
}
}
if ($do_continue) {
continue;
}
if ($base->getVar($layer, array('settings', 'show-on-lightbox-video'), 'false') == 'true' && $is_video === false) {
return false; //this element is hidden if media is video
}
if ($base->getVar($layer, array('settings', 'show-on-lightbox-video'), 'false') == 'hide' && $is_video === true) {
return false; //this element is hidden if media is video
}
break;
}
/* 2.1.5 */
if ($order === 'featured-image') {
$default_img = $this->default_image;
if (!empty($default_img)) {
$lb_source = $default_img;
$lb_class = ' esgbox';
$lb_owidth = ' data-width="' . $this->default_image_attr[0] . '" ';
$lb_oheight = ' data-height="' . $this->default_image_attr[1] . '" ';
break;
}
}
}
}
$lb_title = $this->get_lightbox_title($demo, $is_post);
$lb_description = $this->get_lightbox_description($demo, $is_post);
$lb_caption = '';
if (!empty($lb_title)) {
$lb_caption .= '
'.$lb_title.'
';
}
if (!empty($lb_description)) {
$lb_caption .= '
'.$lb_description.'
';
}
if (!empty($lb_caption)) {
$lb_caption = ' data-caption="' . esc_attr($lb_caption) . '" ';
}
$text = '' . $text . '';
$this->load_lightbox = true; //set that jQuery is written
break;
case 'embedded_video':
$video_play = ' esg-click-to-play-video';
break;
case 'ajax':
$ajax_class = '';
if (!empty($this->default_ajax_source_order)) {
//only show if something is checked
$ajax_class = ' eg-ajaxclicklistener';
foreach ($this->default_ajax_source_order as $order) {
//go through the order and set media as wished
$do_continue = false;
if (isset($this->media_sources[$order]) && $this->media_sources[$order] !== '' && $this->media_sources[$order] !== false || $order == 'post-content') { //found entry
switch ($order) {
case 'youtube':
$vid_ratio = ($this->video_ratios['youtube'] == '0') ? '4:3' : '16:9';
$ajax_attr = ' data-ajaxtype="youtubeid"'; // postid, html5vid youtubeid vimeoid soundcloud revslider
$ajax_attr .= ' data-ajaxsource="' . esc_attr($this->media_sources[$order]) . '"'; //depending on type
$ajax_attr .= ' data-ajaxvideoaspect="' . $vid_ratio . '"'; //depending on type
break;
case 'vimeo':
$vid_ratio = ($this->video_ratios['vimeo'] == '0') ? '4:3' : '16:9';
$ajax_attr = ' data-ajaxtype="vimeoid"'; // postid, html5vid youtubeid vimeoid soundcloud revslider
$ajax_attr .= ' data-ajaxsource="' . esc_attr($this->media_sources[$order]) . '"'; //depending on type
$ajax_attr .= ' data-ajaxvideoaspect="' . $vid_ratio . '"'; //depending on type
break;
case 'wistia':
$vid_ratio = ($this->video_ratios['wistia'] == '0') ? '4:3' : '16:9';
$ajax_attr = ' data-ajaxtype="wistiaid"'; // postid, html5vid youtubeid vimeoid soundcloud revslider
$ajax_attr .= ' data-ajaxsource="' . esc_attr($this->media_sources[$order]) . '"'; //depending on type
$ajax_attr .= ' data-ajaxvideoaspect="' . $vid_ratio . '"'; //depending on type
break;
case 'html5':
if ($this->media_sources[$order]['mp4'] == ''
&& $this->media_sources[$order]['webm'] == ''
&& $this->media_sources[$order]['ogv'] == '') {
$do_continue = true;
} else {
//mp4/webm/ogv
$vid_ratio = ($this->video_ratios['html5'] == '0') ? '4:3' : '16:9';
$ajax_attr = ' data-ajaxtype="html5vid"'; // postid, html5vid youtubeid vimeoid soundcloud revslider
$ajax_attr .= ' data-ajaxsource="';
$ajax_attr .= esc_attr(@$this->media_sources[$order]['mp4']) . '|';
$ajax_attr .= esc_attr(@$this->media_sources[$order]['webm']) . '|';
$ajax_attr .= esc_attr(@$this->media_sources[$order]['ogv']);
$ajax_attr .= '"';
$ajax_attr .= ' data-ajaxvideoaspect="' . $vid_ratio . '"'; //depending on type
}
break;
case 'soundcloud':
$ajax_attr = ' data-ajaxtype="soundcloudid"'; // postid, html5vid youtubeid vimeoid soundcloud revslider
$ajax_attr .= ' data-ajaxsource="' . esc_attr($this->media_sources[$order]) . '"'; //depending on type
break;
case 'post-content':
if ($is_post) {
$ajax_attr = ' data-ajaxtype="postid"'; // postid, html5vid youtubeid vimeoid soundcloud revslider
$ajax_attr .= ' data-ajaxsource="' . @$this->post['ID'] . '"'; //depending on type
} else {
$do_continue = true;
//$ajax_class = '';
}
break;
case 'featured-image':
case 'alternate-image':
case 'content-image':
$img_url = '';
if ($order == 'content-image')
$img_url = $this->media_sources[$order];
else
$img_url = $this->media_sources[$order . '-full'];
$ajax_attr = ' data-ajaxtype="imageurl"'; // postid, html5vid youtubeid vimeoid soundcloud revslider
$ajax_attr .= ' data-ajaxsource="' . esc_attr($img_url) . '"'; //depending on type
break;
default:
$ajax_class = '';
$do_continue = true;
break;
}
if ($do_continue) {
continue;
}
break;
} else {
//some custom entry maybe
$postobj = ($is_post) ? $this->post : false;
$ajax_attr = apply_filters('essgrid_handle_ajax_content', $order, $this->media_sources, $postobj, $this->grid_id);
if (empty($ajax_attr)) {
$do_continue = true;
}
if ($do_continue) {
continue;
}
break;
}
}
}
if ($ajax_class !== '') {
//set ajax loading to true so that the grid can decide to put ajax container in top/bottom
$this->ajax_loading = true;
}
break;
case 'sharefacebook':
if (isset($layer['settings']['link-type-sharefacebook'])) {
switch ($layer['settings']['link-type-sharefacebook']) {
case 'custom':
$facebook_share_url = $layer['settings']['link-type-sharefacebook-custom-url'];
break;
case 'site':
$facebook_share_url = get_permalink();
break;
default:
if ($is_post) {
$facebook_share_url = get_permalink($post['ID']);
} else {
$get_link = $this->get_custom_element_value('post-link', $separator, '');
$facebook_share_url = $get_link;
}
break;
}
} else {
if ($is_post) {
$facebook_share_url = get_permalink($post['ID']);
} else {
$get_link = $this->get_custom_element_value('post-link', $separator, '');
$facebook_share_url = $get_link;
}
}
$text = '' . $text . '';
break;
case 'sharegplus':
if (isset($layer['settings']['link-type-sharegplus'])) {
switch ($layer['settings']['link-type-sharegplus']) {
case 'custom':
$gplus_share_url = $layer['settings']['link-type-sharegplus-custom-url'];
break;
case 'site':
$gplus_share_url = get_permalink();
break;
default:
if ($is_post) {
$gplus_share_url = get_permalink($post['ID']);
} else {
$get_link = $this->get_custom_element_value('post-link', $separator, '');
$gplus_share_url = $get_link;
}
break;
}
} else {
if ($is_post) {
$gplus_share_url = get_permalink($post['ID']);
} else {
$get_link = $this->get_custom_element_value('post-link', $separator, '');
$gplus_share_url = $get_link;
}
}
$text = '' . $text . '';
break;
case 'sharepinterest':
$title = $excerpt = $img_url = "";
if (isset($layer['settings']['link-type-sharepinterest'])) {
switch ($layer['settings']['link-type-sharepinterest']) {
case 'custom':
$pinterest_share_url = $layer['settings']['link-type-sharepinterest-custom-url'];
break;
case 'site':
$pinterest_share_url = get_permalink();
$title = get_the_title();
$excerpt = get_the_excerpt();
break;
default:
if ($is_post) {
$pinterest_share_url = get_permalink($post['ID']);
$title = get_the_title($post['ID']);
$excerpt = get_the_excerpt($post['ID']);
} else {
$get_link = $this->get_custom_element_value('post-link', $separator, '');
$title = $this->get_custom_element_value('title', $separator, '');
$excerpt = $this->get_custom_element_value('content', $separator, '');
$pinterest_share_url = $get_link;
}
break;
}
} else {
if ($is_post) {
$pinterest_share_url = get_permalink($post['ID']);
$title = get_the_title($post['ID']);
$excerpt = get_the_excerpt($post['ID']);
} else {
$get_link = $this->get_custom_element_value('post-link', $separator, '');
$title = $this->get_custom_element_value('title', $separator, '');
$excerpt = $this->get_custom_element_value('content', $separator, '');
$pinterest_share_url = $get_link;
}
}
// if featured full is available
if (isset($this->media_sources['featured-image-full']) && !empty($this->media_sources['featured-image-full'])) {
$img_url = $this->media_sources['featured-image-full'];
} // if featured regular size is available
else if (isset($this->media_sources['featured-image']) && !empty($this->media_sources['featured-image'])) {
$img_url = $this->media_sources['featured-image'];
} // if global image is available
else if (!empty($this->default_image)) {
$img_url = esc_attr($this->default_image);
}
$description = '';
if (!empty($layer['settings']['link-type-sharepinterest-description'])) {
$description = str_replace(array("%title%", "%excerpt%"), array($title, $excerpt), $layer['settings']['link-type-sharepinterest-description']);
}
$text = '' . $text . '';
break;
case 'sharetwitter':
$title = $excerpt = $img_url = "";
if (isset($layer['settings']['link-type-sharetwitter'])) {
switch ($layer['settings']['link-type-sharetwitter']) {
case 'custom':
$twitter_share_url = $layer['settings']['link-type-sharetwitter-custom-url'];
break;
case 'site':
$twitter_share_url = get_permalink();
$title = get_the_title();
$excerpt = get_the_excerpt();
break;
default:
if ($is_post) {
$twitter_share_url = get_permalink($post['ID']);
$title = get_the_title($post['ID']);
$excerpt = get_the_excerpt($post['ID']);
} else {
$get_link = $this->get_custom_element_value('post-link', $separator, '');
$title = $this->get_custom_element_value('title', $separator, '');
$excerpt = $this->get_custom_element_value('content', $separator, '');
$twitter_share_url = $get_link;
}
break;
}
} else {
if ($is_post) {
$twitter_share_url = get_permalink($post['ID']);
$title = get_the_title($post['ID']);
$excerpt = get_the_excerpt($post['ID']);
} else {
$get_link = $this->get_custom_element_value('post-link', $separator, '');
$title = $this->get_custom_element_value('title', $separator, '');
$excerpt = $this->get_custom_element_value('content', $separator, '');
$twitter_share_url = $get_link;
}
}
if (!empty($layer['settings']['link-type-sharetwitter-text-before'])) {
$twitter_share_text_before = str_replace(array("%title%", "%excerpt%"), array($title, $excerpt), $layer['settings']['link-type-sharetwitter-text-before']);
} else {
$twitter_share_text_before = "";
}
if (!empty($layer['settings']['link-type-sharetwitter-text-after'])) {
$twitter_share_text_after = str_replace(array("%title%", "%excerpt%"), array($title, $excerpt), $layer['settings']['link-type-sharetwitter-text-after']);
} else {
$twitter_share_text_after = "";
}
$twitter_share_text = $twitter_share_text_before;
$text = '' . $text . '';
break;
case 'likepost':
if (!empty($this->post['ID']))
$text = '' . $text . ''; //javascript-link
else $text = '';
break;
}
if ($link_to !== 'none') $do_display = true; //set back to true if a link is set on layer
$text = trim($text);
//check for special styling coming from post option and set css to the queue
if (isset($layer['id'])) $this->set_meta_element_changes($layer['id'], $unique_class);
if ($is_post) {
$post_class = (!isset($post['ID'])) ? '' : ' eg-post-' . $post['ID'];
} else {
$post_class = isset($this->post['post_id']) && !empty($this->post['post_id']) ? ' eg-post-' . $this->post['post_id'] : '';
}
if ($base->text_has_certain_tag($text, 'a') && !$do_ignore_styles) {
//check if a tag exists, if yes, class will be set to a tags and not the wrapping div, also the div will receive the position and other stylings // && @$layer['settings']['source'] !== 'text'
if ($is_woo_cats && strpos($text, 'class="') !== false || $is_woo_button || $is_filter_cat && strpos($text, 'class="') !== false) {
//add to the classes instead of creating own class attribute if it is woocommerce cats AND a class can be found
$text = str_replace('class="', 'class="' . $unique_class . $post_class . $lb_class . ' ', $text);
} elseif ($is_html_source && strpos($text, 'class="') !== false) {
$text = str_replace('handle) . '-nostyle-element-' . $layer['id'];
//replace all the normal shortcodes
if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
//use qTranslate
$text = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($text);
} elseif (function_exists('ppqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
//use qTranslate plus
$text = ppqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($text);
} elseif (function_exists('qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
//use qTranslate X
$text = qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($text);
}
$text = do_shortcode($text);
if ($special_item == 'true' && $special_item_type == 'line-break') {
//line break element
echo ' ' . "\n";
} elseif (trim($text) !== '') {
$use_tag = $base->getVar($layer, array('settings', 'tag-type'), 'div');
echo ' <' . $use_tag . ' class="esg-' . $class . $post_class . $video_play . $ajax_class . ' ' . $hideunderClass . $unique_class . $transition . '"' . $ajax_attr . $transition_split . $delay . $duration . $hideunderHTML;
echo ($demo == 'custom') ? $demo_element_type : '';
echo $data_transition_transition . '>';
echo $text;
echo '' . $use_tag . '>' . "\n";
}
}
/**
* Retrieve the value of post elements
*/
public function get_post_value($handle, $separator, $function, $meta, $catmax = '-1', $taxonomy = "")
{
$base = new Essential_Grid_Base();
$text = '';
/* 2.1.5 category max option */
$adjustMax = false;
if (in_array($handle, array('cat_list', 'tag_list', 'taxonomy'))) {
if (!empty($catmax) && $catmax !== '-1' && is_numeric($catmax) && intval($catmax) > 0) {
$catmax = intval($catmax);
$adjustMax = true;
}
}
switch ($handle) {
//Post elements
case 'post_id':
$text = $base->getVar($this->post, 'ID', '');
break;
case 'post_url':
$post_id = $base->getVar($this->post, 'ID', '');
$text = get_permalink($post_id);
break;
case 'title':
$text = $base->getVar($this->post, 'post_title', '');
break;
case 'caption':
case 'excerpt':
$text = trim($base->getVar($this->post, 'post_excerpt'));
if (empty($text)) {
//strip essential grid shortcode here
$text = do_shortcode($base->strip_essential_shortcode($base->getVar($this->post, 'post_content')));
$text = preg_replace("/