当前位置: 首页>>代码示例>>PHP>>正文


PHP get_pung函数代码示例

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


在下文中一共展示了get_pung函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_add_ping_with_post_object

 public function test_add_ping_with_post_object()
 {
     $post_id = self::factory()->post->create();
     $post = get_post($post_id);
     add_ping($post, 'foo');
     $this->assertSame(array('foo'), get_pung($post_id));
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:7,代码来源:pings.php

示例2: do_trackbacks

function do_trackbacks($post_id) {
	global $wpdb;

	$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id");
	$to_ping = get_to_ping($post_id);
	$pinged  = get_pung($post_id);
	if ( empty($to_ping) ) {
		$wpdb->query("UPDATE $wpdb->posts SET to_ping = '' WHERE ID = '$post_id'");
		return;
	}
	
	if (empty($post->post_excerpt))
		$excerpt = apply_filters('the_content', $post->post_content);
	else
		$excerpt = apply_filters('the_excerpt', $post->post_excerpt);
	$excerpt = str_replace(']]>', ']]>', $excerpt);
	$excerpt = strip_tags($excerpt);
	if ( function_exists('mb_strcut') ) // For international trackbacks
    	$excerpt = mb_strcut($excerpt, 0, 252, get_settings('blog_charset')) . '...';
	else
		$excerpt = substr($excerpt, 0, 252) . '...';

	$post_title = apply_filters('the_title', $post->post_title);
	$post_title = strip_tags($post_title);

	if ($to_ping) : foreach ($to_ping as $tb_ping) :
		$tb_ping = trim($tb_ping);
		if ( !in_array($tb_ping, $pinged) ) {
			trackback($tb_ping, $post_title, $excerpt, $post_id);
			$pinged[] = $tb_ping;
		} else {
			$wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_ping', '')) WHERE ID = '$post_id'");
		}
	endforeach; endif;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:35,代码来源:functions-post.php

示例3: pingback

/**
 * Pings back the links found in a post.
 *
 * @since 0.71
 *
 * @global string $wp_version
 *
 * @param string $content Post content to check for links.
 * @param int $post_ID Post ID.
 */
function pingback($content, $post_ID)
{
    global $wp_version;
    include_once ABSPATH . WPINC . '/class-IXR.php';
    include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
    // original code by Mort (http://mort.mine.nu:8080)
    $post_links = array();
    $pung = get_pung($post_ID);
    // Step 1
    // Parsing the post, external links (if any) are stored in the $post_links array
    $post_links_temp = wp_extract_urls($content);
    // Step 2.
    // Walking thru the links array
    // first we get rid of links pointing to sites, not to specific files
    // Example:
    // http://dummy-weblog.org
    // http://dummy-weblog.org/
    // http://dummy-weblog.org/post.php
    // We don't wanna ping first and second types, even if they have a valid <link/>
    foreach ((array) $post_links_temp as $link_test) {
        if (!in_array($link_test, $pung) && url_to_postid($link_test) != $post_ID && !is_local_attachment($link_test)) {
            // Also, let's never ping local attachments.
            if ($test = @parse_url($link_test)) {
                if (isset($test['query'])) {
                    $post_links[] = $link_test;
                } elseif (isset($test['path']) && $test['path'] != '/' && $test['path'] != '') {
                    $post_links[] = $link_test;
                }
            }
        }
    }
    $post_links = array_unique($post_links);
    /**
     * Fires just before pinging back links found in a post.
     *
     * @since 2.0.0
     *
     * @param array &$post_links An array of post links to be checked, passed by reference.
     * @param array &$pung       Whether a link has already been pinged, passed by reference.
     * @param int   $post_ID     The post ID.
     */
    do_action_ref_array('pre_ping', array(&$post_links, &$pung, $post_ID));
    foreach ((array) $post_links as $pagelinkedto) {
        $pingback_server_url = discover_pingback_server_uri($pagelinkedto);
        if ($pingback_server_url) {
            @set_time_limit(60);
            // Now, the RPC call
            $pagelinkedfrom = get_permalink($post_ID);
            // using a timeout of 3 seconds should be enough to cover slow servers
            $client = new WP_HTTP_IXR_Client($pingback_server_url);
            $client->timeout = 3;
            /**
             * Filter the user agent sent when pinging-back a URL.
             *
             * @since 2.9.0
             *
             * @param string $concat_useragent    The user agent concatenated with ' -- WordPress/'
             *                                    and the WordPress version.
             * @param string $useragent           The useragent.
             * @param string $pingback_server_url The server URL being linked to.
             * @param string $pagelinkedto        URL of page linked to.
             * @param string $pagelinkedfrom      URL of page linked from.
             */
            $client->useragent = apply_filters('pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom);
            // when set to true, this outputs debug messages by itself
            $client->debug = false;
            if ($client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || isset($client->error->code) && 48 == $client->error->code) {
                // Already registered
                add_ping($post_ID, $pagelinkedto);
            }
        }
    }
}
开发者ID:hadywisam,项目名称:WordPress,代码行数:83,代码来源:comment-functions.php

示例4: pingback

function pingback($content, $post_ID)
{
    global $wp_version, $wpdb;
    include_once ABSPATH . WPINC . '/class-IXR.php';
    // original code by Mort (http://mort.mine.nu:8080)
    $log = debug_fopen(ABSPATH . '/pingback.log', 'a');
    $post_links = array();
    debug_fwrite($log, 'BEGIN ' . date('YmdHis', time()) . "\n");
    $pung = get_pung($post_ID);
    // Variables
    $ltrs = '\\w';
    $gunk = '/#~:.?+=&%@!\\-';
    $punc = '.:?\\-';
    $any = $ltrs . $gunk . $punc;
    // Step 1
    // Parsing the post, external links (if any) are stored in the $post_links array
    // This regexp comes straight from phpfreaks.com
    // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
    preg_match_all("{\\b http : [{$any}] +? (?= [{$punc}] * [^{$any}] | \$)}x", $content, $post_links_temp);
    // Debug
    debug_fwrite($log, 'Post contents:');
    debug_fwrite($log, $content . "\n");
    // Step 2.
    // Walking thru the links array
    // first we get rid of links pointing to sites, not to specific files
    // Example:
    // http://dummy-weblog.org
    // http://dummy-weblog.org/
    // http://dummy-weblog.org/post.php
    // We don't wanna ping first and second types, even if they have a valid <link/>
    foreach ($post_links_temp[0] as $link_test) {
        if (!in_array($link_test, $pung) && url_to_postid($link_test) != $post_ID && !is_local_attachment($link_test)) {
            // Also, let's never ping local attachments.
            $test = parse_url($link_test);
            if (isset($test['query'])) {
                $post_links[] = $link_test;
            } elseif ($test['path'] != '/' && $test['path'] != '') {
                $post_links[] = $link_test;
            }
            do_action('pre_ping', array(&$post_links, &$pung));
        }
    }
    foreach ($post_links as $pagelinkedto) {
        debug_fwrite($log, "Processing -- {$pagelinkedto}\n");
        $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
        if ($pingback_server_url) {
            @set_time_limit(60);
            // Now, the RPC call
            debug_fwrite($log, "Page Linked To: {$pagelinkedto} \n");
            debug_fwrite($log, 'Page Linked From: ');
            $pagelinkedfrom = get_permalink($post_ID);
            debug_fwrite($log, $pagelinkedfrom . "\n");
            // using a timeout of 3 seconds should be enough to cover slow servers
            $client = new IXR_Client($pingback_server_url);
            $client->timeout = 3;
            $client->useragent .= ' -- WordPress/' . $wp_version;
            // when set to true, this outputs debug messages by itself
            $client->debug = false;
            if ($client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto)) {
                add_ping($post_ID, $pagelinkedto);
            } else {
                debug_fwrite($log, "Error.\n Fault code: " . $client->getErrorCode() . " : " . $client->getErrorMessage() . "\n");
            }
        }
    }
    debug_fwrite($log, "\nEND: " . time() . "\n****************************\n");
    debug_fclose($log);
}
开发者ID:robertlange81,项目名称:Website,代码行数:68,代码来源:comment-functions.php

示例5: pingback

/**
 * Pings back the links found in a post.
 *
 * @since 0.71
 * @uses $wp_version
 * @uses IXR_Client
 *
 * @param string $content Post content to check for links.
 * @param int $post_ID Post ID.
 */
function pingback($content, $post_ID)
{
    global $wp_version;
    include_once ABSPATH . WPINC . '/class-IXR.php';
    // original code by Mort (http://mort.mine.nu:8080)
    $post_links = array();
    $pung = get_pung($post_ID);
    // Variables
    $ltrs = '\\w';
    $gunk = '/#~:.?+=&%@!\\-';
    $punc = '.:?\\-';
    $any = $ltrs . $gunk . $punc;
    // Step 1
    // Parsing the post, external links (if any) are stored in the $post_links array
    // This regexp comes straight from phpfreaks.com
    // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
    preg_match_all("{\\b http : [{$any}] +? (?= [{$punc}] * [^{$any}] | \$)}x", $content, $post_links_temp);
    // Step 2.
    // Walking thru the links array
    // first we get rid of links pointing to sites, not to specific files
    // Example:
    // http://dummy-weblog.org
    // http://dummy-weblog.org/
    // http://dummy-weblog.org/post.php
    // We don't wanna ping first and second types, even if they have a valid <link/>
    foreach ((array) $post_links_temp[0] as $link_test) {
        if (!in_array($link_test, $pung) && url_to_postid($link_test) != $post_ID && !is_local_attachment($link_test)) {
            // Also, let's never ping local attachments.
            if ($test = @parse_url($link_test)) {
                if (isset($test['query'])) {
                    $post_links[] = $link_test;
                } elseif ($test['path'] != '/' && $test['path'] != '') {
                    $post_links[] = $link_test;
                }
            }
        }
    }
    do_action_ref_array('pre_ping', array(&$post_links, &$pung));
    foreach ((array) $post_links as $pagelinkedto) {
        $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
        if ($pingback_server_url) {
            @set_time_limit(60);
            // Now, the RPC call
            $pagelinkedfrom = get_permalink($post_ID);
            // using a timeout of 3 seconds should be enough to cover slow servers
            $client = new IXR_Client($pingback_server_url);
            $client->timeout = 3;
            $client->useragent .= ' -- WordPress/' . $wp_version;
            // when set to true, this outputs debug messages by itself
            $client->debug = false;
            if ($client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || isset($client->error->code) && 48 == $client->error->code) {
                // Already registered
                add_ping($post_ID, $pagelinkedto);
            }
        }
    }
}
开发者ID:SymbiSoft,项目名称:litprojects,代码行数:67,代码来源:comment.php

示例6: webmention

 /**
  * filter for webmention URLs hook
  *
  * @param array $links - array of URLs already sorted
  * @param int $postid - WordPress Post ID of currently active post
  *
  * @return array $links - modified and extended array of URLs
  */
 public static function webmention($links, $postid)
 {
     if (empty($postid)) {
         return $links;
     }
     $post = get_post($postid);
     if (!static::is_post($post)) {
         return $links;
     }
     $targs = array('fields' => 'all');
     $tagged = wp_get_post_terms($post->ID, 'indieweb_people', $targs);
     $pung = get_pung($post->ID);
     $to_ping = array();
     foreach ($tagged as $person) {
         $url = strtolower(trim($person->description));
         if (!in_array($url, $pung)) {
             static::debug(sprintf('queueing webmention for %s in post #%d', $url, $post->ID));
             array_push($to_ping, $url);
         }
     }
     $to_ping = apply_filters('wp_peoplemention_webmentions', $to_ping, $post->ID);
     $links = array_merge($links, $to_ping);
     return $links;
 }
开发者ID:petermolnar,项目名称:wp-peoplemention,代码行数:32,代码来源:wp-peoplemention.php

示例7: send_webmentions

 /**
  * Send WebMentions if new Post was saved
  *
  * You can still hook this function directly into the `publish_post` action:
  *
  * <code>
  *	 add_action('publish_post', array('WebMentionPlugin', 'send_webmentions'));
  * </code>
  *
  * @param int $post_ID the post_ID
  */
 public static function send_webmentions($post_ID)
 {
     // get source url
     $source = get_permalink($post_ID);
     // get post
     $post = get_post($post_ID);
     // initialize links array
     $links = array();
     // Find all external links in the source
     if (preg_match_all('/<a[^>]+href=.(https?:\\/\\/[^\'\\"]+)/i', $post->post_content, $matches)) {
         $links = $matches[1];
     }
     // filter links
     $targets = apply_filters('webmention_links', $links, $post_ID);
     $targets = array_unique($targets);
     foreach ($targets as $target) {
         // send webmention
         $response = self::send_webmention($source, $target, $post_ID);
         // check response
         if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) < 400) {
             $pung = get_pung($post_ID);
             // if not already added to punged urls
             if (!in_array($target, $pung)) {
                 // tell the pingback function not to ping these links again
                 add_ping($post_ID, $target);
             }
         }
         // rescedule if server responds with a http error 5xx
         if (wp_remote_retrieve_response_code($response) >= 500) {
             self::reschedule($post_ID);
         }
     }
 }
