PluginProbe
WP Directory Kit / 1.2.7
WP Directory Kit v1.2.7
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / dash-widgets / dash-widgets-news.php

dash-widgets-news.php in WP Directory Kit 1.2.7, at dash-widgets/dash-widgets-news.php

85 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Wdk\DashWidgets\Widgets;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7 class WDK_Dashboard_Widget_News extends WDK_DashWidgets {
8
9 /**
10 * The id of this widget.
11 */
12 static $widget_id = 'wdk_dashboard_widget_news';
13
14 /**
15 * Hook to wp_dashboard_setup to add the widget.
16 */
17 public static function init() {
18 //Register widget settings...
19 self::update_dashboard_widget_options(
20 self::$widget_id, //The widget id
21 array( //Associative array of options & default values
22 'example_number' => 42,
23 ),
24 true //Add only (will not update existing options)
25 );
26
27 //Register the widget...
28 wp_add_dashboard_widget(
29 self::$widget_id, //A unique slug/ID
30 __( 'Wdk News', 'wpdirectorykit' ),//Visible name for the widget
31 array('Wdk\DashWidgets\Widgets\WDK_Dashboard_Widget_News','widget') //Callback for the main widget content
32 );
33 }
34
35 /**
36 * Load the widget code
37 */
38 public static function widget() {
39
40 $WMVC = &wdk_get_instance();
41 $WMVC->model('listing_m');
42 $WMVC->load_helper('listing');
43
44 $data = array();
45
46 wp_enqueue_style('wdk-dash-widgets-news');
47 wp_enqueue_script('wdk-dash-widgets-news');
48
49 /* default from settings */
50 $data['id_element'] = self::$widget_id;
51
52 $data['settings'] = array(
53 'conf_limit' => 20,
54 );
55
56 $columns = array('ID', 'location_id', 'category_id', 'post_title', 'post_date', 'search', 'order_by','is_featured', 'address');
57 $controller = 'listing';
58 $custom_parameters = array();
59
60 if(!empty($data['settings']['conf_query'])) {
61 $qr_string = trim($data['settings']['conf_query'],'?');
62 $string_par = array();
63 parse_str($qr_string, $string_par);
64 $custom_parameters += array_map('trim', $string_par);
65 }
66
67 $external_columns = array('location_id', 'category_id', 'post_title');
68 wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
69
70 $data['results'] = $WMVC->listing_m->get_pagination($data['settings']['conf_limit'], NULL, array('is_activated' => 1,'is_approved'=>1), TRUE);
71
72 self::view('dash-widgets-news', $data, true);
73 }
74
75 /**
76 * Load widget config code.
77 *
78 * This is what will display when an admin clicks
79 */
80 public static function config() {
81 wp_redirect(admin_url("admin.php?page=listing_settings")); exit;
82 }
83
84
85 }