本文整理汇总了PHP中wp_get_shortlink函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_shortlink函数的具体用法?PHP wp_get_shortlink怎么用?PHP wp_get_shortlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_shortlink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: esc_url
<i class="icon-twitter-square"></i>
</a>
<a class="social-google" href="https://plus.google.com/share?url=<?php
echo esc_url(wp_get_shortlink());
?>
" target="_blank">
<i class="icon-google-plus-square"></i>
</a>
<a class="social-email" href="mailto:?subject=I wanted to share this post with you from <?php
echo esc_url(bloginfo('name'));
?>
&body=<?php
the_title('', '', true);
?>
  <?php
echo esc_url(wp_get_shortlink());
?>
" title="Email to a friend">
<i class="icon-envelope"></i>
</a>
</div>
<!-- /social share -->
<!-- author bio -->
<hr>
<div id="author-bio">
<a href="<?php
the_author_meta('user_url');
?>
">
<?php
示例2: bctt_shortcode
function bctt_shortcode($atts)
{
extract(shortcode_atts(array('tweet' => '', 'via' => 'yes', 'url' => 'yes'), $atts));
$handle = get_option('bctt-twitter-handle');
if (!empty($handle) && $via != 'no') {
$handle_code = "&via=" . $handle . "&related=" . $handle;
} else {
$handle_code = '';
}
$text = $tweet;
if ($url != 'no') {
if (get_option('bctt-short-url') != false) {
$bcttURL = '&url=' . wp_get_shortlink();
} else {
$bcttURL = '&url=' . get_permalink();
}
} else {
$bcttURL = '';
}
$bcttBttn = sprintf(__('Click To Tweet', 'better-click-to-tweet'));
$short = bctt_shorten($text, 117 - (6 + mb_strlen($handle)));
if (!is_feed()) {
return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank'>" . $short . "</a></span><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . "&url=" . $bcttURL . "' target='_blank' class='bctt-ctt-btn'>" . $bcttBttn . "</a></div>";
} else {
return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'>" . $bcttBttn . "</a><br /><hr />";
}
}
示例3: get_stc_tweetbutton
/**
* Simple tweet button
*/
function get_stc_tweetbutton($args = '')
{
global $stc_tweetbutton_defaults;
$args = wp_parse_args($args, $stc_tweetbutton_defaults);
extract($args);
// fix for missing ID in some cases (some shortlink plugins don't work well with ID = zero)
if (!$id) {
$id = get_the_ID();
}
$options = get_option('stc_options');
if ($options['tweetbutton_source']) {
$source = $options['tweetbutton_source'];
}
if ($options['tweetbutton_style']) {
$style = $options['tweetbutton_style'];
}
if ($options['tweetbutton_related']) {
$related = $options['tweetbutton_related'];
}
$url = wp_get_shortlink($id);
$counturl = get_permalink($id);
$post = get_post($id);
$text = esc_attr(strip_tags($post->post_title));
if (!empty($related)) {
$datarelated = " data-related='{$related}'";
}
$query = http_build_query(array('url' => $url, 'count' => $style, 'related' => $related));
$query .= '&text=' . rawurlencode($text);
$out = "<a href='http://twitter.com/share?{$query}' class='twitter-share-button' data-text='{$text}' data-url='{$url}' data-counturl='{$counturl}' data-count='{$style}' data-via='{$source}'{$datarelated}>Tweet</a>";
return $out;
}
示例4: wps_post_suggestion
function wps_post_suggestion($content)
{
if (is_single()) {
global $sms;
require_once dirname(__FILE__) . "/../templates/wp-sms-post-suggestion.php";
if ($_POST['send_post']) {
$mobile = $_POST['get_fmobile'];
if ($_POST['get_name'] && $_POST['get_fname'] && $_POST['get_fmobile']) {
if (preg_match("([a-zA-Z])", $mobile) == 0) {
$sms->to = array($_POST['get_fmobile']);
$template_vars = array('post_title' => get_the_title(), 'sms_sender' => $_POST['get_name'], 'sms_receiver' => $_POST['get_fname'], 'post_shortlink' => wp_get_shortlink());
$string = get_option('wpsms_suggestion_tt');
$final_message = preg_replace('/%(.*?)%/ime', "\$template_vars['\$1']", $string);
$sms->msg = $final_message;
if ($sms->SendSMS()) {
_e('SMS was sent with success', 'wp-sms');
}
} else {
_e('Please enter a valid mobile number', 'wp-sms');
}
} else {
_e('Please complete all fields', 'wp-sms');
}
}
}
return $content;
}
示例5: googl_custom_columns
function googl_custom_columns( $column ) {
if ( 'shortlink' == $column ) {
$shorturl = wp_get_shortlink();
$shorturl_caption = str_replace( 'http://', '', $shorturl );
$shorturl_info = str_replace( 'goo.gl/', 'goo.gl/info/', $shorturl );
printf( '<a href="%s">%s</a> (<a href="%s">info</a>)', esc_url( $shorturl ), esc_html( $shorturl_caption ), esc_url( $shorturl_info ) );
}
}
示例6: wpbitly_add_metaboxes
/**
* Callback for add_meta_boxes-{posttype}
*/
function wpbitly_add_metaboxes($post)
{
global $post;
$shortlink = wp_get_shortlink();
if (empty($shortlink)) {
return;
}
add_meta_box('wpbitly-meta', 'WP Bit.ly', 'wpbitly_build_metabox', $post->post_type, 'side', 'default', array($shortlink));
}
示例7: test_wp_get_shortlink_with_home_page
/**
* @ticket 26871
*/
function test_wp_get_shortlink_with_home_page()
{
$post_id = self::factory()->post->create(array('post_type' => 'page'));
update_option('show_on_front', 'page');
update_option('page_on_front', $post_id);
$this->assertEquals(home_url('/'), wp_get_shortlink($post_id, 'post'));
$this->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
$this->assertEquals(home_url('/'), wp_get_shortlink($post_id, 'post'));
}
示例8: ativista_share_twitter
function ativista_share_twitter($atts, $content = null)
{
$a = shortcode_atts(array('text' => ''), $atts);
if (!empty($atts['text'])) {
$twitter_text = $atts['text'] . ' ' . wp_get_shortlink();
} else {
$twitter_text = wp_get_shortlink();
}
return '<a href="https://twitter.com/intent/tweet?text=' . $twitter_text . ' " class="content-button content-button-twitter icon-twitter" target="_blank">' . do_shortcode($content) . '</a>';
}
示例9: get_rows_social_preview
public function get_rows_social_preview(&$form, &$head_info)
{
$rows = array();
$prev_width = 600;
$prev_height = 315;
$div_style = 'width:' . $prev_width . 'px; height:' . $prev_height . 'px;';
$have_sizes = !empty($head_info['og:image:width']) && $head_info['og:image:width'] > 0 && !empty($head_info['og:image:height']) && $head_info['og:image:height'] > 0 ? true : false;
$is_sufficient = $have_sizes === true && $head_info['og:image:width'] >= $prev_width && $head_info['og:image:height'] >= $prev_height ? true : false;
foreach (array('og:image:secure_url', 'og:image') as $img_url) {
if (!empty($head_info[$img_url])) {
if ($have_sizes === true) {
$image_preview_html = '<div class="preview_img" style="' . $div_style . '
background-size:' . ($is_sufficient === true ? 'cover' : $head_info['og:image:width'] . ' ' . $head_info['og:image:height']) . ';
background-image:url(' . $head_info[$img_url] . ');" />' . ($is_sufficient === true ? '' : '<p>' . sprintf(_x('Image Dimensions Smaller<br/>than Suggested Minimum<br/>of %s', 'preview image error', 'nextgen-facebook'), $prev_width . 'x' . $prev_height . 'px') . '</p>') . '</div>';
} else {
$image_preview_html = '<div class="preview_img" style="' . $div_style . '
background-image:url(' . $head_info[$img_url] . ');" /><p>' . _x('Image Dimensions Unknown<br/>or Not Available', 'preview image error', 'nextgen-facebook') . '</p></div>';
}
break;
// stop after first image
}
}
if (empty($image_preview_html)) {
$image_preview_html = '<div class="preview_img" style="' . $div_style . '"><p>' . _x('No Open Graph Image Found', 'preview image error', 'nextgen-facebook') . '</p></div>';
}
$long_url = $this->p->util->get_sharing_url($head_info['post_id']);
$short_url = apply_filters($this->p->cf['lca'] . '_shorten_url', $long_url, $this->p->options['plugin_shortener']);
if ($long_url === $short_url && SucomUtil::is_post_page()) {
$short_url = wp_get_shortlink();
}
$rows[] = $this->p->util->get_th(_x('Sharing URL', 'option label', 'nextgen-facebook'), 'medium') . '<td>' . $form->get_copy_input($long_url) . '</td>';
$rows[] = $this->p->util->get_th(_x('Short URL', 'option label', 'nextgen-facebook'), 'medium') . '<td>' . $form->get_copy_input($short_url) . '</td>';
$rows[] = $this->p->util->get_th(_x('Open Graph Example', 'option label', 'nextgen-facebook'), 'medium') . '<td rowspan="2" style="background-color:#e9eaed;border:1px dotted #e0e0e0;">
<div class="preview_box" style="width:' . ($prev_width + 40) . 'px;">
<div class="preview_box" style="width:' . $prev_width . 'px;">
' . $image_preview_html . '
<div class="preview_txt">
<div class="preview_title">' . (empty($head_info['og:title']) ? 'No Title' : $head_info['og:title']) . '</div>
<div class="preview_desc">' . (empty($head_info['og:description']) ? 'No Description' : $head_info['og:description']) . '</div>
<div class="preview_by">' . ($_SERVER['SERVER_NAME'] . (empty($head_info['author']) ? '' : ' | By ' . $head_info['author'])) . '</div>
</div>
</div>
</div></td>';
$rows[] = '<th class="medium textinfo">' . $this->p->msgs->get('info-meta-social-preview') . '</th>';
return $rows;
}
示例10: wp_sms_subscribe_send
function wp_sms_subscribe_send($wp_sms_new_status = NULL, $wp_sms_old_status = NULL, $post = NULL)
{
if ($_REQUEST['wps_send_subscribe'] == 'yes') {
if ('publish' == $wp_sms_new_status && 'publish' != $wp_sms_old_status) {
global $wpdb, $table_prefix, $sms, $wps_options;
if ($_REQUEST['wps_subscribe_group'] == 'all') {
$sms->to = $wpdb->get_col("SELECT mobile FROM {$table_prefix}sms_subscribes");
} else {
$sms->to = $wpdb->get_col("SELECT mobile FROM {$table_prefix}sms_subscribes WHERE group_ID = '{$_REQUEST['wps_subscribe_group']}'");
}
$template_vars = array('title_post' => get_the_title($post->ID), 'url_post' => wp_get_shortlink($post->ID), 'date_post' => get_post_time('Y-m-d', true, $post->ID, true));
$sms->msg = preg_replace('/%(.*?)%/ime', "\$template_vars['\$1']", $_REQUEST['wps_custom_text']);
$sms->SendSMS();
}
}
return $post;
}
示例11: add_copyright_text
function add_copyright_text()
{
if (is_single()) {
?>
<script type='text/javascript'>
function addLink() {
if (
window.getSelection().containsNode(
document.getElementsByClassName('entry-content')[0], true)) {
var body_element = document.getElementsByTagName('body')[0];
var selection;
selection = window.getSelection();
var oldselection = selection
var pagelink = "<br /><br /> Read more at WPBeginner: <?php
the_title();
?>
<a href='<?php
echo wp_get_shortlink(get_the_ID());
?>
'><?php
echo wp_get_shortlink(get_the_ID());
?>
</a>"; //Change this if you like
var copy_text = selection + pagelink;
var new_div = document.createElement('div');
new_div.style.left='-99999px';
new_div.style.position='absolute';
body_element.appendChild(new_div );
new_div.innerHTML = copy_text ;
selection.selectAllChildren(new_div );
window.setTimeout(function() {
body_element.removeChild(new_div );
},0);
}
}
document.oncopy = addLink;
</script>
<?php
}
}
示例12: wp_sms_subscribe_send
function wp_sms_subscribe_send($wp_sms_new_status = NULL, $wp_sms_old_status = NULL, $post_ID = NULL)
{
if ($_REQUEST['subscribe_post'] == 'yes') {
if ('publish' == $wp_sms_new_status && 'publish' != $wp_sms_old_status) {
global $wpdb, $table_prefix, $sms;
$sms->to = $wpdb->get_col("SELECT mobile FROM {$table_prefix}sms_subscribes");
$string = get_option('wp_sms_text_template');
$template_vars = array('title_post' => get_the_title($post_ID), 'url_post' => wp_get_shortlink($post_ID), 'date_post' => get_post_time(get_option('date_format'), true, $post_ID));
$final_message = preg_replace('/%(.*?)%/ime', "\$template_vars['\$1']", $string);
if (get_option('wp_sms_text_template')) {
$sms->msg = $final_message;
} else {
$sms->msg = get_the_title($post_ID);
}
$sms->SendSMS();
}
}
return $post_ID;
}
示例13: shortcodeCompartir
/**
* Muestra botones para compartir una página.
* @param array $atts Redes sociales el
* @return [type] [description]
*/
function shortcodeCompartir($atts = array())
{
$args = shortcode_atts(array('mostrar' => 'facebook,twitter,googleplus,whatsapp'), $atts);
$redesMostradas = explode(',', $args['mostrar']);
$retorno = array();
// Clase del tag, url, nombre, contenido del tag
$formato = '<a class="%s" href="%s" onclick="return !window.open(this.href, \'%s\', \'width=640,height=580\')">%s</a>';
// Se los pasa por un loop para poder elegir el orden desde el shortcode.
$permalink = get_the_permalink();
$shortlink = wp_get_shortlink();
foreach ($redesMostradas as $item) {
if ($item == 'facebook') {
$nombre = 'Facebook';
$contenido = retornarSVG('facebook');
$query = http_build_query(array('u' => $permalink, 'display' => 'popup', 'ref' => 'plugin', 'src' => 'share_button'));
$url = 'https://www.facebook.com/sharer/sharer.php?' . $query;
$retorno[] = sprintf($formato, 'compartir ' . $item, $url, $nombre, $contenido);
}
if ($item == 'twitter') {
$nombre = 'Twitter';
$contenido = retornarSVG('twitter');
$query = http_build_query(array('status' => $shortlink));
$url = 'https://twitter.com/home?' . $query;
$retorno[] = sprintf($formato, 'compartir ' . $item, $url, $nombre, $contenido);
}
if ($item == 'googleplus') {
$nombre = 'Google Plus';
$contenido = retornarSVG('google-plus');
$query = http_build_query(array('url' => get_the_permalink()));
$url = 'https://plus.google.com/share?';
$retorno[] = sprintf($formato, 'compartir ' . $item, $url . $query, $nombre, $contenido);
}
if ($item == 'whatsapp') {
$nombre = 'WhatsApp';
$contenido = retornarSVG('whatsapp');
$query = http_build_query(array('text' => get_the_permalink()));
$url = 'whatsapp://send?' . $query;
$retorno[] = sprintf('<a class="%s" href="%s" rel="nofollow">%s</a>', 'compartir ' . $item, $url, $contenido);
}
}
return implode('', $retorno);
}
示例14: get_QR_code
function get_QR_code($atts, $content = null)
{
extract(shortcode_atts(array('size' => '150x150', 'ImgTag' => 'yes', 'link' => 'no'), $atts));
if ($size == null) {
$size = '150x150';
}
if ($content == null) {
$content = wp_get_shortlink();
}
$content = urlencode($content);
if ($ImgTag == 'yes') {
if ($link == 'yes') {
return '<a href="' . urldecode($content) . '"><img src="http://chart.apis.google.com/chart?cht=qr&chs=' . $size . '&choe=UTF-8&chld=H&chl=' . $content . '"></a>';
} else {
return '<img src="http://chart.apis.google.com/chart?cht=qr&chs=' . $size . '&choe=UTF-8&chld=H&chl=' . $content . '">';
}
} else {
return 'http://chart.apis.google.com/chart?cht=qr&chs=' . $size . '&choe=UTF-8&chld=H&chl=' . $content;
}
}
示例15: jawsdays_publicize_save_meta
function jawsdays_publicize_save_meta($submit_post, $post_id, $service_name, $connection)
{
$suffix = " #jawsdays #jawsug";
$title = get_the_title($post_id);
$link = wp_get_shortlink($post_id);
$publicize_custom_message = get_post_meta($post_id, '_wpas_mess', true);
if (empty($publicize_custom_message)) {
$publicize_custom_message = sprintf("%s %s %s", $title, $link, $suffix);
} else {
if (strpos($publicize_custom_message, $title) === false) {
$publicize_custom_message = $publicize_custom_message . $title;
}
if (strpos($publicize_custom_message, $link) === false) {
$publicize_custom_message = $publicize_custom_message . $link;
}
if (strpos($publicize_custom_message, $suffix) === false) {
$publicize_custom_message = $publicize_custom_message . $suffix;
}
}
update_post_meta($post_id, '_wpas_mess', $publicize_custom_message);
}