/** * Get a value for the slider configuration (with 'config-') or current project loop * * @param string $var The name of variable * @param array $args * * @return mixed * @since 1.0 * @author Antonino Scarfì <*****@*****.**> */ public function get($var, $args = array()) { // global $post; $defaults = array('post_id' => false, 'echo' => false, 'size' => 'post-thumbnail', 'attr' => '', 'before' => '', 'after' => '', 'container' => true, 'video_width' => 425, 'video_height' => 356, 'content_type' => 'image'); extract(wp_parse_args($args, $defaults)); // general variables if ('baseurl' == $var) { return YIT_Slider()->cptu->locate_url($this->config->layout); } // get from slider config if (strpos($var, 'config-') !== false) { if (!$post_id) { $post_id = $this->config->ID; } $var = str_replace('config-', '', $var); if (isset($this->config->{$var})) { return $this->config->{$var}; } elseif ($var = get_post_meta($post_id, '_' . $this->config->layout . '_' . $var, true)) { return $var; } elseif ($var = get_post_meta($post_id, '_' . $var, true)) { return $var; } else { return null; } } // get from item //if ( ! is_null( $this->query ) ) { if (!$post_id) { global $post; $post_id = $post->ID; } elseif (!$post_id && isset($this->config->ID)) { $post_id = $this->config->ID; } elseif (!isset($this->config->ID)) { return null; } if ('title' == $var) { return get_the_title($post_id); } elseif ('content' == $var) { $content = get_the_content(); if ($echo) { $content = apply_filters('the_content', $content); } return $content; } elseif ('permalink' == $var) { return get_permalink($post_id); } elseif ('image' == $var) { return $this->get_image($size, $attr); } elseif ('featured-content' == $var) { return $this->featured_content($content_type, array('before' => $before, 'after' => $after, 'container' => $container, 'video_width' => $video_width, 'video_height' => $video_height)); } elseif ('ID' == $var) { return $post_id; } elseif ($value = get_post_meta($post_id, '_' . $this->config->layout . '_' . $var, true)) { return $value; } else { return get_post_meta($post_id, '_' . $var, true); } //} }
/** * Add portfolio single layout setup on after setup theme * * @since 2.0.0 * @author Antonio La Rocca <*****@*****.**> */ function init_slider_layouts() { if (function_exists('YIT_Slider')) { add_filter('yit_cptu_' . YIT_Slider()->sliders_post_type . '_layout_values', 'yit_slider_layout_values'); } }
/** * Define the variables for the frontend of the shortcode * * @param $vars * @param $post_type * * @return array * @since 1.0 * @author Antonino Scarfì <*****@*****.**> */ public function frontend_vars($vars, $post_type) { if ($post_type != $this->sliders_post_type) { return $vars; } $vars['slider'] = YIT_Slider()->get_slider($vars['name']); $vars['slider']->init_query(); //wpml fix $vars['post_type'] = $vars['slider']->post_type; $vars['layout'] = $vars['slider']->config->layout; return $vars; }