Ticket #307: meta-307.diff
File meta-307.diff, 2.2 KB (added by , 10 years ago) |
---|
-
inc/widgets.php
66 66 <h4 class="sponsor-level-title"><?php echo esc_html( $term->name ); ?></h4> 67 67 68 68 <?php while ( $sponsors->have_posts() ) : $sponsors->the_post(); ?> 69 <?php 70 $link = get_the_permalink(); 71 if ( ! empty( $link_type ) && 'website' == $link_type ) { 72 if ( $website = get_post_meta( get_the_ID(), '_wcpt_sponsor_website', true ) ) { 73 $link = $website; 74 } 75 } 76 ?> 69 77 70 <a class="sponsor-logo" href="<?php the_permalink(); ?>">78 <a class="sponsor-logo" href="<?php echo esc_url( $link ); ?>"> 71 79 <?php ( has_post_thumbnail() ) ? the_post_thumbnail() : the_title(); ?> 72 80 </a> 73 81 … … 82 90 } 83 91 84 92 function form( $instance ) { 85 $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); 86 $title = $instance['title']; 93 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'link_type' => 'page' ) ); 94 $title = $instance['title']; 95 $link_type = $instance['link_type']; 87 96 ?> 88 97 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', $this->textdomain ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> 98 <p><label><?php _e( 'Link:', $this->textdomain ); ?> <input name="<?php echo $this->get_field_name( 'link_type' ); ?>" type="checkbox" value="website" <?php checked( $link_type ); ?> /></label></p> 89 99 <?php 90 100 } 91 101 92 102 function update( $new_instance, $old_instance ) { 93 $instance = $old_instance; 94 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '' ) ); 95 $instance['title'] = strip_tags( $new_instance['title'] ); 103 $instance = $old_instance; 104 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '' ) ); 105 $instance['title'] = strip_tags( $new_instance['title'] ); 106 $instance['link_type'] = empty( $new_instance['link_type'] ) ? null : 'website'; 96 107 return $instance; 97 108 } 98 109 }