| 1 |
<?php |
| 2 |
|
| 3 |
namespace HTML_Forms; |
| 4 |
|
| 5 |
use WP_Post; |
| 6 |
|
| 7 |
class TagReplacers { |
| 8 |
|
| 9 |
/** |
| 10 |
* @param string $prop |
| 11 |
* @return mixed |
| 12 |
*/ |
| 13 |
public function user( $prop ) { |
| 14 |
if( ! is_user_logged_in() ) { |
| 15 |
return ''; |
| 16 |
} |
| 17 |
|
| 18 |
$user = wp_get_current_user(); |
| 19 |
return isset( $user->{$prop} ) ? $user->{$prop} : ''; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* @param string $prop |
| 24 |
* @return mixed |
| 25 |
*/ |
| 26 |
public function post( $prop ) { |
| 27 |
global $post; |
| 28 |
|
| 29 |
if( ! $post instanceof WP_Post || ! isset( $post->{$prop} ) ) { |
| 30 |
return ''; |
| 31 |
} |
| 32 |
|
| 33 |
return $post->{$prop}; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* @param string $key |
| 38 |
* @return mixed |
| 39 |
*/ |
| 40 |
public function url_params( $key ) { |
| 41 |
if( ! isset( $_GET[ $key] ) ) { |
| 42 |
return ''; |
| 43 |
} |
| 44 |
|
| 45 |
return esc_attr( strip_tags( $_GET[$key] ) ); |
| 46 |
} |
| 47 |
} |
| 48 |
|