PodsWidgetList

The Pods - Custom Content Types and Fields PodsWidgetList class.

Defined (1)

The class is defined in the following location(s).

/classes/widgets/PodsWidgetList.php  
  1. class PodsWidgetList extends WP_Widget { 
  2.  
  3. /** 
  4. * Register the widget 
  5. * @since 2.5.4 
  6. * Note: params are totally ignored. Included for the sake of strict standards. 
  7. * @param string $id_base Optional Base ID for the widget, lowercase and unique. If left empty,  
  8. * a portion of the widget's class name will be used Has to be unique. 
  9. * @param string $name Name for the widget displayed on the configuration page. 
  10. * @param array $widget_options Optional. Widget options. See {@see wp_register_sidebar_widget()} for 
  11. * information on accepted arguments. Default empty array. 
  12. * @param array $control_options Optional. Widget control options. See {@see wp_register_widget_control()} 
  13. * for information on accepted arguments. Default empty array. 
  14. */ 
  15. public function __construct( $id_base = 'pods_widget_list', $name = 'Pods - List Items', $widget_options = array(), $control_options = array() ) { 
  16. parent::__construct( 
  17. 'pods_widget_list',  
  18. 'Pods - List Items',  
  19. array( 'classname' => 'pods_widget_list', 'description' => 'Display multiple Pod items' ),  
  20. array( 'width' => 200 ) 
  21. ); 
  22.  
  23.  
  24. /** 
  25. * Output of widget 
  26. */ 
  27. public function widget ( $args, $instance ) { 
  28. extract( $args ); 
  29.  
  30. // Get widget fields 
  31. $title = apply_filters( 'widget_title', $instance[ 'title' ] ); 
  32.  
  33. $args = array( 
  34. 'name' => trim( pods_var_raw( 'pod_type', $instance, '' ) ),  
  35. 'template' => trim( pods_var_raw( 'template', $instance, '' ) ),  
  36. 'limit' => (int) pods_var_raw( 'limit', $instance, 15, null, true ),  
  37. 'orderby' => trim( pods_var_raw( 'orderby', $instance, '' ) ),  
  38. 'where' => trim( pods_var_raw( 'where', $instance, '' ) ),  
  39. 'expires' => (int) trim( pods_var_raw( 'expires', $instance, ( 60 * 5 ) ) ),  
  40. 'cache_mode' => trim( pods_var_raw( 'cache_mode', $instance, 'none', null, true ) ) 
  41. ); 
  42.  
  43. $before_content = trim( pods_var_raw( 'before_content', $instance, '' ) ); 
  44. $content = trim( pods_var_raw( 'template_custom', $instance, '' ) ); 
  45. $after_content = trim( pods_var_raw( 'after_content', $instance, '' ) ); 
  46.  
  47. if ( 0 < strlen( $args[ 'name' ] ) && ( 0 < strlen( $args[ 'template' ] ) || 0 < strlen( $content ) ) ) { 
  48. require PODS_DIR . 'ui/front/widgets.php'; 
  49.  
  50. /** 
  51. * Updates the new instance of widget arguments 
  52. * @returns array $instance Updated instance 
  53. */ 
  54. public function update ( $new_instance, $old_instance ) { 
  55. $instance = $old_instance; 
  56.  
  57. $instance[ 'title' ] = pods_var_raw( 'title', $new_instance, '' ); 
  58. $instance[ 'pod_type' ] = pods_var_raw( 'pod_type', $new_instance, '' ); 
  59. $instance[ 'template' ] = pods_var_raw( 'template', $new_instance, '' ); 
  60. $instance[ 'template_custom' ] = pods_var_raw( 'template_custom', $new_instance, '' ); 
  61. $instance[ 'limit' ] = (int) pods_var_raw( 'limit', $new_instance, 15, null, true ); 
  62. $instance[ 'orderby' ] = pods_var_raw( 'orderby', $new_instance, '' ); 
  63. $instance[ 'where' ] = pods_var_raw( 'where', $new_instance, '' ); 
  64. $instance[ 'expires' ] = (int) pods_var_raw( 'expires', $new_instance, ( 60 * 5 ) ); 
  65. $instance[ 'cache_mode' ] = pods_var_raw( 'cache_mode', $new_instance, 'none' ); 
  66. $instance[ 'before_content' ] = pods_var_raw( 'before_content', $new_instance, '' ); 
  67. $instance[ 'after_content' ] = pods_var_raw( 'after_content', $new_instance, '' ); 
  68.  
  69. return $instance; 
  70.  
  71. /** 
  72. * Widget Form 
  73. */ 
  74. public function form ( $instance ) { 
  75. $title = pods_var_raw( 'title', $instance, '' ); 
  76. $pod_type = pods_var_raw( 'pod_type', $instance, '' ); 
  77. $template = pods_var_raw( 'template', $instance, '' ); 
  78. $template_custom = pods_var_raw( 'template_custom', $instance, '' ); 
  79. $limit = (int) pods_var_raw( 'limit', $instance, 15, null, true ); 
  80. $orderby = pods_var_raw( 'orderby', $instance, '' ); 
  81. $where = pods_var_raw( 'where', $instance, '' ); 
  82. $expires = (int) pods_var_raw( 'expires', $instance, ( 60 * 5 ) ); 
  83. $cache_mode = pods_var_raw( 'cache_mode', $instance, 'none' ); 
  84. $before_content = pods_var_raw( 'before_content', $instance, '' ); 
  85. $after_content = pods_var_raw( 'after_content', $instance, '' ); 
  86.  
  87. require PODS_DIR . 'ui/admin/widgets/list.php';