function hocwp_twitter_follow_button($args = array()) { $username = hocwp_get_value_by_key($args, 'username'); if (empty($username)) { $username = hocwp_get_value_by_key($args, 'account'); } $permalink = hocwp_get_value_by_key($args, 'permalink'); if (empty($permalink)) { $permalink = $username; } if (!empty($permalink) && !hocwp_is_url($permalink)) { $permalink = 'https://twitter.com/' . $permalink; } if (empty($permalink)) { $permalink = hocwp_get_option_by_name('hocwp_option_social', 'twitter_site'); } if (empty($permalink)) { return; } $show_screen_name = hocwp_get_value_by_key($args, 'show_screen_name'); $show_count = hocwp_get_value_by_key($args, 'show_count'); $show_count = hocwp_bool_to_string($show_count); if (empty($username)) { $username = hocwp_get_last_part_in_url($permalink); } if (!empty($username)) { $first_char = hocwp_get_first_char($username); if ('@' != $first_char) { $username = '******' . $username; } } $text = __('Follow', 'hocwp-theme'); if ($show_screen_name) { $username = $text . ' ' . $username; } else { $username = $text; } $username = trim($username); $size = hocwp_get_value_by_key($args, 'size'); $show_screen_name = hocwp_bool_to_string($show_screen_name); ?> <a data-show-screen-name="<?php echo $show_screen_name; ?> " data-size="<?php echo $size; ?> " href="<?php echo esc_url($permalink); ?> " class="twitter-follow-button" data-show-count="<?php echo $show_count; ?> "><?php echo $username; ?> </a> <script type="text/javascript"> window.twttr = (function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], t = window.twttr || {}; if (d.getElementById(id)) return t; js = d.createElement(s); js.id = id; js.src = "https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); t._e = []; t.ready = function (f) { t._e.push(f); }; return t; }(document, "script", "twitter-wjs")); </script> <?php }
function hocwp_detect_video_id($url) { $result = ''; if (is_array($url)) { $url = array_shift($url); } $server = hocwp_detect_video_server_name($url); $data = parse_url($url); $query = isset($data['query']) ? $data['query'] : ''; parse_str($query, $output); switch ($server) { case 'youtube': $result = isset($output['v']) ? $output['v'] : ''; if (empty($result)) { $result = hocwp_get_last_part_in_url($url); } break; case 'vimeo': $result = intval(hocwp_get_last_part_in_url($url)); break; case 'dailymotion': $result = hocwp_get_last_part_in_url($url); break; } return $result; }