viewing source for "fancy-categories.php"
last commit
commit 2023770d4aea75baa7dd033df9b6402e134da37b
Date: Wed Dec 12 18:28:18 2007 +0000
source code
001: <?php
002: /*
003: Plugin Name: Fancy Categories
004: Plugin URI: http://voidsplat.org/code/wordpress/fancy-categories/
005: Description: Replacement function for displaying fancy categories that use javascript for collapsable categories
006: Author: Andrew Rader
007: Version: 0.3
008: Author URI: http://voidsplat.org
009:
010: Copyright 2007 Andrew Rader
011:
012: This file is part of Fancy Categories
013:
014: Fancy Categories is free software; you can redistribute it and/or modify
015: it under the terms of the GNU General Public License as published by
016: the Free Software Foundation; either version 2 of the License, or
017: (at your option) any later version.
018:
019: Fancy Categories is distributed in the hope that it will be useful,
020: but WITHOUT ANY WARRANTY; without even the implied warranty of
021: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
022: GNU General Public License for more details.
023:
024: You should have received a copy of the GNU General Public License
025: along with Fancy Categories; if not, write to the Free Software
026: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
027: */
028:
029: add_action( 'wp_head', array('fancat','get_head'));
030: add_action('activate_fancy-categories/fancy-categories.php', array('fancat','fancy_init'));
031: add_action('admin_menu', array('fancat','fancy_setup'));
032: //add_action('init', array('fancat','js_vars'));
033:
034: class fancat {
035:
036: function fancy_init() {
037: if( function_exists('add_option') ) {
038: add_option( 'fancycat-showpostcount', 'yes' );
039: add_option( 'fancycat-showcounttotal', 'yes' );
040: add_option( 'fancycat-poststring', '%title' );
041: add_option( 'fancycat-titlesize', '0' );
042: add_option( 'fancycat-showellipsis', 'yes' );
043: }
044: }
045:
046: function fancy_setup() {
047: if( function_exists('add_options_page') ) {
048: add_options_page(__('Fancy Categories'),__('Fancy Categories'),1,basename(__FILE__),array('fancat','fancy_ui'));
049: }
050: }
051:
052: function fancy_ui() {
053: include_once( 'fancy-categories-ui.php' );
054: }
055:
056: function list_categories() {
057: global $wpdb;
058:
059: include( 'fancy-categories-list.php' );
060:
061: return;
062: }
063:
064: function get_head() {
065: $url = get_settings('siteurl');
066: echo "<script type=\"text/javascript\" src=\"$url/wp-content/plugins/fancy-categories/fancy-categories.js\"></script>\n";
067: //echo "<script type=\"text/javascript\" src=\"$url/?fancatvars\"></script>\n";
068: }
069:
070: function js_vars() {
071: if( isset( $_GET['fancatvars'] ) ) {
072: header( 'Content-type: application/x-javascript' );
073: echo "// These variables are part of the Fancy Categories Plugin\n";
074: echo "// Copyright 2007 Andrew Rader (nymb.us)\n";
075: exit;
076: }
077: }
078:
079: function set_show_post_count( $yesno ) {
080: if( $yesno ) {
081: update_option( 'fancycat-showpostcount', 'yes' );
082: }
083: else {
084: update_option( 'fancycat-showpostcount', 'no' );
085: }
086: }
087:
088: function get_show_post_count() {
089: return get_option( 'fancycat-showpostcount' ) == 'yes';
090: }
091:
092: function set_show_count_total($yesno) {
093: if( $yesno ) {
094: update_option( 'fancycat-showcounttotal', 'yes' );
095: }
096: else {
097: update_option( 'fancycat-showcounttotal', 'no' );
098: }
099: }
100:
101: function get_show_count_total() {
102: return get_option( 'fancycat-showcounttotal' ) == 'yes';
103: }
104:
105: function set_post_string( $string ) {
106: update_option( 'fancycat-poststring', $string );
107: }
108:
109: function get_post_string() {
110: return get_option( 'fancycat-poststring' );
111: }
112:
113: function set_title_size( $size ) {
114: update_option( 'fancycat-titlesize', $size );
115: }
116:
117: function get_title_size() {
118: return get_option( 'fancycat-titlesize' );
119: }
120:
121: function set_show_ellipsis( $yesno ) {
122: if( $yesno ) {
123: update_option( 'fancycat-showellipsis', 'yes' );
124: }
125: else {
126: update_option( 'fancycat-showellipsis', 'no' );
127: }
128: }
129:
130: function get_show_ellipsis() {
131: return get_option( 'fancycat-showellipsis' ) == 'yes';
132: }
133: }
134:
135: function list_fancy_categories() {
136: fancat::list_categories();
137: }
138: ?>