| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Client Info Widget |
| 4 |
* |
| 5 |
* Displays the Client Info. |
| 6 |
* |
| 7 |
* @package MainWP/MainWP_Client_Info |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace MainWP\Dashboard; |
| 11 |
|
| 12 |
// Exit if accessed directly. |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
/** |
| 19 |
* Class MainWP_Client_Info |
| 20 |
* |
| 21 |
* Displays the Client info. |
| 22 |
*/ |
| 23 |
class MainWP_Client_Info { //phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR - complexity. |
| 24 |
|
| 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 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Method render() |
| 36 |
* |
| 37 |
* @return mixed render_site_info() |
| 38 |
*/ |
| 39 |
public static function render() { |
| 40 |
static::render_site_info(); |
| 41 |
} |
| 42 |
|
| 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 |
} |
| 58 |
|
| 59 |
$website = MainWP_DB::instance()->get_website_by_id( $current_wpid, true ); |
| 60 |
|
| 61 |
static::render_info( $website ); |
| 62 |
} |
| 63 |
|
| 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; |
| 71 |
|
| 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 |
} |
| 112 |
|
| 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> |
| 145 |
|
| 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; ?> |
| 157 |
|
| 158 |
|
| 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 |
} |
| 204 |
} |
| 205 |
|