PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.3.9.1
Pods – Custom Content Types and Fields v3.3.9.1
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 weeks ago PodsWidgetForm.php 2 weeks ago PodsWidgetList.php 2 weeks ago PodsWidgetSingle.php 2 weeks ago PodsWidgetView.php 2 weeks ago
PodsWidgetSingle.php
97 lines
1 <?php
2
3 // Don't load directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 die( '-1' );
6 }
7
8 /**
9 * @package Pods\Widgets
10 */
11 class PodsWidgetSingle extends WP_Widget {
12
13 /**
14 * {@inheritdoc}
15 */
16 public function __construct( $id_base = '', $name = '', $widget_options = array(), $control_options = array() ) {
17
18 parent::__construct( 'pods_widget_single', __( 'Pods - Single Item', 'pods' ), array(
19 'classname' => 'pods_widget_single',
20 'description' => __( 'Display a Single Pod Item', 'pods' ),
21 ), array( 'width' => 200 ) );
22 }
23
24 /**
25 * {@inheritdoc}
26 */
27 public function widget( $args, $instance ) {
28
29 // Setup basic widget parameters.
30 $before_widget = pods_v( 'before_widget', $args );
31 $after_widget = pods_v( 'after_widget', $args );
32 $before_title = pods_v( 'before_title', $args );
33 $title = apply_filters( 'widget_title', pods_v( 'title', $instance ) );
34 $after_title = pods_v( 'after_title', $args );
35 $before_content = pods_v( 'before_content', $instance );
36 $after_content = pods_v( 'after_content', $instance );
37
38 $args = array(
39 'name' => trim( (string) pods_v( 'pod_type', $instance, '' ) ),
40 'slug' => trim( (string) pods_v( 'slug', $instance, '' ) ),
41 'use_current' => trim( (string) pods_v( 'use_current', $instance, '' ) ),
42 'template' => trim( (string) pods_v( 'template', $instance, '' ) ),
43 );
44
45 $content = trim( (string) pods_v( 'template_custom', $instance, '' ) );
46
47 if (
48 (
49 (
50 0 < strlen( $args['name'] )
51 && 0 < strlen( $args['slug'] )
52 )
53 || 0 < strlen( $args['use_current'] )
54 )
55 &&
56 (
57 0 < strlen( $args['template'] )
58 || 0 < strlen( $content )
59 )
60 ) {
61 require PODS_DIR . 'ui/front/widgets.php';
62 }
63 }
64
65 /**
66 * {@inheritdoc}
67 */
68 public function update( $new_instance, $old_instance ) {
69
70 $instance = $old_instance;
71
72 $instance['title'] = pods_v( 'title', $new_instance, '' );
73 $instance['pod_type'] = pods_v( 'pod_type', $new_instance, '' );
74 $instance['slug'] = pods_v( 'slug', $new_instance, '' );
75 $instance['use_current'] = pods_v( 'use_current', $new_instance, '' );
76 $instance['template'] = pods_v( 'template', $new_instance, '' );
77 $instance['template_custom'] = pods_v( 'template_custom', $new_instance, '' );
78
79 return $instance;
80 }
81
82 /**
83 * {@inheritdoc}
84 */
85 public function form( $instance ) {
86
87 $title = pods_v( 'title', $instance, '' );
88 $slug = pods_v( 'slug', $instance, '' );
89 $use_current = pods_v( 'use_current', $instance, '' );
90 $pod_type = pods_v( 'pod_type', $instance, '' );
91 $template = pods_v( 'template', $instance, '' );
92 $template_custom = pods_v( 'template_custom', $instance, '' );
93
94 require PODS_DIR . 'ui/admin/widgets/single.php';
95 }
96 }
97