YaWK  24.1
Yet another WebKit
pinterest_follow.php
Go to the documentation of this file.
1 <?php
3 {
4  /**
5  * @details<b>Pinterest Follow Widget - add a follow me on pinterest button to your page.</b>
6  *
7  * <p>If you want to pay attention to your pinterest channel, embed this widget.
8  * All you need to enter is any pinterest url to follow. Like any other widget,
9  * you can add a heading and a subtext that will be displayed above this widget.</p>
10  *
11  *
12  * @author Daniel Retzl <[email protected]>
13  * @copyright 2018 Daniel Retzl
14  * @version 1.0.0
15  * @brief Pinterest Follow Widget
16  */
17  class pinterestFollow 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 $pinterestFollowHeading = '';
23  /** @param string Subtext will be displayed beside title */
24  public $pinterestFollowSubtext = '';
25  /** @param string The URL of your pinterest channel */
26  public $pinterestFollowUrl = '';
27 
28  /**
29  * @brief Load all widget settings from database and fill object
30  * @param object $db Database Object
31  * @brief Load all widget settings on object init.
32  */
33  public function __construct($db)
34  {
35  // load this widget settings from db
36  $this->widget = new \YAWK\widget();
38  foreach ($settings as $property => $value) {
39  $this->$property = $value;
40  }
41  }
42 
43  /**
44  * @brief Init example widget and call a function for demo purpose
45  * @brief Example Widget Init
46  */
47  public function init()
48  { // draw headline on screen
49  echo $this->getHeading($this->pinterestFollowHeading, $this->pinterestFollowSubtext);
50  $this->embedPinterestFollow();
51  }
52 
53  /**
54  * @brief Embed Pinterest Follow Button
55  * @brief Embed Pinterest Follow Button
56  */
57  public function embedPinterestFollow()
58  { // check if url is set
59  if (isset($this->pinterestFollowUrl)
60  && (!empty($this->pinterestFollowUrl)
61  && (is_string($this->pinterestFollowUrl))))
62  { // embed pinterest follow button markup
63  echo '
64  <a data-pin-do="buttonFollow" href="'.$this->pinterestFollowUrl.'">Pinterest</a>
65  <script async defer src="//assets.pinterest.com/js/pinit.js"></script>';
66  }
67  else
68  {
69  echo "Here should be a pinterest follow button, but no URL is set. Please add your pinterest url.";
70  }
71  }
72 
73  }
74 }
75 ?>
init()
Init example widget and call a function for demo purpose.
__construct($db)
Load all widget settings from database and fill object.
embedPinterestFollow()
Embed Pinterest Follow Button.
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