PodsWidgetField.php
4 months ago
PodsWidgetForm.php
4 months ago
PodsWidgetList.php
4 months ago
PodsWidgetSingle.php
4 months ago
PodsWidgetView.php
4 months ago
PodsWidgetView.php
78 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 PodsWidgetView 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_view', __( 'Pods - View', 'pods' ), array( |
| 19 | 'classname' => 'pods_widget_view', |
| 20 | 'description' => __( 'Include a file from a theme, with caching options', 'pods' ), |
| 21 | ), array( 'width' => 200 ) ); |
| 22 | |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * {@inheritdoc} |
| 27 | */ |
| 28 | public function widget( $args, $instance ) { |
| 29 | |
| 30 | // Setup basic widget parameters. |
| 31 | $before_widget = pods_v( 'before_widget', $args ); |
| 32 | $after_widget = pods_v( 'after_widget', $args ); |
| 33 | $before_title = pods_v( 'before_title', $args ); |
| 34 | $title = apply_filters( 'widget_title', pods_v( 'title', $instance ) ); |
| 35 | $after_title = pods_v( 'after_title', $args ); |
| 36 | $before_content = pods_v( 'before_content', $instance ); |
| 37 | $after_content = pods_v( 'after_content', $instance ); |
| 38 | |
| 39 | $args = array( |
| 40 | 'view' => trim( (string) pods_v( 'view', $instance, '' ) ), |
| 41 | 'expires' => (int) pods_v( 'expires', $instance, ( 60 * 5 ) ), |
| 42 | 'cache_mode' => trim( (string) pods_v( 'cache_mode', $instance, 'none', true ) ), |
| 43 | ); |
| 44 | |
| 45 | if ( 0 < strlen( $args['view'] ) ) { |
| 46 | require PODS_DIR . 'ui/front/widgets.php'; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * {@inheritdoc} |
| 52 | */ |
| 53 | public function update( $new_instance, $old_instance ) { |
| 54 | |
| 55 | $instance = $old_instance; |
| 56 | |
| 57 | $instance['title'] = pods_v( 'title', $new_instance, '' ); |
| 58 | $instance['view'] = pods_v( 'view', $new_instance, '' ); |
| 59 | $instance['expires'] = (int) pods_v( 'expires', $new_instance, ( 60 * 5 ) ); |
| 60 | $instance['cache_mode'] = pods_v( 'cache_mode', $new_instance, 'none', true ); |
| 61 | |
| 62 | return $instance; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * {@inheritdoc} |
| 67 | */ |
| 68 | public function form( $instance ) { |
| 69 | |
| 70 | $title = pods_v( 'title', $instance, '' ); |
| 71 | $view = pods_v( 'view', $instance, '' ); |
| 72 | $expires = (int) pods_v( 'expires', $instance, ( 60 * 5 ) ); |
| 73 | $cache_mode = pods_v( 'cache_mode', $instance, 'none', true ); |
| 74 | |
| 75 | require PODS_DIR . 'ui/admin/widgets/view.php'; |
| 76 | } |
| 77 | } |
| 78 |