PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
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-info.php +102 -127 5.2.1 → 6.2.2 View file →
@@ -8,8 +8,14 @@
8 8 */
9 9
10 10 namespace MainWP\Dashboard;
11 11
12 +// Exit if accessed directly.
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit;
15 +}
16 +
17 +
12 18 /**
13 19 * Class MainWP_Client_Info
14 20 *
15 21 * Displays the Client info.
@@ -60,13 +66,12 @@
60 66 *
61 67 * @param object $website Object containing the child site info.
62 68 */
63 69 public static function render_info( $website ) { //phpcs:ignore -- NOSONAR - complex.
64 -
65 70 $client_info = $website->client_id ? MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $website->client_id, ARRAY_A ) : false;
66 71
67 72 ?>
68 - <h3 class="ui header handle-drag">
73 + <h2 class="ui header handle-drag mainwp-widget-header">
69 74 <?php
70 75 /**
71 76 * Filter: mainwp_clients_info_widget_title
72 77 *
@@ -77,153 +82,123 @@
77 82 * @since 4.1
78 83 */
79 84 echo esc_html( apply_filters( 'mainwp_clients_info_widget_title', esc_html__( 'Client Info', 'mainwp' ), $website ) );
80 85 ?>
81 - <div class="sub header"><?php esc_html_e( 'Client Information', 'mainwp' ); ?></div>
82 - </h3>
83 - <div class="mainwp-widget-site-info mainwp-scrolly-overflow">
86 + <div class="sub header"><?php esc_html_e( 'Client Information', 'mainwp' ); ?></div>
87 + </h2>
88 + <div class="mainwp-widget-site-info mainwp-scrolly-overflow">
89 + <?php
90 + /**
91 + * Actoin: mainwp_clients_info_widget_top
92 + *
93 + * Fires at the top of the Site Info widget on the Individual site overview page.
94 + *
95 + * @param object $website Object containing the child site info.
96 + *
97 + * @since 4.0
98 + */
99 + do_action( 'mainwp_clients_info_widget_top', $website );
100 + ?>
101 + <?php if ( $client_info ) : ?>
84 102 <?php
103 + if ( 0 === intval( $client_info['suspended'] ) ) {
104 + $client_status = '<span class="ui green basic button">' . esc_html__( 'Active', 'mainwp' ) . '</span>';
105 + } elseif ( 1 === intval( $client_info['suspended'] ) ) {
106 + $client_status = '<span class="ui yellow button">' . esc_html__( 'Suspended', 'mainwp' ) . '</span>';
107 + } elseif ( 2 === intval( $client_info['suspended'] ) ) {
108 + $client_status = '<span class="ui blue button">' . esc_html__( 'Lead', 'mainwp' ) . '</span>';
109 + } elseif ( 3 === intval( $client_info['suspended'] ) ) {
110 + $client_status = '<span class="ui red button">' . esc_html__( 'Lost', 'mainwp' ) . '</span>';
111 + }
112 +
85 113 /**
86 - * Actoin: mainwp_clients_info_widget_top
114 + * Action: mainwp_clients_info_table_top
87 115 *
88 - * Fires at the top of the Site Info widget on the Individual site overview page.
116 + * Fires at the top of the Site Info table in Site Info widget on the Individual site overview page.
89 117 *
90 118 * @param object $website Object containing the child site info.
91 119 *
92 120 * @since 4.0
93 121 */
94 - do_action( 'mainwp_clients_info_widget_top', $website );
122 + do_action( 'mainwp_clients_info_table_top', $website );
95 123 ?>
96 - <?php
97 - if ( $client_info ) {
98 - $default_client_fields = MainWP_Client_Handler::get_default_client_fields();
99 - $custom_fields = MainWP_DB_Client::instance()->get_client_fields( true, $website->client_id );
124 + <div class="ui grid">
125 + <div class="sixteen wide center aligned column">
126 + <div class="ui image">
127 + <?php echo MainWP_Client_Handler::get_client_contact_image( $client_info, 'client', 'small' ); //phpcs:ignore -- ok. ?>
128 + </div>
129 + </div>
130 + <div class="sixteen wide center aligned column">
131 + <h2 class="ui center aligned header">
132 + <div class="content">
133 + <?php echo esc_html( $client_info['name'] ); ?>
134 + <?php if ( isset( $client_info['created'] ) && ! empty( $client_info['created'] ) ) : ?>
135 + <div class="sub header">
136 + <i class="calendar grey icon"></i> <?php esc_html_e( 'Added ', 'mainwp' ); ?><span data-tooltip="<?php echo esc_attr( 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>.
137 + </div>
138 + <?php endif; ?>
139 + </div>
140 + </h2>
141 + </div>
142 + <div class="sixteen wide center aligned column">
143 + <?php echo $client_status; //phpcs:ignore -- ok. ?>
144 + </div>
100 145
101 - ?>
102 - <table class="ui celled striped table">
103 - <tbody>
104 - <?php
105 - /**
106 - * Action: mainwp_clients_info_table_top
107 - *
108 - * Fires at the top of the Site Info table in Site Info widget on the Individual site overview page.
109 - *
110 - * @param object $website Object containing the child site info.
111 - *
112 - * @since 4.0
113 - */
114 - do_action( 'mainwp_clients_info_table_top', $website );
115 - ?>
116 - <?php
146 + <div class="sixteen wide center aligned column">
147 + <?php if ( isset( $client_info['client_email'] ) && '' !== $client_info['client_email'] ) : ?>
148 + <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">
149 + <i class="envelope grey icon"></i>
150 + </a>
151 + <?php endif; ?>
152 + <?php if ( isset( $client_info['client_phone'] ) && '' !== $client_info['client_phone'] ) : ?>
153 + <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">
154 + <i class="phone grey icon"></i>
155 + </a>
156 + <?php endif; ?>
117 157
118 - foreach ( $default_client_fields as $field ) {
119 158
120 - $db_field = isset( $field['db_field'] ) ? $field['db_field'] : '';
121 - $val = ( ! empty( $db_field ) && isset( $client_info[ $db_field ] ) ) ? $client_info[ $db_field ] : '';
122 -
123 - if ( empty( $val ) ) {
124 - continue;
125 - }
126 -
127 - ?>
128 - <tr>
129 - <td><?php echo esc_html( $field['title'] ); ?></td>
130 - <td>
131 - <?php
132 - if ( 'name' === $db_field ) {
133 - ?>
134 - <a class="item" href="admin.php?page=ClientAddNew&client_id=<?php echo intval( $client_info['client_id'] ); ?>"><?php echo esc_html( $client_info['name'] ); ?></a>
135 - <?php
136 - } elseif ( 'email' === $db_field ) {
137 - ?>
138 - <a class="item" href="admin.php?page=ClientAddNew&client_id=<?php echo intval( $client_info['client_id'] ); ?>"><?php echo esc_html( $client_info['email'] ); ?></a>
139 - <?php
140 -
141 - } elseif ( 'created' === $db_field ) {
142 - ?>
143 - <?php echo MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( esc_html( $client_info['created'] ) ) ); //phpcs:ignore ?>
144 - <?php
145 -
146 - } elseif ( 'note' === $db_field ) {
147 - $note = html_entity_decode( $client_info['note'] );
148 - $esc_note = MainWP_Utility::esc_content( $note );
149 - $strip_note = wp_strip_all_tags( $esc_note );
150 -
151 - if ( empty( $client_info['note'] ) ) :
152 - ?>
153 - <a href="javascript:void(0)" class="mainwp-edit-client-note" id="mainwp-notes-<?php echo intval( $client_info['client_id'] ); ?>" data-tooltip="<?php esc_attr_e( 'Edit client notes.', 'mainwp' ); ?>" data-position="left center" data-inverted=""><i class="sticky note outline icon"></i></a>
154 - <?php else : ?>
155 - <a href="javascript:void(0)" class="mainwp-edit-client-note" id="mainwp-notes-<?php echo intval( $client_info['client_id'] ); ?>" data-tooltip="<?php echo substr( wp_unslash( $strip_note ), 0, 100 ); // phpcs:ignore WordPress.Security.EscapeOutput ?>" data-position="left center" data-inverted=""><i class="sticky green note icon"></i></a>
156 - <?php endif; ?>
157 - <span 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 ?></span>
158 - <?php
159 - } else {
160 - echo esc_html( $val );
161 - }
162 -
163 - ?>
164 - </td>
165 - </tr>
166 - <?php } ?>
167 -
168 - <?php
169 -
170 - if ( is_array( $custom_fields ) && ! empty( $custom_fields ) ) {
171 - foreach ( $custom_fields as $field ) {
172 - if ( empty( $field->field_value ) ) {
173 - continue;
174 - }
175 - ?>
176 - <tr>
177 - <td><?php echo esc_html( $field->field_desc ); ?></td>
178 - <td><?php echo esc_html( $field->field_value ); ?></td>
179 - </tr>
180 - <?php
181 - }
182 - }
183 -
184 - ?>
185 - <?php
186 - /**
187 - * Action: mainwp_clients_info_table_bottom
188 - *
189 - * Fires at the bottom of the Site Info table in Site Info widget on the Individual site overview page.
190 - *
191 - * @param object $website Object containing the child site info.
192 - *
193 - * @since 4.0
194 - */
195 - do_action( 'mainwp_clients_info_table_bottom', $website );
196 - ?>
197 - </tbody>
198 - </table>
199 - <?php
200 - } else {
201 - MainWP_UI::render_empty_element_placeholder();
202 - }
203 - ?>
159 + <?php if ( isset( $client_info['client_facebook'] ) && '' !== $client_info['client_facebook'] ) : ?>
160 + <a href="<?php echo esc_url( $client_info['client_facebook'] ); ?>" class="ui basic icon button" target="_blank"><i class="facebook grey icon"></i></a>
161 + <?php endif; ?>
162 + <?php if ( isset( $client_info['client_twitter'] ) && '' !== $client_info['client_twitter'] ) : ?>
163 + <a href="<?php echo esc_url( $client_info['client_twitter'] ); ?>" class="ui basic icon button" target="_blank"><i class="twitter grey icon"></i></a>
164 + <?php endif; ?>
165 + <?php if ( isset( $client_info['client_instagram'] ) && '' !== $client_info['client_instagram'] ) : ?>
166 + <a href="<?php echo esc_url( $client_info['client_instagram'] ); ?>" class="ui basic icon button" target="_blank"><i class="instagram grey icon"></i></a>
167 + <?php endif; ?>
168 + <?php if ( isset( $client_info['client_linkedin'] ) && '' !== $client_info['client_linkedin'] ) : ?>
169 + <a href="<?php echo esc_url( $client_info['client_linkedin'] ); ?>" class="ui basic icon button" target="_blank"><i class="linkedin grey icon"></i></a>
170 + <?php endif; ?>
171 + </div>
172 + </div>
204 173 <?php
205 174 /**
206 - * Action: mainwp_clients_info_widget_bottom
175 + * Action: mainwp_clients_info_table_bottom
207 176 *
208 - * Fires at the bottom of the Site Info widget on the Individual site overview page.
177 + * Fires at the bottom of the Site Info table in Site Info widget on the Individual site overview page.
209 178 *
210 179 * @param object $website Object containing the child site info.
211 180 *
212 181 * @since 4.0
213 182 */
214 - do_action( 'mainwp_clients_info_widget_bottom', $website );
183 + do_action( 'mainwp_clients_info_table_bottom', $website );
215 184 ?>
216 - </div>
217 - <div class="ui stackable two columns grid mainwp-widget-footer">
218 - <div class="middle aligned column">
219 - <?php if ( $client_info ) { ?>
220 - <a href="admin.php?page=ClientAddNew&client_id=<?php echo intval( $client_info['client_id'] ); ?>" title="" class="ui mini fluid button green basic"><?php echo esc_html__( 'Edit Client', 'mainwp' ); ?></a>
221 - <?php } ?>
222 - </div>
223 - <div class="middle aligned column">
224 - <a href="admin.php?page=ClientAddNew" title="" class="ui mini fluid button green"><?php echo esc_html__( 'Add New Client', 'mainwp' ); ?></a>
225 - </div>
226 - </div>
185 + <?php else : ?>
186 + <?php MainWP_UI::render_empty_element_placeholder( __( 'No Client selected', 'mainwp' ), __( 'Create a client to display their information in this widget.', 'mainwp' ), '<em data-emoji=":bust_in_silhouette:" class="medium"></em>' ); ?>
187 + <?php endif; ?>
227 188 <?php
189 + /**
190 + * Action: mainwp_clients_info_widget_bottom
191 + *
192 + * Fires at the bottom of the Site Info widget on the Individual site overview page.
193 + *
194 + * @param object $website Object containing the child site info.
195 + *
196 + * @since 4.0
197 + */
198 + do_action( 'mainwp_clients_info_widget_bottom', $website );
199 + ?>
200 + </div>
201 + <div class="mainwp-widget-footer"></div>
202 + <?php
228 203 }
229 204 }