daily gadgets, computers, and electronic news
21/04
2005

CA-Weekday

Sponsored Links

[php]< ?php
/*
Plugin Name: CA-Weekday
Plugin URI: http://www.funponsel.com/blog/archives/2005/04/21/ca-weekday/
Description: Display custom weekday name
Version: 0.1
Author: Cosa Aranda
Author URI: http://www.funponsel.com/blog/
*/

$dayhint = array(
'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday',
);

if (is_plugin_page()) :
ca_weekday_option();
else :

// Admin interface

function ca_weekday_add_option() {
add_options_page('Custom Weekday Options', 'Custom Weekday', 8, __FILE__);
$options = array(
'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday',
);
add_option('ca_weekday', $options, 'Options for Custom Weekday by Cosa Aranda');
} //end ca_weekday_add_option

function ca_weekday($before='',$after='',$tipe=0,$print=true,$current=null) {
if (is_null($current)) {
//$current = get_the_time('U');
ob_start();
switch ($tipe) {
case 0: //current date
$day = date('j');
$month = date('n');
$year = date('Y');
break;
case 1: //post
$day = get_the_time('j');
$month = get_the_time('n');
$year = get_the_time('Y');
break;
case 2: //comment date
$day = comment_date('j');
$month = comment_date('n');
$year = comment_date('Y');
break;
}
$current = mktime(0,0,0,$month,$day,$year)+1;
ob_end_clean();
} else {
$current++;
}
$options = get_option('ca_weekday');
$h = date("w",$current);
$hh = $options[$h];
$hh = $before . $hh . $after;
if ($print) echo $hh;
else return($hh);
} //end ca_weekday

function ca_weekday_option() {
global $dayhint;

if ( isset($_POST['submitted']) ) {
$options = array();
$options[] = $_POST['weekday0'];
$options[] = $_POST['weekday1'];
$options[] = $_POST['weekday2'];
$options[] = $_POST['weekday3'];
$options[] = $_POST['weekday4'];
$options[] = $_POST['weekday5'];
$options[] = $_POST['weekday6'];
update_option('ca_weekday', $options);
echo '

Plugin settings saved.

‘;
}

$options = get_option(’ca_weekday’);
$action_url = $_SERVER[PHP_SELF] . ‘?page=’ . basename(__FILE__);
echo < <

\n

Custom Weekday Options

\n

Custom Weekday is a plugin that allows you to define custom weekday name. Use the form below to modify the weekday name to fit your personal preferance.

This plugin can be used anywhere on the page, like this:

ca_weekday('(',')',0,TRUE);

An example above will display custom weekday for today inside ‘(’ and ‘)’ character. More information about the syntax can be found here.


Custom Weekday
$dayhint[0] :
$dayhint[1] :
$dayhint[2] :
$dayhint[3] :
$dayhint[4] :
$dayhint[5] :
$dayhint[6] :

END;
} //end ca_weekday_option()

add_action(’admin_menu’, ‘ca_weekday_add_option’);

endif; // end if is_plugin_page()

?>[/php]

Pages: 1 2

CA-Weekday is written by cosa and posted under Programming, WordPress , , . If you like it, you might consider subscribing to our feed or receive our latest posts via email. Or else, you could also bookmark it to your favourite social bookmark sites. Further information about this article can be found .

2 Comments (leave yours)

  1. 1

    [...] Visit [...]

  2. 2

    [...] other people’s plugins, I did create my own plugins as well. For example: CA-Weton, CA-Weekday, CA-Credits, and [...]

Leave a comment