WordPress.org

Plugin Directory

Changeset 828794


Ignore:
Timestamp:
12/26/13 21:47:08 (4 years ago)
Author:
brandonferens
Message:

Small bug fix
Better PHP code standards in a few places
More attractive quote insert button in content area

Location:
perfect-quotes/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • perfect-quotes/trunk/includes/post-type.php

    r677097 r828794  
    6262    'show_ui'      => true, 
    6363    'query_var'    => true, 
    64     'rewrite'      => array('slug' => 'pefect-quotes-categories'), 
     64    'rewrite'      => array('slug' => 'perfect-quotes-categories'), 
    6565  ); 
    6666  register_taxonomy('perfect_quotes_category', 'perfect-quotes', $args); 
  • perfect-quotes/trunk/includes/shortcodes.php

    r677097 r828794  
    55 
    66// Action target that adds the "Insert Product(s)" button to the post/page edit screen. 
    7 function js_add_perfect_quotes_button($context){ 
     7function jsAddPerfectQuotesButton($context) { 
    88    $image_btn = plugins_url('images/perfect-space-icon.png', dirname(__FILE__)); 
    9     $out = '<a href="#TB_inline?width=450&height=700&inlineId=insert_perfect_quote" class="thickbox" title="Insert Perfect Quote"><img src="'.$image_btn.'" alt="Insert Perfect Quote" /></a>'; 
     9    $out = '<a href="#TB_inline?width=450&height=700&inlineId=insert_perfect_quote" class="button thickbox" title="Insert Perfect Quote"><img src="'.$image_btn.'" alt="Insert Perfect Quote" /> Add Quote</a>'; 
    1010    return $context . $out; 
    1111} 
    12  
    13 add_action('admin_footer','js_add_perfect_quotes_popup'); 
    14 add_action('media_buttons_context','js_add_perfect_quotes_button'); 
     12add_action('media_buttons_context', 'jsAddPerfectQuotesButton'); 
    1513 
    1614//Action target that displays the popup to insert a form to a post/page 
    17 function js_add_perfect_quotes_popup(){ 
     15function jsAddPerfectQuotesPopup() { 
    1816  $quotes = get_posts(array('post_type' => 'perfect-quotes')); 
    1917  foreach ($quotes as $quote) { 
     
    8583  <script type="text/javascript"> 
    8684 
    87     function InsertPerfectQuote(){ 
     85    function InsertPerfectQuote() { 
    8886      var quote  = jQuery("#js_perfect_quotes_shortcode_select").val(); 
    8987      var random = jQuery("#js_perfect_quote_shortcode_random").attr('checked') ? ' random="true"' : ''; 
     
    115113    <?php 
    116114} 
     115add_action('admin_footer', 'jsAddPerfectQuotesPopup'); 
    117116 
    118117// Shortcode [perfect_quotes id="10"] 
    119 function perfect_quotes_func($atts) { 
     118function perfectQuotesFunc($atts) { 
    120119  extract(shortcode_atts(array('id' => null, 'num' => null, 'random' => null, 'cat' => null), $atts)); 
    121120  if ($id == null && $num == null & $random == null) { 
    122121    return false; 
    123   } else if ($id){ 
     122  } else if ($id) { 
    124123    $args = array( 
    125124      'p'         => $id, 
     
    163162    $query->the_post(); 
    164163    echo '<div class="perfect-quotes">'; 
    165     if (get_the_title()) the_title(); 
     164    if (get_the_title()) { 
     165      the_title(); 
     166    } 
     167 
    166168    $quote_author = get_post_meta(get_the_ID(), 'perfect_quote_author', true); 
    167169    $quote_where  = get_post_meta(get_the_ID(), 'perfect_quote_where', true); 
     
    169171    if (!empty($quote_author) || !empty($quote_where)) { 
    170172      echo '<span>- '; 
    171       if (!empty($quote_author)) echo $quote_author; 
    172       if (!empty($quote_author) && !empty($quote_where)) echo ', '; 
    173       if (!empty($quote_where)) echo $quote_where; 
     173      if (!empty($quote_author)) { 
     174        echo $quote_author; 
     175      } 
     176 
     177      if (!empty($quote_author) && !empty($quote_where)) { 
     178        echo ', '; 
     179      } 
     180 
     181      if (!empty($quote_where)) { 
     182        echo $quote_where; 
     183      } 
     184 
    174185      echo '</span>'; 
    175186    } 
     
    181192  return $content; 
    182193} 
    183 add_shortcode('perfect_quotes', 'perfect_quotes_func'); 
     194add_shortcode('perfect_quotes', 'perfectQuotesFunc'); 
  • perfect-quotes/trunk/includes/widget.php

    r680622 r828794  
    11<?php 
    2 add_action('widgets_init', 'perfect_quotes_register_widget'); 
    32 
    4 function perfect_quotes_register_widget() { 
    5   register_widget('Perfect_Quotes_Widget'); 
     3function perfectQuotesRegisterWidget() { 
     4  register_widget('PerfectQuotesWidget'); 
    65} 
     6add_action('widgets_init', 'perfectQuotesRegisterWidget'); 
    77 
    8 class Perfect_Quotes_Widget extends WP_Widget { 
     8class PerfectQuotesWidget extends WP_Widget { 
    99 
    10   function __construct() { 
     10  public function __construct() { 
    1111    $widget_ops = array( 
    1212      'classname'   => 'widget_perfect_quote', 
     
    1616    $this->alt_option_name = 'widget_perfect_quote'; 
    1717 
    18     add_action( 'save_post', array(&$this, 'flush_widget_cache') ); 
    19     add_action( 'deleted_post', array(&$this, 'flush_widget_cache') ); 
    20     add_action( 'switch_theme', array(&$this, 'flush_widget_cache') ); 
     18    add_action('save_post', array(&$this, 'flushWidgetCache')); 
     19    add_action('deleted_post', array(&$this, 'flushWidgetCache')); 
     20    add_action('switch_theme', array(&$this, 'flushWidgetCache')); 
    2121  } 
    2222 
    23   function widget($args, $instance) { 
     23  public function widget($args, $instance) { 
    2424    // Retrieve cached data 
    2525    $cache = wp_cache_get('widget_perfect_quotes', 'widget'); 
     
    4848    $query = array( 
    4949      'showposts'           => $number, 
    50       'no_found_rows'       => TRUE, 
     50      'no_found_rows'       => true, 
    5151      'post_status'         => 'publish', 
    52       'ignore_sticky_posts' => TRUE, 
     52      'ignore_sticky_posts' => true, 
    5353      'post_type'           => 'perfect-quotes' 
    5454    ); 
     
    8282        <li> 
    8383          <?php 
    84           if (get_the_title()) the_title(); 
     84          if (get_the_title()) { 
     85            the_title(); 
     86          } 
     87 
    8588          $quote_author = get_post_meta(get_the_ID(), 'perfect_quote_author', true); 
    8689          $quote_where  = get_post_meta(get_the_ID(), 'perfect_quote_where', true); 
     
    8891          <span> 
    8992            <?php 
    90             if (!empty($quote_author)) echo $quote_author; 
    91             if (!empty($quote_author) && !empty($quote_where)) echo '<br />'; 
    92             if (!empty($quote_where)) echo $quote_where; 
     93            if (!empty($quote_author)) { 
     94              echo $quote_author; 
     95            } 
     96 
     97            if (!empty($quote_author) && !empty($quote_where)) { 
     98              echo '<br />'; 
     99            } 
     100 
     101            if (!empty($quote_where)) { 
     102              echo $quote_where; 
     103            } 
    93104            ?> 
    94105          </span> 
     
    108119  } 
    109120 
    110   function update($new_instance, $old_instance) { 
     121  public function update($new_instance, $old_instance) { 
    111122    $instance           = $old_instance; 
    112123    $instance['title']  = strip_tags($new_instance['title']); 
     
    115126    $instance['cat']    = $new_instance['cat']; 
    116127    // Keep the data fresh 
    117     $this->flush_widget_cache(); 
     128    $this->flushWidgetCache(); 
    118129 
    119130    $alloptions = wp_cache_get('alloptions', 'options'); 
     
    125136  } 
    126137 
    127   function flush_widget_cache() { 
     138  public function flushWidgetCache() { 
    128139    wp_cache_delete('widget_perfect_quotes', 'widget'); 
    129140  } 
    130141 
    131   function form($instance) { 
     142  public function form($instance) { 
    132143    $title = isset($instance['title']) ? esc_attr($instance['title']) : 'Perfect Quotes'; 
    133144    $number = isset($instance['number']) ? absint($instance['number']) : 1; 
    134     $random = esc_attr( $instance['random']); 
    135     $cat = isset($instance['cat']) ? $instance['cat'] : null; 
     145    $random = esc_attr($instance['random']); 
     146    $cat = isset($instance['cat']) ? $instance['cat'] : array(); 
    136147    ?> 
    137148    <p> 
  • perfect-quotes/trunk/perfect_quotes.php

    r684361 r828794  
    44Plugin URI: http://www.perfectspace.com/perfect-quotes 
    55Description: An easy to use plugin for quotes and testimonials! It integrates easily using a widget or shortcode. It does quotes perfectly! 
    6 Version: 0.3.4.2 
     6Version: 0.3.4.3 
    77Author: Brandon Ferens 
    88Author URI: http://www.perfectspace.com 
  • perfect-quotes/trunk/readme.txt

    r684361 r828794  
    44Tags: Perfect Quotes, perfect, quote, quotes, widget, plugin, shortcode, testimonial, testimonials, random 
    55Requires at least: 3.0 
    6 Tested up to: 3.5.1 
    7 Stable tag: 0.3.4.2 
     6Tested up to: 3.8 
     7Stable tag: 0.3.4.3 
    88 
    99== Description == 
     
    9696== Changelog == 
    9797 
     98= 0.3.4.3 = 
     99* Fixed a few small code errors and updated a few files with better coding standards 
     100* Made the "Add Quote" button for the main content in posts/pages a little bit more attractive 
     101 
    98102= 0.3.4.2 = 
    99103* Fixed bug in which a quote would not let you save the "author" or "where" meta data if none was originally entered. Thank to Elisa Donin for allowing me onto her dev server to figure this one out. 
     
    129133== Upgrade Notice == 
    130134 
     135= 0.3.4.3 = 
     136* Minor updates to coding standards in a few places. Small bug fix. 
     137 
    131138= 0.3.4.2 = 
    132139* Minor fix for updating meta data if no meta data existed before the update 
Note: See TracChangeset for help on using the changeset viewer.