Advertisement
pixedelic

pix_widgets_3.3.0.php

Dec 15th, 2011
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.37 KB | None | 0 0
  1. <?php
  2. class pixRecentPosts extends WP_Widget
  3. {
  4.     function pixRecentPosts(){
  5.     $widget_ops = array('class' => 'pix-sliding-news', 'description' => __( "Recent posts with thumbnail and control on the excerpt length") );
  6.     $this->WP_Widget('pixRecentPosts', __('Pixedelic Recent Posts'), $widget_ops, 200);
  7.     }
  8.  
  9.     function widget($args, $instance){
  10.       extract($args);
  11.     $title = $instance['title'];
  12.     $posts = $instance['posts'];
  13.     $thumbnail = $instance['thumbnail'];
  14.     $category = $instance['category'];
  15.     $excerpt = $instance['excerpt'];
  16.     $button = $instance['button'];
  17.  
  18.       echo $before_widget;
  19.  
  20.       if ( $title )
  21.       echo $before_title . $title . $after_title .'';
  22.  
  23.    
  24. query_posts('posts_per_page='.$posts.'&cat='.$category); ?>
  25.     <?php
  26. global $custom_payoff;
  27.     if (have_posts()) : ?>
  28.         <?php while (have_posts()) : the_post();
  29. $meta_title = get_post_meta(get_the_ID(), $custom_payoff->get_the_id(), TRUE);
  30. if($meta_title['payoff']!='') {
  31.     $the_title = $meta_title['payoff'];
  32. } else {
  33.     $the_title = get_the_title();
  34. }
  35.          ?>
  36.                             <div class="clear">
  37.                                 <h5><a href="<?php echo get_permalink(); ?>"><?php echo $the_title; ?></a></h5>
  38.                                 <?php
  39.                                 if($meta_title['subtitle']!=''){?>
  40.                                 <p class="subtitle"><?php echo $meta_title['subtitle']; ?></p>
  41.                                 <?php } ?>
  42.                                 <div class="entry-widget">
  43.                                 <?php
  44.                                     if(has_post_thumbnail() && $thumbnail==true) { ?>
  45.                                         <div class="imgHentry">
  46.                                             <?php the_post_thumbnail('exTh'); ?>
  47.                                             <div class="linkIcon" style="width:50px; height:50px;">
  48.                                                 <a href="<?php the_permalink(); ?>" class="goto-icon"></a>
  49.                                             </div>
  50.                                        </div><!-- .imgHentry -->
  51.                                     <?php }
  52.                                     echo custom_the_excerpt($excerpt,$button);
  53.                                     ?>
  54.                                 </div><!-- .entry-widget -->
  55.                              </div><!-- .clear -->
  56.             <?php endwhile; remove_filter('excerpt_length', 'excerpt_recent_posts'); ?>
  57.     <?php endif; ?>
  58.     <?php wp_reset_query(); ?>
  59.  
  60.      <?php
  61.         echo $after_widget . '';
  62.   }
  63.  
  64.     function update($new_instance, $old_instance){
  65.       $instance = $old_instance;
  66.       $instance['title'] = strip_tags(stripslashes($new_instance['title']));
  67.       $instance['posts'] = strip_tags(stripslashes($new_instance['posts']));
  68.       $instance['thumbnail'] = isset($new_instance['thumbnail']);
  69.       $instance['category'] = strip_tags(stripslashes($new_instance['category']));
  70.       $instance['excerpt'] = strip_tags(stripslashes($new_instance['excerpt']));
  71.       $instance['button'] = strip_tags(stripslashes($new_instance['button']));
  72.  
  73.     return $instance;
  74.   }
  75.  
  76.     function form($instance){
  77.       $instance = wp_parse_args( (array) $instance, array('title'=>'News', 'posts'=>'10', 'thumbnail'=>true, 'category'=>'0', 'excerpt'=>'10', 'button'=>'Read more') );
  78.  
  79.       $title = htmlspecialchars($instance['title']);
  80.       $posts = htmlspecialchars($instance['posts']);
  81.       $thumbnail = isset($new_instance['thumbnail']);
  82.       $category = htmlspecialchars($instance['category']);
  83.       $excerpt = htmlspecialchars($instance['excerpt']);
  84.       $button = htmlspecialchars($instance['button']);
  85.  
  86.         echo '<p><label for="' . $this->get_field_name('title') . '">Title <input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></label></p>';
  87.        
  88.         echo '<p><label for="' . $this->get_field_name('category') . '">Include categories</label><input class="widefat" id="' . $this->get_field_name('category') . '" name="' . $this->get_field_name('category') . '" type="text" value="'.$category.'" /></p>';
  89.  
  90.         ?>
  91.        <p><label for="<?php echo $this->get_field_name('thumbnail'); ?>">Show featured image</label>&nbsp;
  92.         <input id="<?php echo $this->get_field_id('thumbnail'); ?>" name="<?php echo $this->get_field_name('thumbnail'); ?>" type="checkbox" <?php checked(isset($instance['thumbnail']) ? $instance['thumbnail'] : 0); ?> />
  93.          </p>
  94.  
  95.         <?php echo '<p><label for="' . $this->get_field_name('excerpt') . '">How many words to display in the excerpt</label><input class="widefat" id="' . $this->get_field_name('excerpt') . '" name="' . $this->get_field_name('excerpt') . '" type="text" value="'.$excerpt.'" /></p>';
  96.  
  97.         echo '<p><label for="' . $this->get_field_name('posts') . '">Amount of news</label><input class="widefat" id="' . $this->get_field_name('posts') . '" name="' . $this->get_field_name('posts') . '" type="text" value="'.$posts.'" /></p>';
  98.        
  99.         echo '<p><label for="' . $this->get_field_name('button') . '">Text of the button</label><input class="widefat" id="' . $this->get_field_name('button') . '" name="' . $this->get_field_name('button') . '" type="text" value="'.$button.'" /></p>';
  100.  
  101.   }
  102.  
  103. }
  104.  
  105.   function pixPostsInit() {
  106.   register_widget('pixRecentPosts');
  107.   }
  108.   add_action('widgets_init', 'pixPostsInit');
  109.  
  110.  
  111.  
  112. function get_flickr_images( $id = "", $number = 5, $key = "") {
  113.     require_once(TEMPLATEPATH."/scripts/phpFlickr.php");
  114.     $phpFlickrObj = new phpFlickr($key);
  115.     $user_url = $phpFlickrObj->urls_getUserPhotos($id);
  116.     $photos = $phpFlickrObj->people_getPublicPhotos($id, NULL, NULL, $number);
  117.     return $photos['photos']['photo'];
  118. }
  119.  
  120.  
  121. class pixThumbGallery extends WP_Widget
  122. {
  123.     function pixThumbGallery(){
  124.     $widget_ops = array('class' => 'pix-thumb-gallery', 'description' => __( "Create a thumb-gallery from your posts") );
  125.     $this->WP_Widget('pixThumbGallery', __('Pixedelic Thumb Gallery'), $widget_ops, 200);
  126.     }
  127.  
  128.     function widget($args, $instance){
  129.       extract($args);
  130.     $title = $instance['title'];
  131.     $posts = $instance['posts'];
  132.     $category = $instance['category'];
  133.     $gallery = $instance['gallery'];
  134.     $click = $instance['click'];
  135.     $source = $instance['source'];
  136.     $flickrid = $instance['flickrid'];
  137.     $key = $instance['key'];
  138.    
  139.    
  140.       echo $before_widget;
  141.  
  142.       if ( $title )
  143.       echo $before_title . $title . $after_title;
  144.  
  145.       if ($source == 'posts') { query_posts('cat='.$category.'&posts_per_page='.$posts); ?>
  146.     <div class="pix_thumbs">
  147.     <?php if (have_posts()) : ?>
  148.         <?php $i=1; while (have_posts()) : the_post();
  149.     if(has_post_thumbnail()) {
  150.         $attachment_id = get_post_thumbnail_id($post->ID);
  151.         $thumb_src = wp_get_attachment_image_src( $attachment_id, $size_th );
  152.         $image_id = get_post_thumbnail_id();  
  153.         $image_url = wp_get_attachment_image_src($image_id,'full');  
  154.         $image_url = $image_url[0];
  155.     ?>
  156.         <div class="imgHentry<?php if($i % 3 === 0) { ?> marginZero<?php } ?>">
  157.                 <img src="<?php echo get_bloginfo('stylesheet_directory'); ?>/scripts/timthumb.php?src=<?php echo pix_image_path($thumb_src[0]); ?>&amp;h=64&amp;w=64" alt="<?php echo $image['title']; ?>">
  158.             <div class="linkIcon" style="width:64px; height:64px;">
  159.                 <a href="<?php if($click == 'colorbox') { echo $image_url; } else { the_permalink(); } ?>" class="<?php if($click == 'colorbox') { echo 'enlarge-icon'; } else { echo 'goto-icon'; } ?>" data-rel="thumbgallery"></a>
  160.             </div>
  161.        </div><!-- .imgHentry -->
  162. <?php $i++; }  ?>
  163.         <?php endwhile; ?>
  164.     </div><!-- .pix_thumbs -->
  165.     <?php endif; ?>
  166.     <?php wp_reset_query();
  167.    
  168.       } elseif ($source == 'galleries') {
  169.           if($gallery=='all') {
  170.               $gallery='';
  171.           }
  172.          
  173.         $args=array(
  174.             'gallery'   => $gallery,
  175.             'post_type' => 'portfolio',
  176.             'posts_per_page' => $posts
  177.     );
  178.     $my_query = null;
  179.     $my_query = new WP_Query($args);  ?>
  180.  
  181.     <div class="pix_thumbs">
  182.         <?php $i=1;
  183.     while ( $my_query->have_posts() ) : $my_query->the_post();
  184.     if(has_post_thumbnail()) {
  185.         $attachment_id = get_post_thumbnail_id($post->ID);
  186.         $thumb_src = wp_get_attachment_image_src( $attachment_id, $size_th );
  187.         $image_id = get_post_thumbnail_id();  
  188.         $image_url = wp_get_attachment_image_src($image_id,'full');  
  189.         $image_url = $image_url[0];
  190.     ?>
  191.         <div class="imgHentry<?php if($i % 3 === 0) { ?> marginZero<?php } ?>">
  192.                 <img src="<?php echo get_bloginfo('stylesheet_directory'); ?>/scripts/timthumb.php?src=<?php echo pix_image_path($thumb_src[0]); ?>&amp;h=64&amp;w=64" alt="<?php echo $image['title']; ?>">
  193.             <div class="linkIcon" style="width:64px; height:64px;">
  194.                 <a href="<?php if($click == 'colorbox') { echo $image_url; } else { the_permalink(); } ?>" class="<?php if($click == 'colorbox') { echo 'enlarge-icon'; } else { echo 'goto-icon'; } ?>" data-rel="thumbgallery"></a>
  195.             </div>
  196.        </div><!-- .imgHentry -->
  197. <?php $i++; }  ?>
  198.  
  199.  
  200. <?php   endwhile; ?>
  201.     </div><!-- .pix_thumbs -->
  202. <?php   wp_reset_query();
  203.     ?>
  204.      
  205.      
  206.      
  207.      
  208.       <?php } else { ?>
  209.  
  210.     <div class="pix_thumbs">
  211. <?php
  212.  
  213. $images = get_flickr_images($flickrid,$posts,$key);
  214. $i=0;
  215. require_once(TEMPLATEPATH."/scripts/phpFlickr.php");
  216. $phpFlickrObj = new phpFlickr($key);
  217. $user_url = $phpFlickrObj->urls_getUserPhotos($flickrid);
  218. foreach( $images as $image ) {
  219.     $i++;
  220.     ?>
  221.         <div class="imgHentry<?php if($i % 3 === 0) { ?> marginZero<?php } ?>">
  222.                 <img src="<?php echo get_bloginfo('stylesheet_directory'); ?>/scripts/timthumb.php?src=<?php echo $phpFlickrObj->buildPhotoURL($image, "thumbnail"); ?>&amp;h=64&amp;w=64" alt="<?php echo $image['title']; ?>">
  223.             <div class="linkIcon" style="width:64px; height:64px;">
  224.                 <a href="<?php if($click == 'colorbox') { echo $phpFlickrObj->buildPhotoURL($image, "large"); } else { echo 'http://www.flickr.com/photos/'.$flickrid.'/'.$image['id'].'/in/photostream'; } ?>" class="<?php if($click == 'colorbox') { echo 'enlarge-icon'; } else { echo 'goto-icon'; } ?>" data-rel="flickr"<?php if($click == 'topost') { echo ' target="_blank"'; } ?>></a>
  225.             </div>
  226.        </div><!-- .imgHentry -->
  227. <?php } ?>
  228.     </div><!-- .pix_thumbs -->
  229.    
  230.  
  231.  
  232.  
  233.  
  234.     <?php }
  235.  
  236.         echo $after_widget;
  237.   }
  238.  
  239.     function update($new_instance, $old_instance){
  240.       $instance = $old_instance;
  241.       $instance['title'] = strip_tags(stripslashes($new_instance['title']));
  242.       $instance['posts'] = strip_tags(stripslashes($new_instance['posts']));
  243.       $instance['category'] = strip_tags(stripslashes($new_instance['category']));
  244.       $instance['gallery'] = strip_tags(stripslashes($new_instance['gallery']));
  245.       $instance['click'] = strip_tags(stripslashes($new_instance['click']));
  246.       $instance['source'] = strip_tags(stripslashes($new_instance['source']));
  247.       $instance['flickrid'] = strip_tags(stripslashes($new_instance['flickrid']));
  248.       $instance['key'] = strip_tags(stripslashes($new_instance['key']));
  249.  
  250.     return $instance;
  251.   }
  252.  
  253.     function form($instance){
  254.       $instance = wp_parse_args( (array) $instance, array('title'=>'Gallery', 'posts'=>'9', 'category'=>'0', 'gallery'=>'0', 'click'=>'c', 'source'=>'posts', 'source'=>'flickr', 'flickrid'=>'Your Flickr ID', 'key'=>'Flickr API key') );
  255.  
  256.       $title = htmlspecialchars($instance['title']);
  257.       $posts = htmlspecialchars($instance['posts']);
  258.       $category = htmlspecialchars($instance['category']);
  259.       $gallery = htmlspecialchars($instance['gallery']);
  260.       $click = htmlspecialchars($instance['click']);
  261.       $source = htmlspecialchars($instance['source']);
  262.       $flickrid = htmlspecialchars($instance['flickrid']);
  263.       $key = htmlspecialchars($instance['key']);
  264.  
  265.         echo '<p><label for="' . $this->get_field_name('title') . '">Title <input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></label></p>';
  266.        
  267.         ?>
  268.         <p>
  269.             <label for="<?php echo $this->get_field_name('source'); ?>"> Choose the source for the thumbnails</label>
  270.                 <select id="<?php echo $this->get_field_name('source'); ?>" name="<?php echo $this->get_field_name('source'); ?>" class="widefat toggler">
  271.                     <option value="posts"<?php selected( $instance['source'], 'posts' ); ?>>Posts</option>
  272.                     <option value="galleries"<?php selected( $instance['source'], 'galleries' ); ?>>Galleries</option>
  273.                     <option value="flickr"<?php selected( $instance['source'], 'flickr' ); ?>>Flickr</option>
  274.                 </select>
  275.         </p>
  276.  
  277.        <p class="<?php echo $this->get_field_name('source'); ?> toggle" data-type="posts"><label for="<?php echo $this->get_field_name('category'); ?>">Category <small>(if you previously selected posts)</small></label>    
  278.         <?php wp_dropdown_categories(array('selected' => $category, 'name' => $this->get_field_name('category'), 'show_option_all'=>'All', 'class'=>'widefat', 'sort_column'=> 'menu_order, post_title'));?>
  279.          </p>
  280.  
  281.        <p class="<?php echo $this->get_field_name('source'); ?> toggle" data-type="galleries"><label for="<?php echo $this->get_field_name('gallery'); ?>">Gallery <small>(if you selected galleries)</small></label>    
  282.         <?php
  283.             $terms = get_terms("gallery");
  284.             $count = count($terms);
  285.             if($count > 0){
  286.                 echo '<select id="'.$this->get_field_name('gallery').'" name="'.$this->get_field_name('gallery').'" class="widefat">';
  287.                 echo '<option value="all"'. selected( $instance['gallery'], 'all' ) .'>All</option>';
  288.                 foreach ($terms as $term) {
  289.                     echo '<option value="'.$term->slug.'"'. selected( $instance['gallery'], $term->slug ) .'>'.$term->name.'</option>';
  290.                 }
  291.                 echo "</select>";
  292.             }
  293.         ?>
  294.          </p>
  295.  
  296.         <?php echo '<p class="'.$this->get_field_name('source').' toggle" data-type="flickr"><label for="' . $this->get_field_name('flickrid') . '">Flickr ID <small>(if you previously selected Flickr)</small></label><input class="widefat" id="' . $this->get_field_name('flickrid') . '" name="' . $this->get_field_name('flickrid') . '" type="text" value="'.$flickrid.'" /></p>'; ?>
  297.  
  298.         <?php echo '<p class="'.$this->get_field_name('source').' toggle" data-type="flickr"><label for="' . $this->get_field_name('key') . '">Flickr API key <small>(if you previously selected Flickr: <a href="http://www.flickr.com/services/apps/create/apply" target="_blank">where to get it</a>)</small></label><input class="widefat" id="' . $this->get_field_name('key') . '" name="' . $this->get_field_name('key') . '" type="text" value="'.$key.'" /></p>'; ?>
  299.  
  300.         <p>
  301.             <label for="<?php echo $this->get_field_name('click'); ?>"> Choose the thumbnails links</label>
  302.                 <select id="<?php echo $this->get_field_name('click'); ?>" name="<?php echo $this->get_field_name('click'); ?>" class="widefat">
  303.                     <option value="colorbox"<?php selected( $instance['click'], 'colorbox' ); ?>>Open with Colorbox</option>
  304.                     <option value="topost"<?php selected( $instance['click'], 'topost' ); ?>>Go to the post or page</option>
  305.                 </select>
  306.         </p>
  307.  
  308.         <?php echo '<p><label for="' . $this->get_field_name('posts') . '">Amount of thumbs</label><input class="widefat" id="' . $this->get_field_name('posts') . '" name="' . $this->get_field_name('posts') . '" type="text" value="'.$posts.'" /></p>';
  309.        
  310.  
  311.   }
  312.  
  313. }
  314.  
  315.   function pixThumbInit() {
  316.   register_widget('pixThumbGallery');
  317.   }
  318.   add_action('widgets_init', 'pixThumbInit');
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325. function pix_recent_comments($amount) {
  326.   $pre_HTML ="";
  327.   $post_HTML ="";
  328.   global $wpdb;
  329.   $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url,  comment_author_email, SUBSTRING(comment_content,1,30) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT ".$amount;
  330.  
  331.   $comments = $wpdb->get_results($sql);
  332.   $output = $pre_HTML;
  333.   foreach ($comments as $comment) {
  334.     $output .= '<div class="comment">';
  335.     $output .= '<span class="vcard">';
  336.     $output .= get_avatar( $comment->comment_author_email, $size = '40' );
  337.     $output .= '</span><!-- .vcard -->';
  338.     $output .= '<span class="text">';
  339.     $output .= '<span class="left_arrow"></span>';
  340.     $output .= strip_tags($comment->comment_author) . __(' on','delight').' <a href="' . get_permalink($comment->ID).'#comment-' . $comment->comment_ID . '" title="'. __('on','delight').' '.$comment->post_title . '">'.get_the_title($comment->ID).'</a><br />';
  341.     $output .= '<span class="comment_text">&ldquo;'.strip_tags($comment->com_excerpt).'&rdquo;</span><!-- .commenttext -->';
  342.     $output .= '</span><!-- .text -->';
  343.     $output .= '</div><!-- .comment -->';
  344.  }
  345.   $output .= $post_HTML;
  346.   echo $output;
  347. }
  348.  
  349.  
  350. class pixRecentComments extends WP_Widget
  351. {
  352.     function pixRecentComments(){
  353.     $widget_ops = array('classname' => 'pix-recent-comments', 'description' => __( "Add a fading slide show for recent comments") );
  354.     $this->WP_Widget('pixRecentComments', __('Pixedelic Recent Comments'), $widget_ops, 200);
  355.     }
  356.  
  357.     function widget($args, $instance){
  358.       extract($args);
  359.     $title = $instance['title'];
  360.     $posts = $instance['posts'];
  361.  
  362.       echo $before_widget;
  363.  
  364.       if ( $title )
  365.       echo $before_title . $title . $after_title. '<div class="pix_side_comments">' ;
  366.  
  367.         ?>
  368.                             <?php pix_recent_comments($posts); ?>
  369.  
  370.       <?php
  371.         echo '</div><!-- pix_side_comments -->'.$after_widget;
  372.   }
  373.  
  374.     function update($new_instance, $old_instance){
  375.       $instance = $old_instance;
  376.       $instance['title'] = strip_tags(stripslashes($new_instance['title']));
  377.       $instance['posts'] = strip_tags(stripslashes($new_instance['posts']));
  378.  
  379.     return $instance;
  380.   }
  381.  
  382.     function form($instance){
  383.       $instance = wp_parse_args( (array) $instance, array('title'=>'Comments', 'posts'=>'10') );
  384.  
  385.       $title = htmlspecialchars($instance['title']);
  386.       $posts = htmlspecialchars($instance['posts']);
  387.  
  388.         echo '<p><label for="' . $this->get_field_name('title') . '">Title <input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></label></p>';
  389.        
  390.         ?>
  391.  
  392.         <?php echo '<p><label for="' . $this->get_field_name('posts') . '">Amount of comments</label><input class="widefat" id="' . $this->get_field_name('posts') . '" name="' . $this->get_field_name('posts') . '" type="text" value="'.$posts.'" /></p>';
  393.  
  394.   }
  395.  
  396. }
  397.  
  398.   function pixSlidCommentInit() {
  399.   register_widget('pixRecentComments');
  400.   }
  401.   add_action('widgets_init', 'pixSlidCommentInit');
  402.  
  403.  
  404.  
  405.  
  406.  function unregister_them() {
  407. unregister_widget( 'WP_Widget_Search' );
  408. }
  409. add_action('widgets_init','unregister_them',10);
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417. class pixContactForm extends WP_Widget
  418. {
  419.     function pixContactForm(){
  420.     $widget_ops = array('class' => 'pix-contact-form', 'description' => __( "Select a form") );
  421.     $this->WP_Widget('pixContactForm', __('Pixedelic Contact Forms'), $widget_ops, 200);
  422.     remove_action('wp_enqueue_scripts', 'remove_datePicker2');
  423.     }
  424.  
  425.  
  426.    
  427.     function widget($args, $instance){
  428.       extract($args);
  429.     $title = $instance['title'];
  430.     $form = $instance['form'];
  431.     global $print_datepicker;  
  432.      echo $before_widget;
  433.  
  434.       if ( $title )
  435.       echo $before_title . $title . $after_title; ?>
  436.      
  437.                 <div class="contactForm" id="<?php echo $form; ?>">
  438.                     <?php
  439.                         $i2 = 0;
  440.                         $pix_array_your_field = get_pix_option('pix_array_'.$form.'_fields_');
  441.                         $pix_array_your_field2 = print_r($pix_array_your_field, true);
  442.                         if ( stripos($pix_array_your_field2, '[pix_period') ){
  443.                             $print_datepicker = true;
  444.                         }
  445.                     ?>
  446.                     <div class="success" style="display:none">
  447.                     <?php echo get_pix_option('pix_array_'.$form.'_issuccess'); ?>
  448.                     </div>
  449.                     <div class="unsuccess" style="display:none">
  450.                     <?php echo get_pix_option('pix_array_'.$form.'_unsuccess'); ?>
  451.                     </div>
  452.                     <form>
  453.                         <fieldset>
  454.                             <?php
  455.                             while ($i2<count($pix_array_your_field)){
  456.                             $field = $pix_array_your_field[$i2][0];
  457.                             echo do_shortcode(add_space_brackets(stripslashes($pix_array_your_field[$i2][$field])));
  458.                             $i2++;
  459.                             } ?>
  460.                             <div class="clear"></div>
  461.                             <input type="submit" class="button medium" value="<?php echo get_pix_option('pix_array_'.$form.'_button'); ?>">
  462.                         </fieldset>
  463.                     </form>
  464.                 </div><!-- .contactForm -->
  465.  
  466.  
  467.  
  468.  
  469.     <?php
  470.  
  471.         echo $after_widget;
  472.   }
  473.  
  474.     function update($new_instance, $old_instance){
  475.       $instance = $old_instance;
  476.       $instance['title'] = strip_tags(stripslashes($new_instance['title']));
  477.       $instance['form'] = strip_tags(stripslashes($new_instance['form']));
  478.  
  479.     return $instance;
  480.   }
  481.  
  482.     function form($instance){
  483.       $instance = wp_parse_args( (array) $instance, array('title'=> __('Contact us','delight'), 'form'=>'') );
  484.  
  485.       $title = htmlspecialchars($instance['title']);
  486.       $form = htmlspecialchars($instance['form']);
  487.  
  488.         echo '<p><label for="' . $this->get_field_name('title') . '">Title <input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></label></p>';
  489.        
  490.         ?>
  491.         <p>
  492.             <label for="<?php echo $this->get_field_name('form'); ?>">Select a form</label>
  493.                 <select id="<?php echo $this->get_field_name('form'); ?>" name="<?php echo $this->get_field_name('form'); ?>" class="widefat">
  494.                     <?php
  495.                         $i = 0;
  496.                         $pix_array_your_forms = get_pix_option('pix_array_your_forms_');
  497.                         while($i<count($pix_array_your_forms)){ ?>
  498.                             <option value="<?php echo sanitize_title($pix_array_your_forms[$i]); ?>"<?php selected( $instance['form'], sanitize_title($pix_array_your_forms[$i]) ); ?>><?php echo $pix_array_your_forms[$i]; ?></option>
  499.                             <?php $i++;
  500.                         }
  501.                     ?>
  502.  
  503.                 </select>
  504.         </p>
  505.         <?php
  506.  
  507.   }
  508.  
  509. }
  510.  
  511.   function pixContactInit() {
  512.     register_widget('pixContactForm');
  513.   }
  514.   add_action('widgets_init', 'pixContactInit');
  515. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement