| @@ -8,113 +8,113 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | namespace MainWP\Dashboard; |
| 11 | 11 | |
| 12 | +// Exit if accessed directly. | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 16 | + | |
| 12 | 17 | /** |
| 13 | 18 | * Class MainWP_Notes |
| 14 | 19 | * |
| 15 | 20 | * Grab Child Site Notes & Build Notes Widget. |
| 16 | 21 | */ |
| 17 | -class MainWP_Notes { | |
| 22 | +class MainWP_Notes { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 18 | 23 | |
| 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 | - } | |
| 24 | + /** | |
| 25 | + * Method get_class_name() | |
| 26 | + * | |
| 27 | + * @return string __CLASS__ Class Name | |
| 28 | + */ | |
| 29 | + public static function get_class_name() { | |
| 30 | + return __CLASS__; | |
| 31 | + } | |
| 27 | 32 | |
| 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(); | |
| 33 | + /** | |
| 34 | + * Method render() | |
| 35 | + * | |
| 36 | + * Grab Child Site Notes & Render Widget. | |
| 37 | + * | |
| 38 | + * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() | |
| 39 | + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid() | |
| 40 | + * @uses \MainWP\Dashboard\MainWP_UI::render_modal_edit_notes() | |
| 41 | + * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() | |
| 42 | + * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() | |
| 43 | + */ | |
| 44 | + public static function render() { | |
| 45 | + $current_wpid = MainWP_System_Utility::get_current_wpid(); | |
| 41 | 46 | |
| 42 | - if ( ! MainWP_Utility::ctype_digit( $current_wpid ) ) { | |
| 43 | - return; | |
| 44 | - } | |
| 47 | + if ( ! MainWP_Utility::ctype_digit( $current_wpid ) ) { | |
| 48 | + return; | |
| 49 | + } | |
| 45 | 50 | |
| 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> | |
| 51 | + $website = MainWP_DB::instance()->get_website_by_id( $current_wpid, true ); | |
| 52 | + $note = html_entity_decode( $website->note ); | |
| 53 | + $esc_note = MainWP_Utility::esc_content( $note ); | |
| 54 | + ?> | |
| 55 | + <div class="mainwp-widget-header"> | |
| 56 | + <h2 class="ui header handle-drag"> | |
| 57 | + <?php | |
| 58 | + /** | |
| 59 | + * Filter: mainwp_notes_widget_title | |
| 60 | + * | |
| 61 | + * Filters the Notes widget title text. | |
| 62 | + * | |
| 63 | + * @param object $website Object containing the child site info. | |
| 64 | + * | |
| 65 | + * @since 4.1 | |
| 66 | + */ | |
| 67 | + echo esc_html( apply_filters( 'mainwp_notes_widget_title', esc_html__( 'Notes', 'mainwp' ), $website ) ); | |
| 68 | + ?> | |
| 69 | + <div class="sub header"><?php esc_html_e( 'Child site notes', 'mainwp' ); ?></div> | |
| 70 | + </h2> | |
| 71 | + </div> | |
| 67 | 72 | |
| 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 ); | |
| 73 | + <div class="mainwp-scrolly-overflow"> | |
| 74 | + <?php | |
| 75 | + /** | |
| 76 | + * Action: mainwp_notes_widget_top | |
| 77 | + * | |
| 78 | + * Fires at the top of the Notes widget on the Individual site overview page. | |
| 79 | + * | |
| 80 | + * @param object $website Object containing the child site info. | |
| 81 | + * | |
| 82 | + * @since 4.1 | |
| 83 | + */ | |
| 84 | + do_action( 'mainwp_notes_widget_top', $website ); | |
| 80 | 85 | |
| 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"> | |
| 113 | - | |
| 114 | - </div> | |
| 115 | - </div> | |
| 116 | - <?php endif; ?> | |
| 117 | - <?php | |
| 118 | - MainWP_UI::render_modal_edit_notes(); | |
| 119 | - } | |
| 86 | + if ( empty( $website->note ) ) { | |
| 87 | + MainWP_UI::render_empty_element_placeholder( __( 'Add your first note', 'mainwp' ), __( 'Create a website note for updates, reminders, or anything you want to track.', 'mainwp' ), '<em data-emoji=":pencil2:" class="medium"></em>' ); | |
| 88 | + } else { | |
| 89 | + ?> | |
| 90 | + <div class="content"> | |
| 91 | + <?php | |
| 92 | + echo wp_unslash( $esc_note ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 93 | + ?> | |
| 94 | + </div> | |
| 95 | + <?php | |
| 96 | + } | |
| 97 | + ?> | |
| 98 | + <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> | |
| 99 | + <?php | |
| 100 | + /** | |
| 101 | + * Action: mainwp_notes_widget_bottom | |
| 102 | + * | |
| 103 | + * Fires at the bottom of the Notes widget on the Individual site overview page. | |
| 104 | + * | |
| 105 | + * @param object $website Object containing the child site info. | |
| 106 | + * | |
| 107 | + * @since 4.1 | |
| 108 | + */ | |
| 109 | + do_action( 'mainwp_notes_widget_bottom', $website ); | |
| 110 | + ?> | |
| 111 | + </div> | |
| 112 | + <div class="ui one column grid mainwp-widget-footer"> | |
| 113 | + <div class="column"> | |
| 114 | + <a href="javascript:void(0)" class="ui basic mini button mainwp-edit-site-note" id="mainwp-notes-<?php echo intval( $website->id ); ?>" <?php echo '' !== $website->note ? '' : 'add-new="1"'; ?>><?php echo '' !== $website->note ? esc_html__( 'Edit Notes', 'mainwp' ) : esc_html__( 'Add Notes', 'mainwp' ); ?></a> | |
| 115 | + <?php MainWP_UI::render_modal_edit_notes(); ?> | |
| 116 | + </div> | |
| 117 | + </div> | |
| 118 | + <?php | |
| 119 | + } | |
| 120 | 120 | } |