← All changes
|
widgets/widget-mainwp-client-overview-contacts.php
+137
-143
5.0
→
6.2.1
View file →
| @@ -8,161 +8,155 @@ | ||
| 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_Overview_Contacts |
| 14 | 20 | * |
| 15 | 21 | * Displays the Client Contacts. |
| 16 | 22 | */ |
| 17 | -class MainWP_Client_Overview_Contacts { | |
| 23 | +class MainWP_Client_Overview_Contacts { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 18 | 24 | |
| 19 | 25 | |
| 20 | - /** | |
| 21 | - * The contact variable. | |
| 22 | - * | |
| 23 | - * @var mixed Default null | |
| 24 | - */ | |
| 25 | - public $contact = null; | |
| 26 | + /** | |
| 27 | + * The contact variable. | |
| 28 | + * | |
| 29 | + * @var mixed Default null | |
| 30 | + */ | |
| 31 | + public $contact = null; | |
| 26 | 32 | |
| 27 | - /** | |
| 28 | - * Method get_class_name() | |
| 29 | - * | |
| 30 | - * @return string __CLASS__ Class name. | |
| 31 | - */ | |
| 32 | - public static function get_class_name() { | |
| 33 | - return __CLASS__; | |
| 34 | - } | |
| 33 | + /** | |
| 34 | + * Method get_class_name() | |
| 35 | + * | |
| 36 | + * @return string __CLASS__ Class name. | |
| 37 | + */ | |
| 38 | + public static function get_class_name() { | |
| 39 | + return __CLASS__; | |
| 40 | + } | |
| 35 | 41 | |
| 36 | - /** | |
| 37 | - * Method render() | |
| 38 | - * | |
| 39 | - * @return mixed render_site_info() | |
| 40 | - */ | |
| 41 | - public function render() { | |
| 42 | - if ( empty( $this->contact ) ) { | |
| 43 | - return; | |
| 44 | - } | |
| 45 | - self::render_contact( $this->contact ); | |
| 46 | - } | |
| 42 | + /** | |
| 43 | + * Method render() | |
| 44 | + * | |
| 45 | + * @return mixed render_site_info() | |
| 46 | + */ | |
| 47 | + public function render() { | |
| 48 | + if ( empty( $this->contact ) ) { | |
| 49 | + return; | |
| 50 | + } | |
| 51 | + static::render_contact( $this->contact ); | |
| 52 | + } | |
| 47 | 53 | |
| 48 | 54 | |
| 49 | - /** | |
| 50 | - * Render client Contacts Info. | |
| 51 | - * | |
| 52 | - * @param object $contact_info The Contact. | |
| 53 | - */ | |
| 54 | - public static function render_contact( $contact_info ) { | |
| 55 | + /** | |
| 56 | + * Render client Contacts Info. | |
| 57 | + * | |
| 58 | + * @param object $contact_info The Contact. | |
| 59 | + */ | |
| 60 | + public static function render_contact( $contact_info ) { // phpcs:ignore -- NOSONAR - complex. | |
| 55 | 61 | |
| 56 | - if ( empty( $contact_info ) ) { | |
| 57 | - return; | |
| 58 | - } | |
| 62 | + if ( empty( $contact_info ) ) { | |
| 63 | + return; | |
| 64 | + } | |
| 59 | 65 | |
| 60 | - ?> | |
| 61 | - <div class="mainwp-widget-header"> | |
| 62 | - <h3 class="ui header handle-drag"> | |
| 63 | - <?php | |
| 64 | - /** | |
| 65 | - * Filter: mainwp_clients_overview_contact_widget_title | |
| 66 | - * | |
| 67 | - * Filters the Site info widget title text. | |
| 68 | - * | |
| 69 | - * @param object $contact_info Object containing the child site info. | |
| 70 | - * | |
| 71 | - * @since 4.1 | |
| 72 | - */ | |
| 73 | - echo esc_html( apply_filters( 'mainwp_clients_overview_contact_widget_title', $contact_info['contact_name'], $contact_info ) ); | |
| 74 | - ?> | |
| 75 | - <div class="sub header"> | |
| 76 | - <?php echo esc_html( apply_filters( 'mainwp_clients_overview_contact_widget_sutbitle', $contact_info['contact_role'], $contact_info ) ); ?> | |
| 77 | - </div> | |
| 78 | - </h3> | |
| 79 | - </div> | |
| 80 | - <div class="mainwp-widget-client-card mainwp-scrolly-overflow"> | |
| 81 | - <?php | |
| 82 | - /** | |
| 83 | - * Actoin: mainwp_clients_overview_contact_widget_top | |
| 84 | - * | |
| 85 | - * Fires at the top of the Site Info widget on the Individual site overview page. | |
| 86 | - * | |
| 87 | - * @param object $contact_info Object containing the child site info. | |
| 88 | - * | |
| 89 | - * @since 4.0 | |
| 90 | - */ | |
| 91 | - do_action( 'mainwp_clients_overview_contact_widget_top', $contact_info ); | |
| 92 | - ?> | |
| 93 | - <?php if ( $contact_info ) { ?> | |
| 94 | - <div class="ui stackable grid"> | |
| 95 | - <div class="four wide column"> | |
| 96 | - <?php if ( empty( $contact_info['contact_image'] ) ) { ?> | |
| 97 | - <i class="user icon massive"></i> | |
| 98 | - <?php | |
| 99 | - } else { | |
| 100 | - $image_url = MainWP_Client_Handler::get_client_image_url( $contact_info['contact_image'] ); | |
| 101 | - ?> | |
| 102 | - <img class="ui circular medium image" src="<?php echo esc_attr( $image_url ); ?>"> | |
| 103 | - <?php } ?> | |
| 104 | - </div> | |
| 105 | - <div class="twelve wide middle aligned column"> | |
| 106 | - <div class="ui relaxed list"> | |
| 107 | - <?php if ( isset( $contact_info['contact_email'] ) && '' !== $contact_info['contact_email'] ) : ?> | |
| 108 | - <div class="item"> | |
| 109 | - <i class="envelope grey icon"></i> | |
| 110 | - <div class="content"><a href="mailto:<?php echo esc_url( $contact_info['contact_email'] ); ?>" target="_blank"><?php echo esc_html( $contact_info['contact_email'] ); ?></a> <i data-clipboard-text="<?php echo esc_html( $contact_info['contact_email'] ); ?>" style="cursor:pointer" class="copy green icon copy-to-clipboard"></i></div> | |
| 111 | - </div> | |
| 112 | - <?php endif; ?> | |
| 113 | - <?php if ( isset( $contact_info['contact_phone'] ) && '' !== $contact_info['contact_phone'] ) : ?> | |
| 114 | - <div class="item"> | |
| 115 | - <i class="phone grey rotated icon"></i> | |
| 116 | - <div class="content"><a href="tel:<?php echo esc_url( $contact_info['contact_phone'] ); ?>" target="_blank"><?php echo esc_html( $contact_info['contact_phone'] ); ?></a></div> | |
| 117 | - </div> | |
| 118 | - <?php endif; ?> | |
| 119 | - <?php if ( isset( $contact_info['facebook'] ) && '' !== $contact_info['facebook'] ) : ?> | |
| 120 | - <div class="item"> | |
| 121 | - <i class="facebook grey icon"></i> | |
| 122 | - <div class="content"><a href="<?php echo esc_url( $contact_info['facebook'] ); ?>" target="_blank"><?php echo esc_html( $contact_info['facebook'] ); ?></a></div> | |
| 123 | - </div> | |
| 124 | - <?php endif; ?> | |
| 125 | - <?php if ( isset( $contact_info['twitter'] ) && '' !== $contact_info['twitter'] ) : ?> | |
| 126 | - <div class="item"> | |
| 127 | - <i class="twitter grey icon"></i> | |
| 128 | - <div class="content"><a href="<?php echo esc_url( $contact_info['twitter'] ); ?>" target="_blank"><?php echo esc_html( $contact_info['twitter'] ); ?></a></div> | |
| 129 | - </div> | |
| 130 | - <?php endif; ?> | |
| 131 | - <?php if ( isset( $contact_info['instagram'] ) && '' !== $contact_info['instagram'] ) : ?> | |
| 132 | - <div class="item"> | |
| 133 | - <i class="instagram grey icon"></i> | |
| 134 | - <div class="content"><a href="<?php echo esc_url( $contact_info['instagram'] ); ?>" target="_blank"><?php echo esc_html( $contact_info['instagram'] ); ?></a></div> | |
| 135 | - </div> | |
| 136 | - <?php endif; ?> | |
| 137 | - <?php if ( isset( $contact_info['linkedin'] ) && '' !== $contact_info['linkedin'] ) : ?> | |
| 138 | - <div class="item"> | |
| 139 | - <i class="linkedin grey icon"></i> | |
| 140 | - <div class="content"><a href="<?php echo esc_url( $contact_info['linkedin'] ); ?>" target="_blank"><?php echo esc_html( $contact_info['linkedin'] ); ?></a></div> | |
| 141 | - </div> | |
| 142 | - <?php endif; ?> | |
| 143 | - </div> | |
| 144 | - </div> | |
| 145 | - </div> | |
| 146 | - <div class="ui hidden divider"></div> | |
| 147 | - <script type="text/javascript"> | |
| 148 | - jQuery( document ).ready( function ($) { | |
| 149 | - new ClipboardJS('.copy-to-clipboard'); | |
| 150 | - }); | |
| 151 | - </script> | |
| 152 | - <?php } ?> | |
| 153 | - <?php | |
| 154 | - /** | |
| 155 | - * Action: mainwp_clients_overview_contact_widget_bottom | |
| 156 | - * | |
| 157 | - * Fires at the bottom of the Site Info widget on the Individual site overview page. | |
| 158 | - * | |
| 159 | - * @param object $contact_info Object containing the child site info. | |
| 160 | - * | |
| 161 | - * @since 4.0 | |
| 162 | - */ | |
| 163 | - do_action( 'mainwp_clients_overview_contact_widget_bottom', $contact_info ); | |
| 164 | - ?> | |
| 165 | - </div> | |
| 166 | - <?php | |
| 167 | - } | |
| 66 | + ?> | |
| 67 | + <div class="mainwp-widget-header"> | |
| 68 | + <h2 class="ui header handle-drag"> | |
| 69 | + <?php | |
| 70 | + /** | |
| 71 | + * Filter: mainwp_clients_overview_contact_widget_title | |
| 72 | + * | |
| 73 | + * Filters the Site info widget title text. | |
| 74 | + * | |
| 75 | + * @param object $contact_info Object containing the child site info. | |
| 76 | + * | |
| 77 | + * @since 4.1 | |
| 78 | + */ | |
| 79 | + echo esc_html( apply_filters( 'mainwp_clients_overview_contact_widget_title', __( 'Client Contact', 'mainwp' ), $contact_info ) ); | |
| 80 | + ?> | |
| 81 | + <div class="sub header"> | |
| 82 | + <?php echo esc_html( apply_filters( 'mainwp_clients_overview_contact_widget_sutbitle', __( 'Contact Information', 'mainwp' ), $contact_info ) ); ?> | |
| 83 | + </div> | |
| 84 | + </h2> | |
| 85 | + </div> | |
| 86 | + <div class="mainwp-widget-client-card mainwp-scrolly-overflow"> | |
| 87 | + <?php | |
| 88 | + /** | |
| 89 | + * Actoin: mainwp_clients_overview_contact_widget_top | |
| 90 | + * | |
| 91 | + * Fires at the top of the Site Info widget on the Individual site overview page. | |
| 92 | + * | |
| 93 | + * @param object $contact_info Object containing the child site info. | |
| 94 | + * | |
| 95 | + * @since 4.0 | |
| 96 | + */ | |
| 97 | + do_action( 'mainwp_clients_overview_contact_widget_top', $contact_info ); | |
| 98 | + ?> | |
| 99 | + <?php if ( $contact_info ) : ?> | |
| 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( $contact_info, 'contact', '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( $contact_info['contact_name'] ); ?> | |
| 110 | + <?php if ( isset( $contact_info['contact_role'] ) && ! empty( $contact_info['contact_role'] ) ) : ?> | |
| 111 | + <div class="sub header"> | |
| 112 | + <?php echo esc_html( $contact_info['contact_role'] ); ?> | |
| 113 | + </div> | |
| 114 | + <?php endif; ?> | |
| 115 | + </div> | |
| 116 | + </h2> | |
| 117 | + </div> | |
| 118 | + | |
| 119 | + <div class="sixteen wide center aligned column"> | |
| 120 | + <?php if ( isset( $contact_info['contact_email'] ) && '' !== $contact_info['contact_email'] ) : ?> | |
| 121 | + <a href="mailto:<?php echo esc_attr( $contact_info['contact_email'] ); ?>" class="ui basic icon button" target="_blank" data-tooltip="<?php echo esc_attr( $contact_info['contact_email'] ); ?>" data-inverted="" data-position="top center"> | |
| 122 | + <i class="envelope grey icon"></i> | |
| 123 | + </a> | |
| 124 | + <?php endif; ?> | |
| 125 | + <?php if ( isset( $contact_info['contact_phone'] ) && '' !== $contact_info['contact_phone'] ) : ?> | |
| 126 | + <a href="tel:<?php echo esc_attr( $contact_info['contact_phone'] ); ?>" class="ui basic icon button" target="_blank" data-tooltip="<?php echo esc_attr( $contact_info['contact_phone'] ); ?>" data-inverted="" data-position="top center"> | |
| 127 | + <i class="phone grey icon"></i> | |
| 128 | + </a> | |
| 129 | + <?php endif; ?> | |
| 130 | + | |
| 131 | + | |
| 132 | + <?php if ( isset( $contact_info['facebook'] ) && '' !== $contact_info['facebook'] ) : ?> | |
| 133 | + <a href="<?php echo esc_url( $contact_info['facebook'] ); ?>" class="ui basic icon button" target="_blank"><i class="facebook grey icon"></i></a> | |
| 134 | + <?php endif; ?> | |
| 135 | + <?php if ( isset( $contact_info['twitter'] ) && '' !== $contact_info['twitter'] ) : ?> | |
| 136 | + <a href="<?php echo esc_url( $contact_info['twitter'] ); ?>" class="ui basic icon button" target="_blank"><i class="twitter grey icon"></i></a> | |
| 137 | + <?php endif; ?> | |
| 138 | + <?php if ( isset( $contact_info['instagram'] ) && '' !== $contact_info['instagram'] ) : ?> | |
| 139 | + <a href="<?php echo esc_url( $contact_info['instagram'] ); ?>" class="ui basic icon button" target="_blank"><i class="instagram grey icon"></i></a> | |
| 140 | + <?php endif; ?> | |
| 141 | + <?php if ( isset( $contact_info['linkedin'] ) && '' !== $contact_info['linkedin'] ) : ?> | |
| 142 | + <a href="<?php echo esc_url( $contact_info['linkedin'] ); ?>" class="ui basic icon button" target="_blank"><i class="linkedin grey icon"></i></a> | |
| 143 | + <?php endif; ?> | |
| 144 | + </div> | |
| 145 | + </div> | |
| 146 | + <?php endif; ?> | |
| 147 | + <?php | |
| 148 | + /** | |
| 149 | + * Action: mainwp_clients_overview_contact_widget_bottom | |
| 150 | + * | |
| 151 | + * Fires at the bottom of the Site Info widget on the Individual site overview page. | |
| 152 | + * | |
| 153 | + * @param object $contact_info Object containing the child site info. | |
| 154 | + * | |
| 155 | + * @since 4.0 | |
| 156 | + */ | |
| 157 | + do_action( 'mainwp_clients_overview_contact_widget_bottom', $contact_info ); | |
| 158 | + ?> | |
| 159 | + </div> | |
| 160 | + <?php | |
| 161 | + } | |
| 168 | 162 | } |