public function get_html() { $params = $this->params; if ($params['ids'] === false) { // v6.2 || $params['height'] === false || $params['width'] === false) { return; // bail out if we haven't got the required parameters } if ($params['layout']) { // v5.6 $params['style'] = $params['style'] . " " . $params['layout']; // adds class of (eg) 'tabs' } //$posttypes = array_merge(get_post_types( array('_builtin'=> false)),array('post','attachment','page') ); // v6.28 added page $posttypes = array_keys(get_insertable_posttypes()); // v6.52 $args = array('post_type' => $posttypes, 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => null, 'post__in' => $params['ids']); //FB::info($args,'$args'); $rankedposts = get_ranked_posts($args); // v6.4 Was $this->get_ranked_posts $html_slidemain = "\n\n<div id='slidemain'>\n"; $html_text = ''; // needed for attachment version $html_thumb = "<div id ='slidethumbs'>\n"; $c = 0; // NB non-human counting from 0! $video_ids = array(); // an array of ids used by the YouTube API // v4.1 foreach ($rankedposts as $rankedpost) { $img_id = ''; // v6.11 so wf_get_credits($img_id) can bail out for videos unset($q_array); // v6.28 so that values from last time get destroyed. Don't need to check isset() first $html_slidemain .= "\n<div id ='slide" . $c . "' class='slide'>\n"; if ($rankedpost->post_type != 'attachment') { // a post, so get image id (and link?) from customfield in the post (not the page) $custom_value = get_post_meta($rankedpost->ID, 'extras', true); // the contents of customfield extras - or '' if ($custom_value != '') { $qstring = qscode($custom_value); // the QUERYSTRING version parse_str($qstring, $q_array); // parses the querystring into an associative array } if (isset($q_array['featured_video'])) { // v4.1 'featured_video' takes precedence over 'slidepic_id' and featured image $this_img = "<iframe id='player_" . $c . "' width='290' height='200' src='http://www.youtube.com/embed/" . $q_array['featured_video'] . "?rel=0&enablejsapi=1' frameborder='0' allowfullscreen></iframe>"; $video_ids[] = 'player_' . $c; } else { if (isset($q_array['slidepic_id'])) { $img_id = $q_array['slidepic_id']; // v4.1 'slidepic_id' takes precedence over featured image } else { if (has_post_thumbnail($rankedpost->ID)) { $img_id = get_post_thumbnail_id($rankedpost->ID); } else { throw new WF_Exception('Slideshow: no image or video found'); // v4.1 } } $this_img = wp_get_attachment_image($img_id, $size = $params['pic_size'], $icon = false, $attr = array('alt' => '', 'title' => '')); } $html_slidemain .= $this_img; if ($params['text_type'] != 'none') { // v6.28 $html_slidemain .= "\n<div class='slide_text'>\n"; if ($params['showtitles'] || $params['text_type'] == 'titles') { // v6.28 $html_slidemain .= "<h4>" . remove_square_brackets($rankedpost->post_title) . "</h4>\n"; // v6.28 } //$html_slidemain .= postProcessSidepost($rankedpost->post_content)."</div>\n"; $html_slidemain .= Wf_Widget::get_excerpt_or_full($rankedpost, $params['text_type'], $list = false) . "</div>\n"; // v6.28 } if (isset($q_array['link']) || $params['selflinks']) { // some sort of link is required // v4.1 v4.3 $coverlink = $params['selflinks'] ? get_permalink($rankedpost->ID) : wf_linkfix($q_array['link']); // v4.1 $html_slidemain .= "<a class='coverlink' href='" . $coverlink . "'> </a>\n"; // v3.22 (was slidelink) } //} else { //throw new WF_Exception('Slideshow: no customfield found'); // v4.1 } else { // it's an attachment $img_id = $rankedpost->ID; $this_img = wp_get_attachment_image($img_id, $size = $params['pic_size'], $icon = false, $attr = array('alt' => '', 'title' => '')); $html_slidemain .= $this_img . "\n"; } $html_slidemain .= wf_get_credits($img_id); // returns empty if no 'credit=' in description, otherwise a <div> (or <a> if it's a link) // v6.27 switch ($params['layout']) { case 'tabs': //case 'buttons': $this_img = " "; case 'thumbnails': // and 'buttons' $html_thumb .= "\n<span class='slidethumb' id ='slidethumb" . $c . "'>\n" . $this_img . "\n"; $html_thumb .= "<span class='darkner'></span>\n</span>\n"; // v6.30 changed divs to spans break; } $html_slidemain .= "</div>\n"; // v6.27 $c++; } // foreach $html = "\n\n<div id='slideshow' class='" . $params['style'] . "'>"; // assemble it all $html .= extra_markup($params); // v6.65 if ($params['heading']) { // v3.36 $html .= "\n<div class='hwrap'>\n<h2>" . $params['heading'] . "</h2>\n</div>\n"; } $html .= $html_slidemain . "\n</div>\n\n"; if ($params['layout']) { // == 'thumbnails' || $params['layout'] == 'buttons') { // v6.27 $html .= $html_thumb . "\n</div>\n\n"; } $html .= "</div>\n\n"; $html = str_replace('title=""', '', $html); if (!empty($video_ids)) { // v4.1 global $widget_params; $widget_params = $video_ids; if (!function_exists('pass_youtube_params')) { function pass_youtube_params($widget_params) { wp_enqueue_script('init_videos_js'); global $widget_params; wp_localize_script('init_videos_js', 'video_params', $widget_params); } } add_action('wp_enqueue_scripts', 'pass_youtube_params'); } // v6.69 $this->js_params['speed'] = $params['speed']; $this->js_params['interval'] = $params['interval']; self::add_action('wp_enqueue_scripts', 'pass_js_params'); return $html; }
function get_widget_dialog() { $post_types = get_insertable_posttypes(); // v6.52 Was get_widget_help_posttypes(); d('$post_types', $post_types); // (F3) calls Wf_Debug $html = "<div id='widget_dialog_box'>\n"; // wrapper round whole thing $html .= "<div id='dialog-form'></div>\n"; // the form $html .= "<div id='available_items'>\n"; // the available posts etc to insert $html .= "<h3>Available items to insert...</h3>\n"; $html .= "<p>(For info only: ‘selecting’ doesn't do anything)</p>\n"; $cat_html = "<div id='post_type_picker'>\n"; $cat_html .= "<select name='post_type' class='widefat' id='post_type'>\n"; $cat_html .= "<option value='0'>Select...</option>\n"; foreach ($post_types as $post_type => $name) { $html .= get_post_listing_dropdown($post_type, $name); // defined in wf_library.php $html .= get_term_dropdown($post_type, $name); $cat_html .= get_post_type_option($post_type, $name); //v5.19 v6.2 } // Now add the post_type param selector (that is moved by js) // v5.19 $html .= $cat_html; $html .= "</select>\n"; $html .= "</div>\n"; // Now add the list of active plugins to pass via Ajax as a comma-separated string //$active_plugins = get_option('active_plugins'); // typical array item: "wf_widget_forms/wf_forms.php" // v6.2 /* //v6.60 replaced now with function wf_get_active_plugin_dirs($value) in wf_widgets.php $active_plugin_dirs = array_map(function($value) { // v6.3 $path_array = explode('/',$value); return $path_array[0]; }, get_option('active_plugins')); */ $active_plugin_dirs = array_map('wf_get_active_plugin_dirs', get_option('active_plugins')); //v6.60 //var_dump($active_plugin_dirs); $html .= "<div id='active_plugin_dirs'>" . implode(',', $active_plugin_dirs) . "</div>\n"; // eg: syntaxhighlighter,wf_library,wf_widget_forms,wf_widgets $html .= "<div id='user_roles'>" . implode(',', array_keys(get_role_names())) . "</div>\n"; // comma-separated list of available roles //var_dump(implode(',',array_keys(get_role_names()))); // comma-separated list of available roles $html .= "</div>\n"; // #available_items $html .= "</div>\n"; // #widget_dialog_box return $html; }