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


PHP sanitize_bookmark函数代码示例

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


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

示例1: get_bookmark

/**
 * Retrieve Bookmark data based on ID
 *
 * @since 2.1.0
 * @uses $wpdb Database Object
 *
 * @param int $bookmark_id
 * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant
 * @param string $filter Optional, default is 'raw'.
 * @return array|object Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else {
        if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
            $_bookmark =& $GLOBALS['link'];
        } elseif (!($_bookmark = wp_cache_get($bookmark, 'bookmark'))) {
            $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
            $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', 'fields=ids'));
            wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
        }
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if ($output == OBJECT) {
        return $_bookmark;
    } elseif ($output == ARRAY_A) {
        return get_object_vars($_bookmark);
    } elseif ($output == ARRAY_N) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}
开发者ID:papayalabs,项目名称:htdocs,代码行数:43,代码来源:bookmark.php

示例2: get_bookmark

/**
 * Retrieve Bookmark data based on ID
 *
 * @since 2.1
 * @uses $wpdb Database Object
 *
 * @param int $bookmark_id
 * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant
 * @param string $filter Optional, default is 'raw'.
 * @return array|object Type returned depends on $output value.
 */
function get_bookmark($bookmark_id, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    $link = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark_id));
    $link->link_category = array_unique(wp_get_object_terms($link->link_id, 'link_category', 'fields=ids'));
    $link = sanitize_bookmark($link, $filter);
    if ($output == OBJECT) {
        return $link;
    } elseif ($output == ARRAY_A) {
        return get_object_vars($link);
    } elseif ($output == ARRAY_N) {
        return array_values(get_object_vars($link));
    } else {
        return $link;
    }
}
开发者ID:nurpax,项目名称:saastafi,代码行数:27,代码来源:bookmark.php

示例3: print_column_headers

	</tr>
	</thead>

	<tfoot>
	<tr>
<?php 
    print_column_headers('link-manager', false);
    ?>
	</tr>
	</tfoot>

	<tbody>
