| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Client Overview Note Widget |
| 4 |
* |
| 5 |
* Displays the Client Note. |
| 6 |
* |
| 7 |
* @package MainWP/MainWP_Client_Overview_Note |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace MainWP\Dashboard; |
| 11 |
|
| 12 |
// Exit if accessed directly. |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Class MainWP_Client_Overview_Note |
| 19 |
* |
| 20 |
* Displays the Client Note. |
| 21 |
*/ |
| 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 |
} |
| 31 |
|
| 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 |
} |
| 44 |
|
| 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 ) { |
| 52 |
|
| 53 |
$client_info = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $client_id, ARRAY_A ); |
| 54 |
|
| 55 |
$note = ''; |
| 56 |
$esc_note = ''; |
| 57 |
|
| 58 |
if ( $client_info ) { |
| 59 |
$note = html_entity_decode( $client_info['note'] ); |
| 60 |
$esc_note = MainWP_Utility::esc_content( $note ); |
| 61 |
} |
| 62 |
|
| 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 |
?> |
| 99 |
|
| 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> |
| 102 |
|
| 103 |
<?php |
| 104 |
|
| 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 |
} |
| 132 |
} |
| 133 |
|