Changeset 981794
- Timestamp:
- 09/05/2014 01:28:19 PM (12 years ago)
- Location:
- currently-reading/trunk
- Files:
-
- 2 edited
-
CurrentlyReading.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
currently-reading/trunk/CurrentlyReading.php
r897607 r981794 1 <?php 2 /* 3 Plugin Name: Currently Reading 4 Plugin URI: http://blog.damn.org.za/widgets/ 5 Description: Display a Currently Reading widget using an image from (and linking to) the Google Books Website 6 Author: Eugéne Roux 7 Version: 3.4 8 Author URI: http://damn.org.za/ 9 */ 10 11 // 12 // CurrentlyReading Class 13 // 14 class CurrentlyReading extends WP_Widget { 15 /** constructor */ 16 function CurrentlyReading() { 17 $widget_ops = array( 'classname' => 'widget_reading', 'description' => __( 'Display a Currently Reading widget using an image from (and linking to) the Google Books website' ), 'internalcss' => true ); 18 $this->WP_Widget( 'reading', __( 'Reading', 'reading_widget' ), $widget_ops ); 19 $this->widget_defaults = array( 20 'internalcss' => true, 21 'boxshadow' => true, 22 ); 23 } 24 25 // 26 // @see WP_Widget::widget 27 // 28 function widget($args, $instance) { 29 $args = wp_parse_args( $args, $this->widget_defaults ); 30 extract( $args ); 31 //$widget_options = wp_parse_args( $instance, $this->widget_defaults ); 32 33 $title = apply_filters('widget_title', $instance['title']); 34 $internalcss = $instance["internalcss"] ? true : false; 35 $boxshadow = $instance["boxshadow"] ? true : false; 36 37 if ($instance['isbn'] != "") { // No point in a "Currently Reading" if you aren't, is there? 38 39 echo $before_widget; 40 41 if ( $title ) 42 echo $before_title . $title . $after_title; // This way we get to choose a "No Title" scenario... 43 44 $spacechars = array(' ', '-', '_'); 45 $myisbn = str_replace($spacechars, "", $instance['isbn']); 46 47 print("\n\t<!-- ISBN: " . $instance['isbn'] . " -->\n"); 48 49 print("\t\t<div"); 50 if ( $internalcss ) { 51 print(" style='margin: 1em; padding: 2ex;'"); 52 } 53 print( " class='currentlyreading' id='currenlyreading-ISBN" . $myisbn . "'>\n"); 54 55 print( "\t\t\t<a href='http://books.google.com/books?vid=ISBN$myisbn'>"); 56 print( "<img class='currentlyreading' id='currenlyreading-ISBN" . $myisbn . "-img' " ); 57 if ( $boxshadow ) { 58 print( "style='-moz-box-shadow: #CCC 5px 5px 5px; -webkit-box-shadow: #CCC 5px 5px 5px; " ); 59 print( "-khtml-box-shadow: #CCC 5px 5px 5px; box-shadow: #CCC 5px 5px 5px;' " ); 60 } 61 print( "src='http://books.google.com/books?vid=ISBN$myisbn&printsec=frontcover&img=1&zoom=1' "); 62 print( "alt='ISBN: " . $instance['isbn'] . "' title='ISBN: " . $instance['isbn'] . "'/></a>\n"); 63 print( "\t\t</div>\n"); 64 65 echo $after_widget; 66 } 67 } 68 69 // 70 // @see WP_Widget::update 71 // 72 function update($new_instance, $old_instance) { 73 $instance = $old_instance; 74 $instance['title'] = strip_tags( $new_instance['title'] ); 75 $instance['isbn'] = strip_tags( $new_instance['isbn'] ); 76 $instance['internalcss'] = $new_instance['internalcss'] ? 1 : 0; 77 $instance['boxshadow'] = $new_instance['boxshadow'] ? 1 : 0; 78 return $instance; 79 } 80 81 // 82 // @see WP_Widget::form 83 // 84 function form( $instance ) { 85 $instance = wp_parse_args( $instance, $this->widget_defaults ); 86 extract( $instance ); 87 88 $title = esc_attr( $instance['title'] ); 89 $isbn = esc_attr( $instance['isbn'] ); 90 $internalcss = $instance['internalcss'] ? "checked='checked'" : ""; 91 $boxshadow = $instance['boxshadow'] ? "checked='checked'" : ""; 92 93 print( "\t<p>\n\t\t<label for='" . $this->get_field_id("title") . "'>" ); _e( "Title:" ); 94 print( "\n\t\t\t<input class='widefat' id='" . $this->get_field_id('title') . "' name='" ); 95 print( $this->get_field_name('title') . "' type='text' value='" . $title ); 96 print( "' />\n\t\t</label>\n\t\t<em>Leave blank for no title</em>\n\t</p>\n" ); 97 98 print( "\t<p>\n\t\t<label for='" . $this->get_field_id("isbn") . "'>" ); _e( "ISBN:" ); 99 print( "\n\t\t\t<input class='widefat' id='" . $this->get_field_id("isbn") . "' name='" ); 100 print( $this->get_field_name("isbn") . "' type='text' value='" . $isbn . "' />\n\t\t</label>\n\t</p>\n" ); 101 102 print( "\t<p>\n" ); 103 print( "\t\t<input class='checkbox' type='checkbox' " . $internalcss ); 104 print( " id='" . $this->get_field_id("internalcss") . "' name='" . $this->get_field_name("internalcss") . "'/>\n" ); 105 print( "\t\t<label for='" . $this->get_field_id("internalcss") . "'>" ); _e( "Pad the Image" ); 106 print( "\n\t\t<br />\n" ); 107 print( "\t\t<input class='checkbox' type='checkbox' " . $boxshadow ); 108 print( " id='" . $this->get_field_id("boxshadow") . "' name='" . $this->get_field_name("boxshadow") . "'/>\n" ); 109 print( "\t\t<label for='" . $this->get_field_id("boxshadow") . "'>" ); _e( "Display a Box-Shadow" ); 110 print( "</label>\n\t</p>\n" ); 111 112 } 113 } 114 115 // 116 // register CurrentlyReading widget 117 // 118 add_action('widgets_init', create_function('', 'return register_widget( "CurrentlyReading" );')); 119 1 -
currently-reading/trunk/readme.txt
r897599 r981794 3 3 Tags: books, read, reading, admin, administration, jadb 4 4 Requires at least: 2.8 5 Tested up to: 3.95 Tested up to: 4.0 6 6 Stable tag: trunk 7 7
Note: See TracChangeset
for help on using the changeset viewer.