PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/nonus/theme/shortcodes/contact/ctSocialsShortcode.class.php

https://github.com/alniko009/magic
PHP | 118 lines | 88 code | 9 blank | 21 comment | 16 complexity | 6b504b7f047223797ada52e76619fe56 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Socials shortcode
  4. */
  5. class ctSocialsShortcode extends ctShortcode {
  6. /**
  7. * Returns name
  8. * @return string|void
  9. */
  10. public function getName() {
  11. return 'Socials';
  12. }
  13. /**
  14. * Shortcode name
  15. * @return string
  16. */
  17. public function getShortcodeName() {
  18. return 'socials';
  19. }
  20. /**
  21. * Handles shortcode
  22. * @param $atts
  23. * @param null $content
  24. * @return string
  25. */
  26. public function handle($atts, $content = null) {
  27. extract(shortcode_atts($this->extractShortcodeAttributes($atts), $atts));
  28. $headerHtml = $header ? '<h4>' . $header . '</h4>' : '';
  29. $linksHtml = '';
  30. if ($fb) {
  31. $linksHtml .= '<a href="http://www.facebook.com/' . $fb . '" target="_blank" rel="nofollow"><i class="icon-facebook-sign"></i>Facebook</a><br>';
  32. }
  33. if ($twit) {
  34. $linksHtml .= '<a href="http://www.twitter.com/' . $twit . '" target="_blank" rel="nofollow"><i class="icon-twitter"></i>Twitter</a><br>';
  35. }
  36. if ($google) {
  37. $linksHtml .= '<a href="http://plus.google.com/' . $google . '" target="_blank" rel="nofollow"><i class="icon-google-plus-sign"></i>Google+</a><br>';
  38. }
  39. if ($linkedin) {
  40. $linksHtml .= '<a href="http://www.linkedin.com/' . $linkedin . '" target="_blank" rel="nofollow"><i class="icon-linkedin"></i>LinkedIn</a><br>';
  41. }
  42. if ($pinterest) {
  43. $linksHtml .= '<a href="http://www.pinterest.com/' . $pinterest . '" target="_blank" rel="nofollow"><i class="icon-pinterest"></i>Pinterest</a><br>';
  44. }
  45. if ($dribbble) {
  46. $linksHtml .= '<a href="http://dribbble.com/' . $dribbble . '" target="_blank" rel="nofollow"><i class="icon-dribbble"></i>Dribbble</a><br>';
  47. }
  48. if ($flickr) {
  49. $linksHtml .= '<a href="http://www.flickr.com/photos/' . $flickr . '" target="_blank" rel="nofollow"><i class="icon-flickr"></i>Flickr</a><br>';
  50. }
  51. if ($tumblr) {
  52. $linksHtml .= '<a href="http://' . $tumblr . '.tumblr.com" target="_blank" rel="nofollow"><i class="icon-tumblr"></i>Tumblr</a><br>';
  53. }
  54. if ($instagram) {
  55. $linksHtml .= '<a href="http://instagram.com/' . $instagram . '" target="_blank" rel="nofollow"><i class="icon-instagram"></i>Instagram</a><br>';
  56. }
  57. if ($youtube) {
  58. $linksHtml .= '<a href="http://www.youtube.com/' . $youtube . '" target="_blank" rel="nofollow"><i class="icon-youtube-sign"></i>Youtube</a><br>';
  59. }
  60. if ($phone) {
  61. $linksHtml .= '<a href="callto://+' . $phone . '" target="_blank" rel="nofollow"><i class="icon-phone"></i>'.$phonelabel.'</a><br>';
  62. }
  63. if ($skype) {
  64. $linksHtml .= '<a href="skype:' . $skype . '?call" target="_blank" rel="nofollow"><i class="icon-skype"></i>Skype</a><br>';
  65. }
  66. if ($website) {
  67. $linksHtml .= '<a href="' . $website . '" target="_blank" rel="nofollow"><i class="icon-external-link"></i>' . $website . '</a><br>';
  68. }
  69. if ($email) {
  70. $linksHtml .= '<a href="mailto:' . $email . '" target="_blank" rel="nofollow"><i class="icon-envelope"></i>'.$emaillabel.'</a><br>';
  71. }
  72. if ($rss == 'yes') {
  73. $linksHtml .= '<a href="' . current_page_url() . '?feed=rss2" target="_blank" rel="nofollow"><i class="icon-rss"></i>RSS</a><br>';
  74. }
  75. return $headerHtml . '<div class="social-widget widget">
  76. <p class="social">
  77. ' . $linksHtml . '
  78. </p>
  79. </div>';
  80. }
  81. /**
  82. * Returns config
  83. * @return null
  84. */
  85. public function getAttributes() {
  86. return array(
  87. 'widgetmode' => array('default' => 'false', 'type' => false),
  88. 'header' => array('label' => __("header text", 'ct_theme'), 'default' => '', 'type' => 'input'),
  89. 'fb' => array('label' => __("Facebook username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  90. 'twit' => array('label' => __("Twitter username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  91. 'dribbble' => array('label' => __("Dribbble username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  92. 'google' => array('label' => __("Google+ username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  93. 'linkedin' => array('label' => __("LinkedIn username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  94. 'pinterest' => array('label' => __("Pinterest username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  95. 'flickr' => array('label' => __("Flickr username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  96. 'tumblr' => array('label' => __("Tumblr username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  97. 'instagram' => array('label' => __("Instagram username", 'ct_theme'), 'default' => '', 'type' => 'input'),
  98. 'youtube' => array('label' => __("Youtube movie", 'ct_theme'), 'default' => '', 'type' => 'input'),
  99. 'phone' => array('label' => __("Phone number to call by Skype", 'ct_theme'), 'default' => '', 'type' => 'input'),
  100. 'phonelabel' => array('label' => __("Phone tooltip label", 'ct_theme'), 'default' => __("Phone",'ct_theme'), 'type' => 'input'),
  101. 'skype' => array('label' => __("Skype user", 'ct_theme'), 'default' => '', 'type' => 'input'),
  102. 'website' => array('label' => __("Website url - with http://", 'ct_theme'), 'default' => '', 'type' => 'input'),
  103. 'email' => array('label' => __("Email address", 'ct_theme'), 'default' => '', 'type' => 'input'),
  104. 'emaillabel' => array('label' => __("Email tooltip label", 'ct_theme'), 'default' => __("Email",'ct_theme'), 'type' => 'input'),
  105. 'rss' => array('label' => __('Rss', 'ct_theme'), 'default' => 'no', 'type' => 'select', 'options' => array('no' => __('no', 'ct_theme'), 'yes' => __('yes', 'ct_theme')), 'help' => __("Show rss feed link?", 'ct_theme')),
  106. );
  107. }
  108. }
  109. new ctSocialsShortcode();