PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
6.2.2 6.2.1 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 All 155 releases
← All changes | widgets/widget-mainwp-client-overview-info.php +176 -185 5.0 → 6.2.1 View file →
@@ -8,200 +8,191 @@
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_Info
14 19 *
15 20 * Displays the Client info.
16 21 */
17 -class MainWP_Client_Overview_Info {
22 +class MainWP_Client_Overview_Info { // 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 - * @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_client_overview( $client_id );
39 - }
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 + }
40 45
41 46
42 - /**
43 - * Render client overview Info.
44 - *
45 - * @param object $client_id Client ID.
46 - */
47 - public static function render_client_overview( $client_id ) { // phpcs:ignore -- complex function.
48 - $params = array(
49 - 'with_selected_sites' => true,
50 - 'with_tags' => true,
51 - );
52 - $client_info = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $client_id, ARRAY_A, $params );
53 - $client_status = '';
54 - if ( 0 === intval( $client_info['suspended'] ) ) {
55 - $client_status = '<span class="ui green label">' . esc_html__( 'Active', 'mainwp' ) . '</span>';
56 - } elseif ( 1 === intval( $client_info['suspended'] ) ) {
57 - $client_status = '<span class="ui yellow label">' . esc_html__( 'Suspended', 'mainwp' ) . '</span>';
58 - } elseif ( 2 === intval( $client_info['suspended'] ) ) {
59 - $client_status = '<span class="ui blue label">' . esc_html__( 'Lead', 'mainwp' ) . '</span>';
60 - } elseif ( 3 === intval( $client_info['suspended'] ) ) {
61 - $client_status = '<span class="ui red label">' . esc_html__( 'Lost', 'mainwp' ) . '</span>';
62 - }
63 - ?>
64 - <div class="mainwp-widget-header">
65 - <h3 class="ui header handle-drag">
66 - <?php echo esc_html( $client_info['name'] ); ?> <?php echo $client_status; //phpcs:ignore -- ok. ?>
67 - <div class="ui hidden divider"></div>
68 - <div class="sub header">
69 - <?php echo MainWP_System_Utility::get_site_tags( $client_info, true ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
70 - </div>
71 - </h3>
72 - </div>
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 + }
73 68
74 - <div class="mainwp-widget-client-card mainwp-scrolly-overflow" client-id="<?php echo intval( $client_id ); ?>">
75 - <?php
76 - /**
77 - * Actoin: mainwp_clients_overview_overview_widget_top
78 - *
79 - * Fires at the top of the Site Info widget on the Individual site overview page.
80 - *
81 - * @param object $client_info Object containing the child site info.
82 - *
83 - * @since 4.0
84 - */
85 - do_action( 'mainwp_clients_overview_overview_widget_top', $client_info );
86 - ?>
87 - <?php
88 - if ( $client_info ) {
89 - $selected_sites = isset( $client_info['selected_sites'] ) ? trim( $client_info['selected_sites'] ) : '';
90 - ?>
91 - <div class="ui stackable grid">
92 - <div class="four wide middle aligned column">
93 - <?php if ( empty( $client_info['image'] ) ) : ?>
94 - <i class="user icon massive"></i>
95 - <?php else : ?>
96 - <?php $image_url = MainWP_Client_Handler::get_client_image_url( $client_info['image'] ); ?>
97 - <img class="ui medium circular image" src="<?php echo esc_attr( $image_url ); ?>">
98 - <?php endif; ?>
99 - </div>
100 - <div class="twelve wide middle aligned column">
101 - <div class="ui relaxed list">
102 - <?php if ( isset( $client_info['client_email'] ) && '' !== $client_info['client_email'] ) : ?>
103 - <div class="item">
104 - <i class="envelope grey icon"></i>
105 - <div class="content"><a href="mailto:<?php echo esc_url( $client_info['client_email'] ); ?>" target="_blank"><?php echo esc_html( $client_info['client_email'] ); ?></a> <i data-clipboard-text="<?php echo esc_html( $client_info['client_email'] ); ?>" style="cursor:pointer" class="copy green icon copy-to-clipboard"></i></div>
106 - </div>
107 - <?php endif; ?>
108 - <?php if ( isset( $client_info['client_phone'] ) && '' !== $client_info['client_phone'] ) : ?>
109 - <div class="item">
110 - <i class="phone grey rotated icon"></i>
111 - <div class="content"><a href="tel:<?php echo esc_url( $client_info['client_phone'] ); ?>" target="_blank"><?php echo esc_html( $client_info['client_phone'] ); ?></a></div>
112 - </div>
113 - <?php endif; ?>
114 - <?php if ( isset( $client_info['client_facebook'] ) && '' !== $client_info['client_facebook'] ) : ?>
115 - <div class="item">
116 - <i class="facebook grey icon"></i>
117 - <div class="content"><a href="<?php echo esc_url( $client_info['client_facebook'] ); ?>" target="_blank"><?php echo esc_html( $client_info['client_facebook'] ); ?></a></div>
118 - </div>
119 - <?php endif; ?>
120 - <?php if ( isset( $client_info['client_twitter'] ) && '' !== $client_info['client_twitter'] ) : ?>
121 - <div class="item">
122 - <i class="twitter grey icon"></i>
123 - <div class="content"><a href="<?php echo esc_url( $client_info['client_twitter'] ); ?>" target="_blank"><?php echo esc_html( $client_info['client_twitter'] ); ?></a></div>
124 - </div>
125 - <?php endif; ?>
126 - <?php if ( isset( $client_info['client_instagram'] ) && '' !== $client_info['client_instagram'] ) : ?>
127 - <div class="item">
128 - <i class="instagram grey icon"></i>
129 - <div class="content"><a href="<?php echo esc_url( $client_info['client_instagram'] ); ?>" target="_blank"><?php echo esc_html( $client_info['client_instagram'] ); ?></a></div>
130 - </div>
131 - <?php endif; ?>
132 - <?php if ( isset( $client_info['client_linkedin'] ) && '' !== $client_info['client_linkedin'] ) : ?>
133 - <div class="item">
134 - <i class="linkedin grey icon"></i>
135 - <div class="content"><a href="<?php echo esc_url( $client_info['client_linkedin'] ); ?>" target="_blank"><?php echo esc_html( $client_info['client_linkedin'] ); ?></a></div>
136 - </div>
137 - <?php endif; ?>
138 - <?php if ( ( isset( $client_info['address_1'] ) && '' !== $client_info['address_1'] ) || ( isset( $client_info['address_2'] ) && '' !== $client_info['address_2'] ) || ( isset( $client_info['city'] ) && '' !== $client_info['city'] ) || ( isset( $client_info['state'] ) && '' !== $client_info['state'] ) || ( isset( $client_info['zip'] ) && '' !== $client_info['zip'] ) || ( isset( $client_info['country'] ) && '' !== $client_info['country'] ) ) : ?>
139 - <div class="item">
140 - <i class="map marker grey icon"></i>
141 - <div class="content">
142 - <?php if ( isset( $client_info['address_1'] ) && '' !== $client_info['address_1'] ) : ?>
143 - <?php echo esc_html( $client_info['address_1'] ); ?>
144 - <?php endif; ?>
145 - <?php if ( isset( $client_info['address_2'] ) && '' !== $client_info['address_2'] ) : ?>
146 - <?php echo esc_html( $client_info['address_2'] ); ?>
147 - <?php endif; ?>
148 - <?php if ( isset( $client_info['city'] ) && '' !== $client_info['city'] ) : ?>
149 - <?php echo esc_html( $client_info['city'] ); ?>
150 - <?php endif; ?>
151 - <?php if ( isset( $client_info['zip'] ) && '' !== $client_info['zip'] ) : ?>
152 - <?php echo esc_html( $client_info['zip'] ); ?>
153 - <?php endif; ?>
154 - <?php if ( isset( $client_info['state'] ) && '' !== $client_info['state'] ) : ?>
155 - <?php echo esc_html( $client_info['state'] ); ?>
156 - <?php endif; ?>
157 - <?php if ( isset( $client_info['country'] ) && '' !== $client_info['country'] ) : ?>
158 - <?php echo esc_html( $client_info['country'] ); ?>
159 - <?php endif; ?>
160 - </div>
161 - </div>
162 - <?php endif; ?>
163 - <?php if ( isset( $client_info['created'] ) && ! empty( $client_info['created'] ) ) : ?>
164 - <div class="item">
165 - <i class="calendar icon"></i>
166 - <div class="content"><?php echo esc_html( MainWP_Utility::format_date( $client_info['created'] ) ); ?></div>
167 - </div>
168 - <?php endif; ?>
169 - </div>
170 - </div>
171 - </div>
172 - <script type="text/javascript">
173 - jQuery( document ).ready( function ($) {
174 - new ClipboardJS('.copy-to-clipboard');
175 - } );
176 - </script>
177 - <?php } ?>
178 - <?php
179 - /**
180 - * Action: mainwp_clients_overview_overview_widget_bottom
181 - *
182 - * Fires at the bottom of the Site Info widget on the Individual site overview page.
183 - *
184 - * @param object $client_info Object containing the child site info.
185 - *
186 - * @since 4.0
187 - */
188 - do_action( 'mainwp_clients_overview_overview_widget_bottom', $client_info );
189 - ?>
190 - </div>
191 - <div class="mainwp-widget-footer ui four columns stackable grid" client-id="<?php echo intval( $client_id ); ?>">
192 - <div class="column"><a href="admin.php?page=ClientAddNew&client_id=<?php echo intval( $client_id ); ?>" title="" class="ui button mini fluid green"><?php echo esc_html__( 'Edit Client', 'mainwp' ); ?></a></div>
193 - <div class="column"><a class="ui green basic mini fluid button" href="admin.php?page=managesites&client=<?php echo intval( $client_id ); ?>"><?php esc_html_e( 'Manage Sites', 'mainwp' ); ?></a></div>
194 - <div class="column">
195 - <?php if ( is_plugin_active( 'mainwp-pro-reports-extension/mainwp-pro-reports-extension.php' ) ) { ?>
196 - <a class="ui green basic mini fluid button" href="admin.php?page=Extensions-Mainwp-Pro-Reports-Extension&tab=report&action=newreport&selected_sites=<?php echo esc_html( $selected_sites ); ?>"><?php esc_html_e( 'Create Report', 'mainwp' ); ?></a>
197 - <?php } ?>
198 - </div>
199 - <div class="column">
200 - <?php if ( 0 === intval( $client_info['suspended'] ) || 1 === intval( $client_info['suspended'] ) ) : ?>
201 - <a href="javascript:void(0);" suspend-status="<?php echo intval( $client_info['suspended'] ); ?>" title="" class="ui mini fluid button client-suspend-unsuspend-sites"><?php echo empty( $client_info['suspended'] ) ? esc_html__( 'Suspend Sites', 'mainwp' ) : esc_html__( 'Unsuspend Sites', 'mainwp' ); ?></a>
202 - <?php endif; ?>
203 - </div>
204 - </div>
205 - <?php
206 - }
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 + }
207 198 }