Bookmark/link rework. #2499
git-svn-id: http://svn.automattic.com/wordpress/trunk@3570 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0bc5aae7ef
commit
e9c75f4bd2
|
@ -105,11 +105,21 @@ function wp_insert_category($catarr) {
|
|||
if (empty ($category_parent))
|
||||
$category_parent = 0;
|
||||
|
||||
if ( isset($posts_private) )
|
||||
$posts_private = (int) $posts_private;
|
||||
else
|
||||
$posts_private = 0;
|
||||
|
||||
if ( isset($links_private) )
|
||||
$links_private = (int) $links_private;
|
||||
else
|
||||
$links_private = 0;
|
||||
|
||||
if (!$update) {
|
||||
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
|
||||
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
|
||||
$cat_ID = $wpdb->insert_id;
|
||||
} else {
|
||||
$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");
|
||||
$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
|
||||
}
|
||||
|
||||
if ( $category_nicename == '' ) {
|
||||
|
@ -153,7 +163,10 @@ function wp_delete_category($cat_ID) {
|
|||
$cat_ID = (int) $cat_ID;
|
||||
|
||||
// Don't delete the default cat.
|
||||
if (1 == $cat_ID)
|
||||
if ( $cat_ID == get_option('default_category') )
|
||||
return 0;
|
||||
|
||||
if ( $cat_ID == get_option('default_link_category') )
|
||||
return 0;
|
||||
|
||||
$category = get_category($cat_ID);
|
||||
|
@ -166,8 +179,28 @@ function wp_delete_category($cat_ID) {
|
|||
// Update children to point to new parent.
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
|
||||
|
||||
// TODO: Only set categories to general if they're not in another category already
|
||||
$wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'");
|
||||
// Only set posts and links to the default category if they're not in another category already.
|
||||
$default_cat = get_option('default_category');
|
||||
$posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
|
||||
if ( is_array($posts) ) foreach ($posts as $post_id) {
|
||||
$cats = wp_get_post_cats('', $post_id);
|
||||
if ( 1 == count($cats) )
|
||||
$cats = array($default_cat);
|
||||
else
|
||||
$cats = array_diff($cats, array($cat_ID));
|
||||
wp_set_post_cats('', $post_id, $cats);
|
||||
}
|
||||
|
||||
$default_link_cat = get_option('default_link_category');
|
||||
$links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
|
||||
if ( is_array($links) ) foreach ($links as $link_id) {
|
||||
$cats = wp_get_link_cats($link_id);
|
||||
if ( 1 == count($cats) )
|
||||
$cats = array($default_link_cat);
|
||||
else
|
||||
$cats = array_diff($cats, array($cat_ID));
|
||||
wp_set_link_cats($link_id, $cats);
|
||||
}
|
||||
|
||||
wp_cache_delete($cat_ID, 'category');
|
||||
wp_cache_delete('all_category_ids', 'category');
|
||||
|
@ -244,6 +277,7 @@ function get_link($link_id, $output = OBJECT) {
|
|||
global $wpdb;
|
||||
|
||||
$link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'");
|
||||
$link->link_category = wp_get_link_cats($link_id);
|
||||
|
||||
if ( $output == OBJECT ) {
|
||||
return $link;
|
||||
|
@ -280,19 +314,26 @@ function wp_insert_link($linkdata) {
|
|||
if ( empty($link_notes) )
|
||||
$link_notes = '';
|
||||
|
||||
// Make sure we set a valid category
|
||||
if (0 == count($link_category) || !is_array($link_category)) {
|
||||
$link_category = array(get_option('default_category'));
|
||||
}
|
||||
|
||||
if ( $update ) {
|
||||
$wpdb->query("UPDATE $wpdb->links SET link_url='$link_url',
|
||||
link_name='$link_name', link_image='$link_image',
|
||||
link_target='$link_target', link_category='$link_category',
|
||||
link_target='$link_target',
|
||||
link_visible='$link_visible', link_description='$link_description',
|
||||
link_rating='$link_rating', link_rel='$link_rel',
|
||||
link_notes='$link_notes', link_rss = '$link_rss'
|
||||
WHERE link_id='$link_id'");
|
||||
} else {
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
|
||||
$link_id = $wpdb->insert_id;
|
||||
}
|
||||
|
||||
wp_set_link_cats($link_id, $link_category);
|
||||
|
||||
if ( $update )
|
||||
do_action('edit_link', $link_id);
|
||||
else
|
||||
|
@ -311,8 +352,16 @@ function wp_update_link($linkdata) {
|
|||
// Escape data pulled from DB.
|
||||
$link = add_magic_quotes($link);
|
||||
|
||||
// Passed link category list overwrites existing category list if not empty.
|
||||
if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
|
||||
&& 0 != count($linkdata['link_category']) )
|
||||
$link_cats = $linkdata['link_category'];
|
||||
else
|
||||
$link_cats = $link['link_category'];
|
||||
|
||||
// Merge old and new fields with new fields overwriting old ones.
|
||||
$linkdata = array_merge($link, $linkdata);
|
||||
$linkdata['link_category'] = $link_cats;
|
||||
|
||||
return wp_insert_link($linkdata);
|
||||
}
|
||||
|
@ -321,9 +370,88 @@ function wp_delete_link($link_id) {
|
|||
global $wpdb;
|
||||
|
||||
do_action('delete_link', $link_id);
|
||||
|
||||
$categories = wp_get_link_cats($link_id);
|
||||
if( is_array( $categories ) ) {
|
||||
foreach ( $categories as $category ) {
|
||||
$wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
|
||||
wp_cache_delete($category, 'category');
|
||||
}
|
||||
}
|
||||
|
||||
$wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'");
|
||||
return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
|
||||
}
|
||||
|
||||
function wp_get_link_cats($link_ID = 0) {
|
||||
global $wpdb;
|
||||
|
||||
$sql = "SELECT category_id
|
||||
FROM $wpdb->link2cat
|
||||
WHERE link_id = $link_ID
|
||||
ORDER BY category_id";
|
||||
|
||||
$result = $wpdb->get_col($sql);
|
||||
|
||||
if ( !$result )
|
||||
$result = array();
|
||||
|
||||
return array_unique($result);
|
||||
}
|
||||
|
||||
function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
|
||||
global $wpdb;
|
||||
// If $link_categories isn't already an array, make it one:
|
||||
if (!is_array($link_categories) || 0 == count($link_categories))
|
||||
$link_categories = array(get_option('default_category'));
|
||||
|
||||
$link_categories = array_unique($link_categories);
|
||||
|
||||
// First the old categories
|
||||
$old_categories = $wpdb->get_col("
|
||||
SELECT category_id
|
||||
FROM $wpdb->link2cat
|
||||
WHERE link_id = $link_ID");
|
||||
|
||||
if (!$old_categories) {
|
||||
$old_categories = array();
|
||||
} else {
|
||||
$old_categories = array_unique($old_categories);
|
||||
}
|
||||
|
||||
// Delete any?
|
||||
$delete_cats = array_diff($old_categories,$link_categories);
|
||||
|
||||
if ($delete_cats) {
|
||||
foreach ($delete_cats as $del) {
|
||||
$wpdb->query("
|
||||
DELETE FROM $wpdb->link2cat
|
||||
WHERE category_id = $del
|
||||
AND link_id = $link_ID
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
// Add any?
|
||||
$add_cats = array_diff($link_categories, $old_categories);
|
||||
|
||||
if ($add_cats) {
|
||||
foreach ($add_cats as $new_cat) {
|
||||
$wpdb->query("
|
||||
INSERT INTO $wpdb->link2cat (link_id, category_id)
|
||||
VALUES ($link_ID, $new_cat)");
|
||||
}
|
||||
}
|
||||
|
||||
// Update category counts.
|
||||
$all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
|
||||
foreach ( $all_affected_cats as $cat_id ) {
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
|
||||
$wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
|
||||
wp_cache_delete($cat_id, 'category');
|
||||
}
|
||||
} // wp_set_link_cats()
|
||||
|
||||
function post_exists($title, $content = '', $post_date = '') {
|
||||
global $wpdb;
|
||||
|
||||
|
|
|
@ -476,6 +476,7 @@ function get_link_to_edit($link_id) {
|
|||
$link->link_description = wp_specialchars($link->link_description);
|
||||
$link->link_notes = wp_specialchars($link->link_notes);
|
||||
$link->link_rss = wp_specialchars($link->link_rss);
|
||||
$link->post_category = $link->link_category;
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
@ -491,6 +492,8 @@ function get_default_link_to_edit() {
|
|||
else
|
||||
$link->link_name = '';
|
||||
|
||||
$link->link_visible = 'Y';
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
|
@ -507,14 +510,7 @@ function edit_link($link_id = '') {
|
|||
$_POST['link_name'] = wp_specialchars($_POST['link_name']);
|
||||
$_POST['link_image'] = wp_specialchars($_POST['link_image']);
|
||||
$_POST['link_rss'] = wp_specialchars($_POST['link_rss']);
|
||||
$auto_toggle = get_autotoggle($_POST['link_category']);
|
||||
|
||||
// if we are in an auto toggle category and this one is visible then we
|
||||
// need to make the others invisible before we add this new one.
|
||||
// FIXME Add category toggle func.
|
||||
//if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
|
||||
// $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");
|
||||
//}
|
||||
$_POST['link_category'] = $_POST['post_category'];
|
||||
|
||||
if ( !empty($link_id) ) {
|
||||
$_POST['link_id'] = $link_id;
|
||||
|
@ -554,7 +550,7 @@ function sort_cats($cat1, $cat2) {
|
|||
}
|
||||
|
||||
function get_nested_categories($default = 0, $parent = 0) {
|
||||
global $post_ID, $mode, $wpdb;
|
||||
global $post_ID, $link_id, $mode, $wpdb;
|
||||
|
||||
if ($post_ID) {
|
||||
$checked_categories = $wpdb->get_col("
|
||||
|
@ -567,7 +563,17 @@ function get_nested_categories($default = 0, $parent = 0) {
|
|||
// No selected categories, strange
|
||||
$checked_categories[] = $default;
|
||||
}
|
||||
} else if ($link_id) {
|
||||
$checked_categories = $wpdb->get_col("
|
||||
SELECT category_id
|
||||
FROM $wpdb->categories, $wpdb->link2cat
|
||||
WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
|
||||
");
|
||||
|
||||
if (count($checked_categories) == 0) {
|
||||
// No selected categories, strange
|
||||
$checked_categories[] = $default;
|
||||
}
|
||||
} else {
|
||||
$checked_categories[] = $default;
|
||||
}
|
||||
|
@ -620,9 +626,10 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
|
|||
if ( current_user_can('manage_categories') ) {
|
||||
$edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
|
||||
$default_cat_id = get_option('default_category');
|
||||
$default_link_cat_id = get_option('default_link_category');
|
||||
|
||||
if ($category->cat_ID != $default_cat_id)
|
||||
$edit .= "<td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>";
|
||||
if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
|
||||
$edit .= "<td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts and bookmarks will go to the default categories.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>";
|
||||
else
|
||||
$edit .= "<td style='text-align:center'>".__("Default");
|
||||
}
|
||||
|
@ -633,6 +640,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
|
|||
echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
|
||||
<td>$category->category_description</td>
|
||||
<td>$category->category_count</td>
|
||||
<td>$category->link_count</td>
|
||||
<td>$edit</td>
|
||||
</tr>";
|
||||
cat_rows($category->cat_ID, $level +1, $categories);
|
||||
|
@ -687,7 +695,6 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev
|
|||
if ($categories) {
|
||||
foreach ($categories as $category) {
|
||||
if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
|
||||
$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
|
||||
$pad = str_repeat('– ', $level);
|
||||
$category->cat_name = wp_specialchars($category->cat_name);
|
||||
echo "\n\t<option value='$category->cat_ID'";
|
||||
|
@ -702,21 +709,9 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev
|
|||
}
|
||||
}
|
||||
|
||||
function link_category_dropdown($fieldname, $selected = 0) {
|
||||
function return_link_categories_list($parent = 0) {
|
||||
global $wpdb;
|
||||
|
||||
$results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
|
||||
echo "\n<select name='$fieldname' size='1'>\n";
|
||||
foreach ($results as $row) {
|
||||
echo "\n\t<option value='$row->cat_id'";
|
||||
if ($row->cat_id == $selected)
|
||||
echo " selected='selected'";
|
||||
echo ">$row->cat_id : " . wp_specialchars($row->cat_name);
|
||||
if ($row->auto_toggle == 'Y')
|
||||
echo ' (auto toggle)';
|
||||
echo "</option>";
|
||||
}
|
||||
echo "\n</select>\n";
|
||||
return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC LIMIT 100");
|
||||
}
|
||||
|
||||
function wp_create_thumbnail($file, $max_side, $effect = '') {
|
||||
|
|
|
@ -40,6 +40,8 @@ addLoadEvent( function() {
|
|||
var manager = new dbxManager('postmeta');
|
||||
<?php break; case 'page.php' : case 'page-new.php' : ?>
|
||||
var manager = new dbxManager('pagemeta');
|
||||
<?php break; case 'link.php' : case 'link-add.php' : ?>
|
||||
var manager = new dbxManager('linkmeta');
|
||||
<?php break; endswitch; ?>
|
||||
});
|
||||
//]]>
|
||||
|
|
|
@ -127,6 +127,7 @@ $messages[3] = __('Category updated.');
|
|||
<th scope="col"><?php _e('Name') ?></th>
|
||||
<th scope="col"><?php _e('Description') ?></th>
|
||||
<th scope="col"><?php _e('# Posts') ?></th>
|
||||
<th scope="col"><?php _e('# Links') ?></th>
|
||||
<th colspan="2"><?php _e('Action') ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
|
@ -140,7 +141,7 @@ cat_rows();
|
|||
|
||||
<?php if ( current_user_can('manage_categories') ) : ?>
|
||||
<div class="wrap">
|
||||
<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete posts from that category, it will just set them back to the default category <strong>%s</strong>.'), get_catname(get_option('default_category'))) ?></p>
|
||||
<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and bookmarks in that category. Instead, posts in the deleted category are set to the category <strong>%s</strong> and bookmarks are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
|
||||
</div>
|
||||
|
||||
<div class="wrap">
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
<?php
|
||||
if ( ! empty($link_id) ) {
|
||||
$editing = true;
|
||||
$heading = __('Edit a link:');
|
||||
$heading = __('Edit Bookmark');
|
||||
$submit_text = __('Save Changes »');
|
||||
$form = '<form action="" method="post" name="editlink" id="editlink">';
|
||||
$form = '<form name="editlink" id="editlink" method="post" action="link.php">';
|
||||
} else {
|
||||
$editing = false;
|
||||
$heading = __('<strong>Add</strong> a link:');
|
||||
$submit_text = __('Add Link »');
|
||||
$form = '<form name="addlink" method="post" action="link-manager.php">';
|
||||
$heading = __('Create Bookmark');
|
||||
$submit_text = __('Add Bookmark »');
|
||||
$form = '<form name="addlink" id="addlink" method="post" action="link.php">';
|
||||
}
|
||||
|
||||
function xfn_check($class, $value = '', $type = 'check') {
|
||||
|
@ -28,39 +26,78 @@ function xfn_check($class, $value = '', $type = 'check') {
|
|||
if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<?php echo $form ?>
|
||||
<h2><?php echo $heading ?></h2>
|
||||
<fieldset class="options">
|
||||
<legend><?php _e('Basics') ?></legend>
|
||||
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
||||
<tr>
|
||||
<th width="33%" scope="row"><?php _e('URI:') ?></th>
|
||||
<td width="67%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%;" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Link Name:') ?></th>
|
||||
<td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Short description:') ?></th>
|
||||
<td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Category:') ?></th>
|
||||
<td><?php link_category_dropdown('link_category', $link->link_category); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><?php echo $heading ?></h2>
|
||||
<?php echo $form ?>
|
||||
|
||||
<div id="poststuff">
|
||||
<div id="moremeta">
|
||||
<div id="grabit" class="dbx-group">
|
||||
|
||||
<fieldset id="categorydiv" class="dbx-box">
|
||||
<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
|
||||
<div class="dbx-content">
|
||||
<p id="jaxcat"></p>
|
||||
<div id="categorychecklist"><?php dropdown_categories(get_settings('default_link_category')); ?></div></div>
|
||||
</fieldset>
|
||||
<p class="submit">
|
||||
<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
|
||||
</p>
|
||||
<fieldset class="options">
|
||||
<legend><?php _e('Link Relationship (XFN)') ?></legend>
|
||||
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
||||
|
||||
<fieldset class="dbx-box">
|
||||
<h3 class="dbx-handle"><?php _e('Target') ?></h3>
|
||||
<div class="dbx-content">
|
||||
<label for="link_target_blank" class="selectit">
|
||||
<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
|
||||
<code>_blank</code></label>
|
||||
<label for="link_target_top" class="selectit">
|
||||
<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
|
||||
<code>_top</code></label>
|
||||
<label for="link_target_none" class="selectit">
|
||||
<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
|
||||
<?php _e('none') ?></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="dbx-box">
|
||||
<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
|
||||
<div class="dbx-content">
|
||||
<label for="link_visible_yes" class="selectit">
|
||||
<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
|
||||
<?php _e('Yes') ?></label>
|
||||
<label for="link_visible_no" class="selectit">
|
||||
<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
|
||||
<?php _e('No') ?></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<fieldset id="uridiv">
|
||||
<legend><?php _e('URI:') ?></legend>
|
||||
<div><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%" /></div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="namediv">
|
||||
<legend><?php _e('Name:') ?></legend>
|
||||
<div><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="descdiv">
|
||||
<legend><?php _e('Description:') ?></legend>
|
||||
<div><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></div>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
|
||||
</p>
|
||||
|
||||
<div id="advancedstuff" class="dbx-group" >
|
||||
|
||||
<fieldset id="xfn" class="dbx-box">
|
||||
<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
|
||||
<div class="dbx-content">
|
||||
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
||||
<tr>
|
||||
<th width="33%" scope="row"><?php _e('rel:') ?></th>
|
||||
<td width="67%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
|
||||
|
@ -167,18 +204,18 @@ function xfn_check($class, $value = '', $type = 'check') {
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</fieldset>
|
||||
<p class="submit">
|
||||
<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
|
||||
</p>
|
||||
<fieldset class="options">
|
||||
<legend><?php _e('Advanced') ?></legend>
|
||||
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
||||
|
||||
<fieldset id="advanced" class="dbx-box">
|
||||
<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
|
||||
<div class="dbx-content">
|
||||
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
||||
<tr>
|
||||
<th width="33%" scope="row"><?php _e('Image URI:') ?></th>
|
||||
<td width="67%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('RSS URI:') ?> </th>
|
||||
<td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
|
||||
</tr>
|
||||
|
@ -189,48 +226,28 @@ function xfn_check($class, $value = '', $type = 'check') {
|
|||
<tr>
|
||||
<th scope="row"><?php _e('Rating:') ?></th>
|
||||
<td><select name="link_rating" size="1">
|
||||
<?php
|
||||
<?php
|
||||
for ($r = 0; $r < 10; $r++) {
|
||||
echo(' <option value="'.$r.'" ');
|
||||
if ($link->link_rating == $r)
|
||||
echo 'selected="selected"';
|
||||
echo('>'.$r.'</option>');
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php _e('(Leave at 0 for no rating.)') ?> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Target') ?></th>
|
||||
<td><label>
|
||||
<input type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
|
||||
<code>_blank</code></label><br />
|
||||
<label>
|
||||
<input type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
|
||||
<code>_top</code></label><br />
|
||||
<label>
|
||||
<input type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
|
||||
<?php _e('none') ?></label><br />
|
||||
<?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Visible:') ?></th>
|
||||
<td><label>
|
||||
<input type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
|
||||
<?php _e('Yes') ?></label><br /><label>
|
||||
<input type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
|
||||
<?php _e('No') ?></label></td>
|
||||
?></select> <?php _e('(Leave at 0 for no rating.)') ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
|
||||
<?php if ( $editing ) : ?>
|
||||
<input type="hidden" name="action" value="editlink" />
|
||||
<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
|
||||
<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
|
||||
<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
|
||||
</div>
|
||||
|
||||
<?php if ( $link_id ) : ?>
|
||||
<input type="hidden" name="action" value="save" />
|
||||
<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
|
||||
<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
|
||||
<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
|
||||
<?php else: ?>
|
||||
<input type="hidden" name="action" value="Add" />
|
||||
<input type="hidden" name="action" value="add" />
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
|
@ -120,7 +120,7 @@ if (0 < $numcats) $numcats = number_format($numcats);
|
|||
<ul>
|
||||
<li><a href="post-new.php"><?php _e('Write a post'); ?></a></li>
|
||||
<li><a href="profile.php"><?php _e('Update your profile or change your password'); ?></a></li>
|
||||
<li><a href="link-add.php"><?php _e('Add a link to your blogroll'); ?></a></li>
|
||||
<li><a href="link-add.php"><?php _e('Add a bookmark to your blogroll'); ?></a></li>
|
||||
<li><a href="themes.php"><?php _e('Change your site’s look or theme'); ?></a></li>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -154,19 +154,34 @@ update_option('blog_public', $public);
|
|||
if ( ! $public )
|
||||
update_option('default_pingback_flag', 0);
|
||||
|
||||
// Now drop in some default links
|
||||
$wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".$wpdb->escape(__('Blogroll'))."')");
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/', '');");
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/', '');");
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/', '');");
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/', '');");
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/', '');");
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php', '');");
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/', '');");
|
||||
|
||||
// Default category
|
||||
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
|
||||
|
||||
// Default link category
|
||||
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, link_count, category_description) VALUES ('0', '".$wpdb->escape(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', '7', '')");
|
||||
|
||||
// Now drop in some default links
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 0, 'http://blogs.linux.ie/xeer/feed/', '');");
|
||||
$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (1, 2)" );
|
||||
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 0, 'http://zengun.org/weblog/feed/', '');");
|
||||
$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (2, 2)" );
|
||||
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 0, 'http://boren.nu/feed/', '');");
|
||||
$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (3, 2)" );
|
||||
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 0, 'http://xml.photomatt.net/feed/', '');");
|
||||
$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (4, 2)" );
|
||||
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 0, 'http://zed1.com/journalized/feed/', '');");
|
||||
$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (5, 2)" );
|
||||
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 0, 'http://www.alexking.org/blog/wp-rss2.php', '');");
|
||||
$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (6, 2)" );
|
||||
|
||||
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 0, 'http://dougal.gunters.org/feed/', '');");
|
||||
$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (7, 2)" );
|
||||
|
||||
// First post
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$now_gmt = gmdate('Y-m-d H:i:s');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
require_once('admin.php');
|
||||
|
||||
$title = __('Add Link');
|
||||
$title = __('Add Bookmark');
|
||||
$this_file = 'link-manager.php';
|
||||
$parent_file = 'link-manager.php';
|
||||
|
||||
|
@ -26,11 +26,12 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
|||
}
|
||||
|
||||
$xfn_js = true;
|
||||
$editing = true;
|
||||
require('admin-header.php');
|
||||
?>
|
||||
|
||||
<?php if ($_GET['added']) : ?>
|
||||
<div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
|
||||
<div id="message" class="updated fade"><p><?php _e('Bookmark added.'); ?></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
|
@ -39,7 +40,7 @@ require('admin-header.php');
|
|||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<?php printf(__('<p>You can drag <a href="%s" title="Link add bookmarklet">Link This</a> to your toolbar and when you click it a window will pop up that will allow you to add whatever site you’re on to your links! Right now this only works on Mozilla or Netscape, but we’re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&linkurl='+escape(location.href)+'&name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?>
|
||||
<?php printf(__('<p>You can drag <a href="%s" title="Bookmark add bookmarklet">Link This</a> to your toolbar and when you click it a window will pop up that will allow you to add whatever site you’re on to your bookmarks! Right now this only works on Mozilla or Netscape, but we’re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&linkurl='+escape(location.href)+'&name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
|
|
@ -1,455 +0,0 @@
|
|||
<?php
|
||||
// Links
|
||||
// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
|
||||
require_once('admin.php');
|
||||
$title = __('Link Categories');
|
||||
$this_file='link-categories.php';
|
||||
$parent_file = 'link-manager.php';
|
||||
$list_js = true;
|
||||
|
||||
$wpvarstoreset = array('action', 'cat', 'auto_toggle');
|
||||
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
||||
$wpvar = $wpvarstoreset[$i];
|
||||
if (!isset($$wpvar)) {
|
||||
if (empty($_POST["$wpvar"])) {
|
||||
if (empty($_GET["$wpvar"])) {
|
||||
$$wpvar = '';
|
||||
} else {
|
||||
$$wpvar = $_GET["$wpvar"];
|
||||
}
|
||||
} else {
|
||||
$$wpvar = $_POST["$wpvar"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'addcat':
|
||||
{
|
||||
if ( !current_user_can('manage_links') )
|
||||
die (__("Cheatin' uh ?"));
|
||||
|
||||
$cat_name = wp_specialchars($_POST['cat_name']);
|
||||
$auto_toggle = $_POST['auto_toggle'];
|
||||
if ($auto_toggle != 'Y') {
|
||||
$auto_toggle = 'N';
|
||||
}
|
||||
|
||||
$show_images = $_POST['show_images'];
|
||||
if ($show_images != 'Y') {
|
||||
$show_images = 'N';
|
||||
}
|
||||
|
||||
$show_description = $_POST['show_description'];
|
||||
if ($show_description != 'Y') {
|
||||
$show_description = 'N';
|
||||
}
|
||||
|
||||
$show_rating = $_POST['show_rating'];
|
||||
if ($show_rating != 'Y') {
|
||||
$show_rating = 'N';
|
||||
}
|
||||
|
||||
$show_updated = $_POST['show_updated'];
|
||||
if ($show_updated != 'Y') {
|
||||
$show_updated = 'N';
|
||||
}
|
||||
|
||||
$sort_order = $_POST['sort_order'];
|
||||
|
||||
$sort_desc = $_POST['sort_desc'];
|
||||
if ($sort_desc != 'Y') {
|
||||
$sort_desc = 'N';
|
||||
}
|
||||
$text_before_link = $_POST['text_before_link'];
|
||||
$text_after_link = $_POST['text_after_link'];
|
||||
$text_after_all = $_POST['text_after_all'];
|
||||
|
||||
$list_limit = $_POST['list_limit'];
|
||||
if ($list_limit == '')
|
||||
$list_limit = -1;
|
||||
|
||||
$wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name, auto_toggle, show_images, show_description, \n" .
|
||||
" show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, text_after_all, list_limit) \n" .
|
||||
" VALUES ('0', '$cat_name', '$auto_toggle', '$show_images', '$show_description', \n" .
|
||||
" '$show_rating', '$show_updated', '$sort_order', '$sort_desc', '$text_before_link', '$text_after_link', \n" .
|
||||
" '$text_after_all', $list_limit)");
|
||||
|
||||
header('Location: link-categories.php');
|
||||
break;
|
||||
} // end addcat
|
||||
case 'Delete':
|
||||
{
|
||||
$cat_id = (int) $_GET['cat_id'];
|
||||
$cat_name=get_linkcatname($cat_id);
|
||||
|
||||
if ($cat_id=="1")
|
||||
die(sprintf(__("Can't delete the <strong>%s</strong> link category: this is the default one"), $cat_name));
|
||||
|
||||
if ( !current_user_can('manage_links') )
|
||||
die (__("Cheatin' uh ?"));
|
||||
|
||||
$wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$cat_id'");
|
||||
$wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$cat_id'");
|
||||
|
||||
header('Location: link-categories.php');
|
||||
break;
|
||||
} // end delete
|
||||
case 'Edit':
|
||||
{
|
||||
include_once ('admin-header.php');
|
||||
$cat_id = (int) $_GET['cat_id'];
|
||||
$row = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
|
||||
. " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
|
||||
. " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$cat_id");
|
||||
if ($row) {
|
||||
if ($row->list_limit == -1) {
|
||||
$row->list_limit = '';
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php printf(__('Edit “%s” Category'), wp_specialchars($row->cat_name)); ?></h2>
|
||||
|
||||
<form name="editcat" method="post">
|
||||
<input type="hidden" name="action" value="editedcat" />
|
||||
<input type="hidden" name="cat_id" value="<?php echo $row->cat_id ?>" />
|
||||
<fieldset class="options">
|
||||
<legend><?php _e('Category Options') ?></legend>
|
||||
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
||||
<tr>
|
||||
<th width="33%" scope="row"><?php _e('Name:') ?></th>
|
||||
<td width="67%"><input name="cat_name" type="text" value="<?php echo wp_specialchars($row->cat_name)?>" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Show:') ?></th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="show_images" value="Y" <?php checked('Y', $row->show_images); ?> />
|
||||
<?php _e('Image') ?></label> <br />
|
||||
<label>
|
||||
<input type="checkbox" name="show_description" value="Y" <?php checked('Y', $row->show_description); ?> />
|
||||
<?php _e('Description') ?></label>
|
||||
<?php _e('(shown in <code>title</code> regardless)') ?><br />
|
||||
<label>
|
||||
<input type="checkbox" name="show_rating" value="Y" <?php checked('Y', $row->show_rating); ?> />
|
||||
<?php _e('Rating') ?></label> <br />
|
||||
<label>
|
||||
<input type="checkbox" name="show_updated" value="Y" <?php checked('Y', $row->show_updated); ?> />
|
||||
<?php _e('Updated') ?></label>
|
||||
<?php _e('(shown in <code>title</code> regardless)') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Sort order:') ?></th>
|
||||
<td>
|
||||
<select name="sort_order" size="1">
|
||||
<option value="name" <?php echo ($row->sort_order == 'name') ? 'selected="selected"' : ''?>><?php _e('Name') ?></option>
|
||||
<option value="id" <?php echo ($row->sort_order == 'id') ? 'selected' : ''?>><?php _e('Id') ?></option>
|
||||
<option value="url" <?php echo ($row->sort_order == 'url') ? 'selected' : ''?>><?php _e('URL') ?></option>
|
||||
<option value="rating" <?php echo ($row->sort_order == 'rating') ? 'selected' : ''?>><?php _e('Rating') ?></option>
|
||||
<option value="updated" <?php echo ($row->sort_order == 'updated') ? 'selected' : ''?>><?php _e('Updated') ?></option>
|
||||
<option value="rand" <?php echo ($row->sort_order == 'rand') ? 'selected' : ''?>><?php _e('Random') ?></option>
|
||||
<option value="length" <?php echo ($row->sort_order == 'length') ? 'selected' : ''?>><?php _e('Name Length') ?></option>
|
||||
</select>
|
||||
<label>
|
||||
<input type="checkbox" name="sort_desc" value="Y" <?php checked('Y', $row->sort_desc); ?> />
|
||||
<?php _e('Descending') ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Limit:') ?></th>
|
||||
<td>
|
||||
<input type="text" name="list_limit" size="5" value="<?php echo $row->list_limit ?>" />
|
||||
<?php _e('(Leave empty for no limit to number of links shown)') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Toggle:') ?></th>
|
||||
<td><label>
|
||||
<input type="checkbox" name="auto_toggle" value="Y" <?php checked('Y', $row->auto_toggle); ?> />
|
||||
<?php _e('When new link is added toggle all others to be invisible') ?></label></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset class="options">
|
||||
<legend><?php _e('Formatting') ?></legend>
|
||||
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
||||
<tr>
|
||||
<th width="33%" scope="row"><?php _e('Before Link:') ?></th>
|
||||
<td width="67%"><input type="text" name="text_before_link" size="45" value="<?php echo wp_specialchars($row->text_before_link)?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Between Link and Description:') ?></th>
|
||||
<td><input type="text" name="text_after_link" size="45" value="<?php echo wp_specialchars($row->text_after_link)?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('After Link:') ?></th>
|
||||
<td><input type="text" name="text_after_all" size="45" value="<?php echo wp_specialchars($row->text_after_all)?>"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<p class="submit"><input type="submit" name="submit" value="<?php _e('Save Category Settings »') ?>" /></p>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
} // end if row
|
||||
break;
|
||||
} // end Edit
|
||||
case "editedcat":
|
||||
{
|
||||
if ( !current_user_can('manage_links') )
|
||||
die (__("Cheatin' uh ?"));
|
||||
|
||||
$submit=$_POST["submit"];
|
||||
if (isset($submit)) {
|
||||
|
||||
$cat_id = (int)$_POST["cat_id"];
|
||||
|
||||
$cat_name= wp_specialchars($_POST["cat_name"]);
|
||||
$auto_toggle = $_POST["auto_toggle"];
|
||||
if ($auto_toggle != 'Y') {
|
||||
$auto_toggle = 'N';
|
||||
}
|
||||
|
||||
$show_images = $_POST["show_images"];
|
||||
if ($show_images != 'Y') {
|
||||
$show_images = 'N';
|
||||
}
|
||||
|
||||
$show_description = $_POST["show_description"];
|
||||
if ($show_description != 'Y') {
|
||||
$show_description = 'N';
|
||||
}
|
||||
|
||||
$show_rating = $_POST["show_rating"];
|
||||
if ($show_rating != 'Y') {
|
||||
$show_rating = 'N';
|
||||
}
|
||||
|
||||
$show_updated = $_POST["show_updated"];
|
||||
if ($show_updated != 'Y') {
|
||||
$show_updated = 'N';
|
||||
}
|
||||
|
||||
$sort_order = $_POST["sort_order"];
|
||||
|
||||
$sort_desc = $_POST["sort_desc"];
|
||||
if ($sort_desc != 'Y') {
|
||||
$sort_desc = 'N';
|
||||
}
|
||||
$text_before_link = $_POST["text_before_link"];
|
||||
$text_after_link = $_POST["text_after_link"];
|
||||
$text_after_all = $_POST["text_after_all"];
|
||||
|
||||
$list_limit = $_POST["list_limit"];
|
||||
if ($list_limit == '')
|
||||
$list_limit = -1;
|
||||
|
||||
$wpdb->query("UPDATE $wpdb->linkcategories set
|
||||
cat_name='$cat_name',
|
||||
auto_toggle='$auto_toggle',
|
||||
show_images='$show_images',
|
||||
show_description='$show_description',
|
||||
show_rating='$show_rating',
|
||||
show_updated='$show_updated',
|
||||
sort_order='$sort_order',
|
||||
sort_desc='$sort_desc',
|
||||
text_before_link='$text_before_link',
|
||||
text_after_link='$text_after_link',
|
||||
text_after_all='$text_after_all',
|
||||
list_limit=$list_limit
|
||||
WHERE cat_id=$cat_id
|
||||
");
|
||||
} // end if save
|
||||
|
||||
|
||||
header("Location: link-categories.php");
|
||||
break;
|
||||
} // end editcat
|
||||
default:
|
||||
{
|
||||
include_once ("admin-header.php");
|
||||
if ( !current_user_can('manage_links') )
|
||||
die(__("You have do not have sufficient permissions to edit the link categories for this blog. :)"));
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Link Categories:') ?></h2>
|
||||
<table id="the-list" width="100%" cellpadding="5" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<th rowspan="2" valign="bottom"><?php _e('Name') ?></th>
|
||||
<th rowspan="2" valign="bottom"><?php _e('ID') ?></th>
|
||||
<th rowspan="2" valign="bottom"><?php _e('Toggle?') ?></th>
|
||||
<th colspan="4" valign="bottom" class="alternate"><?php _e('Show') ?></th>
|
||||
<th rowspan="2" valign="bottom"><?php _e('Sort Order') ?></th>
|
||||
<th rowspan="2" valign="bottom"><?php _e('Desc?') ?></th>
|
||||
<th colspan="3" valign="bottom" class="alternate"><?php _e('Formatting') ?></th>
|
||||
<th rowspan="2" valign="bottom"><?php _e('Limit') ?></th>
|
||||
<th rowspan="2" colspan="2"> </th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th valign="top"><?php _e('Images') ?></th>
|
||||
<th valign="top"><?php _e('Description') ?></th>
|
||||
<th valign="top"><?php _e('Rating') ?></th>
|
||||
<th valign="top"><?php _e('Updated') ?></th>
|
||||
<th valign="top"><?php _e('Before') ?></th>
|
||||
<th valign="top"><?php _e('Between') ?></th>
|
||||
<th valign="top"><?php _e('After') ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
|
||||
. " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
|
||||
. " text_after_all, list_limit FROM $wpdb->linkcategories ORDER BY cat_id");
|
||||
$i = 1;
|
||||
foreach ($results as $row) {
|
||||
if ($row->list_limit == -1) {
|
||||
$row->list_limit = __('none');
|
||||
}
|
||||
$style = ($i % 2) ? ' class="alternate"' : '';
|
||||
/*
|
||||
Manually internationalize every sort order option.
|
||||
*/
|
||||
switch ($row->sort_order) {
|
||||
case 'name':
|
||||
$row->sort_order = __('name');
|
||||
break;
|
||||
case 'id':
|
||||
$row->sort_order = __('id');
|
||||
break;
|
||||
case 'url':
|
||||
$row->sort_order = __('url');
|
||||
break;
|
||||
case 'rating':
|
||||
$row->sort_order = __('rating');
|
||||
break;
|
||||
case 'updated':
|
||||
$row->sort_order = __('updated');
|
||||
break;
|
||||
case 'rand':
|
||||
$row->sort_order = __('rand');
|
||||
break;
|
||||
case 'length':
|
||||
$row->sort_order = __('length');
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<tr id="link-category-<?php echo $row->cat_id; ?>" valign="middle" align="center" <?php echo $style ?> style="border-bottom: 1px dotted #9C9A9C;">
|
||||
<td><?php echo wp_specialchars($row->cat_name)?></td>
|
||||
<td ><?php echo $row->cat_id?></td>
|
||||
<td><?php echo $row->auto_toggle == 'Y' ? __('Yes') : __('No') ?></td>
|
||||
<td><?php echo $row->show_images == 'Y' ? __('Yes') : __('No') ?></td>
|
||||
<td><?php echo $row->show_description == 'Y' ? __('Yes') : __('No') ?></td>
|
||||
<td><?php echo $row->show_rating == 'Y' ? __('Yes') : __('No') ?></td>
|
||||
<td><?php echo $row->show_updated == 'Y' ? __('Yes') : __('No') ?></td>
|
||||
<td><?php echo $row->sort_order ?></td>
|
||||
<td><?php echo $row->sort_desc == 'Y' ? __('Yes') : __('No') ?></td>
|
||||
<td nowrap="nowrap"><?php echo htmlentities($row->text_before_link)?> </td>
|
||||
<td nowrap="nowrap"><?php echo htmlentities($row->text_after_link)?> </td>
|
||||
<td nowrap="nowrap"><?php echo htmlentities($row->text_after_all)?></td>
|
||||
<td><?php echo $row->list_limit ?></td>
|
||||
<td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&action=Edit" class="edit"><?php _e('Edit') ?></a></td>
|
||||
<td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&action=Delete" onclick="return deleteSomething( 'link category', <?php echo $row->cat_id . ", '" . sprintf(__("You are about to delete the "%s" link category.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($row->cat_name,1)); ?>' );" class="delete"><?php _e('Delete') ?></a></td>
|
||||
</tr>
|
||||
<?php
|
||||
++$i;
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<p><?php _e('These are the defaults for when you call a link category with no additional arguments. All of these settings may be overwritten.') ?></p>
|
||||
|
||||
<div id="ajax-response"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wrap">
|
||||
<form name="addcat" method="post">
|
||||
<input type="hidden" name="action" value="addcat" />
|
||||
<h2><?php _e('Add a Link Category:') ?></h2>
|
||||
<fieldset class="options">
|
||||
<legend><?php _e('Category Options') ?></legend>
|
||||
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
||||
<tr>
|
||||
<th width="33%" scope="row"><?php _e('Name:') ?></th>
|
||||
<td width="67%"><input type="text" name="cat_name" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Show:') ?></th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="show_images" value="Y" />
|
||||
<?php _e('Image') ?></label> <br />
|
||||
<label>
|
||||
<input type="checkbox" name="show_description" value="Y" />
|
||||
<?php _e('Description') ?></label>
|
||||
<?php _e('(shown in <code>title</code> regardless)') ?><br />
|
||||
<label>
|
||||
<input type="checkbox" name="show_rating" value="Y" />
|
||||
<?php _e('Rating') ?></label> <br />
|
||||
<label>
|
||||
<input type="checkbox" name="show_updated" value="Y" />
|
||||
<?php _e('Updated') ?></label>
|
||||
<?php _e('(shown in <code>title</code> regardless)') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Sort order:') ?></th>
|
||||
<td>
|
||||
<select name="sort_order" size="1">
|
||||
<option value="name"><?php _e('Name') ?></option>
|
||||
<option value="id"><?php _e('Id') ?></option>
|
||||
<option value="url"><?php _e('URL') ?></option>
|
||||
<option value="rating"><?php _e('Rating') ?></option>
|
||||
<option value="updated"><?php _e('Updated') ?></option>
|
||||
<option value="rand"><?php _e('Random') ?></option>
|
||||
</select>
|
||||
<label>
|
||||
<input type="checkbox" name="sort_desc" value="Y" />
|
||||
<?php _e('Descending') ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Limit:') ?></th>
|
||||
<td>
|
||||
<input type="text" name="list_limit" size="5" value="" /> <?php _e('(Leave empty for no limit to number of links shown)') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Toggle:') ?></th>
|
||||
<td><label>
|
||||
<input type="checkbox" name="auto_toggle" value="Y" />
|
||||
<?php _e('When new link is added toggle all others to be invisible') ?></label></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset class="options">
|
||||
<legend><?php _e('Formatting') ?></legend>
|
||||
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
||||
<tr>
|
||||
<th width="33%" scope="row"><?php _e('Before Link:') ?></th>
|
||||
<td width="67%"><input type="text" name="text_before_link" size="45" value="<li>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Between Link and Description:') ?></th>
|
||||
<td><input type="text" name="text_after_link" size="45" value="<br />" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('After Link:') ?></th>
|
||||
<td><input type="text" name="text_after_all" size="45" value="</li>"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<p class="submit"><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<h3><?php _e('Note:') ?></h3>
|
||||
<p><?php printf(__('Deleting a link category does not delete links from that category.<br />It will just set them back to the default category <strong>%s</strong>.'), get_linkcatname(1)) ?></p>
|
||||
</div>
|
||||
<?php
|
||||
break;
|
||||
} // end default
|
||||
} // end case
|
||||
?>
|
||||
<?php include('admin-footer.php'); ?>
|
|
@ -25,7 +25,7 @@ switch ($step) {
|
|||
<h2><?php _e('Import your blogroll from another system') ?> </h2>
|
||||
<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
|
||||
|
||||
<p><?php _e('If a program or website you use allows you to export your links or subscriptions as OPML you may import them here.'); ?>
|
||||
<p><?php _e('If a program or website you use allows you to export your bookmarks or subscriptions as OPML you may import them here.'); ?>
|
||||
<div style="width: 70%; margin: auto; height: 8em;">
|
||||
<input type="hidden" name="step" value="1" />
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
|
||||
|
@ -42,13 +42,13 @@ switch ($step) {
|
|||
|
||||
</div>
|
||||
|
||||
<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these links in.') ?><br />
|
||||
<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these bookmarks in.') ?><br />
|
||||
<?php _e('Category:') ?> <select name="cat_id">
|
||||
<?php
|
||||
$categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
|
||||
$categories = get_categories('hide_empty=0');
|
||||
foreach ($categories as $category) {
|
||||
?>
|
||||
<option value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_id.': '.$category->cat_name; ?></option>
|
||||
<option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option>
|
||||
<?php
|
||||
} // end foreach
|
||||
?>
|
||||
|
@ -103,14 +103,12 @@ foreach ($categories as $category) {
|
|||
$titles[$i] = '';
|
||||
if ('http' == substr($titles[$i], 0, 4))
|
||||
$titles[$i] = '';
|
||||
// FIXME: Use wp_insert_link().
|
||||
$query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss)
|
||||
VALUES('{$urls[$i]}', '".$wpdb->escape($names[$i])."', '', $cat_id, '".$wpdb->escape($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n";
|
||||
$result = $wpdb->query($query);
|
||||
$link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]);
|
||||
wp_insert_link($link);
|
||||
echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]);
|
||||
}
|
||||
?>
|
||||
<p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
|
||||
<p><?php printf(__('Inserted %1$d bookmarks into category %2$s. All done! Go <a href="%3$s">manage those bookmarks</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
|
||||
<?php
|
||||
} // end if got url
|
||||
else
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
<?php
|
||||
|
||||
|
||||
// Links
|
||||
// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
|
||||
|
||||
require_once('admin.php');
|
||||
require_once ('admin.php');
|
||||
|
||||
$title = __('Manage Links');
|
||||
$title = __('Manage Bookmarks');
|
||||
$this_file = $parent_file = 'link-manager.php';
|
||||
$list_js = true;
|
||||
|
||||
$wpvarstoreset = array('action','cat_id', 'linkurl', 'name', 'image',
|
||||
'description', 'visible', 'target', 'category', 'link_id',
|
||||
'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
|
||||
'notes', 'linkcheck[]');
|
||||
$wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]');
|
||||
|
||||
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
||||
for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
|
||||
$wpvar = $wpvarstoreset[$i];
|
||||
if (!isset($$wpvar)) {
|
||||
if (empty($_POST["$wpvar"])) {
|
||||
if (empty($_GET["$wpvar"])) {
|
||||
if (!isset ($$wpvar)) {
|
||||
if (empty ($_POST["$wpvar"])) {
|
||||
if (empty ($_GET["$wpvar"])) {
|
||||
$$wpvar = '';
|
||||
} else {
|
||||
$$wpvar = $_GET["$wpvar"];
|
||||
|
@ -28,226 +27,39 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
|||
}
|
||||
}
|
||||
|
||||
$links_show_cat_id = $_COOKIE['links_show_cat_id_' . COOKIEHASH];
|
||||
$links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH];
|
||||
if (empty ($cat_id))
|
||||
$cat_id = 'all';
|
||||
|
||||
if ('' != $_POST['assign']) $action = 'assign';
|
||||
if ('' != $_POST['visibility']) $action = 'visibility';
|
||||
if ('' != $_POST['move']) $action = 'move';
|
||||
if ('' != $_POST['linkcheck']) $linkcheck = $_POST[linkcheck];
|
||||
|
||||
switch ($action) {
|
||||
case 'assign':
|
||||
{
|
||||
check_admin_referer();
|
||||
|
||||
// check the current user's level first.
|
||||
if ( !current_user_can('manage_links') )
|
||||
die (__("Cheatin' uh ?"));
|
||||
|
||||
//for each link id (in $linkcheck[]): if the current user level >= the
|
||||
//userlevel of the owner of the link then we can proceed.
|
||||
|
||||
if (count($linkcheck) == 0) {
|
||||
header('Location: ' . $this_file);
|
||||
exit;
|
||||
}
|
||||
$all_links = join(',', $linkcheck);
|
||||
$results = $wpdb->get_results("SELECT link_id, link_owner FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
|
||||
foreach ($results as $row) {
|
||||
$ids_to_change[] = $row->link_id;
|
||||
}
|
||||
|
||||
// should now have an array of links we can change
|
||||
$all_links = join(',', $ids_to_change);
|
||||
$q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)");
|
||||
|
||||
header('Location: ' . $this_file);
|
||||
break;
|
||||
}
|
||||
case 'visibility':
|
||||
{
|
||||
check_admin_referer();
|
||||
|
||||
// check the current user's level first.
|
||||
if ( !current_user_can('manage_links') )
|
||||
die (__("Cheatin' uh ?"));
|
||||
|
||||
//for each link id (in $linkcheck[]): toggle the visibility
|
||||
if (count($linkcheck) == 0) {
|
||||
header('Location: ' . $this_file);
|
||||
exit;
|
||||
}
|
||||
$all_links = join(',', $linkcheck);
|
||||
$results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)");
|
||||
foreach ($results as $row) {
|
||||
if ($row->link_visible == 'Y') { // ok to proceed
|
||||
$ids_to_turnoff[] = $row->link_id;
|
||||
} else {
|
||||
$ids_to_turnon[] = $row->link_id;
|
||||
}
|
||||
}
|
||||
|
||||
// should now have two arrays of links to change
|
||||
if (count($ids_to_turnoff)) {
|
||||
$all_linksoff = join(',', $ids_to_turnoff);
|
||||
$q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)");
|
||||
}
|
||||
|
||||
if (count($ids_to_turnon)) {
|
||||
$all_linkson = join(',', $ids_to_turnon);
|
||||
$q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)");
|
||||
}
|
||||
|
||||
header('Location: ' . $this_file);
|
||||
break;
|
||||
}
|
||||
case 'move':
|
||||
{
|
||||
check_admin_referer();
|
||||
|
||||
// check the current user's level first.
|
||||
if ( !current_user_can('manage_links') )
|
||||
die (__("Cheatin' uh ?"));
|
||||
|
||||
//for each link id (in $linkcheck[]) change category to selected value
|
||||
if (count($linkcheck) == 0) {
|
||||
header('Location: ' . $this_file);
|
||||
exit;
|
||||
}
|
||||
$all_links = join(',', $linkcheck);
|
||||
// should now have an array of links we can change
|
||||
$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
|
||||
|
||||
header('Location: ' . $this_file);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Add':
|
||||
{
|
||||
check_admin_referer();
|
||||
|
||||
add_link();
|
||||
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true');
|
||||
break;
|
||||
} // end Add
|
||||
|
||||
case 'editlink':
|
||||
{
|
||||
|
||||
check_admin_referer();
|
||||
|
||||
if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
|
||||
$cat_id = $links_show_cat_id;
|
||||
|
||||
if (!isset($cat_id) || ($cat_id == '')) {
|
||||
if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
|
||||
$cat_id = 'All';
|
||||
}
|
||||
$links_show_cat_id = $cat_id;
|
||||
|
||||
$link_id = (int) $_POST['link_id'];
|
||||
edit_link($link_id);
|
||||
|
||||
setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
|
||||
wp_redirect($this_file);
|
||||
break;
|
||||
} // end Save
|
||||
|
||||
case 'Delete':
|
||||
{
|
||||
check_admin_referer();
|
||||
|
||||
if ( !current_user_can('manage_links') )
|
||||
die (__("Cheatin' uh ?"));
|
||||
|
||||
$link_id = (int) $_GET['link_id'];
|
||||
|
||||
wp_delete_link($link_id);
|
||||
|
||||
if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
|
||||
$cat_id = $links_show_cat_id;
|
||||
|
||||
if (!isset($cat_id) || ($cat_id == '')) {
|
||||
if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
|
||||
$cat_id = 'All';
|
||||
}
|
||||
$links_show_cat_id = $cat_id;
|
||||
setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
|
||||
wp_redirect($this_file);
|
||||
break;
|
||||
} // end Delete
|
||||
|
||||
case 'linkedit': {
|
||||
$xfn_js = true;
|
||||
include_once ('admin-header.php');
|
||||
if ( !current_user_can('manage_links') )
|
||||
die(__('You do not have sufficient permissions to edit the links for this blog.'));
|
||||
|
||||
$link_id = (int) $_GET['link_id'];
|
||||
|
||||
if ( !$link = get_link_to_edit($link_id) )
|
||||
die( __('Link not found.') );
|
||||
|
||||
include('edit-link-form.php');
|
||||
break;
|
||||
} // end linkedit
|
||||
case __("Show"):
|
||||
{
|
||||
if (!isset($cat_id) || ($cat_id == '')) {
|
||||
if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
|
||||
$cat_id = 'All';
|
||||
}
|
||||
$links_show_cat_id = $cat_id;
|
||||
if (!isset($order_by) || ($order_by == '')) {
|
||||
if (!isset($links_show_order) || ($links_show_order == ''))
|
||||
if (empty ($order_by))
|
||||
$order_by = 'order_name';
|
||||
}
|
||||
$links_show_order = $order_by;
|
||||
//break; fall through
|
||||
} // end Show
|
||||
case "popup":
|
||||
{
|
||||
$link_url = stripslashes($_GET["linkurl"]);
|
||||
$link_name = stripslashes($_GET["name"]);
|
||||
//break; fall through
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
|
||||
$cat_id = $links_show_cat_id;
|
||||
|
||||
if (!isset($cat_id) || ($cat_id == '')) {
|
||||
if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
|
||||
$cat_id = 'All';
|
||||
}
|
||||
$links_show_cat_id = $cat_id;
|
||||
if (isset($links_show_order) && ($links_show_order != ''))
|
||||
$order_by = $links_show_order;
|
||||
$title = __('Manage Bookmarks');
|
||||
include_once ("./admin-header.php");
|
||||
|
||||
if (!isset($order_by) || ($order_by == ''))
|
||||
$order_by = 'order_name';
|
||||
$links_show_order = $order_by;
|
||||
if (!current_user_can('manage_links'))
|
||||
die(__("You do not have sufficient permissions to edit the bookmarks for this blog."));
|
||||
|
||||
setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
|
||||
setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600);
|
||||
include_once ("./admin-header.php");
|
||||
if ( !current_user_can('manage_links') )
|
||||
die(__("You do not have sufficient permissions to edit the links for this blog."));
|
||||
|
||||
switch ($order_by)
|
||||
{
|
||||
case 'order_id': $sqlorderby = 'id'; break;
|
||||
case 'order_url': $sqlorderby = 'url'; break;
|
||||
case 'order_desc': $sqlorderby = 'description'; break;
|
||||
case 'order_owner': $sqlorderby = 'owner'; break;
|
||||
case 'order_rating': $sqlorderby = 'rating'; break;
|
||||
case 'order_name':
|
||||
default: $sqlorderby = 'name'; break;
|
||||
}
|
||||
|
||||
if ($action != "popup") {
|
||||
switch ($order_by) {
|
||||
case 'order_id' :
|
||||
$sqlorderby = 'id';
|
||||
break;
|
||||
case 'order_url' :
|
||||
$sqlorderby = 'url';
|
||||
break;
|
||||
case 'order_desc' :
|
||||
$sqlorderby = 'description';
|
||||
break;
|
||||
case 'order_owner' :
|
||||
$sqlorderby = 'owner';
|
||||
break;
|
||||
case 'order_rating' :
|
||||
$sqlorderby = 'rating';
|
||||
break;
|
||||
case 'order_name' :
|
||||
default :
|
||||
$sqlorderby = 'name';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
|
@ -265,12 +77,22 @@ function checkAll(form)
|
|||
//-->
|
||||
</script>
|
||||
|
||||
<?php
|
||||
if ( isset($_GET['deleted']) ) {
|
||||
echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
|
||||
$deleted = (int) $_GET['deleted'];
|
||||
printf(__('%s bookmarks deleted.'), $deleted);
|
||||
echo '</p></div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<form name="cats" method="post" action="">
|
||||
<table width="75%" cellpadding="3" cellspacing="3">
|
||||
<h2><?php _e('Bookmark Management'); ?></h2>
|
||||
<form name="cats" method="post" action="">
|
||||
<table width="75%" cellpadding="3" cellspacing="3">
|
||||
<tr>
|
||||
<td>
|
||||
<?php _e('<strong>Show</strong> links in category:'); ?><br />
|
||||
<?php _e('<strong>Show</strong> bookmarks in category:'); ?><br />
|
||||
</td>
|
||||
<td>
|
||||
<?php _e('<strong>Order</strong> by:');?>
|
||||
|
@ -279,83 +101,55 @@ function checkAll(form)
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
$results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
|
||||
echo " <select name=\"cat_id\">\n";
|
||||
echo " <option value=\"All\"";
|
||||
if ($cat_id == 'All')
|
||||
echo " selected='selected'";
|
||||
echo "> " . __('All') . "</option>\n";
|
||||
foreach ($results as $row) {
|
||||
echo " <option value=\"".$row->cat_id."\"";
|
||||
if ($row->cat_id == $cat_id)
|
||||
echo " selected='selected'";
|
||||
echo ">".$row->cat_id.": ".wp_specialchars($row->cat_name);
|
||||
if ($row->auto_toggle == 'Y')
|
||||
echo ' '.__('(auto toggle)');
|
||||
echo "</option>\n";
|
||||
}
|
||||
echo " </select>\n";
|
||||
?>
|
||||
<?php $categories = get_categories("hide_empty=1&type=link"); ?>
|
||||
<select name="cat_id">
|
||||
<option value="all" <?php echo ($cat_id == 'all') ? " selected='selected'" : ''; ?>><?php _e('All') ?></option>
|
||||
<?php foreach ($categories as $cat): ?>
|
||||
<option value="<?php echo $cat->cat_ID; ?>"<?php echo ($cat->cat_ID == $cat_id) ? " selected='selected'" : ''; ?>><?php echo wp_specialchars($cat->cat_name); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select name="order_by">
|
||||
<option value="order_id" <?php if ($order_by == 'order_id') echo " selected='selected'";?>><?php _e('Link ID') ?></option>
|
||||
<option value="order_id" <?php if ($order_by == 'order_id') echo " selected='selected'";?>><?php _e('Bookmark ID') ?></option>
|
||||
<option value="order_name" <?php if ($order_by == 'order_name') echo " selected='selected'";?>><?php _e('Name') ?></option>
|
||||
<option value="order_url" <?php if ($order_by == 'order_url') echo " selected='selected'";?>><?php _e('URI') ?></option>
|
||||
<option value="order_desc" <?php if ($order_by == 'order_desc') echo " selected='selected'";?>><?php _e('Description') ?></option>
|
||||
<option value="order_owner" <?php if ($order_by == 'order_owner') echo " selected='selected'";?>><?php _e('Owner') ?></option>
|
||||
<option value="order_rating" <?php if ($order_by == 'order_rating') echo " selected='selected'";?>><?php _e('Rating') ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="action" value="<?php _e('Show') ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<form name="links" id="links" method="post" action="">
|
||||
<div class="wrap">
|
||||
|
||||
<input type="hidden" name="link_id" value="" />
|
||||
<input type="hidden" name="action" value="" />
|
||||
<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
|
||||
<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
|
||||
<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
|
||||
<form name="links" id="links" method="post" action="link.php">
|
||||
<input type="hidden" name="link_id" value="" />
|
||||
<input type="hidden" name="action" value="" />
|
||||
<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
|
||||
<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
|
||||
<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
|
||||
<tr>
|
||||
<th width="15%"><?php _e('Name') ?></th>
|
||||
<th><?php _e('URI') ?></th>
|
||||
<th><?php _e('Category') ?></th>
|
||||
<th><?php _e('Categories') ?></th>
|
||||
<th><?php _e('rel') ?></th>
|
||||
<th><?php _e('Image') ?></th>
|
||||
<th><?php _e('Visible') ?></th>
|
||||
<th colspan="2"><?php _e('Action') ?></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<?php
|
||||
$sql = "SELECT link_url, link_name, link_image, link_description, link_visible,
|
||||
link_category AS cat_id, cat_name AS category, $wpdb->users.user_login, link_id,
|
||||
link_rating, link_rel
|
||||
FROM $wpdb->links
|
||||
LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id
|
||||
LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->links.link_owner ";
|
||||
|
||||
if (isset($cat_id) && ($cat_id != 'All')) {
|
||||
$sql .= " WHERE link_category = $cat_id ";
|
||||
}
|
||||
$sql .= ' ORDER BY link_' . $sqlorderby;
|
||||
|
||||
// echo "$sql";
|
||||
$links = $wpdb->get_results($sql);
|
||||
if ($links) {
|
||||
if ( 'all' == $cat_id )
|
||||
$cat_id = '';
|
||||
$links = get_linkz("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0");
|
||||
if ($links)
|
||||
foreach ($links as $link) {
|
||||
$link->link_name = wp_specialchars($link->link_name);
|
||||
$link->link_category = wp_specialchars($link->link_category);
|
||||
$link->link_description = wp_specialchars($link->link_description);
|
||||
$link->link_url = wp_specialchars($link->link_url);
|
||||
$link->link_category = wp_get_link_cats($link->link_id);
|
||||
$short_url = str_replace('http://', '', $link->link_url);
|
||||
$short_url = str_replace('www.', '', $short_url);
|
||||
if ('/' == substr($short_url, -1))
|
||||
|
@ -363,83 +157,54 @@ function checkAll(form)
|
|||
if (strlen($short_url) > 35)
|
||||
$short_url = substr($short_url, 0, 32).'...';
|
||||
|
||||
$image = ($link->link_image != null) ? __('Yes') : __('No');
|
||||
$visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
|
||||
++$i;
|
||||
++ $i;
|
||||
$style = ($i % 2) ? '' : ' class="alternate"';
|
||||
?>
|
||||
<tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
|
||||
<td><strong><?php echo $link->link_name; ?></strong><br />
|
||||
<?php
|
||||
echo sprintf(__('Description: %s'), $link->link_description) . "</td>";
|
||||
echo "<td><a href=\"$link->link_url\" title=\"" . sprintf(__('Visit %s'), $link->link_name) . "\">$short_url</a></td>";
|
||||
echo <<<LINKS
|
||||
<td>$link->category</td>
|
||||
<td>$link->link_rel</td>
|
||||
<td align='center'>$image</td>
|
||||
<td align='center'>$visible</td>
|
||||
LINKS;
|
||||
$show_buttons = 1; // default
|
||||
<?php
|
||||
|
||||
if ($show_buttons) {
|
||||
echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&action=linkedit" class="edit">' . __('Edit') . '</a></td>';
|
||||
echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&action=Delete"' . " onclick=\"return deleteSomething( 'link', $link->link_id , '" . sprintf(__("You are about to delete the "%s" link to %s.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($link->link_name,1), wp_specialchars($link->link_url)) . '\' );" class="delete">' . __('Delete') . '</a></td>';
|
||||
echo '<td><input type="checkbox" name="linkcheck[]" value="' . $link->link_id . '" /></td>';
|
||||
} else {
|
||||
echo "<td> </td><td> </td><td> </td>\n";
|
||||
|
||||
echo $link->link_description . "</td>";
|
||||
echo "<td><a href=\"$link->link_url\" title=\"".sprintf(__('Visit %s'), $link->link_name)."\">$short_url</a></td>";
|
||||
?>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
$cat_names = array();
|
||||
foreach ($link->link_category as $category) {
|
||||
$cat_name = get_the_category_by_ID($category);
|
||||
$cat_names[] = wp_specialchars($cat_name);
|
||||
}
|
||||
echo implode(', ', $cat_names);
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo $link->link_rel; ?></td>
|
||||
<td align='center'><?php echo $visible; ?></td>
|
||||
<?php
|
||||
|
||||
echo '<td><a href="link.php?link_id='.$link->link_id.'&action=edit" class="edit">'.__('Edit').'</a></td>';
|
||||
echo '<td><a href="link.php?link_id='.$link->link_id.'&action=delete"'." class='delete' onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the "%s" bookmark to %s.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
|
||||
echo '<td><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
|
||||
echo "\n </tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<div id="ajax-response"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wrap">
|
||||
<table width="100%" cellpadding="3" cellspacing="3">
|
||||
<tr><th colspan="4"><?php _e('Manage Multiple Links:') ?></th></tr>
|
||||
<tr><td colspan="4"><?php _e('Use the checkboxes on the right to select multiple links and choose an action below:') ?></td></tr>
|
||||
<table width="100%" cellpadding="3" cellspacing="3">
|
||||
<tr>
|
||||
<td>
|
||||
<?php _e('Assign ownership to:'); ?>
|
||||
<?php
|
||||
$results = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY ID");
|
||||
echo " <select name=\"newowner\" size=\"1\">\n";
|
||||
foreach ($results as $row) {
|
||||
echo " <option value=\"".$row->ID."\"";
|
||||
echo ">".$row->user_login;
|
||||
echo "</option>\n";
|
||||
}
|
||||
echo " </select>\n";
|
||||
?>
|
||||
<input name="assign" type="submit" id="assign" value="<?php _e('Go') ?>" />
|
||||
</td>
|
||||
<td>
|
||||
<input name="visibility" type="submit" id="visibility" value="<?php _e('Toggle Visibility') ?>" />
|
||||
</td>
|
||||
<td>
|
||||
<?php _e('Move to category:'); link_category_dropdown('category'); ?> <input name="move" type="submit" id="move" value="<?php _e('Go') ?>" />
|
||||
<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Bookmarks') ?>" onclick="return confirm('<?php _e("You are about to delete these bookmarks permanently \\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" /></p>
|
||||
</td>
|
||||
<td align="right">
|
||||
<a href="#" onclick="checkAll(document.getElementById('links')); return false; "><?php _e('Toggle Checkboxes') ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
} // end if !popup
|
||||
?>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<?php
|
||||
break;
|
||||
} // end default
|
||||
} // end case
|
||||
?>
|
||||
|
||||
<?php include('admin-footer.php'); ?>
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
require_once ('admin.php');
|
||||
|
||||
$wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]');
|
||||
|
||||
for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
|
||||
$wpvar = $wpvarstoreset[$i];
|
||||
if (!isset ($$wpvar)) {
|
||||
if (empty ($_POST["$wpvar"])) {
|
||||
if (empty ($_GET["$wpvar"])) {
|
||||
$$wpvar = '';
|
||||
} else {
|
||||
$$wpvar = $_GET["$wpvar"];
|
||||
}
|
||||
} else {
|
||||
$$wpvar = $_POST["$wpvar"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ('' != $_POST['deletebookmarks'])
|
||||
$action = 'deletebookmarks';
|
||||
if ('' != $_POST['move'])
|
||||
$action = 'move';
|
||||
if ('' != $_POST['linkcheck'])
|
||||
$linkcheck = $_POST[linkcheck];
|
||||
|
||||
$this_file = 'link-manager.php';
|
||||
|
||||
switch ($action) {
|
||||
case 'deletebookmarks' :
|
||||
check_admin_referer();
|
||||
|
||||
// check the current user's level first.
|
||||
if (!current_user_can('manage_links'))
|
||||
die(__("Cheatin' uh ?"));
|
||||
|
||||
//for each link id (in $linkcheck[]) change category to selected value
|
||||
if (count($linkcheck) == 0) {
|
||||
header('Location: '.$this_file);
|
||||
exit;
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
foreach ($linkcheck as $link_id) {
|
||||
$link_id = (int) $link_id;
|
||||
|
||||
if ( wp_delete_link($link_id) )
|
||||
$deleted++;
|
||||
}
|
||||
|
||||
header("Location: $this_file?deleted=$deleted");
|
||||
break;
|
||||
|
||||
case 'move' :
|
||||
check_admin_referer();
|
||||
|
||||
// check the current user's level first.
|
||||
if (!current_user_can('manage_links'))
|
||||
die(__("Cheatin' uh ?"));
|
||||
|
||||
//for each link id (in $linkcheck[]) change category to selected value
|
||||
if (count($linkcheck) == 0) {
|
||||
header('Location: '.$this_file);
|
||||
exit;
|
||||
}
|
||||
$all_links = join(',', $linkcheck);
|
||||
// should now have an array of links we can change
|
||||
//$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
|
||||
|
||||
header('Location: '.$this_file);
|
||||
break;
|
||||
|
||||
case 'add' :
|
||||
check_admin_referer();
|
||||
|
||||
add_link();
|
||||
|
||||
header('Location: '.$_SERVER['HTTP_REFERER'].'?added=true');
|
||||
break;
|
||||
|
||||
case 'save' :
|
||||
check_admin_referer();
|
||||
|
||||
$link_id = (int) $_POST['link_id'];
|
||||
edit_link($link_id);
|
||||
|
||||
wp_redirect($this_file);
|
||||
exit;
|
||||
break;
|
||||
|
||||
case 'delete' :
|
||||
check_admin_referer();
|
||||
|
||||
if (!current_user_can('manage_links'))
|
||||
die(__("Cheatin' uh ?"));
|
||||
|
||||
$link_id = (int) $_GET['link_id'];
|
||||
|
||||
wp_delete_link($link_id);
|
||||
|
||||
wp_redirect($this_file);
|
||||
break;
|
||||
|
||||
case 'edit' :
|
||||
$xfn_js = true;
|
||||
$editing = true;
|
||||
$parent_file = 'link-manager.php';
|
||||
$submenu_file = 'link-manager.php';
|
||||
$title = __('Edit Bookmark');
|
||||
include_once ('admin-header.php');
|
||||
if (!current_user_can('manage_links'))
|
||||
die(__('You do not have sufficient permissions to edit the bookmarks for this blog.'));
|
||||
|
||||
$link_id = (int) $_GET['link_id'];
|
||||
|
||||
if (!$link = get_link_to_edit($link_id))
|
||||
die(__('Link not found.'));
|
||||
|
||||
include ('edit-link-form.php');
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
include ('admin-footer.php');
|
||||
?>
|
|
@ -22,7 +22,7 @@ case 'delete-link' :
|
|||
if ( !current_user_can('manage_links') )
|
||||
die ('-1');
|
||||
|
||||
if ( $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$id'") )
|
||||
if ( wp_delete_link($id) )
|
||||
die('1');
|
||||
else die('0');
|
||||
break;
|
||||
|
@ -80,11 +80,10 @@ case 'delete-link-category' :
|
|||
$id = (int) $_POST['id'];
|
||||
if ( 1 == $id )
|
||||
die('0');
|
||||
if ( !current_user_can('manage_links') )
|
||||
if ( !current_user_can('manage_categories') )
|
||||
die('-1');
|
||||
|
||||
if ( $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$id'") ) {
|
||||
$wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$id'");
|
||||
if ( wp_delete_category($id) ) {
|
||||
die('1');
|
||||
} else {
|
||||
die('0');
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
$menu[0] = array(__('Dashboard'), 'read', 'index.php');
|
||||
$menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
|
||||
$menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
|
||||
$menu[20] = array(__('Links'), 'manage_links', 'link-manager.php');
|
||||
$menu[20] = array(__('Bookmarks'), 'manage_links', 'link-manager.php');
|
||||
$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
|
||||
$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
|
||||
if ( current_user_can('edit_users') )
|
||||
|
@ -28,10 +28,9 @@ $awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comme
|
|||
$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiting_mod), 'edit_posts', 'moderation.php');
|
||||
$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php');
|
||||
|
||||
$submenu['link-manager.php'][5] = array(__('Manage Links'), 'manage_links', 'link-manager.php');
|
||||
$submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php');
|
||||
$submenu['link-manager.php'][15] = array(__('Link Categories'), 'manage_links', 'link-categories.php');
|
||||
$submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php');
|
||||
$submenu['link-manager.php'][5] = array(__('Manage Bookmarks'), 'manage_links', 'link-manager.php');
|
||||
$submenu['link-manager.php'][10] = array(__('Add Bookmark'), 'manage_links', 'link-add.php');
|
||||
$submenu['link-manager.php'][20] = array(__('Import Bookmarks'), 'manage_links', 'link-import.php');
|
||||
|
||||
$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
|
||||
$submenu['profile.php'][10] = array(__('Authors & Users'), 'edit_users', 'users.php');
|
||||
|
|
|
@ -35,7 +35,7 @@ include('admin-header.php');
|
|||
</fieldset>
|
||||
|
||||
<p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_settings('use_linksupdate')); ?> />
|
||||
<label for="use_linksupdate"><?php _e('Track Links’ Update Times') ?></label></p>
|
||||
<label for="use_linksupdate"><?php _e('Track Bookmarks’ Update Times') ?></label></p>
|
||||
<p>
|
||||
<label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_settings('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label>
|
||||
</p>
|
||||
|
|
|
@ -41,6 +41,18 @@ endforeach;
|
|||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Default bookmark category:') ?></th>
|
||||
<td><select name="default_link_category" id="default_link_category">
|
||||
<?php
|
||||
foreach ($categories as $category) :
|
||||
if ($category->cat_ID == get_settings('default_link_category')) $selected = " selected='selected'";
|
||||
else $selected = '';
|
||||
echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
|
||||
endforeach;
|
||||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<fieldset class="options">
|
||||
|
@ -90,7 +102,7 @@ endforeach;
|
|||
|
||||
<p class="submit">
|
||||
<input type="hidden" name="action" value="update" />
|
||||
<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags" />
|
||||
<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags,default_link_category" />
|
||||
<input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once(ABSPATH . '/wp-admin/admin-functions.php');
|
||||
require_once(ABSPATH . '/wp-admin/admin-db.php');
|
||||
require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
|
||||
// Functions to be called in install and upgrade scripts
|
||||
function upgrade_all() {
|
||||
|
@ -33,7 +34,7 @@ function upgrade_all() {
|
|||
if ( $wp_current_db_version < 3308 )
|
||||
upgrade_160();
|
||||
|
||||
if ( $wp_current_db_version < 3548 )
|
||||
if ( $wp_current_db_version < 3570 )
|
||||
upgrade_210();
|
||||
|
||||
$wp_rewrite->flush_rules();
|
||||
|
@ -366,6 +367,43 @@ function upgrade_210() {
|
|||
foreach ( $posts as $post )
|
||||
wp_schedule_event(mysql2date('U', $post->post_date), 'once', 'publish_future_post', $post->ID);
|
||||
}
|
||||
if ( $wp_current_db_version < 3570 ) {
|
||||
// Create categories for link categories if a category with the same
|
||||
// name doesn't exist. Create a map of link cat IDs to cat IDs.
|
||||
$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
|
||||
foreach ( $link_cats as $link_cat) {
|
||||
if ( $cat_id = category_exists($link_cat->cat_name) ) {
|
||||
$link_cat_id_map[$link_cat->cat_id] = $cat_id;
|
||||
$default_link_cat = $cat_id;
|
||||
} else {
|
||||
$link_cat_id_map[$link_cat->cat_id] = wp_create_category($link_cat->cat_name);
|
||||
$default_link_cat = $link_cat_id_map[$link_cat->cat_id];
|
||||
}
|
||||
}
|
||||
|
||||
// Associate links to cats.
|
||||
$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
|
||||
foreach ( $links as $link ) {
|
||||
$link_cat = $link_cat_id_map[$link->link_category];
|
||||
$cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'");
|
||||
if (!$cat && 0 != $link->link_category) {
|
||||
$wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id)
|
||||
VALUES ('$link->link_id', '$link_cat')");
|
||||
}
|
||||
}
|
||||
|
||||
// Set default to the last category we grabbed during the upgrade loop.
|
||||
update_option('default_link_category', $default_link_cat);
|
||||
|
||||
// Count links per category.
|
||||
if ( 0 == $wpdb->get_var("SELECT SUM(link_count) FROM $wpdb->categories") ) {
|
||||
$categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
|
||||
foreach ( $categories as $cat_id ) {
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
|
||||
$wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The functions we use to actually do stuff
|
||||
|
|
|
@ -8,6 +8,9 @@ $wp_queries="CREATE TABLE $wpdb->categories (
|
|||
category_description longtext NOT NULL,
|
||||
category_parent bigint(20) NOT NULL default '0',
|
||||
category_count bigint(20) NOT NULL default '0',
|
||||
link_count bigint(20) NOT NULL default '0',
|
||||
posts_private tinyint(1) NOT NULL default '0',
|
||||
links_private tinyint(1) NOT NULL default '0',
|
||||
PRIMARY KEY (cat_ID),
|
||||
KEY category_nicename (category_nicename)
|
||||
);
|
||||
|
@ -31,6 +34,13 @@ CREATE TABLE $wpdb->comments (
|
|||
KEY comment_approved (comment_approved),
|
||||
KEY comment_post_ID (comment_post_ID)
|
||||
);
|
||||
CREATE TABLE $wpdb->link2cat (
|
||||
rel_id bigint(20) NOT NULL auto_increment,
|
||||
link_id bigint(20) NOT NULL default '0',
|
||||
category_id bigint(20) NOT NULL default '0',
|
||||
PRIMARY KEY (rel_id),
|
||||
KEY link_id (link_id,category_id)
|
||||
);
|
||||
CREATE TABLE $wpdb->linkcategories (
|
||||
cat_id bigint(20) NOT NULL auto_increment,
|
||||
cat_name tinytext NOT NULL,
|
||||
|
@ -231,6 +241,7 @@ function populate_options() {
|
|||
}
|
||||
// 2.1
|
||||
add_option('blog_public', 1);
|
||||
add_option('default_link_category', 2);
|
||||
|
||||
// Delete unused options
|
||||
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
|
||||
|
|
|
@ -466,6 +466,11 @@ table .vers, table .name {
|
|||
color: #fff;
|
||||
}
|
||||
|
||||
#deletebookmarks:hover {
|
||||
background: #ce0000;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#quicktags #ed_strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
|
@ -2409,4 +2409,9 @@ function privacy_ping_filter( $sites ) {
|
|||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
function bool_from_yn($yn) {
|
||||
if ($yn == 'Y') return 1;
|
||||
return 0;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -28,21 +28,16 @@ function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />',
|
|||
$limit = -1, $show_updated = 0) {
|
||||
global $wpdb;
|
||||
$cat_id = -1;
|
||||
$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
|
||||
$results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
|
||||
if ($results) {
|
||||
foreach ($results as $result) {
|
||||
$cat_id = $result->cat_id;
|
||||
$cat_id = $result->cat_ID;
|
||||
}
|
||||
}
|
||||
get_links($cat_id, $before, $after, $between, $show_images, $orderby,
|
||||
$show_description, $show_rating, $limit, $show_updated);
|
||||
}
|
||||
|
||||
function bool_from_yn($yn) {
|
||||
if ($yn == 'Y') return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** function wp_get_linksbyname()
|
||||
** Gets the links associated with the named category.
|
||||
** Parameters:
|
||||
|
@ -51,26 +46,13 @@ function bool_from_yn($yn) {
|
|||
function wp_get_linksbyname($category, $args = '') {
|
||||
global $wpdb;
|
||||
|
||||
$cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
|
||||
. " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
|
||||
. " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_name='$category'");
|
||||
$cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1");
|
||||
|
||||
if (! $cat) {
|
||||
if (! $cat_id)
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($args)) {
|
||||
if ($cat->sort_desc == 'Y') {
|
||||
$cat->sort_order = '_'.$cat->sort_order;
|
||||
}
|
||||
get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
|
||||
$cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
|
||||
bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
|
||||
$cat->list_limit, bool_from_yn($cat->show_updated));
|
||||
} else {
|
||||
$args = add_query_arg('category', $cat->cat_id, $args);
|
||||
$args = add_query_arg('category', $cat_id, $args);
|
||||
wp_get_links($args);
|
||||
}
|
||||
} // end wp_get_linksbyname
|
||||
|
||||
/** function wp_get_links()
|
||||
|
@ -83,22 +65,14 @@ function wp_get_linksbyname($category, $args = '') {
|
|||
function wp_get_links($args = '') {
|
||||
global $wpdb;
|
||||
|
||||
if (!empty($args) && false === strpos($args, '=')) {
|
||||
// If args is not a query string, it's a category id.
|
||||
$category = $args;
|
||||
$cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
|
||||
. " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
|
||||
. " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category");
|
||||
if ($cat) {
|
||||
if ($cat->sort_desc == 'Y') {
|
||||
$cat->sort_order = '_'.$cat->sort_order;
|
||||
if ( empty($args) )
|
||||
return;
|
||||
|
||||
if ( false === strpos($args, '=') ) {
|
||||
$cat_id = $args;
|
||||
$args = add_query_arg('category', $cat_id, $args);
|
||||
}
|
||||
get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
|
||||
$cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
|
||||
bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
|
||||
$cat->list_limit, bool_from_yn($cat->show_updated));
|
||||
}
|
||||
} else {
|
||||
|
||||
parse_str($args);
|
||||
|
||||
if (! isset($category)) $category = -1;
|
||||
|
@ -114,7 +88,6 @@ function wp_get_links($args = '') {
|
|||
if (! isset($echo)) $echo = true;
|
||||
|
||||
return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
|
||||
}
|
||||
} // end wp_get_links
|
||||
|
||||
/** function get_links()
|
||||
|
@ -154,53 +127,13 @@ function get_links($category = -1,
|
|||
|
||||
global $wpdb;
|
||||
|
||||
$direction = ' ASC';
|
||||
$category_query = '';
|
||||
if ($category != -1) {
|
||||
$category_query = " AND link_category = $category ";
|
||||
}
|
||||
if (get_settings('links_recently_updated_time')) {
|
||||
$recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
|
||||
} else {
|
||||
$recently_updated_test = '';
|
||||
}
|
||||
if ($show_updated) {
|
||||
$get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
|
||||
}
|
||||
$results = get_linkz("category=$category&orderby=$orderby&show_updated=$show_updated&limit=$limit");
|
||||
|
||||
$orderby = strtolower($orderby);
|
||||
if ($orderby == '')
|
||||
$orderby = 'id';
|
||||
if (substr($orderby, 0, 1) == '_') {
|
||||
$direction = ' DESC';
|
||||
$orderby = substr($orderby, 1);
|
||||
}
|
||||
|
||||
switch($orderby) {
|
||||
case 'length':
|
||||
$length = ", CHAR_LENGTH(link_name) AS length";
|
||||
break;
|
||||
case 'rand':
|
||||
$orderby = 'rand()';
|
||||
break;
|
||||
default:
|
||||
$orderby = " link_" . $orderby;
|
||||
}
|
||||
|
||||
if (!isset($length)) {
|
||||
$length = '';
|
||||
}
|
||||
|
||||
$sql = "SELECT link_url, link_name, link_image, link_target, link_description, link_rating, link_rel $length $recently_updated_test $get_updated FROM $wpdb->links WHERE link_visible = 'Y' " . $category_query;
|
||||
$sql .= ' ORDER BY ' . $orderby . $direction;
|
||||
/* The next 2 lines implement LIMIT TO processing */
|
||||
if ($limit != -1)
|
||||
$sql .= " LIMIT $limit";
|
||||
$results = $wpdb->get_results($sql);
|
||||
if (!$results) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach ($results as $row) {
|
||||
|
@ -290,10 +223,12 @@ function get_links($category = -1,
|
|||
** echo '<li>'.$link->link_name.'</li>';
|
||||
** }
|
||||
**/
|
||||
// Deprecate in favor of get_linkz().
|
||||
function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
|
||||
global $wpdb;
|
||||
$cat_id = -1;
|
||||
$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
|
||||
//$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
|
||||
// TODO: Fix me.
|
||||
if ($results) {
|
||||
foreach ($results as $result) {
|
||||
$cat_id = $result->cat_id;
|
||||
|
@ -337,6 +272,7 @@ function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit
|
|||
** link_rel
|
||||
** link_notes
|
||||
**/
|
||||
// Deprecate in favor of get_linkz().
|
||||
function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -445,12 +381,18 @@ function get_links_withrating($category = -1, $before = '', $after = '<br />',
|
|||
** uses 0
|
||||
*/
|
||||
function get_linkcatname($id = 0) {
|
||||
global $wpdb;
|
||||
$cat_name = '';
|
||||
if ('' != $id) {
|
||||
$cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id");
|
||||
}
|
||||
return $cat_name;
|
||||
if ( empty($id) )
|
||||
return '';
|
||||
|
||||
$cats = wp_get_link_cats($id);
|
||||
|
||||
if ( empty($cats) || ! is_array($cats) )
|
||||
return '';
|
||||
|
||||
$cat_id = $cats[0]; // Take the first cat.
|
||||
|
||||
$cat = get_category($cat_id);
|
||||
return $cat->cat_name;
|
||||
}
|
||||
|
||||
/** function get_get_autotoggle()
|
||||
|
@ -459,11 +401,7 @@ function get_linkcatname($id = 0) {
|
|||
** uses 0
|
||||
*/
|
||||
function get_autotoggle($id = 0) {
|
||||
global $wpdb;
|
||||
$auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id");
|
||||
if ('' == $auto_toggle)
|
||||
$auto_toggle = 'N';
|
||||
return $auto_toggle;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** function links_popup_script()
|
||||
|
@ -511,50 +449,29 @@ function links_popup_script($text = 'Links', $width=400, $height=400,
|
|||
* hide_if_empty (default true) - Supress listing empty link categories
|
||||
*/
|
||||
function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
|
||||
global $wpdb;
|
||||
|
||||
$order = strtolower($order);
|
||||
|
||||
// Handle link category sorting
|
||||
$direction = 'ASC';
|
||||
if (substr($order,0,1) == '_') {
|
||||
$direction = ' DESC';
|
||||
$direction = 'DESC';
|
||||
$order = substr($order,1);
|
||||
}
|
||||
|
||||
// if 'name' wasn't specified, assume 'id':
|
||||
$cat_order = ('name' == $order) ? 'cat_name' : 'cat_id';
|
||||
|
||||
if (!isset($direction)) $direction = '';
|
||||
// Fetch the link category data as an array of hashesa
|
||||
$cats = $wpdb->get_results("
|
||||
SELECT DISTINCT link_category, cat_name, show_images,
|
||||
show_description, show_rating, show_updated, sort_order,
|
||||
sort_desc, list_limit
|
||||
FROM `$wpdb->links`
|
||||
LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
|
||||
WHERE link_visible = 'Y'
|
||||
AND list_limit <> 0
|
||||
ORDER BY $cat_order $direction ", ARRAY_A);
|
||||
|
||||
$cats = get_categories("type=link&orderby=$order&order=$direction");
|
||||
|
||||
// Display each category
|
||||
if ($cats) {
|
||||
foreach ($cats as $cat) {
|
||||
// Handle each category.
|
||||
// First, fix the sort_order info
|
||||
$orderby = $cat['sort_order'];
|
||||
$orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;
|
||||
|
||||
// Display the category name
|
||||
echo ' <li id="linkcat-' . $cat['link_category'] . '"><h2>' . $cat['cat_name'] . "</h2>\n\t<ul>\n";
|
||||
echo ' <li id="linkcat-' . $cat->cat_ID . '"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n";
|
||||
// Call get_links() with all the appropriate params
|
||||
get_links($cat['link_category'],
|
||||
'<li>',"</li>","\n",
|
||||
bool_from_yn($cat['show_images']),
|
||||
$orderby,
|
||||
bool_from_yn($cat['show_description']),
|
||||
bool_from_yn($cat['show_rating']),
|
||||
$cat['list_limit'],
|
||||
bool_from_yn($cat['show_updated']));
|
||||
get_links($cat->cat_ID,
|
||||
'<li>',"</li>","\n");
|
||||
|
||||
// Close the last category
|
||||
echo "\n\t</ul>\n</li>\n";
|
||||
|
@ -562,4 +479,86 @@ function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
|
|||
}
|
||||
}
|
||||
|
||||
function get_linkz($args = '') {
|
||||
global $wpdb;
|
||||
|
||||
parse_str($args, $r);
|
||||
|
||||
if ( !isset($r['orderby']) )
|
||||
$r['orderby'] = 'name';
|
||||
if ( !isset($r['order']) )
|
||||
$r['order'] = 'ASC';
|
||||
if ( !isset($r['limit']) )
|
||||
$r['limit'] = -1;
|
||||
if ( !isset($r['category']) )
|
||||
$r['category'] = -1;
|
||||
if ( !isset($r['category_name']) )
|
||||
$r['category_name'] = '';
|
||||
if ( !isset($r['hide_invisible']) )
|
||||
$r['hide_invisible'] = 1;
|
||||
if ( !isset($r['show_updated']) )
|
||||
$r['show_updated'] = 0;
|
||||
|
||||
$exclusions = '';
|
||||
if ( !empty($r['exclude']) ) {
|
||||
$exlinks = preg_split('/[\s,]+/',$r['exclude']);
|
||||
if ( count($exlinks) ) {
|
||||
foreach ( $exlinks as $exlink ) {
|
||||
$exclusions .= ' AND link_id <> ' . intval($exlink) . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extract($r);
|
||||
|
||||
if ( ! empty($category_name) ) {
|
||||
if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") )
|
||||
$category = $cat_id;
|
||||
}
|
||||
|
||||
$category_query = '';
|
||||
$join = '';
|
||||
if ( $category != -1 && !empty($category) ) {
|
||||
$join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) ";
|
||||
|
||||
$category_query = " AND category_id = $category ";
|
||||
}
|
||||
|
||||
if (get_settings('links_recently_updated_time')) {
|
||||
$recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
|
||||
} else {
|
||||
$recently_updated_test = '';
|
||||
}
|
||||
|
||||
if ($show_updated) {
|
||||
$get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
|
||||
}
|
||||
|
||||
$orderby = strtolower($r['orderby']);
|
||||
$length = '';
|
||||
switch ($orderby) {
|
||||
case 'length':
|
||||
$length = ", CHAR_LENGTH(link_name) AS length";
|
||||
break;
|
||||
case 'rand':
|
||||
$orderby = 'rand()';
|
||||
break;
|
||||
default:
|
||||
$orderby = "link_" . $orderby;
|
||||
}
|
||||
|
||||
if ( 'link_id' == $orderby )
|
||||
$orderby = "$wpdb->links.link_id";
|
||||
|
||||
$visible = '';
|
||||
if ( $hide_invisible )
|
||||
$visible = "AND link_visible = 'Y'";
|
||||
|
||||
$query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
|
||||
$query .= " ORDER BY $orderby $order";
|
||||
if ($limit != -1)
|
||||
$query .= " LIMIT $limit";
|
||||
|
||||
return $wpdb->get_results($query);
|
||||
}
|
||||
?>
|
|
@ -410,4 +410,60 @@ function in_category($category) { // Check if the current post is in the given c
|
|||
return false;
|
||||
}
|
||||
|
||||
function &get_categories($args = '') {
|
||||
global $wpdb, $category_links;
|
||||
|
||||
parse_str($args, $r);
|
||||
|
||||
if ( !isset($r['type']) ) // 'post' or 'link'
|
||||
$r['type'] = 'post';
|
||||
if ( !isset($r['child_of']) )
|
||||
$r['child_of'] = 0;
|
||||
if ( !isset($r['orderby']) )
|
||||
$r['orderby'] = 'name';
|
||||
if ( !isset($r['order']) )
|
||||
$r['order'] = 'ASC';
|
||||
if ( !isset($r['hide_empty']) )
|
||||
$r['hide_empty'] = true;
|
||||
|
||||
$r['orderby'] = "cat_" . $r['orderby'];
|
||||
|
||||
$exclusions = '';
|
||||
if ( !empty($r['exclude']) ) {
|
||||
$excategories = preg_split('/[\s,]+/',$r['exclude']);
|
||||
if ( count($excategories) ) {
|
||||
foreach ( $excategories as $excat ) {
|
||||
$exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$categories = $wpdb->get_results("SELECT * " .
|
||||
"FROM $wpdb->categories " .
|
||||
"$exclusions " .
|
||||
"ORDER BY " . $r['orderby'] . " " . $r['order']);
|
||||
|
||||
if ( empty($categories) )
|
||||
return array();
|
||||
|
||||
if ( $r['hide_empty'] ) {
|
||||
foreach ( $categories as $category ) {
|
||||
$count = 0;
|
||||
if ( 'link' == $r['type'] ) {
|
||||
$count = $category->link_count;
|
||||
} else {
|
||||
$count = $category->category_count;
|
||||
}
|
||||
if ( $count )
|
||||
$the_categories[] = $category;
|
||||
}
|
||||
$categories = $the_categories;
|
||||
}
|
||||
|
||||
/* if ( $r['child_of'] )
|
||||
$categories = & get_category_children($r['child_of'], $categories); */
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
|
||||
|
||||
$wp_version = '2.1-alpha1';
|
||||
$wp_db_version = 3548;
|
||||
$wp_db_version = 3570;
|
||||
|
||||
?>
|
|
@ -78,6 +78,7 @@ $wpdb->users = $table_prefix . 'users';
|
|||
$wpdb->categories = $table_prefix . 'categories';
|
||||
$wpdb->post2cat = $table_prefix . 'post2cat';
|
||||
$wpdb->comments = $table_prefix . 'comments';
|
||||
$wpdb->link2cat = $table_prefix . 'link2cat';
|
||||
$wpdb->links = $table_prefix . 'links';
|
||||
$wpdb->linkcategories = $table_prefix . 'linkcategories';
|
||||
$wpdb->options = $table_prefix . 'options';
|
||||
|
@ -98,6 +99,7 @@ $tableusers = $wpdb->users;
|
|||
$tablecategories = $wpdb->categories;
|
||||
$tablepost2cat = $wpdb->post2cat;
|
||||
$tablecomments = $wpdb->comments;
|
||||
$tablelink2cat = $wpdb->link2cat;
|
||||
$tablelinks = $wpdb->links;
|
||||
$tablelinkcategories = $wpdb->linkcategories;
|
||||
$tableoptions = $wpdb->options;
|
||||
|
|
Loading…
Reference in New Issue