Ticket #21307: link-manager.diff
File link-manager.diff, 229.5 KB (added by , 13 years ago) |
---|
-
wp-includes/admin-bar.php
492 492 if ( current_user_can( 'upload_files' ) ) 493 493 $actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' ); 494 494 495 if ( current_user_can( 'manage_links' ) )496 $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );497 498 495 if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) { 499 496 $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); 500 497 unset( $cpts['page'] ); -
wp-includes/category.php
41 41 $args = wp_parse_args( $args, $defaults ); 42 42 43 43 $taxonomy = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args ); 44 45 // Back compat 46 if ( isset($args['type']) && 'link' == $args['type'] ) { 47 _deprecated_argument( __FUNCTION__, '3.0', '' ); 48 $taxonomy = $args['taxonomy'] = 'link_category'; 49 } 50 44 $args['taxonomy'] = $taxonomy; 45 51 46 $categories = (array) get_terms( $taxonomy, $args ); 52 47 53 48 foreach ( array_keys( $categories ) as $k ) -
wp-includes/taxonomy.php
73 73 'show_in_nav_menus' => false, 74 74 ) ); 75 75 76 register_taxonomy( 'link_category', 'link', array(77 'hierarchical' => false,78 'labels' => array(79 'name' => __( 'Link Categories' ),80 'singular_name' => __( 'Link Category' ),81 'search_items' => __( 'Search Link Categories' ),82 'popular_items' => null,83 'all_items' => __( 'All Link Categories' ),84 'edit_item' => __( 'Edit Link Category' ),85 'update_item' => __( 'Update Link Category' ),86 'add_new_item' => __( 'Add New Link Category' ),87 'new_item_name' => __( 'New Link Category Name' ),88 'separate_items_with_commas' => null,89 'add_or_remove_items' => null,90 'choose_from_most_used' => null,91 ),92 'query_var' => false,93 'rewrite' => false,94 'public' => false,95 'show_ui' => false,96 '_builtin' => true,97 ) );98 99 76 register_taxonomy( 'post_format', 'post', array( 100 77 'public' => true, 101 78 'hierarchical' => false, … … 2920 2897 /** 2921 2898 * Will update term count based on number of objects. 2922 2899 * 2923 * Default callback for the link_category taxonomy.2924 2900 * 2925 2901 * @package WordPress 2926 2902 * @subpackage Taxonomy -
wp-includes/default-widgets.php
83 83 } 84 84 85 85 /** 86 * Links widget class87 *88 * @since 2.8.089 */90 class WP_Widget_Links extends WP_Widget {91 92 function __construct() {93 $widget_ops = array('description' => __( "Your blogroll" ) );94 parent::__construct('links', __('Links'), $widget_ops);95 }96 97 function widget( $args, $instance ) {98 extract($args, EXTR_SKIP);99 100 $show_description = isset($instance['description']) ? $instance['description'] : false;101 $show_name = isset($instance['name']) ? $instance['name'] : false;102 $show_rating = isset($instance['rating']) ? $instance['rating'] : false;103 $show_images = isset($instance['images']) ? $instance['images'] : true;104 $category = isset($instance['category']) ? $instance['category'] : false;105 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';106 $order = $orderby == 'rating' ? 'DESC' : 'ASC';107 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;108 109 $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);110 wp_list_bookmarks(apply_filters('widget_links_args', array(111 'title_before' => $before_title, 'title_after' => $after_title,112 'category_before' => $before_widget, 'category_after' => $after_widget,113 'show_images' => $show_images, 'show_description' => $show_description,114 'show_name' => $show_name, 'show_rating' => $show_rating,115 'category' => $category, 'class' => 'linkcat widget',116 'orderby' => $orderby, 'order' => $order,117 'limit' => $limit,118 )));119 }120 121 function update( $new_instance, $old_instance ) {122 $new_instance = (array) $new_instance;123 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 );124 foreach ( $instance as $field => $val ) {125 if ( isset($new_instance[$field]) )126 $instance[$field] = 1;127 }128 129 $instance['orderby'] = 'name';130 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) )131 $instance['orderby'] = $new_instance['orderby'];132 133 $instance['category'] = intval( $new_instance['category'] );134 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;135 136 return $instance;137 }138 139 function form( $instance ) {140 141 //Defaults142 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) );143 $link_cats = get_terms( 'link_category' );144 if ( ! $limit = intval( $instance['limit'] ) )145 $limit = -1;146 ?>147 <p>148 <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Select Link Category:' ); ?></label>149 <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">150 <option value=""><?php _ex('All Links', 'links widget'); ?></option>151 <?php152 foreach ( $link_cats as $link_cat ) {153 echo '<option value="' . intval($link_cat->term_id) . '"'154 . ( $link_cat->term_id == $instance['category'] ? ' selected="selected"' : '' )155 . '>' . $link_cat->name . "</option>\n";156 }157 ?>158 </select>159 <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Sort by:' ); ?></label>160 <select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">161 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option>162 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option>163 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option>164 <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _e( 'Random' ); ?></option>165 </select>166 </p>167 <p>168 <input class="checkbox" type="checkbox" <?php checked($instance['images'], true) ?> id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" />169 <label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />170 <input class="checkbox" type="checkbox" <?php checked($instance['name'], true) ?> id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" />171 <label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />172 <input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" />173 <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />174 <input class="checkbox" type="checkbox" <?php checked($instance['rating'], true) ?> id="<?php echo $this->get_field_id('rating'); ?>" name="<?php echo $this->get_field_name('rating'); ?>" />175 <label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>176 </p>177 <p>178 <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e( 'Number of links to show:' ); ?></label>179 <input id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />180 </p>181 <?php182 }183 }184 185 /**186 86 * Search widget class 187 87 * 188 88 * @since 2.8.0 … … 1158 1058 1159 1059 register_widget('WP_Widget_Archives'); 1160 1060 1161 register_widget('WP_Widget_Links');1162 1163 1061 register_widget('WP_Widget_Meta'); 1164 1062 1165 1063 register_widget('WP_Widget_Search'); -
wp-includes/bookmark-template.php
1 <?php2 /**3 * Bookmark Template Functions for usage in Themes4 *5 * @package WordPress6 * @subpackage Template7 */8 9 /**10 * The formatted output of a list of bookmarks.11 *12 * The $bookmarks array must contain bookmark objects and will be iterated over13 * to retrieve the bookmark to be used in the output.14 *15 * The output is formatted as HTML with no way to change that format. However,16 * what is between, before, and after can be changed. The link itself will be17 * HTML.18 *19 * This function is used internally by wp_list_bookmarks() and should not be20 * used by themes.21 *22 * The defaults for overwriting are:23 * 'show_updated' - Default is 0 (integer). Will show the time of when the24 * bookmark was last updated.25 * 'show_description' - Default is 0 (integer). Whether to show the description26 * of the bookmark.27 * 'show_images' - Default is 1 (integer). Whether to show link image if28 * available.29 * 'show_name' - Default is 0 (integer). Whether to show link name if30 * available.31 * 'before' - Default is '<li>' (string). The html or text to prepend to each32 * bookmarks.33 * 'after' - Default is '</li>' (string). The html or text to append to each34 * bookmarks.35 * 'link_before' - Default is '' (string). The html or text to prepend to each36 * bookmarks inside the <a> tag.37 * 'link_after' - Default is '' (string). The html or text to append to each38 * bookmarks inside the <a> tag.39 * 'between' - Default is '\n' (string). The string for use in between the link,40 * description, and image.41 * 'show_rating' - Default is 0 (integer). Whether to show the link rating.42 *43 * @since 2.1.044 * @access private45 *46 * @param array $bookmarks List of bookmarks to traverse47 * @param string|array $args Optional. Overwrite the defaults.48 * @return string Formatted output in HTML49 */50 function _walk_bookmarks($bookmarks, $args = '' ) {51 $defaults = array(52 'show_updated' => 0, 'show_description' => 0,53 'show_images' => 1, 'show_name' => 0,54 'before' => '<li>', 'after' => '</li>', 'between' => "\n",55 'show_rating' => 0, 'link_before' => '', 'link_after' => ''56 );57 58 $r = wp_parse_args( $args, $defaults );59 extract( $r, EXTR_SKIP );60 61 $output = ''; // Blank string to start with.62 63 foreach ( (array) $bookmarks as $bookmark ) {64 if ( !isset($bookmark->recently_updated) )65 $bookmark->recently_updated = false;66 $output .= $before;67 if ( $show_updated && $bookmark->recently_updated )68 $output .= get_option('links_recently_updated_prepend');69 70 $the_link = '#';71 if ( !empty($bookmark->link_url) )72 $the_link = esc_url($bookmark->link_url);73 74 $desc = esc_attr(sanitize_bookmark_field('link_description', $bookmark->link_description, $bookmark->link_id, 'display'));75 $name = esc_attr(sanitize_bookmark_field('link_name', $bookmark->link_name, $bookmark->link_id, 'display'));76 $title = $desc;77 78 if ( $show_updated )79 if ( '00' != substr($bookmark->link_updated_f, 0, 2) ) {80 $title .= ' (';81 $title .= sprintf(__('Last updated: %s'), date(get_option('links_updated_date_format'), $bookmark->link_updated_f + (get_option('gmt_offset') * 3600)));82 $title .= ')';83 }84 85 $alt = ' alt="' . $name . ( $show_description ? ' ' . $title : '' ) . '"';86 87 if ( '' != $title )88 $title = ' title="' . $title . '"';89 90 $rel = $bookmark->link_rel;91 if ( '' != $rel )92 $rel = ' rel="' . esc_attr($rel) . '"';93 94 $target = $bookmark->link_target;95 if ( '' != $target )96 $target = ' target="' . $target . '"';97 98 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';99 100 $output .= $link_before;101 102 if ( $bookmark->link_image != null && $show_images ) {103 if ( strpos($bookmark->link_image, 'http') === 0 )104 $output .= "<img src=\"$bookmark->link_image\" $alt $title />";105 else // If it's a relative path106 $output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />";107 108 if ( $show_name )109 $output .= " $name";110 } else {111 $output .= $name;112 }113 114 $output .= $link_after;115 116 $output .= '</a>';117 118 if ( $show_updated && $bookmark->recently_updated )119 $output .= get_option('links_recently_updated_append');120 121 if ( $show_description && '' != $desc )122 $output .= $between . $desc;123 124 if ( $show_rating )125 $output .= $between . sanitize_bookmark_field('link_rating', $bookmark->link_rating, $bookmark->link_id, 'display');126 127 $output .= "$after\n";128 } // end while129 130 return $output;131 }132 133 /**134 * Retrieve or echo all of the bookmarks.135 *136 * List of default arguments are as follows:137 * 'orderby' - Default is 'name' (string). How to order the links by. String is138 * based off of the bookmark scheme.139 * 'order' - Default is 'ASC' (string). Either 'ASC' or 'DESC'. Orders in either140 * ascending or descending order.141 * 'limit' - Default is -1 (integer) or show all. The amount of bookmarks to142 * display.143 * 'category' - Default is empty string (string). Include the links in what144 * category ID(s).145 * 'category_name' - Default is empty string (string). Get links by category146 * name.147 * 'hide_invisible' - Default is 1 (integer). Whether to show (default) or hide148 * links marked as 'invisible'.149 * 'show_updated' - Default is 0 (integer). Will show the time of when the150 * bookmark was last updated.151 * 'echo' - Default is 1 (integer). Whether to echo (default) or return the152 * formatted bookmarks.153 * 'categorize' - Default is 1 (integer). Whether to show links listed by154 * category (default) or show links in one column.155 * 'show_description' - Default is 0 (integer). Whether to show the description156 * of the bookmark.157 *158 * These options define how the Category name will appear before the category159 * links are displayed, if 'categorize' is 1. If 'categorize' is 0, then it will160 * display for only the 'title_li' string and only if 'title_li' is not empty.161 * 'title_li' - Default is 'Bookmarks' (translatable string). What to show162 * before the links appear.163 * 'title_before' - Default is '<h2>' (string). The HTML or text to show before164 * the 'title_li' string.165 * 'title_after' - Default is '</h2>' (string). The HTML or text to show after166 * the 'title_li' string.167 * 'class' - Default is 'linkcat' (string). The CSS class to use for the168 * 'title_li'.169 *170 * 'category_before' - Default is '<li id="%id" class="%class">'. String must171 * contain '%id' and '%class' to get172 * the id of the category and the 'class' argument. These are used for173 * formatting in themes.174 * Argument will be displayed before the 'title_before' argument.175 * 'category_after' - Default is '</li>' (string). The HTML or text that will176 * appear after the list of links.177 *178 * These are only used if 'categorize' is set to 1 or true.179 * 'category_orderby' - Default is 'name'. How to order the bookmark category180 * based on term scheme.181 * 'category_order' - Default is 'ASC'. Set the order by either ASC (ascending)182 * or DESC (descending).183 *184 * @see _walk_bookmarks() For other arguments that can be set in this function185 * and passed to _walk_bookmarks().186 * @see get_bookmarks() For other arguments that can be set in this function and187 * passed to get_bookmarks().188 * @link http://codex.wordpress.org/Template_Tags/wp_list_bookmarks189 *190 * @since 2.1.0191 * @uses _walk_bookmarks() Used to iterate over all of the bookmarks and return192 * the html193 * @uses get_terms() Gets all of the categories that are for links.194 *195 * @param string|array $args Optional. Overwrite the defaults of the function196 * @return string|null Will only return if echo option is set to not echo.197 * Default is not return anything.198 */199 function wp_list_bookmarks($args = '') {200 $defaults = array(201 'orderby' => 'name', 'order' => 'ASC',202 'limit' => -1, 'category' => '', 'exclude_category' => '',203 'category_name' => '', 'hide_invisible' => 1,204 'show_updated' => 0, 'echo' => 1,205 'categorize' => 1, 'title_li' => __('Bookmarks'),206 'title_before' => '<h2>', 'title_after' => '</h2>',207 'category_orderby' => 'name', 'category_order' => 'ASC',208 'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',209 'category_after' => '</li>'210 );211 212 $r = wp_parse_args( $args, $defaults );213 extract( $r, EXTR_SKIP );214 215 $output = '';216 217 if ( $categorize ) {218 //Split the bookmarks into ul's for each category219 $cats = get_terms('link_category', array('name__like' => $category_name, 'include' => $category, 'exclude' => $exclude_category, 'orderby' => $category_orderby, 'order' => $category_order, 'hierarchical' => 0));220 221 foreach ( (array) $cats as $cat ) {222 $params = array_merge($r, array('category'=>$cat->term_id));223 $bookmarks = get_bookmarks($params);224 if ( empty($bookmarks) )225 continue;226 $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->term_id", $class), $category_before);227 $catname = apply_filters( "link_category", $cat->name );228 $output .= "$title_before$catname$title_after\n\t<ul class='xoxo blogroll'>\n";229 $output .= _walk_bookmarks($bookmarks, $r);230 $output .= "\n\t</ul>\n$category_after\n";231 }232 } else {233 //output one single list using title_li for the title234 $bookmarks = get_bookmarks($r);235 236 if ( !empty($bookmarks) ) {237 if ( !empty( $title_li ) ){238 $output .= str_replace(array('%id', '%class'), array("linkcat-$category", $class), $category_before);239 $output .= "$title_before$title_li$title_after\n\t<ul class='xoxo blogroll'>\n";240 $output .= _walk_bookmarks($bookmarks, $r);241 $output .= "\n\t</ul>\n$category_after\n";242 } else {243 $output .= _walk_bookmarks($bookmarks, $r);244 }245 }246 }247 248 $output = apply_filters( 'wp_list_bookmarks', $output );249 250 if ( !$echo )251 return $output;252 echo $output;253 } -
wp-includes/bookmark.php
1 <?php2 /**3 * Link/Bookmark API4 *5 * @package WordPress6 * @subpackage Bookmark7 */8 9 /**10 * Retrieve Bookmark data11 *12 * @since 2.1.013 * @uses $wpdb Database Object14 *15 * @param mixed $bookmark16 * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant17 * @param string $filter Optional, default is 'raw'.18 * @return array|object Type returned depends on $output value.19 */20 function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw') {21 global $wpdb;22 23 if ( empty($bookmark) ) {24 if ( isset($GLOBALS['link']) )25 $_bookmark = & $GLOBALS['link'];26 else27 $_bookmark = null;28 } elseif ( is_object($bookmark) ) {29 wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');30 $_bookmark = $bookmark;31 } else {32 if ( isset($GLOBALS['link']) && ($GLOBALS['link']->link_id == $bookmark) ) {33 $_bookmark = & $GLOBALS['link'];34 } elseif ( ! $_bookmark = wp_cache_get($bookmark, 'bookmark') ) {35 $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark));36 $_bookmark->link_category = array_unique( wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')) );37 wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');38 }39 }40 41 $_bookmark = sanitize_bookmark($_bookmark, $filter);42 43 if ( $output == OBJECT ) {44 return $_bookmark;45 } elseif ( $output == ARRAY_A ) {46 return get_object_vars($_bookmark);47 } elseif ( $output == ARRAY_N ) {48 return array_values(get_object_vars($_bookmark));49 } else {50 return $_bookmark;51 }52 }53 54 /**55 * Retrieve single bookmark data item or field.56 *57 * @since 2.3.058 * @uses get_bookmark() Gets bookmark object using $bookmark as ID59 * @uses sanitize_bookmark_field() Sanitizes Bookmark field based on $context.60 *61 * @param string $field The name of the data field to return62 * @param int $bookmark The bookmark ID to get field63 * @param string $context Optional. The context of how the field will be used.64 * @return string65 */66 function get_bookmark_field( $field, $bookmark, $context = 'display' ) {67 $bookmark = (int) $bookmark;68 $bookmark = get_bookmark( $bookmark );69 70 if ( is_wp_error($bookmark) )71 return $bookmark;72 73 if ( !is_object($bookmark) )74 return '';75 76 if ( !isset($bookmark->$field) )77 return '';78 79 return sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context);80 }81 82 /**83 * Retrieves the list of bookmarks84 *85 * Attempts to retrieve from the cache first based on MD5 hash of arguments. If86 * that fails, then the query will be built from the arguments and executed. The87 * results will be stored to the cache.88 *89 * List of default arguments are as follows:90 * 'orderby' - Default is 'name' (string). How to order the links by. String is91 * based off of the bookmark scheme.92 * 'order' - Default is 'ASC' (string). Either 'ASC' or 'DESC'. Orders in either93 * ascending or descending order.94 * 'limit' - Default is -1 (integer) or show all. The amount of bookmarks to95 * display.96 * 'category' - Default is empty string (string). Include the links in what97 * category ID(s).98 * 'category_name' - Default is empty string (string). Get links by category99 * name.100 * 'hide_invisible' - Default is 1 (integer). Whether to show (default) or hide101 * links marked as 'invisible'.102 * 'show_updated' - Default is 0 (integer). Will show the time of when the103 * bookmark was last updated.104 * 'include' - Default is empty string (string). Include bookmark ID(s)105 * separated by commas.106 * 'exclude' - Default is empty string (string). Exclude bookmark ID(s)107 * separated by commas.108 *109 * @since 2.1.0110 * @uses $wpdb Database Object111 * @link http://codex.wordpress.org/Template_Tags/get_bookmarks112 *113 * @param string|array $args List of arguments to overwrite the defaults114 * @return array List of bookmark row objects115 */116 function get_bookmarks($args = '') {117 global $wpdb;118 119 $defaults = array(120 'orderby' => 'name', 'order' => 'ASC',121 'limit' => -1, 'category' => '',122 'category_name' => '', 'hide_invisible' => 1,123 'show_updated' => 0, 'include' => '',124 'exclude' => '', 'search' => ''125 );126 127 $r = wp_parse_args( $args, $defaults );128 extract( $r, EXTR_SKIP );129 130 $cache = array();131 $key = md5( serialize( $r ) );132 if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {133 if ( is_array($cache) && isset( $cache[ $key ] ) )134 return apply_filters('get_bookmarks', $cache[ $key ], $r );135 }136 137 if ( !is_array($cache) )138 $cache = array();139 140 $inclusions = '';141 if ( !empty($include) ) {142 $exclude = ''; //ignore exclude, category, and category_name params if using include143 $category = '';144 $category_name = '';145 $inclinks = preg_split('/[\s,]+/',$include);146 if ( count($inclinks) ) {147 foreach ( $inclinks as $inclink ) {148 if (empty($inclusions))149 $inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';150 else151 $inclusions .= ' OR link_id = ' . intval($inclink) . ' ';152 }153 }154 }155 if (!empty($inclusions))156 $inclusions .= ')';157 158 $exclusions = '';159 if ( !empty($exclude) ) {160 $exlinks = preg_split('/[\s,]+/',$exclude);161 if ( count($exlinks) ) {162 foreach ( $exlinks as $exlink ) {163 if (empty($exclusions))164 $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';165 else166 $exclusions .= ' AND link_id <> ' . intval($exlink) . ' ';167 }168 }169 }170 if (!empty($exclusions))171 $exclusions .= ')';172 173 if ( !empty($category_name) ) {174 if ( $category = get_term_by('name', $category_name, 'link_category') ) {175 $category = $category->term_id;176 } else {177 $cache[ $key ] = array();178 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );179 return apply_filters( 'get_bookmarks', array(), $r );180 }181 }182 183 if ( ! empty($search) ) {184 $search = like_escape($search);185 $search = " AND ( (link_url LIKE '%$search%') OR (link_name LIKE '%$search%') OR (link_description LIKE '%$search%') ) ";186 }187 188 $category_query = '';189 $join = '';190 if ( !empty($category) ) {191 $incategories = preg_split('/[\s,]+/',$category);192 if ( count($incategories) ) {193 foreach ( $incategories as $incat ) {194 if (empty($category_query))195 $category_query = ' AND ( tt.term_id = ' . intval($incat) . ' ';196 else197 $category_query .= ' OR tt.term_id = ' . intval($incat) . ' ';198 }199 }200 }201 if (!empty($category_query)) {202 $category_query .= ") AND taxonomy = 'link_category'";203 $join = " INNER JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id) INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id";204 }205 206 if ( $show_updated && get_option('links_recently_updated_time') ) {207 $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_option('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";208 } else {209 $recently_updated_test = '';210 }211 212 $get_updated = ( $show_updated ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : '';213 214 $orderby = strtolower($orderby);215 $length = '';216 switch ( $orderby ) {217 case 'length':218 $length = ", CHAR_LENGTH(link_name) AS length";219 break;220 case 'rand':221 $orderby = 'rand()';222 break;223 case 'link_id':224 $orderby = "$wpdb->links.link_id";225 break;226 default:227 $orderparams = array();228 foreach ( explode(',', $orderby) as $ordparam ) {229 $ordparam = trim($ordparam);230 $keys = array( 'link_id', 'link_name', 'link_url', 'link_visible', 'link_rating', 'link_owner', 'link_updated', 'link_notes' );231 if ( in_array( 'link_' . $ordparam, $keys ) )232 $orderparams[] = 'link_' . $ordparam;233 elseif ( in_array( $ordparam, $keys ) )234 $orderparams[] = $ordparam;235 }236 $orderby = implode(',', $orderparams);237 }238 239 if ( empty( $orderby ) )240 $orderby = 'link_name';241 242 $order = strtoupper( $order );243 if ( '' !== $order && !in_array( $order, array( 'ASC', 'DESC' ) ) )244 $order = 'ASC';245 246 $visible = '';247 if ( $hide_invisible )248 $visible = "AND link_visible = 'Y'";249 250 $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";251 $query .= " $exclusions $inclusions $search";252 $query .= " ORDER BY $orderby $order";253 if ($limit != -1)254 $query .= " LIMIT $limit";255 256 $results = $wpdb->get_results($query);257 258 $cache[ $key ] = $results;259 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );260 261 return apply_filters('get_bookmarks', $results, $r);262 }263 264 /**265 * Sanitizes all bookmark fields266 *267 * @since 2.3.0268 *269 * @param object|array $bookmark Bookmark row270 * @param string $context Optional, default is 'display'. How to filter the271 * fields272 * @return object|array Same type as $bookmark but with fields sanitized.273 */274 function sanitize_bookmark($bookmark, $context = 'display') {275 $fields = array('link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category',276 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated',277 'link_rel', 'link_notes', 'link_rss', );278 279 if ( is_object($bookmark) ) {280 $do_object = true;281 $link_id = $bookmark->link_id;282 } else {283 $do_object = false;284 $link_id = $bookmark['link_id'];285 }286 287 foreach ( $fields as $field ) {288 if ( $do_object ) {289 if ( isset($bookmark->$field) )290 $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $link_id, $context);291 } else {292 if ( isset($bookmark[$field]) )293 $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $link_id, $context);294 }295 }296 297 return $bookmark;298 }299 300 /**301 * Sanitizes a bookmark field302 *303 * Sanitizes the bookmark fields based on what the field name is. If the field304 * has a strict value set, then it will be tested for that, else a more generic305 * filtering is applied. After the more strict filter is applied, if the306 * $context is 'raw' then the value is immediately return.307 *308 * Hooks exist for the more generic cases. With the 'edit' context, the309 * 'edit_$field' filter will be called and passed the $value and $bookmark_id310 * respectively. With the 'db' context, the 'pre_$field' filter is called and311 * passed the value. The 'display' context is the final context and has the312 * $field has the filter name and is passed the $value, $bookmark_id, and313 * $context respectively.314 *315 * @since 2.3.0316 *317 * @param string $field The bookmark field318 * @param mixed $value The bookmark field value319 * @param int $bookmark_id Bookmark ID320 * @param string $context How to filter the field value. Either 'raw', 'edit',321 * 'attribute', 'js', 'db', or 'display'322 * @return mixed The filtered value323 */324 function sanitize_bookmark_field($field, $value, $bookmark_id, $context) {325 switch ( $field ) {326 case 'link_id' : // ints327 case 'link_rating' :328 $value = (int) $value;329 break;330 case 'link_category' : // array( ints )331 $value = array_map('absint', (array) $value);332 // We return here so that the categories aren't filtered.333 // The 'link_category' filter is for the name of a link category, not an array of a link's link categories334 return $value;335 break;336 case 'link_visible' : // bool stored as Y|N337 $value = preg_replace('/[^YNyn]/', '', $value);338 break;339 case 'link_target' : // "enum"340 $targets = array('_top', '_blank');341 if ( ! in_array($value, $targets) )342 $value = '';343 break;344 }345 346 if ( 'raw' == $context )347 return $value;348 349 if ( 'edit' == $context ) {350 $value = apply_filters("edit_$field", $value, $bookmark_id);351 352 if ( 'link_notes' == $field ) {353 $value = esc_html( $value ); // textarea_escaped354 } else {355 $value = esc_attr($value);356 }357 } else if ( 'db' == $context ) {358 $value = apply_filters("pre_$field", $value);359 } else {360 // Use display filters by default.361 $value = apply_filters($field, $value, $bookmark_id, $context);362 363 if ( 'attribute' == $context )364 $value = esc_attr($value);365 else if ( 'js' == $context )366 $value = esc_js($value);367 }368 369 return $value;370 }371 372 /**373 * Deletes bookmark cache374 *375 * @since 2.7.0376 * @uses wp_cache_delete() Deletes the contents of 'get_bookmarks'377 */378 function clean_bookmark_cache( $bookmark_id ) {379 wp_cache_delete( $bookmark_id, 'bookmark' );380 wp_cache_delete( 'get_bookmarks', 'bookmark' );381 clean_object_term_cache( $bookmark_id, 'link');382 } -
wp-includes/link-template.php
1015 1015 echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; 1016 1016 } 1017 1017 1018 /**1019 * Display edit bookmark (literally a URL external to blog) link.1020 *1021 * @since 2.7.01022 *1023 * @param int $link Optional. Bookmark ID.1024 * @return string1025 */1026 function get_edit_bookmark_link( $link = 0 ) {1027 $link = get_bookmark( $link );1028 1029 if ( !current_user_can('manage_links') )1030 return;1031 1032 $location = admin_url('link.php?action=edit&link_id=') . $link->link_id;1033 return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id );1034 }1035 1036 /**1037 * Display edit bookmark (literally a URL external to blog) link anchor content.1038 *1039 * @since 2.7.01040 *1041 * @param string $link Optional. Anchor text.1042 * @param string $before Optional. Display before edit link.1043 * @param string $after Optional. Display after edit link.1044 * @param int $bookmark Optional. Bookmark ID.1045 */1046 function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) {1047 $bookmark = get_bookmark($bookmark);1048 1049 if ( !current_user_can('manage_links') )1050 return;1051 1052 if ( empty($link) )1053 $link = __('Edit This');1054 1055 $link = '<a href="' . get_edit_bookmark_link( $bookmark ) . '" title="' . esc_attr__( 'Edit Link' ) . '">' . $link . '</a>';1056 echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after;1057 }1058 1059 1018 // Navigation links 1060 1019 1061 1020 /** -
wp-includes/formatting.php
2746 2746 case 'rss_excerpt_length': 2747 2747 case 'default_category': 2748 2748 case 'default_email_category': 2749 case 'default_link_category':2750 2749 case 'close_comments_days_old': 2751 2750 case 'comments_per_page': 2752 2751 case 'thread_comments_depth': -
wp-includes/deprecated.php
384 384 } 385 385 386 386 /** 387 * Gets the links associated with category $cat_name.388 *389 * @since 0.71390 * @deprecated 2.1391 * @deprecated Use get_bookmarks()392 * @see get_bookmarks()393 *394 * @param string $cat_name Optional. The category name to use. If no match is found uses all.395 * @param string $before Optional. The html to output before the link.396 * @param string $after Optional. The html to output after the link.397 * @param string $between Optional. The html to output between the link/image and it's description. Not used if no image or $show_images is true.398 * @param bool $show_images Optional. Whether to show images (if defined).399 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner.400 * If you start the name with an underscore the order will be reversed. You can also specify 'rand' as the order which will return links in a401 * random order.402 * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.403 * @param bool $show_rating Optional. Show rating stars/chars.404 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.405 * @param int $show_updated Optional. Whether to show last updated timestamp406 */407 function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id',408 $show_description = true, $show_rating = false,409 $limit = -1, $show_updated = 0) {410 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );411 412 $cat_id = -1;413 $cat = get_term_by('name', $cat_name, 'link_category');414 if ( $cat )415 $cat_id = $cat->term_id;416 417 get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated);418 }419 420 /**421 * Gets the links associated with the named category.422 *423 * @since 1.0.1424 * @deprecated 2.1425 * @deprecated Use wp_list_bookmarks()426 * @see wp_list_bookmarks()427 *428 * @param string $category The category to use.429 * @param string $args430 * @return bool|null431 */432 function wp_get_linksbyname($category, $args = '') {433 _deprecated_function(__FUNCTION__, '2.1', 'wp_list_bookmarks()');434 435 $defaults = array(436 'after' => '<br />',437 'before' => '',438 'categorize' => 0,439 'category_after' => '',440 'category_before' => '',441 'category_name' => $category,442 'show_description' => 1,443 'title_li' => '',444 );445 446 $r = wp_parse_args( $args, $defaults );447 448 return wp_list_bookmarks($r);449 }450 451 /**452 * Gets an array of link objects associated with category $cat_name.453 *454 * <code>455 * $links = get_linkobjectsbyname('fred');456 * foreach ($links as $link) {457 * echo '<li>'.$link->link_name.'</li>';458 * }459 * </code>460 *461 * @since 1.0.1462 * @deprecated 2.1463 * @deprecated Use get_bookmarks()464 * @see get_bookmarks()465 *466 * @param string $cat_name The category name to use. If no match is found uses all.467 * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', 'description', or 'rating'.468 * Or maybe owner. If you start the name with an underscore the order will be reversed. You can also469 * specify 'rand' as the order which will return links in a random order.470 * @param int $limit Limit to X entries. If not specified, all entries are shown.471 * @return unknown472 */473 function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {474 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );475 476 $cat_id = -1;477 $cat = get_term_by('name', $cat_name, 'link_category');478 if ( $cat )479 $cat_id = $cat->term_id;480 481 return get_linkobjects($cat_id, $orderby, $limit);482 }483 484 /**485 * Gets an array of link objects associated with category n.486 *487 * Usage:488 * <code>489 * $links = get_linkobjects(1);490 * if ($links) {491 * foreach ($links as $link) {492 * echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';493 * }494 * }495 * </code>496 *497 * Fields are:498 * <ol>499 * <li>link_id</li>500 * <li>link_url</li>501 * <li>link_name</li>502 * <li>link_image</li>503 * <li>link_target</li>504 * <li>link_category</li>505 * <li>link_description</li>506 * <li>link_visible</li>507 * <li>link_owner</li>508 * <li>link_rating</li>509 * <li>link_updated</li>510 * <li>link_rel</li>511 * <li>link_notes</li>512 * </ol>513 *514 * @since 1.0.1515 * @deprecated 2.1516 * @deprecated Use get_bookmarks()517 * @see get_bookmarks()518 *519 * @param int $category The category to use. If no category supplied uses all520 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',521 * 'description', or 'rating'. Or maybe owner. If you start the name with an522 * underscore the order will be reversed. You can also specify 'rand' as the523 * order which will return links in a random order.524 * @param int $limit Limit to X entries. If not specified, all entries are shown.525 * @return unknown526 */527 function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) {528 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );529 530 $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ;531 532 $links_array = array();533 foreach ($links as $link)534 $links_array[] = $link;535 536 return $links_array;537 }538 539 /**540 * Gets the links associated with category 'cat_name' and display rating stars/chars.541 *542 * @since 0.71543 * @deprecated 2.1544 * @deprecated Use get_bookmarks()545 * @see get_bookmarks()546 *547 * @param string $cat_name The category name to use. If no match is found uses all548 * @param string $before The html to output before the link549 * @param string $after The html to output after the link550 * @param string $between The html to output between the link/image and it's description. Not used if no image or show_images is true551 * @param bool $show_images Whether to show images (if defined).552 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',553 * 'description', or 'rating'. Or maybe owner. If you start the name with an554 * underscore the order will be reversed. You can also specify 'rand' as the555 * order which will return links in a random order.556 * @param bool $show_description Whether to show the description if show_images=false/not defined557 * @param int $limit Limit to X entries. If not specified, all entries are shown.558 * @param int $show_updated Whether to show last updated timestamp559 */560 function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ",561 $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {562 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );563 564 get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);565 }566 567 /**568 * Gets the links associated with category n and display rating stars/chars.569 *570 * @since 0.71571 * @deprecated 2.1572 * @deprecated Use get_bookmarks()573 * @see get_bookmarks()574 *575 * @param int $category The category to use. If no category supplied uses all576 * @param string $before The html to output before the link577 * @param string $after The html to output after the link578 * @param string $between The html to output between the link/image and it's description. Not used if no image or show_images == true579 * @param bool $show_images Whether to show images (if defined).580 * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url',581 * 'description', or 'rating'. Or maybe owner. If you start the name with an582 * underscore the order will be reversed. You can also specify 'rand' as the583 * order which will return links in a random order.584 * @param bool $show_description Whether to show the description if show_images=false/not defined.585 * @param string $limit Limit to X entries. If not specified, all entries are shown.586 * @param int $show_updated Whether to show last updated timestamp587 */588 function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true,589 $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {590 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );591 592 get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);593 }594 595 /**596 387 * Gets the auto_toggle setting. 597 388 * 598 389 * @since 0.71 … … 880 671 } 881 672 882 673 /** 883 * Gets the links associated with category.884 *885 * @see get_links() for argument information that can be used in $args886 * @since 1.0.1887 * @deprecated 2.1888 * @deprecated Use wp_list_bookmarks()889 * @see wp_list_bookmarks()890 *891 * @param string $args a query string892 * @return null|string893 */894 function wp_get_links($args = '') {895 _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' );896 897 if ( strpos( $args, '=' ) === false ) {898 $cat_id = $args;899 $args = add_query_arg( 'category', $cat_id, $args );900 }901 902 $defaults = array(903 'after' => '<br />',904 'before' => '',905 'between' => ' ',906 'categorize' => 0,907 'category' => '',908 'echo' => true,909 'limit' => -1,910 'orderby' => 'name',911 'show_description' => true,912 'show_images' => true,913 'show_rating' => false,914 'show_updated' => true,915 'title_li' => '',916 );917 918 $r = wp_parse_args( $args, $defaults );919 920 return wp_list_bookmarks($r);921 }922 923 /**924 * Gets the links associated with category by id.925 *926 * @since 0.71927 * @deprecated 2.1928 * @deprecated Use get_bookmarks()929 * @see get_bookmarks()930 *931 * @param int $category The category to use. If no category supplied uses all932 * @param string $before the html to output before the link933 * @param string $after the html to output after the link934 * @param string $between the html to output between the link/image and its description.935 * Not used if no image or show_images == true936 * @param bool $show_images whether to show images (if defined).937 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',938 * 'description', or 'rating'. Or maybe owner. If you start the name with an939 * underscore the order will be reversed. You can also specify 'rand' as the order940 * which will return links in a random order.941 * @param bool $show_description whether to show the description if show_images=false/not defined.942 * @param bool $show_rating show rating stars/chars943 * @param int $limit Limit to X entries. If not specified, all entries are shown.944 * @param int $show_updated whether to show last updated timestamp945 * @param bool $echo whether to echo the results, or return them instead946 * @return null|string947 */948 function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name',949 $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) {950 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );951 952 $order = 'ASC';953 if ( substr($orderby, 0, 1) == '_' ) {954 $order = 'DESC';955 $orderby = substr($orderby, 1);956 }957 958 if ( $category == -1 ) //get_bookmarks uses '' to signify all categories959 $category = '';960 961 $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit));962 963 if ( !$results )964 return;965 966 $output = '';967 968 foreach ( (array) $results as $row ) {969 if ( !isset($row->recently_updated) )970 $row->recently_updated = false;971 $output .= $before;972 if ( $show_updated && $row->recently_updated )973 $output .= get_option('links_recently_updated_prepend');974 $the_link = '#';975 if ( !empty($row->link_url) )976 $the_link = esc_url($row->link_url);977 $rel = $row->link_rel;978 if ( '' != $rel )979 $rel = ' rel="' . $rel . '"';980 981 $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display'));982 $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display'));983 $title = $desc;984 985 if ( $show_updated )986 if (substr($row->link_updated_f, 0, 2) != '00')987 $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')';988 989 if ( '' != $title )990 $title = ' title="' . $title . '"';991 992 $alt = ' alt="' . $name . '"';993 994 $target = $row->link_target;995 if ( '' != $target )996 $target = ' target="' . $target . '"';997 998 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';999 1000 if ( $row->link_image != null && $show_images ) {1001 if ( strpos($row->link_image, 'http') !== false )1002 $output .= "<img src=\"$row->link_image\" $alt $title />";1003 else // If it's a relative path1004 $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />";1005 } else {1006 $output .= $name;1007 }1008 1009 $output .= '</a>';1010 1011 if ( $show_updated && $row->recently_updated )1012 $output .= get_option('links_recently_updated_append');1013 1014 if ( $show_description && '' != $desc )1015 $output .= $between . $desc;1016 1017 if ($show_rating) {1018 $output .= $between . get_linkrating($row);1019 }1020 1021 $output .= "$after\n";1022 } // end while1023 1024 if ( !$echo )1025 return $output;1026 echo $output;1027 }1028 1029 /**1030 * Output entire list of links by category.1031 *1032 * Output a list of all links, listed by category, using the settings in1033 * $wpdb->linkcategories and output it as a nested HTML unordered list.1034 *1035 * @since 1.0.11036 * @deprecated 2.11037 * @deprecated Use wp_list_bookmarks()1038 * @see wp_list_bookmarks()1039 *1040 * @param string $order Sort link categories by 'name' or 'id'1041 */1042 function get_links_list($order = 'name') {1043 _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' );1044 1045 $order = strtolower($order);1046 1047 // Handle link category sorting1048 $direction = 'ASC';1049 if ( '_' == substr($order,0,1) ) {1050 $direction = 'DESC';1051 $order = substr($order,1);1052 }1053 1054 if ( !isset($direction) )1055 $direction = '';1056 1057 $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0));1058 1059 // Display each category1060 if ( $cats ) {1061 foreach ( (array) $cats as $cat ) {1062 // Handle each category.1063 1064 // Display the category name1065 echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n";1066 // Call get_links() with all the appropriate params1067 get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false);1068 1069 // Close the last category1070 echo "\n\t</ul>\n</li>\n";1071 }1072 }1073 }1074 1075 /**1076 * Show the link to the links popup and the number of links.1077 *1078 * @since 0.711079 * @deprecated 2.11080 * @deprecated {@internal Use function instead is unknown}}1081 *1082 * @param string $text the text of the link1083 * @param int $width the width of the popup window1084 * @param int $height the height of the popup window1085 * @param string $file the page to open in the popup window1086 * @param bool $count the number of links in the db1087 */1088 function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) {1089 _deprecated_function( __FUNCTION__, '2.1' );1090 1091 if ( $count )1092 $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links");1093 1094 $javascript = "<a href=\"#\" onclick=\"javascript:window.open('$file?popup=1', '_blank', 'width=$width,height=$height,scrollbars=yes,status=no'); return false\">";1095 $javascript .= $text;1096 1097 if ( $count )1098 $javascript .= " ($counts)";1099 1100 $javascript .= "</a>\n\n";1101 echo $javascript;1102 }1103 1104 /**1105 * @since 1.0.11106 * @deprecated 2.11107 * @deprecated Use sanitize_bookmark_field()1108 * @see sanitize_bookmark_field()1109 *1110 * @param object $link1111 * @return unknown1112 */1113 function get_linkrating($link) {1114 _deprecated_function( __FUNCTION__, '2.1', 'sanitize_bookmark_field()' );1115 return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display');1116 }1117 1118 /**1119 * Gets the name of category by id.1120 *1121 * @since 0.711122 * @deprecated 2.11123 * @deprecated Use get_category()1124 * @see get_category()1125 *1126 * @param int $id The category to get. If no category supplied uses 01127 * @return string1128 */1129 function get_linkcatname($id = 0) {1130 _deprecated_function( __FUNCTION__, '2.1', 'get_category()' );1131 1132 $id = (int) $id;1133 1134 if ( empty($id) )1135 return '';1136 1137 $cats = wp_get_link_cats($id);1138 1139 if ( empty($cats) || ! is_array($cats) )1140 return '';1141 1142 $cat_id = (int) $cats[0]; // Take the first cat.1143 1144 $cat = get_category($cat_id);1145 return $cat->name;1146 }1147 1148 /**1149 674 * Print RSS comment feed link. 1150 675 * 1151 676 * @since 1.0.1 … … 2035 1560 } 2036 1561 2037 1562 /** 2038 * Retrieve bookmark data based on ID.2039 *2040 * @since 2.0.02041 * @deprecated 2.1.02042 * @deprecated Use get_bookmark()2043 * @see get_bookmark()2044 *2045 * @param int $bookmark_id ID of link2046 * @param string $output OBJECT, ARRAY_N, or ARRAY_A2047 * @return object|array2048 */2049 function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') {2050 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmark()' );2051 return get_bookmark($bookmark_id, $output, $filter);2052 }2053 2054 /**2055 1563 * Performs esc_url() for database or redirect usage. 2056 1564 * 2057 1565 * @since 2.3.1 -
wp-includes/ms-functions.php
263 263 if ( $reassign != '' ) { 264 264 $reassign = (int) $reassign; 265 265 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id) ); 266 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id));266 do_action( 'reassign_user_data', $user_id, $reassign ); 267 267 } 268 268 269 269 restore_current_blog(); -
wp-includes/category-template.php
312 312 313 313 $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; 314 314 315 // Back compat. 316 if ( isset( $args['type'] ) && 'link' == $args['type'] ) { 317 _deprecated_argument( __FUNCTION__, '3.0', '' ); 318 $args['taxonomy'] = 'link_category'; 319 } 320 315 $args = apply_filters( 'dropdown_categories_args', $args ); 316 321 317 $r = wp_parse_args( $args, $defaults ); 322 318 323 319 if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { -
wp-content/plugins/link-manager/bookmark-template.php
1 <?php 2 /** 3 * Bookmark Template Functions for usage in Themes 4 * 5 * @package Link Manager 6 * @subpackage Template 7 */ 8 9 /** 10 * The formatted output of a list of bookmarks. 11 * 12 * The $bookmarks array must contain bookmark objects and will be iterated over 13 * to retrieve the bookmark to be used in the output. 14 * 15 * The output is formatted as HTML with no way to change that format. However, 16 * what is between, before, and after can be changed. The link itself will be 17 * HTML. 18 * 19 * This function is used internally by wp_list_bookmarks() and should not be 20 * used by themes. 21 * 22 * The defaults for overwriting are: 23 * 'show_updated' - Default is 0 (integer). Will show the time of when the 24 * bookmark was last updated. 25 * 'show_description' - Default is 0 (integer). Whether to show the description 26 * of the bookmark. 27 * 'show_images' - Default is 1 (integer). Whether to show link image if 28 * available. 29 * 'show_name' - Default is 0 (integer). Whether to show link name if 30 * available. 31 * 'before' - Default is '<li>' (string). The html or text to prepend to each 32 * bookmarks. 33 * 'after' - Default is '</li>' (string). The html or text to append to each 34 * bookmarks. 35 * 'link_before' - Default is '' (string). The html or text to prepend to each 36 * bookmarks inside the <a> tag. 37 * 'link_after' - Default is '' (string). The html or text to append to each 38 * bookmarks inside the <a> tag. 39 * 'between' - Default is '\n' (string). The string for use in between the link, 40 * description, and image. 41 * 'show_rating' - Default is 0 (integer). Whether to show the link rating. 42 * 43 * @since WP 2.1.0 44 * @access private 45 * 46 * @param array $bookmarks List of bookmarks to traverse 47 * @param string|array $args Optional. Overwrite the defaults. 48 * @return string Formatted output in HTML 49 */ 50 function _walk_bookmarks( $bookmarks, $args = '' ) { 51 $defaults = array( 52 'show_updated' => 0, 'show_description' => 0, 53 'show_images' => 1, 'show_name' => 0, 54 'before' => '<li>', 'after' => '</li>', 'between' => "\n", 55 'show_rating' => 0, 'link_before' => '', 'link_after' => '' 56 ); 57 58 $r = wp_parse_args( $args, $defaults ); 59 extract( $r, EXTR_SKIP ); 60 61 $output = ''; // Blank string to start with. 62 63 foreach ( (array) $bookmarks as $bookmark ) { 64 if ( !isset( $bookmark->recently_updated ) ) 65 $bookmark->recently_updated = false; 66 $output .= $before; 67 if ( $show_updated && $bookmark->recently_updated ) 68 $output .= get_option( 'links_recently_updated_prepend' ); 69 70 $the_link = '#'; 71 if ( !empty( $bookmark->link_url ) ) 72 $the_link = esc_url( $bookmark->link_url ); 73 74 $desc = esc_attr(sanitize_bookmark_field( 'link_description', $bookmark->link_description, $bookmark->link_id, 'display' )); 75 $name = esc_attr(sanitize_bookmark_field( 'link_name', $bookmark->link_name, $bookmark->link_id, 'display' )); 76 $title = $desc; 77 78 if ( $show_updated ) 79 if ( '00' != substr( $bookmark->link_updated_f, 0, 2) ) { 80 $title .= ' ( '; 81 $title .= sprintf(__( 'Last updated: %s' ), date(get_option( 'links_updated_date_format' ), $bookmark->link_updated_f + (get_option( 'gmt_offset' ) * 3600))); 82 $title .= ' )'; 83 } 84 85 $alt = ' alt="' . $name . ( $show_description ? ' ' . $title : '' ) . '"'; 86 87 if ( '' != $title ) 88 $title = ' title="' . $title . '"'; 89 90 $rel = $bookmark->link_rel; 91 if ( '' != $rel ) 92 $rel = ' rel="' . esc_attr( $rel ) . '"'; 93 94 $target = $bookmark->link_target; 95 if ( '' != $target ) 96 $target = ' target="' . $target . '"'; 97 98 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>'; 99 100 $output .= $link_before; 101 102 if ( $bookmark->link_image != null && $show_images ) { 103 if ( strpos( $bookmark->link_image, 'http' ) === 0 ) 104 $output .= "<img src=\"$bookmark->link_image\" $alt $title />"; 105 else // If it's a relative path 106 $output .= "<img src=\"" . get_option( 'siteurl' ) . "$bookmark->link_image\" $alt $title />"; 107 108 if ( $show_name ) 109 $output .= " $name"; 110 } else { 111 $output .= $name; 112 } 113 114 $output .= $link_after; 115 116 $output .= '</a>'; 117 118 if ( $show_updated && $bookmark->recently_updated ) 119 $output .= get_option( 'links_recently_updated_append' ); 120 121 if ( $show_description && '' != $desc ) 122 $output .= $between . $desc; 123 124 if ( $show_rating ) 125 $output .= $between . sanitize_bookmark_field( 'link_rating', $bookmark->link_rating, $bookmark->link_id, 'display' ); 126 127 $output .= "$after\n"; 128 } // end while 129 130 return $output; 131 } 132 133 /** 134 * Retrieve or echo all of the bookmarks. 135 * 136 * List of default arguments are as follows: 137 * 'orderby' - Default is 'name' (string). How to order the links by. String is 138 * based off of the bookmark scheme. 139 * 'order' - Default is 'ASC' (string). Either 'ASC' or 'DESC'. Orders in either 140 * ascending or descending order. 141 * 'limit' - Default is -1 (integer) or show all. The amount of bookmarks to 142 * display. 143 * 'category' - Default is empty string (string). Include the links in what 144 * category ID(s). 145 * 'category_name' - Default is empty string (string). Get links by category 146 * name. 147 * 'hide_invisible' - Default is 1 (integer). Whether to show (default) or hide 148 * links marked as 'invisible'. 149 * 'show_updated' - Default is 0 (integer). Will show the time of when the 150 * bookmark was last updated. 151 * 'echo' - Default is 1 (integer). Whether to echo (default) or return the 152 * formatted bookmarks. 153 * 'categorize' - Default is 1 (integer). Whether to show links listed by 154 * category (default) or show links in one column. 155 * 'show_description' - Default is 0 (integer). Whether to show the description 156 * of the bookmark. 157 * 158 * These options define how the Category name will appear before the category 159 * links are displayed, if 'categorize' is 1. If 'categorize' is 0, then it will 160 * display for only the 'title_li' string and only if 'title_li' is not empty. 161 * 'title_li' - Default is 'Bookmarks' (translatable string). What to show 162 * before the links appear. 163 * 'title_before' - Default is '<h2>' (string). The HTML or text to show before 164 * the 'title_li' string. 165 * 'title_after' - Default is '</h2>' (string). The HTML or text to show after 166 * the 'title_li' string. 167 * 'class' - Default is 'linkcat' (string). The CSS class to use for the 168 * 'title_li'. 169 * 170 * 'category_before' - Default is '<li id="%id" class="%class">'. String must 171 * contain '%id' and '%class' to get 172 * the id of the category and the 'class' argument. These are used for 173 * formatting in themes. 174 * Argument will be displayed before the 'title_before' argument. 175 * 'category_after' - Default is '</li>' (string). The HTML or text that will 176 * appear after the list of links. 177 * 178 * These are only used if 'categorize' is set to 1 or true. 179 * 'category_orderby' - Default is 'name'. How to order the bookmark category 180 * based on term scheme. 181 * 'category_order' - Default is 'ASC'. Set the order by either ASC (ascending) 182 * or DESC (descending). 183 * 184 * @see _walk_bookmarks() For other arguments that can be set in this function 185 * and passed to _walk_bookmarks(). 186 * @see get_bookmarks() For other arguments that can be set in this function and 187 * passed to get_bookmarks(). 188 * @link http://codex.wordpress.org/Template_Tags/wp_list_bookmarks 189 * 190 * @since WP 2.1.0 191 * @uses _walk_bookmarks() Used to iterate over all of the bookmarks and return 192 * the html 193 * @uses get_terms() Gets all of the categories that are for links. 194 * 195 * @param string|array $args Optional. Overwrite the defaults of the function 196 * @return string|null Will only return if echo option is set to not echo. 197 * Default is not return anything. 198 */ 199 function wp_list_bookmarks( $args = '' ) { 200 $defaults = array( 201 'orderby' => 'name', 'order' => 'ASC', 202 'limit' => -1, 'category' => '', 'exclude_category' => '', 203 'category_name' => '', 'hide_invisible' => 1, 204 'show_updated' => 0, 'echo' => 1, 205 'categorize' => 1, 'title_li' => __( 'Bookmarks' ), 206 'title_before' => '<h2>', 'title_after' => '</h2>', 207 'category_orderby' => 'name', 'category_order' => 'ASC', 208 'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">', 209 'category_after' => '</li>' 210 ); 211 212 $r = wp_parse_args( $args, $defaults ); 213 extract( $r, EXTR_SKIP ); 214 215 $output = ''; 216 217 if ( $categorize ) { 218 //Split the bookmarks into ul's for each category 219 $cats = get_terms( 'link_category', array( 'name__like' => $category_name, 'include' => $category, 'exclude' => $exclude_category, 'orderby' => $category_orderby, 'order' => $category_order, 'hierarchical' => 0)); 220 221 foreach ( (array) $cats as $cat ) { 222 $params = array_merge( $r, array( 'category'=>$cat->term_id ) ); 223 $bookmarks = get_bookmarks( $params ); 224 if ( empty( $bookmarks ) ) 225 continue; 226 $output .= str_replace(array( '%id', '%class' ), array("linkcat-$cat->term_id", $class ), $category_before ); 227 $catname = apply_filters( "link_category", $cat->name ); 228 $output .= "$title_before$catname$title_after\n\t<ul class='xoxo blogroll'>\n"; 229 $output .= _walk_bookmarks( $bookmarks, $r ); 230 $output .= "\n\t</ul>\n$category_after\n"; 231 } 232 } else { 233 //output one single list using title_li for the title 234 $bookmarks = get_bookmarks( $r ); 235 236 if ( !empty( $bookmarks ) ) { 237 if ( !empty( $title_li ) ){ 238 $output .= str_replace(array( '%id', '%class' ), array("linkcat-$category", $class ), $category_before ); 239 $output .= "$title_before$title_li$title_after\n\t<ul class='xoxo blogroll'>\n"; 240 $output .= _walk_bookmarks( $bookmarks, $r ); 241 $output .= "\n\t</ul>\n$category_after\n"; 242 } else { 243 $output .= _walk_bookmarks( $bookmarks, $r ); 244 } 245 } 246 } 247 248 $output = apply_filters( 'wp_list_bookmarks', $output ); 249 250 if ( !$echo ) 251 return $output; 252 echo $output; 253 } -
wp-content/plugins/link-manager/deprecated.php
1 <?php 2 /** 3 * Gets the links associated with category $cat_name. 4 * 5 * @since WP 0.71 6 * @deprecated WP 2.1 7 * @deprecated WP Use get_bookmarks() 8 * @see get_bookmarks() 9 * 10 * @param string $cat_name Optional. The category name to use. If no match is found uses all. 11 * @param string $before Optional. The html to output before the link. 12 * @param string $after Optional. The html to output after the link. 13 * @param string $between Optional. The html to output between the link/image and it's description. Not used if no image or $show_images is true. 14 * @param bool $show_images Optional. Whether to show images (if defined). 15 * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner. 16 * If you start the name with an underscore the order will be reversed. You can also specify 'rand' as the order which will return links in a 17 * random order. 18 * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. 19 * @param bool $show_rating Optional. Show rating stars/chars. 20 * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. 21 * @param int $show_updated Optional. Whether to show last updated timestamp 22 */ 23 function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id', 24 $show_description = true, $show_rating = false, 25 $limit = -1, $show_updated = 0) { 26 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); 27 28 $cat_id = -1; 29 $cat = get_term_by('name', $cat_name, 'link_category'); 30 if ( $cat ) 31 $cat_id = $cat->term_id; 32 33 get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); 34 } 35 36 /** 37 * Gets the links associated with the named category. 38 * 39 * @since WP 1.0.1 40 * @deprecated WP 2.1 41 * @deprecated WP Use wp_list_bookmarks() 42 * @see wp_list_bookmarks() 43 * 44 * @param string $category The category to use. 45 * @param string $args 46 * @return bool|null 47 */ 48 function wp_get_linksbyname($category, $args = '') { 49 _deprecated_function(__FUNCTION__, '2.1', 'wp_list_bookmarks()'); 50 51 $defaults = array( 52 'after' => '<br />', 53 'before' => '', 54 'categorize' => 0, 55 'category_after' => '', 56 'category_before' => '', 57 'category_name' => $category, 58 'show_description' => 1, 59 'title_li' => '', 60 ); 61 62 $r = wp_parse_args( $args, $defaults ); 63 64 return wp_list_bookmarks($r); 65 } 66 67 /** 68 * Gets an array of link objects associated with category $cat_name. 69 * 70 * <code> 71 * $links = get_linkobjectsbyname('fred'); 72 * foreach ($links as $link) { 73 * echo '<li>'.$link->link_name.'</li>'; 74 * } 75 * </code> 76 * 77 * @since WP 1.0.1 78 * @deprecated WP 2.1 79 * @deprecated WP Use get_bookmarks() 80 * @see get_bookmarks() 81 * 82 * @param string $cat_name The category name to use. If no match is found uses all. 83 * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', 'description', or 'rating'. 84 * Or maybe owner. If you start the name with an underscore the order will be reversed. You can also 85 * specify 'rand' as the order which will return links in a random order. 86 * @param int $limit Limit to X entries. If not specified, all entries are shown. 87 * @return unknown 88 */ 89 function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { 90 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); 91 92 $cat_id = -1; 93 $cat = get_term_by('name', $cat_name, 'link_category'); 94 if ( $cat ) 95 $cat_id = $cat->term_id; 96 97 return get_linkobjects($cat_id, $orderby, $limit); 98 } 99 100 /** 101 * Gets an array of link objects associated with category n. 102 * 103 * Usage: 104 * <code> 105 * $links = get_linkobjects(1); 106 * if ($links) { 107 * foreach ($links as $link) { 108 * echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>'; 109 * } 110 * } 111 * </code> 112 * 113 * Fields are: 114 * <ol> 115 * <li>link_id</li> 116 * <li>link_url</li> 117 * <li>link_name</li> 118 * <li>link_image</li> 119 * <li>link_target</li> 120 * <li>link_category</li> 121 * <li>link_description</li> 122 * <li>link_visible</li> 123 * <li>link_owner</li> 124 * <li>link_rating</li> 125 * <li>link_updated</li> 126 * <li>link_rel</li> 127 * <li>link_notes</li> 128 * </ol> 129 * 130 * @since WP 1.0.1 131 * @deprecated WP 2.1 132 * @deprecated WP Use get_bookmarks() 133 * @see get_bookmarks() 134 * 135 * @param int $category The category to use. If no category supplied uses all 136 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', 137 * 'description', or 'rating'. Or maybe owner. If you start the name with an 138 * underscore the order will be reversed. You can also specify 'rand' as the 139 * order which will return links in a random order. 140 * @param int $limit Limit to X entries. If not specified, all entries are shown. 141 * @return unknown 142 */ 143 function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { 144 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); 145 146 $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; 147 148 $links_array = array(); 149 foreach ($links as $link) 150 $links_array[] = $link; 151 152 return $links_array; 153 } 154 155 /** 156 * Gets the links associated with category 'cat_name' and display rating stars/chars. 157 * 158 * @since WP 0.71 159 * @deprecated WP 2.1 160 * @deprecated WP Use get_bookmarks() 161 * @see get_bookmarks() 162 * 163 * @param string $cat_name The category name to use. If no match is found uses all 164 * @param string $before The html to output before the link 165 * @param string $after The html to output after the link 166 * @param string $between The html to output between the link/image and it's description. Not used if no image or show_images is true 167 * @param bool $show_images Whether to show images (if defined). 168 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', 169 * 'description', or 'rating'. Or maybe owner. If you start the name with an 170 * underscore the order will be reversed. You can also specify 'rand' as the 171 * order which will return links in a random order. 172 * @param bool $show_description Whether to show the description if show_images=false/not defined 173 * @param int $limit Limit to X entries. If not specified, all entries are shown. 174 * @param int $show_updated Whether to show last updated timestamp 175 */ 176 function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ", 177 $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { 178 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); 179 180 get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); 181 } 182 183 /** 184 * Gets the links associated with category n and display rating stars/chars. 185 * 186 * @since WP 0.71 187 * @deprecated WP 2.1 188 * @deprecated WP Use get_bookmarks() 189 * @see get_bookmarks() 190 * 191 * @param int $category The category to use. If no category supplied uses all 192 * @param string $before The html to output before the link 193 * @param string $after The html to output after the link 194 * @param string $between The html to output between the link/image and it's description. Not used if no image or show_images == true 195 * @param bool $show_images Whether to show images (if defined). 196 * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', 197 * 'description', or 'rating'. Or maybe owner. If you start the name with an 198 * underscore the order will be reversed. You can also specify 'rand' as the 199 * order which will return links in a random order. 200 * @param bool $show_description Whether to show the description if show_images=false/not defined. 201 * @param string $limit Limit to X entries. If not specified, all entries are shown. 202 * @param int $show_updated Whether to show last updated timestamp 203 */ 204 function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true, 205 $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { 206 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); 207 208 get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); 209 } 210 211 /** 212 * Gets the links associated with category. 213 * 214 * @see get_links() for argument information that can be used in $args 215 * @since WP 1.0.1 216 * @deprecated WP 2.1 217 * @deprecated WP Use wp_list_bookmarks() 218 * @see wp_list_bookmarks() 219 * 220 * @param string $args a query string 221 * @return null|string 222 */ 223 function wp_get_links($args = '') { 224 _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' ); 225 226 if ( strpos( $args, '=' ) === false ) { 227 $cat_id = $args; 228 $args = add_query_arg( 'category', $cat_id, $args ); 229 } 230 231 $defaults = array( 232 'after' => '<br />', 233 'before' => '', 234 'between' => ' ', 235 'categorize' => 0, 236 'category' => '', 237 'echo' => true, 238 'limit' => -1, 239 'orderby' => 'name', 240 'show_description' => true, 241 'show_images' => true, 242 'show_rating' => false, 243 'show_updated' => true, 244 'title_li' => '', 245 ); 246 247 $r = wp_parse_args( $args, $defaults ); 248 249 return wp_list_bookmarks($r); 250 } 251 252 /** 253 * Gets the links associated with category by id. 254 * 255 * @since WP 0.71 256 * @deprecated WP 2.1 257 * @deprecated WP Use get_bookmarks() 258 * @see get_bookmarks() 259 * 260 * @param int $category The category to use. If no category supplied uses all 261 * @param string $before the html to output before the link 262 * @param string $after the html to output after the link 263 * @param string $between the html to output between the link/image and its description. 264 * Not used if no image or show_images == true 265 * @param bool $show_images whether to show images (if defined). 266 * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', 267 * 'description', or 'rating'. Or maybe owner. If you start the name with an 268 * underscore the order will be reversed. You can also specify 'rand' as the order 269 * which will return links in a random order. 270 * @param bool $show_description whether to show the description if show_images=false/not defined. 271 * @param bool $show_rating show rating stars/chars 272 * @param int $limit Limit to X entries. If not specified, all entries are shown. 273 * @param int $show_updated whether to show last updated timestamp 274 * @param bool $echo whether to echo the results, or return them instead 275 * @return null|string 276 */ 277 function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name', 278 $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) { 279 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); 280 281 $order = 'ASC'; 282 if ( substr($orderby, 0, 1) == '_' ) { 283 $order = 'DESC'; 284 $orderby = substr($orderby, 1); 285 } 286 287 if ( $category == -1 ) //get_bookmarks uses '' to signify all categories 288 $category = ''; 289 290 $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); 291 292 if ( !$results ) 293 return; 294 295 $output = ''; 296 297 foreach ( (array) $results as $row ) { 298 if ( !isset($row->recently_updated) ) 299 $row->recently_updated = false; 300 $output .= $before; 301 if ( $show_updated && $row->recently_updated ) 302 $output .= get_option('links_recently_updated_prepend'); 303 $the_link = '#'; 304 if ( !empty($row->link_url) ) 305 $the_link = esc_url($row->link_url); 306 $rel = $row->link_rel; 307 if ( '' != $rel ) 308 $rel = ' rel="' . $rel . '"'; 309 310 $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); 311 $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); 312 $title = $desc; 313 314 if ( $show_updated ) 315 if (substr($row->link_updated_f, 0, 2) != '00') 316 $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')'; 317 318 if ( '' != $title ) 319 $title = ' title="' . $title . '"'; 320 321 $alt = ' alt="' . $name . '"'; 322 323 $target = $row->link_target; 324 if ( '' != $target ) 325 $target = ' target="' . $target . '"'; 326 327 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; 328 329 if ( $row->link_image != null && $show_images ) { 330 if ( strpos($row->link_image, 'http') !== false ) 331 $output .= "<img src=\"$row->link_image\" $alt $title />"; 332 else // If it's a relative path 333 $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; 334 } else { 335 $output .= $name; 336 } 337 338 $output .= '</a>'; 339 340 if ( $show_updated && $row->recently_updated ) 341 $output .= get_option('links_recently_updated_append'); 342 343 if ( $show_description && '' != $desc ) 344 $output .= $between . $desc; 345 346 if ($show_rating) { 347 $output .= $between . get_linkrating($row); 348 } 349 350 $output .= "$after\n"; 351 } // end while 352 353 if ( !$echo ) 354 return $output; 355 echo $output; 356 } 357 358 /** 359 * Output entire list of links by category. 360 * 361 * Output a list of all links, listed by category, using the settings in 362 * $wpdb->linkcategories and output it as a nested HTML unordered list. 363 * 364 * @since WP 1.0.1 365 * @deprecated WP 2.1 366 * @deprecated WP Use wp_list_bookmarks() 367 * @see wp_list_bookmarks() 368 * 369 * @param string $order Sort link categories by 'name' or 'id' 370 */ 371 function get_links_list($order = 'name') { 372 _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' ); 373 374 $order = strtolower($order); 375 376 // Handle link category sorting 377 $direction = 'ASC'; 378 if ( '_' == substr($order,0,1) ) { 379 $direction = 'DESC'; 380 $order = substr($order,1); 381 } 382 383 if ( !isset($direction) ) 384 $direction = ''; 385 386 $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); 387 388 // Display each category 389 if ( $cats ) { 390 foreach ( (array) $cats as $cat ) { 391 // Handle each category. 392 393 // Display the category name 394 echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n"; 395 // Call get_links() with all the appropriate params 396 get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false); 397 398 // Close the last category 399 echo "\n\t</ul>\n</li>\n"; 400 } 401 } 402 } 403 404 /** 405 * Show the link to the links popup and the number of links. 406 * 407 * @since WP 0.71 408 * @deprecated WP 2.1 409 * @deprecated WP {@internal Use function instead is unknown}} 410 * 411 * @param string $text the text of the link 412 * @param int $width the width of the popup window 413 * @param int $height the height of the popup window 414 * @param string $file the page to open in the popup window 415 * @param bool $count the number of links in the db 416 */ 417 function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { 418 _deprecated_function( __FUNCTION__, '2.1' ); 419 420 if ( $count ) 421 $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links"); 422 423 $javascript = "<a href=\"#\" onclick=\"javascript:window.open('$file?popup=1', '_blank', 'width=$width,height=$height,scrollbars=yes,status=no'); return false\">"; 424 $javascript .= $text; 425 426 if ( $count ) 427 $javascript .= " ($counts)"; 428 429 $javascript .= "</a>\n\n"; 430 echo $javascript; 431 } 432 433 /** 434 * @since WP 1.0.1 435 * @deprecated WP 2.1 436 * @deprecated WP Use sanitize_bookmark_field() 437 * @see sanitize_bookmark_field() 438 * 439 * @param object $link 440 * @return unknown 441 */ 442 function get_linkrating($link) { 443 _deprecated_function( __FUNCTION__, '2.1', 'sanitize_bookmark_field()' ); 444 return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); 445 } 446 447 /** 448 * Gets the name of category by id. 449 * 450 * @since WP 0.71 451 * @deprecated WP 2.1 452 * @deprecated WP Use get_category() 453 * @see get_category() 454 * 455 * @param int $id The category to get. If no category supplied uses 0 456 * @return string 457 */ 458 function get_linkcatname($id = 0) { 459 _deprecated_function( __FUNCTION__, '2.1', 'get_category()' ); 460 461 $id = (int) $id; 462 463 if ( empty($id) ) 464 return ''; 465 466 $cats = wp_get_link_cats($id); 467 468 if ( empty($cats) || ! is_array($cats) ) 469 return ''; 470 471 $cat_id = (int) $cats[0]; // Take the first cat. 472 473 $cat = get_category($cat_id); 474 return $cat->name; 475 } 476 477 /** 478 * Retrieve bookmark data based on ID. 479 * 480 * @since WP 2.0.0 481 * @deprecated WP 2.1.0 482 * @deprecated WP Use get_bookmark() 483 * @see get_bookmark() 484 * 485 * @param int $bookmark_id ID of link 486 * @param string $output OBJECT, ARRAY_N, or ARRAY_A 487 * @return object|array 488 */ 489 function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') { 490 _deprecated_function( __FUNCTION__, '2.1', 'get_bookmark()' ); 491 return get_bookmark($bookmark_id, $output, $filter); 492 } 493 494 /** 495 * {@internal Missing Short Description}} 496 * 497 * @since 2.1.0 498 * @deprecated 2.6.0 499 * @deprecated Use wp_link_category_checklist() 500 * @see wp_link_category_checklist() 501 * 502 * @param unknown_type $default 503 */ 504 function dropdown_link_categories( $default = 0 ) { 505 _deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' ); 506 global $link_id; 507 wp_link_category_checklist( $link_id ); 508 } 509 No newline at end of file -
wp-content/plugins/link-manager/admin/edit-link-form.php
1 <?php 2 /** 3 * Edit links form for inclusion in administration panels. 4 * 5 * @package Link Manager 6 * @subpackage Administration 7 */ 8 9 // don't load directly 10 if ( !defined( 'ABSPATH' ) ) 11 die('-1'); 12 13 $main_action = menu_page_url( 'link-manager.php', false ); 14 15 if ( ! empty( $link_id ) ) { 16 $heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), $main_action ); 17 $submit_text = __('Update Link'); 18 $form = '<form name="editlink" id="editlink" method="post" action="' . $main_action . '">'; 19 $nonce_action = 'update-bookmark_' . $link_id; 20 } else { 21 $heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), $main_action ); 22 $submit_text = __('Add Link'); 23 $form = '<form name="addlink" id="addlink" method="post" action="' . $main_action . '">'; 24 $nonce_action = 'add-bookmark'; 25 } 26 27 add_meta_box( 'linksubmitdiv', __('Save'), 'link_submit_meta_box', 'link', 'side', 'core' ); 28 add_meta_box( 'linkcategorydiv', __('Categories'), 'link_categories_meta_box', null, 'normal', 'core' ); 29 add_meta_box( 'linktargetdiv', __('Target'), 'link_target_meta_box', null, 'normal', 'core' ); 30 add_meta_box( 'linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', null, 'normal', 'core' ); 31 add_meta_box( 'linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', null, 'normal', 'core' ); 32 33 do_action( 'add_meta_boxes', 'link', $link ); 34 do_action( 'add_meta_boxes_link', $link ); 35 36 do_action( 'do_meta_boxes', 'link', 'normal', $link ); 37 do_action( 'do_meta_boxes', 'link', 'advanced', $link ); 38 do_action( 'do_meta_boxes', 'link', 'side', $link ); 39 40 ?> 41 42 <div class="wrap"> 43 <?php screen_icon(); ?> 44 <h2><?php echo esc_html( $title ); ?> <a href="<?php menu_page_url( 'link-add.php' ) ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'link' ) ?></a></h2> 45 46 <?php if ( isset( $_GET['added'] ) ) : ?> 47 <div id="message" class="updated"><p><?php _e( 'Link added.' ); ?></p></div> 48 <?php endif; ?> 49 50 <?php 51 if ( !empty( $form ) ) 52 echo $form; 53 if ( !empty( $link_added ) ) 54 echo $link_added; 55 56 wp_nonce_field( $nonce_action ); 57 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 58 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> 59 60 <div id="poststuff"> 61 62 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 63 <div id="post-body-content"> 64 <div id="namediv" class="stuffbox"> 65 <h3><label for="link_name"><?php _ex('Name', 'link name') ?></label></h3> 66 <div class="inside"> 67 <input type="text" name="link_name" size="30" value="<?php echo esc_attr( $link->link_name ); ?>" id="link_name" /> 68 <p><?php _e( 'Example: Nifty blogging software' ); ?></p> 69 </div> 70 </div> 71 72 <div id="addressdiv" class="stuffbox"> 73 <h3><label for="link_url"><?php _e('Web Address') ?></label></h3> 74 <div class="inside"> 75 <input type="text" name="link_url" size="30" class="code" value="<?php echo esc_attr( $link->link_url ); ?>" id="link_url" /> 76 <p><?php _e( 'Example: <code>http://wordpress.org/</code> — don’t forget the <code>http://</code>' ); ?></p> 77 </div> 78 </div> 79 80 <div id="descriptiondiv" class="stuffbox"> 81 <h3><label for="link_description"><?php _e('Description') ?></label></h3> 82 <div class="inside"> 83 <input type="text" name="link_description" size="30" value="<?php echo isset( $link->link_description ) ? esc_attr( $link->link_description ) : ''; ?>" id="link_description" /> 84 <p><?php _e( 'This will be shown when someone hovers over the link in the blogroll, or optionally below the link.' ); ?></p> 85 </div> 86 </div> 87 </div><!-- /post-body-content --> 88 89 <div id="postbox-container-1" class="postbox-container"> 90 <?php 91 do_action( 'submitlink_box' ); 92 $side_meta_boxes = do_meta_boxes( 'link', 'side', $link ); 93 94 ?> 95 </div> 96 <div id="postbox-container-2" class="postbox-container"> 97 <?php 98 99 do_meta_boxes( null, 'normal', $link ); 100 do_meta_boxes( null, 'advanced', $link ); 101 102 ?> 103 </div> 104 <?php 105 106 if ( $link_id ) : ?> 107 <input type="hidden" name="action" value="save" /> 108 <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" /> 109 <input type="hidden" name="order_by" value="<?php echo esc_attr( $order_by ); ?>" /> 110 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> 111 <?php else: ?> 112 <input type="hidden" name="action" value="add" /> 113 <?php endif; ?> 114 115 </div> 116 </div> 117 118 </form> 119 </div> 120 No newline at end of file -
wp-content/plugins/link-manager/admin/meta-boxes.php
1 <?php 2 // -- Link related Meta Boxes 3 4 /** 5 * Display link create form fields. 6 * 7 * @since WP 2.7.0 8 * 9 * @param object $link 10 */ 11 function link_submit_meta_box( $link ) { 12 ?> 13 <div class="submitbox" id="submitlink"> 14 15 <div id="minor-publishing"> 16 17 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> 18 <div style="display:none;"> 19 <?php submit_button( __( 'Save' ), 'button', 'save', false ); ?> 20 </div> 21 22 <div id="minor-publishing-actions"> 23 <div id="preview-action"> 24 <?php if ( !empty($link->link_id) ) { ?> 25 <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e('Visit Link'); ?></a> 26 <?php } ?> 27 </div> 28 <div class="clear"></div> 29 </div> 30 31 <div id="misc-publishing-actions"> 32 <div class="misc-pub-section"> 33 <label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label> 34 </div> 35 </div> 36 37 </div> 38 39 <div id="major-publishing-actions"> 40 <?php do_action('post_submitbox_start'); ?> 41 <div id="delete-action"> 42 <?php 43 if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?> 44 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo 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;"><?php _e('Delete'); ?></a> 45 <?php } ?> 46 </div> 47 48 <div id="publishing-action"> 49 <?php if ( !empty($link->link_id) ) { ?> 50 <input name="save" type="submit" class="button-primary" id="publish" accesskey="p" value="<?php esc_attr_e('Update Link') ?>" /> 51 <?php } else { ?> 52 <input name="save" type="submit" class="button-primary" id="publish" accesskey="p" value="<?php esc_attr_e('Add Link') ?>" /> 53 <?php } ?> 54 </div> 55 <div class="clear"></div> 56 </div> 57 <?php do_action('submitlink_box'); ?> 58 <div class="clear"></div> 59 </div> 60 <?php 61 } 62 63 /** 64 * Display link categories form fields. 65 * 66 * @since WP 2.6.0 67 * 68 * @param object $link 69 */ 70 function link_categories_meta_box($link) { 71 ?> 72 <div id="taxonomy-linkcategory" class="categorydiv"> 73 <ul id="category-tabs" class="category-tabs"> 74 <li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li> 75 <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li> 76 </ul> 77 78 <div id="categories-all" class="tabs-panel"> 79 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 80 <?php 81 if ( isset($link->link_id) ) 82 wp_link_category_checklist($link->link_id); 83 else 84 wp_link_category_checklist(); 85 ?> 86 </ul> 87 </div> 88 89 <div id="categories-pop" class="tabs-panel" style="display: none;"> 90 <ul id="categorychecklist-pop" class="categorychecklist form-no-clear"> 91 <?php wp_popular_terms_checklist('link_category'); ?> 92 </ul> 93 </div> 94 95 <div id="category-adder" class="wp-hidden-children"> 96 <h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4> 97 <p id="link-category-add" class="wp-hidden-child"> 98 <label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label> 99 <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" /> 100 <input type="button" id="link-category-add-submit" class="add:categorychecklist:linkcategorydiv button" value="<?php esc_attr_e( 'Add' ); ?>" /> 101 <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?> 102 <span id="category-ajax-response"></span> 103 </p> 104 </div> 105 </div> 106 <?php 107 } 108 109 /** 110 * Display form fields for changing link target. 111 * 112 * @since WP 2.6.0 113 * 114 * @param object $link 115 */ 116 function link_target_meta_box($link) { ?> 117 <fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend> 118 <p><label for="link_target_blank" class="selectit"> 119 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> 120 <?php _e('<code>_blank</code> — new window or tab.'); ?></label></p> 121 <p><label for="link_target_top" class="selectit"> 122 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> 123 <?php _e('<code>_top</code> — current window or tab, with no frames.'); ?></label></p> 124 <p><label for="link_target_none" class="selectit"> 125 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> /> 126 <?php _e('<code>_none</code> — same window or tab.'); ?></label></p> 127 </fieldset> 128 <p><?php _e('Choose the target frame for your link.'); ?></p> 129 <?php 130 } 131 132 /** 133 * Display checked checkboxes attribute for xfn microformat options. 134 * 135 * @since WP 1.0.1 136 * 137 * @param string $class 138 * @param string $value 139 * @param mixed $deprecated Never used. 140 */ 141 function xfn_check( $class, $value = '', $deprecated = '' ) { 142 global $link; 143 144 if ( !empty( $deprecated ) ) 145 _deprecated_argument( __FUNCTION__, '0.0' ); // Never implemented 146 147 $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; 148 $rels = preg_split('/\s+/', $link_rel); 149 150 if ('' != $value && in_array($value, $rels) ) { 151 echo ' checked="checked"'; 152 } 153 154 if ('' == $value) { 155 if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"'; 156 if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"'; 157 if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"'; 158 if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; 159 } 160 } 161 162 /** 163 * Display xfn form fields. 164 * 165 * @since WP 2.6.0 166 * 167 * @param object $link 168 */ 169 function link_xfn_meta_box($link) { 170 ?> 171 <table class="links-table" cellspacing="0"> 172 <tr> 173 <th scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th> 174 <td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td> 175 </tr> 176 <tr> 177 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></th> 178 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></span></legend> 179 <label for="me"> 180 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> /> 181 <?php _e('another web address of mine') ?></label> 182 </fieldset></td> 183 </tr> 184 <tr> 185 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></th> 186 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></span></legend> 187 <label for="contact"> 188 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('contact') ?> 189 </label> 190 <label for="acquaintance"> 191 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('acquaintance') ?> 192 </label> 193 <label for="friend"> 194 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friend') ?> 195 </label> 196 <label for="friendship"> 197 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?> 198 </label> 199 </fieldset></td> 200 </tr> 201 <tr> 202 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </th> 203 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?></span></legend> 204 <label for="met"> 205 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('met') ?> 206 </label> 207 </fieldset></td> 208 </tr> 209 <tr> 210 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </th> 211 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?></span></legend> 212 <label for="co-worker"> 213 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-worker') ?> 214 </label> 215 <label for="colleague"> 216 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('colleague') ?> 217 </label> 218 </fieldset></td> 219 </tr> 220 <tr> 221 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?></th> 222 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </span></legend> 223 <label for="co-resident"> 224 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-resident') ?> 225 </label> 226 <label for="neighbor"> 227 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('neighbor') ?> 228 </label> 229 <label for="geographical"> 230 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?> 231 </label> 232 </fieldset></td> 233 </tr> 234 <tr> 235 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?></th> 236 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </span></legend> 237 <label for="child"> 238 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('child') ?> 239 </label> 240 <label for="kin"> 241 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('kin') ?> 242 </label> 243 <label for="parent"> 244 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('parent') ?> 245 </label> 246 <label for="sibling"> 247 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sibling') ?> 248 </label> 249 <label for="spouse"> 250 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('spouse') ?> 251 </label> 252 <label for="family"> 253 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?> 254 </label> 255 </fieldset></td> 256 </tr> 257 <tr> 258 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?></th> 259 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </span></legend> 260 <label for="muse"> 261 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('muse') ?> 262 </label> 263 <label for="crush"> 264 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('crush') ?> 265 </label> 266 <label for="date"> 267 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('date') ?> 268 </label> 269 <label for="romantic"> 270 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sweetheart') ?> 271 </label> 272 </fieldset></td> 273 </tr> 274 275 </table> 276 <p><?php _e('If the link is to a person, you can specify your relationship with them using the above form. If you would like to learn more about the idea check out <a href="http://gmpg.org/xfn/">XFN</a>.'); ?></p> 277 <?php 278 } 279 280 /** 281 * Display advanced link options form fields. 282 * 283 * @since WP 2.6.0 284 * 285 * @param object $link 286 */ 287 function link_advanced_meta_box($link) { 288 ?> 289 <table class="links-table" cellpadding="0"> 290 <tr> 291 <th scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th> 292 <td><input type="text" name="link_image" class="code" id="link_image" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" /></td> 293 </tr> 294 <tr> 295 <th scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th> 296 <td><input name="link_rss" class="code" type="text" id="rss_uri" value="<?php echo ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" /></td> 297 </tr> 298 <tr> 299 <th scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th> 300 <td><textarea name="link_notes" id="link_notes" rows="10"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : ''); // textarea_escaped ?></textarea></td> 301 </tr> 302 <tr> 303 <th scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th> 304 <td><select name="link_rating" id="link_rating" size="1"> 305 <?php 306 for ( $r = 0; $r <= 10; $r++ ) { 307 echo '<option value="' . $r . '"'; 308 if ( isset($link->link_rating) && $link->link_rating == $r ) 309 echo ' selected="selected"'; 310 echo('>' . $r . '</option>'); 311 } 312 ?></select> <?php _e('(Leave at 0 for no rating.)') ?> 313 </td> 314 </tr> 315 </table> 316 <?php 317 } 318 No newline at end of file -
wp-content/plugins/link-manager/admin/class-wp-links-list-table.php
1 <?php 2 /** 3 * Links Manager List Table class. 4 * 5 * @package WordPress 6 * @subpackage List_Table 7 * @since 3.1.0 8 * @access private 9 */ 10 class WP_Links_List_Table extends WP_List_Table { 11 12 function __construct() { 13 parent::__construct( array( 14 'plural' => 'bookmarks', 15 ) ); 16 } 17 18 function ajax_user_can() { 19 return current_user_can( 'manage_links' ); 20 } 21 22 function prepare_items() { 23 global $cat_id, $s, $orderby, $order; 24 25 wp_reset_vars( array( 'action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'orderby', 'order', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]', 's' ) ); 26 27 $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); 28 29 if ( 'all' != $cat_id ) 30 $args['category'] = $cat_id; 31 if ( !empty( $s ) ) 32 $args['search'] = $s; 33 if ( !empty( $orderby ) ) 34 $args['orderby'] = $orderby; 35 if ( !empty( $order ) ) 36 $args['order'] = $order; 37 38 $this->items = get_bookmarks( $args ); 39 } 40 41 function no_items() { 42 _e( 'No links found.' ); 43 } 44 45 function get_bulk_actions() { 46 $actions = array(); 47 $actions['delete'] = __( 'Delete' ); 48 49 return $actions; 50 } 51 52 function extra_tablenav( $which ) { 53 global $cat_id; 54 55 if ( 'top' != $which ) 56 return; 57 ?> 58 <div class="alignleft actions"> 59 <?php 60 $dropdown_options = array( 61 'selected' => $cat_id, 62 'name' => 'cat_id', 63 'taxonomy' => 'link_category', 64 'show_option_all' => __( 'View all categories' ), 65 'hide_empty' => true, 66 'hierarchical' => 1, 67 'show_count' => 0, 68 'orderby' => 'name', 69 ); 70 wp_dropdown_categories( $dropdown_options ); 71 submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); 72 ?> 73 </div> 74 <?php 75 } 76 77 function get_columns() { 78 return array( 79 'cb' => '<input type="checkbox" />', 80 'name' => _x( 'Name', 'link name' ), 81 'url' => __( 'URL' ), 82 'categories' => __( 'Categories' ), 83 'rel' => __( 'Relationship' ), 84 'visible' => __( 'Visible' ), 85 'rating' => __( 'Rating' ) 86 ); 87 } 88 89 function get_sortable_columns() { 90 return array( 91 'name' => 'name', 92 'url' => 'url', 93 'visible' => 'visible', 94 'rating' => 'rating' 95 ); 96 } 97 98 function display_rows() { 99 global $cat_id; 100 101 $alt = 0; 102 103 foreach ( $this->items as $link ) { 104 $link = sanitize_bookmark( $link ); 105 $link->link_name = esc_attr( $link->link_name ); 106 $link->link_category = wp_get_link_cats( $link->link_id ); 107 108 $short_url = url_shorten( $link->link_url ); 109 110 $visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' ); 111 $rating = $link->link_rating; 112 $style = ( $alt++ % 2 ) ? '' : ' class="alternate"'; 113 114 $edit_link = get_edit_bookmark_link( $link ); 115 ?> 116 <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>> 117 <?php 118 119 list( $columns, $hidden ) = $this->get_column_info(); 120 121 foreach ( $columns as $column_name => $column_display_name ) { 122 $class = "class='column-$column_name'"; 123 124 $style = ''; 125 if ( in_array( $column_name, $hidden ) ) 126 $style = ' style="display:none;"'; 127 128 $attributes = $class . $style; 129 130 switch ( $column_name ) { 131 case 'cb': ?> 132 <th scope="row" class="check-column"> 133 <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf( __( 'Select %s' ), $link->link_name ); ?></label> 134 <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" /> 135 </th> 136 <?php 137 break; 138 139 case 'name': 140 echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ) . "'>$link->link_name</a></strong><br />"; 141 142 $menu_page_url = menu_page_url( 'link-manager.php', false ); 143 $delete_url = add_query_arg( array( 'action' => 'delete', 'link_id' => $link->link_id ), $menu_page_url ); 144 145 $actions = array(); 146 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; 147 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( $delete_url, '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>"; 148 echo $this->row_actions( $actions ); 149 150 echo '</td>'; 151 break; 152 case 'url': 153 echo "<td $attributes><a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a></td>"; 154 break; 155 case 'categories': 156 ?><td <?php echo $attributes ?>><?php 157 $cat_names = array(); 158 foreach ( $link->link_category as $category ) { 159 $cat = get_term( $category, 'link_category', OBJECT, 'display' ); 160 if ( is_wp_error( $cat ) ) 161 echo $cat->get_error_message(); 162 $cat_name = $cat->name; 163 if ( $cat_id != $category ) 164 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>"; 165 $cat_names[] = $cat_name; 166 } 167 echo implode( ', ', $cat_names ); 168 ?></td><?php 169 break; 170 case 'rel': 171 ?><td <?php echo $attributes ?>><?php echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; ?></td><?php 172 break; 173 case 'visible': 174 ?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php 175 break; 176 case 'rating': 177 ?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php 178 break; 179 default: 180 ?> 181 <td <?php echo $attributes ?>><?php do_action( 'manage_link_custom_column', $column_name, $link->link_id ); ?></td> 182 <?php 183 break; 184 } 185 } 186 ?> 187 </tr> 188 <?php 189 } 190 } 191 } -
wp-content/plugins/link-manager/admin/link-manager.php
1 <?php 2 /** 3 * Link Management Administration Screen. 4 * 5 * @package Link Manager 6 * @subpackage Administration 7 */ 8 9 ?> 10 <div class="wrap nosubsub"> 11 <?php screen_icon(); ?> 12 <h2><?php _e( 'Links' ) ?> <a href="<?php menu_page_url( 'link-add.php' ) ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'link' ); ?></a> <?php 13 if ( !empty($_REQUEST['s']) ) 14 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes( $_REQUEST['s'] ) ) ); ?> 15 </h2> 16 17 <?php 18 if ( isset( $_REQUEST['deleted'] ) ) { 19 echo '<div id="message" class="updated"><p>'; 20 $deleted = (int) $_REQUEST['deleted']; 21 printf( _n( '%s link deleted.', '%s links deleted', $deleted ), $deleted ); 22 echo '</p></div>'; 23 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] ); 24 } 25 ?> 26 27 <form id="posts-filter" action="<?php menu_page_url( 'link-manager.php' ) ?>" method="post"> 28 29 <?php 30 $wp_list_table->search_box( __( 'Search Links' ), 'link' ); 31 $wp_list_table->display(); 32 ?> 33 34 <div id="ajax-response"></div> 35 </form> 36 37 </div> 38 No newline at end of file -
wp-content/plugins/link-manager/widget.php
1 <?php 2 /** 3 * Links widget class 4 * 5 * @since WP 2.8.0 6 */ 7 class WP_Widget_Links extends WP_Widget { 8 9 function __construct() { 10 $widget_ops = array( 'description' => __( "Your blogroll" ) ); 11 parent::__construct( 'links', __( 'Links' ), $widget_ops ); 12 } 13 14 function widget( $args, $instance ) { 15 extract( $args, EXTR_SKIP ); 16 17 $show_description = isset( $instance['description'] ) ? $instance['description'] : false; 18 $show_name = isset( $instance['name'] ) ? $instance['name'] : false; 19 $show_rating = isset( $instance['rating'] ) ? $instance['rating'] : false; 20 $show_images = isset( $instance['images'] ) ? $instance['images'] : true; 21 $category = isset( $instance['category'] ) ? $instance['category'] : false; 22 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; 23 $order = $orderby == 'rating' ? 'DESC' : 'ASC'; 24 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; 25 26 $before_widget = preg_replace( '/id="[^"]*"/','id="%id"', $before_widget ); 27 wp_list_bookmarks( apply_filters( 'widget_links_args', array( 28 'title_before' => $before_title, 'title_after' => $after_title, 29 'category_before' => $before_widget, 'category_after' => $after_widget, 30 'show_images' => $show_images, 'show_description' => $show_description, 31 'show_name' => $show_name, 'show_rating' => $show_rating, 32 'category' => $category, 'class' => 'linkcat widget', 33 'orderby' => $orderby, 'order' => $order, 34 'limit' => $limit, 35 ) ) ); 36 } 37 38 function update( $new_instance, $old_instance ) { 39 $new_instance = (array) $new_instance; 40 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 ); 41 foreach ( $instance as $field => $val ) { 42 if ( isset( $new_instance[$field] ) ) 43 $instance[$field] = 1; 44 } 45 46 $instance['orderby'] = 'name'; 47 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) 48 $instance['orderby'] = $new_instance['orderby']; 49 50 $instance['category'] = intval( $new_instance['category'] ); 51 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; 52 53 return $instance; 54 } 55 56 function form( $instance ) { 57 58 //Defaults 59 $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false, 'orderby' => 'name', 'limit' => -1 ) ); 60 $link_cats = get_terms( 'link_category' ); 61 if ( ! $limit = intval( $instance['limit'] ) ) 62 $limit = -1; 63 ?> 64 <p> 65 <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Select Link Category:' ); ?></label> 66 <select class="widefat" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>"> 67 <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option> 68 <?php 69 foreach ( $link_cats as $link_cat ) { 70 echo '<option value="' . intval( $link_cat->term_id ) . '"' 71 . ( $link_cat->term_id == $instance['category'] ? ' selected="selected"' : '' ) 72 . '>' . $link_cat->name . "</option>\n"; 73 } 74 ?> 75 </select> 76 <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Sort by:' ); ?></label> 77 <select name="<?php echo $this->get_field_name( 'orderby' ); ?>" id="<?php echo $this->get_field_id( 'orderby' ); ?>" class="widefat"> 78 <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option> 79 <option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option> 80 <option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option> 81 <option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _e( 'Random' ); ?></option> 82 </select> 83 </p> 84 <p> 85 <input class="checkbox" type="checkbox" <?php checked( $instance['images'], true ) ?> id="<?php echo $this->get_field_id( 'images' ); ?>" name="<?php echo $this->get_field_name( 'images' ); ?>" /> 86 <label for="<?php echo $this->get_field_id( 'images' ); ?>"><?php _e( 'Show Link Image' ); ?></label><br /> 87 <input class="checkbox" type="checkbox" <?php checked( $instance['name'], true ) ?> id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" /> 88 <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e( 'Show Link Name' ); ?></label><br /> 89 <input class="checkbox" type="checkbox" <?php checked( $instance['description'], true ) ?> id="<?php echo $this->get_field_id( 'description' ); ?>" name="<?php echo $this->get_field_name( 'description' ); ?>" /> 90 <label for="<?php echo $this->get_field_id( 'description' ); ?>"><?php _e( 'Show Link Description' ); ?></label><br /> 91 <input class="checkbox" type="checkbox" <?php checked( $instance['rating'], true ) ?> id="<?php echo $this->get_field_id( 'rating' ); ?>" name="<?php echo $this->get_field_name( 'rating' ); ?>" /> 92 <label for="<?php echo $this->get_field_id( 'rating' ); ?>"><?php _e( 'Show Link Rating' ); ?></label> 93 </p> 94 <p> 95 <label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e( 'Number of links to show:' ); ?></label> 96 <input id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" /> 97 </p> 98 <?php 99 } 100 } 101 No newline at end of file -
wp-content/plugins/link-manager/link-manager.php
1 <?php 2 /* 3 Plugin Name: Link Manager 4 Description: Manages links 5 Author: Scott Taylor 6 Version: 1.0 7 Author URI: http://scotty-t.com/ 8 */ 9 10 define( 'LINK_MANAGER_URL', WP_PLUGIN_URL . '/link-manager' ); 11 define( 'LINK_MANAGER_DIR', WP_PLUGIN_DIR . '/link-manager' ); 12 13 require( LINK_MANAGER_DIR . '/functions.php' ); 14 require( LINK_MANAGER_DIR . '/deprecated.php' ); 15 require( LINK_MANAGER_DIR . '/bookmark.php' ); 16 require( LINK_MANAGER_DIR . '/bookmark-template.php' ); 17 require( LINK_MANAGER_DIR . '/widget.php' ); 18 19 register_activation_hook( __FILE__, array( 'LinkManagerPlugin', 'install_defaults' ) ); 20 21 class LinkManagerPlugin { 22 var $reset_vars; 23 var $wp_list_table; 24 25 private static $instance; 26 public static function get_instance() { 27 if ( !isset( self::$instance ) ) 28 self::$instance = new LinkManagerPlugin(); 29 30 return self::$instance; 31 } 32 33 private function __construct() { 34 $this->reset_vars = array( 35 'action', 'cat_id', 'linkurl', 'name', 'image', 'description', 36 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 37 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]' 38 ); 39 40 add_action( 'init', array( $this, 'create_taxonomy' ), 0 ); 41 add_action( 'widgets_init', array( $this, 'widgets_init' ), 1 ); 42 add_action( '_admin_menu', array( $this, 'menu_compat' ) ); 43 add_action( 'admin_menu', array( $this, 'menu' ) ); 44 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 71 ); 45 add_action( 'admin_head', array( $this, 'menu_css' ) ); 46 47 add_filter( 'whitelist_options', array( $this, 'whitelist_options' ) ); 48 add_filter( 'terms_list_table_coumns', array( $this, 'terms_list_table_coumns' ) ); 49 add_filter( 'dropdown_categories_args', array( $this, 'dropdown_categories_args' ) ); 50 add_filter( 'get_categories_taxonomy', array( $this, 'get_categories_taxonomy' ), 10, 2 ); 51 add_filter( 'sanitize_option_default_link_category', array( $this, 'sanitize_default_link_category' ) ); 52 53 add_action( 'wpmu_delete_user', array( $this, 'wpmu_delete_user' ) ); 54 add_action( 'delete_user', array( $this, 'delete_user' ) ); 55 add_action( 'reassign_user_data', array( $this, 'reassign_user_data' ), 10, 2 ); 56 57 add_action( 'edit_link_category_help', array( $this, 'edit_link_category_help' ) ); 58 add_action( 'install_defaults', array( $this, 'install_defaults' ) ); 59 60 add_action( 'admin_init', array( $this, 'add_settings_field' ) ); 61 62 /** 63 * AJAX Actions 64 * 65 */ 66 add_action( 'wp_ajax_add-link-category', array( $this, 'ajax_add_link_category' ), 1 ); 67 add_action( 'wp_ajax_delete-link', array( $this, 'ajax_delete_link' ), 1 ); 68 69 /** 70 * These switch the order of the actions, but I seriously doubt they are used at all 71 * By hooking into these, we remove link_category-specific backcompat checks in admin code 72 * 73 */ 74 add_action( 'load-edit-tags.php', array( $this, 'backcompat_load_taxnow' ) ); 75 add_action( 'link_category_pre_add_form', array( $this, 'link_category_pre_add_form' ), 10, 2 ); 76 add_action( 'link_category_add_form', array( $this, 'link_category_add_form' ), 10, 2 ); 77 add_action( 'link_category_pre_edit_form', array( $this, 'link_category_pre_edit_form' ), 10, 2 ); 78 add_action( 'link_category_edit_form_fields', array( $this, 'link_category_edit_form_fields' ), 10, 2 ); 79 add_action( 'link_category_edit_form', array( $this, 'link_category_edit_form' ), 10, 2 ); 80 } 81 82 function menu_css() { 83 ?> 84 <style type="text/css"> 85 .toplevel_page_link-manager div.wp-menu-image {background-image: url('/wp-admin/images/menu.png?ver=20120201');} 86 #adminmenu .toplevel_page_link-manager div.wp-menu-image { 87 background-position: -89px -33px; 88 } 89 90 #adminmenu .toplevel_page_link-manager:hover div.wp-menu-image, 91 #adminmenu .toplevel_page_link-manager.wp-has-current-submenu div.wp-menu-image, 92 #adminmenu .toplevel_page_link-manager.current div.wp-menu-image { 93 background-position: -89px -1px; 94 } 95 </style> 96 <?php 97 } 98 99 function create_taxonomy() { 100 register_taxonomy( 'link_category', 'link', array( 101 'hierarchical' => false, 102 'labels' => array( 103 'name' => __( 'Link Categories' ), 104 'singular_name' => __( 'Link Category' ), 105 'search_items' => __( 'Search Link Categories' ), 106 'popular_items' => null, 107 'all_items' => __( 'All Link Categories' ), 108 'edit_item' => __( 'Edit Link Category' ), 109 'update_item' => __( 'Update Link Category' ), 110 'add_new_item' => __( 'Add New Link Category' ), 111 'new_item_name' => __( 'New Link Category Name' ), 112 'separate_items_with_commas' => null, 113 'add_or_remove_items' => null, 114 'choose_from_most_used' => null, 115 ), 116 'query_var' => false, 117 'rewrite' => false, 118 'public' => false, 119 'show_ui' => false, 120 '_builtin' => true, 121 ) ); 122 } 123 124 function add_settings_field() { 125 add_settings_field( 126 'default_link_category', 127 __( 'Default Link Category' ), 128 'wp_dropdown_categories', 129 'writing', 130 'default', 131 array( 132 'hide_empty' => 0, 133 'name' => 'default_link_category', 134 'orderby' => 'name', 135 'selected' => get_option( 'default_link_category' ), 136 'hierarchical' => true, 137 'taxonomy' => 'link_category' 138 ) 139 ); 140 } 141 142 /** 143 * Register Links widget on startup. 144 * 145 */ 146 function widgets_init() { 147 register_widget( 'WP_Widget_Links' ); 148 } 149 150 function menu_compat() { 151 global $compat; 152 $compat['link-manager'] = 'links'; 153 } 154 155 function menu() { 156 $links_page = add_menu_page( __( 'Links' ), __( 'Links' ), 'manage_links', 'link-manager.php', array( $this, 'admin_page' ), admin_url( 'wp-includes/images/blank.gif' ), 15 ); 157 add_action( "load-{$links_page}", array( $this, 'load_admin_page' ) ); 158 159 $all_links_page = add_links_page( _x( 'All Links', 'admin menu' ), _x( 'All Links', 'admin menu' ), 'manage_links', 'link-manager.php', array( $this, 'admin_page' ) ); 160 if ( $links_page !== $all_links_page ) 161 add_action( "load-{$all_links_page}", array( $this, 'load_admin_page' ) ); 162 163 /* translators: add new links */ 164 $add_new_page = add_links_page( _x( 'Add New', 'link' ), _x( 'Add New', 'link' ), 'manage_links', 'link-add.php', array( $this, 'add_new_page' ) ); 165 add_action( "load-{$add_new_page}", array( $this, 'load_add_new_page' ) ); 166 167 add_links_page( __( 'Link Categories' ), __( 'Link Categories' ), 'manage_categories', 'edit-tags.php?taxonomy=link_category' ); 168 } 169 170 function check_permissions() { 171 if ( ! current_user_can( 'manage_links' ) ) 172 wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) ); 173 } 174 175 function load_admin_page() { 176 $this->check_permissions(); 177 wp_reset_vars( $this->reset_vars ); 178 foreach ( $this->reset_vars as $_var ) 179 $$_var = $GLOBALS[$_var]; 180 181 if ( ! empty( $_POST['linkcheck'] ) ) 182 $action = 'deletebookmarks'; 183 if ( ! empty( $_POST['move'] ) ) 184 $action = 'move'; 185 if ( ! empty( $_POST['linkcheck'] ) ) 186 $linkcheck = $_POST['linkcheck']; 187 188 $redirect_to = menu_page_url( 'link-manager.php', false ); 189 190 switch ( $action ) { 191 case 'deletebookmarks' : 192 check_admin_referer( 'bulk-bookmarks' ); 193 194 //for each link id (in $linkcheck[]) change category to selected value 195 if ( empty( $linkcheck ) ) { 196 wp_redirect( $redirect_to ); 197 exit; 198 } 199 200 $deleted = 0; 201 foreach ( $linkcheck as $link_id ) { 202 $link_id = (int) $link_id; 203 204 if ( wp_delete_link( $link_id ) ) 205 $deleted++; 206 } 207 208 $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); 209 wp_redirect( $redirect_to ); 210 exit; 211 break; 212 213 case 'move' : 214 check_admin_referer( 'bulk-bookmarks' ); 215 216 //for each link id (in $linkcheck[]) change category to selected value 217 if ( empty( $linkcheck ) ) { 218 wp_redirect( $redirect_to ); 219 exit; 220 } 221 $all_links = join( ',', $linkcheck ); 222 // should now have an array of links we can change 223 //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); 224 225 wp_redirect( $redirect_to ); 226 exit; 227 break; 228 229 case 'add' : 230 check_admin_referer( 'add-bookmark' ); 231 232 $redir = wp_get_referer(); 233 if ( add_link() ) 234 $redir = add_query_arg( 'added', 'true', $redir ); 235 236 wp_redirect( $redir ); 237 exit; 238 break; 239 240 case 'save' : 241 $link_id = (int) $link_id; 242 check_admin_referer( 'update-bookmark_' . $link_id ); 243 244 edit_link( $link_id ); 245 246 wp_redirect( $redirect_to ); 247 exit; 248 break; 249 250 case 'delete' : 251 $link_id = (int) $link_id; 252 check_admin_referer( 'delete-bookmark_' . $link_id ); 253 254 wp_delete_link( $link_id ); 255 256 wp_redirect( $redirect_to ); 257 exit; 258 break; 259 260 case 'edit' : 261 wp_enqueue_script( 'link' ); 262 wp_enqueue_script( 'xfn' ); 263 264 if ( wp_is_mobile() ) 265 wp_enqueue_script( 'jquery-touch-punch' ); 266 267 268 $link_id = (int) $link_id; 269 270 if ( !$link = get_link_to_edit( $link_id ) ) 271 wp_die( __( 'Link not found.' ) ); 272 273 add_screen_option( 'layout_columns', array( 'max' => 2, 'default' => 2 ) ); 274 275 get_current_screen()->add_help_tab( array( 276 'id' => 'overview', 277 'title' => __('Overview'), 278 'content' => 279 '<p>' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link’s web address and name (the text you want to display on your site as the link) are required fields.' ) . '</p>' . 280 '<p>' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don’t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '</p>' . 281 '<p>' . __( 'XFN stands for <a href="http://gmpg.org/xfn/" target="_blank">XHTML Friends Network</a>, which is optional. WordPress allows the generation of XFN attributes to show how you are related to the authors/owners of the site to which you are linking.' ) . '</p>' 282 ) ); 283 284 get_current_screen()->set_help_sidebar( 285 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 286 '<p>' . __( '<a href="http://codex.wordpress.org/Links_Add_New_Screen" target="_blank">Documentation on Creating Links</a>' ) . '</p>' . 287 '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' 288 ); 289 290 break; 291 292 default : 293 require( LINK_MANAGER_DIR . '/admin/class-wp-links-list-table.php' ); 294 $this->wp_list_table = new WP_Links_List_Table(); 295 296 // Handle bulk deletes 297 $doaction = $this->wp_list_table->current_action(); 298 299 if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) { 300 check_admin_referer( 'bulk-bookmarks' ); 301 302 if ( 'delete' == $doaction ) { 303 $bulklinks = (array) $_REQUEST['linkcheck']; 304 foreach ( $bulklinks as $link_id ) { 305 $link_id = (int) $link_id; 306 307 wp_delete_link( $link_id ); 308 } 309 310 wp_redirect( add_query_arg( 'deleted', count( $bulklinks ), menu_page_url( 'link-manager.php', false ) ) ); 311 exit; 312 } 313 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { 314 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) ); 315 exit; 316 } 317 318 get_current_screen()->add_help_tab( array( 319 'id' => 'overview', 320 'title' => __('Overview'), 321 'content' => 322 '<p>' . sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php') . '</p>' . 323 '<p>' . __('Links may be separated into Link Categories; these are different than the categories used on your posts.') . '</p>' . 324 '<p>' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '</p>' 325 ) ); 326 get_current_screen()->add_help_tab( array( 327 'id' => 'deleting-links', 328 'title' => __('Deleting Links'), 329 'content' => 330 '<p>' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '</p>' 331 ) ); 332 333 get_current_screen()->set_help_sidebar( 334 '<p><strong>' . __('For more information:') . '</strong></p>' . 335 '<p>' . __('<a href="http://codex.wordpress.org/Links_Screen" target="_blank">Documentation on Managing Links</a>') . '</p>' . 336 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 337 ); 338 break; 339 } 340 } 341 342 function admin_page() { 343 global $link; 344 wp_reset_vars( $this->reset_vars ); 345 foreach ( $this->reset_vars as $_var ) 346 $$_var = $GLOBALS[$_var]; 347 348 $title = __( 'Links' ); 349 if ( 'edit' === $action ) { 350 $link = get_link_to_edit( $link_id ); 351 require( LINK_MANAGER_DIR . '/admin/meta-boxes.php' ); 352 include( LINK_MANAGER_DIR . '/admin/edit-link-form.php' ); 353 } else { 354 $wp_list_table =& $this->wp_list_table; 355 $wp_list_table->prepare_items(); 356 include( LINK_MANAGER_DIR . '/admin/link-manager.php' ); 357 } 358 } 359 360 function add_new_page() { 361 global $link; 362 363 $this->check_permissions(); 364 wp_reset_vars( $this->reset_vars ); 365 foreach ( $this->reset_vars as $_var ) 366 $$_var = $GLOBALS[$_var]; 367 368 $title = __( 'Add New Link' ); 369 $link = get_default_link_to_edit(); 370 require( LINK_MANAGER_DIR . '/admin/meta-boxes.php' ); 371 include( LINK_MANAGER_DIR . '/admin/edit-link-form.php' ); 372 } 373 374 function load_add_new_page() { 375 wp_enqueue_script( 'link' ); 376 wp_enqueue_script( 'xfn' ); 377 378 if ( wp_is_mobile() ) 379 wp_enqueue_script( 'jquery-touch-punch' ); 380 } 381 382 function admin_bar_menu() { 383 global $wp_admin_bar; 384 if ( current_user_can( 'manage_links' ) ) { 385 $wp_admin_bar->add_menu( array( 386 'parent' => 'new-content', 387 'id' => 'new-link', 388 'title' => _x( 'Link', 'add new from admin bar' ), 389 'href' => admin_url( 'link-add.php' ) 390 ) ); 391 } 392 } 393 394 function whitelist_options( $options ) { 395 $options['writing'][] = 'default_link_category'; 396 return $options; 397 } 398 399 function terms_list_table_coumns( $columns ) { 400 global $taxonomy; 401 if ( 'link_category' === $taxonomy ) 402 $columns['links'] = __( 'Links' ); 403 404 return $columns; 405 } 406 407 function dropdown_categories_args( $args ) { 408 // Back compat. 409 if ( isset( $args['type'] ) && 'link' == $args['type'] ) { 410 _deprecated_argument( 'wp_dropdown_categories', '3.0', '' ); 411 $args['taxonomy'] = 'link_category'; 412 } 413 return $args; 414 } 415 416 function get_categories_taxonomy( $taxonomy, $args ) { 417 // Back compat 418 if ( isset( $args['type'] ) && 'link' == $args['type'] ) { 419 _deprecated_argument( 'get_categories', '3.0', '' ); 420 $args['taxonomy'] = 'link_category'; 421 } 422 return $args['taxonomy']; 423 } 424 425 function sanitize_default_link_category( $value ) { 426 $value = absint( $value ); 427 return $value; 428 } 429 430 function wpmu_delete_user( $id ) { 431 global $wpdb; 432 $blogs = get_blogs_of_user( $id ); 433 434 if ( ! empty( $blogs ) ) { 435 foreach ( $blogs as $blog ) { 436 switch_to_blog( $blog->userblog_id ); 437 // Clean links 438 $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) ); 439 440 if ( $link_ids ) 441 foreach ( $link_ids as $link_id ) 442 wp_delete_link( $link_id ); 443 } 444 } 445 } 446 447 function delete_user( $id ) { 448 global $wpdb; 449 // Clean links 450 $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); 451 452 if ( $link_ids ) { 453 foreach ( $link_ids as $link_id ) 454 wp_delete_link( $link_id ); 455 } 456 } 457 458 function reassign_user_data( $id, $reassign ) { 459 global $wpdb; 460 $wpdb->update( $wpdb->links, array( 'link_owner' => $reassign ), array( 'link_owner' => $id ) ); 461 } 462 463 function edit_link_category_help() { 464 $help = '<p>' . __( 'You can create groups of links by using Link Categories. Link Category names must be unique and Link Categories are separate from the categories you use for posts.' ) . '</p>'; 465 $help .= '<p>' . __( 'You can delete Link Categories in the Bulk Action pull-down, but that action does not delete the links within the category. Instead, it moves them to the default Link Category.' ) . '</p>'; 466 467 get_current_screen()->add_help_tab( array( 468 'id' => 'overview', 469 'title' => __('Overview'), 470 'content' => $help, 471 ) ); 472 473 $help = '<p><strong>' . __( 'For more information:' ) . '</strong></p>'; 474 $help .= '<p>' . __( '<a href="http://codex.wordpress.org/Links_Link_Categories_Screen" target="_blank">Documentation on Link Categories</a>' ) . '</p>'; 475 $help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'; 476 477 get_current_screen()->set_help_sidebar( $help ); 478 } 479 480 /** 481 * Ajax Actions 482 * 483 */ 484 function ajax_add_link_category( $action ) { 485 if ( empty( $action ) ) 486 $action = 'add-link-category'; 487 check_ajax_referer( $action ); 488 if ( !current_user_can( 'manage_categories' ) ) 489 wp_die( -1 ); 490 $names = explode( ',', $_POST['newcat'] ); 491 $x = new WP_Ajax_Response(); 492 foreach ( $names as $cat_name ) { 493 $cat_name = trim( $cat_name ); 494 $slug = sanitize_title( $cat_name ); 495 if ( '' === $slug ) 496 continue; 497 if ( !$cat_id = term_exists( $cat_name, 'link_category' ) ) 498 $cat_id = wp_insert_term( $cat_name, 'link_category' ); 499 if ( is_wp_error( $cat_id ) ) 500 continue; 501 else if ( is_array( $cat_id ) ) 502 $cat_id = $cat_id['term_id']; 503 $cat_name = esc_html( stripslashes( $cat_name ) ); 504 $x->add( array( 505 'what' => 'link-category', 506 'id' => $cat_id, 507 'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='" . esc_attr( $cat_id ) . "' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>", 508 'position' => -1 509 ) ); 510 } 511 $x->send(); 512 } 513 514 function ajax_delete_link() { 515 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; 516 517 check_ajax_referer( "delete-bookmark_$id" ); 518 if ( !current_user_can( 'manage_links' ) ) 519 wp_die( -1 ); 520 521 $link = get_bookmark( $id ); 522 if ( !$link || is_wp_error( $link ) ) 523 wp_die( 1 ); 524 525 if ( wp_delete_link( $id ) ) 526 wp_die( 1 ); 527 else 528 wp_die( 0 ); 529 } 530 531 function install_defaults() { 532 global $wpdb; 533 534 if ( get_option( 'default_links_added' ) ) 535 return; 536 537 // Default link category 538 $cat_name = __( 'Blogroll' ); 539 /* translators: Default link category slug */ 540 $cat_slug = sanitize_title( _x( 'Blogroll', 'Default link category slug' ) ); 541 542 if ( global_terms_enabled() ) { 543 $blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) ); 544 if ( $blogroll_id == null ) { 545 $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time( 'mysql', true ) ) ); 546 $blogroll_id = $wpdb->insert_id; 547 } 548 update_option( 'default_link_category', $blogroll_id ); 549 } 550 551 if ( empty( $blogroll_id ) ) 552 $blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM {$wpdb->terms} WHERE name = %s AND slug = %s", $cat_name, $cat_slug ) ); 553 554 if ( empty( $blogroll_id ) ) { 555 $wpdb->insert( $wpdb->terms, array( 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0 ) ); 556 $blogroll_id = $wpdb->insert_id; 557 } 558 559 $wpdb->insert( $wpdb->term_taxonomy, array( 'term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7 ) ); 560 $blogroll_tt_id = $wpdb->insert_id; 561 562 // Now drop in some default links 563 $default_links = array(); 564 $default_links[] = array( 565 'link_url' => __( 'http://codex.wordpress.org/' ), 566 'link_name' => __( 'Documentation' ), 567 'link_rss' => '', 568 'link_notes'=> '' 569 ); 570 571 $default_links[] = array( 572 'link_url' => __( 'http://wordpress.org/news/' ), 573 'link_name' => __( 'WordPress Blog' ), 574 'link_rss' => __( 'http://wordpress.org/news/feed/' ), 575 'link_notes'=> '' 576 ); 577 578 $default_links[] = array( 579 'link_url' => __( 'http://wordpress.org/support/' ), 580 'link_name' => _x( 'Support Forums', 'default link' ), 581 'link_rss' => '', 582 'link_notes'=>'' 583 ); 584 585 $default_links[] = array( 586 'link_url' => 'http://wordpress.org/extend/plugins/', 587 'link_name' => _x( 'Plugins', 'Default link to wordpress.org/extend/plugins/' ), 588 'link_rss' => '', 589 'link_notes'=>'' 590 ); 591 592 $default_links[] = array( 593 'link_url' => 'http://wordpress.org/extend/themes/', 594 'link_name' => _x( 'Themes', 'Default link to wordpress.org/extend/themes/' ), 595 'link_rss' => '', 596 'link_notes'=>'' 597 ); 598 599 $default_links[] = array( 600 'link_url' => __( 'http://wordpress.org/support/forum/requests-and-feedback' ), 601 'link_name' => __( 'Feedback' ), 602 'link_rss' => '', 603 'link_notes'=>'' 604 ); 605 606 $default_links[] = array( 607 'link_url' => __( 'http://planet.wordpress.org/' ), 608 'link_name' => __( 'WordPress Planet' ), 609 'link_rss' => '', 610 'link_notes'=>'' 611 ); 612 613 foreach ( $default_links as $link ) { 614 $wpdb->insert( $wpdb->links, $link ); 615 $wpdb->insert( $wpdb->term_relationships, array( 'term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id ) ); 616 } 617 618 update_option( 'default_links_added', 1 ); 619 } 620 621 /** 622 * Back-compat actions 623 * 624 */ 625 function backcompat_load_taxnow() { 626 global $taxnow; 627 if ( 'link_category' === $taxnow ) 628 do_action( 'load-edit-link-categories.php' ); 629 } 630 631 function link_category_pre_add_form( $taxonomy ) { 632 do_action( 'add_link_category_form_pre', (object) array( 'parent' => 0 ) ); 633 } 634 635 function link_category_add_form( $taxonomy ) { 636 do_action( 'edit_link_category_form', (object) array( 'parent' => 0 ) ); 637 } 638 639 function link_category_pre_edit_form( $tag, $taxonomy ) { 640 do_action( 'edit_link_category_form_pre', $tag ); 641 } 642 643 function link_category_edit_form_fields( $tag, $taxonomy ) { 644 do_action( 'edit_link_category_form_fields', $tag ); 645 } 646 647 function link_category_edit_form( $tag, $taxonomy ) { 648 do_action( 'edit_link_category_form', $tag ); 649 } 650 } 651 LinkManagerPlugin::get_instance(); 652 No newline at end of file -
wp-content/plugins/link-manager/bookmark.php
1 <?php 2 /** 3 * Link/Bookmark API 4 * 5 * @package Link Manager 6 * @subpackage Bookmark 7 */ 8 9 /** 10 * Retrieve Bookmark data 11 * 12 * @since WP 2.1.0 13 * @uses $wpdb Database Object 14 * 15 * @param mixed $bookmark 16 * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant 17 * @param string $filter Optional, default is 'raw'. 18 * @return array|object Type returned depends on $output value. 19 */ 20 function get_bookmark( $bookmark, $output = OBJECT, $filter = 'raw' ) { 21 global $wpdb; 22 23 if ( empty( $bookmark ) ) { 24 if ( isset( $GLOBALS['link']) ) 25 $_bookmark = & $GLOBALS['link']; 26 else 27 $_bookmark = null; 28 } elseif ( is_object( $bookmark ) ) { 29 wp_cache_add( $bookmark->link_id, $bookmark, 'bookmark' ); 30 $_bookmark = $bookmark; 31 } else { 32 if ( isset( $GLOBALS['link']) && ( $GLOBALS['link']->link_id == $bookmark ) ) { 33 $_bookmark = & $GLOBALS['link']; 34 } elseif ( ! $_bookmark = wp_cache_get( $bookmark, 'bookmark' ) ) { 35 $_bookmark = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark ) ); 36 $_bookmark->link_category = array_unique( wp_get_object_terms( $_bookmark->link_id, 'link_category', array( 'fields' => 'ids' ) ) ); 37 wp_cache_add( $_bookmark->link_id, $_bookmark, 'bookmark' ); 38 } 39 } 40 41 $_bookmark = sanitize_bookmark( $_bookmark, $filter ); 42 43 if ( $output == OBJECT ) { 44 return $_bookmark; 45 } elseif ( $output == ARRAY_A ) { 46 return get_object_vars( $_bookmark ); 47 } elseif ( $output == ARRAY_N ) { 48 return array_values(get_object_vars( $_bookmark ) ); 49 } else { 50 return $_bookmark; 51 } 52 } 53 54 /** 55 * Retrieve single bookmark data item or field. 56 * 57 * @since WP 2.3.0 58 * @uses get_bookmark() Gets bookmark object using $bookmark as ID 59 * @uses sanitize_bookmark_field() Sanitizes Bookmark field based on $context. 60 * 61 * @param string $field The name of the data field to return 62 * @param int $bookmark The bookmark ID to get field 63 * @param string $context Optional. The context of how the field will be used. 64 * @return string 65 */ 66 function get_bookmark_field( $field, $bookmark, $context = 'display' ) { 67 $bookmark = (int) $bookmark; 68 $bookmark = get_bookmark( $bookmark ); 69 70 if ( is_wp_error( $bookmark ) ) 71 return $bookmark; 72 73 if ( !is_object( $bookmark ) ) 74 return ''; 75 76 if ( !isset( $bookmark->$field ) ) 77 return ''; 78 79 return sanitize_bookmark_field( $field, $bookmark->$field, $bookmark->link_id, $context ); 80 } 81 82 /** 83 * Retrieves the list of bookmarks 84 * 85 * Attempts to retrieve from the cache first based on MD5 hash of arguments. If 86 * that fails, then the query will be built from the arguments and executed. The 87 * results will be stored to the cache. 88 * 89 * List of default arguments are as follows: 90 * 'orderby' - Default is 'name' (string). How to order the links by. String is 91 * based off of the bookmark scheme. 92 * 'order' - Default is 'ASC' (string). Either 'ASC' or 'DESC'. Orders in either 93 * ascending or descending order. 94 * 'limit' - Default is -1 (integer) or show all. The amount of bookmarks to 95 * display. 96 * 'category' - Default is empty string (string). Include the links in what 97 * category ID(s ). 98 * 'category_name' - Default is empty string (string). Get links by category 99 * name. 100 * 'hide_invisible' - Default is 1 (integer). Whether to show (default) or hide 101 * links marked as 'invisible'. 102 * 'show_updated' - Default is 0 (integer). Will show the time of when the 103 * bookmark was last updated. 104 * 'include' - Default is empty string (string). Include bookmark ID(s ) 105 * separated by commas. 106 * 'exclude' - Default is empty string (string). Exclude bookmark ID(s ) 107 * separated by commas. 108 * 109 * @since WP 2.1.0 110 * @uses $wpdb Database Object 111 * @link http://codex.wordpress.org/Template_Tags/get_bookmarks 112 * 113 * @param string|array $args List of arguments to overwrite the defaults 114 * @return array List of bookmark row objects 115 */ 116 function get_bookmarks( $args = '' ) { 117 global $wpdb; 118 119 $defaults = array( 120 'orderby' => 'name', 'order' => 'ASC', 121 'limit' => -1, 'category' => '', 122 'category_name' => '', 'hide_invisible' => 1, 123 'show_updated' => 0, 'include' => '', 124 'exclude' => '', 'search' => '' 125 ); 126 127 $r = wp_parse_args( $args, $defaults ); 128 extract( $r, EXTR_SKIP ); 129 130 $cache = array(); 131 $key = md5( serialize( $r ) ); 132 if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) { 133 if ( is_array( $cache ) && isset( $cache[ $key ] ) ) 134 return apply_filters( 'get_bookmarks', $cache[ $key ], $r ); 135 } 136 137 if ( !is_array( $cache ) ) 138 $cache = array(); 139 140 $inclusions = ''; 141 if ( !empty( $include ) ) { 142 $exclude = ''; //ignore exclude, category, and category_name params if using include 143 $category = ''; 144 $category_name = ''; 145 $inclinks = preg_split( '/[\s,]+/',$include ); 146 if ( count( $inclinks ) ) { 147 foreach ( $inclinks as $inclink ) { 148 if (empty( $inclusions ) ) 149 $inclusions = ' AND ( link_id = ' . intval( $inclink ) . ' '; 150 else 151 $inclusions .= ' OR link_id = ' . intval( $inclink ) . ' '; 152 } 153 } 154 } 155 if (!empty( $inclusions ) ) 156 $inclusions .= ' )'; 157 158 $exclusions = ''; 159 if ( !empty( $exclude ) ) { 160 $exlinks = preg_split( '/[\s,]+/',$exclude ); 161 if ( count( $exlinks ) ) { 162 foreach ( $exlinks as $exlink ) { 163 if (empty( $exclusions ) ) 164 $exclusions = ' AND ( link_id <> ' . intval( $exlink ) . ' '; 165 else 166 $exclusions .= ' AND link_id <> ' . intval( $exlink ) . ' '; 167 } 168 } 169 } 170 if (!empty( $exclusions ) ) 171 $exclusions .= ' )'; 172 173 if ( !empty( $category_name ) ) { 174 if ( $category = get_term_by( 'name', $category_name, 'link_category' ) ) { 175 $category = $category->term_id; 176 } else { 177 $cache[ $key ] = array(); 178 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); 179 return apply_filters( 'get_bookmarks', array(), $r ); 180 } 181 } 182 183 if ( ! empty( $search ) ) { 184 $search = like_escape( $search ); 185 $search = " AND ( (link_url LIKE '%$search%' ) OR (link_name LIKE '%$search%' ) OR (link_description LIKE '%$search%' ) ) "; 186 } 187 188 $category_query = ''; 189 $join = ''; 190 if ( !empty( $category ) ) { 191 $incategories = preg_split( '/[\s,]+/',$category ); 192 if ( count( $incategories ) ) { 193 foreach ( $incategories as $incat ) { 194 if (empty( $category_query ) ) 195 $category_query = ' AND ( tt.term_id = ' . intval( $incat ) . ' '; 196 else 197 $category_query .= ' OR tt.term_id = ' . intval( $incat ) . ' '; 198 } 199 } 200 } 201 if (!empty( $category_query ) ) { 202 $category_query .= " ) AND taxonomy = 'link_category'"; 203 $join = " INNER JOIN $wpdb->term_relationships AS tr ON ( $wpdb->links.link_id = tr.object_id) INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id"; 204 } 205 206 if ( $show_updated && get_option( 'links_recently_updated_time' ) ) { 207 $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_option( 'links_recently_updated_time' ) . " MINUTe ) >= NOW(), 1,0) as recently_updated "; 208 } else { 209 $recently_updated_test = ''; 210 } 211 212 $get_updated = ( $show_updated ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : ''; 213 214 $orderby = strtolower( $orderby ); 215 $length = ''; 216 switch ( $orderby ) { 217 case 'length': 218 $length = ", CHAR_LENGTH(link_name ) AS length"; 219 break; 220 case 'rand': 221 $orderby = 'rand()'; 222 break; 223 case 'link_id': 224 $orderby = "$wpdb->links.link_id"; 225 break; 226 default: 227 $orderparams = array(); 228 foreach ( explode( ',', $orderby ) as $ordparam ) { 229 $ordparam = trim( $ordparam ); 230 $keys = array( 'link_id', 'link_name', 'link_url', 'link_visible', 'link_rating', 'link_owner', 'link_updated', 'link_notes' ); 231 if ( in_array( 'link_' . $ordparam, $keys ) ) 232 $orderparams[] = 'link_' . $ordparam; 233 elseif ( in_array( $ordparam, $keys ) ) 234 $orderparams[] = $ordparam; 235 } 236 $orderby = implode( ',', $orderparams ); 237 } 238 239 if ( empty( $orderby ) ) 240 $orderby = 'link_name'; 241 242 $order = strtoupper( $order ); 243 if ( '' !== $order && !in_array( $order, array( 'ASC', 'DESC' ) ) ) 244 $order = 'ASC'; 245 246 $visible = ''; 247 if ( $hide_invisible ) 248 $visible = "AND link_visible = 'Y'"; 249 250 $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query"; 251 $query .= " $exclusions $inclusions $search"; 252 $query .= " ORDER BY $orderby $order"; 253 if ( $limit != -1) 254 $query .= " LIMIT $limit"; 255 256 $results = $wpdb->get_results( $query ); 257 258 $cache[ $key ] = $results; 259 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); 260 261 return apply_filters( 'get_bookmarks', $results, $r ); 262 } 263 264 /** 265 * Sanitizes all bookmark fields 266 * 267 * @since WP 2.3.0 268 * 269 * @param object|array $bookmark Bookmark row 270 * @param string $context Optional, default is 'display'. How to filter the 271 * fields 272 * @return object|array Same type as $bookmark but with fields sanitized. 273 */ 274 function sanitize_bookmark( $bookmark, $context = 'display' ) { 275 $fields = array( 'link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category', 276 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated', 277 'link_rel', 'link_notes', 'link_rss', ); 278 279 if ( is_object( $bookmark ) ) { 280 $do_object = true; 281 $link_id = $bookmark->link_id; 282 } else { 283 $do_object = false; 284 $link_id = $bookmark['link_id']; 285 } 286 287 foreach ( $fields as $field ) { 288 if ( $do_object ) { 289 if ( isset( $bookmark->$field ) ) 290 $bookmark->$field = sanitize_bookmark_field( $field, $bookmark->$field, $link_id, $context ); 291 } else { 292 if ( isset( $bookmark[$field]) ) 293 $bookmark[$field] = sanitize_bookmark_field( $field, $bookmark[$field], $link_id, $context ); 294 } 295 } 296 297 return $bookmark; 298 } 299 300 /** 301 * Sanitizes a bookmark field 302 * 303 * Sanitizes the bookmark fields based on what the field name is. If the field 304 * has a strict value set, then it will be tested for that, else a more generic 305 * filtering is applied. After the more strict filter is applied, if the 306 * $context is 'raw' then the value is immediately return. 307 * 308 * Hooks exist for the more generic cases. With the 'edit' context, the 309 * 'edit_$field' filter will be called and passed the $value and $bookmark_id 310 * respectively. With the 'db' context, the 'pre_$field' filter is called and 311 * passed the value. The 'display' context is the final context and has the 312 * $field has the filter name and is passed the $value, $bookmark_id, and 313 * $context respectively. 314 * 315 * @since WP 2.3.0 316 * 317 * @param string $field The bookmark field 318 * @param mixed $value The bookmark field value 319 * @param int $bookmark_id Bookmark ID 320 * @param string $context How to filter the field value. Either 'raw', 'edit', 321 * 'attribute', 'js', 'db', or 'display' 322 * @return mixed The filtered value 323 */ 324 function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) { 325 switch ( $field ) { 326 case 'link_id' : // ints 327 case 'link_rating' : 328 $value = (int) $value; 329 break; 330 case 'link_category' : // array( ints ) 331 $value = array_map( 'absint', (array) $value ); 332 // We return here so that the categories aren't filtered. 333 // The 'link_category' filter is for the name of a link category, not an array of a link's link categories 334 return $value; 335 break; 336 case 'link_visible' : // bool stored as Y|N 337 $value = preg_replace( '/[^YNyn]/', '', $value ); 338 break; 339 case 'link_target' : // "enum" 340 $targets = array( '_top', '_blank' ); 341 if ( ! in_array( $value, $targets ) ) 342 $value = ''; 343 break; 344 } 345 346 if ( 'raw' == $context ) 347 return $value; 348 349 if ( 'edit' == $context ) { 350 $value = apply_filters( "edit_$field", $value, $bookmark_id ); 351 352 if ( 'link_notes' == $field ) { 353 $value = esc_html( $value ); // textarea_escaped 354 } else { 355 $value = esc_attr( $value ); 356 } 357 } else if ( 'db' == $context ) { 358 $value = apply_filters( "pre_$field", $value ); 359 } else { 360 // Use display filters by default. 361 $value = apply_filters( $field, $value, $bookmark_id, $context ); 362 363 if ( 'attribute' == $context ) 364 $value = esc_attr( $value ); 365 else if ( 'js' == $context ) 366 $value = esc_js( $value ); 367 } 368 369 return $value; 370 } 371 372 /** 373 * Deletes bookmark cache 374 * 375 * @since WP 2.7.0 376 * @uses wp_cache_delete() Deletes the contents of 'get_bookmarks' 377 */ 378 function clean_bookmark_cache( $bookmark_id ) { 379 wp_cache_delete( $bookmark_id, 'bookmark' ); 380 wp_cache_delete( 'get_bookmarks', 'bookmark' ); 381 clean_object_term_cache( $bookmark_id, 'link' ); 382 } -
wp-content/plugins/link-manager/functions.php
1 <?php 2 /** 3 * Add sub menu page to the links main menu. 4 * 5 * This function takes a capability which will be used to determine whether 6 * or not a page is included in the menu. 7 * 8 * The function which is hooked in to handle the output of the page must check 9 * that the user has the required capability as well. 10 * 11 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected 12 * @param string $menu_title The text to be used for the menu 13 * @param string $capability The capability required for this menu to be displayed to the user. 14 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 15 * @param callback $function The function to be called to output the content for this page. 16 * 17 * @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required. 18 */ 19 function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { 20 return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function ); 21 } 22 23 /** 24 * Display edit bookmark (literally a URL external to blog) link anchor content. 25 * 26 * @since 2.7.0 27 * 28 * @param string $link Optional. Anchor text. 29 * @param string $before Optional. Display before edit link. 30 * @param string $after Optional. Display after edit link. 31 * @param int $bookmark Optional. Bookmark ID. 32 */ 33 function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) { 34 $bookmark = get_bookmark( $bookmark ); 35 36 if ( !current_user_can('manage_links') ) 37 return; 38 39 if ( empty($link) ) 40 $link = __('Edit This'); 41 42 $link = '<a href="' . get_edit_bookmark_link( $bookmark ) . '" title="' . esc_attr__( 'Edit Link' ) . '">' . $link . '</a>'; 43 echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; 44 } 45 46 /** 47 * Display edit bookmark (literally a URL external to blog) link. 48 * 49 * @since 2.7.0 50 * 51 * @param int $link Optional. Bookmark ID. 52 * @return string 53 */ 54 function get_edit_bookmark_link( $link = 0 ) { 55 $link = get_bookmark( $link ); 56 57 if ( !current_user_can('manage_links') ) 58 return; 59 60 $menu_page_url = menu_page_url( 'link-manager.php', false ); 61 $location = add_query_arg( array( 'action' => 'edit', 'link_id' => $link->link_id ), $menu_page_url ); 62 return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id ); 63 } 64 65 /** 66 * Add a link to using values provided in $_POST. 67 * 68 * @since WP 2.0.0 69 * 70 * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. 71 */ 72 function add_link() { 73 return edit_link(); 74 } 75 76 /** 77 * Update or insert a link using values provided in $_POST. 78 * 79 * @since WP 2.0.0 80 * 81 * @param int $link_id Optional. ID of the link to edit. 82 * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. 83 */ 84 function edit_link( $link_id = 0 ) { 85 if ( !current_user_can( 'manage_links' ) ) 86 wp_die( __( 'Cheatin’ uh?' ) ); 87 88 $_POST['link_url'] = esc_html( $_POST['link_url'] ); 89 $_POST['link_url'] = esc_url($_POST['link_url']); 90 $_POST['link_name'] = esc_html( $_POST['link_name'] ); 91 $_POST['link_image'] = esc_html( $_POST['link_image'] ); 92 $_POST['link_rss'] = esc_url( $_POST['link_rss'] ); 93 if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] ) 94 $_POST['link_visible'] = 'Y'; 95 96 if ( !empty( $link_id ) ) { 97 $_POST['link_id'] = $link_id; 98 return wp_update_link( $_POST ); 99 } else { 100 return wp_insert_link( $_POST ); 101 } 102 } 103 104 /** 105 * Retrieve the default link for editing. 106 * 107 * @since WP 2.0.0 108 * 109 * @return object Default link 110 */ 111 function get_default_link_to_edit() { 112 $link = new stdClass; 113 if ( isset( $_GET['linkurl'] ) ) 114 $link->link_url = esc_url( $_GET['linkurl'] ); 115 else 116 $link->link_url = ''; 117 118 if ( isset( $_GET['name'] ) ) 119 $link->link_name = esc_attr( $_GET['name'] ); 120 else 121 $link->link_name = ''; 122 123 $link->link_visible = 'Y'; 124 125 return $link; 126 } 127 128 /** 129 * Delete link specified from database 130 * 131 * @since WP 2.0.0 132 * 133 * @param int $link_id ID of the link to delete 134 * @return bool True 135 */ 136 function wp_delete_link( $link_id ) { 137 global $wpdb; 138 139 do_action( 'delete_link', $link_id ); 140 141 wp_delete_object_term_relationships( $link_id, 'link_category' ); 142 143 $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) ); 144 145 do_action( 'deleted_link', $link_id ); 146 147 clean_bookmark_cache( $link_id ); 148 149 return true; 150 } 151 152 /** 153 * Retrieves the link categories associated with the link specified. 154 * 155 * @since WP 2.1.0 156 * 157 * @param int $link_id Link ID to look up 158 * @return array The requested link's categories 159 */ 160 function wp_get_link_cats( $link_id = 0 ) { 161 162 $cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) ); 163 164 return array_unique( $cats ); 165 } 166 167 /** 168 * Retrieve link data based on ID. 169 * 170 * @since WP 2.0.0 171 * 172 * @param int $link_id ID of link to retrieve 173 * @return object Link for editing 174 */ 175 function get_link_to_edit( $link_id ) { 176 return get_bookmark( $link_id, OBJECT, 'edit' ); 177 } 178 179 /** 180 * This function inserts/updates links into/in the database. 181 * 182 * @since WP 2.0.0 183 * 184 * @param array $linkdata Elements that make up the link to insert. 185 * @param bool $wp_error Optional. If true return WP_Error object on failure. 186 * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. 187 */ 188 function wp_insert_link( $linkdata, $wp_error = false ) { 189 global $wpdb; 190 191 $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 ); 192 193 $linkdata = wp_parse_args( $linkdata, $defaults ); 194 $linkdata = sanitize_bookmark( $linkdata, 'db' ); 195 196 extract( stripslashes_deep( $linkdata ), EXTR_SKIP ); 197 198 $update = false; 199 200 if ( !empty( $link_id ) ) 201 $update = true; 202 203 if ( trim( $link_name ) == '' ) { 204 if ( trim( $link_url ) != '' ) { 205 $link_name = $link_url; 206 } else { 207 return 0; 208 } 209 } 210 211 if ( trim( $link_url ) == '' ) 212 return 0; 213 214 if ( empty( $link_rating ) ) 215 $link_rating = 0; 216 217 if ( empty( $link_image ) ) 218 $link_image = ''; 219 220 if ( empty( $link_target ) ) 221 $link_target = ''; 222 223 if ( empty( $link_visible ) ) 224 $link_visible = 'Y'; 225 226 if ( empty( $link_owner ) ) 227 $link_owner = get_current_user_id(); 228 229 if ( empty( $link_notes ) ) 230 $link_notes = ''; 231 232 if ( empty( $link_description ) ) 233 $link_description = ''; 234 235 if ( empty( $link_rss ) ) 236 $link_rss = ''; 237 238 if ( empty( $link_rel ) ) 239 $link_rel = ''; 240 241 // Make sure we set a valid category 242 if ( ! isset( $link_category ) || 0 == count( $link_category ) || !is_array( $link_category ) ) { 243 $link_category = array( get_option( 'default_link_category' ) ); 244 } 245 246 if ( $update ) { 247 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' ) ) ) { 248 if ( $wp_error ) 249 return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error ); 250 else 251 return 0; 252 } 253 } else { 254 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' ) ) ) { 255 if ( $wp_error ) 256 return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error ); 257 else 258 return 0; 259 } 260 $link_id = (int) $wpdb->insert_id; 261 } 262 263 wp_set_link_cats( $link_id, $link_category ); 264 265 if ( $update ) 266 do_action( 'edit_link', $link_id ); 267 else 268 do_action( 'add_link', $link_id ); 269 270 clean_bookmark_cache( $link_id ); 271 272 return $link_id; 273 } 274 275 /** 276 * Update link with the specified link categories. 277 * 278 * @since WP 2.1.0 279 * 280 * @param int $link_id ID of link to update 281 * @param array $link_categories Array of categories to 282 */ 283 function wp_set_link_cats( $link_id = 0, $link_categories = array() ) { 284 // If $link_categories isn't already an array, make it one: 285 if ( !is_array( $link_categories ) || 0 == count( $link_categories ) ) 286 $link_categories = array( get_option( 'default_link_category' ) ); 287 288 $link_categories = array_map( 'intval', $link_categories ); 289 $link_categories = array_unique( $link_categories ); 290 291 wp_set_object_terms( $link_id, $link_categories, 'link_category' ); 292 293 clean_bookmark_cache( $link_id ); 294 } 295 296 /** 297 * Update a link in the database. 298 * 299 * @since WP 2.0.0 300 * 301 * @param array $linkdata Link data to update. 302 * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success. 303 */ 304 function wp_update_link( $linkdata ) { 305 $link_id = (int) $linkdata['link_id']; 306 307 $link = get_bookmark( $link_id, ARRAY_A ); 308 309 // Escape data pulled from DB. 310 $link = add_magic_quotes( $link ); 311 312 // Passed link category list overwrites existing category list if not empty. 313 if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) 314 && 0 != count( $linkdata['link_category'] ) ) 315 $link_cats = $linkdata['link_category']; 316 else 317 $link_cats = $link['link_category']; 318 319 // Merge old and new fields with new fields overwriting old ones. 320 $linkdata = array_merge( $link, $linkdata ); 321 $linkdata['link_category'] = $link_cats; 322 323 return wp_insert_link( $linkdata ); 324 } 325 326 327 /** 328 * {@internal Missing Short Description}} 329 * 330 * @since 2.5.1 331 * 332 * @param unknown_type $link_id 333 */ 334 function wp_link_category_checklist( $link_id = 0 ) { 335 $default = 1; 336 337 if ( $link_id ) { 338 $checked_categories = wp_get_link_cats( $link_id ); 339 // No selected categories, strange 340 if ( ! count( $checked_categories ) ) 341 $checked_categories[] = $default; 342 } else { 343 $checked_categories[] = $default; 344 } 345 346 $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) ); 347 348 if ( empty( $categories ) ) 349 return; 350 351 foreach ( $categories as $category ) { 352 $cat_id = $category->term_id; 353 $name = esc_html( apply_filters( 'the_category', $category->name ) ); 354 $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : ''; 355 echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>"; 356 } 357 } 358 No newline at end of file -
wp-settings.php
125 125 require( ABSPATH . WPINC . '/comment-template.php' ); 126 126 require( ABSPATH . WPINC . '/rewrite.php' ); 127 127 require( ABSPATH . WPINC . '/feed.php' ); 128 require( ABSPATH . WPINC . '/bookmark.php' );129 require( ABSPATH . WPINC . '/bookmark-template.php' );130 128 require( ABSPATH . WPINC . '/kses.php' ); 131 129 require( ABSPATH . WPINC . '/cron.php' ); 132 130 require( ABSPATH . WPINC . '/deprecated.php' ); -
wp-admin/users.php
212 212 ?> 213 213 </ul> 214 214 <?php if ( $go_delete ) : ?> 215 <fieldset><p><legend><?php echo _n( 'What should be done with posts and links owned by this user?', 'What should be done with posts and links owned by these users?', $go_delete ); ?></legend></p>215 <fieldset><p><legend><?php echo _n( 'What should be done with posts owned by this user?', 'What should be done with posts owned by these users?', $go_delete ); ?></legend></p> 216 216 <ul style="list-style:none;"> 217 217 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" /> 218 <?php _e('Delete all posts and links.'); ?></label></li>218 <?php _e('Delete all posts.'); ?></label></li> 219 219 <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> 220 <?php echo '<label for="delete_option1">'.__('Attribute all posts and linksto:').'</label>';220 <?php echo '<label for="delete_option1">'.__('Attribute all posts to:').'</label>'; 221 221 wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> 222 222 </ul></fieldset> 223 223 <input type="hidden" name="action" value="dodelete" /> -
wp-admin/admin-ajax.php
42 42 ); 43 43 44 44 $core_actions_post = array( 45 'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',45 'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 46 46 'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment', 47 'add- link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',47 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment', 48 48 'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'autosave', 'closed-postboxes', 49 49 'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax', 50 50 'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink', -
wp-admin/includes/plugin.php
1210 1210 } 1211 1211 1212 1212 /** 1213 * Add sub menu page to the links main menu.1214 *1215 * This function takes a capability which will be used to determine whether1216 * or not a page is included in the menu.1217 *1218 * The function which is hooked in to handle the output of the page must check1219 * that the user has the required capability as well.1220 *1221 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected1222 * @param string $menu_title The text to be used for the menu1223 * @param string $capability The capability required for this menu to be displayed to the user.1224 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)1225 * @param callback $function The function to be called to output the content for this page.1226 *1227 * @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.1228 */1229 function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {1230 return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function );1231 }1232 1233 /**1234 1213 * Add sub menu page to the pages main menu. 1235 1214 * 1236 1215 * This function takes a capability which will be used to determine whether -
wp-admin/includes/list-table.php
25 25 'WP_Users_List_Table' => 'users', 26 26 'WP_Comments_List_Table' => 'comments', 27 27 'WP_Post_Comments_List_Table' => 'comments', 28 'WP_Links_List_Table' => 'links',29 28 'WP_Plugin_Install_List_Table' => 'plugin-install', 30 29 'WP_Themes_List_Table' => 'themes', 31 30 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ), -
wp-admin/includes/bookmark.php
1 <?php2 /**3 * WordPress Bookmark Administration API4 *5 * @package WordPress6 * @subpackage Administration7 */8 9 /**10 * Add a link to using values provided in $_POST.11 *12 * @since 2.0.013 *14 * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.15 */16 function add_link() {17 return edit_link();18 }19 20 /**21 * Update or insert a link using values provided in $_POST.22 *23 * @since 2.0.024 *25 * @param int $link_id Optional. ID of the link to edit.26 * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.27 */28 function edit_link( $link_id = 0 ) {29 if ( !current_user_can( 'manage_links' ) )30 wp_die( __( 'Cheatin’ uh?' ) );31 32 $_POST['link_url'] = esc_html( $_POST['link_url'] );33 $_POST['link_url'] = esc_url($_POST['link_url']);34 $_POST['link_name'] = esc_html( $_POST['link_name'] );35 $_POST['link_image'] = esc_html( $_POST['link_image'] );36 $_POST['link_rss'] = esc_url($_POST['link_rss']);37 if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )38 $_POST['link_visible'] = 'Y';39 40 if ( !empty( $link_id ) ) {41 $_POST['link_id'] = $link_id;42 return wp_update_link( $_POST );43 } else {44 return wp_insert_link( $_POST );45 }46 }47 48 /**49 * Retrieve the default link for editing.50 *51 * @since 2.0.052 *53 * @return object Default link54 */55 function get_default_link_to_edit() {56 $link = new stdClass;57 if ( isset( $_GET['linkurl'] ) )58 $link->link_url = esc_url( $_GET['linkurl'] );59 else60 $link->link_url = '';61 62 if ( isset( $_GET['name'] ) )63 $link->link_name = esc_attr( $_GET['name'] );64 else65 $link->link_name = '';66 67 $link->link_visible = 'Y';68 69 return $link;70 }71 72 /**73 * Delete link specified from database74 *75 * @since 2.0.076 *77 * @param int $link_id ID of the link to delete78 * @return bool True79 */80 function wp_delete_link( $link_id ) {81 global $wpdb;82 83 do_action( 'delete_link', $link_id );84 85 wp_delete_object_term_relationships( $link_id, 'link_category' );86 87 $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );88 89 do_action( 'deleted_link', $link_id );90 91 clean_bookmark_cache( $link_id );92 93 return true;94 }95 96 /**97 * Retrieves the link categories associated with the link specified.98 *99 * @since 2.1.0100 *101 * @param int $link_id Link ID to look up102 * @return array The requested link's categories103 */104 function wp_get_link_cats( $link_id = 0 ) {105 106 $cats = wp_get_object_terms( $link_id, 'link_category', array('fields' => 'ids') );107 108 return array_unique( $cats );109 }110 111 /**112 * Retrieve link data based on ID.113 *114 * @since 2.0.0115 *116 * @param int $link_id ID of link to retrieve117 * @return object Link for editing118 */119 function get_link_to_edit( $link_id ) {120 return get_bookmark( $link_id, OBJECT, 'edit' );121 }122 123 /**124 * This function inserts/updates links into/in the database.125 *126 * @since 2.0.0127 *128 * @param array $linkdata Elements that make up the link to insert.129 * @param bool $wp_error Optional. If true return WP_Error object on failure.130 * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.131 */132 function wp_insert_link( $linkdata, $wp_error = false ) {133 global $wpdb;134 135 $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );136 137 $linkdata = wp_parse_args( $linkdata, $defaults );138 $linkdata = sanitize_bookmark( $linkdata, 'db' );139 140 extract( stripslashes_deep( $linkdata ), EXTR_SKIP );141 142 $update = false;143 144 if ( !empty( $link_id ) )145 $update = true;146 147 if ( trim( $link_name ) == '' ) {148 if ( trim( $link_url ) != '' ) {149 $link_name = $link_url;150 } else {151 return 0;152 }153 }154 155 if ( trim( $link_url ) == '' )156 return 0;157 158 if ( empty( $link_rating ) )159 $link_rating = 0;160 161 if ( empty( $link_image ) )162 $link_image = '';163 164 if ( empty( $link_target ) )165 $link_target = '';166 167 if ( empty( $link_visible ) )168 $link_visible = 'Y';169 170 if ( empty( $link_owner ) )171 $link_owner = get_current_user_id();172 173 if ( empty( $link_notes ) )174 $link_notes = '';175 176 if ( empty( $link_description ) )177 $link_description = '';178 179 if ( empty( $link_rss ) )180 $link_rss = '';181 182 if ( empty( $link_rel ) )183 $link_rel = '';184 185 // Make sure we set a valid category186 if ( ! isset( $link_category ) || 0 == count( $link_category ) || !is_array( $link_category ) ) {187 $link_category = array( get_option( 'default_link_category' ) );188 }189 190 if ( $update ) {191 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') ) ) {192 if ( $wp_error )193 return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error );194 else195 return 0;196 }197 } else {198 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') ) ) {199 if ( $wp_error )200 return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error );201 else202 return 0;203 }204 $link_id = (int) $wpdb->insert_id;205 }206 207 wp_set_link_cats( $link_id, $link_category );208 209 if ( $update )210 do_action( 'edit_link', $link_id );211 else212 do_action( 'add_link', $link_id );213 214 clean_bookmark_cache( $link_id );215 216 return $link_id;217 }218 219 /**220 * Update link with the specified link categories.221 *222 * @since 2.1.0223 *224 * @param int $link_id ID of link to update225 * @param array $link_categories Array of categories to226 */227 function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {228 // If $link_categories isn't already an array, make it one:229 if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )230 $link_categories = array( get_option( 'default_link_category' ) );231 232 $link_categories = array_map( 'intval', $link_categories );233 $link_categories = array_unique( $link_categories );234 235 wp_set_object_terms( $link_id, $link_categories, 'link_category' );236 237 clean_bookmark_cache( $link_id );238 }239 240 /**241 * Update a link in the database.242 *243 * @since 2.0.0244 *245 * @param array $linkdata Link data to update.246 * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success.247 */248 function wp_update_link( $linkdata ) {249 $link_id = (int) $linkdata['link_id'];250 251 $link = get_bookmark( $link_id, ARRAY_A );252 253 // Escape data pulled from DB.254 $link = add_magic_quotes( $link );255 256 // Passed link category list overwrites existing category list if not empty.257 if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )258 && 0 != count( $linkdata['link_category'] ) )259 $link_cats = $linkdata['link_category'];260 else261 $link_cats = $link['link_category'];262 263 // Merge old and new fields with new fields overwriting old ones.264 $linkdata = array_merge( $link, $linkdata );265 $linkdata['link_category'] = $link_cats;266 267 return wp_insert_link( $linkdata );268 } -
wp-admin/includes/class-wp-links-list-table.php
1 <?php2 /**3 * Links Manager List Table class.4 *5 * @package WordPress6 * @subpackage List_Table7 * @since 3.1.08 * @access private9 */10 class WP_Links_List_Table extends WP_List_Table {11 12 function __construct() {13 parent::__construct( array(14 'plural' => 'bookmarks',15 ) );16 }17 18 function ajax_user_can() {19 return current_user_can( 'manage_links' );20 }21 22 function prepare_items() {23 global $cat_id, $s, $orderby, $order;24 25 wp_reset_vars( array( 'action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'orderby', 'order', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]', 's' ) );26 27 $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 );28 29 if ( 'all' != $cat_id )30 $args['category'] = $cat_id;31 if ( !empty( $s ) )32 $args['search'] = $s;33 if ( !empty( $orderby ) )34 $args['orderby'] = $orderby;35 if ( !empty( $order ) )36 $args['order'] = $order;37 38 $this->items = get_bookmarks( $args );39 }40 41 function no_items() {42 _e( 'No links found.' );43 }44 45 function get_bulk_actions() {46 $actions = array();47 $actions['delete'] = __( 'Delete' );48 49 return $actions;50 }51 52 function extra_tablenav( $which ) {53 global $cat_id;54 55 if ( 'top' != $which )56 return;57 ?>58 <div class="alignleft actions">59 <?php60 $dropdown_options = array(61 'selected' => $cat_id,62 'name' => 'cat_id',63 'taxonomy' => 'link_category',64 'show_option_all' => __( 'View all categories' ),65 'hide_empty' => true,66 'hierarchical' => 1,67 'show_count' => 0,68 'orderby' => 'name',69 );70 wp_dropdown_categories( $dropdown_options );71 submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );72 ?>73 </div>74 <?php75 }76 77 function get_columns() {78 return array(79 'cb' => '<input type="checkbox" />',80 'name' => _x( 'Name', 'link name' ),81 'url' => __( 'URL' ),82 'categories' => __( 'Categories' ),83 'rel' => __( 'Relationship' ),84 'visible' => __( 'Visible' ),85 'rating' => __( 'Rating' )86 );87 }88 89 function get_sortable_columns() {90 return array(91 'name' => 'name',92 'url' => 'url',93 'visible' => 'visible',94 'rating' => 'rating'95 );96 }97 98 function display_rows() {99 global $cat_id;100 101 $alt = 0;102 103 foreach ( $this->items as $link ) {104 $link = sanitize_bookmark( $link );105 $link->link_name = esc_attr( $link->link_name );106 $link->link_category = wp_get_link_cats( $link->link_id );107 108 $short_url = url_shorten( $link->link_url );109 110 $visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' );111 $rating = $link->link_rating;112 $style = ( $alt++ % 2 ) ? '' : ' class="alternate"';113 114 $edit_link = get_edit_bookmark_link( $link );115 ?>116 <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>117 <?php118 119 list( $columns, $hidden ) = $this->get_column_info();120 121 foreach ( $columns as $column_name => $column_display_name ) {122 $class = "class='column-$column_name'";123 124 $style = '';125 if ( in_array( $column_name, $hidden ) )126 $style = ' style="display:none;"';127 128 $attributes = $class . $style;129 130 switch ( $column_name ) {131 case 'cb': ?>132 <th scope="row" class="check-column">133 <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf( __( 'Select %s' ), $link->link_name ); ?></label>134 <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />135 </th>136 <?php137 break;138 139 case 'name':140 echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ) . "'>$link->link_name</a></strong><br />";141 142 $actions = array();143 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';144 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&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>";145 echo $this->row_actions( $actions );146 147 echo '</td>';148 break;149 case 'url':150 echo "<td $attributes><a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a></td>";151 break;152 case 'categories':153 ?><td <?php echo $attributes ?>><?php154 $cat_names = array();155 foreach ( $link->link_category as $category ) {156 $cat = get_term( $category, 'link_category', OBJECT, 'display' );157 if ( is_wp_error( $cat ) )158 echo $cat->get_error_message();159 $cat_name = $cat->name;160 if ( $cat_id != $category )161 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";162 $cat_names[] = $cat_name;163 }164 echo implode( ', ', $cat_names );165 ?></td><?php166 break;167 case 'rel':168 ?><td <?php echo $attributes ?>><?php echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; ?></td><?php169 break;170 case 'visible':171 ?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php172 break;173 case 'rating':174 ?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php175 break;176 default:177 ?>178 <td <?php echo $attributes ?>><?php do_action( 'manage_link_custom_column', $column_name, $link->link_id ); ?></td>179 <?php180 break;181 }182 }183 ?>184 </tr>185 <?php186 }187 }188 } -
wp-admin/includes/class-wp-terms-list-table.php
102 102 'slug' => __( 'Slug' ), 103 103 ); 104 104 105 if ( 'link_category' == $taxonomy ) { 106 $columns['links'] = __( 'Links' ); 107 } else { 105 if ( $post_type ) { 108 106 $post_type_object = get_post_type_object( $post_type ); 109 107 $columns['posts'] = $post_type_object ? $post_type_object->labels->name : __( 'Posts' ); 110 108 } 111 109 110 $columns = apply_filters( 'terms_list_table_columns', $columns ); 111 112 112 return $columns; 113 113 } 114 114 -
wp-admin/includes/ajax-actions.php
425 425 wp_die( 0 ); 426 426 } 427 427 428 function wp_ajax_delete_link() {429 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;430 431 check_ajax_referer( "delete-bookmark_$id" );432 if ( !current_user_can( 'manage_links' ) )433 wp_die( -1 );434 435 $link = get_bookmark( $id );436 if ( !$link || is_wp_error( $link ) )437 wp_die( 1 );438 439 if ( wp_delete_link( $id ) )440 wp_die( 1 );441 else442 wp_die( 0 );443 }444 445 428 function wp_ajax_delete_meta() { 446 429 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; 447 430 … … 558 541 wp_die( 0 ); 559 542 } 560 543 561 function wp_ajax_add_link_category( $action ) {562 if ( empty( $action ) )563 $action = 'add-link-category';564 check_ajax_referer( $action );565 if ( !current_user_can( 'manage_categories' ) )566 wp_die( -1 );567 $names = explode(',', $_POST['newcat']);568 $x = new WP_Ajax_Response();569 foreach ( $names as $cat_name ) {570 $cat_name = trim($cat_name);571 $slug = sanitize_title($cat_name);572 if ( '' === $slug )573 continue;574 if ( !$cat_id = term_exists( $cat_name, 'link_category' ) )575 $cat_id = wp_insert_term( $cat_name, 'link_category' );576 if ( is_wp_error( $cat_id ) )577 continue;578 else if ( is_array( $cat_id ) )579 $cat_id = $cat_id['term_id'];580 $cat_name = esc_html(stripslashes($cat_name));581 $x->add( array(582 'what' => 'link-category',583 'id' => $cat_id,584 'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='" . esc_attr($cat_id) . "' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>",585 'position' => -1586 ) );587 }588 $x->send();589 }590 591 544 function wp_ajax_add_tag() { 592 545 global $wp_list_table; 593 546 -
wp-admin/includes/upgrade.php
123 123 $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1)); 124 124 $cat_tt_id = $wpdb->insert_id; 125 125 126 // Default link category127 $cat_name = __('Blogroll');128 /* translators: Default link category slug */129 $cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));130 131 if ( global_terms_enabled() ) {132 $blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );133 if ( $blogroll_id == null ) {134 $wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );135 $blogroll_id = $wpdb->insert_id;136 }137 update_option('default_link_category', $blogroll_id);138 } else {139 $blogroll_id = 2;140 }141 142 $wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );143 $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));144 $blogroll_tt_id = $wpdb->insert_id;145 146 // Now drop in some default links147 $default_links = array();148 $default_links[] = array( 'link_url' => __( 'http://codex.wordpress.org/' ),149 'link_name' => __( 'Documentation' ),150 'link_rss' => '',151 'link_notes' => '');152 153 $default_links[] = array( 'link_url' => __( 'http://wordpress.org/news/' ),154 'link_name' => __( 'WordPress Blog' ),155 'link_rss' => __( 'http://wordpress.org/news/feed/' ),156 'link_notes' => '');157 158 $default_links[] = array( 'link_url' => __( 'http://wordpress.org/support/' ),159 'link_name' => _x( 'Support Forums', 'default link' ),160 'link_rss' => '',161 'link_notes' =>'');162 163 $default_links[] = array( 'link_url' => 'http://wordpress.org/extend/plugins/',164 'link_name' => _x( 'Plugins', 'Default link to wordpress.org/extend/plugins/' ),165 'link_rss' => '',166 'link_notes' =>'');167 168 $default_links[] = array( 'link_url' => 'http://wordpress.org/extend/themes/',169 'link_name' => _x( 'Themes', 'Default link to wordpress.org/extend/themes/' ),170 'link_rss' => '',171 'link_notes' =>'');172 173 $default_links[] = array( 'link_url' => __( 'http://wordpress.org/support/forum/requests-and-feedback' ),174 'link_name' => __( 'Feedback' ),175 'link_rss' => '',176 'link_notes' =>'');177 178 $default_links[] = array( 'link_url' => __( 'http://planet.wordpress.org/' ),179 'link_name' => __( 'WordPress Planet' ),180 'link_rss' => '',181 'link_notes' =>'');182 183 foreach ( $default_links as $link ) {184 $wpdb->insert( $wpdb->links, $link);185 $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id) );186 }187 188 126 // First post 189 127 $now = date('Y-m-d H:i:s'); 190 128 $now_gmt = gmdate('Y-m-d H:i:s'); … … 303 241 if ( !is_super_admin( $user_id ) && $user_id != 1 ) 304 242 $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); 305 243 } 244 245 do_action( 'install_defaults' ); 306 246 } 307 247 endif; 308 248 -
wp-admin/includes/admin.php
13 13 load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' ); 14 14 } 15 15 16 /** WordPress Bookmark Administration API */17 require_once(ABSPATH . 'wp-admin/includes/bookmark.php');18 19 16 /** WordPress Comment Administration API */ 20 17 require_once(ABSPATH . 'wp-admin/includes/comment.php'); 21 18 -
wp-admin/includes/deprecated.php
75 75 /** 76 76 * {@internal Missing Short Description}} 77 77 * 78 * @since 2.1.079 * @deprecated 2.6.080 * @deprecated Use wp_link_category_checklist()81 * @see wp_link_category_checklist()82 *83 * @param unknown_type $default84 */85 function dropdown_link_categories( $default = 0 ) {86 _deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' );87 global $link_id;88 wp_link_category_checklist( $link_id );89 }90 91 /**92 * {@internal Missing Short Description}}93 *94 78 * @since 1.2.0 95 79 * @deprecated 3.0.0 96 80 * @deprecated Use wp_dropdown_categories() -
wp-admin/includes/meta-boxes.php
590 590 <?php 591 591 } 592 592 593 // -- Link related Meta Boxes594 595 593 /** 596 * Display link create form fields.597 *598 * @since 2.7.0599 *600 * @param object $link601 */602 function link_submit_meta_box($link) {603 ?>604 <div class="submitbox" id="submitlink">605 606 <div id="minor-publishing">607 608 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>609 <div style="display:none;">610 <?php submit_button( __( 'Save' ), 'button', 'save', false ); ?>611 </div>612 613 <div id="minor-publishing-actions">614 <div id="preview-action">615 <?php if ( !empty($link->link_id) ) { ?>616 <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e('Visit Link'); ?></a>617 <?php } ?>618 </div>619 <div class="clear"></div>620 </div>621 622 <div id="misc-publishing-actions">623 <div class="misc-pub-section">624 <label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label>625 </div>626 </div>627 628 </div>629 630 <div id="major-publishing-actions">631 <?php do_action('post_submitbox_start'); ?>632 <div id="delete-action">633 <?php634 if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>635 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo 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;"><?php _e('Delete'); ?></a>636 <?php } ?>637 </div>638 639 <div id="publishing-action">640 <?php if ( !empty($link->link_id) ) { ?>641 <input name="save" type="submit" class="button-primary" id="publish" accesskey="p" value="<?php esc_attr_e('Update Link') ?>" />642 <?php } else { ?>643 <input name="save" type="submit" class="button-primary" id="publish" accesskey="p" value="<?php esc_attr_e('Add Link') ?>" />644 <?php } ?>645 </div>646 <div class="clear"></div>647 </div>648 <?php do_action('submitlink_box'); ?>649 <div class="clear"></div>650 </div>651 <?php652 }653 654 /**655 * Display link categories form fields.656 *657 * @since 2.6.0658 *659 * @param object $link660 */661 function link_categories_meta_box($link) {662 ?>663 <div id="taxonomy-linkcategory" class="categorydiv">664 <ul id="category-tabs" class="category-tabs">665 <li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>666 <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>667 </ul>668 669 <div id="categories-all" class="tabs-panel">670 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">671 <?php672 if ( isset($link->link_id) )673 wp_link_category_checklist($link->link_id);674 else675 wp_link_category_checklist();676 ?>677 </ul>678 </div>679 680 <div id="categories-pop" class="tabs-panel" style="display: none;">681 <ul id="categorychecklist-pop" class="categorychecklist form-no-clear">682 <?php wp_popular_terms_checklist('link_category'); ?>683 </ul>684 </div>685 686 <div id="category-adder" class="wp-hidden-children">687 <h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>688 <p id="link-category-add" class="wp-hidden-child">689 <label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label>690 <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" />691 <input type="button" id="category-add-submit" class="add:categorychecklist:linkcategorydiv button" value="<?php esc_attr_e( 'Add' ); ?>" />692 <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>693 <span id="category-ajax-response"></span>694 </p>695 </div>696 </div>697 <?php698 }699 700 /**701 * Display form fields for changing link target.702 *703 * @since 2.6.0704 *705 * @param object $link706 */707 function link_target_meta_box($link) { ?>708 <fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend>709 <p><label for="link_target_blank" class="selectit">710 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />711 <?php _e('<code>_blank</code> — new window or tab.'); ?></label></p>712 <p><label for="link_target_top" class="selectit">713 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />714 <?php _e('<code>_top</code> — current window or tab, with no frames.'); ?></label></p>715 <p><label for="link_target_none" class="selectit">716 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />717 <?php _e('<code>_none</code> — same window or tab.'); ?></label></p>718 </fieldset>719 <p><?php _e('Choose the target frame for your link.'); ?></p>720 <?php721 }722 723 /**724 * Display checked checkboxes attribute for xfn microformat options.725 *726 * @since 1.0.1727 *728 * @param string $class729 * @param string $value730 * @param mixed $deprecated Never used.731 */732 function xfn_check( $class, $value = '', $deprecated = '' ) {733 global $link;734 735 if ( !empty( $deprecated ) )736 _deprecated_argument( __FUNCTION__, '0.0' ); // Never implemented737 738 $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';739 $rels = preg_split('/\s+/', $link_rel);740 741 if ('' != $value && in_array($value, $rels) ) {742 echo ' checked="checked"';743 }744 745 if ('' == $value) {746 if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"';747 if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"';748 if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"';749 if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';750 }751 }752 753 /**754 * Display xfn form fields.755 *756 * @since 2.6.0757 *758 * @param object $link759 */760 function link_xfn_meta_box($link) {761 ?>762 <table class="links-table" cellspacing="0">763 <tr>764 <th scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th>765 <td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td>766 </tr>767 <tr>768 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></th>769 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></span></legend>770 <label for="me">771 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />772 <?php _e('another web address of mine') ?></label>773 </fieldset></td>774 </tr>775 <tr>776 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></th>777 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></span></legend>778 <label for="contact">779 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('contact') ?>780 </label>781 <label for="acquaintance">782 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('acquaintance') ?>783 </label>784 <label for="friend">785 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friend') ?>786 </label>787 <label for="friendship">788 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?>789 </label>790 </fieldset></td>791 </tr>792 <tr>793 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </th>794 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?></span></legend>795 <label for="met">796 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('met') ?>797 </label>798 </fieldset></td>799 </tr>800 <tr>801 <th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </th>802 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?></span></legend>803 <label for="co-worker">804 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-worker') ?>805 </label>806 <label for="colleague">807 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('colleague') ?>808 </label>809 </fieldset></td>810 </tr>811 <tr>812 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?></th>813 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </span></legend>814 <label for="co-resident">815 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-resident') ?>816 </label>817 <label for="neighbor">818 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('neighbor') ?>819 </label>820 <label for="geographical">821 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?>822 </label>823 </fieldset></td>824 </tr>825 <tr>826 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?></th>827 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </span></legend>828 <label for="child">829 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('child') ?>830 </label>831 <label for="kin">832 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('kin') ?>833 </label>834 <label for="parent">835 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('parent') ?>836 </label>837 <label for="sibling">838 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sibling') ?>839 </label>840 <label for="spouse">841 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('spouse') ?>842 </label>843 <label for="family">844 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?>845 </label>846 </fieldset></td>847 </tr>848 <tr>849 <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?></th>850 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </span></legend>851 <label for="muse">852 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('muse') ?>853 </label>854 <label for="crush">855 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('crush') ?>856 </label>857 <label for="date">858 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('date') ?>859 </label>860 <label for="romantic">861 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sweetheart') ?>862 </label>863 </fieldset></td>864 </tr>865 866 </table>867 <p><?php _e('If the link is to a person, you can specify your relationship with them using the above form. If you would like to learn more about the idea check out <a href="http://gmpg.org/xfn/">XFN</a>.'); ?></p>868 <?php869 }870 871 /**872 * Display advanced link options form fields.873 *874 * @since 2.6.0875 *876 * @param object $link877 */878 function link_advanced_meta_box($link) {879 ?>880 <table class="links-table" cellpadding="0">881 <tr>882 <th scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>883 <td><input type="text" name="link_image" class="code" id="link_image" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" /></td>884 </tr>885 <tr>886 <th scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>887 <td><input name="link_rss" class="code" type="text" id="rss_uri" value="<?php echo ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" /></td>888 </tr>889 <tr>890 <th scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>891 <td><textarea name="link_notes" id="link_notes" rows="10"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : ''); // textarea_escaped ?></textarea></td>892 </tr>893 <tr>894 <th scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>895 <td><select name="link_rating" id="link_rating" size="1">896 <?php897 for ( $r = 0; $r <= 10; $r++ ) {898 echo '<option value="' . $r . '"';899 if ( isset($link->link_rating) && $link->link_rating == $r )900 echo ' selected="selected"';901 echo('>' . $r . '</option>');902 }903 ?></select> <?php _e('(Leave at 0 for no rating.)') ?>904 </td>905 </tr>906 </table>907 <?php908 }909 910 /**911 594 * Display post thumbnail meta box. 912 595 * 913 596 * @since 2.9.0 -
wp-admin/includes/update-core.php
398 398 // 3.5 399 399 'wp-admin/gears-manifest.php', 400 400 'wp-admin/includes/manifest.php', 401 'wp-admin/edit-link-form.php', 402 'wp-admin/includes/class-wp-links-list-table.php', 403 'wp-admin/link-add.php', 404 'wp-admin/link-manager.php', 405 'wp-admin/link-parse-opml.php', 406 'wp-admin/link.php', 407 'wp-includes/bookmark.php', 408 'wp-includes/bookmark-template.php', 409 'wp-admin/includes/bookmark.php', 401 410 ); 402 411 403 412 /** -
wp-admin/includes/template.php
202 202 return $popular_ids; 203 203 } 204 204 205 /**206 * {@internal Missing Short Description}}207 *208 * @since 2.5.1209 *210 * @param unknown_type $link_id211 */212 function wp_link_category_checklist( $link_id = 0 ) {213 $default = 1;214 215 if ( $link_id ) {216 $checked_categories = wp_get_link_cats( $link_id );217 // No selected categories, strange218 if ( ! count( $checked_categories ) )219 $checked_categories[] = $default;220 } else {221 $checked_categories[] = $default;222 }223 224 $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );225 226 if ( empty( $categories ) )227 return;228 229 foreach ( $categories as $category ) {230 $cat_id = $category->term_id;231 $name = esc_html( apply_filters( 'the_category', $category->name ) );232 $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';233 echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>";234 }235 }236 237 205 // adds hidden fields with the data for use in the inline editor for posts and pages 238 206 /** 239 207 * {@internal Missing Short Description}} … … 938 906 $screen = convert_to_screen( $screen ); 939 907 940 908 $page = $screen->id; 941 942 909 $hidden = get_hidden_meta_boxes( $screen ); 943 910 944 911 printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context)); -
wp-admin/includes/user.php
221 221 } 222 222 223 223 /** 224 * Remove user and optionally reassign posts and linksto another user.224 * Remove user and optionally reassign posts to another user. 225 225 * 226 226 * If the $reassign parameter is not assigned to an User ID, then all posts will 227 227 * be deleted of that user. The action 'delete_user' that is passed the User ID … … 231 231 * @since 2.0.0 232 232 * 233 233 * @param int $id User ID. 234 * @param int $reassign Optional. Reassign posts and linksto new User ID.234 * @param int $reassign Optional. Reassign posts to new User ID. 235 235 * @return bool True when finished. 236 236 */ 237 237 function wp_delete_user( $id, $reassign = 'novalue' ) { … … 260 260 foreach ( $post_ids as $post_id ) 261 261 wp_delete_post( $post_id ); 262 262 } 263 264 // Clean links265 $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) );266 267 if ( $link_ids ) {268 foreach ( $link_ids as $link_id )269 wp_delete_link($link_id);270 }271 263 } else { 272 264 $reassign = (int) $reassign; 273 265 $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) ); 274 $wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));266 do_action( 'reassign_user_data', $id, $reassign ); 275 267 } 276 268 277 269 // FINALLY, delete user -
wp-admin/includes/ms.php
148 148 wp_delete_post( $post_id ); 149 149 } 150 150 151 // Clean links152 $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );153 154 if ( $link_ids ) {155 foreach ( $link_ids as $link_id )156 wp_delete_link( $link_id );157 }158 159 151 restore_current_blog(); 160 152 } 161 153 } -
wp-admin/edit-tags.php
185 185 if ( current_user_can($tax->cap->edit_terms) ) 186 186 wp_enqueue_script('inline-edit-tax'); 187 187 188 if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy ) { 188 do_action( 'edit_' . $taxonomy . '_help', $taxonomy ); 189 190 if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) { 189 191 $help =''; 190 192 if ( 'category' == $taxonomy ) 191 193 $help = '<p>' . sprintf(__( 'You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your <a href="%s">writing settings</a>.' ) , 'options-writing.php' ) . '</p>'; 192 elseif ( 'link_category' == $taxonomy )193 $help = '<p>' . __( 'You can create groups of links by using Link Categories. Link Category names must be unique and Link Categories are separate from the categories you use for posts.' ) . '</p>';194 194 else 195 195 $help = '<p>' . __( 'You can assign keywords to your posts using <strong>tags</strong>. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.' ) . '</p>'; 196 196 197 if ( 'link_category' == $taxonomy ) 198 $help .= '<p>' . __( 'You can delete Link Categories in the Bulk Action pull-down, but that action does not delete the links within the category. Instead, it moves them to the default Link Category.' ) . '</p>'; 199 else 200 $help .='<p>' . __( 'What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '</p>'; 201 197 $help .='<p>' . __( 'What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '</p>'; 198 202 199 get_current_screen()->add_help_tab( array( 203 200 'id' => 'overview', 204 201 'title' => __('Overview'), … … 235 232 236 233 if ( 'category' == $taxonomy ) 237 234 $help .= '<p>' . __( '<a href="http://codex.wordpress.org/Posts_Categories_Screen" target="_blank">Documentation on Categories</a>' ) . '</p>'; 238 elseif ( 'link_category' == $taxonomy )239 $help .= '<p>' . __( '<a href="http://codex.wordpress.org/Links_Link_Categories_Screen" target="_blank">Documentation on Link Categories</a>' ) . '</p>';240 235 else 241 236 $help .= '<p>' . __( '<a href="http://codex.wordpress.org/Posts_Tags_Screen" target="_blank">Documentation on Tags</a>' ) . '</p>'; 242 237 … … 339 334 // Back compat hooks. Deprecated in preference to {$taxonomy}_pre_add_form 340 335 if ( 'category' == $taxonomy ) 341 336 do_action('add_category_form_pre', (object)array('parent' => 0) ); 342 elseif ( 'link_category' == $taxonomy )343 do_action('add_link_category_form_pre', (object)array('parent' => 0) );344 337 else 345 338 do_action('add_tag_form_pre', $taxonomy); 346 339 … … 392 385 393 386 // Back compat hooks. Deprecated in preference to {$taxonomy}_add_form 394 387 if ( 'category' == $taxonomy ) 395 do_action('edit_category_form', (object)array('parent' => 0) ); 396 elseif ( 'link_category' == $taxonomy ) 397 do_action('edit_link_category_form', (object)array('parent' => 0) ); 388 do_action('edit_category_form', (object) array( 'parent' => 0 ) ); 398 389 else 399 390 do_action('add_tag_form', $taxonomy); 400 391 -
wp-admin/admin.php
223 223 } elseif ( $pagenow == 'edit-tags.php' ) { 224 224 if ( $taxnow == 'category' ) 225 225 do_action( 'load-categories.php' ); 226 elseif ( $taxnow == 'link_category' )227 do_action( 'load-edit-link-categories.php' );228 226 } 229 227 } 230 228 -
wp-admin/edit-link-form.php
1 <?php2 /**3 * Edit links form for inclusion in administration panels.4 *5 * @package WordPress6 * @subpackage Administration7 */8 9 // don't load directly10 if ( !defined('ABSPATH') )11 die('-1');12 13 if ( ! empty($link_id) ) {14 $heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );15 $submit_text = __('Update Link');16 $form = '<form name="editlink" id="editlink" method="post" action="link.php">';17 $nonce_action = 'update-bookmark_' . $link_id;18 } else {19 $heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' );20 $submit_text = __('Add Link');21 $form = '<form name="addlink" id="addlink" method="post" action="link.php">';22 $nonce_action = 'add-bookmark';23 }24 25 require_once('./includes/meta-boxes.php');26 27 add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', null, 'side', 'core');28 add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', null, 'normal', 'core');29 add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', null, 'normal', 'core');30 add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', null, 'normal', 'core');31 add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', null, 'normal', 'core');32 33 do_action('add_meta_boxes', 'link', $link);34 do_action('add_meta_boxes_link', $link);35 36 do_action('do_meta_boxes', 'link', 'normal', $link);37 do_action('do_meta_boxes', 'link', 'advanced', $link);38 do_action('do_meta_boxes', 'link', 'side', $link);39 40 add_screen_option('layout_columns', array('max' => 2, 'default' => 2) );41 42 get_current_screen()->add_help_tab( array(43 'id' => 'overview',44 'title' => __('Overview'),45 'content' =>46 '<p>' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link’s web address and name (the text you want to display on your site as the link) are required fields.' ) . '</p>' .47 '<p>' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don’t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '</p>' .48 '<p>' . __( 'XFN stands for <a href="http://gmpg.org/xfn/" target="_blank">XHTML Friends Network</a>, which is optional. WordPress allows the generation of XFN attributes to show how you are related to the authors/owners of the site to which you are linking.' ) . '</p>'49 ) );50 51 get_current_screen()->set_help_sidebar(52 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .53 '<p>' . __( '<a href="http://codex.wordpress.org/Links_Add_New_Screen" target="_blank">Documentation on Creating Links</a>' ) . '</p>' .54 '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'55 );56 57 require_once ('admin-header.php');58 ?>59 60 <div class="wrap">61 <?php screen_icon(); ?>62 <h2><?php echo esc_html( $title ); ?> <a href="link-add.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'link'); ?></a></h2>63 64 <?php if ( isset( $_GET['added'] ) ) : ?>65 <div id="message" class="updated"><p><?php _e('Link added.'); ?></p></div>66 <?php endif; ?>67 68 <?php69 if ( !empty($form) )70 echo $form;71 if ( !empty($link_added) )72 echo $link_added;73 74 wp_nonce_field( $nonce_action );75 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );76 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>77 78 <div id="poststuff">79 80 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">81 <div id="post-body-content">82 <div id="namediv" class="stuffbox">83 <h3><label for="link_name"><?php _ex('Name', 'link name') ?></label></h3>84 <div class="inside">85 <input type="text" name="link_name" size="30" value="<?php echo esc_attr($link->link_name); ?>" id="link_name" />86 <p><?php _e('Example: Nifty blogging software'); ?></p>87 </div>88 </div>89 90 <div id="addressdiv" class="stuffbox">91 <h3><label for="link_url"><?php _e('Web Address') ?></label></h3>92 <div class="inside">93 <input type="text" name="link_url" size="30" class="code" value="<?php echo esc_attr($link->link_url); ?>" id="link_url" />94 <p><?php _e('Example: <code>http://wordpress.org/</code> — don’t forget the <code>http://</code>'); ?></p>95 </div>96 </div>97 98 <div id="descriptiondiv" class="stuffbox">99 <h3><label for="link_description"><?php _e('Description') ?></label></h3>100 <div class="inside">101 <input type="text" name="link_description" size="30" value="<?php echo isset($link->link_description) ? esc_attr($link->link_description) : ''; ?>" id="link_description" />102 <p><?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?></p>103 </div>104 </div>105 </div><!-- /post-body-content -->106 107 <div id="postbox-container-1" class="postbox-container">108 <?php109 110 do_action('submitlink_box');111 $side_meta_boxes = do_meta_boxes( 'link', 'side', $link );112 113 ?>114 </div>115 <div id="postbox-container-2" class="postbox-container">116 <?php117 118 do_meta_boxes(null, 'normal', $link);119 120 do_meta_boxes(null, 'advanced', $link);121 122 ?>123 </div>124 <?php125 126 if ( $link_id ) : ?>127 <input type="hidden" name="action" value="save" />128 <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />129 <input type="hidden" name="order_by" value="<?php echo esc_attr($order_by); ?>" />130 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />131 <?php else: ?>132 <input type="hidden" name="action" value="add" />133 <?php endif; ?>134 135 </div>136 </div>137 138 </form>139 </div> -
wp-admin/edit-tag-form.php
19 19 // Back compat hooks 20 20 if ( 'category' == $taxonomy ) 21 21 do_action('edit_category_form_pre', $tag ); 22 elseif ( 'link_category' == $taxonomy )23 do_action('edit_link_category_form_pre', $tag );24 22 else 25 23 do_action('edit_tag_form_pre', $tag); 26 24 … … 68 66 // Back compat hooks 69 67 if ( 'category' == $taxonomy ) 70 68 do_action('edit_category_form_fields', $tag); 71 elseif ( 'link_category' == $taxonomy )72 do_action('edit_link_category_form_fields', $tag);73 69 else 74 70 do_action('edit_tag_form_fields', $tag); 75 71 76 do_action( $taxonomy . '_edit_form_fields', $tag, $taxonomy);72 do_action( $taxonomy . '_edit_form_fields', $tag, $taxonomy ); 77 73 ?> 78 74 </table> 79 75 <?php 80 76 // Back compat hooks 81 77 if ( 'category' == $taxonomy ) 82 78 do_action('edit_category_form', $tag); 83 elseif ( 'link_category' == $taxonomy )84 do_action('edit_link_category_form', $tag);85 79 else 86 80 do_action('edit_tag_form', $tag); 87 81 -
wp-admin/network/users.php
24 24 screen_icon(); 25 25 ?> 26 26 <h2><?php esc_html_e( 'Users' ); ?></h2> 27 <p><?php _e( 'Transfer or delete posts and linksbefore deleting users.' ); ?></p>27 <p><?php _e( 'Transfer or delete posts before deleting users.' ); ?></p> 28 28 <form action="users.php?action=dodelete" method="post"> 29 29 <input type="hidden" name="dodelete" /> 30 30 <?php … … 47 47 48 48 if ( !empty( $blogs ) ) { 49 49 ?> 50 <br /><fieldset><p><legend><?php printf( __( "What should be done with posts and linksowned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>50 <br /><fieldset><p><legend><?php printf( __( "What should be done with posts owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p> 51 51 <?php 52 52 foreach ( (array) $blogs as $key => $details ) { 53 53 $blog_users = get_users( array( 'blog_id' => $details->userblog_id ) ); … … 67 67 <ul style="list-style:none;"> 68 68 <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li> 69 69 <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" /> 70 <?php _e( 'Delete all posts and links.' ); ?></label></li>70 <?php _e( 'Delete all posts.' ); ?></label></li> 71 71 <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" /> 72 <?php echo __( 'Attribute all posts and linksto:' ) . '</label>' . $user_dropdown; ?></li>72 <?php echo __( 'Attribute all posts to:' ) . '</label>' . $user_dropdown; ?></li> 73 73 </ul> 74 74 <?php 75 75 } -
wp-admin/menu.php
65 65 /* translators: add new file */ 66 66 $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php'); 67 67 68 $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'div' );69 $submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );70 /* translators: add new links */71 $submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' );72 $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' );73 74 68 $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'div' ); 75 69 $submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' ); 76 70 /* translators: add new page */ … … 227 221 'edit' => 'posts', 228 222 'post' => 'posts', 229 223 'upload' => 'media', 230 'link-manager' => 'links',231 224 'edit-pages' => 'pages', 232 225 'page' => 'pages', 233 226 'edit-comments' => 'comments', -
wp-admin/link-add.php
1 <?php2 /**3 * Add Link Administration Screen.4 *5 * @package WordPress6 * @subpackage Administration7 */8 9 /** Load WordPress Administration Bootstrap */10 require_once('./admin.php');11 12 if ( ! current_user_can('manage_links') )13 wp_die(__('You do not have sufficient permissions to add links to this site.'));14 15 $title = __('Add New Link');16 $parent_file = 'link-manager.php';17 18 wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',19 'description', 'visible', 'target', 'category', 'link_id',20 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',21 'notes', 'linkcheck[]'));22 23 wp_enqueue_script('link');24 wp_enqueue_script('xfn');25 26 if ( wp_is_mobile() )27 wp_enqueue_script( 'jquery-touch-punch' );28 29 $link = get_default_link_to_edit();30 include('./edit-link-form.php');31 32 require('./admin-footer.php'); -
wp-admin/options.php
64 64 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ), 65 65 'privacy' => array( 'blog_public' ), 66 66 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ), 67 'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_ link_category', 'default_post_format', 'enable_app', 'enable_xmlrpc' ),67 'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_post_format', 'enable_app', 'enable_xmlrpc' ), 68 68 'options' => array( '' ) ); 69 69 70 70 $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass'); -
wp-admin/link.php
1 <?php2 /**3 * Manage link administration actions.4 *5 * This page is accessed by the link management pages and handles the forms and6 * AJAX processes for link actions.7 *8 * @package WordPress9 * @subpackage Administration10 */11 12 /** Load WordPress Administration Bootstrap */13 require_once ('admin.php');14 15 wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));16 17 if ( ! current_user_can('manage_links') )18 wp_die( __('You do not have sufficient permissions to edit the links for this site.') );19 20 if ( !empty($_POST['deletebookmarks']) )21 $action = 'deletebookmarks';22 if ( !empty($_POST['move']) )23 $action = 'move';24 if ( !empty($_POST['linkcheck']) )25 $linkcheck = $_POST['linkcheck'];26 27 $this_file = admin_url('link-manager.php');28 29 switch ($action) {30 case 'deletebookmarks' :31 check_admin_referer('bulk-bookmarks');32 33 //for each link id (in $linkcheck[]) change category to selected value34 if (count($linkcheck) == 0) {35 wp_redirect($this_file);36 exit;37 }38 39 $deleted = 0;40 foreach ($linkcheck as $link_id) {41 $link_id = (int) $link_id;42 43 if ( wp_delete_link($link_id) )44 $deleted++;45 }46 47 wp_redirect("$this_file?deleted=$deleted");48 exit;49 break;50 51 case 'move' :52 check_admin_referer('bulk-bookmarks');53 54 //for each link id (in $linkcheck[]) change category to selected value55 if (count($linkcheck) == 0) {56 wp_redirect($this_file);57 exit;58 }59 $all_links = join(',', $linkcheck);60 // should now have an array of links we can change61 //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");62 63 wp_redirect($this_file);64 exit;65 break;66 67 case 'add' :68 check_admin_referer('add-bookmark');69 70 $redir = wp_get_referer();71 if ( add_link() )72 $redir = add_query_arg( 'added', 'true', $redir );73 74 wp_redirect( $redir );75 exit;76 break;77 78 case 'save' :79 $link_id = (int) $_POST['link_id'];80 check_admin_referer('update-bookmark_' . $link_id);81 82 edit_link($link_id);83 84 wp_redirect($this_file);85 exit;86 break;87 88 case 'delete' :89 $link_id = (int) $_GET['link_id'];90 check_admin_referer('delete-bookmark_' . $link_id);91 92 wp_delete_link($link_id);93 94 wp_redirect($this_file);95 exit;96 break;97 98 case 'edit' :99 wp_enqueue_script('link');100 wp_enqueue_script('xfn');101 102 if ( wp_is_mobile() )103 wp_enqueue_script( 'jquery-touch-punch' );104 105 $parent_file = 'link-manager.php';106 $submenu_file = 'link-manager.php';107 $title = __('Edit Link');108 109 $link_id = (int) $_GET['link_id'];110 111 if (!$link = get_link_to_edit($link_id))112 wp_die(__('Link not found.'));113 114 include ('edit-link-form.php');115 include ('admin-footer.php');116 break;117 118 default :119 break;120 } -
wp-admin/css/colors-fresh.dev.css
1173 1173 .menu-icon-post div.wp-menu-image, 1174 1174 .icon16.icon-media, 1175 1175 .menu-icon-media div.wp-menu-image, 1176 .icon16.icon-links,1177 .menu-icon-links div.wp-menu-image,1178 1176 .icon16.icon-page, 1179 1177 .menu-icon-page div.wp-menu-image, 1180 1178 .icon16.icon-comments, … … 1227 1225 background-position: -119px -1px; 1228 1226 } 1229 1227 1230 .icon16.icon-links,1231 #adminmenu .menu-icon-links div.wp-menu-image {1232 background-position: -89px -33px;1233 }1234 1235 #adminmenu .menu-icon-links:hover div.wp-menu-image,1236 #adminmenu .menu-icon-links.wp-has-current-submenu div.wp-menu-image,1237 #adminmenu .menu-icon-links.current div.wp-menu-image {1238 background-position: -89px -1px;1239 }1240 1241 1228 .icon16.icon-page, 1242 1229 #adminmenu .menu-icon-page div.wp-menu-image { 1243 1230 background-position: -149px -33px; -
wp-admin/link-manager.php
1 <?php2 /**3 * Link Management Administration Screen.4 *5 * @package WordPress6 * @subpackage Administration7 */8 9 /** Load WordPress Administration Bootstrap */10 require_once ('admin.php');11 if ( ! current_user_can( 'manage_links' ) )12 wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) );13 14 $wp_list_table = _get_list_table('WP_Links_List_Table');15 16 // Handle bulk deletes17 $doaction = $wp_list_table->current_action();18 19 if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) {20 check_admin_referer( 'bulk-bookmarks' );21 22 if ( 'delete' == $doaction ) {23 $bulklinks = (array) $_REQUEST['linkcheck'];24 foreach ( $bulklinks as $link_id ) {25 $link_id = (int) $link_id;26 27 wp_delete_link( $link_id );28 }29 30 wp_redirect( add_query_arg('deleted', count( $bulklinks ), admin_url( 'link-manager.php' ) ) );31 exit;32 }33 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {34 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );35 exit;36 }37 38 $wp_list_table->prepare_items();39 40 $title = __('Links');41 $this_file = $parent_file = 'link-manager.php';42 43 get_current_screen()->add_help_tab( array(44 'id' => 'overview',45 'title' => __('Overview'),46 'content' =>47 '<p>' . sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php') . '</p>' .48 '<p>' . __('Links may be separated into Link Categories; these are different than the categories used on your posts.') . '</p>' .49 '<p>' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '</p>'50 ) );51 get_current_screen()->add_help_tab( array(52 'id' => 'deleting-links',53 'title' => __('Deleting Links'),54 'content' =>55 '<p>' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '</p>'56 ) );57 58 get_current_screen()->set_help_sidebar(59 '<p><strong>' . __('For more information:') . '</strong></p>' .60 '<p>' . __('<a href="http://codex.wordpress.org/Links_Screen" target="_blank">Documentation on Managing Links</a>') . '</p>' .61 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'62 );63 64 include_once ('./admin-header.php');65 66 if ( ! current_user_can('manage_links') )67 wp_die(__("You do not have sufficient permissions to edit the links for this site."));68 69 ?>70 71 <div class="wrap nosubsub">72 <?php screen_icon(); ?>73 <h2><?php echo esc_html( $title ); ?> <a href="link-add.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php74 if ( !empty($_REQUEST['s']) )75 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>76 </h2>77 78 <?php79 if ( isset($_REQUEST['deleted']) ) {80 echo '<div id="message" class="updated"><p>';81 $deleted = (int) $_REQUEST['deleted'];82 printf(_n('%s link deleted.', '%s links deleted', $deleted), $deleted);83 echo '</p></div>';84 $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);85 }86 ?>87 88 <form id="posts-filter" action="" method="get">89 90 <?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?>91 92 <?php $wp_list_table->display(); ?>93 94 <div id="ajax-response"></div>95 </form>96 97 </div>98 99 <?php100 include('./admin-footer.php'); -
wp-admin/link-parse-opml.php
1 <?php2 /**3 * Parse OPML XML files and store in globals.4 *5 * @package WordPress6 * @subpackage Administration7 */8 9 if ( ! defined('ABSPATH') )10 die();11 12 global $opml, $map;13 14 // columns we wish to find are: link_url, link_name, link_target, link_description15 // we need to map XML attribute names to our columns16 $opml_map = array('URL' => 'link_url',17 'HTMLURL' => 'link_url',18 'TEXT' => 'link_name',19 'TITLE' => 'link_name',20 'TARGET' => 'link_target',21 'DESCRIPTION' => 'link_description',22 'XMLURL' => 'link_rss'23 );24 25 $map = $opml_map;26 27 /**28 * XML callback function for the start of a new XML tag.29 *30 * @since 0.7131 * @access private32 *33 * @uses $updated_timestamp Not used inside function.34 * @uses $all_links Not used inside function.35 * @uses $map Stores names of attributes to use.36 * @global array $names37 * @global array $urls38 * @global array $targets39 * @global array $descriptions40 * @global array $feeds41 *42 * @param mixed $parser XML Parser resource.43 * @param string $tagName XML element name.44 * @param array $attrs XML element attributes.45 */46 function startElement($parser, $tagName, $attrs) {47 global $updated_timestamp, $all_links, $map;48 global $names, $urls, $targets, $descriptions, $feeds;49 50 if ($tagName == 'OUTLINE') {51 foreach (array_keys($map) as $key) {52 if (isset($attrs[$key])) {53 $$map[$key] = $attrs[$key];54 }55 }56 57 //echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");58 59 // save the data away.60 $names[] = $link_name;61 $urls[] = $link_url;62 $targets[] = $link_target;63 $feeds[] = $link_rss;64 $descriptions[] = $link_description;65 } // end if outline66 }67 68 /**69 * XML callback function that is called at the end of a XML tag.70 *71 * @since 0.7172 * @access private73 * @package WordPress74 * @subpackage Dummy75 *76 * @param mixed $parser XML Parser resource.77 * @param string $tagName XML tag name.78 */79 function endElement($parser, $tagName) {80 // nothing to do.81 }82 83 // Create an XML parser84 $xml_parser = xml_parser_create();85 86 // Set the functions to handle opening and closing tags87 xml_set_element_handler($xml_parser, "startElement", "endElement");88 89 if (!xml_parse($xml_parser, $opml, true)) {90 echo(sprintf(__('XML error: %1$s at line %2$s'),91 xml_error_string(xml_get_error_code($xml_parser)),92 xml_get_current_line_number($xml_parser)));93 }94 95 // Free up memory used by the XML parser96 xml_parser_free($xml_parser); -
wp-admin/options-writing.php
107 107 </select> 108 108 </td> 109 109 </tr> 110 <?php endif; endif; ?> 111 <tr valign="top"> 112 <th scope="row"><label for="default_link_category"><?php _e('Default Link Category') ?></label></th> 113 <td> 114 <?php 115 wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_link_category', 'orderby' => 'name', 'selected' => get_option('default_link_category'), 'hierarchical' => true, 'taxonomy' => 'link_category')); 116 ?> 117 </td> 118 </tr> 119 <?php do_settings_fields('writing', 'default'); ?> 110 <?php endif; endif; 111 112 do_settings_fields('writing', 'default'); ?> 120 113 </table> 121 114 122 115 <h3 class="title"><?php _e('Press This') ?></h3>