开发者ID:petermolnar,项目名称:wordpress-webmention,代码行数:44,代码来源:webmention.php

示例8: do_trackbacks

function do_trackbacks($post_id)
{
    global $wpdb;
    $post = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE ID = {$post_id}");
    $to_ping = get_to_ping($post_id);
    $pinged = get_pung($post_id);
    if (empty($to_ping)) {
        return;
    }
    if (empty($post->post_excerpt)) {
        $excerpt = apply_filters('the_content', $post->post_content);
    } else {
        $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
    }
    $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
    $excerpt = strip_tags($excerpt);
    $excerpt = substr($excerpt, 0, 252) . '...';
    $post_title = apply_filters('the_title', $post->post_title);
    $post_title = strip_tags($post_title);
    if ($to_ping) {
        foreach ($to_ping as $tb_ping) {
            $tb_ping = trim($tb_ping);
            if (!in_array($tb_ping, $pinged)) {
                trackback($tb_ping, $post_title, $excerpt, $post_id);
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:steampress-svn,代码行数:28,代码来源:functions-post.php

示例9: do_trackbacks

function do_trackbacks($post_id) {
	global $wpdb;

	$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id");
	$to_ping = get_to_ping($post_id);
	$pinged  = get_pung($post_id);

	if (empty($post->post_excerpt))
		$excerpt = apply_filters('the_content', $post->post_content);
	else
		$excerpt = apply_filters('the_excerpt', $post->post_excerpt);
	$excerpt = str_replace(']]>', ']]&gt;', $excerpt);
	$excerpt = strip_tags($excerpt);
	$excerpt = substr($excerpt, 0, 252) . '...';

	$post_title = apply_filters('the_title', $post->post_title);
	$post_title = strip_tags($post_title);

	if ($to_ping) : foreach ($to_ping as $tb_ping) :
		$tb_ping = trim($tb_ping);
		if ( !in_array($tb_ping, $pinged) )
		 trackback($tb_ping, $post_title, $excerpt, $post_id);
	endforeach; endif;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:24,代码来源:functions-post.php


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