• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_get_shortlink函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_get_shortlink函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_shortlink函数的具体用法?PHP wp_get_shortlink怎么用?PHP wp_get_shortlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_get_shortlink函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
?>
&#32;&#32;<?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 
开发者ID:shameemreza,项目名称:twentysixteenpro,代码行数:31,代码来源:post-footer.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 />";
    }
}
开发者ID:sorich87,项目名称:better-click-to-tweet,代码行数:27,代码来源:better-click-to-tweet.php


示例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;
}
开发者ID:thejimbirch,项目名称:unionrockyards,代码行数:34,代码来源:stc-tweetbutton.php


示例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;
}
开发者ID:ajaycorbus,项目名称:Plugins,代码行数:27,代码来源:wp-sms-post-suggestion.php


示例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 ) );
	}
}
开发者ID:recetasdemama,项目名称:wordpress,代码行数:8,代码来源:googl.php


示例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));
}
开发者ID:aarontgrogg,项目名称:aarontgrogg,代码行数:12,代码来源:wp-bitly-views.php


示例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'));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:12,代码来源:link.php


示例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>';
}
开发者ID:randler,项目名称:ativista,代码行数:10,代码来源:shortcodes.php


示例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;
        }
开发者ID:leotaillard,项目名称:btws2016,代码行数:46,代码来源:meta.php


示例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;
}
开发者ID:veronalabs,项目名称:wp-sms,代码行数:17,代码来源:newslleter.php


示例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 
    }
}
开发者ID:voquanghoa,项目名称:WebPhim,代码行数:43,代码来源:functions.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;
}
开发者ID:QoboLtd,项目名称:wp-sms,代码行数:19,代码来源:newslleter.php


示例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);
}
开发者ID:eliasdorigoni,项目名称:WPBase,代码行数:47,代码来源:shortcodes.php


示例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;
     }
 }
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:20,代码来源:wordpress-qr-code.php


示例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);
}
开发者ID:jaws-ug,项目名称:jawsdays2016,代码行数:21,代码来源:jetpack.php


示例16: bcom_social_links

    /**
     * Show social links on post using the permalink.
     */
    function bcom_social_links()
    {
        ?>
	<ul class="social-sharing" id="social-sharing">
	  <li class="facebook"><a href="http://www.facebook.com/share.php?u=<?php 
        echo wp_get_shortlink();
        ?>
&title=<?php 
        echo get_the_title();
        ?>
" data-title="<?php 
        echo get_the_title();
        ?>
" title="Share on Facebook">Share on Facebook</a></li>
	  <li class="twitter"><a href="http://twitter.com/home?status=<?php 
        echo get_the_title();
        ?>
+<?php 
        echo wp_get_shortlink();
        ?>
" data-title="<?php 
        echo get_the_title();
        ?>
" title="Share on Twitter">Share on Twitter</a></li>
	  <li class="linkedin"><a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php 
        echo wp_get_shortlink();
        ?>
&title=<?php 
        echo get_the_title();
        ?>
" data-title="<?php 
        echo get_the_title();
        ?>
" title="Share on LinkedIn">Share on LinkedIn</a></li>
	</ul>
	<?php 
    }
开发者ID:BComSolutions,项目名称:bcom-framework,代码行数:40,代码来源:template-tags.php


示例17: wp_tell_a_freind

