YaWK  24.1
Yet another WebKit
fb_like_button.php
Go to the documentation of this file.
1 <?php
3 {
4  /**
5  * @details<b>Facebook Like Button - embed a like button on your page</b>
6  *
7  * <p>If you want to bring attention to your facebook page, you might want to add
8  * a 'like me on facebook' button to your page. With this widget, you can do that
9  * very easily. You can configure some settings, like width, height, layout, color
10  * scheme and much more.</p>
11  *
12  *
13  * @author Daniel Retzl <[email protected]>
14  * @copyright 2018 Daniel Retzl
15  * @version 1.0.0
16  * @brief Facebook Like Button - embed a like button on your page
17  */
18  class fbLikeButton extends \YAWK\widget
19  {
20  /** @param object global widget object data */
21  public $widget = '';
22  public $fbLikeButtonWidth = "450";
23  public $fbLikeButtonHeight = "35";
24  public $fbLikeButtonUrl = "http%3A%2F%2Fwww.facebook.com%2Fplatform";
25  public $fbLikeButtonAppID = ""; // "100710516666226";
26  public $fbLikeButtonColorscheme = "light";
27  public $fbLikeButtonLayout = "standard";
28  public $fbLikeButtonAction = "like";
29  public $fbLikeButtonSize = "small";
30  public $fbLikeButtonShowFaces = "false";
31  public $fbLikeButtonShare = "false";
32 
33  /**
34  * @brief Load all widget settings from database and fill object
35  * @param object $db Database Object
36  * @brief Load all widget settings on object init.
37  */
38  public function __construct($db)
39  {
40  // load this widget settings from db
41  $this->widget = new \YAWK\widget();
43  foreach ($settings as $property => $value) {
44  $this->$property = $value;
45  }
46  }
47 
48  /**
49  * @brief Init facebook like button
50  * @brief Facebook Like Button
51  */
52  public function init()
53  { // embed like Button
54  $this->embedLikeButton();
55  }
56 
57  public function embedLikeButton()
58  { // check if url is set
59  if (isset($this->fbLikeButtonUrl) && (!empty($this->fbLikeButtonUrl)))
60  { // encode url string
61  $this->fbLikeButtonUrl = rawurlencode($this->fbLikeButtonUrl);
62  }
63  // embed facebook like button
64  // REMEMBER: this could be blocked by AdBlock Browser Plugins
65  echo '<iframe src="https://www.facebook.com/plugins/like.php?href='.$this->fbLikeButtonUrl.'&width='.$this->fbLikeButtonWidth.'&layout='.$this->fbLikeButtonLayout.'&action='.$this->fbLikeButtonAction.'&size='.$this->fbLikeButtonSize.'&show_faces='.$this->fbLikeButtonShowFaces.'&share='.$this->fbLikeButtonShare.'&height='.$this->fbLikeButtonHeight.'&appId='.$this->fbLikeButtonAppID.'" width="'.$this->fbLikeButtonWidth.'" height="'.$this->fbLikeButtonHeight.'" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>';
66  }
67  }
68 }
69 ?>
Facebook Like Button - embed a like button on your page.
__construct($db)
Load all widget settings from database and fill object.
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
if(isset($_POST['save'])) $settings
$value