YaWK  24.1
Yet another WebKit
pinterest_pin.php
Go to the documentation of this file.
1 <?php
3 {
4  /**
5  * @details<b>Pinterest Pin - embed a single pin on your page</b>
6  *
7  * <p>Use this widget to embed any single pin on your page. To get this widget to work,
8  * enter any public pin url. Description can be shown or hidden, the size of your pin can
9  * be changed and heading and subtext could be added as well. </p>
10  *
11  *
12  * @author Daniel Retzl <[email protected]>
13  * @copyright 2018 Daniel Retzl
14  * @version 1.0.0
15  * @brief Pinterest Pin Widget
16  */
17  class pinterestPin extends \YAWK\widget
18  {
19  /** @param object global widget object data */
20  public $widget = '';
21  /** @param string Title that will be shown above widget */
22  public $pinterestPinHeading = '';
23  /** @param string Subtext will be displayed beside title */
24  public $pinterestPinSubtext = '';
25  /** @param string The URL of your pinterest channel */
26  public $pinterestPinUrl="https://www.pinterest.com/pin/99360735500167749/";
27  /** @param string The URL of your pinterest channel */
28  public $pinterestPinSize="large";
29  /** @param string The URL of your pinterest channel */
30  public $pinterestPinHideDescription = 'data-pin-terse="true"';
31 
32  /**
33  * @brief Load all widget settings from database and fill object
34  * @param object $db Database Object
35  * @brief Load all widget settings on object init.
36  */
37  public function __construct($db)
38  {
39  // load this widget settings from db
40  $this->widget = new \YAWK\widget();
42  foreach ($settings as $property => $value) {
43  $this->$property = $value;
44  }
45  }
46 
47  /**
48  * @brief Init pinterest pin widget and call embed method
49  * @brief Embed any public Pinterest Pin
50  */
51  public function init()
52  { // draw headline on screen
53  echo $this->getHeading($this->pinterestPinHeading, $this->pinterestPinSubtext);
54  $this->embedPinterestPin();
55  }
56 
57  /**
58  * @brief Embed Pinterest Pin
59  * @brief Embed Pinterest Pin
60  */
61  public function embedPinterestPin()
62  { // check if url is set
63  if (isset($this->pinterestPinUrl)
64  && (!empty($this->pinterestPinUrl)
65  && (is_string($this->pinterestPinUrl))))
66  { // embed pinterest follow button markup
67  echo '
68  <a data-pin-do="embedPin" data-pin-width="'.$this->pinterestPinSize.'" data-pin-terse="'.$this->pinterestPinHideDescription.'" href="'.$this->pinterestPinUrl.'"></a>
69  <script async defer src="//assets.pinterest.com/js/pinit.js"></script>';
70  }
71  else
72  {
73  echo "Here should be a pinterest pin, but no URL is set. Please enter your pinterest pin URL.";
74  }
75  }
76 
77  }
78 }
79 ?>
__construct($db)
Load all widget settings from database and fill object.
init()
Init pinterest pin widget and call embed method.
Widgets are small, useful tools that you can include everywhere in your website.
Definition: widget.php:22
getWidgetSettingsArray($db)
Get widget settings and return it as array.
Definition: widget.php:69
getHeading($heading, $subtext)
Get widget heading and subtext, return headline.
Definition: widget.php:669
if(isset($_POST['save'])) $settings
$value