Help with a small PHP modifcation

Discussion in 'Web Design and Development' started by torndownunit, Feb 3, 2011.

  1. torndownunit macrumors regular

    Joined:
    Jan 4, 2009
    #1
    Hi, I am wondering if anyone can help me out. There is a widget in a Wordpress theme I would like to very slightly modify.

    You can see the widget here http://www.purewatercanada.com/wordpress/ . It's the quote widget on the right side. I'd like to add a line of text at the bottom of it that says "View more testimonials" with a link to the testimonials page.

    This is the code for the widget:

    Code:
    class theme_quote_widget extends WP_Widget {
    
        function theme_quote_widget() {
    		global $themeTitle;
    		$options = array('classname' => 'quote-widget', 'description' => __( "Theme styled quote or testimonial.") );
    		$controls = array('width' => 250, 'height' => 200);
    		$this->WP_Widget('quote', __($themeTitle.' - Quote'), $options, $controls);
        }
    
        function widget($args, $instance) {
    		global $wpdb, $shortname;
            extract( $args );
    
    		$quote = stripslashes($instance['quote']);
    		$author = stripslashes($instance['author']);
    		$details = stripslashes($instance['details']);
    
    		
    		echo $before_widget;
    
    		?>
    		<!-- Testimonial/Quote -->
    		<div class="quote">
    			<div class="quoteBox-1">
    				<div class="quoteBox-2">
    					<p><?php echo $quote; ?></p>
    				</div>
    			</div>
    		</div>
    		<div class="quoteAuthor">
    			<p class="name"><?php echo $author; ?></p>
    			<p class="details"><?php echo $details; ?></p>
    		</div>
    		
    		<div class="hr"></div>
    		<?php 
    			
    		echo $after_widget;
        }
    
        function update($new_instance, $old_instance) {				
            $instance = $old_instance;
    		$instance['quote'] = strip_tags($new_instance['quote']);
    		$instance['author'] = strip_tags($new_instance['author']);
    		$instance['details'] = strip_tags($new_instance['details']);
            return $instance;
        }
    
        function form($instance) {				
    		$quote = isset($instance['quote']) ? esc_attr($instance['quote']) : '';
    		$author = isset($instance['author']) ? esc_attr($instance['author']) : '';
    		$details = isset($instance['details']) ? esc_attr($instance['details']) : '';
            ?>
    
    		<p>
    			<label for="<?php echo $this->get_field_id('quote'); ?>"><?php _e('Quote Text:'); ?></label>
    			<textarea class="widefat" id="<?php echo $this->get_field_id('quote'); ?>" name="<?php echo $this->get_field_name('quote'); ?>"><?php echo $quote; ?></textarea>
    			<small>Enter the text being quoted.</small>
    		</p>
    		<p>
    			<label for="<?php echo $this->get_field_id('author'); ?>"><?php _e('Author Name:'); ?></label>
    			<input class="widefat" id="<?php echo $this->get_field_id('author'); ?>" name="<?php echo $this->get_field_name('author'); ?>" type="text" value="<?php echo $author; ?>" />
    			<small>The name of the person being quoted.</small>
    		</p>
    		<p>
    			<label for="<?php echo $this->get_field_id('details'); ?>"><?php _e('Author Title:'); ?></label>
    			<input class="widefat" id="<?php echo $this->get_field_id('details'); ?>" name="<?php echo $this->get_field_name('details'); ?>" type="text" value="<?php echo $details; ?>" />
    			<small>The title, company or other details associated with the person being quoted.</small>
    		</p>
    
            <?php 
        }
    
    }
    Thanks for any help anyone can give.
     
  2. elppa macrumors 68040

    elppa

    Joined:
    Nov 26, 2003
    #2
    Code:
    <!-- Testimonial/Quote -->
    <div class="quote">
    	<div class="quoteBox-1">
    		<div class="quoteBox-2">
    			<p><?php echo $quote; ?></p>
    		</div>
    	</div>
    </div>
    <div class="quoteAuthor">
    	<p class="name"><?php echo $author; ?></p>
    	<p class="details"><?php echo $details; ?></p>
    </div>
    <p><a href="/wordpress/?page_id=343">View more testimonials »</a></p>
    
    <div class="hr"></div>
     
  3. torndownunit thread starter macrumors regular

    Joined:
    Jan 4, 2009

Share This Page