YaWK  24.1
Yet another WebKit
pinterest_profile.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 pinterestProfile 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 $pinterestProfileHeading = '';
23  /** @param string Subtext will be displayed beside title */
24  public $pinterestProfileSubtext = '';
25  /** @param string The URL of your pinterest channel */
26  public $pinterestProfileUrl="https://www.pinterest.com/pin/99360735500167749/";
27  /** @param int Profile Width in pixels */
28  public $pinterestProfileWidth = 900;
29  /** @param int Profile Heightin pixels */
30  public $pinterestProfileHeight = 500;
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 profile widget and call embed method
49  * @brief Embed any public Pinterest Profile
50  */
51  public function init()
52  { // draw headline on screen
53  echo $this->getHeading($this->pinterestProfileHeading, $this->pinterestProfileSubtext);
54  $this->embedPinterestProfile();
55  }
56 
57  /**
58  * @brief Embed Pinterest Profile
59  * @brief Embed Pinterest Profile
60  */
61  public function embedPinterestProfile()
62  { // check if url is set
63  if (isset($this->pinterestProfileUrl)
64  && (!empty($this->pinterestProfileUrl)
65  && (is_string($this->pinterestProfileUrl))))
66  { // embed pinterest follow button markup
67  echo '
68  <a data-pin-do="embedUser" data-pin-board-width="'.$this->pinterestProfileWidth.'" data-pin-scale-height="'.$this->pinterestProfileHeight.'" data-pin-scale-width="115" href="'.$this->pinterestProfileUrl.'"></a>
69  <script async defer src="//assets.pinterest.com/js/pinit.js"></script>';
70  }
71  else
72  {
73  echo "Here should be a pinterest profile, but no URL is set. Please enter your pinterest profile URL.";
74  }
75  }
76 
77  }
78 }
79 ?>
__construct($db)
Load all widget settings from database and fill object.
init()
Init pinterest profile 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