PluginProbe ʕ •ᴥ•ʔ
YITH WooCommerce Wishlist / 4.0.1
YITH WooCommerce Wishlist v4.0.1
trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.25 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.10.0 3.11.0 3.12.0 3.13.0 3.14.0 3.15.0 3.16.0 3.17.0 3.18.0 3.19.0 3.2.0 3.20.0 3.21.0 3.22.0 3.23.0 3.24.0 3.25.0 3.26.0 3.27.0 3.28.0 3.29.0 3.3.0 3.30.0 3.31.0 3.32.0 3.33.0 3.34.0 3.35.0 3.36.0 3.37.0 3.38.0 3.4.0 3.5.0 3.6.0 3.7.0 3.8.0 3.9.0 4.0.0 4.0.1 4.1.0 4.10.0 4.10.1 4.10.2 4.11.0 4.12.0 4.13.0 4.14.0 4.15.0 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.8.0 4.9.0
yith-woocommerce-wishlist / plugin-fw / includes / class-yith-dashboard.php
yith-woocommerce-wishlist / plugin-fw / includes Last commit date
builders 2 years ago privacy 2 years ago class-yit-ajax.php 2 years ago class-yit-assets.php 2 years ago class-yit-cpt-unlimited.php 5 years ago class-yit-gradients.php 2 years ago class-yit-help-desk.php 2 years ago class-yit-icons.php 2 years ago class-yit-metabox.php 2 years ago class-yit-plugin-common.php 5 years ago class-yit-plugin-licence.php 2 years ago class-yit-plugin-panel-woocommerce.php 1 year ago class-yit-plugin-panel.php 1 year ago class-yit-plugin-subpanel.php 2 years ago class-yit-pointers.php 2 years ago class-yit-theme-licence.php 2 years ago class-yit-upgrade.php 5 years ago class-yit-video.php 5 years ago class-yith-bh-onboarding.php 3 years ago class-yith-dashboard.php 4 years ago class-yith-debug.php 2 years ago class-yith-external-services.php 1 year ago class-yith-post-type-admin.php 2 years ago class-yith-system-status.php 1 year ago
class-yith-dashboard.php
150 lines
1 <?php
2 /**
3 * YITH Dashboard Class
4 * handle WordPress Admin Dashboard
5 *
6 * @class YITH_Dashboard
7 * @package YITH\PluginFramework\Classes
8 */
9
10 defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
11
12 if ( ! class_exists( 'YITH_Dashboard' ) ) {
13 /**
14 * YITH_Dashboard class.
15 */
16 class YITH_Dashboard {
17 /**
18 * Products Feed URL
19 *
20 * @var string
21 */
22 private static $products_feed = 'https://yithemes.com/latest-updates/feeds/';
23
24 /**
25 * Blog Feed URL
26 *
27 * @var string
28 */
29 private static $blog_feed = 'https://yithemes.com/feed/';
30
31 /**
32 * Dashboard widget setup.
33 */
34 public static function dashboard_widget_setup() {
35 wp_add_dashboard_widget( 'yith_dashboard_products_news', __( 'YITH Latest Updates', 'yith-plugin-fw' ), 'YITH_Dashboard::dashboard_products_news' );
36 wp_add_dashboard_widget( 'yith_dashboard_blog_news', __( 'Latest news from YITH Blog', 'yith-plugin-fw' ), 'YITH_Dashboard::dashboard_blog_news' );
37 }
38
39
40 /**
41 * Product news Widget
42 */
43 public static function dashboard_products_news() {
44 $items = 10;
45 $rss = static::$products_feed;
46 if ( is_string( $rss ) ) {
47 $rss = fetch_feed( $rss );
48 } elseif ( is_array( $rss ) && isset( $rss['url'] ) ) {
49 $rss = fetch_feed( $rss['url'] );
50 } elseif ( ! is_object( $rss ) ) {
51 return;
52 }
53
54 if ( is_wp_error( $rss ) ) {
55 if ( is_admin() || current_user_can( 'manage_options' ) ) {
56 echo '<p><strong>' . esc_html__( 'RSS Error:', 'yith-plugin-fw' ) . '</strong> ' . wp_kses_post( $rss->get_error_message() ) . '</p>';
57 }
58
59 return;
60 }
61
62 if ( ! $rss->get_item_quantity() ) {
63 echo '<ul><li>' . esc_html__( 'An error has occurred, which probably means the feed is down. Try again later.', 'yith-plugin-fw' ) . '</li></ul>';
64 $rss->__destruct();
65 unset( $rss );
66
67 return;
68 }
69
70 /**
71 * The feed items.
72 *
73 * @var SimplePie_Item[] $last_updates
74 */
75 $last_updates = $rss->get_items( 0, $items );
76 $html_classes = 'rsswidget yith-update-feeds';
77 $output = '';
78
79 if ( count( $last_updates ) > 0 ) {
80 $output = '<ul class="yith-update-feeds">';
81 }
82
83 foreach ( $last_updates as $last_update ) {
84 $output .= '<li class="yith-update-feed">';
85
86 $date = $last_update->get_date( 'U' );
87 $date_i18n = ! empty( $date ) ? date_i18n( get_option( 'date_format' ), $date ) : '';
88 $html_date = ! empty( $date_i18n ) ? ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>' : '';
89
90 $output .= sprintf( '<a target="_blank" href="%s" class="%s">%s</a> %s', $last_update->get_permalink(), $html_classes, $last_update->get_title(), $html_date );
91
92 $changelog = $last_update->get_description();
93
94 if ( ! empty( $changelog ) ) {
95 $output .= ' - ';
96 $output .= sprintf( '<a class="yith-last-changelog" href="#" data-changelogid="%s" data-plugininfo="%s">%s</a>', $last_update->get_id( true ), $last_update->get_title(), _x( 'View Changelog', 'Plugin FW', 'yith-plugin-fw' ) );
97 $output .= sprintf( '<div class="yith-feeds-wrapper" id="%s"><div class="yith-feeds-changelog-plugin-name"><img class="yith-feeds-logo" src="%s" /><h3 class="yith-feeds-plugin-name"><span style="font-weight: normal;">%s</span> %s</h3></div><p>%s</p></div>', $last_update->get_id( true ), yith_plugin_fw_get_default_logo(), _x( 'Latest update released on', 'Plugin FW', 'yith-plugin-fw' ), $date_i18n, $changelog );
98 }
99
100 $output .= '</li>';
101 }
102
103 if ( ! empty( $output ) ) {
104 $output .= '</ul>';
105 }
106
107 echo wp_kses_post( $output );
108 $rss->__destruct();
109 unset( $rss );
110 }
111
112 /**
113 * Blog news Widget
114 */
115 public static function dashboard_blog_news() {
116 $args = array(
117 'show_author' => 0,
118 'show_date' => 1,
119 'show_summary' => 1,
120 'items' => 3,
121 );
122 $feed = static::$blog_feed;
123 wp_widget_rss_output( $feed, $args );
124 }
125
126 /**
127 * Enqueue Styles and Scripts for View Last Changelog widget
128 */
129 public static function enqueue_scripts() {
130 if ( function_exists( 'get_current_screen' ) && get_current_screen() && 'dashboard' === get_current_screen()->id ) {
131 $script_path = defined( 'YIT_CORE_PLUGIN_URL' ) ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
132 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
133 wp_enqueue_script( 'yith-dashboard', $script_path . '/assets/js/yith-dashboard' . $suffix . '.js', array( 'jquery-ui-dialog' ), yith_plugin_fw_get_version(), true );
134 wp_enqueue_style( 'wp-jquery-ui-dialog' );
135 $l10n = array(
136 'buttons' => array(
137 'close' => _x( 'Close', 'Button label', 'yith-plugin-fw' ),
138 ),
139 );
140 wp_localize_script( 'yith-dashboard', 'yith_dashboard', $l10n );
141 }
142 }
143 }
144
145 if ( apply_filters( 'yith_plugin_fw_show_dashboard_widgets', true ) ) {
146 add_action( 'wp_dashboard_setup', 'YITH_Dashboard::dashboard_widget_setup' );
147 add_action( 'admin_enqueue_scripts', 'YITH_Dashboard::enqueue_scripts', 20 );
148 }
149 }
150