function widget($args, $instance) { // extracting info extract($args); extract(spyropress_clean_array($instance)); // get view to render include $this->get_view(); }
/** * Clean Css Classes for Class Attribute */ function spyropress_clean_cssclass($classes = array()) { if (empty($classes)) { return false; } //$classes = array_filter( $classes, 'remove_these_classes' ); return implode(' ', spyropress_clean_array($classes)); }
function widget($args, $instance) { // Defaults $defaults = array('tab_position' => 'top', 'tab_align' => 'left'); // extracting info extract($args); extract(wp_parse_args(spyropress_clean_array($instance), $defaults)); // get view to render include $this->get_view(); }
<?php // Setup Instance for view $instance = spyropress_clean_array($instance); $instance['callback'] = array($this, 'generate_item_carousel'); $instance['row'] = false; $instance['columns'] = false; $instance['row_class'] = ''; // tempalte $tmpl = '{content}'; echo '<h1>' . $title . '</h1>'; echo '<div class="owl-carousel owl-carousel-spaced" data-plugin-options=\'{"items": 4}\'>'; // output content echo $this->query($instance, $tmpl); echo '</div>';
<?php spyropress_before_loop(); $counter = 0; $translate['read-more-title'] = get_setting('translate') ? get_setting('read_more_title', 'Read more...') : __('Read more...', 'spyropress'); $args = $this->query(spyropress_clean_array($instance)); $blog_query = new WP_Query($args); ?> <div class="blog-posts"> <section class="timeline"> <div class="timeline-body" id="timeline-body"> <?php if ($blog_query->have_posts()) { while ($blog_query->have_posts()) { $blog_query->the_post(); $date = the_date('', '', '', false); if ($date) { $counter = 0; echo '<div class="timeline-date"><h3>' . $date . '</h3></div>'; } $post_alt = ++$counter % 2 ? 'left' : 'right'; spyropress_before_post(); ?> <article class="timeline-box post post-medium <?php echo $post_alt; ?> "> <div class="row"> <div class="col-md-12">
/** * Validate the options by type before saving */ function spyropress_validate_setting($value, $type, $field_id, $section) { // check for null if (!$value || !$type || !$field_id) { return $value; } // type = background if ('repeater' == $type) { // skip last dummy element array_pop($value); // reset array indexes array_reindex($value); // Validate Fields $new_values = array(); $total = count($value); for ($i = 0; $i < $total; $i++) { $raw_value = $value[$i]; foreach ($section['fields'] as $field) { if (isset($field['id']) && isset($raw_value[$field['id']]) && !in_array($field['type'], spyropress_exclude_option_types())) { $key = trim($field['id']); $type = $field['type']; $new_value = $raw_value[$key]; $new_values[$i][$key] = spyropress_validate_setting($new_value, $type, $key, $field); } } $new_values[$i] = spyropress_clean_array($new_values[$i]); } $value = $new_values; } elseif ('background' == $type) { $value = spyropress_clean_array($value); if (isset($value['background-color'])) { $value['background-color'] = spyropress_validate_setting($value['background-color'], 'colorpicker', $field_id, $section); } if (isset($value['background-image']) || isset($value['background-pattern'])) { if (isset($value['background-image'])) { $value['background-image'] = spyropress_validate_setting($value['background-image'], 'upload', $field_id, $section); } } } elseif ('typography' == $type) { $value = spyropress_clean_array($value); // if using google fonts unset system fonts if (isset($value['use'])) { unset($value['font-family']); unset($value['font-style']); unset($value['font-weight']); } else { unset($value['font-google']); unset($value['font-google-variant']); } if (isset($value['color'])) { $value['color'] = spyropress_validate_setting($value['color'], 'colorpicker', $field_id, $section); } if (isset($value['font-size']) && $value['font-size'] == '0px') { unset($value['font-size']); } if (isset($value['line-height']) && $value['line-height'] == '0px') { unset($value['line-height']); } if (isset($value['letter-spacing']) && $value['letter-spacing'] == '0px') { unset($value['letter-spacing']); } if (!isset($value['text-shadowcolor']) || $value['text-shadowcolor'] == '') { unset($value['text-hshadow']); unset($value['text-vshadow']); unset($value['text-blur']); unset($value['text-shadowcolor']); } } elseif ('border' == $type) { $heads = array('top', 'right', 'bottom', 'left'); foreach ($heads as $h) { // if empty unset if ($value[$h] == '0px' || empty($value[$h]) || empty($value[$h . '-style']) || empty($value[$h . '-color'])) { unset($value[$h]); unset($value[$h . '-style']); unset($value[$h . '-color']); } else { $value[$h . '-style'] = spyropress_validate_setting($value[$h . '-style'], 'text', $field_id, $section); $value[$h . '-color'] = spyropress_validate_setting($value[$h . '-color'], 'colorpicker', $field_id, $section); } } } elseif ('padder' == $type) { foreach ($value as $k => $v) { if ($v == '0px') { unset($value[$k]); } } } elseif ('colorpicker' == $type) { $value = stripslashes(sanitize_text_field($value)); $value = str_replace('#', '', $value); if (!is_str_starts_with('rgb', $value)) { $value = '#' . $value; } } elseif ('textarea' == $type) { $value = stripslashes($value); } elseif (in_array($type, array('css', 'text', 'editor'))) { $value = stripslashes(wp_kses_post($value)); } elseif (in_array($type, array('upload', 'datepicker', 'hidden', 'range_slider'))) { $value = stripslashes(sanitize_text_field($value)); } return $value; }
function apply_widget_styles($params) { global $wp_registered_widgets; $widget_id = $params[0]['widget_id']; $widget_obj = $wp_registered_widgets[$widget_id]; $widget_opt = get_option($widget_obj['callback'][0]->option_name); $widget_num = $widget_obj['params'][0]['number']; $defaults = array('custom_container_id' => '', 'custom_container_class' => '', 'template' => ''); $cssclass = shortcode_atts($defaults, $widget_opt[$widget_num]); extract($cssclass); if (isset($widget_obj['callback'][0]->templates) && !empty($widget_obj['callback'][0]->templates) && isset($widget_obj['callback'][0]->templates[$template]['class'])) { $template = $widget_obj['callback'][0]->templates[$template]['class']; } // custom id if ('' != $custom_container_id) { $params[0]['before_widget'] = preg_replace('/id=".*?"/', 'id="' . $custom_container_id . '"', $params[0]['before_widget'], 1); } // cusotm class $cssclass = array(); $cssclass[] = $template; $cssclass[] = $custom_container_class; $cssclass = spyropress_clean_array($cssclass); if (!empty($cssclass)) { $count = 1; $params[0]['before_widget'] = str_replace('class="', 'class="' . implode(' ', $cssclass) . ' ', $params[0]['before_widget'], $count); } return $params; }
function spyropress_sc_promo_img($atts = array(), $content = '') { if (empty($content)) { return; } $atts = spyropress_clean_array(shortcode_atts(array('animation' => 'fadeInRight'), $atts)); return '<div class="push-top"><img class="img-responsive" src="' . spyropress_remove_formatting($content) . '"' . spyropress_build_atts($atts, 'data-appear-') . '></div>'; }
function get_placeholder_img_url($width = 0, $height = 0) { $args = array('bg' => get_setting('no_image_bg', '#eeeeee'), 'color' => get_setting('no_image_color', '#888888'), 'text' => get_setting('no_image_text', 'No Image Found'), 'width' => $width, 'height' => $height); $args = apply_filters('spyropress_placeholder_img_args', spyropress_clean_array($args)); // Setting dimension $wh = wp_constrain_dimensions(999, 999, $width, $height); $args['width'] = $wh[0]; $args['height'] = $wh[1]; $tmpl = 'holder.js/{width}x{height}/{bg}:{color}/text:{text}'; return token_repalce($tmpl, $args); }