| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Client Overview Info Widget |
| 4 |
* |
| 5 |
* Displays the Client Info. |
| 6 |
* |
| 7 |
* @package MainWP/MainWP_Client_Overview_Info |
| 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_Info |
| 19 |
* |
| 20 |
* Displays the Client info. |
| 21 |
*/ |
| 22 |
class MainWP_Client_Overview_Info { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. |
| 23 |
|
| 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 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Method render() |
| 35 |
* |
| 36 |
* @return mixed render_site_info() |
| 37 |
*/ |
| 38 |
public static function render() { |
| 39 |
$client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 40 |
if ( empty( $client_id ) ) { |
| 41 |
return; |
| 42 |
} |
| 43 |
static::render_client_overview( $client_id ); |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
/** |
| 48 |
* Render client overview Info. |
| 49 |
* |
| 50 |
* @param object $client_id Client ID. |
| 51 |
*/ |
| 52 |
public static function render_client_overview( $client_id ) { // phpcs:ignore -- NOSONAR - complex function. |
| 53 |
$params = array( |
| 54 |
'with_selected_sites' => true, |
| 55 |
'with_tags' => true, |
| 56 |
); |
| 57 |
$client_info = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $client_id, ARRAY_A, $params ); |
| 58 |
$client_status = ''; |
| 59 |
if ( 0 === intval( $client_info['suspended'] ) ) { |
| 60 |
$client_status = '<span class="ui green basic button">' . esc_html__( 'Active', 'mainwp' ) . '</span>'; |
| 61 |
} elseif ( 1 === intval( $client_info['suspended'] ) ) { |
| 62 |
$client_status = '<span class="ui yellow button">' . esc_html__( 'Suspended', 'mainwp' ) . '</span>'; |
| 63 |
} elseif ( 2 === intval( $client_info['suspended'] ) ) { |
| 64 |
$client_status = '<span class="ui blue button">' . esc_html__( 'Lead', 'mainwp' ) . '</span>'; |
| 65 |
} elseif ( 3 === intval( $client_info['suspended'] ) ) { |
| 66 |
$client_status = '<span class="ui red button">' . esc_html__( 'Lost', 'mainwp' ) . '</span>'; |
| 67 |
} |
| 68 |
|
| 69 |
$client_contacts = MainWP_DB_Client::instance()->get_wp_client_contact_by( 'client_id', $client_id, ARRAY_A ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 70 |
|
| 71 |
?> |
| 72 |
<div class="mainwp-widget-header"> |
| 73 |
<div class="ui grid"> |
| 74 |
<div class="twelve wide column"> |
| 75 |
<h2 class="ui header handle-drag"> |
| 76 |
<?php echo esc_html__( 'Client Info', 'mainwp' ); ?> |
| 77 |
</h2> |
| 78 |
</div> |
| 79 |
<div class="four wide right aligned column"> |
| 80 |
|
| 81 |
</div> |
| 82 |
</div> |
| 83 |
</div> |
| 84 |
|
| 85 |
<div class="mainwp-widget-client-card mainwp-scrolly-overflow" client-id="<?php echo intval( $client_id ); ?>"> |
| 86 |
<?php |
| 87 |
/** |
| 88 |
* Actoin: mainwp_clients_overview_overview_widget_top |
| 89 |
* |
| 90 |
* Fires at the top of the Site Info widget on the Individual site overview page. |
| 91 |
* |
| 92 |
* @param object $client_info Object containing the child site info. |
| 93 |
* |
| 94 |
* @since 4.0 |
| 95 |
*/ |
| 96 |
do_action( 'mainwp_clients_overview_overview_widget_top', $client_info ); |
| 97 |
?> |
| 98 |
<?php if ( $client_info ) : ?> |
| 99 |
<?php $selected_sites = isset( $client_info['selected_sites'] ) ? trim( $client_info['selected_sites'] ) : ''; ?> |
| 100 |
<div class="ui grid"> |
| 101 |
<div class="sixteen wide center aligned column"> |
| 102 |
<div class="ui image"> |
| 103 |
<?php echo MainWP_Client_Handler::get_client_contact_image( $client_info, 'client', 'small' ); //phpcs:ignore -- ok. ?> |
| 104 |
</div> |
| 105 |
</div> |
| 106 |
<div class="sixteen wide center aligned column"> |
| 107 |
<h2 class="ui center aligned header"> |
| 108 |
<div class="content"> |
| 109 |
<?php echo esc_html( $client_info['name'] ); ?> |
| 110 |
<?php if ( isset( $client_info['created'] ) && ! empty( $client_info['created'] ) ) : ?> |
| 111 |
<div class="sub header"> |
| 112 |
<i class="calendar grey icon"></i> <?php esc_html_e( 'Added ', 'mainwp' ); ?><span data-tooltip="<?php esc_attr_e( MainWP_Utility::format_date( $client_info['created'] ) ); ?>" data-inverted="" data-position="top center"><?php echo MainWP_Utility::time_elapsed_string( $client_info['created'] ); //phpcs:ignore -- ok. ?></span>. |
| 113 |
</div> |
| 114 |
<?php endif; ?> |
| 115 |
</div> |
| 116 |
</h2> |
| 117 |
</div> |
| 118 |
<div class="sixteen wide center aligned column"> |
| 119 |
<?php echo $client_status; //phpcs:ignore -- ok. ?> |
| 120 |
</div> |
| 121 |
|
| 122 |
<div class="sixteen wide center aligned column"> |
| 123 |
<?php if ( isset( $client_info['client_email'] ) && '' !== $client_info['client_email'] ) : ?> |
| 124 |
<a href="mailto:<?php echo esc_attr( $client_info['client_email'] ); ?>" class="ui basic icon button" target="_blank" data-tooltip="<?php echo esc_attr( $client_info['client_email'] ); ?>" data-inverted="" data-position="top center"> |
| 125 |
<i class="envelope grey icon"></i> |
| 126 |
</a> |
| 127 |
<?php endif; ?> |
| 128 |
<?php if ( isset( $client_info['client_phone'] ) && '' !== $client_info['client_phone'] ) : ?> |
| 129 |
<a href="tel:<?php echo esc_attr( $client_info['client_phone'] ); ?>" class="ui basic icon button" target="_blank" data-tooltip="<?php echo esc_attr( $client_info['client_phone'] ); ?>" data-inverted="" data-position="top center"> |
| 130 |
<i class="phone grey icon"></i> |
| 131 |
</a> |
| 132 |
<?php endif; ?> |
| 133 |
|
| 134 |
|
| 135 |
<?php if ( isset( $client_info['client_facebook'] ) && '' !== $client_info['client_facebook'] ) : ?> |
| 136 |
<a href="<?php echo esc_url( $client_info['client_facebook'] ); ?>" class="ui basic icon button" target="_blank"><i class="facebook grey icon"></i></a> |
| 137 |
<?php endif; ?> |
| 138 |
<?php if ( isset( $client_info['client_twitter'] ) && '' !== $client_info['client_twitter'] ) : ?> |
| 139 |
<a href="<?php echo esc_url( $client_info['client_twitter'] ); ?>" class="ui basic icon button" target="_blank"><i class="twitter grey icon"></i></a> |
| 140 |
<?php endif; ?> |
| 141 |
<?php if ( isset( $client_info['client_instagram'] ) && '' !== $client_info['client_instagram'] ) : ?> |
| 142 |
<a href="<?php echo esc_url( $client_info['client_instagram'] ); ?>" class="ui basic icon button" target="_blank"><i class="instagram grey icon"></i></a> |
| 143 |
<?php endif; ?> |
| 144 |
<?php if ( isset( $client_info['client_linkedin'] ) && '' !== $client_info['client_linkedin'] ) : ?> |
| 145 |
<a href="<?php echo esc_url( $client_info['client_linkedin'] ); ?>" class="ui basic icon button" target="_blank"><i class="linkedin grey icon"></i></a> |
| 146 |
<?php endif; ?> |
| 147 |
</div> |
| 148 |
</div> |
| 149 |
<?php endif; ?> |
| 150 |
<?php if ( $client_contacts ) : ?> |
| 151 |
<div class="ui divider"></div> |
| 152 |
<?php foreach ( $client_contacts as $contact ) : ?> |
| 153 |
<h2 class="ui header"> |
| 154 |
<?php echo MainWP_Client_Handler::get_client_contact_image( $contact, 'contact', 'small' ); //phpcs:ignore -- ok. ?> |
| 155 |
<div class="content"> |
| 156 |
<?php echo esc_html( $contact['contact_name'] ); ?> |
| 157 |
<div class="sub header"><?php echo esc_html( $contact['contact_role'] ); ?></div> |
| 158 |
</div> |
| 159 |
</h2> |
| 160 |
<?php endforeach; ?> |
| 161 |
<?php endif; ?> |
| 162 |
|
| 163 |
<?php |
| 164 |
/** |
| 165 |
* Action: mainwp_clients_overview_overview_widget_bottom |
| 166 |
* |
| 167 |
* Fires at the bottom of the Site Info widget on the Individual site overview page. |
| 168 |
* |
| 169 |
* @param object $client_info Object containing the child site info. |
| 170 |
* |
| 171 |
* @since 4.0 |
| 172 |
*/ |
| 173 |
do_action( 'mainwp_clients_overview_overview_widget_bottom', $client_info ); |
| 174 |
?> |
| 175 |
</div> |
| 176 |
<div class="mainwp-widget-footer" client-id="<?php echo intval( $client_id ); ?>"> |
| 177 |
<a href="admin.php?page=ClientAddNew&client_id=<?php echo intval( $client_id ); ?>" class="ui green mini button"><?php esc_html_e( 'Edit Client', 'mainwp' ); ?></a> |
| 178 |
<?php if ( 0 === intval( $client_info['suspended'] ) || 1 === intval( $client_info['suspended'] ) ) : ?> |
| 179 |
<a href="javascript:void(0);" suspend-status="<?php echo intval( $client_info['suspended'] ); ?>" class="ui basic mini button client-suspend-unsuspend-sites"><?php echo empty( $client_info['suspended'] ) ? esc_html__( 'Suspend', 'mainwp' ) : esc_html__( 'Unsuspend', 'mainwp' ); ?></a> |
| 180 |
<?php endif; ?> |
| 181 |
<?php |
| 182 |
if ( is_plugin_active( 'mainwp-pro-reports-extension/mainwp-pro-reports-extension.php' ) ) { |
| 183 |
$report_url = add_query_arg( |
| 184 |
array( |
| 185 |
'page' => 'Extensions-Mainwp-Pro-Reports-Extension', |
| 186 |
'tab' => 'report', |
| 187 |
'action' => 'newreport', |
| 188 |
'selected_sites' => $selected_sites, |
| 189 |
), |
| 190 |
'admin.php' |
| 191 |
); |
| 192 |
?> |
| 193 |
<a class="ui basic mini right floated button" href="<?php echo esc_url( $report_url ); ?>"><?php echo esc_html__( 'Create Report', 'mainwp' ); ?></a> |
| 194 |
<?php } ?> |
| 195 |
</div> |
| 196 |
<?php |
| 197 |
} |
| 198 |
} |
| 199 |
|