PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 6.2.1
پارسی دیت – Parsi Date v6.2.1
6.2.1 6.2 6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0.1 2.3.0.2 2.3.1 2.3.2 2.3.3 2.3.4 3.0.1 3.0.2 3.0.3 4.0.0 4.0.1 4.0.2 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5
wp-parsidate / inc / Admin / AdminDashboard.php
wp-parsidate / inc / Admin Last commit date
Admin.php 3 weeks ago AdminAbout.php 3 weeks ago AdminAssets.php 3 weeks ago AdminConvert.php 3 weeks ago AdminCore.php 3 weeks ago AdminDashboard.php 3 weeks ago AdminIntegration.php 3 weeks ago AdminPages.php 3 weeks ago AdminSettings.php 3 weeks ago AdminTools.php 3 weeks ago
AdminDashboard.php
84 lines
1 <?php
2
3 namespace WPParsidate\Admin;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use WPParsidate\Addons\Addons;
8 use WPParsidate\Helper\{Assets, FeedReader, Notice, Templates, User};
9
10 class AdminDashboard {
11 public const tab = 'dashboard';
12 public const icon = '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M15.5777 3.38197L17.5777 4.43152C19.7294 5.56066 20.8052 6.12523 21.4026 7.13974C22 8.15425 22 9.41667 22 11.9415V12.0585C22 14.5833 22 15.8458 21.4026 16.8603C20.8052 17.8748 19.7294 18.4393 17.5777 19.5685L15.5777 20.618C13.8221 21.5393 12.9443 22 12 22C11.0557 22 10.1779 21.5393 8.42229 20.618L6.42229 19.5685C4.27063 18.4393 3.19479 17.8748 2.5974 16.8603C2 15.8458 2 14.5833 2 12.0585V11.9415C2 9.41667 2 8.15425 2.5974 7.13974C3.19479 6.12523 4.27063 5.56066 6.42229 4.43152L8.42229 3.38197C10.1779 2.46066 11.0557 2 12 2C12.9443 2 13.8221 2.46066 15.5777 3.38197Z" stroke="#3c3c3c" stroke-width="1.5" stroke-linecap="round"></path> <path d="M21 7.5L12 12M12 12L3 7.5M12 12V21.5" stroke="#3c3c3c" stroke-width="1.5" stroke-linecap="round"></path> </g></svg>';
13
14 public function __construct() {
15 add_action( 'wp_parsidate_dashboard_tab_content', [ $this, 'content' ] );
16 add_action( 'wp_parsidate_admin_init', [ $this, 'notice' ] );
17 add_filter( 'wp_parsidate_menus', [ $this, 'addMenu' ] );
18 }
19
20 public function addMenu( $menus ) {
21 $menus[ self::tab ] = array(
22 'title' => esc_html__( 'Dashboard', 'wp-parsidate' ),
23 'icon' => self::icon
24 );
25
26 return $menus;
27 }
28
29 public function notice(): void {
30 Notice::add( self::tab, esc_html__( 'Welcome to WP Parsi!', 'wp-parsidate' ), 'default' );
31 }
32
33 public function content(): void {
34 $dashboardTypeLinks = array(
35 'addons' => $this->getAddons(),
36 'custom' => apply_filters( 'wp_parsidate_dashboard_custom_links', [] )
37 );
38
39 if ( empty( $dashboardTypeLinks['addons'] ) ) {
40 $message = '<strong>' . esc_html__( 'Hello',
41 'wp-parsidate' ) . '، ' . User::getData( 'display_name' ) . '!</strong>';
42 $message .= '<p>' . esc_html__( 'WP Parsi is here to help you integrate Jalali date with your site, go to the Addons tab and activate the required addons.',
43 'wp-parsidate' ) . '</p>';
44
45 echo '<div class="wppd-dashboard-welcome">' . wp_kses( $message, [ 'strong' => [], 'p' => [] ] ) . '</div>';
46 }
47
48 echo '<div class="wppd-dashboard-links-wrap">';
49 foreach ( $dashboardTypeLinks as $dashboardLinks ) {
50 foreach ( $dashboardLinks as $link ) {
51 $icon = ! empty( $link['icon'] ) && Assets::isSvgImageString( $link['icon'] ) ? Assets::setSvgDimensions( $link['icon'],
52 50 ) : '';
53 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
54 echo '<a href="' . esc_url_raw( $link['link'] ) . '" title="' . esc_html( $link['desc'] ) . '" class="wppd-link-type-' . esc_html( $link['type'] ) . '">' . $icon . '<span>' . esc_html( $link['title'] ) . '</span></a>';
55 }
56 }
57 echo '</div>';
58
59 echo '<div class="wppd-dashboard-feed-news"><strong class="wppd-dashboard-feed-head">' .
60 esc_html__( 'WP Parsi news', 'wp-parsidate' ) . '</strong>';
61 $feedReader = new FeedReader( [ 'url' => 'https://wp-parsi.com/parsidate/feed/' ] );
62 $feedItems = $feedReader->read()->getFeedLinks();
63 $feedNone = $feedReader->setEmptyFeedDesc( esc_html__( 'WP-Parsi website is not available.', 'wp-parsidate' ) );
64 Templates::load(
65 Templates::getPath( 'feed-reader/feed_list.php' ),
66 array( 'items' => $feedItems, 'none' => $feedNone )
67 );
68 echo '</div>';
69 }
70
71 private function getAddons(): array {
72 $addons = apply_filters( 'wp_parsidate_dashboard_addon_links', [] );
73 $addonCats = Addons::getAddonCats();
74 $addonList = array();
75 foreach ( array_keys( $addonCats ) as $addonCat ) {
76 if ( ! empty( $addons[ $addonCat ] ) ) {
77 $addonList[] = $addons[ $addonCat ];
78 }
79 }
80
81 return array_merge( [], ...$addonList );
82 }
83 }
84