<?php 
    $alt = 0;
    foreach ($links as $link) {
        $link = sanitize_bookmark($link);
        $link->link_name = esc_attr($link->link_name);
        $link->link_category = wp_get_link_cats($link->link_id);
        $short_url = str_replace('http://', '', $link->link_url);
        $short_url = preg_replace('/^www\\./i', '', $short_url);
        if ('/' == substr($short_url, -1)) {
            $short_url = substr($short_url, 0, -1);
        }
        if (strlen($short_url) > 35) {
            $short_url = substr($short_url, 0, 32) . '...';
        }
        $visible = $link->link_visible == 'Y' ? __('Yes') : __('No');
        $rating = $link->link_rating;
        $style = $alt % 2 ? '' : ' class="alternate"';
        ++$alt;
        $edit_link = get_edit_bookmark_link();
开发者ID:jinpingv,项目名称:website_wrapper,代码行数:31,代码来源:link-manager.php

示例4: link_library_insert_link

 function link_library_insert_link($linkdata, $wp_error = false, $addlinknoaddress = false)
 {
     global $wpdb;
     $defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0);
     $linkdata = wp_parse_args($linkdata, $defaults);
     $linkdata = sanitize_bookmark($linkdata, 'db');
     extract(stripslashes_deep($linkdata), EXTR_SKIP);
     $update = false;
     if (!empty($link_id)) {
         $update = true;
     }
     if (isset($link_name) && trim($link_name) == '') {
         if (isset($link_url) && trim($link_url) != '') {
             $link_name = $link_url;
         } else {
             return 0;
         }
     }
     if ($addlinknoaddress == false) {
         if (trim($link_url) == '') {
             return 0;
         }
     }
     if (empty($link_rating)) {
         $link_rating = 0;
     }
     if (empty($link_image)) {
         $link_image = '';
     }
     if (empty($link_target)) {
         $link_target = '';
     }
     if (empty($link_visible)) {
         $link_visible = 'Y';
     }
     if (empty($link_owner)) {
         $link_owner = get_current_user_id();
     }
     if (empty($link_notes)) {
         $link_notes = '';
     }
     if (empty($link_description)) {
         $link_description = '';
     }
     if (empty($link_rss)) {
         $link_rss = '';
     }
     if (empty($link_rel)) {
         $link_rel = '';
     }
     // Make sure we set a valid category
     if (!isset($link_category) || 0 == count($link_category) || !is_array($link_category)) {
         $link_category = array(get_option('default_link_category'));
     }
     if ($update) {
         if (false === $wpdb->update($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id'))) {
             if ($wp_error) {
                 return new WP_Error('db_update_error', __('Could not update link in the database', 'link-library'), $wpdb->last_error);
             } else {
                 return 0;
             }
         }
     } else {
         if (false === $wpdb->insert($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss'))) {
             if ($wp_error) {
                 return new WP_Error('db_insert_error', __('Could not insert link into the database', 'link-library'), $wpdb->last_error);
             } else {
                 return 0;
             }
         }
         $link_id = (int) $wpdb->insert_id;
     }
     wp_set_link_cats($link_id, $link_category);
     if ($update) {
         do_action('edit_link', $link_id);
     } else {
         do_action('add_link', $link_id);
     }
     clean_bookmark_cache($link_id);
     return $link_id;
 }
开发者ID:wenhao87,项目名称:WPPlugins,代码行数:81,代码来源:link-library.php

示例5: display_rows

    public function display_rows()
    {
        foreach ($this->items as $link) {
            $link = sanitize_bookmark($link);
            $link->link_name = esc_attr($link->link_name);
            $link->link_category = wp_get_link_cats($link->link_id);
            ?>
		<tr id="link-<?php 
            echo $link->link_id;
            ?>
">
			<?php 
            $this->single_row_columns($link);
            ?>
		</tr>
<?php 
        }
    }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:18,代码来源:class-wp-links-list-table.php

示例6: display_rows

    function display_rows()
    {
        global $cat_id;
        $alt = 0;
        foreach ($this->items as $link) {
            $link = sanitize_bookmark($link);
            $link->link_name = esc_attr($link->link_name);
            $link->link_category = wp_get_link_cats($link->link_id);
            $short_url = url_shorten($link->link_url);
            $visible = $link->link_visible == 'Y' ? __('Yes') : __('No');
            $rating = $link->link_rating;
            $style = $alt++ % 2 ? '' : ' class="alternate"';
            $edit_link = get_edit_bookmark_link($link);
            ?>
		<tr id="link-<?php 
            echo $link->link_id;
            ?>
" valign="middle" <?php 
            echo $style;
            ?>
>
<?php 
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $class = "class='column-{$column_name}'";
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = $class . $style;
                switch ($column_name) {
                    case 'cb':
                        ?>
						<th scope="row" class="check-column">
							<label class="screen-reader-text" for="cb-select-<?php 
                        echo $link->link_id;
                        ?>
"><?php 
                        echo sprintf(__('Select %s'), $link->link_name);
                        ?>
</label>
							<input type="checkbox" name="linkcheck[]" id="cb-select-<?php 
                        echo $link->link_id;
                        ?>
" value="<?php 
                        echo esc_attr($link->link_id);
                        ?>
" />
						</th>
						<?php 
                        break;
                    case 'name':
                        echo "<td {$attributes}><strong><a class='row-title' href='{$edit_link}' title='" . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $link->link_name)) . "'>{$link->link_name}</a></strong><br />";
                        $actions = array();
                        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
                        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&amp;link_id={$link->link_id}", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>";
                        echo $this->row_actions($actions);
                        echo '</td>';
                        break;
                    case 'url':
                        echo "<td {$attributes}><a href='{$link->link_url}' title='" . esc_attr(sprintf(__('Visit %s'), $link->link_name)) . "'>{$short_url}</a></td>";
                        break;
                    case 'categories':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        $cat_names = array();
                        foreach ($link->link_category as $category) {
                            $cat = get_term($category, 'link_category', OBJECT, 'display');
                            if (is_wp_error($cat)) {
                                echo $cat->get_error_message();
                            }
                            $cat_name = $cat->name;
                            if ($cat_id != $category) {
                                $cat_name = "<a href='link-manager.php?cat_id={$category}'>{$cat_name}</a>";
                            }
                            $cat_names[] = $cat_name;
                        }
                        echo implode(', ', $cat_names);
                        ?>
</td><?php 
                        break;
                    case 'rel':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo empty($link->link_rel) ? '<br />' : $link->link_rel;
                        ?>
</td><?php 
                        break;
                    case 'visible':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
//.........这里部分代码省略.........
开发者ID:dev-lav,项目名称:htdocs,代码行数:101,代码来源:class-wp-links-list-table.php

示例7: wp_insert_link

/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @param unknown_type $linkdata
 * @return unknown
 */
function wp_insert_link( $linkdata, $wp_error = false ) {
	global $wpdb, $current_user;

	$defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );

	$linkdata = wp_parse_args( $linkdata, $defaults );
	$linkdata = sanitize_bookmark( $linkdata, 'db' );

	extract( stripslashes_deep( $linkdata ), EXTR_SKIP );

	$update = false;

	if ( !empty( $link_id ) )
		$update = true;

	if ( trim( $link_name ) == '' )
		return 0;

	if ( trim( $link_url ) == '' )
		return 0;

	if ( empty( $link_rating ) )
		$link_rating = 0;

	if ( empty( $link_image ) )
		$link_image = '';

	if ( empty( $link_target ) )
		$link_target = '';

	if ( empty( $link_visible ) )
		$link_visible = 'Y';

	if ( empty( $link_owner ) )
		$link_owner = $current_user->id;

	if ( empty( $link_notes ) )
		$link_notes = '';

	if ( empty( $link_description ) )
		$link_description = '';

	if ( empty( $link_rss ) )
		$link_rss = '';

	if ( empty( $link_rel ) )
		$link_rel = '';

	// Make sure we set a valid category
	if ( ! isset( $link_category ) ||0 == count( $link_category ) || !is_array( $link_category ) ) {
		$link_category = array( get_option( 'default_link_category' ) );
	}

	if ( $update ) {
		if ( false === $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_url = %s,
			link_name = %s, link_image = %s, link_target = %s,
			link_visible = %s, link_description = %s, link_rating = %s,
			link_rel = %s, link_notes = %s, link_rss = %s
			WHERE link_id = %s", $link_url, $link_name, $link_image, $link_target, $link_visible, $link_description, $link_rating, $link_rel, $link_notes, $link_rss, $link_id ) ) ) {
			if ( $wp_error )
				return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error );
			else
				return 0;
		}
	} else {
		if ( false === $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
		$link_url,$link_name, $link_image, $link_target, $link_description, $link_visible, $link_owner, $link_rating, $link_rel, $link_notes, $link_rss ) ) ) {
			if ( $wp_error )
				return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error );
			else
				return 0;
		}
		$link_id = (int) $wpdb->insert_id;
	}

	wp_set_link_cats( $link_id, $link_category );

	if ( $update )
		do_action( 'edit_link', $link_id );
	else
		do_action( 'add_link', $link_id );

	clean_bookmark_cache( $link_id );

	return $link_id;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:94,代码来源:bookmark.php