function wp_tell_a_freind($content)
{
    if (is_single()) {
        global $sms;
        include_once dirname(__FILE__) . "/includes/templates/wp-sms-tell-friend.php";
        if ($_POST['send_post']) {
            $mobile = $_POST['get_fmobile'];
            if ($_POST['get_name'] && $_POST['get_fname'] && $_POST['get_fmobile']) {
                if (strlen($mobile) >= 11 && preg_match("([a-zA-Z])", $mobile) == 0) {
                    $sms->to = array($_POST['get_fmobile']);
                    $sms->msg = sprintf(__('Hi %s, the %s post suggested to you by %s. url: %s', 'wp-sms'), $_POST['get_fname'], get_the_title(), $_POST['get_name'], wp_get_shortlink());
                    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;
}
开发者ID:jekv,项目名称:devia,代码行数:24,代码来源:features.php


示例18: o2_get_default_post_actions

 function o2_get_default_post_actions($actions = false, $post_ID = false)
 {
     if (false === $actions) {
         $actions = array();
     }
     // Reply
     $logged_in_requirement_satisfied = get_option('comment_registration') ? is_user_logged_in() : true;
     if (comments_open($post_ID) && !post_password_required($post_ID) && $logged_in_requirement_satisfied) {
         $actions[20] = array('action' => 'reply', 'href' => get_permalink($post_ID) . '#respond', 'classes' => array('o2-post-reply', 'o2-reply'), 'rel' => false, 'initialState' => 'default');
     }
     // Scroll to Comments (Mobile)
     $actions[25] = array('action' => 'scrolltocomments', 'href' => get_permalink($post_ID), 'classes' => array('o2-scroll-to-comments'), 'rel' => false, 'initialState' => 'default');
     // Edit
     if (current_user_can('edit_post', $post_ID)) {
         $actions[30] = array('action' => 'edit', 'href' => get_edit_post_link($post_ID), 'classes' => array('edit-post-link', 'o2-edit'), 'rel' => $post_ID, 'initialState' => 'default');
     }
     // Trash
     if (current_user_can('edit_post', $post_ID)) {
         $actions[100] = array('action' => 'trash', 'href' => get_delete_post_link($post_ID), 'classes' => array('trash-post-link', 'o2-trash', 'o2-actions-border-top', 'o2-warning-hover'), 'rel' => $post_ID, 'initialState' => 'default');
     }
     // Shortlink
     $actions[40] = array('action' => 'shortlink', 'href' => wp_get_shortlink($post_ID, 'post'), 'classes' => array('short-link', 'o2-short-link'), 'rel' => false, 'initialState' => 'default');
     return $actions;
 }
开发者ID:BE-Webdesign,项目名称:o2,代码行数:24,代码来源:template-tags.php


示例19: get_comment

 function get_comment($comment_id, $context)
 {
     global $blog_id;
     $comment = get_comment($comment_id);
     if (!$comment || is_wp_error($comment)) {
         return new WP_Error('unknown_comment', 'Unknown comment', 404);
     }
     $types = array('', 'comment', 'pingback', 'trackback');
     if (!in_array($comment->comment_type, $types)) {
         return new WP_Error('unknown_comment', 'Unknown comment', 404);
     }
     $post = get_post($comment->comment_post_ID);
     if (!$post || is_wp_error($post)) {
         return new WP_Error('unknown_post', 'Unknown post', 404);
     }
     $status = wp_get_comment_status($comment->comment_ID);
     // Permissions
     switch ($context) {
         case 'edit':
             if (!current_user_can('edit_comment', $comment->comment_ID)) {
                 return new WP_Error('unauthorized', 'User cannot edit comment', 403);
             }
             $GLOBALS['post'] = $post;
             $comment = get_comment_to_edit($comment->comment_ID);
             foreach (array('comment_author', 'comment_author_email', 'comment_author_url') as $field) {
                 $comment->{$field} = htmlspecialchars_decode($comment->{$field}, ENT_QUOTES);
             }
             break;
         case 'display':
             if ('approved' !== $status) {
                 $current_user_id = get_current_user_id();
                 $user_can_read_coment = false;
                 if ($current_user_id && $comment->user_id && $current_user_id == $comment->user_id) {
                     $user_can_read_coment = true;
                 } elseif ($comment->comment_author_email && $comment->comment_author && isset($this->api->token_details['user']) && isset($this->api->token_details['user']['user_email']) && $this->api->token_details['user']['user_email'] === $comment->comment_author_email && $this->api->token_details['user']['display_name'] === $comment->comment_author) {
                     $user_can_read_coment = true;
                 } else {
                     $user_can_read_coment = current_user_can('edit_comment', $comment->comment_ID);
                 }
                 if (!$user_can_read_coment) {
                     return new WP_Error('unauthorized', 'User cannot read unapproved comment', 403);
                 }
             }
             $GLOBALS['post'] = $post;
             setup_postdata($post);
             break;
         default:
             return new WP_Error('invalid_context', 'Invalid API CONTEXT', 400);
     }
     $can_view = $this->user_can_view_post($post->ID);
     if (!$can_view || is_wp_error($can_view)) {
         return $can_view;
     }
     $GLOBALS['comment'] = $comment;
     $response = array();
     foreach (array_keys($this->comment_object_format) as $key) {
         switch ($key) {
             case 'ID':
                 // explicitly cast all output
                 $response[$key] = (int) $comment->comment_ID;
                 break;
             case 'post':
                 $response[$key] = (object) array('ID' => (int) $post->ID, 'title' => (string) get_the_title($post->ID), 'type' => (string) $post->post_type, 'link' => (string) $this->links->get_post_link($this->api->get_blog_id_for_output(), $post->ID));
                 break;
             case 'author':
                 $response[$key] = (object) $this->get_author($comment, 'edit' === $context && current_user_can('edit_comment', $comment->comment_ID));
                 break;
             case 'date':
                 $response[$key] = (string) $this->format_date($comment->comment_date_gmt, $comment->comment_date);
                 break;
             case 'URL':
                 $response[$key] = (string) esc_url_raw(get_comment_link($comment->comment_ID));
                 break;
             case 'short_URL':
                 // @todo - pagination
                 $response[$key] = (string) esc_url_raw(wp_get_shortlink($post->ID) . "%23comment-{$comment->comment_ID}");
                 break;
             case 'content':
                 if ('display' === $context) {
                     ob_start();
                     comment_text();
                     $response[$key] = (string) ob_get_clean();
                 } else {
                     $response[$key] = (string) $comment->comment_content;
                 }
                 break;
             case 'status':
                 $response[$key] = (string) $status;
                 break;
             case 'parent':
                 // (object|false)
                 if ($comment->comment_parent) {
                     $parent = get_comment($comment->comment_parent);
                     $response[$key] = (object) array('ID' => (int) $parent->comment_ID, 'type' => (string) ($parent->comment_type ? $parent->comment_type : 'comment'), 'link' => (string) $this->links->get_comment_link($blog_id, $parent->comment_ID));
                 } else {
                     $response[$key] = false;
                 }
                 break;
             case 'type':
                 $response[$key] = (string) ($comment->comment_type ? $comment->comment_type : 'comment');
//.........这里部分代码省略.........
开发者ID:kanei,项目名称:vantuch.cz,代码行数:101,代码来源:class.wpcom-json-api-comment-endpoint.php


示例20: do_action

    /**
     * Fires before the permalink field in the edit form.
     *
     * @since 4.1.0
     *
     * @param WP_Post $post Post object.
     */
    do_action('edit_form_before_permalink', $post);
    ?>
<div class="inside">
<?php 
    if ($viewable) {
        $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
        // As of 4.4, the Get Shortlink button is hidden by default.
        if (has_filter('pre_get_shortlink') || has_filter('get_shortlink')) {
            $shortlink = wp_get_shortlink($post->ID, 'post');
            if (!empty($shortlink) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID)) {
                $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
            }
        }
        if ($post_type_object->public && !('pending' == get_post_status($post) && !current_user_can($post_type_object->cap->publish_posts))) {
            $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
            ?>
	<div id="edit-slug-box" class="hide-if-no-js">
	<?php 
            if ($has_sample_permalink) {
                echo $sample_permalink_html;
            }
            ?>
	</div>
<?php 
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:31,代码来源:edit-form-advanced.php



注:本文中的wp_get_shortlink函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_get_sidebars_widgets函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_session_token函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap