PluginProbe
Cooked – Recipe Management / 1.16.1
Cooked – Recipe Management v1.16.1
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.16.1, at includes/widgets/nutrition.php

60 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Nutrition Facts Widget
4 *
5 * @package Cooked
6 * @subpackage Widgets
7 * @since 1.2.0
8 */
9
10 /**
11 * Cooked_Widget_Nutrition Class
12 *
13 * This class handles the Nutrition Facts widget display.
14 *
15 * @since 1.2.0
16 */
17
18 class Cooked_Widget_Nutrition extends WP_Widget {
19
20 public function __construct() {
21 $widget_ops = array(
22 'classname' => 'cooked_nutrition_widget',
23 'description' => 'Display nutrition facts on recipe sidebars.',
24 );
25 parent::__construct( 'cooked_nutrition_widget', 'Cooked - Nutrition Facts', $widget_ops );
26 }
27
28 public function widget( $args, $instance ) {
29
30 echo wp_kses_post( $args['before_widget'] );
31 if ( ! empty( $instance['title'] ) ) {
32 echo wp_kses_post( $args['before_title'] ) . esc_html( apply_filters( 'widget_title', $instance['title'] ) ) . wp_kses_post( $args['after_title'] );
33 }
34 echo do_shortcode( '[cooked-nutrition]' );
35 echo wp_kses_post( $args['after_widget'] );
36
37 }
38
39 public function form( $instance ) {
40
41 $title = ( !empty( $instance['title'] ) ? $instance['title'] : false );
42
43 ?>
44
45 <p>
46 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title (optional):', 'cooked' ); ?></label>
47 <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 ); ?>">
48 </p>
49
50 <?php
51 }
52
53 public function update( $new_instance, $old_instance ) {
54 $instance = array();
55 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
56 return $instance;
57 }
58
59 }
60