| 1: | <?php |
| 2: | /** |
| 3: | * EPL Author Loader class |
| 4: | * |
| 5: | * @package EPL |
| 6: | * @subpackage Classes/AuthorLoader |
| 7: | * @copyright Copyright (c) 2022, Merv Barrett |
| 8: | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9: | * @since 3.4.39 |
| 10: | */ |
| 11: | |
| 12: | // Exit if accessed directly. |
| 13: | if ( ! defined( 'ABSPATH' ) ) { |
| 14: | exit; |
| 15: | } |
| 16: | |
| 17: | /** |
| 18: | * EPL_Author_Loader Class |
| 19: | * |
| 20: | * @since 3.4.39 |
| 21: | */ |
| 22: | if ( ! class_exists( 'EPL_Author_Loader' ) ) : |
| 23: | |
| 24: | /** |
| 25: | * EPL_Author_Loader Class |
| 26: | * |
| 27: | * @since 3.4.39 |
| 28: | */ |
| 29: | class EPL_Author_Loader { |
| 30: | |
| 31: | /** |
| 32: | * The user ID |
| 33: | * |
| 34: | * @since 3.4.44 |
| 35: | * @var string $author_id User ID. |
| 36: | */ |
| 37: | public $author_id; |
| 38: | |
| 39: | /** |
| 40: | * The username |
| 41: | * |
| 42: | * @since 3.4.44 |
| 43: | * @var string $name User name. |
| 44: | */ |
| 45: | public $name; |
| 46: | |
| 47: | /** |
| 48: | * The user mobile phone number |
| 49: | * |
| 50: | * @since 3.4.44 |
| 51: | * @var string $mobile User mobile number. |
| 52: | */ |
| 53: | public $mobile; |
| 54: | |
| 55: | /** |
| 56: | * The user office phone number |
| 57: | * |
| 58: | * @since 3.3.0 |
| 59: | * @var string $office_phone User office phone. |
| 60: | */ |
| 61: | public $office_phone; |
| 62: | |
| 63: | /** |
| 64: | * The user website |
| 65: | * |
| 66: | * @since 3.5.15 |
| 67: | * @var string $website User website. |
| 68: | */ |
| 69: | public $website; |
| 70: | |
| 71: | /** |
| 72: | * The user Facebook URL |
| 73: | * |
| 74: | * @since 3.4.44 |
| 75: | * @var string $facebook User Facebook profile URL. |
| 76: | */ |
| 77: | public $facebook; |
| 78: | |
| 79: | /** |
| 80: | * The user LinkedIn URL |
| 81: | * |
| 82: | * @since 3.4.44 |
| 83: | * @var string $linkedin User LinkedIn profile URL. |
| 84: | */ |
| 85: | public $linkedin; |
| 86: | |
| 87: | /** |
| 88: | * The user Google Plus URL |
| 89: | * |
| 90: | * @since 3.4.44 |
| 91: | * @var string $google User Google Plus profile URL. |
| 92: | */ |
| 93: | public $google; |
| 94: | |
| 95: | /** |
| 96: | * The user Twitter URL |
| 97: | * |
| 98: | * @since 3.4.44 |
| 99: | * @var string $twitter User Twitter ID. |
| 100: | */ |
| 101: | public $twitter; |
| 102: | |
| 103: | /** |
| 104: | * The user Instagram URL |
| 105: | * |
| 106: | * @since 3.3.0 |
| 107: | * @var string $instagram User Instagram profile URL. |
| 108: | */ |
| 109: | public $instagram; |
| 110: | |
| 111: | /** |
| 112: | * The user Pinterest URL |
| 113: | * |
| 114: | * @since 3.3.0 |
| 115: | * @var string $pinterest User Pinterest profile URL. |
| 116: | */ |
| 117: | public $pinterest; |
| 118: | |
| 119: | /** |
| 120: | * The user YouTube URL |
| 121: | * |
| 122: | * @since 3.3.0 |
| 123: | * @var string $youtube User YouTube profile URL. |
| 124: | */ |
| 125: | public $youtube; |
| 126: | |
| 127: | /** |
| 128: | * The user email address |
| 129: | * |
| 130: | * @since 3.4.44 |
| 131: | * @var string $email User email address. |
| 132: | */ |
| 133: | public $email; |
| 134: | |
| 135: | /** |
| 136: | * The user Skype name |
| 137: | * |
| 138: | * @since 3.4.44 |
| 139: | * @var string $skype User Skype ID. |
| 140: | */ |
| 141: | public $skype; |
| 142: | |
| 143: | /** |
| 144: | * The user text slogan |
| 145: | * |
| 146: | * @since 3.4.44 |
| 147: | * @var string $slogan User Slogan text string. |
| 148: | */ |
| 149: | public $slogan; |
| 150: | |
| 151: | /** |
| 152: | * The user position |
| 153: | * |
| 154: | * @since 3.4.44 |
| 155: | * @var string $position User position text string. |
| 156: | */ |
| 157: | public $position; |
| 158: | |
| 159: | /** |
| 160: | * The user video profile |
| 161: | * |
| 162: | * @since 3.4.44 |
| 163: | * @var string $video User video profile URL. |
| 164: | */ |
| 165: | public $video; |
| 166: | |
| 167: | /** |
| 168: | * The user contact form shortcode |
| 169: | * |
| 170: | * @since 3.4.44 |
| 171: | * @var string $contact_form User contact shortcode. |
| 172: | */ |
| 173: | public $contact_form; |
| 174: | |
| 175: | /** |
| 176: | * The user bio |
| 177: | * |
| 178: | * @since 3.4.44 |
| 179: | * @var string $description User bio textarea. |
| 180: | */ |
| 181: | public $description; |
| 182: | |
| 183: | /** |
| 184: | * Staff ID |
| 185: | * |
| 186: | * @since 3.4.44 |
| 187: | * @var string Staff ID used in staff dir extension. |
| 188: | */ |
| 189: | public $staff_id; |
| 190: | |
| 191: | /** |
| 192: | * Directory |
| 193: | * |
| 194: | * @since 3.4.44 |
| 195: | * @var string Directory. |
| 196: | */ |
| 197: | public $directory; |
| 198: | |
| 199: | /** |
| 200: | * First Name |
| 201: | * |
| 202: | * @since 3.4.44 |
| 203: | * @var string First Name. |
| 204: | */ |
| 205: | public $first_name; |
| 206: | |
| 207: | /** |
| 208: | * Last Name |
| 209: | * |
| 210: | * @since 3.4.44 |
| 211: | * @var string Last Name. |
| 212: | */ |
| 213: | public $last_name; |
| 214: | |
| 215: | /** |
| 216: | * Secondary Email |
| 217: | * |
| 218: | * @since 3.4.44 |
| 219: | * @var string Secondary Email. |
| 220: | */ |
| 221: | public $secondary_email; |
| 222: | |
| 223: | /** |
| 224: | |
| 225: | * |
| 226: | * @since 3.4.44 |
| 227: | * @var string Whatsapp. |
| 228: | */ |
| 229: | public $whatsapp; |
| 230: | |
| 231: | /** |
| 232: | * Object. |
| 233: | * |
| 234: | * @var string $object Object. |
| 235: | * @since 3.4.39 |
| 236: | */ |
| 237: | public $object; |
| 238: | |
| 239: | /** |
| 240: | * Initiates the loader class and dynamically populates methods & properties for this class from the selected class. |
| 241: | * |
| 242: | * @since 3.4.39 |
| 243: | * @param string $author_id The author WordPress user ID. |
| 244: | */ |
| 245: | public function __construct( $author_id ) { |
| 246: | |
| 247: | $class_name = apply_filters( 'epl_author_class_name', 'EPL_Author' ); |
| 248: | |
| 249: | if ( class_exists( $class_name ) ) { |
| 250: | $this->object = new $class_name( $author_id ); |
| 251: | } else { |
| 252: | // Fallback to default class. |
| 253: | $this->object = new EPL_Author( $author_id ); |
| 254: | } |
| 255: | $this->import_class_properties(); |
| 256: | } |
| 257: | |
| 258: | /** |
| 259: | * Copy class properties from selected class to this class. |
| 260: | * |
| 261: | * @since 3.4.39 |
| 262: | */ |
| 263: | public function import_class_properties() { |
| 264: | foreach ( get_object_vars( $this->object ) as $key => $value ) { |
| 265: | $this->$key = $value; |
| 266: | } |
| 267: | } |
| 268: | |
| 269: | /** |
| 270: | * Invoke methods from selected class when called through load class object. |
| 271: | * |
| 272: | * @param array $name Array of property object. |
| 273: | * @param array $arguments Array of property object. |
| 274: | * |
| 275: | * @since 3.4.39 |
| 276: | */ |
| 277: | public function __call( $name, $arguments ) { |
| 278: | return call_user_func_array( array( $this->object, $name ), $arguments ); |
| 279: | } |
| 280: | |
| 281: | /** |
| 282: | * Get the global property object |
| 283: | * |
| 284: | * @param array $property Array of property object. |
| 285: | * |
| 286: | * @return bool|mixed $return Array of values. |
| 287: | * @since 3.4.39 |
| 288: | */ |
| 289: | public function __get( $property ) { |
| 290: | |
| 291: | $prop_val = ! empty( $this->object->{$property} ) ? $this->object->{$property} : false; |
| 292: | $prop_meta = get_user_meta( $this->author_id, $property, true ); |
| 293: | |
| 294: | if ( ! empty( $prop_val ) ) { |
| 295: | return $prop_val; |
| 296: | |
| 297: | } elseif ( ! empty( $prop_meta ) ) { |
| 298: | return $prop_meta; |
| 299: | } |
| 300: | } |
| 301: | } |
| 302: | endif; |
| 303: |