示例8: wp_insert_link

/**
 * This function inserts/updates links into/in the database.
 *
 * @since 2.0.0
 *
 * @param array $linkdata Elements that make up the link to insert.
 * @param bool $wp_error Optional. If true return WP_Error object on failure.
 * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
 */
function wp_insert_link($linkdata, $wp_error = false)
{
    global $wpdb;
    $defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0);
    $args = wp_parse_args($linkdata, $defaults);
    $r = wp_unslash(sanitize_bookmark($args, 'db'));
    $link_id = $r['link_id'];
    $link_name = $r['link_name'];
    $link_url = $r['link_url'];
    $update = false;
    if (!empty($link_id)) {
        $update = true;
    }
    if (trim($link_name) == '') {
        if (trim($link_url) != '') {
            $link_name = $link_url;
        } else {
            return 0;
        }
    }
    if (trim($link_url) == '') {
        return 0;
    }
    $link_rating = !empty($r['link_rating']) ? $r['link_rating'] : 0;
    $link_image = !empty($r['link_image']) ? $r['link_image'] : '';
    $link_target = !empty($r['link_target']) ? $r['link_target'] : '';
    $link_visible = !empty($r['link_visible']) ? $r['link_visible'] : 'Y';
    $link_owner = !empty($r['link_owner']) ? $r['link_owner'] : get_current_user_id();
    $link_notes = !empty($r['link_notes']) ? $r['link_notes'] : '';
    $link_description = !empty($r['link_description']) ? $r['link_description'] : '';
    $link_rss = !empty($r['link_rss']) ? $r['link_rss'] : '';
    $link_rel = !empty($r['link_rel']) ? $r['link_rel'] : '';
    $link_category = !empty($r['link_category']) ? $r['link_category'] : array();
    // Make sure we set a valid category
    if (!is_array($link_category) || 0 == count($link_category)) {
        $link_category = array(get_option('default_link_category'));
    }
    if ($update) {
        if (false === $wpdb->update($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id'))) {
            if ($wp_error) {
                return new WP_Error('db_update_error', __('Could not update link in the database'), $wpdb->last_error);
            } else {
                return 0;
            }
        }
    } else {
        if (false === $wpdb->insert($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss'))) {
            if ($wp_error) {
                return new WP_Error('db_insert_error', __('Could not insert link into the database'), $wpdb->last_error);
            } else {
                return 0;
            }
        }
        $link_id = (int) $wpdb->insert_id;
    }
    wp_set_link_cats($link_id, $link_category);
    if ($update) {
        /**
         * Fires after a link was updated in the database.
         *
         * @since 2.0.0
         *
         * @param int $link_id ID of the link that was updated.
         */
        do_action('edit_link', $link_id);
    } else {
        /**
         * Fires after a link was added to the database.
         *
         * @since 2.0.0
         *
         * @param int $link_id ID of the link that was added.
         */
        do_action('add_link', $link_id);
    }
    clean_bookmark_cache($link_id);
    return $link_id;
}
开发者ID:ajspencer,项目名称:NCSSM-SG-WordPress,代码行数:87,代码来源:bookmark.php

示例9: wp_insert_link

function wp_insert_link($linkdata)
{
    global $wpdb, $current_user;
    $defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0);
    $linkdata = wp_parse_args($linkdata, $defaults);
    $linkdata = sanitize_bookmark($linkdata, 'db');
    extract($linkdata, EXTR_SKIP);
    $update = false;
    if (!empty($link_id)) {
        $update = true;
    }
    if (trim($link_name) == '') {
        return 0;
    }
    if (trim($link_url) == '') {
        return 0;
    }
    if (empty($link_rating)) {
        $link_rating = 0;
    }
    if (empty($link_image)) {
        $link_image = '';
    }
    if (empty($link_target)) {
        $link_target = '';
    }
    if (empty($link_visible)) {
        $link_visible = 'Y';
    }
    if (empty($link_owner)) {
        $link_owner = $current_user->id;
    }
    if (empty($link_notes)) {
        $link_notes = '';
    }
    if (empty($link_description)) {
        $link_description = '';
    }
    if (empty($link_rss)) {
        $link_rss = '';
    }
    if (empty($link_rel)) {
        $link_rel = '';
    }
    // Make sure we set a valid category
    if (0 == count($link_category) || !is_array($link_category)) {
        $link_category = array(get_option('default_link_category'));
    }
    if ($update) {
        $wpdb->query("UPDATE {$wpdb->links} SET link_url='{$link_url}',\n\t\t\tlink_name='{$link_name}', link_image='{$link_image}',\n\t\t\tlink_target='{$link_target}',\n\t\t\tlink_visible='{$link_visible}', link_description='{$link_description}',\n\t\t\tlink_rating='{$link_rating}', link_rel='{$link_rel}',\n\t\t\tlink_notes='{$link_notes}', link_rss = '{$link_rss}'\n\t\t\tWHERE link_id='{$link_id}'");
    } else {
        $wpdb->query("INSERT INTO {$wpdb->links} (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('{$link_url}','{$link_name}', '{$link_image}', '{$link_target}', '{$link_description}', '{$link_visible}', '{$link_owner}', '{$link_rating}', '{$link_rel}', '{$link_notes}', '{$link_rss}')");
        $link_id = (int) $wpdb->insert_id;
    }
    wp_set_link_cats($link_id, $link_category);
    if ($update) {
        do_action('edit_link', $link_id);
    } else {
        do_action('add_link', $link_id);
    }
    return $link_id;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:62,代码来源:bookmark.php

示例10: display_rows

    /**
     *
     * @global int $cat_id
     */
    public function display_rows()
    {
        global $cat_id;
        foreach ($this->items as $link) {
            $link = sanitize_bookmark($link);
            $link->link_name = esc_attr($link->link_name);
            $link->link_category = wp_get_link_cats($link->link_id);
            $short_url = url_shorten($link->link_url);
            $visible = $link->link_visible == 'Y' ? __('Yes') : __('No');
            $rating = $link->link_rating;
            $edit_link = get_edit_bookmark_link($link);
            ?>
		<tr id="link-<?php 
            echo $link->link_id;
            ?>
">
<?php 
            list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $classes = "{$column_name} column-{$column_name}";
                if ($primary === $column_name) {
                    $classes .= ' has-row-actions column-primary';
                }
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = "class='{$classes}'{$style}";
                if ('cb' === $column_name) {
                    ?>
					<th scope="row" class="check-column">
						<label class="screen-reader-text" for="cb-select-<?php 
                    echo $link->link_id;
                    ?>
"><?php 
                    echo sprintf(__('Select %s'), $link->link_name);
                    ?>
</label>
						<input type="checkbox" name="linkcheck[]" id="cb-select-<?php 
                    echo $link->link_id;
                    ?>
" value="<?php 
                    echo esc_attr($link->link_id);
                    ?>
" />
					</th>
					<?php 
                } else {
                    echo "<td {$attributes}>";
                    switch ($column_name) {
                        case 'name':
                            echo "<strong><a class='row-title' href='{$edit_link}' title='" . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $link->link_name)) . "'>{$link->link_name}</a></strong><br />";
                            break;
                        case 'url':
                            echo "<a href='{$link->link_url}' title='" . esc_attr(sprintf(__('Visit %s'), $link->link_name)) . "'>{$short_url}</a>";
                            break;
                        case 'categories':
                            $cat_names = array();
                            foreach ($link->link_category as $category) {
                                $cat = get_term($category, 'link_category', OBJECT, 'display');
                                if (is_wp_error($cat)) {
                                    echo $cat->get_error_message();
                                }
                                $cat_name = $cat->name;
                                if ($cat_id != $category) {
                                    $cat_name = "<a href='link-manager.php?cat_id={$category}'>{$cat_name}</a>";
                                }
                                $cat_names[] = $cat_name;
                            }
                            echo implode(', ', $cat_names);
                            break;
                        case 'rel':
                            echo empty($link->link_rel) ? '<br />' : $link->link_rel;
                            break;
                        case 'visible':
                            echo $visible;
                            break;
                        case 'rating':
                            echo $rating;
                            break;
                        default:
                            /**
                             * Fires for each registered custom link column.
                             *
                             * @since 2.1.0
                             *
                             * @param string $column_name Name of the custom column.
                             * @param int    $link_id     Link ID.
                             */
                            do_action('manage_link_custom_column', $column_name, $link->link_id);
                            break;
                    }
                    echo $this->handle_row_actions($link, $column_name, $primary);
                    echo '</td>';
                }
            }
