PluginProbe
Cooked – Recipe Management / 1.8.7
Cooked – Recipe Management v1.8.7
1.16.1 1.16.0 1.15.0 trunk 1.10.0 1.11.0 1.11.1 1.11.2 1.11.3 1.11.4 1.12.0 1.13.0 1.14.0 1.7.10 1.7.11 1.7.12 1.7.13 1.7.15.1 1.7.15.3 1.7.15.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 All 37 releases
cooked / includes / widgets / nutrition.php

nutrition.php in Cooked – Recipe Management 1.8.7, at includes/widgets/nutrition.php

45 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Cooked_Widget_Nutrition extends WP_Widget {
4
5 public function __construct() {
6 $widget_ops = array(
7 'classname' => 'cooked_nutrition_widget',
8 'description' => 'Display nutrition facts on recipe sidebars.',
9 );
10 parent::__construct( 'cooked_nutrition_widget', 'Cooked - Nutrition Facts', $widget_ops );
11 }
12
13 public function widget( $args, $instance ) {
14
15 echo wp_kses_post( $args['before_widget'] );
16 if ( ! empty( $instance['title'] ) ) {
17 echo wp_kses_post( $args['before_title'] ) . apply_filters( 'widget_title', $instance['title'] ) . wp_kses_post( $args['after_title'] );
18 }
19 echo do_shortcode( '[cooked-nutrition]' );
20 echo wp_kses_post( $args['after_widget'] );
21
22 }
23
24 public function form( $instance ) {
25
26 $title = ( !empty( $instance['title'] ) ? $instance['title'] : false );
27
28 ?>
29
30 <p>
31 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title (optional):', 'cooked' ); ?></label>
32 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
33 </p>
34
35 <?php
36 }
37
38 public function update( $new_instance, $old_instance ) {
39 $instance = array();
40 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
41 return $instance;
42 }
43
44 }
45