Ned Zimmerman
7 years ago
20 changed files with 209 additions and 48 deletions
@ -0,0 +1,101 @@
|
||||
<?php |
||||
|
||||
namespace Aldine; |
||||
|
||||
class LatestBooks extends \WP_Widget |
||||
{ |
||||
/** |
||||
* Constructor. |
||||
* |
||||
* @see WP_Widget::__construct() |
||||
* |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
parent::__construct('latestbooks', __('Latest Books', 'aldine'), [ |
||||
'description' => esc_html__('Your network’s latest books.', 'aldine') |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* Front-end display of widget. |
||||
* |
||||
* @see WP_Widget::widget() |
||||
* |
||||
* @param array $args Widget arguments. |
||||
* @param array $instance Saved values from database. |
||||
*/ |
||||
public function widget($args, $instance) |
||||
{ |
||||
$number = (! empty($instance['number'])) ? absint($instance['number']) : 3; |
||||
if (!$number) |
||||
$number = 3; |
||||
if (empty($instance['title'])) { |
||||
$instance['title'] = __('Latest Books', 'aldine'); |
||||
} |
||||
echo $args['before_widget']; |
||||
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; |
||||
$books = wp_remote_get(home_url('/wp-json/pressbooks/v2/books')); |
||||
$books = json_decode($books['body'], true); ?> |
||||
<div class="books"> |
||||
<?php for($i = 0; $i < $number; $i++) { |
||||
printf( |
||||
'<div class="book"><a class="subject" href="">TK</a><a class="title" href="%1$s">%2$s</a><a class="read-more" href="%1$s">%3$s</a></div>', |
||||
$books[$i]['link'], |
||||
$books[$i]['metadata']['name'], |
||||
__('About this book →', 'aldine') |
||||
); |
||||
} ?> |
||||
</div> |
||||
<?php echo $args['after_widget']; |
||||
} |
||||
|
||||
/** |
||||
* Back-end widget form. |
||||
* |
||||
* @see WP_Widget::form() |
||||
* |
||||
* @param array $instance Previously saved values from database. |
||||
*/ |
||||
public function form($instance) |
||||
{ |
||||
$title = ! empty($instance['title']) ? $instance['title'] : ''; |
||||
$number = ! empty($instance['number']) ? absint($instance['number']) : 3; ?> |
||||
<p><label for="<?= $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
|
||||
<input |
||||
class="widefat" |
||||
id="<?= $this->get_field_id( 'title' ); ?>"
|
||||
name="<?= $this->get_field_name( 'title' ); ?>"
|
||||
type="text" |
||||
value="<?= $title; ?>" /></p>
|
||||
<p><label for="<?= $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of books to show:' ); ?></label>
|
||||
<input |
||||
class="tiny-text" |
||||
id="<?= $this->get_field_id( 'number' ); ?>"
|
||||
name="<?= $this->get_field_name( 'number' ); ?>"
|
||||
type="number" |
||||
step="1" |
||||
min="1" |
||||
value="<?= $number; ?>"
|
||||
size="3" /></p> |
||||
<?php |
||||
} |
||||
|
||||
/** |
||||
* Sanitize widget form values as they are saved. |
||||
* |
||||
* @see WP_Widget::update() |
||||
* |
||||
* @param array $new_instance Values just sent to be saved. |
||||
* @param array $old_instance Previously saved values from database. |
||||
* |
||||
* @return array Updated safe values to be saved. |
||||
*/ |
||||
public function update($new_instance, $old_instance) |
||||
{ |
||||
$instance = []; |
||||
$instance['title'] = ( ! empty($new_instance['title']) ) ? strip_tags($new_instance['title']) : ''; |
||||
$instance['number'] = (int) $new_instance['number']; |
||||
return $instance; |
||||
} |
||||
} |
@ -1,16 +0,0 @@
|
||||
{ |
||||
"images/banner-desktop.jpg": "images/banner-desktop_bcd1d61f.jpg", |
||||
"images/banner-mobile.jpg": "images/banner-mobile_f655d839.jpg", |
||||
"images/banner-two.jpg": "images/banner-two_a620635c.jpg", |
||||
"images/logo.png": "images/logo_10675684.png", |
||||
"images/logo@2x.png": "images/logo@2x_7d05144c.png", |
||||
"vendor/fontawesome-webfont.eot": "vendor/fontawesome-webfont_674f50d2.eot", |
||||
"vendor/fontawesome-webfont.eot?v=4.7.0": "vendor/fontawesome-webfont_674f50d2.eot", |
||||
"vendor/fontawesome-webfont.svg?v=4.7.0": "vendor/fontawesome-webfont_912ec66d.svg", |
||||
"vendor/fontawesome-webfont.ttf?v=4.7.0": "vendor/fontawesome-webfont_b06871f2.ttf", |
||||
"vendor/fontawesome-webfont.woff2?v=4.7.0": "vendor/fontawesome-webfont_af7ae505.woff2", |
||||
"vendor/fontawesome-webfont.woff?v=4.7.0": "vendor/fontawesome-webfont_fee66e71.woff", |
||||
"scripts/customizer.js": "scripts/customizer_ec2fc400.js", |
||||
"styles/main.css": "styles/main_ec2fc400.css", |
||||
"scripts/main.js": "scripts/main_ec2fc400.js" |
||||
} |
Before Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 1.0 MiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 2.0 KiB |
@ -1 +0,0 @@
|
||||
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/app/themes/pressbooks-aldine/dist/",t(t.s=9)}({0:function(e,t){e.exports=jQuery},10:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n.n(r);wp.customize("blogname",function(e){e.bind(function(e){return o()(".brand").text(e)})})},9:function(e,t,n){e.exports=n(10)}}); |
@ -1 +0,0 @@
|
||||
!function(t){function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var e={};n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="/app/themes/pressbooks-aldine/dist/",n(n.s=1)}([function(t,n){t.exports=jQuery},function(t,n,e){e(2),t.exports=e(8)},function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),function(t){var n=e(0),i=(e.n(n),e(3)),o=e(5),r=e(6),c=e(7),u=new i.a({common:o.a,home:r.a,aboutUs:c.a});t(document).ready(function(){return u.loadEvents()})}.call(n,e(0))},function(t,n,e){"use strict";var i=e(4),o=function(t){this.routes=t};o.prototype.fire=function(t,n,e){void 0===n&&(n="init"),""!==t&&this.routes[t]&&"function"==typeof this.routes[t][n]&&this.routes[t][n](e)},o.prototype.loadEvents=function(){var t=this;this.fire("common"),document.body.className.toLowerCase().replace(/-/g,"_").split(/\s+/).map(i.a).forEach(function(n){t.fire(n),t.fire(n,"finalize")}),this.fire("common","finalize")},n.a=o},function(t,n,e){"use strict";n.a=function(t){return""+t.charAt(0).toLowerCase()+t.replace(/[\W_]/g,"|").split("|").map(function(t){return""+t.charAt(0).toUpperCase()+t.slice(1)}).join("").slice(1)}},function(t,n,e){"use strict";(function(t){n.a={init:function(){t(".toggle-menu").click(function(n){n.preventDefault(),t(n.currentTarget).toggleClass("is-active"),t(".primary-navigation").toggleClass("is-visible")})},finalize:function(){}}}).call(n,e(0))},function(t,n,e){"use strict";n.a={init:function(){},finalize:function(){}}},function(t,n,e){"use strict";n.a={init:function(){}}},function(t,n){}]); |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue