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 / search.php

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

72 lines 3.9 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_Search extends WP_Widget {
4
5 public function __construct() {
6 $widget_ops = array(
7 'classname' => 'cooked_widget_search',
8 'description' => 'Display the recipe search form.',
9 );
10 parent::__construct( 'cooked_widget_search', 'Cooked - Recipe Search', $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 $size = ( isset($instance['size']) && $instance['size'] == 'compact' ? ' compact="true"' : '' );
20 $browse = ( isset($instance['hide_browse']) && $instance['hide_browse'] ? ' hide_browse="true"' : '' );
21 $sorting = ( isset($instance['hide_sorting']) && $instance['hide_sorting'] ? ' hide_sorting="true"' : '' );
22 echo do_shortcode( '[cooked-search' . esc_attr( $size . $browse . $sorting ) . ']' );
23 echo wp_kses_post( $args['after_widget'] );
24
25 }
26
27 public function form( $instance ) {
28
29 $title = ( !empty( $instance['title'] ) ? $instance['title'] : false );
30 $size = ( !empty( $instance['size'] ) ? $instance['size'] : 'compact' );
31 $hide_browse = ( isset( $instance['hide_browse'] ) && $instance['hide_browse'] ? true : false );
32 $hide_sorting = ( isset( $instance['hide_sorting'] ) && $instance['hide_sorting'] ? true : false );
33
34 ?>
35
36 <p>
37 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title (optional):', 'cooked' ); ?></label>
38 <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 ); ?>">
39 </p>
40
41 <p>
42 <label for="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>"><?php esc_attr_e( 'Size:', 'cooked' ); ?></label>
43 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'size' ) ); ?>">
44 <option value="compact"<?php echo ( $size == 'compact' ? ' selected' : '' ); ?>><?php esc_html_e( 'Compact', 'cooked' ); ?></option>
45 <option value="wide"<?php echo ( $size == 'wide' ? ' selected' : '' ); ?>><?php esc_html_e( 'Wide', 'cooked' ); ?></option>
46 </select>
47 </p>
48
49 <p>
50 <input id="<?php echo esc_attr( $this->get_field_id( 'hide_browse' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hide_browse' ) ); ?>"<?php echo ( $hide_browse ? ' checked' : '' ); ?> type="checkbox" value="1">
51 <label for="<?php echo esc_attr( $this->get_field_id( 'hide_browse' ) ); ?>"><?php esc_attr_e( 'Hide "Browse" dropdown', 'cooked' ); ?></label>
52 </p>
53
54 <p>
55 <input id="<?php echo esc_attr( $this->get_field_id( 'hide_sorting' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hide_sorting' ) ); ?>"<?php echo ( $hide_sorting ? ' checked' : '' ); ?> type="checkbox" value="1">
56 <label for="<?php echo esc_attr( $this->get_field_id( 'hide_sorting' ) ); ?>"><?php esc_attr_e( 'Hide "Sorting" dropdown', 'cooked' ); ?></label>
57 </p>
58
59 <?php
60 }
61
62 public function update( $new_instance, $old_instance ) {
63 $instance = array();
64 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
65 $instance['size'] = ( ! empty( $new_instance['size'] ) ) ? wp_strip_all_tags( $new_instance['size'] ) : 'compact';
66 $instance['hide_browse'] = ( !isset( $new_instance['hide_browse'] ) ? 0 : 1 );
67 $instance['hide_sorting'] = ( !isset( $new_instance['hide_sorting'] ) ? 0 : 1 );
68 return $instance;
69 }
70
71 }
72