public function test_returns_to_ping_sites_from_post_object()
    {
        $post_id = self::factory()->post->create(array('to_ping' => 'http://www.example.com
					http://www.otherexample.com'));
        $post = get_post($post_id);
        $this->assertSame(array('http://www.example.com', 'http://www.otherexample.com'), get_to_ping($post));
    }
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;
}
/**
 * Perform trackbacks.
 *
 * @since 1.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int $post_id Post ID to do trackbacks on.
 */
function do_trackbacks($post_id)
{
    global $wpdb;
    $post = get_post($post_id);
    $to_ping = get_to_ping($post_id);
    $pinged = get_pung($post_id);
    if (empty($to_ping)) {
        $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id));
        return;
    }
    if (empty($post->post_excerpt)) {
        /** This filter is documented in wp-includes/post-template.php */
        $excerpt = apply_filters('the_content', $post->post_content, $post->ID);
    } else {
        /** This filter is documented in wp-includes/post-template.php */
        $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
    }
    $excerpt = str_replace(']]>', ']]>', $excerpt);
    $excerpt = wp_html_excerpt($excerpt, 252, '…');
    /** This filter is documented in wp-includes/post-template.php */
    $post_title = apply_filters('the_title', $post->post_title, $post->ID);
    $post_title = strip_tags($post_title);
    if ($to_ping) {
        foreach ((array) $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($wpdb->prepare("UPDATE {$wpdb->posts} SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id));
            }
        }
    }
}
Beispiel #4
0
/**
 * Perform trackbacks.
 *
 * @since 1.5.0
 * @uses $wpdb
 *
 * @param int $post_id Post ID to do trackbacks on.
 */
function do_trackbacks($post_id)
{
    global $wpdb;
    $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID = %d", $post_id));
    $to_ping = get_to_ping($post_id);
    $pinged = get_pung($post_id);
    if (empty($to_ping)) {
        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET to_ping = '' WHERE ID = %d", $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 = wp_html_excerpt($excerpt, 252) . '...';
    $post_title = apply_filters('the_title', $post->post_title);
    $post_title = strip_tags($post_title);
    if ($to_ping) {
        foreach ((array) $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($wpdb->prepare("UPDATE {$wpdb->posts} SET to_ping = TRIM(REPLACE(to_ping, '{$tb_ping}', '')) WHERE ID = %d", $post_id));
            }
        }
    }
}
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_option('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 ((array) $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}'");
            }
        }
    }
}
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(']]>', ']]>', $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);
            }
        }
    }
}
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(']]>', ']]>', $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;
}