WordPress.org

Plugin Directory

Changeset 546528


Ignore:
Timestamp:
05/20/12 11:09:45 (2 years ago)
Author:
ramiy
Message:

Added two parameters to the sidebar widget.

Location:
bdihot/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • bdihot/trunk/bdihot.php

    r546124 r546528  
    44 * Plugin URI: http://www.bdihot.co.il/wordpress_plugin/ 
    55 * Description: This plugin allows you to add a random joke (from bdihot.co.il) using wordpress Sidebar-Widget and Dashboard-Widget systems. 
    6  * Version: 0.2 
     6 * Version: 0.3 
    77 * Author: Rami Y 
    88 * Author URI: http://www.bdihot.co.il/ 
     
    3434// Uninstall bdihot 
    3535function bdihot_uninstall() { 
    36     delete_option('bdihot_random_joke'); 
     36    delete_option( 'bdihot_random_joke' ); 
    3737} 
    3838 
     
    4545function bdihot_options() { 
    4646    $defaults = array( 
    47         'title' => __( 'Random Joke', 'bdihot' ), 
     47        'title' => __( 'Random Joke', bdihot ), 
    4848        'jokes_number' => 1, 
     49        'jokes_title' => 'false', 
     50        'jokes_icon' => 'false', 
     51        'jokes_poweredby' => 'false', 
    4952    ); 
    5053    if ( ( !$options = get_option( 'bdihot_random_joke' ) ) || !is_array( $options ) ) 
     
    6871// Register dashboard widget 
    6972function bdihot_add_dashboard_widget() { 
    70     wp_add_dashboard_widget( 'bdihot_dashboard_random_joke', __( 'Random Joke', 'bdihot' ), 'bdihot_widget_output' ); 
     73    wp_add_dashboard_widget( 'bdihot_dashboard_random_joke', __( 'Random Joke', bdihot ), 'bdihot_widget_output' ); 
    7174} 
    7275 
    7376 
    7477// The content of the widget (random joke) 
    75 function bdihot_widget_output() { 
     78function bdihot_widget_output( $show_title = false, $show_icon = false ) { 
    7679    include_once( ABSPATH . WPINC . '/feed.php' ); 
    7780 
     
    8992 
    9093    if ( $max_items == 0 ) { 
    91         echo __('No Jokes found.', 'bdihot'); 
     94        echo __('No Jokes found.', bdihot ); 
    9295    } else { 
    93         foreach ( $rss_items as $item ) :  
    94             echo '<p><a href="' . esc_url( $item->get_permalink() ) . '" title="' . $item->get_date( 'j F Y | g:i a' ) .'" target="_blank">' . esc_html( $item->get_title() ) . '</a></p>'; 
     96        foreach ( $rss_items as $item ) : 
     97            /* if ( $show_icon == true ) echo ''; */ 
     98            if ( $show_title == true ) echo '<p class="joke_title"><a href="' . esc_url( $item->get_permalink() ) . '" target="_blank">' . esc_html( $item->get_title() ) . '</a></p>'; 
    9599            echo wpautop( $item->get_description() ); 
    96100        endforeach; 
     
    117121        parent::__construct( 
    118122            'bdihot_widget', 
    119             __( 'Random Joke', 'bdihot' ), 
    120             array( 'description' => __( 'Displays Random Joke from Bdihot.co.il', 'bdihot' ), ) 
     123            __( 'Random Joke', bdihot ), 
     124            array( 'description' => __( 'Display Random Jokes from Bdihot.co.il', bdihot ), ) 
    121125        ); 
    122126    } 
     
    126130        extract( $args ); 
    127131        $title = apply_filters( 'widget_title', $instance['title'] ); 
     132        $jokes_title = empty( $instance['jokes_title'] ) ? '' : apply_filters( 'jokes_title', $instance['jokes_title'] ); 
     133        $jokes_icon = empty( $instance['jokes_icon'] ) ? '' : apply_filters( 'jokes_icon', $instance['jokes_icon'] ); 
     134        $jokes_poweredby = empty( $instance['jokes_poweredby'] ) ? '' : apply_filters( 'jokes_poweredby', $instance['jokes_poweredby'] ); 
    128135        echo $before_widget; 
     136        // title 
    129137        if ( ! empty( $title ) ) echo $before_title . $title . $after_title; 
    130         bdihot_widget_output(); 
     138        // content 
     139        bdihot_widget_output( $jokes_title, $jokes_icon ); 
     140        //  
     141        if ( $jokes_poweredby == true ) { 
     142            echo '<p class="joke_poweredby">'; 
     143            _e( 'Powered by <a href="http://www.bdihot.co.il/">Bdihot.co.il</a>', bdihot ); 
     144            echo '</p>'; 
     145        } 
     146        echo '<!--// Joke by Bdihot.co.il //-->'; 
    131147        echo $after_widget; 
    132148    } 
     
    136152        $instance = array(); 
    137153        $instance['title'] = strip_tags( $new_instance['title'] ); 
     154        $instance['jokes_title'] = strip_tags( $new_instance['jokes_title'] ); 
     155        $instance['jokes_icon'] = strip_tags( $new_instance['jokes_icon'] ); 
     156        $instance['jokes_poweredby'] = strip_tags( $new_instance['jokes_poweredby'] ); 
    138157        return $instance; 
    139158    } 
     
    145164        } 
    146165        else { 
    147             $title = __( 'Random Joke', 'bdihot' ); 
     166            $title = __( 'Random Joke', bdihot ); 
    148167        } 
     168        $jokes_title = strip_tags(stripslashes($new_instance['jokes_title'])); 
     169        $jokes_icon = strip_tags(stripslashes($new_instance['jokes_icon'])); 
     170        $jokes_poweredby = strip_tags(stripslashes($new_instance['jokes_poweredby'])); 
    149171        ?> 
    150172        <p> 
    151         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'bdihot' ); ?></label> 
    152         <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 ); ?>" /> 
     173        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', bdihot ); ?></label> 
     174        <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>" /> 
     175        </p> 
     176        <p> 
     177        <input type="checkbox" id="<?php echo $this->get_field_id( 'jokes_title' ); ?>" name="<?php echo $this->get_field_name( 'jokes_title' ); ?>" <?php if ( $instance['jokes_title'] ) echo 'checked="checked" '; ?>/> 
     178        <label for="<?php echo $this->get_field_id( 'jokes_title' ); ?>"><?php _e( 'Joke title', bdihot ); ?></label> 
     179        </p> 
     180        <!-- 
     181        <p> 
     182        <input type="checkbox" id="<?php echo $this->get_field_id( 'jokes_icon' ); ?>" name="<?php echo $this->get_field_name( 'jokes_icon' ); ?>" <?php if ( $instance['jokes_icon'] ) echo 'checked="checked" '; ?>/> 
     183        <label for="<?php echo $this->get_field_id( 'jokes_icon' ); ?>"><?php _e( 'Joke icon', bdihot ); ?></label> 
     184        </p> 
     185        --> 
     186        <p> 
     187        <input type="checkbox" id="<?php echo $this->get_field_id( 'jokes_poweredby' ); ?>" name="<?php echo $this->get_field_name( 'jokes_poweredby' ); ?>" <?php if ( $instance['jokes_poweredby'] ) echo 'checked="checked" '; ?>/> 
     188        <label for="<?php echo $this->get_field_id( 'jokes_poweredby' ); ?>"><?php _e( 'Powered by <a href="http://www.bdihot.co.il/">Bdihot.co.il</a>', bdihot ); ?></label> 
    153189        </p> 
    154190        <?php 
  • bdihot/trunk/languages/bdihot-he_IL.po

    r546124 r546528  
    44"Project-Id-Version: Bdihot\n" 
    55"Report-Msgid-Bugs-To: \n" 
    6 "POT-Creation-Date: 2012-04-07 20:54+0200\n" 
    7 "PO-Revision-Date: 2012-05-19 08:37+0200\n" 
    8 "Last-Translator: Rami <r_a_m_i@hotmail.com>\n" 
     6"POT-Creation-Date: 2012-05-20 13:36+0200\n" 
     7"PO-Revision-Date: 2012-05-20 13:38+0200\n" 
     8"Last-Translator: ramiy <r_a_m_i@hotmail.com>\n" 
    99"Language-Team: Rami <r_a_m_i@hotmail.com>\n" 
    1010"MIME-Version: 1.0\n" 
     
    1515 
    1616#: ../bdihot.php:47 
    17 #: ../bdihot.php:70 
    18 #: ../bdihot.php:119 
    19 #: ../bdihot.php:147 
     17#: ../bdihot.php:73 
     18#: ../bdihot.php:123 
     19#: ../bdihot.php:166 
    2020msgid "Random Joke" 
    2121msgstr "בדיחה אקראית" 
    2222 
    23 #: ../bdihot.php:91 
     23#: ../bdihot.php:94 
    2424msgid "No Jokes found." 
    2525msgstr "לא נמצאו בדיחות." 
    2626 
    27 #: ../bdihot.php:120 
    28 msgid "Displays Random Joke from Bdihot.co.il" 
     27#: ../bdihot.php:124 
     28msgid "Display Random Jokes from Bdihot.co.il" 
    2929msgstr "בדיחה אקראית מתוך אתר הבדיחות Bdihot.co.il" 
    3030 
    31 #: ../bdihot.php:151 
     31#: ../bdihot.php:143 
     32#: ../bdihot.php:188 
     33msgid "Powered by <a href=\"http://www.bdihot.co.il/\">Bdihot.co.il</a>" 
     34msgstr "בחסות <a href=\"http://www.bdihot.co.il/\">Bdihot.co.il</a>" 
     35 
     36#: ../bdihot.php:173 
    3237msgid "Title:" 
    3338msgstr "כותרת:" 
     39 
     40#: ../bdihot.php:178 
     41msgid "Joke title" 
     42msgstr "כותרת הבדיחה" 
     43 
     44#: ../bdihot.php:183 
     45msgid "Joke icon" 
     46msgstr "האיקון של הבדיחה" 
     47 
  • bdihot/trunk/languages/bdihot.pot

    r546124 r546528  
    44"Project-Id-Version: Bdihot\n" 
    55"Report-Msgid-Bugs-To: \n" 
    6 "POT-Creation-Date: 2012-04-07 20:54+0200\n" 
    7 "PO-Revision-Date: 2012-04-07 20:54+0200\n" 
    8 "Last-Translator: Rami <r_a_m_i@hotmail.com>\n" 
     6"POT-Creation-Date: 2012-05-20 13:36+0200\n" 
     7"PO-Revision-Date: 2012-05-20 13:36+0200\n" 
     8"Last-Translator: ramiy <r_a_m_i@hotmail.com>\n" 
    99"Language-Team: LANGUAGE <LL@li.org>\n" 
    1010"MIME-Version: 1.0\n" 
     
    1616 
    1717#: ../bdihot.php:47 
    18 #: ../bdihot.php:70 
    19 #: ../bdihot.php:119 
    20 #: ../bdihot.php:147 
     18#: ../bdihot.php:73 
     19#: ../bdihot.php:123 
     20#: ../bdihot.php:166 
    2121msgid "Random Joke" 
    2222msgstr "" 
    2323 
    24 #: ../bdihot.php:91 
     24#: ../bdihot.php:94 
    2525msgid "No Jokes found." 
    2626msgstr "" 
    2727 
    28 #: ../bdihot.php:120 
    29 msgid "Displays Random Joke from Bdihot.co.il" 
     28#: ../bdihot.php:124 
     29msgid "Display Random Jokes from Bdihot.co.il" 
    3030msgstr "" 
    3131 
    32 #: ../bdihot.php:151 
     32#: ../bdihot.php:143 
     33#: ../bdihot.php:188 
     34msgid "Powered by <a href=\"http://www.bdihot.co.il/\">Bdihot.co.il</a>" 
     35msgstr "" 
     36 
     37#: ../bdihot.php:173 
    3338msgid "Title:" 
    3439msgstr "" 
     40 
     41#: ../bdihot.php:178 
     42msgid "Joke title" 
     43msgstr "" 
     44 
     45#: ../bdihot.php:183 
     46msgid "Joke icon" 
     47msgstr "" 
     48 
  • bdihot/trunk/readme.txt

    r546124 r546528  
    2929== Changelog == 
    3030 
     31= 0.3 (20.05.2012) = 
     32* Joke title parameter to control the title display. 
     33* Powered by parameter to control the poweredby text display. 
     34 
    3135= 0.2 (07.04.2012) = 
    3236* Added Dashboard-Widget. 
Note: See TracChangeset for help on using the changeset viewer.