//.........这里部分代码省略.........
开发者ID:pmanterys,项目名称:wp-mw-newsletter,代码行数:101,代码来源:class-wp-links-list-table.php

示例11: display_rows

    function display_rows()
    {
        global $cat_id;
        $alt = 0;
        foreach ($this->items as $link) {
            $link = sanitize_bookmark($link);
            $link->link_name = esc_attr($link->link_name);
            $link->link_category = wp_get_link_cats($link->link_id);
            $short_url = str_replace('http://', '', $link->link_url);
            $short_url = preg_replace('/^www\\./i', '', $short_url);
            if ('/' == substr($short_url, -1)) {
                $short_url = substr($short_url, 0, -1);
            }
            if (strlen($short_url) > 35) {
                $short_url = substr($short_url, 0, 32) . '...';
            }
            $visible = $link->link_visible == 'Y' ? __('Yes') : __('No');
            $rating = $link->link_rating;
            $style = $alt++ % 2 ? '' : ' class="alternate"';
            $edit_link = get_edit_bookmark_link($link);
            ?>
		<tr id="link-<?php 
            echo $link->link_id;
            ?>
" valign="middle" <?php 
            echo $style;
            ?>
>
<?php 
            list($columns, $hidden) = $this->get_column_headers();
            foreach ($columns as $column_name => $column_display_name) {
                $class = "class='column-{$column_name}'";
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = $class . $style;
                switch ($column_name) {
                    case 'cb':
                        echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="' . esc_attr($link->link_id) . '" /></th>';
                        break;
                    case 'name':
                        echo "<td {$attributes}><strong><a class='row-title' href='{$edit_link}' title='" . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $link->link_name)) . "'>{$link->link_name}</a></strong><br />";
                        $actions = array();
                        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
                        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&amp;link_id={$link->link_id}", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>";
                        $action_count = count($actions);
                        $i = 0;
                        echo '<div class="row-actions">';
                        foreach ($actions as $action => $linkaction) {
                            ++$i;
                            $i == $action_count ? $sep = '' : ($sep = ' | ');
                            echo "<span class='{$action}'>{$linkaction}{$sep}</span>";
                        }
                        echo '</div>';
                        echo '</td>';
                        break;
                    case 'url':
                        echo "<td {$attributes}><a href='{$link->link_url}' title='" . sprintf(__('Visit %s'), $link->link_name) . "'>{$short_url}</a></td>";
                        break;
                    case 'categories':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        $cat_names = array();
                        foreach ($link->link_category as $category) {
                            $cat = get_term($category, 'link_category', OBJECT, 'display');
                            if (is_wp_error($cat)) {
                                echo $cat->get_error_message();
                            }
                            $cat_name = $cat->name;
                            if ($cat_id != $category) {
                                $cat_name = "<a href='link-manager.php?cat_id={$category}'>{$cat_name}</a>";
                            }
                            $cat_names[] = $cat_name;
                        }
                        echo implode(', ', $cat_names);
                        ?>
</td><?php 
                        break;
                    case 'rel':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo empty($link->link_rel) ? '<br />' : $link->link_rel;
                        ?>
</td><?php 
                        break;
                    case 'visible':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $visible;
                        ?>
//.........这里部分代码省略.........
开发者ID:junxuan,项目名称:wordpress,代码行数:101,代码来源:default-list-tables.php


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