| @@ -8,120 +8,125 @@ | ||
| 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_Client_Overview_Note |
| 14 | 19 | * |
| 15 | 20 | * Displays the Client Note. |
| 16 | 21 | */ |
| 17 | -class MainWP_Client_Overview_Note { | |
| 22 | +class MainWP_Client_Overview_Note { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 23 | + /** | |
| 24 | + * Method get_class_name() | |
| 25 | + * | |
| 26 | + * @return string __CLASS__ Class name. | |
| 27 | + */ | |
| 28 | + public static function get_class_name() { | |
| 29 | + return __CLASS__; | |
| 30 | + } | |
| 18 | 31 | |
| 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 | - } | |
| 32 | + /** | |
| 33 | + * Method render() | |
| 34 | + * | |
| 35 | + * @return mixed render_site_info() | |
| 36 | + */ | |
| 37 | + public static function render() { | |
| 38 | + $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 39 | + if ( empty( $client_id ) ) { | |
| 40 | + return; | |
| 41 | + } | |
| 42 | + static::render_addition_info( $client_id ); | |
| 43 | + } | |
| 27 | 44 | |
| 28 | - /** | |
| 29 | - * Method render() | |
| 30 | - * | |
| 31 | - * @return mixed render_site_info() | |
| 32 | - */ | |
| 33 | - public static function render() { | |
| 34 | - $client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 35 | - if ( empty( $client_id ) ) { | |
| 36 | - return; | |
| 37 | - } | |
| 38 | - self::render_addition_info( $client_id ); | |
| 39 | - } | |
| 40 | 45 | |
| 46 | + /** | |
| 47 | + * Render client overview Info. | |
| 48 | + * | |
| 49 | + * @param object $client_id Client ID. | |
| 50 | + */ | |
| 51 | + public static function render_addition_info( $client_id ) { | |
| 41 | 52 | |
| 42 | - /** | |
| 43 | - * Render client overview Info. | |
| 44 | - * | |
| 45 | - * @param object $client_id Client ID. | |
| 46 | - */ | |
| 47 | - public static function render_addition_info( $client_id ) { | |
| 53 | + $client_info = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $client_id, ARRAY_A ); | |
| 48 | 54 | |
| 49 | - $client_info = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $client_id, ARRAY_A ); | |
| 55 | + $note = ''; | |
| 56 | + $esc_note = ''; | |
| 50 | 57 | |
| 51 | - $note = ''; | |
| 52 | - $strip_note = ''; | |
| 53 | - $esc_note = ''; | |
| 58 | + if ( $client_info ) { | |
| 59 | + $note = html_entity_decode( $client_info['note'] ); | |
| 60 | + $esc_note = MainWP_Utility::esc_content( $note ); | |
| 61 | + } | |
| 54 | 62 | |
| 55 | - if ( $client_info ) { | |
| 56 | - $note = html_entity_decode( $client_info['note'] ); | |
| 57 | - $esc_note = MainWP_Utility::esc_content( $note ); | |
| 58 | - } | |
| 63 | + ?> | |
| 64 | + <div class="mainwp-widget-header"> | |
| 65 | + <h2 class="ui header handle-drag"> | |
| 66 | + <?php | |
| 67 | + /** | |
| 68 | + * Filter: mainwp_clients_overview_note_widget_title | |
| 69 | + * | |
| 70 | + * Filters the Site info widget title text. | |
| 71 | + * | |
| 72 | + * @param object $client_info Object containing the child site info. | |
| 73 | + * | |
| 74 | + * @since 4.1 | |
| 75 | + */ | |
| 76 | + echo esc_html( apply_filters( 'mainwp_clients_overview_note_widget_title', esc_html__( 'Notes', 'mainwp' ), $client_info ) ); | |
| 77 | + ?> | |
| 78 | + <div class="sub header"><?php echo esc_html__( 'Client notes.', 'mainwp' ); ?></div> | |
| 79 | + </h2> | |
| 80 | + </div> | |
| 81 | + <div class="mainwp-widget-client-card mainwp-scrolly-overflow"> | |
| 82 | + <?php | |
| 83 | + /** | |
| 84 | + * Actoin: mainwp_clients_overview_note_widget_top | |
| 85 | + * | |
| 86 | + * Fires at the top of the Site Info widget on the Individual site overview page. | |
| 87 | + * | |
| 88 | + * @param object $client_info Object containing the child site info. | |
| 89 | + * | |
| 90 | + * @since 4.0 | |
| 91 | + */ | |
| 92 | + do_action( 'mainwp_clients_overview_note_widget_top', $client_info ); | |
| 93 | + ?> | |
| 94 | + <?php | |
| 95 | + if ( $client_info ) { | |
| 96 | + echo $esc_note; // phpcs:ignore WordPress.Security.EscapeOutput | |
| 97 | + } | |
| 98 | + ?> | |
| 59 | 99 | |
| 60 | - ?> | |
| 61 | - <div class="mainwp-widget-header"> | |
| 62 | - <h3 class="ui header handle-drag"> | |
| 63 | - <?php | |
| 64 | - /** | |
| 65 | - * Filter: mainwp_clients_overview_note_widget_title | |
| 66 | - * | |
| 67 | - * Filters the Site info widget title text. | |
| 68 | - * | |
| 69 | - * @param object $client_info Object containing the child site info. | |
| 70 | - * | |
| 71 | - * @since 4.1 | |
| 72 | - */ | |
| 73 | - echo esc_html( apply_filters( 'mainwp_clients_overview_note_widget_title', esc_html__( 'Notes', 'mainwp' ), $client_info ) ); | |
| 74 | - ?> | |
| 75 | - <div class="sub header"><?php echo esc_html__( 'Client notes.', 'mainwp' ); ?></div> | |
| 76 | - </h3> | |
| 77 | - </div> | |
| 78 | - <div class="mainwp-widget-client-card mainwp-scrolly-overflow"> | |
| 79 | - <?php | |
| 80 | - /** | |
| 81 | - * Actoin: mainwp_clients_overview_note_widget_top | |
| 82 | - * | |
| 83 | - * Fires at the top of the Site Info widget on the Individual site overview page. | |
| 84 | - * | |
| 85 | - * @param object $client_info Object containing the child site info. | |
| 86 | - * | |
| 87 | - * @since 4.0 | |
| 88 | - */ | |
| 89 | - do_action( 'mainwp_clients_overview_note_widget_top', $client_info ); | |
| 90 | - ?> | |
| 91 | - <?php | |
| 92 | - if ( $client_info ) { | |
| 93 | - echo $esc_note; // phpcs:ignore WordPress.Security.EscapeOutput | |
| 94 | - } | |
| 95 | - ?> | |
| 96 | 100 | |
| 101 | + <div style="display:none" id="mainwp-notes-<?php echo intval( $client_info['client_id'] ); ?>-note"><?php echo wp_unslash( $esc_note ); // phpcs:ignore WordPress.Security.EscapeOutput ?></div> | |
| 97 | 102 | |
| 98 | - <div style="display:none" id="mainwp-notes-<?php echo intval( $client_info['client_id'] ); ?>-note"><?php echo wp_unslash( $esc_note ); // phpcs:ignore WordPress.Security.EscapeOutput ?></div> | |
| 103 | + <?php | |
| 99 | 104 | |
| 100 | - <?php | |
| 101 | - | |
| 102 | - /** | |
| 103 | - * Action: mainwp_clients_overview_note_widget_bottom | |
| 104 | - * | |
| 105 | - * Fires at the bottom of the Site Info widget on the Individual site overview page. | |
| 106 | - * | |
| 107 | - * @param object $client_info Object containing the child site info. | |
| 108 | - * | |
| 109 | - * @since 4.0 | |
| 110 | - */ | |
| 111 | - do_action( 'mainwp_clients_overview_note_widget_bottom', $client_info ); | |
| 112 | - ?> | |
| 113 | - </div> | |
| 114 | - <div class="ui two columns grid mainwp-widget-footer"> | |
| 115 | - <div class="column"> | |
| 116 | - <?php if ( empty( $note ) ) : ?> | |
| 117 | - <a href="javascript:void(0)" class="mainwp-edit-client-note ui button mini fluid green" id="mainwp-notes-<?php echo esc_attr( $client_info['client_id'] ); ?>" data-tooltip="<?php esc_attr_e( 'Add notes.', 'mainwp' ); ?>" data-position="right center" data-inverted=""><?php esc_attr_e( 'Add Notes', 'mainwp' ); ?></a> | |
| 118 | - <?php else : ?> | |
| 119 | - <a href="javascript:void(0)" class="mainwp-edit-client-note ui mini fluid button green" id="mainwp-notes-<?php echo esc_attr( $client_info['client_id'] ); ?>" data-tooltip="<?php esc_attr_e( 'Edit notes.', 'mainwp' ); ?>" data-position="right center" data-inverted=""><?php esc_attr_e( 'Edit Notes', 'mainwp' ); ?></a> | |
| 120 | - <?php endif; ?> | |
| 121 | - </div> | |
| 122 | - <div class="column"></div> | |
| 123 | - </div> | |
| 124 | - <?php | |
| 125 | - MainWP_UI::render_modal_edit_notes(); | |
| 126 | - } | |
| 105 | + /** | |
| 106 | + * Action: mainwp_clients_overview_note_widget_bottom | |
| 107 | + * | |
| 108 | + * Fires at the bottom of the Site Info widget on the Individual site overview page. | |
| 109 | + * | |
| 110 | + * @param object $client_info Object containing the child site info. | |
| 111 | + * | |
| 112 | + * @since 4.0 | |
| 113 | + */ | |
| 114 | + do_action( 'mainwp_clients_overview_note_widget_bottom', $client_info ); | |
| 115 | + ?> | |
| 116 | + </div> | |
| 117 | + <div class="ui two columns grid mainwp-widget-footer"> | |
| 118 | + <div class="column"> | |
| 119 | + <?php if ( empty( $note ) ) : ?> | |
| 120 | + <a href="javascript:void(0)" class="mainwp-edit-client-note ui button mini" id="mainwp-notes-<?php echo esc_attr( $client_info['client_id'] ); ?>"><?php esc_attr_e( 'Add Notes', 'mainwp' ); ?></a> | |
| 121 | + <?php else : | |
| 122 | + $el_id_cl_id_1 = $client_info['client_id']; | |
| 123 | + ?> | |
| 124 | + <a href="javascript:void(0)" class="mainwp-edit-client-note ui mini button" id="mainwp-notes-<?php echo esc_attr( $el_id_cl_id_1 ); ?>"><?php esc_attr_e( 'Edit Notes', 'mainwp' ); ?></a> | |
| 125 | + <?php endif; ?> | |
| 126 | + </div> | |
| 127 | + <div class="column"></div> | |
| 128 | + </div> | |
| 129 | + <?php | |
| 130 | + MainWP_UI::render_modal_edit_notes(); | |
| 131 | + } | |
| 127 | 132 | } |