WordPress.org

Ready to get started?Download WordPress

Forums

plugin to change blog description based on date? (18 posts)

  1. bubazoo
    Member
    Posted 7 years ago #

    Anyone know of a plugin that would allow me to change the blog description based on the day of the week? (rather its Monday, tue, wed, thurs, fri, sat or sunday)

    or could this be designed fairly easy?

    thanks

  2. Firas
    Member
    Posted 7 years ago #

    <?php
    function daydesc() {
    $daydesc['Mon'] = 'Description for Monday';
    $daydesc['Tue'] = 'Description for Tuesday';
    /* etc: just finish the $daydesc['3-letter-day'] = 'description' info */
    if(!get_option('daydesc')) {
    add_option('daydesc', date('l'));
    update_option('blogdescription', $daydesc[date('l')]);
    } else {
    $stored_day = get_option('daydesc');
    $current_day = date('l');
    if($stored_day != $current_day) {
    update_option('daydesc', $current_day);
    update_option('blogdescription', $daydesc[$current_day]);
    }
    }
    }
    add_action('init', 'daydesc')
    ?>

    Don't even know if it parses actually but look up the plugin headers on the codex, add them above the code, upload, activate and try it out.

  3. vkaryl
    Member
    Posted 7 years ago #

    Hoo.... that would make a nifty widget, firas! Could be expanded to do months, seasons, holidays - wow.... cool!

  4. bubazoo
    Member
    Posted 7 years ago #

    yeah thats what I was thinking too vkaryl

    I just had no idea how to write a plugin, how to even start for that matter, I've never done one before. I know PHP but thats about it.

  5. vkaryl
    Member
    Posted 7 years ago #

    Well, me either, but I'm twitching around with the widget thing so I guess I'll figure it out eventually. Thanks firas!

  6. Firas
    Member
    Posted 7 years ago #

    vkaryl, at your pleasure! I haven't looked into the widgets thing. They seem a bit scary. I guess I'll gather the guts to figure out what on earth they are this weekend.

  7. vkaryl
    Member
    Posted 7 years ago #

    Well, actually.... I've played around with various "self made functions", and succeeded in making viable widgets out of them. Both sidebars on P O V are run with widgets for the most part.

    So if you get stuck, email me (vkaryl_at_bytehaven_dot_com) and we'll discuss....

  8. bubazoo
    Member
    Posted 7 years ago #

    well, I don't care about widgets, as I don't have the widget system on my blog anyway (and don't care to, mainly because I'm scared that it will slow the loading time of my blog down more then it already is)

    I just wanted to know how to write a simple plugin to do it is all. with a screen in the options admin menu for it so options can be customized, which is a bit beyond my scope. I'm not a programmer by any means.

    I mean, that bit of code at the top there, I don't even know where it goes, in my theme? a new file under plugins? or what? writing plugins is beyond my scope of understanding, and you shouldn't have to be a PHP programmer to install a wordpress blog and add in some plugins is my point.

  9. vkaryl
    Member
    Posted 7 years ago #

    Widgets don't slow stuff down.... adding plugins is dirt-simple.... figuring out how to program a plugin isn't easy but do-able eventually....

    The "bit of code" goes into a file produced by a vanilla text editor like notepad2. Then you need to find the correct plugin headers (probably using codex, dunno - never looked.... maybe you can extrapolate from other plugin files), add at the top, and save as dailydesc.php.

    Upload to the plugins folder, and if you did the headers right, it should show up to be activated. Activate and see what happens.

  10. bubazoo
    Member
    Posted 7 years ago #

    I tried, and it doesn't work :(

    and yes widgets do slow things down. so do enough plugins as I'm finding out the hard way :) My blog now already takes 22 seconds to do a single page load, thats 20x slower then ordinary PHP files, and 20x slower then my simple machines forum.. alot of it is because I have like 20 plugins installed and it slows the page load time way down, to the point where I have been recieving complaints about it.. I can deal with it now, but I don't want to add a widget system for that reason, I don't want even more complaints then I'm already getting :)

  11. bubazoo
    Member
    Posted 7 years ago #

    besides, not all my plugins come with widget support. the majority of 'em don't

  12. Chris_K
    Member
    Posted 7 years ago #

    Have you tried wp-cache? Yep, another plugin, but can sure make a difference.

  13. vkaryl
    Member
    Posted 7 years ago #

    Ummmmm. I've got 43 plugins installed on my main blog. The page loads in about 7 seconds. Widgets - it's also the one with widgets.

    It's not the plugins/widgets....

  14. Firas
    Member
    Posted 7 years ago #

    bubazoo, "it doesn't work" as in, it doesn't show up under plugins, you activate it and nothing happens, something else? You filled in the $daydesc array right? This is really trivial, nothing to pull your hair out over.

  15. bubazoo
    Member
    Posted 7 years ago #

    oh I'm not pulling my hair out over it, its no big deal right now :)

    I don't know, I was thinking the problem could be with one of my plugins. I've got the lightbox2 thing installed, and that flash image viewer thingy, and I'm thinking one of those could be causing the page to load slowly. I just don't know if all my plugins will work with widgets or not and am too lazy to mess with it right now :) hehe

    as for the original question, I'll work on it more tomorrow, maybe something will come to me in my sleep. lol

    thanks

  16. vkaryl
    Member
    Posted 7 years ago #

    Ah.... well, both flash and lightbox will crap your site sometimes.

    Let us know when you get "unlazy".

  17. bubazoo
    Member
    Posted 7 years ago #

    well, it was the only way to get the sidebars to expand/colapse like that, and to move them around by user preference.

    and I just thought opening inline images up in a flash window above the blog was kinda neat :)

    anyway, I tried to put the plugin header above that code, into a .php file, along with that code below it, but I didn't know what to put in my template file?

    I tried

    <?php daydesc(); ?> but that didn't work, broke the blog. plugin activated ok, just isn't displaying anything where its supposed to. So I give up on it tonight and I'll work on it more tomorrow when I feel more like learning how to design a plugin.. since odviously I am not able to do it by myself.

  18. Firas
    Member
    Posted 7 years ago #

    Ah I see. This changes the 'blogdescription' value in the wp options table, like in your RSS feed and stuff. You can try calling that by <?php echo get_option('blogdescription'); ?>. I'm not sure whether that's the description used in the default Kubrick header? Probably is. You can modify the code to not touch your blogdescription and just output something based on day:

    <?php
    function daydesc() {
    $daydesc['Mon'] = 'Description for Monday';
    $daydesc['Tue'] = 'Description for Tuesday';
    /* etc: just finish the $daydesc['3-letter-day'] = 'description' info */
    echo $daydesc[date('l')];
    }
    ?>

    If the plugin contains just that, you can call <?php daydesc(); ?> anywhere in your template.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags