PageRenderTime 40ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/nonus/theme/shortcodes/boxes/ctPersonBoxShortcode.class.php

https://github.com/alniko009/magic
PHP | 143 lines | 103 code | 13 blank | 27 comment | 16 complexity | c1e2cdcdd1812c6afe4ea33576db25ca MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Person Box shortcode
  4. */
  5. class ctPersonBoxShortcode extends ctShortcode {
  6. /**
  7. * Returns name
  8. * @return string|void
  9. */
  10. public function getName() {
  11. return 'Person box';
  12. }
  13. /**
  14. * Shortcode name
  15. * @return string
  16. */
  17. public function getShortcodeName() {
  18. return 'person_box';
  19. }
  20. /**
  21. * Shortcode type
  22. * @return string
  23. */
  24. public function getShortcodeType() {
  25. return self::TYPE_SHORTCODE_ENCLOSING;
  26. }
  27. /**
  28. * Handles shortcode
  29. * @param $atts
  30. * @param null $content
  31. * @return string
  32. */
  33. public function handle($atts, $content = null) {
  34. extract(shortcode_atts($this->extractShortcodeAttributes($atts), $atts));
  35. $preLink = '';
  36. $postLink = '';
  37. $br = '';
  38. if ($link) {
  39. $preLink = '<a href="' . $link . '">';
  40. $postLink = '</a>';
  41. }
  42. $linksHtml = '';
  43. if ($prezi) {
  44. $linksHtml .= '<a href="http://prezi.com/' . $prezi . '" target="_blank" data-toggle="tooltip" title="Prezi">' . $prezilabel . '</a>';
  45. }
  46. if ($fb) {
  47. $linksHtml .= '<a href="http://www.facebook.com/' . $fb . '" target="_blank" data-toggle="tooltip" title="Facebook">Facebook</a>';
  48. }
  49. if ($twit) {
  50. $linksHtml .= '<a href="http://www.twitter.com/' . $twit . '" target="_blank" data-toggle="tooltip" title="Twitter">Twitter</a>';
  51. }
  52. if ($google) {
  53. $linksHtml .= '<a href="http://plus.google.com/' . $google . '" target="_blank" data-toggle="tooltip" title="Google+">Google+</a>';
  54. }
  55. if ($linkedin) {
  56. $linksHtml .= '<a href="http://www.linkedin.com/' . $linkedin . '" target="_blank" data-toggle="tooltip" title="LinkedIn">LinkedIn</a>';
  57. }
  58. if ($pinterest) {
  59. $linksHtml .= '<a href="http://www.pinterest.com/' . $pinterest . '" target="_blank" data-toggle="tooltip" title="Pinterest">Pinterest</a>';
  60. }
  61. if ($dribbble) {
  62. $linksHtml .= '<a href="http://dribbble.com/' . $dribbble . '" target="_blank" data-toggle="tooltip" title="Dribbble">Dribbble</a>';
  63. }
  64. if ($flickr) {
  65. $linksHtml .= '<a href="http://www.flickr.com/photos/' . $flickr . '" target="_blank" data-toggle="tooltip" title="Flickr">Flickr</a>';
  66. }
  67. if ($tumblr) {
  68. $linksHtml .= '<a href="http://' . $tumblr . '.tumblr.com" target="_blank" data-toggle="tooltip" title="Tumblr">Tumblr</a>';
  69. }
  70. if ($instagram) {
  71. $linksHtml .= '<a href="http://instagram.com/' . $instagram . '" target="_blank" data-toggle="tooltip" title="Instagram">Instagram</a>';
  72. }
  73. if ($youtube) {
  74. $linksHtml .= '<a href="http://www.youtube.com/' . $youtube . '" target="_blank" data-toggle="tooltip" title="Youtube">Youtube</a>';
  75. }
  76. if ($vimeo) {
  77. $linksHtml .= '<a href="http://vimeo.com/' . $vimeo . '" target="_blank" data-toggle="tooltip" title="Vimeo">Vimeo</a>';
  78. }
  79. if ($phone) {
  80. $linksHtml .= '<a href="callto://+' . $phone . '" target="_blank" data-toggle="tooltip" title="'.$phonelabel.'">'.$phonelabel.'</a>';
  81. }
  82. if ($skype) {
  83. $linksHtml .= '<a href="skype:' . $skype . '?call" target="_blank" data-toggle="tooltip" title="Skype">Skype</a>';
  84. }
  85. if ($email) {
  86. $linksHtml .= '<a href="mailto:' . $email . '" target="_blank" data-toggle="tooltip" title="'.$emaillabel.'">'.$emaillabel.'</a>';
  87. }
  88. //if($link && $linksHtml != ""){
  89. $br = "<br />";
  90. //}
  91. return do_shortcode('<div class="person-box">
  92. ' . $preLink . '<img src="' . $imgsrc . '" alt="">' . $postLink . '
  93. <h4>' . $header . '</h4>
  94. <h5>' . $subheader . '</h5>
  95. ' . $preLink . $emaillabel . $postLink . $br . $linksHtml . '
  96. </div>');
  97. }
  98. /**
  99. * Returns config
  100. * @return null
  101. */
  102. public function getAttributes() {
  103. return array(
  104. 'imgsrc' => array('label' => __("source", 'ct_theme'), 'default' => '', 'type' => 'image', 'help' => __("Image", 'ct_theme')),
  105. 'header' => array('label' => __('header', 'ct_theme'), 'default' => '', 'type' => 'input', 'help' => __("Header text", 'ct_theme')),
  106. 'subheader' => array('label' => __('subheader', 'ct_theme'), 'default' => '', 'type' => 'input', 'help' => __("Subheader text", 'ct_theme')),
  107. 'link' => array('label' => __('link', 'ct_theme'), 'default' => '', 'type' => 'input', 'help' => __("Link", 'ct_theme')),
  108. 'content' => array('label' => __('content', 'ct_theme'), 'default' => '', 'type' => "textarea"),
  109. 'fb' => array('label' => __("Facebook username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  110. 'twit' => array('label' => __("Twitter username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  111. 'dribbble' => array('label' => __("Dribbble username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  112. 'google' => array('label' => __("Google+ username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  113. 'linkedin' => array('label' => __("LinkedIn username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  114. 'pinterest' => array('label' => __("Pinterest username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  115. 'flickr' => array('label' => __("Flickr username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  116. 'tumblr' => array('label' => __("Tumblr username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  117. 'instagram' => array('label' => __("Instagram username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  118. 'youtube' => array('label' => __("Youtube movie", 'ct_theme'), 'default' => '', 'type' => 'input'),
  119. 'vimeo' => array('label' => __("Vimeo movie", 'ct_theme'), 'default' => '', 'type' => 'input'),
  120. 'phone' => array('label' => __("Phone number to call by Skype", 'ct_theme'), 'default' => '', 'type' => 'input'),
  121. 'phonelabel' => array('label' => __("Phone tooltip label", 'ct_theme'), 'default' => __("Phone",'ct_theme'), 'type' => 'input'),
  122. 'skype' => array('label' => __("Skype user", 'ct_theme'), 'default' => '', 'type' => 'input'),
  123. 'email' => array('label' => __("Email address", 'ct_theme'), 'default' => '', 'type' => 'input'),
  124. 'emaillabel' => array('label' => __("Email tooltip label", 'ct_theme'), 'default' => __("Email",'ct_theme'), 'type' => 'input'),
  125. 'prezi' => array('label' => __("Prezi link", 'ct_theme'), 'default' => '', 'type' => 'input'),
  126. 'prezilabel' => array('label' => __("Prezi tooltip label", 'ct_theme'), 'default' => __("Prezi",'ct_theme'), 'type' => 'input'),
  127. );
  128. }
  129. }
  130. new ctPersonBoxShortcode();