Plugin Directory

Changeset 1157830


Ignore:
Timestamp:
05/11/2015 10:49:31 AM (11 years ago)
Author:
eroux
Message:

Allow the centring of the Book Cover; Cache Google Books API call data

Location:
currently-reading/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • currently-reading/trunk/CurrentlyReading.php

    r1157374 r1157830  
    55    Description: Display a Currently Reading widget using the Google Books API
    66    Author: Eugéne Roux
    7     Version: 4.0.2
     7    Version: 4.0.3
    88    Author URI: http://damn.org.za/
    99 */
     
    1818        $this->widget_defaults = [
    1919            'internalcss' => true,
     20            'centercover' => false,
    2021            'boxshadow'   => true,
    21             'booksapi'    => false,
     22            'booksapi'    => true,
     23            'cachedays'   => 30,
    2224            'domain'      => 'google.com',
    2325        ];
     
    3436        $title = apply_filters( 'widget_title', $instance[ 'title' ]);
    3537        $internalcss = $instance[ "internalcss" ] ? true : false;
     38        $centercover = $instance[ "centercover" ] ? true : false;
    3639        $boxshadow   = $instance[ "boxshadow" ]   ? true : false;
    3740        $booksapi    = $instance[ "booksapi" ]    ? true : false;
     41        $cachedays   = $instance[ "cachedays" ]   ? $instance[ "cachedays" ] : 30;
    3842        $localdomain = $instance[ "domain" ]      ? $instance[ "domain" ] : "google.com";
    3943
     
    4852
    4953            if ( $booksapi == true ) {
    50                 try {
    51                     $isbnjson = json_decode( file_get_contents( "https://www.googleapis.com/books/v1/volumes?q=isbn:" . $myisbn ), true );
    52                 } catch (Exception $e) {
     54                $preerror = ini_get('display_errors');
     55                ini_set( 'display_errors', '0' );
     56
     57                $cache = plugin_dir_path( __FILE__ ) . "." . $myisbn . ".cache";
     58                #print("\n\t<!-- Cache file is " . $cache . "... -->\n");
     59
     60                if ( file_exists( $cache ) and time() - filectime( $cache ) < $cachedays * 24 * 60 * 60 ) {
     61                    $bookdata = file_get_contents( $cache );
     62                    $isbnjson = json_decode( $bookdata, true );
     63                    print("\n\t<!-- Cache file read... -->\n");
     64                } elseif (( $bookdata = file_get_contents( "https://www.googleapis.com/books/v1/volumes?q=isbn:" . $myisbn ))) {
     65                    print("\n\t<!-- Google Books API call successful... Write cache file. -->\n");
     66                    if ( !file_put_contents( $cache, $bookdata )) {
     67                        print("\n\t<!-- Cache file is not writable... This will end in tears. -->\n");
     68                    }
     69                    $isbnjson = json_decode( $bookdata, true );
     70                } else {
    5371                    $booksapi = false;
    54                     print("\n\t<!-- Google Books API Check Failed - Disabled -->\n");
     72                    print("\n\t<!-- Google Books API call Failed - Disabled -->\n");
    5573                }
     74
     75                ini_set( 'display_errors', $preerror );
    5676            }
    5777
     78            print( "\t\t<div" );
     79
     80            if ( $centercover or $internalcss ) {
     81                print( " style='" );
     82                if ( $centercover )
     83                    print( "margin-left:auto;margin-right:auto;width:128px;" );
     84                if ( $internalcss )
     85                    print( "padding:1em 1em 0;" );          // print( " style='margin: 1em; padding: 2ex;'" );
     86                print( "'" );
     87            }
     88            print( " class='currentlyreading' id='currenlyreading-ISBN" . $myisbn . "'>\n");
     89
     90            $shadow = '';
     91            if ( $boxshadow )
     92                $shadow = "style='-moz-box-shadow: #CCC 5px 5px 5px; -webkit-box-shadow: #CCC 5px 5px 5px; -khtml-box-shadow: #CCC 5px 5px 5px; box-shadow: #CCC 5px 5px 5px;' ";
     93
    5894            if ( $booksapi == true and $isbnjson[ "totalItems" ] > 0 ) {
    5995
    60                 print("\n\t<!-- ISBN: " . $myisbn . " / Title: " . $isbnjson[ 'items' ][0][ 'volumeInfo' ][ 'title' ] . " -->\n");
    61 
    62                 print( "\t\t<div" );
    63 
    64                 if ( $internalcss )
    65                     print( " style='padding: 1em 1em 0;'" );        // print( " style='margin: 1em; padding: 2ex;'" );
    66 
    67                 print( " class='currentlyreading' id='currenlyreading-ISBN" . $myisbn . "'>\n");
    68 
    6996                $googlelink = $isbnjson[ 'items' ][0][ 'volumeInfo' ][ 'canonicalVolumeLink' ];
    70                 print("\n\t<!-- Google Canonical Volume Link: " . $googlelink . " -->\n");
    71 
    72                 print( "\t\t\t<a href='" . str_replace( "google.com", $localdomain, $googlelink ) . "'>");
     97
     98                print( "\t\t\t<a href='" . str_replace( "google.com", $localdomain, $googlelink ) . "'>" );
    7399                print( "<img class='currentlyreading' id='currenlyreading-ISBN" . $myisbn . "-img' " );
    74 
    75                 if ( $boxshadow ) {
    76                     print( "style='-moz-box-shadow: #CCC 5px 5px 5px; -webkit-box-shadow: #CCC 5px 5px 5px; " );
    77                     print( "-khtml-box-shadow: #CCC 5px 5px 5px; box-shadow: #CCC 5px 5px 5px;' " );
    78                 }
    79 
     100                print( $shadow );
    80101                print( "src='"   . $isbnjson[ 'items' ][0][ 'volumeInfo' ][ 'imageLinks' ][ 'thumbnail' ]   . "' " );
    81102                print( "alt='"   . $isbnjson[ 'items' ][0][ 'volumeInfo' ][ 'title' ]                       . "' ");
    82103                print( "title='" . $isbnjson[ 'items' ][0][ 'volumeInfo' ][ 'title' ]                       . "'/></a>\n");
    83                 print( "\t\t</div>\n");
    84104
    85105            } else if ( $booksapi == true and $isbnjson[ "totalItems" ] == 0 ) {
    86106
    87                 print( "\n\t<!-- ISBN: " . $myisbn . " / No Google Books Entry Found -->\n");
    88                 print( "\n\t<div class='currentlyreading' id='currenlyreading-ISBN" . $myisbn . "'" );
    89                 if ( $internalcss )
    90                     print( " style='padding: 1em 1em 0 1em;'" );
    91                 print( ">No Google Books Entry Found for ISBN: <em>" . $myisbn . "</em></div>\n");
     107                print( "\t\t\t<em>No Google Books Entry Found for ISBN: <em>" . $myisbn . "</em>\n");
    92108
    93109            } else {
    94110
    95                 print("\n\t<!-- ISBN: " . $myisbn . " [Direct Link into Google Domain] -->\n");
    96 
    97                 print( "\t\t<div" );
    98 
    99                 if ( $internalcss )
    100                     print( " style='padding: 1em 1em 0;'" );        // print( " style='margin: 1em; padding: 2ex;'" );
    101 
    102                 print( " class='currentlyreading' id='currenlyreading-ISBN" . $myisbn . "'>\n");
    103 
    104                 print( "\n\t<!-- ISBN: " . $myisbn . " / Google Books API Disabled -->\n");
    105 
    106                 print( "\t\t\t<a href='http://books." . $localdomain . "/books?vid=ISBN$myisbn'>");
     111                print( "\t\t\t<a href='http://books." . $localdomain . "/books?vid=ISBN$myisbn'>" );
    107112                print( "<img class='currentlyreading' id='currenlyreading-ISBN" . $myisbn . "-img' " );
    108 
    109                 if ( $boxshadow ) {
    110                     print( "style='-moz-box-shadow: #CCC 5px 5px 5px; -webkit-box-shadow: #CCC 5px 5px 5px; " );
    111                     print( "-khtml-box-shadow: #CCC 5px 5px 5px; box-shadow: #CCC 5px 5px 5px;' " );
    112                 }
    113 
     113                print( $shadow );
    114114                print( "src='http://books." . $localdomain . "/books?vid=ISBN$myisbn&printsec=frontcover&img=1&zoom=1' ");
    115115                print( "alt='ISBN: " . $instance['isbn'] . "' title='ISBN: " . $instance['isbn'] . "'/></a>\n");
    116116
    117                 print( "\t\t</div>\n");
    118117            }
    119118
     119            print( "\t\t</div>\n");
    120120            echo $after_widget;
    121121        }
     
    124124    //
    125125    //  @see WP_Widget::update
     126    //
     127    //  Populates any unknown fields to ensure a coherent instance
    126128    //
    127129    function update( $new_instance, $old_instance ) {
     
    130132        $instance[ 'isbn' ]         = strip_tags( $new_instance[ 'isbn' ]);
    131133        $instance[ 'internalcss' ]  = $new_instance[ 'internalcss' ] ? 1 : 0;
     134        $instance[ "centercover" ]  = $new_instance[ "centercover" ] ? 1 : 0;
    132135        $instance[ 'boxshadow' ]    = $new_instance[ 'boxshadow'   ] ? 1 : 0;
    133136        $instance[ 'booksapi' ]     = $new_instance[ 'booksapi' ]    ? 1 : 0;
     137        $instance[ "cachedays" ]    = $new_instance[ "cachedays" ]   ? $new_instance[ "cachedays" ] : 30;
    134138        $instance[ "domain" ]       = $new_instance[ "domain" ]      ? $new_instance[ "domain" ] : "google.com";
     139
     140        if ( filter_var( $instance[ "cachedays" ], FILTER_VALIDATE_INT ) === false ) {
     141            $instance[ "cachedays" ] = 30;
     142        }
     143
    135144        return $instance;
    136145    }
     
    146155        $isbn        = esc_attr( strip_tags( $instance[ 'isbn' ]));
    147156        $internalcss = $instance[ 'internalcss' ] ? "checked='checked'" : "";
     157        $centercover = $instance[ 'centercover' ] ? "checked='checked'" : "";
    148158        $boxshadow   = $instance[ 'boxshadow' ]   ? "checked='checked'" : "";
    149159        $booksapi    = $instance[ 'booksapi' ]    ? "checked='checked'" : "";
     160        $cachedays   = $instance[ 'cachedays' ];
    150161        $activedom   = $instance[ 'domain' ];
    151162
    152         $googledomains = [
    153             'Worldwide' => 'google.com',
    154             'Afghanistan' => 'google.com.af',
    155             'Albania' => 'google.al',
    156             'Algeria' => 'google.dz',
    157             'American Samoa' => 'google.as',
    158             'Andorra' => 'google.ad',
    159             'Angola' => 'google.co.ao',
    160             'Anguilla' => 'google.com.ai',
    161             'Antigua and Barbuda' => 'google.com.ag',
    162             'Argentina' => 'google.com.ar',
    163             'Armenia' => 'google.am',
    164             'Ascension Island' => 'google.ac',
    165             'Australia' => 'google.com.au',
    166             'Austria' => 'google.at',
    167             'Azerbaijan' => 'google.az',
    168             'Bahamas' => 'google.bs',
    169             'Bahrain' => 'google.com.bh',
    170             'Bangladesh' => 'google.com.bd',
    171             'Belarus' => 'google.by',
    172             'Belgium' => 'google.be',
    173             'Belize' => 'google.com.bz',
    174             'Benin' => 'google.bj',
    175             'Bhutan' => 'google.bt',
    176             'Bolivia' => 'google.com.bo',
    177             'Bosnia and Herzegovina' => 'google.ba',
    178             'Botswana' => 'google.co.bw',
    179             'Brazil' => 'google.com.br',
    180             'British Indian Ocean Territory' => 'google.io',
    181             'British Virgin Islands' => 'google.vg',
    182             'Brunei' => 'google.com.bn',
    183             'Bulgaria' => 'google.bg',
    184             'Burkina Faso' => 'google.bf',
    185             'Burma' => 'google.com.mm',
    186             'Burundi' => 'google.bi',
    187             'Cambodia' => 'google.com.kh',
    188             'Cameroon' => 'google.cm',
    189             'Canada' => 'google.ca',
    190             'Cape Verde' => 'google.cv',
    191             'Catalonia Catalan Countries' => 'google.cat',
    192             'Central African Republic' => 'google.cf',
    193             'Chad' => 'google.td',
    194             'Chile' => 'google.cl',
    195             'China' => 'g.cn',
    196             'China' => 'google.cn',
    197             'Cocos (Keeling) Islands' => 'google.cc',
    198             'Colombia' => 'google.com.co',
    199             'Cook Islands' => 'google.co.ck',
    200             'Costa Rica' => 'google.co.cr',
    201             'Croatia' => 'google.hr',
    202             'Cuba' => 'google.com.cu',
    203             'Cyprus' => 'google.com.cy',
    204             'Czech Republic' => 'google.cz',
    205             'Democratic Republic of the Congo' => 'google.cd',
    206             'Denmark' => 'google.dk',
    207             'Djibouti' => 'google.dj',
    208             'Dominica' => 'google.dm',
    209             'Dominican Republic' => 'google.com.do',
    210             'Ecuador' => 'google.com.ec',
    211             'Egypt' => 'google.com.eg',
    212             'El Salvador' => 'google.com.sv',
    213             'Estonia' => 'google.ee',
    214             'Ethiopia' => 'google.com.et',
    215             'Federated States of Micronesia' => 'google.fm',
    216             'Fiji' => 'google.com.fj',
    217             'Finland' => 'google.fi',
    218             'France' => 'google.fr',
    219             'French Guiana' => 'google.gf',
    220             'Gabon' => 'google.ga',
    221             'Gambia' => 'google.gm',
    222             'Georgia' => 'google.ge',
    223             'Germany' => 'google.de',
    224             'Ghana' => 'google.com.gh',
    225             'Gibraltar' => 'google.com.gi',
    226             'Greece' => 'google.gr',
    227             'Greenland' => 'google.gl',
    228             'Guadeloupe' => 'google.gp',
    229             'Guatemala' => 'google.com.gt',
    230             'Guernsey' => 'google.gg',
    231             'Guyana' => 'google.gy',
    232             'Haiti' => 'google.ht',
    233             'Honduras' => 'google.hn',
    234             'Hong Kong' => 'google.com.hk',
    235             'Hungary' => 'google.hu',
    236             'Iceland' => 'google.is',
    237             'India' => 'google.co.in',
    238             'Indonesia' => 'google.co.id',
    239             'Iran' => 'google.ir',
    240             'Iraq' => 'google.iq',
    241             'Ireland' => 'google.ie',
    242             'Isle of Man' => 'google.im',
    243             'Israel' => 'google.co.il',
    244             'Italy' => 'google.it',
    245             'Ivory Coast' => 'google.ci',
    246             'Jamaica' => 'google.com.jm',
    247             'Japan' => 'google.co.jp',
    248             'Jersey' => 'google.je',
    249             'Jordan' => 'google.jo',
    250             'Kazakhstan' => 'google.kz',
    251             'Kenya' => 'google.co.ke',
    252             'Kiribati' => 'google.ki',
    253             'Kuwait' => 'google.com.kw',
    254             'Kyrgyzstan' => 'google.kg',
    255             'Laos' => 'google.la',
    256             'Latvia' => 'google.lv',
    257             'Lebanon' => 'google.com.lb',
    258             'Lesotho' => 'google.co.ls',
    259             'Libya' => 'google.com.ly',
    260             'Liechtenstein' => 'google.li',
    261             'Lithuania' => 'google.lt',
    262             'Luxembourg' => 'google.lu',
    263             'Macedonia' => 'google.mk',
    264             'Madagascar' => 'google.mg',
    265             'Malawi' => 'google.mw',
    266             'Malaysia' => 'google.com.my',
    267             'Maldives' => 'google.mv',
    268             'Mali' => 'google.ml',
    269             'Malta' => 'google.com.mt',
    270             'Mauritius' => 'google.mu',
    271             'Mexico' => 'google.com.mx',
    272             'Moldova' => 'google.md',
    273             'Mongolia' => 'google.mn',
    274             'Montenegro' => 'google.me',
    275             'Montserrat' => 'google.ms',
    276             'Morocco' => 'google.co.ma',
    277             'Mozambique' => 'google.co.mz',
    278             'Namibia' => 'google.com.na',
    279             'Nauru' => 'google.nr',
    280             'Nepal' => 'google.com.np',
    281             'Netherlands' => 'google.nl',
    282             'New Zealand' => 'google.co.nz',
    283             'Nicaragua' => 'google.com.ni',
    284             'Niger' => 'google.ne',
    285             'Nigeria' => 'google.com.ng',
    286             'Niue' => 'google.nu',
    287             'Norfolk Island' => 'google.com.nf',
    288             'Norway' => 'google.no',
    289             'Oman' => 'google.com.om',
    290             'Pakistan' => 'google.com.pk',
    291             'Palestine' => 'google.ps',
    292             'Panama' => 'google.com.pa',
    293             'Papua New Guinea' => 'google.com.pg',
    294             'Paraguay' => 'google.com.py',
    295             'Peru' => 'google.com.pe',
    296             'Philippines' => 'google.com.ph',
    297             'Pitcairn Islands' => 'google.pn',
    298             'Poland' => 'google.pl',
    299             'Portugal' => 'google.pt',
    300             'Puerto Rico' => 'google.com.pr',
    301             'Qatar' => 'google.com.qa',
    302             'Republic of the Congo' => 'google.cg',
    303             'Romania' => 'google.ro',
    304             'Russia' => 'google.ru',
    305             'Rwanda' => 'google.rw',
    306             'Saint Helena, Ascension, Tristan da Cunha' => 'google.sh',
    307             'Saint Lucia' => 'google.com.lc',
    308             'Saint Vincent and the Grenadines' => 'google.com.vc',
    309             'Samoa' => 'google.ws',
    310             'San Marino' => 'google.sm',
    311             'Saudi Arabia' => 'google.com.sa',
    312             'Senegal' => 'google.sn',
    313             'Serbia' => 'google.rs',
    314             'Seychelles' => 'google.sc',
    315             'Sierra Leone' => 'google.com.sl',
    316             'Singapore' => 'google.com.sg',
    317             'Slovakia' => 'google.sk',
    318             'Slovenia' => 'google.si',
    319             'Solomon Islands' => 'google.com.sb',
    320             'Somalia' => 'google.so',
    321             'South Africa' => 'google.co.za',
    322             'South Korea' => 'google.co.kr',
    323             'Spain' => 'google.es',
    324             'Sri Lanka' => 'google.lk',
    325             'Sweden' => 'google.se',
    326             'Switzerland' => 'google.ch',
    327             'São Tomé and Príncipe' => 'google.st',
    328             'Taiwan' => 'google.com.tw',
    329             'Tajikistan' => 'google.com.tj',
    330             'Tanzania' => 'google.co.tz',
    331             'Thailand' => 'google.co.th',
    332             'Timor-Leste' => 'google.tl',
    333             'Togo' => 'google.tg',
    334             'Tokelau' => 'google.tk',
    335             'Tonga' => 'google.to',
    336             'Trinidad and Tobago' => 'google.tt',
    337             'Tunisia' => 'google.com.tn',
    338             'Tunisia' => 'google.tn',
    339             'Turkey' => 'google.com.tr',
    340             'Turkmenistan' => 'google.tm',
    341             'Uganda' => 'google.co.ug',
    342             'Ukraine' => 'google.com.ua',
    343             'United Arab Emirates' => 'google.ae',
    344             'United Kingdom' => 'google.co.uk',
    345             'United States Virgin Islands' => 'google.co.vi',
    346             'United States' => 'google.us',
    347             'Uruguay' => 'google.com.uy',
    348             'Uzbekistan' => 'google.co.uz',
    349             'Vanuatu' => 'google.vu',
    350             'Venezuela' => 'google.co.ve',
    351             'Vietnam' => 'google.com.vn',
    352             'Zambia' => 'google.co.zm',
    353             'Zimbabwe' => 'google.co.zw',
    354         ];
     163        $googledomains = [ 'Worldwide' => 'google.com', 'Afghanistan' => 'google.com.af', 'Albania' => 'google.al', 'Algeria' => 'google.dz', 'American Samoa' => 'google.as', 'Andorra' => 'google.ad', 'Angola' => 'google.co.ao', 'Anguilla' => 'google.com.ai', 'Antigua and Barbuda' => 'google.com.ag', 'Argentina' => 'google.com.ar', 'Armenia' => 'google.am', 'Ascension Island' => 'google.ac', 'Australia' => 'google.com.au', 'Austria' => 'google.at', 'Azerbaijan' => 'google.az', 'Bahamas' => 'google.bs', 'Bahrain' => 'google.com.bh', 'Bangladesh' => 'google.com.bd', 'Belarus' => 'google.by', 'Belgium' => 'google.be', 'Belize' => 'google.com.bz', 'Benin' => 'google.bj', 'Bhutan' => 'google.bt', 'Bolivia' => 'google.com.bo', 'Bosnia and Herzegovina' => 'google.ba', 'Botswana' => 'google.co.bw', 'Brazil' => 'google.com.br', 'British Indian Ocean Territory' => 'google.io', 'British Virgin Islands' => 'google.vg', 'Brunei' => 'google.com.bn', 'Bulgaria' => 'google.bg', 'Burkina Faso' => 'google.bf', 'Burma' => 'google.com.mm', 'Burundi' => 'google.bi', 'Cambodia' => 'google.com.kh', 'Cameroon' => 'google.cm', 'Canada' => 'google.ca', 'Cape Verde' => 'google.cv', 'Catalonia Catalan Countries' => 'google.cat', 'Central African Republic' => 'google.cf', 'Chad' => 'google.td', 'Chile' => 'google.cl', 'China' => 'g.cn', 'China' => 'google.cn', 'Cocos (Keeling) Islands' => 'google.cc', 'Colombia' => 'google.com.co', 'Cook Islands' => 'google.co.ck', 'Costa Rica' => 'google.co.cr', 'Croatia' => 'google.hr', 'Cuba' => 'google.com.cu', 'Cyprus' => 'google.com.cy', 'Czech Republic' => 'google.cz', 'Democratic Republic of the Congo' => 'google.cd', 'Denmark' => 'google.dk', 'Djibouti' => 'google.dj', 'Dominica' => 'google.dm', 'Dominican Republic' => 'google.com.do', 'Ecuador' => 'google.com.ec', 'Egypt' => 'google.com.eg', 'El Salvador' => 'google.com.sv', 'Estonia' => 'google.ee', 'Ethiopia' => 'google.com.et', 'Federated States of Micronesia' => 'google.fm', 'Fiji' => 'google.com.fj', 'Finland' => 'google.fi', 'France' => 'google.fr', 'French Guiana' => 'google.gf', 'Gabon' => 'google.ga', 'Gambia' => 'google.gm', 'Georgia' => 'google.ge', 'Germany' => 'google.de', 'Ghana' => 'google.com.gh', 'Gibraltar' => 'google.com.gi', 'Greece' => 'google.gr', 'Greenland' => 'google.gl', 'Guadeloupe' => 'google.gp', 'Guatemala' => 'google.com.gt', 'Guernsey' => 'google.gg', 'Guyana' => 'google.gy', 'Haiti' => 'google.ht', 'Honduras' => 'google.hn', 'Hong Kong' => 'google.com.hk', 'Hungary' => 'google.hu', 'Iceland' => 'google.is', 'India' => 'google.co.in', 'Indonesia' => 'google.co.id', 'Iran' => 'google.ir', 'Iraq' => 'google.iq', 'Ireland' => 'google.ie', 'Isle of Man' => 'google.im', 'Israel' => 'google.co.il', 'Italy' => 'google.it', 'Ivory Coast' => 'google.ci', 'Jamaica' => 'google.com.jm', 'Japan' => 'google.co.jp', 'Jersey' => 'google.je', 'Jordan' => 'google.jo', 'Kazakhstan' => 'google.kz', 'Kenya' => 'google.co.ke', 'Kiribati' => 'google.ki', 'Kuwait' => 'google.com.kw', 'Kyrgyzstan' => 'google.kg', 'Laos' => 'google.la', 'Latvia' => 'google.lv', 'Lebanon' => 'google.com.lb', 'Lesotho' => 'google.co.ls', 'Libya' => 'google.com.ly', 'Liechtenstein' => 'google.li', 'Lithuania' => 'google.lt', 'Luxembourg' => 'google.lu', 'Macedonia' => 'google.mk', 'Madagascar' => 'google.mg', 'Malawi' => 'google.mw', 'Malaysia' => 'google.com.my', 'Maldives' => 'google.mv', 'Mali' => 'google.ml', 'Malta' => 'google.com.mt', 'Mauritius' => 'google.mu', 'Mexico' => 'google.com.mx', 'Moldova' => 'google.md', 'Mongolia' => 'google.mn', 'Montenegro' => 'google.me', 'Montserrat' => 'google.ms', 'Morocco' => 'google.co.ma', 'Mozambique' => 'google.co.mz', 'Namibia' => 'google.com.na', 'Nauru' => 'google.nr', 'Nepal' => 'google.com.np', 'Netherlands' => 'google.nl', 'New Zealand' => 'google.co.nz', 'Nicaragua' => 'google.com.ni', 'Niger' => 'google.ne', 'Nigeria' => 'google.com.ng', 'Niue' => 'google.nu', 'Norfolk Island' => 'google.com.nf', 'Norway' => 'google.no', 'Oman' => 'google.com.om', 'Pakistan' => 'google.com.pk', 'Palestine' => 'google.ps', 'Panama' => 'google.com.pa', 'Papua New Guinea' => 'google.com.pg', 'Paraguay' => 'google.com.py', 'Peru' => 'google.com.pe', 'Philippines' => 'google.com.ph', 'Pitcairn Islands' => 'google.pn', 'Poland' => 'google.pl', 'Portugal' => 'google.pt', 'Puerto Rico' => 'google.com.pr', 'Qatar' => 'google.com.qa', 'Republic of the Congo' => 'google.cg', 'Romania' => 'google.ro', 'Russia' => 'google.ru', 'Rwanda' => 'google.rw', 'Saint Helena, Ascension, Tristan da Cunha' => 'google.sh', 'Saint Lucia' => 'google.com.lc', 'Saint Vincent and the Grenadines' => 'google.com.vc', 'Samoa' => 'google.ws', 'San Marino' => 'google.sm', 'Saudi Arabia' => 'google.com.sa', 'Senegal' => 'google.sn', 'Serbia' => 'google.rs', 'Seychelles' => 'google.sc', 'Sierra Leone' => 'google.com.sl', 'Singapore' => 'google.com.sg', 'Slovakia' => 'google.sk', 'Slovenia' => 'google.si', 'Solomon Islands' => 'google.com.sb', 'Somalia' => 'google.so', 'South Africa' => 'google.co.za', 'South Korea' => 'google.co.kr', 'Spain' => 'google.es', 'Sri Lanka' => 'google.lk', 'Sweden' => 'google.se', 'Switzerland' => 'google.ch', 'São Tomé and Príncipe' => 'google.st', 'Taiwan' => 'google.com.tw', 'Tajikistan' => 'google.com.tj', 'Tanzania' => 'google.co.tz', 'Thailand' => 'google.co.th', 'Timor-Leste' => 'google.tl', 'Togo' => 'google.tg', 'Tokelau' => 'google.tk', 'Tonga' => 'google.to', 'Trinidad and Tobago' => 'google.tt', 'Tunisia' => 'google.com.tn', 'Tunisia' => 'google.tn', 'Turkey' => 'google.com.tr', 'Turkmenistan' => 'google.tm', 'Uganda' => 'google.co.ug', 'Ukraine' => 'google.com.ua', 'United Arab Emirates' => 'google.ae', 'United Kingdom' => 'google.co.uk', 'United States Virgin Islands' => 'google.co.vi', 'United States' => 'google.us', 'Uruguay' => 'google.com.uy', 'Uzbekistan' => 'google.co.uz', 'Vanuatu' => 'google.vu', 'Venezuela' => 'google.co.ve', 'Vietnam' => 'google.com.vn', 'Zambia' => 'google.co.zm', 'Zimbabwe' => 'google.co.zw' ];
    355164
    356165        print( "\t<p>\n\t\t<label for='" . $this->get_field_id("title") . "'>" ); _e( "Title:" );
     
    366175        print( "\t\t<input class='checkbox' type='checkbox' " . $booksapi );
    367176        print( " id='" . $this->get_field_id( "booksapi" ) . "' name='" . $this->get_field_name( "booksapi" ) . "'/>\n" );
    368         print( "\t\t<label for='" . $this->get_field_id( "booksapi" ) . "'>" ); _e( "Use Google Books API" );
    369         print( "</label>\n\t</p>\n" );
     177        print( "\t\t<label for='" . $this->get_field_id( "booksapi" ) . "'>" ); _e( "Use the Google Books API" );
     178        print( "</label>\n\t<br />" );
     179
     180        print( "\t\t<input class='checkbox' type='checkbox' " . $centercover );
     181        print( " id='" . $this->get_field_id( "centercover" ) . "' name='" . $this->get_field_name( "centercover" ) . "'/>\n" );
     182        print( "\t\t<label for='" . $this->get_field_id( "centercover" ) . "'>" ); _e( "Center the Book Cover" );
     183        print( "</label>\n\t<br />\n" );
    370184
    371185        print( "\t\t<input class='checkbox' type='checkbox' " . $internalcss );
    372186        print( " id='" . $this->get_field_id( "internalcss" ) . "' name='" . $this->get_field_name( "internalcss" ) . "'/>\n" );
    373187        print( "\t\t<label for='" . $this->get_field_id( "internalcss" ) . "'>" ); _e( "Pad the Image" );
    374         print( "</label>\n\t</p>\n" );
     188        print( "</label>\n\t<br />\n" );
    375189
    376190        print( "\t\t<input class='checkbox' type='checkbox' " . $boxshadow );
     
    379193        print( "\t\t<label for='" . $this->get_field_id( "boxshadow" ) . "'>" ); _e( "Display a Box-Shadow" );
    380194        print( "</label>\n\t</p>\n" );
     195
     196        print( "\t<p>\n\t\t<label for='" . $this->get_field_id( "cachedays" ) . "'>" ); _e( "Cache Data for (days):" );
     197        print( "\n\t\t\t<input class='widefat' id='" . $this->get_field_id( 'cachedays' ) . "' name='" );
     198        print( $this->get_field_name( "cachedays" ) . "' type='text' value='" . $cachedays . "' />\n\t\t</label>\n\t</p>\n" );
    381199
    382200        print( "\t<p>\n" );
  • currently-reading/trunk/readme.txt

    r1157374 r1157830  
    4949== Frequently Asked Questions ==
    5050
    51 **I get a '*Warning: file_get_contents ... : failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden*' Error in my logs and no books are displayed. Why is this happening?**
     51**I Get a '*Warning: file_get_contents ... : failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden*' Error on My Blog With No Books Displayed. Why Is This Happening?**
    5252
    53 Your web-site has been configure not to allow outgoing HTTP requests and you have 'Use Google API' enabled.
     53Your web-site has been configure not to allow outgoing HTTP requests and you have 'Use Google API' enabled or Google rejected your connection.
    5454
    55 Please de-select the 'Use Google API' option to use the direct connection instead.
     55If the automated fail-back failed, please de-select the 'Use Google API' option to use the direct connection instead nd report this as a bug.
    5656
    57 **I get a '*No Google Books Entry Found for ISBN:NUMBER*' on my Blog... Why?**
     57**I Get a '*No Google Books Entry Found for ISBN:NUMBER*' on My Blog... Why?**
    5858
    5959Sometimes Google Books does not return any valid responses on ISBNs. Try the following:
     
    63633. Find the eBook on Google's Books Web Page and use its ISBN
    6464
    65 **Are you planing to insert other sources than Google Books to the Currently Reading widget?**
     65**I Get an *Image Not Available* Image on My Blog Instead of the Book Cover, and Clicking It Gives Me a Google 404 Error**
     66
     67You will only see this if you are *not* using the Google Books API or the if you are and it failed back to the previous system for some reason.
     68
     69Double-check the ISBN you used; it's either wrong or Google does not have an entry for the book referenced.
     70
     71**Are You Planning to Insert Other Sources Than Google Books to the Currently Reading Widget?**
    6672
    6773I'll have a look into supporting Amazon, though they do make you jump through hoops to use their API (which is the reason I settled on using Google Books to start with).
    6874
    69 **Is there a way to get this plugin to do a library of all of your books into WordPress?**
     75**Is There a Way to Get This Plug-In to Do a Library of All of Your Books Into WordPress?**
    7076
    71 It's not currently possible with this plugin, no.
     77It's not currently possible with this plug-in, no.
    7278
    7379I'll give it a bit of thought and see if I can extend it to do that; but it will most likely need the creation of an alternate plugin to do that.
     
    8591== Changelog ==
    8692
     93= 4.0.3 =
     94
     95* Allow the centring of the Book Cover within the sidebar (Props Andy Tegala for the suggestion)
     96* Cache Google Books API call (if successful) for (default) 30 days
     97* (Semi-)Gently fall back to previous behaviour if Google Books API call fails
     98
    8799= 4.0.2 =
    88100
    89 * Allow (and default to) *not* using the Google Books API in preference to the older -- direct -- connection
     101* Allow *not* using the Google Books API in preference to the older -- direct -- connection
    90102* Since I'm probably the only Saffer using this, default to "books.google.com"
    91103
Note: See TracChangeset for help on using the changeset viewer.