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 +176 -196 5.0 → 6.2.2 View file →
@@ -8,217 +8,197 @@
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.
16 22 */
17 -class MainWP_Client_Info {
23 +class MainWP_Client_Info { //phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR - complexity.
18 24
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 - }
25 + /**
26 + * Method get_class_name()
27 + *
28 + * @return string __CLASS__ Class name.
29 + */
30 + public static function get_class_name() {
31 + return __CLASS__;
32 + }
27 33
28 - /**
29 - * Method render()
30 - *
31 - * @return mixed render_site_info()
32 - */
33 - public static function render() {
34 - self::render_site_info();
35 - }
34 + /**
35 + * Method render()
36 + *
37 + * @return mixed render_site_info()
38 + */
39 + public static function render() {
40 + static::render_site_info();
41 + }
36 42
37 - /**
38 - * Method render_site_info()
39 - *
40 - * Grab Child Site Info and render.
41 - *
42 - * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
43 - * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
44 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
45 - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
46 - */
47 - public static function render_site_info() {
48 - $current_wpid = MainWP_System_Utility::get_current_wpid();
49 - if ( empty( $current_wpid ) ) {
50 - return;
51 - }
43 + /**
44 + * Method render_site_info()
45 + *
46 + * Grab Child Site Info and render.
47 + *
48 + * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
49 + * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
50 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
51 + * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
52 + */
53 + public static function render_site_info() {
54 + $current_wpid = MainWP_System_Utility::get_current_wpid();
55 + if ( empty( $current_wpid ) ) {
56 + return;
57 + }
52 58
53 - $website = MainWP_DB::instance()->get_website_by_id( $current_wpid, true );
59 + $website = MainWP_DB::instance()->get_website_by_id( $current_wpid, true );
54 60
55 - self::render_info( $website );
56 - }
61 + static::render_info( $website );
62 + }
57 63
58 - /**
59 - * Render Sites Info.
60 - *
61 - * @param object $website Object containing the child site info.
62 - */
63 - public static function render_info( $website ) {
64 + /**
65 + * Render Sites Info.
66 + *
67 + * @param object $website Object containing the child site info.
68 + */
69 + public static function render_info( $website ) { //phpcs:ignore -- NOSONAR - complex.
70 + $client_info = $website->client_id ? MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $website->client_id, ARRAY_A ) : false;
64 71
65 - $client_info = $website->client_id ? MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $website->client_id, ARRAY_A ) : false;
72 + ?>
73 + <h2 class="ui header handle-drag mainwp-widget-header">
74 + <?php
75 + /**
76 + * Filter: mainwp_clients_info_widget_title
77 + *
78 + * Filters the Site info widget title text.
79 + *
80 + * @param object $website Object containing the child site info.
81 + *
82 + * @since 4.1
83 + */
84 + echo esc_html( apply_filters( 'mainwp_clients_info_widget_title', esc_html__( 'Client Info', 'mainwp' ), $website ) );
85 + ?>
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 ) : ?>
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 + }
66 112
67 - ?>
68 - <h3 class="ui header handle-drag">
69 - <?php
70 - /**
71 - * Filter: mainwp_clients_info_widget_title
72 - *
73 - * Filters the Site info widget title text.
74 - *
75 - * @param object $website Object containing the child site info.
76 - *
77 - * @since 4.1
78 - */
79 - echo esc_html( apply_filters( 'mainwp_clients_info_widget_title', esc_html__( 'Client Info', 'mainwp' ), $website ) );
80 - ?>
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">
84 - <?php
85 - /**
86 - * Actoin: mainwp_clients_info_widget_top
87 - *
88 - * Fires at the top of the Site Info widget on the Individual site overview page.
89 - *
90 - * @param object $website Object containing the child site info.
91 - *
92 - * @since 4.0
93 - */
94 - do_action( 'mainwp_clients_info_widget_top', $website );
95 - ?>
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 );
113 + /**
114 + * Action: mainwp_clients_info_table_top
115 + *
116 + * Fires at the top of the Site Info table in Site Info widget on the Individual site overview page.
117 + *
118 + * @param object $website Object containing the child site info.
119 + *
120 + * @since 4.0
121 + */
122 + do_action( 'mainwp_clients_info_table_top', $website );
123 + ?>
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_name => $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 ( 'note' === $db_field ) {
142 - $note = html_entity_decode( $client_info['note'] );
143 - $esc_note = MainWP_Utility::esc_content( $note );
144 - $strip_note = wp_strip_all_tags( $esc_note );
145 -
146 - if ( empty( $client_info['note'] ) ) :
147 - ?>
148 - <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>
149 - <?php else : ?>
150 - <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>
151 - <?php endif; ?>
152 - <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>
153 - <?php
154 - } else {
155 - echo esc_html( $val );
156 - }
157 -
158 - ?>
159 - </td>
160 - </tr>
161 - <?php } ?>
162 -
163 - <?php
164 -
165 - if ( is_array( $custom_fields ) && count( $custom_fields ) > 0 ) {
166 - foreach ( $custom_fields as $field ) {
167 - if ( empty( $field->field_value ) ) {
168 - continue;
169 - }
170 - ?>
171 - <tr>
172 - <td><?php echo esc_html( $field->field_desc ); ?></td>
173 - <td><?php echo esc_html( $field->field_value ); ?></td>
174 - </tr>
175 - <?php
176 - }
177 - }
178 -
179 - ?>
180 - <?php
181 - /**
182 - * Action: mainwp_clients_info_table_bottom
183 - *
184 - * Fires at the bottom of the Site Info table in Site Info widget on the Individual site overview page.
185 - *
186 - * @param object $website Object containing the child site info.
187 - *
188 - * @since 4.0
189 - */
190 - do_action( 'mainwp_clients_info_table_bottom', $website );
191 - ?>
192 - </tbody>
193 - </table>
194 - <?php
195 - } else {
196 - MainWP_UI::render_empty_element_placeholder();
197 - }
198 - ?>
199 - <?php
200 - /**
201 - * Action: mainwp_clients_info_widget_bottom
202 - *
203 - * Fires at the bottom of the Site Info widget on the Individual site overview page.
204 - *
205 - * @param object $website Object containing the child site info.
206 - *
207 - * @since 4.0
208 - */
209 - do_action( 'mainwp_clients_info_widget_bottom', $website );
210 - ?>
211 - </div>
212 - <div class="ui stackable two columns grid mainwp-widget-footer">
213 - <div class="middle aligned column">
214 - <?php if ( $client_info ) { ?>
215 - <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>
216 - <?php } ?>
217 - </div>
218 - <div class="middle aligned column">
219 - <a href="admin.php?page=ClientAddNew" title="" class="ui mini fluid button green"><?php echo esc_html__( 'Add New Client', 'mainwp' ); ?></a>
220 - </div>
221 - </div>
222 - <?php
223 - }
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>
173 + <?php
174 + /**
175 + * Action: mainwp_clients_info_table_bottom
176 + *
177 + * Fires at the bottom of the Site Info table in Site Info widget on the Individual site overview page.
178 + *
179 + * @param object $website Object containing the child site info.
180 + *
181 + * @since 4.0
182 + */
183 + do_action( 'mainwp_clients_info_table_bottom', $website );
184 + ?>
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; ?>
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
203 + }
224 204 }