PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / trunk
MainWP Dashboard: Self-hosted WordPress Management for Agencies vtrunk
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 5.2.2 5.3 All 153 releases
mainwp / widgets / widget-mainwp-clients.php

widget-mainwp-clients.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies trunk, at widgets/widget-mainwp-clients.php

189 lines 9.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Clients Widget
4 *
5 * Displays the Clients list.
6 *
7 * @package MainWP/Dashboard
8 */
9
10 namespace MainWP\Dashboard;
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Class MainWP_Clients
19 *
20 * Displays the Site Actions.
21 */
22 class MainWP_Clients { // 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_clients()
37 */
38 public static function render() {
39 $clients = MainWP_DB_Client::instance()->get_wp_clients();
40 static::render_clients( $clients );
41 }
42
43 /**
44 * Render Clients Info.
45 *
46 * @param mixed $clients Clients data.
47 */
48 private static function render_clients( $clients ) { // phpcs:ignore -- NOSONAR - complex.
49 ?>
50 <div class="mainwp-widget-header">
51 <h2 class="ui header handle-drag">
52 <?php
53 /**
54 * Filter: mainwp_clients_widget_title
55 *
56 * Filters the Clients widget title text.
57 *
58 * @since 4.4
59 */
60 echo esc_html( apply_filters( 'mainwp_clients_widget_title', esc_html__( 'Clients', 'mainwp' ) ) );
61 ?>
62 <div class="sub header"><?php esc_html_e( 'View and manage all clients connected to your MainWP Dashboard.', 'mainwp' ); ?></div>
63 </h2>
64 </div>
65 <div id="mainwp-clients-widget" class="mainwp-scrolly-overflow">
66 <?php
67 /**
68 * Actoin: mainwp_clients_widget_top
69 *
70 * Fires at the top of the Clients widget on the overview page.
71 *
72 * @param object $clients Object containing the clients info.
73 *
74 * @since 4.4
75 */
76 do_action( 'mainwp_clients_widget_top', $clients );
77 ?>
78 <?php if ( $clients ) : ?>
79 <table class="ui table" id="mainwp-clients-widget-table">
80 <thead>
81 <tr>
82 <th scope="col"><?php esc_html_e( 'Client', 'mainwp' ); ?></th>
83 <th scope="col" class="collapsing"><?php esc_html_e( 'Primary Contact', 'mainwp' ); ?></th>
84 <th scope="col" class="no-sort collapsing"></th>
85 </tr>
86 </thead>
87 <tbody>
88 <?php foreach ( $clients as $client ) : ?>
89 <?php $client_display_image = MainWP_Client_Handler::get_client_contact_image( $client ); ?>
90 <tr>
91 <td class="left aligned middle aligned">
92 <a href="admin.php?page=ManageClients&client_id=<?php echo intval( $client['client_id'] ); ?>">
93 <?php echo $client_display_image; //phpcs:ignore -- ok. ?> <?php echo esc_html( $client['name'] ); ?>
94 </a>
95 <br/>
96 <?php if ( isset( $client['client_email'] ) && '' !== $client['client_email'] ) : ?>
97 <span class="ui small text"><a href="mailto:<?php echo esc_attr( $client['client_email'] ); ?>" class="ui grey text"><i class="envelope grey icon"></i> <?php echo esc_html( $client['client_email'] ); ?></a></span><br/>
98 <?php endif; ?>
99 <?php if ( isset( $client['client_phone'] ) && '' !== $client['client_phone'] ) : ?>
100 <span class="ui small text"><a href="tel:<?php echo esc_attr( $client['client_phone'] ); ?>" class="ui grey text"><i class="phone alternate grey icon"></i> <?php echo esc_html( $client['client_phone'] ); ?></a></span>
101 <?php endif; ?>
102 </td>
103 <td class="left aligned middle aligned">
104 <?php
105 $contact = false;
106 if ( isset( $client['primary_contact_id'] ) && '' !== $client['primary_contact_id'] ) {
107 $contact = MainWP_DB_Client::instance()->get_wp_client_contact_by( 'contact_id', $client['primary_contact_id'] );
108 if ( $contact ) {
109 ?>
110 <?php echo esc_html( $contact->contact_name ); ?> <?php echo ( isset( $contact->contact_role ) && '' !== $contact->contact_role ) ? ' - ' . esc_html( $contact->contact_role ) : ''; ?><br/>
111 <?php if ( isset( $contact->contact_email ) && '' !== $contact->contact_email ) : ?>
112 <span class="ui small text"><a href="mailto:<?php echo esc_attr( $contact->contact_email ); ?>" class="ui grey text"><i class="envelope grey icon"></i> <?php echo esc_html( $contact->contact_email ); ?></a></span><br/>
113 <?php endif; ?>
114 <?php if ( isset( $contact->contact_phone ) && '' !== $contact->contact_phone ) : ?>
115 <span class="ui small text"><a href="tel:<?php echo esc_attr( $contact->contact_phone ); ?>" class="ui grey text"><i class="phone alternate grey icon"></i> <?php echo esc_html( $contact->contact_phone ); ?></a></span>
116 <?php endif; ?>
117 <?php
118 }
119 }
120 if ( empty( $contact ) ) {
121 echo esc_html__( 'No Contacts', 'mainwp' );
122 }
123 ?>
124 </td>
125 <td class="right aligned collapsing">
126 <div class="ui right pointing dropdown mainwp-768-hide" style="z-index:999">
127 <i class="ellipsis vertical icon"></i>
128 <div class="menu">
129 <a class="item" href="admin.php?page=ManageClients&client_id=<?php echo intval( $client['client_id'] ); ?>"><?php esc_html_e( 'View', 'mainwp' ); ?></a>
130 <a class="item" href="admin.php?page=ClientAddNew&client_id=<?php echo intval( $client['client_id'] ); ?>"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a>
131 </div>
132 </div>
133 </td>
134 </tr>
135 <?php endforeach; ?>
136 </tbody>
137 </table>
138
139 <script type="text/javascript">
140 jQuery( document ).ready( function() {
141 jQuery.fn.DataTable.ext.pager.numbers_length = 4;
142 jQuery( '#mainwp-clients-widget-table' ).DataTable( {
143 "info": false,
144 "layout": {
145 "bottom": 'paging',
146 "bottomStart": null,
147 "bottomEnd": null
148 },
149 "lengthMenu": [ [5, 10, 25, 50, 100, -1], [5, 10, 25, 50, 100, "All"] ],
150 "stateSave" : true,
151 "order" : [ [1, 'asc'] ],
152 "columnDefs": [ {
153 "targets": 'no-sort',
154 "orderable": false
155 } ],
156 } );
157 setTimeout(() => {
158 mainwp_datatable_fix_menu_overflow('#mainwp-clients-widget-table', -50, 0 );
159 }, 2000 );
160 } );
161 </script>
162 <?php else : ?>
163 <?php MainWP_UI::render_empty_element_placeholder( __( 'No Clients yet', 'mainwp' ), __( 'Create your first client to see them listed here.', 'mainwp' ), '<em data-emoji=":bust_in_silhouette:" class="medium"></em>' ); ?>
164 <?php endif; ?>
165 <?php
166 /**
167 * Action: mainwp_clients_widget_bottom
168 *
169 * Fires at the bottom of the Clients widget on the overview page.
170 *
171 * @param object $clients Object containing the child site info.
172 *
173 * @since 4.4
174 */
175 do_action( 'mainwp_clients_widget_bottom', $clients );
176 ?>
177 </div>
178 <div class="ui two columns stackable grid mainwp-widget-footer">
179 <div class="left aligned middle aligned column">
180
181 </div>
182 <div class="right aligned middle aligned column">
183
184 </div>
185 </div>
186 <?php
187 }
188 }
189