PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.8.4
Pods – Custom Content Types and Fields v3.2.8.4
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / classes / widgets / PodsWidgetSingle.php
pods / classes / widgets Last commit date
PodsWidgetField.php 2 days ago PodsWidgetForm.php 2 days ago PodsWidgetList.php 2 days ago PodsWidgetSingle.php 2 days ago PodsWidgetView.php 2 days ago
PodsWidgetSingle.php
92 lines
1 <?php
2
3 /**
4 * @package Pods\Widgets
5 */
6 class PodsWidgetSingle extends WP_Widget {
7
8 /**
9 * {@inheritdoc}
10 */
11 public function __construct( $id_base = '', $name = '', $widget_options = array(), $control_options = array() ) {
12
13 parent::__construct( 'pods_widget_single', __( 'Pods - Single Item', 'pods' ), array(
14 'classname' => 'pods_widget_single',
15 'description' => __( 'Display a Single Pod Item', 'pods' ),
16 ), array( 'width' => 200 ) );
17 }
18
19 /**
20 * {@inheritdoc}
21 */
22 public function widget( $args, $instance ) {
23
24 // Setup basic widget parameters.
25 $before_widget = pods_v( 'before_widget', $args );
26 $after_widget = pods_v( 'after_widget', $args );
27 $before_title = pods_v( 'before_title', $args );
28 $title = apply_filters( 'widget_title', pods_v( 'title', $instance ) );
29 $after_title = pods_v( 'after_title', $args );
30 $before_content = pods_v( 'before_content', $instance );
31 $after_content = pods_v( 'after_content', $instance );
32
33 $args = array(
34 'name' => trim( (string) pods_v( 'pod_type', $instance, '' ) ),
35 'slug' => trim( (string) pods_v( 'slug', $instance, '' ) ),
36 'use_current' => trim( (string) pods_v( 'use_current', $instance, '' ) ),
37 'template' => trim( (string) pods_v( 'template', $instance, '' ) ),
38 );
39
40 $content = trim( (string) pods_v( 'template_custom', $instance, '' ) );
41
42 if (
43 (
44 (
45 0 < strlen( $args['name'] )
46 && 0 < strlen( $args['slug'] )
47 )
48 || 0 < strlen( $args['use_current'] )
49 )
50 &&
51 (
52 0 < strlen( $args['template'] )
53 || 0 < strlen( $content )
54 )
55 ) {
56 require PODS_DIR . 'ui/front/widgets.php';
57 }
58 }
59
60 /**
61 * {@inheritdoc}
62 */
63 public function update( $new_instance, $old_instance ) {
64
65 $instance = $old_instance;
66
67 $instance['title'] = pods_v( 'title', $new_instance, '' );
68 $instance['pod_type'] = pods_v( 'pod_type', $new_instance, '' );
69 $instance['slug'] = pods_v( 'slug', $new_instance, '' );
70 $instance['use_current'] = pods_v( 'use_current', $new_instance, '' );
71 $instance['template'] = pods_v( 'template', $new_instance, '' );
72 $instance['template_custom'] = pods_v( 'template_custom', $new_instance, '' );
73
74 return $instance;
75 }
76
77 /**
78 * {@inheritdoc}
79 */
80 public function form( $instance ) {
81
82 $title = pods_v( 'title', $instance, '' );
83 $slug = pods_v( 'slug', $instance, '' );
84 $use_current = pods_v( 'use_current', $instance, '' );
85 $pod_type = pods_v( 'pod_type', $instance, '' );
86 $template = pods_v( 'template', $instance, '' );
87 $template_custom = pods_v( 'template_custom', $instance, '' );
88
89 require PODS_DIR . 'ui/admin/widgets/single.php';
90 }
91 }
92