PluginProbe
Cooked – Recipe Management / 1.9.5
Cooked – Recipe Management v1.9.5
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 / class.cooked-widgets.php

class.cooked-widgets.php in Cooked – Recipe Management 1.9.5, at includes/class.cooked-widgets.php

50 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Widgets
4 *
5 * @package Cooked
6 * @subpackage Widgets
7 * @since 1.0.0
8 */
9
10 // Exit if accessed directly
11 if ( ! defined( 'ABSPATH' ) ) exit;
12
13 require_once 'widgets/init.php';
14
15 class Cooked_Widgets {
16
17 public function __construct() {
18 add_action( 'widgets_init', [&$this, 'register_widgets'], 10, 1 );
19 }
20
21 public function register_widgets() {
22 $widgets = apply_filters( 'cooked_widgets', [
23 'Cooked_Widget_Nutrition',
24 'Cooked_Widget_Search',
25 'Cooked_Widget_Recipe_List',
26 'Cooked_Widget_Recipe_Categories',
27 'Cooked_Widget_Recipe_Card',
28 ]);
29 if ( !empty($widgets) ):
30 foreach( $widgets as $widget ):
31 register_widget( $widget );
32 endforeach;
33 endif;
34 }
35
36 public static function recipe_finder( $field_id = '', $field_name = '', $included = '' ) {
37 $button_title = ( !empty( $included ) ? __( 'Edit Recipe(s)...', 'cooked' ) : __( 'Choose recipe(s)...', 'cooked' ) );
38 echo '<div style="margin:-10px 0 0 0;"><a href="#" class="button cooked-recipe-finder-show" id="' . esc_attr( $field_id ) . '-SHOW">' . esc_html( $button_title ) . '</a></div>';
39 echo '<select multiple class="widefat cooked-recipe-finder" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" placeholder="' . __( 'Choose recipe(s)...', 'cooked' ) . '">';
40 if ( !empty( $included ) ):
41 foreach ( $included as $recipe ):
42 $_recipe = Cooked_Recipes::get( $recipe, true );
43 echo '<option selected="selected" value="' . esc_attr( $_recipe['id'] ) . '">' . esc_html( $_recipe['title'] ) . '</option>';
44 endforeach;
45 endif;
46 echo '</select>';
47 }
48
49 }
50