/** * Displays the widget control options in the Widgets admin screen. * * @since 0.0.1 */ public function form($instance) { /** Set up the default form values. */ $defaults = array('title' => 'Agent', 'name' => true, 'name_custom' => '', 'email' => true, 'email_custom' => '', 'phone' => true, 'phone_custom' => '', 'description' => false, 'description_custom' => '', 'photo' => true, 'image_uri' => ''); /** Merge the user-selected arguments with the defaults. */ $instance = wp_parse_args((array) $instance, $defaults); /** Print the backend widget form. */ echo pls_h_div(pls_h_p(pls_h_label('Title' . ':' . pls_h('input', array('type' => 'text', 'class' => 'widefat', 'id' => $this->get_field_id('title'), 'name' => $this->get_field_name('title'), 'value' => esc_attr($instance['title']), 'style' => 'font-weight:normal')), $this->get_field_id('title'), array('style' => 'font-weight:bold'))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['name'], true, false), array('id' => $this->get_field_id('name'), 'name' => $this->get_field_name('name'))) . ' ' . 'Include Name', $this->get_field_id('name'))) . pls_h_p(pls_h_label('Override Name:' . pls_h('input', array('type' => 'text', 'class' => 'widefat', 'id' => $this->get_field_id('name_custom'), 'name' => $this->get_field_name('name_custom'), 'value' => esc_attr($instance['name_custom']), 'style' => 'font-weight:normal')), $this->get_field_id('name_custom'), array('style' => 'font-weight:bold'))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['email'], true, false), array('id' => $this->get_field_id('email'), 'name' => $this->get_field_name('email'))) . ' ' . 'Include Email', $this->get_field_id('email'))) . pls_h_p(pls_h_label('Override Email:' . pls_h('input', array('type' => 'text', 'class' => 'widefat', 'id' => $this->get_field_id('email_custom'), 'name' => $this->get_field_name('email_custom'), 'value' => esc_attr($instance['email_custom']), 'style' => 'font-weight:normal')), $this->get_field_id('email_custom'), array('style' => 'font-weight:bold'))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['phone'], true, false), array('id' => $this->get_field_id('phone'), 'name' => $this->get_field_name('phone'))) . ' ' . 'Include Phone', $this->get_field_id('phone'))) . pls_h_p(pls_h_label('Override Phone:' . pls_h('input', array('type' => 'text', 'class' => 'widefat', 'id' => $this->get_field_id('phone_custom'), 'name' => $this->get_field_name('phone_custom'), 'value' => esc_attr($instance['phone_custom']), 'style' => 'font-weight:normal')), $this->get_field_id('phone_custom'), array('style' => 'font-weight:bold'))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['description'], true, false), array('id' => $this->get_field_id('description'), 'name' => $this->get_field_name('description'))) . ' ' . 'Include Description', $this->get_field_id('description'))) . pls_h_p(pls_h_label('Override Description:' . pls_h('input', array('type' => 'text', 'class' => 'widefat', 'id' => $this->get_field_id('description_custom'), 'name' => $this->get_field_name('description_custom'), 'value' => esc_attr($instance['description_custom']), 'style' => 'font-weight:normal;height:')), $this->get_field_id('description_custom'), array('style' => 'font-weight:bold'))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['photo'], true, false), array('id' => $this->get_field_id('photo'), 'name' => $this->get_field_name('photo'))) . ' ' . 'Photo', $this->get_field_id('photo'))) . pls_h_p(pls_h_label('Image') . pls_h('input', array('name' => $this->get_field_name('image_uri'), 'type' => 'text', 'id' => "image-" . esc_attr($this->get_field_id('image_uri')), 'value' => $instance['image_uri'], 'class' => '.agent-widget-img-text-input')) . pls_h('img', array('id' => "image_tag-" . esc_attr($this->get_field_id("image_uri")), 'src' => $instance['image_uri'], 'class' => '.agent-widget-img-tag')) . pls_h('input', array('type' => 'button', 'id' => 'select-img-' . $this->get_field_id("image_uri"), 'value' => 'Select Image', 'class' => 'agent-widget-img-button')))); }
/** * Slideshow * * @param string $args * @param mixed $data * @static * @access public * @return void */ public static function slideshow($args = '') { /** Define the default argument array */ $defaults = array('animation' => 'fade', 'animationSpeed' => 800, 'timer' => true, 'advanceSpeed' => 4000, 'pauseOnHover' => true, 'startClockOnMouseOut' => true, 'startClockOnMouseOutAfter' => 500, 'directionalNav' => true, 'captions' => true, 'captionAnimation' => 'fade', 'captionAnimationSpeed' => 800, 'afterSlideChange' => 'function(){}', 'bullets' => 'false', 'width' => 620, 'height' => 300, 'container_height' => false, 'context' => '', 'context_var' => false, 'featured_option_id' => false, 'allow_user_slides' => false, 'user_slides_header_id' => false, 'listings' => 'limit=5&sort_by=price', 'data' => false, 'post_id' => false, 'post_meta_key' => false, 'fluid' => false); $args = wp_parse_args($args, $defaults); /** Check cache, return something is there **/ $cache = new PLS_Cache('slide'); if ($result = $cache->get($args)) { return $result; } /** Extract all args for easy usage **/ extract($args, EXTR_SKIP); /** If the slideshow data is null or not an array AND the plugin is working, try to fetch the proper data... **/ if ((!$data || !is_array($data)) && !pls_has_plugin_error()) { /** Data assumed to take this form. */ $data = array('images' => array(), 'links' => array(), 'captions' => array()); // If the calling theme allows user input, get slideshow config option... if ($allow_user_slides && $user_slides_header_id) { $slides = pls_get_option($user_slides_header_id, array()); // Check to see if slides are set to custom, but are empty $custom_but_empty = isset($slides[0]) && $slides[0]['type'] == 'custom' && empty($slides[0]['image']); // Populate slides when '$custom_but_empty' is true OR when no slides exist... if ($custom_but_empty || empty($slides)) { $slides = self::empty_slides_and_add_random_listings(); } foreach ($slides as $index => $slide) { switch ($slide['type']) { case 'listing': unset($slide['html'], $slide['image'], $slide['type'], $slide['link']); // In this case, the slide's remaining key will correspond to it's property ID... $property_id = key($slide); $api_response = PLS_Plugin_API::get_listing_details(array('property_ids' => array($property_id))); if (!empty($api_response['listings']) && $api_response['listings'][0]['id'] === false) { self::$listings_to_delete[] = $property_id; } if ($api_response['total'] == '1') { $listing = $api_response['listings'][0]; $first_valid_img_url = null; // Overwrite the placester url with the local url... $listing_url = PLS_Plugin_API::get_property_url($listing['id']); $data['links'][] = $listing_url; // Try to retrieve the image url if order is set... if (is_array($listing['images']) && isset($listing['images'][0]['order'])) { foreach ($listing['images'] as $key => $image) { if ($image['order'] == 1) { $data['images'][$index] = $image['url']; // break, just in case the listing has more than one '1' in the 'order' param break; } // Record the first valid image URL in case no image has the top order... if (!isset($first_valid_img_url) && isset($image['url'])) { $first_valid_img_url = $image['url']; } } } // If image still isn't set, use first valid image URL discovered above, or just set to default... if (empty($data['images'][$index])) { $data['images'][$index] = isset($first_valid_img_url) ? $first_valid_img_url : self::$default_img_url; } $data['type'][] = 'listing'; $data['listing'][] = $listing; /** Get the listing caption **/ $data['captions'][] = trim(self::render_listing_caption($listing, $index)); } break; case 'custom': $is_empty = empty($slide['image']) && empty($slide['link']) && empty($slide['image']) && empty($slide['html']); // Only include a custom slide if it's not entirely empty... if (!$is_empty) { $data['images'][] = $slide['image']; $data['links'][] = $slide['link']; $data['type'][] = 'custom'; $data['captions'][] = trim(self::render_custom_caption($slide['html'], $index)); } break; } } } else { if (!empty($args['post_id']) && !empty($args['post_meta_key'])) { $api_response = PLS_Listing_Helper::get_featured_from_post($args['post_id'], $args['post_meta_key']); } elseif ($featured_option_id) { $api_response = PLS_Listing_Helper::get_featured($featured_option_id); } if (empty($api_response['listings'])) { $api_response = PLS_Plugin_API::get_listings($listings); } foreach ($api_response['listings'] as $index => $listing) { if (empty($listing['id'])) { continue; } $listing_url = PLS_Plugin_API::get_property_url($listing['id']); /** Overwrite the placester url with the local url. */ $data['links'][] = $listing_url; $data['images'][] = !empty($listing['images']) ? $listing['images'][0]['url'] : self::$default_img_url; $data['listing'][] = $listing; // Get the listing caption $listing_caption = trim(self::render_listing_caption($listing, $index)); // Add a filter for a single caption, to be edited via a template $single_caption = apply_filters(pls_get_merged_strings(array('pls_slideshow_single_caption', $context), '_', 'pre', false), $listing_caption, $listing, $context, $context_var, $index); $data['captions'][] = $single_caption; } } } /** Filter the data array */ $data = apply_filters(pls_get_merged_strings(array('pls_slideshow_data', $context), '_', 'pre', false), $data, $context, $context_var); /** Create the slideshow */ $html = array('slides' => '', 'captions' => ''); if (is_array($data['images'])) { foreach ($data['images'] as $index => $slide_src) { $extra_attr = array(); $extra_attr['title'] = ''; /** Save the caption and the title attribute for the img. */ if (isset($data['captions'][$index])) { $html['captions'] .= $data['captions'][$index]; $extra_attr['title'] = "#caption-{$index}"; } if (isset($data['type'][$index])) { // Get image, but only Dragonfly listing images switch ($data['type'][$index]) { case "listing": $slide_src = PLS_Image::load($slide_src, array('resize' => array('w' => $width, 'h' => $height), 'fancybox' => false, 'as_html' => false)); break; case "custom": $slide_src = PLS_Image::load($slide_src, array('allow_resize' => false, 'fancybox' => false, 'as_html' => false)); break; } } /** Create the img element. */ $slide = pls_h_img($slide_src, false, $extra_attr); /** Wrap it in an achor if the anchor exists. */ if (isset($data['links'][$index])) { $slide = pls_h_a($data['links'][$index], $slide, array('data-caption' => "#caption-{$index}")); } $html['slides'] .= $slide; } } /** Combine the HTML **/ $html = pls_h_div($html['slides'], array('id' => 'slider', 'class' => 'orbitSlider')) . $html['captions']; /** Filter the HTML array */ $html = apply_filters(pls_get_merged_strings(array('pls_slideshow_html', $context), '_', 'pre', false), $html, $data, $context, $context_var, $args); if (!$container_height) { $container_height = $height; } /** Render the necessary inline CSS... */ $css_args = array('width' => $width, 'height' => $height, 'container_height' => $container_height); $css = self::render_inline_css($css_args); /** Render the necessary inline JS... **/ $args['data'] = is_string($data) ? $data : ''; // For compatibility... $js = self::render_inline_js($args); /** Filter inline JS **/ $js = apply_filters(pls_get_merged_strings(array('pls_slideshow_js', $context), '_', 'pre', false), $js, $html, $data, $context, $context_var); /** Filter the final output **/ $full_slideshow = apply_filters(pls_get_merged_strings(array('pls_slideshow', $context), '_', 'pre', false), $css . $html . $js, $html, $js, $data, $context, $context_var, $args); /** Cache rendered slideshow for future retrieval **/ $cache->save($full_slideshow); return $full_slideshow; }
/** * Displays the widget control options in the Widgets admin screen. * * @since 0.0.1 */ public function form($instance) { /** Set up the default form values. */ $defaults = array('title' => 'Latest Blog Posts', 'post_title' => true, 'author' => true, 'date' => true, 'excerpt' => true, 'read_more' => true, 'number' => 5, 'cat' => ''); /** Merge the user-selected arguments with the defaults. */ $instance = wp_parse_args($instance, $defaults); /** Print the backend widget form. */ echo pls_h_div(pls_h_p(pls_h_label('Title' . ':' . pls_h('input', array('type' => 'text', 'class' => 'widefat', 'id' => $this->get_field_id('title'), 'name' => $this->get_field_name('title'), 'value' => esc_attr($instance['title']))), $this->get_field_id('title'))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['post_title'], true, false), array('id' => $this->get_field_id('post_title'), 'name' => $this->get_field_name('post_title'))) . ' ' . 'Post Title', $this->get_field_id('post_title'))) . pls_h_p(pls_h_label("Category:\n" . wp_dropdown_categories(array('show_option_all' => "From All Categories", 'name' => $this->get_field_name("cat"), 'selected' => $instance['cat'], 'hide_empty' => 0, 'echo' => 0)))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['author'], true, false), array('id' => $this->get_field_id('author'), 'name' => $this->get_field_name('author'))) . ' ' . 'Author', $this->get_field_id('author'))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['date'], true, false), array('id' => $this->get_field_id('date'), 'name' => $this->get_field_name('date'))) . ' ' . 'Post Date', $this->get_field_id('date'))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['excerpt'], true, false), array('id' => $this->get_field_id('excerpt'), 'name' => $this->get_field_name('excerpt'))) . ' ' . 'Excerpt', $this->get_field_id('excerpt'))) . pls_h_p(pls_h_label(pls_h_checkbox(checked($instance['read_more'], true, false), array('id' => $this->get_field_id('read_more'), 'name' => $this->get_field_name('read_more'))) . ' ' . 'Read more link', $this->get_field_id('read_more'))) . pls_h_p(pls_h_label('Number of posts' . ': ' . pls_h('input', array('type' => 'text', 'size' => 4, 'id' => $this->get_field_id('number'), 'name' => $this->get_field_name('number'), 'value' => esc_attr($instance['number']))), $this->get_field_id('number')))); }
/** * Displays the widget control options in the Widgets admin screen. * * @since 0.0.1 */ public function form($instance) { /** Set up the default form values. */ $defaults = array('title' => 'Listings', 'type' => 'all', 'placeholder' => '', 'limit' => 5, 'width' => 100, 'height' => '', 'number' => 5, 'name' => true, 'email' => true, 'photo' => true, 'phone' => true, 'description' => true); $type_array = array('all' => 'All', 'featured' => 'Featured', 'new' => 'New'); /** Merge the user-selected arguments with the defaults. */ $instance = wp_parse_args((array) $instance, $defaults); /** Print the backend widget form. */ echo pls_h_div(pls_h_p(pls_h_label('Title' . ':' . pls_h('input', array('type' => 'text', 'class' => 'widefat', 'id' => $this->get_field_id('title'), 'name' => $this->get_field_name('title'), 'value' => esc_attr($instance['title']))), $this->get_field_id('title'))) . pls_h_p(pls_h_label('Listings Type' . ':' . pls_h('select', array('type' => 'text', 'class' => 'widefat', 'id' => $this->get_field_id('type'), 'name' => $this->get_field_name('type')), pls_h_options($type_array, $instance['type'])), $this->get_field_id('type'))) . pls_h_p(pls_h_label('Photo placeholder URL' . ':' . pls_h('input', array('type' => 'text', 'class' => 'widefat', 'id' => $this->get_field_id('placeholder'), 'name' => $this->get_field_name('placeholder'), 'value' => esc_attr($instance['placeholder']))), $this->get_field_id('placeholder'))) . pls_h_p(pls_h_label('Photo width' . ': ' . pls_h('input', array('type' => 'text', 'size' => 4, 'id' => $this->get_field_id('width'), 'name' => $this->get_field_name('width'), 'value' => esc_attr($instance['width']))), $this->get_field_id('width'))) . pls_h_p(pls_h_label('Photo height' . ': ' . pls_h('input', array('type' => 'text', 'size' => 4, 'id' => $this->get_field_id('height'), 'name' => $this->get_field_name('height'), 'value' => esc_attr($instance['height']))), $this->get_field_id('height'))) . pls_h_p(pls_h_label('Number of listings' . ': ' . pls_h('input', array('type' => 'text', 'size' => 4, 'id' => $this->get_field_id('number'), 'name' => $this->get_field_name('number'), 'value' => esc_attr($instance['number']))), $this->get_field_id('number')))); }