| 1 |
<?php |
| 2 |
/** |
| 3 |
* Client Handler. |
| 4 |
* |
| 5 |
* @package MainWP/Dashboard |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace MainWP\Dashboard; |
| 9 |
|
| 10 |
/** |
| 11 |
* Class MainWP_Client_Handler |
| 12 |
* |
| 13 |
* @package MainWP\Dashboard |
| 14 |
* |
| 15 |
* @uses \MainWP\Dashboard\MainWP_Client_Handler |
| 16 |
*/ |
| 17 |
class MainWP_Client_Handler { |
| 18 |
|
| 19 |
/** |
| 20 |
* Private static variable to hold the single instance of the class. |
| 21 |
* |
| 22 |
* @static |
| 23 |
* |
| 24 |
* @var mixed Default null |
| 25 |
*/ |
| 26 |
private static $instance = null; |
| 27 |
|
| 28 |
/** |
| 29 |
* Method instance() |
| 30 |
* |
| 31 |
* Create a public static instance. |
| 32 |
* |
| 33 |
* @static |
| 34 |
* @return MainWP_Client_Handler |
| 35 |
*/ |
| 36 |
public static function instance() { |
| 37 |
if ( null == self::$instance ) { |
| 38 |
self::$instance = new self(); |
| 39 |
} |
| 40 |
return self::$instance; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
/** |
| 45 |
* Get default client fields. |
| 46 |
* |
| 47 |
* Get default client fields. |
| 48 |
*/ |
| 49 |
public static function get_default_client_fields() { |
| 50 |
|
| 51 |
return array( |
| 52 |
'client.name' => array( |
| 53 |
'title' => esc_html__( 'Client Name (Required)', 'mainwp' ), |
| 54 |
'desc' => esc_html__( 'Displays the Client name', 'mainwp' ), |
| 55 |
'db_field' => 'name', |
| 56 |
), |
| 57 |
'client.email' => array( |
| 58 |
'title' => esc_html__( 'Client email', 'mainwp' ), |
| 59 |
'desc' => esc_html__( 'Displays the client email', 'mainwp' ), |
| 60 |
'db_field' => 'client_email', |
| 61 |
), |
| 62 |
'client.phone' => array( |
| 63 |
'title' => esc_html__( 'Client phone', 'mainwp' ), |
| 64 |
'desc' => esc_html__( 'Displays the client phone', 'mainwp' ), |
| 65 |
'db_field' => 'client_phone', |
| 66 |
), |
| 67 |
'client.facebook' => array( |
| 68 |
'title' => esc_html__( 'Client Facebook', 'mainwp' ), |
| 69 |
'desc' => esc_html__( 'Displays the client Facebook', 'mainwp' ), |
| 70 |
'db_field' => 'client_facebook', |
| 71 |
), |
| 72 |
'client.twitter' => array( |
| 73 |
'title' => esc_html__( 'Client Twitter', 'mainwp' ), |
| 74 |
'desc' => esc_html__( 'Displays the client Twitter', 'mainwp' ), |
| 75 |
'db_field' => 'client_twitter', |
| 76 |
), |
| 77 |
'client.instagram' => array( |
| 78 |
'title' => esc_html__( 'Client Instagram', 'mainwp' ), |
| 79 |
'desc' => esc_html__( 'Displays the client Instagram', 'mainwp' ), |
| 80 |
'db_field' => 'client_instagram', |
| 81 |
), |
| 82 |
'client.linkedin' => array( |
| 83 |
'title' => esc_html__( 'Client LinkedIn', 'mainwp' ), |
| 84 |
'desc' => esc_html__( 'Displays the client LinkedIn', 'mainwp' ), |
| 85 |
'db_field' => 'client_linkedin', |
| 86 |
), |
| 87 |
'client.contact.address.1' => array( |
| 88 |
'title' => esc_html__( 'Client address 1', 'mainwp' ), |
| 89 |
'desc' => esc_html__( 'Displays the client contact address 1', 'mainwp' ), |
| 90 |
'db_field' => 'address_1', |
| 91 |
), |
| 92 |
'client.contact.address.2' => array( |
| 93 |
'title' => esc_html__( 'Client address 2', 'mainwp' ), |
| 94 |
'desc' => esc_html__( 'Displays the client contact address 2', 'mainwp' ), |
| 95 |
'db_field' => 'address_2', |
| 96 |
), |
| 97 |
'client.city' => array( |
| 98 |
'title' => esc_html__( 'Client city', 'mainwp' ), |
| 99 |
'desc' => esc_html__( 'Displays the client city', 'mainwp' ), |
| 100 |
'db_field' => 'city', |
| 101 |
), |
| 102 |
'client.state' => array( |
| 103 |
'title' => esc_html__( 'Client state', 'mainwp' ), |
| 104 |
'desc' => esc_html__( 'Displays the client state', 'mainwp' ), |
| 105 |
'db_field' => 'state', |
| 106 |
), |
| 107 |
'client.zip' => array( |
| 108 |
'title' => esc_html__( 'Client ZIP', 'mainwp' ), |
| 109 |
'desc' => esc_html__( 'Displays the client ZIP code', 'mainwp' ), |
| 110 |
'db_field' => 'zip', |
| 111 |
), |
| 112 |
'client.country' => array( |
| 113 |
'title' => esc_html__( 'Client country', 'mainwp' ), |
| 114 |
'desc' => esc_html__( 'Displays the client country', 'mainwp' ), |
| 115 |
'db_field' => 'country', |
| 116 |
), |
| 117 |
'client.note' => array( |
| 118 |
'title' => esc_html__( 'Client notes', 'mainwp' ), |
| 119 |
'desc' => esc_html__( 'Displays the client note', 'mainwp' ), |
| 120 |
'db_field' => 'note', |
| 121 |
), |
| 122 |
'client.suspended' => array( |
| 123 |
'title' => esc_html__( 'Client status', 'mainwp' ), |
| 124 |
'desc' => esc_html__( 'Displays the client suspended state', 'mainwp' ), |
| 125 |
'db_field' => 'suspended', |
| 126 |
), |
| 127 |
); |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
/** |
| 132 |
* Get default contact fields. |
| 133 |
* |
| 134 |
* Get default contact fields. |
| 135 |
*/ |
| 136 |
public static function get_default_contact_fields() { |
| 137 |
return array( |
| 138 |
'client.contact.name' => array( |
| 139 |
'title' => esc_html__( 'Contact name (Required)', 'mainwp' ), |
| 140 |
'desc' => esc_html__( 'Displays the client contact name', 'mainwp' ), |
| 141 |
'db_field' => 'contact_name', |
| 142 |
), |
| 143 |
'contact.role' => array( |
| 144 |
'title' => esc_html__( 'Contact role', 'mainwp' ), |
| 145 |
'desc' => esc_html__( 'Displays the contact role', 'mainwp' ), |
| 146 |
'db_field' => 'contact_role', |
| 147 |
), |
| 148 |
'contact.email' => array( |
| 149 |
'title' => esc_html__( 'Contact email (Required)', 'mainwp' ), |
| 150 |
'desc' => esc_html__( 'Displays the contact email', 'mainwp' ), |
| 151 |
'db_field' => 'contact_email', |
| 152 |
), |
| 153 |
'contact.phone' => array( |
| 154 |
'title' => esc_html__( 'Contact phone', 'mainwp' ), |
| 155 |
'desc' => esc_html__( 'Displays the contact phone', 'mainwp' ), |
| 156 |
'db_field' => 'contact_phone', |
| 157 |
), |
| 158 |
'contact.facebook' => array( |
| 159 |
'title' => esc_html__( 'Contact Facebook', 'mainwp' ), |
| 160 |
'desc' => esc_html__( 'Displays the contact Facebook', 'mainwp' ), |
| 161 |
'db_field' => 'facebook', |
| 162 |
), |
| 163 |
'contact.twitter' => array( |
| 164 |
'title' => esc_html__( 'Contact Twitter', 'mainwp' ), |
| 165 |
'desc' => esc_html__( 'Displays the contact Twitter', 'mainwp' ), |
| 166 |
'db_field' => 'twitter', |
| 167 |
), |
| 168 |
'contact.instagram' => array( |
| 169 |
'title' => esc_html__( 'Contact Instagram', 'mainwp' ), |
| 170 |
'desc' => esc_html__( 'Displays the contact Instagram', 'mainwp' ), |
| 171 |
'db_field' => 'instagram', |
| 172 |
), |
| 173 |
'contact.linkedin' => array( |
| 174 |
'title' => esc_html__( 'Contact LinkedIn', 'mainwp' ), |
| 175 |
'desc' => esc_html__( 'Displays the contact LinkedIn', 'mainwp' ), |
| 176 |
'db_field' => 'linkedin', |
| 177 |
), |
| 178 |
); |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
/** |
| 183 |
* Method get_compatible_tokens(). |
| 184 |
* |
| 185 |
* Get compatible tokens. |
| 186 |
*/ |
| 187 |
public static function get_compatible_tokens() { |
| 188 |
return array( |
| 189 |
'client.contact.name' => 'client.contact.name', |
| 190 |
'client.email' => 'contact.email', |
| 191 |
'client.phone' => 'contact.phone', |
| 192 |
); |
| 193 |
} |
| 194 |
/** |
| 195 |
* Method rest_api_add_client(). |
| 196 |
* |
| 197 |
* Rest API add client. |
| 198 |
* |
| 199 |
* @param array $data fields array. |
| 200 |
* @param bool $edit Is edit. |
| 201 |
* |
| 202 |
* $data fields. |
| 203 |
* 'client_email'. |
| 204 |
* 'name'. |
| 205 |
* 'client_facebook'. |
| 206 |
* 'client_twitter'. |
| 207 |
* 'client_instagram'. |
| 208 |
* 'client_linkedin'. |
| 209 |
* 'address_1'. |
| 210 |
* 'address_2'. |
| 211 |
* 'city'. |
| 212 |
* 'zip'. |
| 213 |
* 'state'. |
| 214 |
* 'note'. |
| 215 |
* 'selected_sites'. |
| 216 |
* 'client_id'. - to edit client. |
| 217 |
* |
| 218 |
* @throws \Exception Error message. |
| 219 |
* @return mixed Results. |
| 220 |
*/ |
| 221 |
public static function rest_api_add_client( $data, $edit = false ) { // phpcs:ignore -- comlex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated. |
| 222 |
|
| 223 |
$params = array(); |
| 224 |
|
| 225 |
if ( $edit ) { |
| 226 |
|
| 227 |
$client_id = isset( $data['client_id'] ) ? intval( $data['client_id'] ) : 0; |
| 228 |
|
| 229 |
if ( empty( $client_id ) ) { // edit client. |
| 230 |
return array( |
| 231 |
'error' => esc_html__( 'Client ID field is required! Please enter a Client ID.', 'mainwp' ), |
| 232 |
); |
| 233 |
} |
| 234 |
|
| 235 |
$params['client_id'] = $client_id; |
| 236 |
|
| 237 |
if ( isset( $data['name'] ) ) { |
| 238 |
$params['name'] = sanitize_text_field( wp_unslash( $data['name'] ) ); |
| 239 |
} |
| 240 |
|
| 241 |
if ( isset( $data['address_1'] ) ) { |
| 242 |
$params['address_1'] = sanitize_text_field( wp_unslash( $data['address_1'] ) ); |
| 243 |
} |
| 244 |
if ( isset( $data['address_2'] ) ) { |
| 245 |
$params['address_2'] = sanitize_text_field( wp_unslash( $data['address_2'] ) ); |
| 246 |
} |
| 247 |
if ( isset( $data['city'] ) ) { |
| 248 |
$params['city'] = sanitize_text_field( wp_unslash( $data['city'] ) ); |
| 249 |
} |
| 250 |
if ( isset( $data['zip'] ) ) { |
| 251 |
$params['zip'] = sanitize_text_field( wp_unslash( $data['zip'] ) ); |
| 252 |
} |
| 253 |
if ( isset( $data['state'] ) ) { |
| 254 |
$params['state'] = sanitize_text_field( wp_unslash( $data['state'] ) ); |
| 255 |
} |
| 256 |
|
| 257 |
if ( isset( $data['country'] ) ) { |
| 258 |
$params['country'] = sanitize_text_field( wp_unslash( $data['country'] ) ); |
| 259 |
} |
| 260 |
|
| 261 |
if ( isset( $data['note'] ) ) { |
| 262 |
$params['note'] = sanitize_text_field( wp_unslash( $data['note'] ) ); |
| 263 |
} |
| 264 |
|
| 265 |
if ( isset( $data['client_email'] ) ) { |
| 266 |
$params['client_email'] = sanitize_text_field( wp_unslash( $data['client_email'] ) ); |
| 267 |
} |
| 268 |
|
| 269 |
if ( isset( $data['client_phone'] ) ) { |
| 270 |
$params['client_phone'] = sanitize_text_field( wp_unslash( $data['client_phone'] ) ); |
| 271 |
} |
| 272 |
|
| 273 |
if ( isset( $data['client_facebook'] ) ) { |
| 274 |
$params['client_facebook'] = sanitize_text_field( wp_unslash( $data['client_facebook'] ) ); |
| 275 |
} |
| 276 |
|
| 277 |
if ( isset( $data['client_twitter'] ) ) { |
| 278 |
$params['client_twitter'] = sanitize_text_field( wp_unslash( $data['client_twitter'] ) ); |
| 279 |
} |
| 280 |
|
| 281 |
if ( isset( $data['client_instagram'] ) ) { |
| 282 |
$params['client_instagram'] = sanitize_text_field( wp_unslash( $data['client_instagram'] ) ); |
| 283 |
} |
| 284 |
|
| 285 |
if ( isset( $data['client_linkedin'] ) ) { |
| 286 |
$params['client_linkedin'] = sanitize_text_field( wp_unslash( $data['client_linkedin'] ) ); |
| 287 |
} |
| 288 |
|
| 289 |
try { |
| 290 |
MainWP_DB_Client::instance()->update_client( $params, true ); |
| 291 |
} catch ( \Exception $e ) { |
| 292 |
throw $e; |
| 293 |
} |
| 294 |
|
| 295 |
if ( isset( $data['selected_sites'] ) && is_array( $data['selected_sites'] ) ) { |
| 296 |
$selected_sites = array_map( 'sanitize_text_field', wp_unslash( $data['selected_sites'] ) ); |
| 297 |
MainWP_DB_Client::instance()->update_selected_sites_for_client( $client_id, $selected_sites ); |
| 298 |
} |
| 299 |
|
| 300 |
if ( isset( $data['custom_fields'] ) && is_array( $data['custom_fields'] ) ) { |
| 301 |
$custom_fields = wp_unslash( $data['custom_fields'] ); |
| 302 |
foreach ( $custom_fields as $field ) { |
| 303 |
$fie_name = isset( $field['field_name'] ) ? sanitize_text_field( wp_unslash( $field['field_name'] ) ) : ''; |
| 304 |
$fie_value = isset( $field['field_value'] ) ? sanitize_text_field( wp_unslash( $field['field_value'] ) ) : ''; |
| 305 |
$fie_desc = isset( $field['field_desc'] ) ? sanitize_text_field( wp_unslash( $field['field_desc'] ) ) : ''; |
| 306 |
if ( ! empty( $fie_name ) && ! empty( $fie_value ) ) { |
| 307 |
$get_gen_field = MainWP_DB_Client::instance()->get_client_fields_by( 'field_name', $fie_name, 0 ); |
| 308 |
if ( $get_gen_field ) { // it is general field. |
| 309 |
if ( ! empty( $fie_desc ) ) { |
| 310 |
MainWP_DB_Client::instance()->update_client_field( |
| 311 |
$get_gen_field->field_id, |
| 312 |
array( |
| 313 |
'field_desc' => $fie_desc, |
| 314 |
) |
| 315 |
); |
| 316 |
} |
| 317 |
MainWP_DB_Client::instance()->update_client_field_value( $get_gen_field->field_id, $fie_value, $client_id ); // add or update general field value for the client. |
| 318 |
} else { |
| 319 |
$indi_gen_field = MainWP_DB_Client::instance()->get_client_fields_by( 'field_name', $fie_name, $client_id ); |
| 320 |
if ( $indi_gen_field ) { // it is individual field. |
| 321 |
|
| 322 |
if ( ! empty( $fie_desc ) ) { |
| 323 |
MainWP_DB_Client::instance()->update_client_field( |
| 324 |
$indi_gen_field->field_id, |
| 325 |
array( |
| 326 |
'field_desc' => $fie_desc, |
| 327 |
'client_id' => $client_id, |
| 328 |
) |
| 329 |
); |
| 330 |
} |
| 331 |
MainWP_DB_Client::instance()->update_client_field_value( $indi_gen_field->field_id, $fie_value, $client_id ); // add or update individual field value for the client. |
| 332 |
} |
| 333 |
} |
| 334 |
} |
| 335 |
} |
| 336 |
} |
| 337 |
|
| 338 |
return array( |
| 339 |
'success' => true, |
| 340 |
'clientid' => $client_id, |
| 341 |
); |
| 342 |
|
| 343 |
} else { |
| 344 |
|
| 345 |
$params['name'] = isset( $data['name'] ) ? sanitize_text_field( wp_unslash( $data['name'] ) ) : ''; |
| 346 |
|
| 347 |
if ( empty( $params['name'] ) ) { |
| 348 |
return array( |
| 349 |
'error' => esc_html__( 'Client name field is required! Please enter a Client name.', 'mainwp' ), |
| 350 |
); |
| 351 |
} |
| 352 |
|
| 353 |
$params['address_1'] = isset( $data['address_1'] ) ? sanitize_text_field( wp_unslash( $data['address_1'] ) ) : ''; |
| 354 |
$params['address_2'] = isset( $data['address_2'] ) ? sanitize_text_field( wp_unslash( $data['address_2'] ) ) : ''; |
| 355 |
$params['city'] = isset( $data['city'] ) ? sanitize_text_field( wp_unslash( $data['city'] ) ) : ''; |
| 356 |
$params['zip'] = isset( $data['zip'] ) ? sanitize_text_field( wp_unslash( $data['zip'] ) ) : ''; |
| 357 |
$params['state'] = isset( $data['state'] ) ? sanitize_text_field( wp_unslash( $data['state'] ) ) : ''; |
| 358 |
$params['country'] = isset( $data['country'] ) ? sanitize_text_field( wp_unslash( $data['country'] ) ) : ''; |
| 359 |
$params['note'] = isset( $data['note'] ) ? sanitize_text_field( wp_unslash( $data['note'] ) ) : ''; |
| 360 |
$params['client_email'] = isset( $data['client_email'] ) ? sanitize_text_field( wp_unslash( $data['client_email'] ) ) : ''; |
| 361 |
$params['client_phone'] = isset( $data['client_phone'] ) ? sanitize_text_field( wp_unslash( $data['client_phone'] ) ) : ''; |
| 362 |
$params['client_facebook'] = isset( $data['client_facebook'] ) ? sanitize_text_field( wp_unslash( $data['client_facebook'] ) ) : ''; |
| 363 |
$params['client_twitter'] = isset( $data['client_twitter'] ) ? sanitize_text_field( wp_unslash( $data['client_twitter'] ) ) : ''; |
| 364 |
$params['client_instagram'] = isset( $data['client_instagram'] ) ? sanitize_text_field( wp_unslash( $data['client_instagram'] ) ) : ''; |
| 365 |
$params['client_linkedin'] = isset( $data['client_linkedin'] ) ? sanitize_text_field( wp_unslash( $data['client_linkedin'] ) ) : ''; |
| 366 |
|
| 367 |
$inserted = MainWP_DB_Client::instance()->update_client( $params ); |
| 368 |
|
| 369 |
if ( empty( $inserted ) ) { |
| 370 |
return array( |
| 371 |
'error' => esc_html__( 'Undefined error. Please try again.', 'mainwp' ), |
| 372 |
); |
| 373 |
} |
| 374 |
|
| 375 |
$selected_sites = ( isset( $data['selected_sites'] ) && is_array( $data['selected_sites'] ) ) ? array_map( 'sanitize_text_field', wp_unslash( $data['selected_sites'] ) ) : array(); |
| 376 |
|
| 377 |
MainWP_DB_Client::instance()->update_selected_sites_for_client( $inserted->client_id, $selected_sites ); |
| 378 |
|
| 379 |
return array( |
| 380 |
'success' => true, |
| 381 |
'clientid' => $inserted->client_id, |
| 382 |
); |
| 383 |
} |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
/** |
| 388 |
* Method get_website_client_tokens_data() |
| 389 |
* |
| 390 |
* Get website client tokens. |
| 391 |
* |
| 392 |
* @param int $websiteid Website ID. |
| 393 |
* |
| 394 |
* @return mixed $result Result of tokens. |
| 395 |
*/ |
| 396 |
public function get_website_client_tokens_data( $websiteid = false ) { // phpcs:ignore -- comlex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated. |
| 397 |
if ( empty( $websiteid ) ) { |
| 398 |
return false; |
| 399 |
} |
| 400 |
$website = MainWP_DB::instance()->get_website_by_id( $websiteid ); |
| 401 |
if ( empty( $website ) ) { |
| 402 |
return false; |
| 403 |
} |
| 404 |
|
| 405 |
$client_tokens = array(); |
| 406 |
|
| 407 |
$client_tokens['client.site.url'] = $website->url; |
| 408 |
$client_tokens['client.site.name'] = $website->name; |
| 409 |
|
| 410 |
// init values. |
| 411 |
$default_client_fields = self::get_default_client_fields(); |
| 412 |
foreach ( $default_client_fields as $tok_name => $field ) { |
| 413 |
$client_tokens[ $tok_name ] = ''; // the tokens with empty value will be removed from the report. |
| 414 |
} |
| 415 |
$contact_fields = self::get_default_contact_fields(); |
| 416 |
if ( ! empty( $contact_fields ) && is_array( $contact_fields ) ) { |
| 417 |
foreach ( $contact_fields as $tok_name => $field ) { |
| 418 |
$client_tokens[ $tok_name ] = ''; // the tokens with empty value will be removed from the report. |
| 419 |
} |
| 420 |
} |
| 421 |
|
| 422 |
$custom_tokens_fields = MainWP_DB_Client::instance()->get_client_fields( true, $website->client_id ); |
| 423 |
if ( ! empty( $custom_tokens_fields ) && is_array( $custom_tokens_fields ) ) { |
| 424 |
foreach ( $custom_tokens_fields as $fields ) { |
| 425 |
$client_tokens[ $fields->field_name ] = ''; // the tokens with empty value will be removed from the report. |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
if ( empty( $website->client_id ) ) { |
| 430 |
return $client_tokens; |
| 431 |
} |
| 432 |
|
| 433 |
$clientid = $website->client_id; |
| 434 |
|
| 435 |
$client_info = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $clientid ); |
| 436 |
|
| 437 |
if ( empty( $client_info ) ) { |
| 438 |
return $client_tokens; |
| 439 |
} |
| 440 |
|
| 441 |
if ( ! empty( $custom_tokens_fields ) && is_array( $custom_tokens_fields ) ) { |
| 442 |
foreach ( $custom_tokens_fields as $fields ) { |
| 443 |
$client_tokens[ $fields->field_name ] = $fields->field_value; |
| 444 |
} |
| 445 |
} |
| 446 |
|
| 447 |
foreach ( $default_client_fields as $tok_name => $field ) { |
| 448 |
$db_field = $field['db_field']; |
| 449 |
if ( property_exists( $client_info, $db_field ) ) { |
| 450 |
$client_tokens[ $tok_name ] = $client_info->{$db_field}; |
| 451 |
} |
| 452 |
} |
| 453 |
|
| 454 |
if ( ! empty( $contact_fields ) && is_array( $contact_fields ) ) { |
| 455 |
foreach ( $contact_fields as $tok_name => $field ) { |
| 456 |
$db_field = isset( $field['db_field'] ) ? $field['db_field'] : ''; |
| 457 |
$val = '' != $db_field && property_exists( $client_info, $db_field ) ? $client_info->{$db_field} : false; |
| 458 |
if ( false !== $val ) { |
| 459 |
$client_tokens[ $tok_name ] = $val; |
| 460 |
} |
| 461 |
} |
| 462 |
} |
| 463 |
$client_tokens = apply_filters( 'mainwp_clients_website_client_tokens', $client_tokens, $websiteid, $clientid ); |
| 464 |
return $client_tokens; |
| 465 |
} |
| 466 |
|
| 467 |
/** |
| 468 |
* Method get_favico_url() |
| 469 |
* |
| 470 |
* Get Child Site favicon URL. |
| 471 |
* |
| 472 |
* @param string $image_path Client image url path. |
| 473 |
* |
| 474 |
* @return mixed $full_url Full image URL. |
| 475 |
*/ |
| 476 |
public static function get_client_image_url( $image_path ) { |
| 477 |
$full_url = ''; |
| 478 |
if ( ! empty( $image_path ) ) { |
| 479 |
$dirs = MainWP_System_Utility::get_mainwp_dir( 'client-images', true ); |
| 480 |
if ( file_exists( $dirs[0] . $image_path ) ) { |
| 481 |
$full_url = $dirs[1] . $image_path; |
| 482 |
} else { |
| 483 |
$full_url = ''; |
| 484 |
} |
| 485 |
} |
| 486 |
return $full_url; |
| 487 |
} |
| 488 |
|
| 489 |
/** |
| 490 |
* Method show_notice_existed_contact_emails() |
| 491 |
*/ |
| 492 |
public static function show_notice_existed_contact_emails() { |
| 493 |
$existed_emails = MainWP_Utility::get_flash_message( 'contact_existed_emails' ); |
| 494 |
if ( ! empty( $existed_emails ) ) { |
| 495 |
$existed_emails = esc_html( $existed_emails ); |
| 496 |
$existed_emails = str_replace( '|', '<br/>', $existed_emails ); |
| 497 |
?> |
| 498 |
<div class="ui yellow message"> |
| 499 |
<?php echo sprintf( esc_html__( 'Existed contact emails.%sPlease try again.', 'mainwp' ), '<br/>' . $existed_emails . '</br>' ); ?> |
| 500 |
</div> |
| 501 |
<?php |
| 502 |
} |
| 503 |
} |
| 504 |
} |
| 505 |
|