PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.0.5
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.0.5
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
← All changes | widgets/widget-mainwp-notes.php +45 -109 5.14.0.5 View file →
@@ -1,120 +1,56 @@
1 1 <?php
2 -/**
3 - * MainWP Notes Widget
4 - *
5 - * Display current Child Site Notes.
6 - *
7 - * @package MainWP/Dashboard
8 - */
9 2
10 -namespace MainWP\Dashboard;
3 +class MainWP_Notes {
11 4
12 -/**
13 - * Class MainWP_Notes
14 - *
15 - * Grab Child Site Notes & Build Notes Widget.
16 - */
17 -class MainWP_Notes { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
5 + public static function getClassName() {
6 + return __CLASS__;
7 + }
18 8
19 - /**
20 - * Method get_class_name()
21 - *
22 - * @return string __CLASS__ Class Name
23 - */
24 - public static function get_class_name() {
25 - return __CLASS__;
26 - }
9 + public static function render() {
10 + $current_wpid = MainWP_Utility::get_current_wpid();
27 11
28 - /**
29 - * Method render()
30 - *
31 - * Grab Child Site Notes & Render Widget.
32 - *
33 - * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
34 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
35 - * @uses \MainWP\Dashboard\MainWP_UI::render_modal_edit_notes()
36 - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
37 - * @uses \MainWP\Dashboard\MainWP_Utility::esc_content()
38 - */
39 - public static function render() {
40 - $current_wpid = MainWP_System_Utility::get_current_wpid();
12 + if ( !MainWP_Utility::ctype_digit( $current_wpid ) ) {
13 + return;
14 + }
41 15
42 - if ( ! MainWP_Utility::ctype_digit( $current_wpid ) ) {
43 - return;
44 - }
16 + $website = MainWP_DB::Instance()->getWebsiteById( $current_wpid, true );
17 + $note = html_entity_decode( $website->note ); // to compatible
18 + $esc_note = MainWP_Utility::esc_content( $note );
45 19
46 - $website = MainWP_DB::instance()->get_website_by_id( $current_wpid, true );
47 - $note = html_entity_decode( $website->note );
48 - $esc_note = MainWP_Utility::esc_content( $note );
49 - ?>
50 - <div class="mainwp-widget-header">
51 - <h3 class="ui header handle-drag">
52 - <?php
53 - /**
54 - * Filter: mainwp_notes_widget_title
55 - *
56 - * Filters the Notes widget title text.
57 - *
58 - * @param object $website Object containing the child site info.
59 - *
60 - * @since 4.1
61 - */
62 - echo esc_html( apply_filters( 'mainwp_notes_widget_title', esc_html__( 'Notes', 'mainwp' ), $website ) );
63 - ?>
64 - <div class="sub header"><?php esc_html_e( 'Child site notes', 'mainwp' ); ?></div>
65 - </h3>
66 - </div>
67 20
68 - <div class="mainwp-scrolly-overflow">
69 - <?php
70 - /**
71 - * Action: mainwp_notes_widget_top
72 - *
73 - * Fires at the top of the Notes widget on the Individual site overview page.
74 - *
75 - * @param object $website Object containing the child site info.
76 - *
77 - * @since 4.1
78 - */
79 - do_action( 'mainwp_notes_widget_top', $website );
21 + ?>
80 22
81 - if ( empty( $website->note ) ) {
82 - MainWP_UI::render_empty_element_placeholder();
83 - } else {
84 - ?>
85 - <div class="content">
86 - <?php
87 - echo wp_unslash( $esc_note ); // phpcs:ignore WordPress.Security.EscapeOutput
88 - ?>
89 - </div>
90 - <?php
91 - }
92 - ?>
93 - <span style="display: none" id="mainwp-notes-<?php echo intval( $current_wpid ); ?>-note"><?php echo wp_unslash( $esc_note ); // phpcs:ignore WordPress.Security.EscapeOutput ?></span>
94 - <?php
95 - /**
96 - * Action: mainwp_notes_widget_bottom
97 - *
98 - * Fires at the bottom of the Notes widget on the Individual site overview page.
99 - *
100 - * @param object $website Object containing the child site info.
101 - *
102 - * @since 4.1
103 - */
104 - do_action( 'mainwp_notes_widget_bottom', $website );
105 - ?>
106 - </div>
107 - <?php if ( '' !== $website->note ) : ?>
108 - <div class="ui two columns grid mainwp-widget-footer">
109 - <div class="column">
110 - <a href="javascript:void(0)" class="ui button mini fluid green mainwp-edit-site-note" id="mainwp-notes-<?php echo intval( $website->id ); ?>"><?php esc_html_e( 'Edit Notes', 'mainwp' ); ?></a>
111 - </div>
112 - <div class="column">
23 + <h3 class="ui header handle-drag">
24 + <?php esc_html_e('Notes', 'mainwp'); ?>
25 + <div class="sub header"><?php esc_html_e( 'Child site notes', 'mainwp' ); ?></div>
26 + </h3>
113 27
114 - </div>
115 - </div>
116 - <?php endif; ?>
117 - <?php
118 - MainWP_UI::render_modal_edit_notes();
119 - }
28 + <div class="ui section hidden divider"></div>
29 +
30 + <div>
31 + <?php
32 + if ( $website->note == '' ) {
33 + ?>
34 + <h2 class="ui icon header">
35 + <i class="info circle icon"></i>
36 + <div class="content">
37 + <?php _e( 'No saved notes!', 'mainwp' ); ?>
38 + <div class="sub header"><?php esc_html_e( 'No saved notes for the child site. ', 'mainwp' ); ?><?php echo '<a href="javascript:void(0)" class="mainwp-edit-site-note" id="mainwp-notes-' . $website->id . '">' . __( 'Click here to add a note.', 'mainwp' ) . '</a>'; ?></div>
39 + </div>
40 + </h2>
41 + <?php
42 + } else {
43 + echo $esc_note;
44 + ?>
45 + <div class="ui section hidden divider"></div>
46 + <a href="javascript:void(0)" class="ui button green mainwp-edit-site-note" id="mainwp-notes-<?php echo $website->id; ?>"><?php esc_html_e( 'Edit Notes', 'mainwp' ); ?></a>
47 + <?php
48 + }
49 + ?>
50 + </div>
51 + <span style="display: none" id="mainwp-notes-<?php echo intval($current_wpid); ?>-note"><?php echo $esc_note; ?></span>
52 + <?php
53 + MainWP_UI::render_modal_edit_notes();
54 + }
55 +
120 56 }