Advertisement
Guest User

Untitled

a guest
Mar 29th, 2021
54
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. use EasyWatermark\Placeholders\Abstracts\StringPlaceholder;
  3.  
  4. /**
  5. * Abstract placeholder
  6. */
  7. class PhotographerPlaceholder extends StringPlaceholder {
  8.  
  9. /**
  10. * Constructor
  11. *
  12. * @return void
  13.  
  14.  
  15. */
  16. public function __construct() {
  17.  
  18. $this->slug = 'photographer';
  19. $this->name = __( 'Photographer', 'textdomain' );
  20. $this->example = __( 'John Doe', 'textdomain' );
  21.  
  22. }
  23.  
  24. /**
  25. * Resolves placeholder
  26. *
  27. * @param EasyWatermark\Placeholders\Resolver $resolver Placeholders resolver instance.
  28. * @return string
  29. */
  30.  
  31. public function is_valid( $resolver ) {
  32. return (bool) $resolver->get_attachment();
  33. }
  34.  
  35. public function resolve( $resolver ) {
  36. return $resolver->get_attachment()->be_photographer_name;
  37. }}
  38.  
  39.  
  40. /**
  41. * @param EasyWatermark\Placeholders\Resolver $resolver Placeholders resolver instance.
  42. */
  43. add_action( 'easy-watermark/placeholders/load', function ( $resolver ) {
  44. // Add custom placeholder instance to the resolver.
  45. $resolver->add_placeholder( new PhotographerPlaceholder() );
  46. } );
Advertisement
RAW Paste Data Copied
Advertisement