viewing source for "fancy-archives.php"

last commit

commit 7780b7260c3088044dd3a52b28f15424a4e9f7e2 Author: root <root@a04a6e75-5819-0410-a511-8dafea38c924> Date: Thu Feb 8 00:05:13 2007 +0000
Added option to display pages with posts Modified everything to newest version number

source code

001: <?php
002: /*
003: Plugin Name: Fancy Archives
004: Plugin URI: http://nymb.us/projects/show/213
005: Description: Replacement function for displaying fancy archives that use javascript for collapsable year links
006: Author: Andrew Rader
007: Version: 0.5
008: Author URI: http://nymb.us
009: 
010: Copyright 2006 Andrew Rader
011: 
012: This file is part of Fancy Archives
013: 
014:     Fancy Archives 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 Archives 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 Archives; 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('fanarc','get_head'));
030: add_action('activate_fancy-archives/fancy-archives.php', array('fanarc','fancy_init'));
031: add_action('admin_menu', array('fanarc','fancy_setup'));
032: 
033: class fanarc {
034: 
035: 	function fancy_init() {
036: 		if( function_exists('add_option') ) {
037: 			add_option( 'fancyarc-expandcurrentyear', 'no' );
038: 			add_option( 'fancyarc-yearcount', 'no' );
039: 			add_option( 'fancyarc-showmonths', 'yes' );
040: 			add_option( 'fancyarc-monthcount', 'no' );
041: 			add_option( 'fancyarc-expandmonths', 'no' );
042: 			add_option( 'fancyarc-commentcount', 'no' );
043:             add_option( 'fancyarc-showpages', 'no' );
044: 			add_option( 'fancyarc-posttitle', 'no' );
045: 			add_option( 'fancyarc-posttitle-length', '0' );
046: 			add_option( 'fancyarc-posttitle-ellipsis', 'yes' );
047: 			add_option( 'fancyarc-postdate', 'no' );
048: 			add_option( 'fancyarc-postdateformat', '' );
049: 			add_option( 'fancyarc-postnumber', 'no' );
050: 		}
051: 	}
052: 
053: 	function fancy_setup() {
054: 		if( function_exists('add_options_page') ) {
055: 			add_options_page(__('Fancy Archives'),__('Fancy Archives'),1,basename(__FILE__),array('fanarc','fancy_ui'));
056: 		}
057: 	}
058: 
059: 	function fancy_ui() {
060: 		include_once( 'fancy-archives-ui.php' );
061: 	}
062: 
063: 	function list_archives() {
064: 		global $wpdb;
065: 
066: 		include( 'fancy-archives-list.php' );
067: 
068: 		return;
069: 	}
070: 
071: 	function get_head() {
072: 		$url = get_settings('siteurl');
073: 		echo "<script type=\"text/javascript\" src=\"$url/wp-content/plugins/fancy-archives/fancy-archives.js\"></script>\n";
074: 		echo "<script type=\"text/javascript\">\n";
075: 		echo "// <![CDATA[\n";
076: 		echo "// These variables are part of the Fancy Archives Plugin\n// Copyright 2006 Andrew Rader (nymb.us)\n";
077: 		echo "fancyarch_exp_curr_year = ";
078: 		if( fanarc::get_expand_current_year() ) {
079: 			echo "true";
080: 		}
081: 		else {
082: 			echo "false";
083: 		}
084: 		echo ";\nfancyarch_exp_curr_month = ";
085: 		if( fanarc::get_expand_current_month() ) {
086: 			echo "true";
087: 		}
088: 		else {
089: 			echo "false";
090: 		}
091: 		echo ";\n// ]]>\n</script>\n";
092: 	}
093: 
094: 	function enable_expand_current_year() {
095: 		update_option( 'fancyarc-expandcurrentyear', 'yes' );
096: 	}
097: 
098: 	function disable_expand_current_year() {
099: 		update_option( 'fancyarc-expandcurrentyear', 'no' );
100: 	}
101: 
102: 	function get_expand_current_year() {
103: 		return get_option( 'fancyarc-expandcurrentyear' ) == 'yes';
104: 	}
105: 
106: 	function enable_expand_current_month() {
107: 		update_option( 'fancyarc-expandcurrentmonth', 'yes' );
108: 	}
109: 
110: 	function disable_expand_current_month() {
111: 		update_option( 'fancyarc-expandcurrentmonth', 'no' );
112: 	}
113: 
114: 	function get_expand_current_month() {
115: 		return get_option( 'fancyarc-expandcurrentmonth' ) == 'yes';
116: 	}
117: 
118: 	function enable_show_year_count() {
119: 		update_option( 'fancyarc-yearcount', 'yes' );
120: 	}
121: 
122: 	function disable_show_year_count() {
123: 		update_option( 'fancyarc-yearcount', 'no' );
124: 	}
125: 
126: 	function get_show_year_count() {
127: 		return get_option( 'fancyarc-yearcount' ) == 'yes';
128: 	}
129: 
130: 	function enable_show_months() {
131: 		update_option( 'fancyarc-showmonths', 'yes' );
132: 	}
133: 	function disable_show_months() {
134: 		update_option( 'fancyarc-showmonths', 'no' );
135: 	}
136: 
137: 	function get_show_months() {
138: 		return get_option( 'fancyarc-showmonths' ) == 'yes';
139: 	}
140: 
141: 	function enable_show_month_count() {
142: 		update_option( 'fancyarc-monthcount', 'yes' );
143: 	}
144: 
145: 	function disable_show_month_count() {
146: 		update_option( 'fancyarc-monthcount', 'no' );
147: 	}
148: 
149: 	function get_show_month_count() {
150: 		return get_option( 'fancyarc-monthcount' ) == 'yes';
151: 	}
152: 
153: 	function enable_expand_months() {
154: 		update_option( 'fancyarc-expandmonths', 'yes' );
155: 	}
156: 
157: 	function disable_expand_months() {
158: 		update_option( 'fancyarc-expandmonths', 'no' );
159: 	}
160: 
161: 	function get_expand_months() {
162: 		return get_option( 'fancyarc-expandmonths' ) == 'yes';
163: 	}
164: 
165: 	function enable_show_comment_count() {
166: 		update_option( 'fancyarc-commentcount', 'yes' );
167: 	}
168: 
169: 	function disable_show_comment_count() {
170: 		update_option( 'fancyarc-commentcount', 'no' );
171: 	}
172: 
173: 	function get_show_comment_count() {
174: 		return get_option( 'fancyarc-commentcount' ) == 'yes';
175: 	}
176: 
177:     function enable_show_pages() {
178:         update_option( 'fancyarc-showpages', 'yes' );
179:     }
180: 
181:     function disable_show_pages() {
182:         update_option( 'fancyarc-showpages', 'no' );
183:     }
184: 
185:     function get_show_pages() {
186:         return get_option( 'fancyarc-showpages' ) == 'yes';
187:     }
188: 
189: 	function enable_show_post_title() {
190: 		update_option( 'fancyarc-posttitle', 'yes' );
191: 	}
192: 
193: 	function disable_show_post_title() {
194: 		update_option( 'fancyarc-posttitle', 'no' );
195: 	}
196: 
197: 	function get_show_post_title() {
198: 		return get_option( 'fancyarc-posttitle' ) == 'yes';
199: 	}
200: 
201: 	function set_post_title_length($length) {
202: 		update_option( 'fancyarc-posttitle-length', $length );
203: 	}
204: 
205: 	function get_post_title_length() {
206: 		return get_option( 'fancyarc-posttitle-length' );
207: 	}
208: 
209: 	function enable_show_post_title_ellipsis() {
210: 		update_option( 'fancyarc-posttitle-ellipsis', 'yes' );
211: 	}
212: 
213: 	function disable_show_post_title_ellipsis() {
214: 		update_option( 'fancyarc-posttitle-ellipsis', 'no' );
215: 	}
216: 
217: 	function get_show_post_title_ellipsis() {
218: 		return get_option( 'fancyarc-posttitle-ellipsis' ) == 'yes';
219: 	}
220: 
221: 	function enable_show_post_date() {
222: 		update_option( 'fancyarc-postdate', 'yes' );
223: 	}
224: 
225: 	function disable_show_post_date() {
226: 		update_option( 'fancyarc-postdate', 'no' );
227: 	}
228: 	
229: 	function get_show_post_date() {
230: 		return get_option( 'fancyarc-postdate' ) == 'yes';
231: 	}
232: 
233: 	function set_post_date_format( $format ) {
234: 		update_option( 'fancyarc-postdateformat', $format );
235: 	}
236: 
237: 	function get_post_date_format() {
238: 		return get_option( 'fancyarc-postdateformat' );
239: 	}
240: 
241: 	function enable_show_post_number() {
242: 		update_option( 'fancyarc-postnumber', 'yes' );
243: 	}
244: 
245: 	function disable_show_post_number() {
246: 		update_option( 'fancyarc-postnumber', 'no' );
247: 	}
248: 
249: 	function get_show_post_number() {
250: 		return get_option( 'fancyarc-postnumber' ) == 'yes';
251: 	}
252: }
253: 
254: function list_fancy_archives() {
255: 	fanarc::list_archives();
256: }
257: ?>