Making WordPress.org

Ticket #307: meta-307.diff

File meta-307.diff, 2.2 KB (added by georgestephanis, 10 years ago)
  • inc/widgets.php

     
    6666                                <h4 class="sponsor-level-title"><?php echo esc_html( $term->name ); ?></h4>
    6767
    6868                                <?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                                        ?>
    6977
    70                                         <a class="sponsor-logo" href="<?php the_permalink(); ?>">
     78                                        <a class="sponsor-logo" href="<?php echo esc_url( $link ); ?>">
    7179                                                <?php ( has_post_thumbnail() ) ? the_post_thumbnail() : the_title(); ?>
    7280                                        </a>
    7381
     
    8290        }
    8391
    8492        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'];
    8796                ?>
    8897                <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>
    8999                <?php
    90100        }
    91101
    92102        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';
    96107                return $instance;
    97108        }
    98109}