link-categories.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 463 行 · 第 1/2 页
PHP
463 行
<?php// Links// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.comrequire_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': { check_admin_referer('add-link-category'); 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)"); wp_redirect('link-categories.php'); break; } // end addcat case 'Delete': { $cat_id = (int) $_GET['cat_id']; check_admin_referer('delete-link-category_' . $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'"); wp_redirect('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"> <?php wp_nonce_field('update-link-category_' . $row->cat_id) ?> <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,'double')?>" /></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,'double')?>" /></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,'double')?>"/></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": { $cat_id = (int)$_POST["cat_id"]; check_admin_referer('update-link-category_' . $cat_id); if ( !current_user_can('manage_links') ) die (__("Cheatin' uh ?")); $submit=$_POST["submit"]; if (isset($submit)) { $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"];
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?