block.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * Name: Call To Action
  4. * Section: content
  5. * Description: Call to action button
  6. */
  7. $default_options = array(
  8. 'text' => 'Call to action',
  9. 'background' => '#256F9C',
  10. 'font_color' => '#ffffff',
  11. 'url' => home_url(),
  12. 'font_family' => $font_family,
  13. 'font_size' => 16,
  14. 'font_weight' => 'normal',
  15. 'block_background' => '#ffffff',
  16. 'width' => '200',
  17. 'block_padding_top' => 20,
  18. 'block_padding_bottom' => 20,
  19. );
  20. $options = array_merge($default_options, $options);
  21. ?>
  22. <style>
  23. .cta-button {
  24. font-size: <?php echo $options['font_size'] ?>px;
  25. font-family: <?php echo $options['font_family'] ?>;
  26. font-weight: <?php echo $options['font_weight'] ?>;
  27. color: <?php echo $options['font_color'] ?>;
  28. text-decoration: none;
  29. background-color: <?php echo $options['background'] ?>;
  30. line-height: normal;
  31. border-top: 15px solid <?php echo $options['background'] ?>;
  32. border-bottom: 15px solid <?php echo $options['background'] ?>;
  33. border-left: 25px solid <?php echo $options['background'] ?>;
  34. border-right: 25px solid <?php echo $options['background'] ?>;
  35. width: <?php echo $options['width'] ?>px;
  36. max-width: 100%;
  37. box-sizing: border-box;
  38. border-radius: 3px;
  39. -webkit-border-radius: 3px;
  40. -moz-border-radius: 3px;
  41. display: inline-block;
  42. }
  43. </style>
  44. <a href="<?php echo $options['url'] ?>" target="_blank" rel="noopener" class="cta-button"><?php echo $options['text'] ?></a>
  45. <div itemscope="" itemtype="http://schema.org/EmailMessage">
  46. <div itemprop="potentialAction" itemscope="" itemtype="http://schema.org/ViewAction">
  47. <meta itemprop="url" content="<?php echo esc_attr($options['url']) ?>" />
  48. <meta itemprop="name" content="<?php echo esc_attr($options['text']) ?>" />
  49. </div>
  50. <meta itemprop="description" content="<?php echo esc_attr($options['text']) ?>" />
  51. </div>