Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

  • convictedvapour
    Participant

    @chronicbubble

    I have now come up with this code also to display the message in the profile header. I will be moving it to the file bp-default/members/single/member-header.php Ths will display it on members profile page headers. How can I do this from within a plugin without moving this file?

    The code itself:

    <div id="member_profile">
    <div id="hollysage" style="padding-bottom:10px;"></div>
    </div>

    The CSS code for the above coding:

    div#member_profile {
    margin-bottom: 15px;
    margin-top: 15px;
    }

    I want to be able to add this via my plugin.

    Thanks in advance!

    Regards,

    Gaz


    convictedvapour
    Participant

    @chronicbubble

    UPDATE:

    I have created a plugin so when I add <div id="hollysage" style="padding-bottom:10px;"></div> within my sites template it track the age and shows Holly Willoughby is 34 years 10 months and 19 days old. as text anywhere I chose to place it.

    What I need now is so it automatically post on all users activity feeds. Happy Birthday Holly. on every 10th of February regardless of the year. This date and only on this date. Any help would be appreciated! The plugin I have is housed in a folder called hollysage The following files are in there.

    Config.php

    <?php
    
    // Language file
    if (defined('WPLANG') && WPLANG == 'zh_CN')
    {
    	require_once(CURRENTDIR . '/language_cn.php');
    }
    else
    {
    	require_once(CURRENTDIR . '/language_en.php');
    }
    
    // Time Zone
    define('TIMEZONE', get_option('gmt_offset'));
    
    // Holly Willoughbys Date of birth
    $bornYear = 1981;
    $bornMonth = 2;
    $bornDay = 10;
    
    ?>

    hollysage.php

    <?php
    /*
    Plugin Name: Hollys Willoughbys Age
    Plugin URI: http://www.willoughbooby.com
    Description: Show Hollys Willoughbys in your wordpress site.
    Version: 0.1
    Author: Willoughbooby
    Author URI: http://www.willoughbooby.com
    */
    
    define('CURRENTDIR', dirname(__FILE__));
    
    // Make string
    function hollysage()
    {
        // System config
        require_once(CURRENTDIR . '/config.php');
    
        // Prepare vars
        $bornMonthLeftDays = intval(date('t', mktime(0, 0 , 0, $bornMonth, $bornDay, $bornYear))) - $bornDay;
        $bornYearLeftMonths = 12 -$bornMonth ;
    
        // Baby age
        $age_year = 0;
        $age_month = 0;
        $age_day = 0;
    
        // Output string
        $baby_age_str = "";
    
        // Process
        $today = getdate(time() + TIMEZONE * 60 * 60);
        if ($today['year'] >= $bornYear)
        {
            // 2008-8-18 or 2008-7-17 or 2008-7-18 or 2008-8-17
            if ($today['mon'] >= $bornMonth and $today['mday'] >= $bornDay)
            {
                $age_year = $today['year'] - $bornYear;
                $age_month = $today['mon'] - $bornMonth;
                $age_day = $today['mday'] - $bornDay;
            }
            // 2008-8-15 or 2008-7-15
            else if ($today['mon'] >= $bornMonth and $today['mday'] < $bornDay)
            {
                $age_day = $bornMonthLeftDays + $today['mday'];
                // 2008-8-15
                if ($today['mon'] > $bornMonth)
                {
                    $age_year = $today['year'] - $bornYear;
                    $age_month = $today['mon'] - $bornMonth - 1;
                }
                // 2008-7-15
                else if ($today['mon'] = $bornMonth)
                {
                    $age_year = $today['year'] - $bornYear - 1;
                    $age_month = 11;
                }
            }
            // 2008-6-18 or 2008-6-17
            else if ($today['mon'] < $bornMonth and $today['mday'] >= $bornDay)
            {
                $age_year = $today['year'] - $bornYear - 1;
                $age_month = $bornYearLeftMonths + $today['mon'];
                $age_day = $today['mday'] - $bornDay;
            }
            // 2008-6-15
            else if ($today['mon'] < $bornMonth and $today['mday'] < $bornDay)
            {
                $age_year = $today['year'] - $bornYear - 1;
                $age_month = $bornYearLeftMonths + $today['mon'] - 1;
                $age_day = $bornMonthLeftDays + $today['mday'];
            }
    
            if ($age_year ==0 and $age_month == 0 and $age_day == 0)
            {
                $baby_age_str = $lang['birthday'];
            }
            else
            {
                $baby_age_str = $lang['hollysage'];
                if ($age_year)
                {
                    $baby_age_str .= $age_year . $lang['yearsold'];
                }
                if ($age_month)
                {
                    $baby_age_str .= $age_month . $lang['month'];
                }
                if ($age_day)
                {
                    $baby_age_str .= $lang['and'] . $age_day . $lang['day'];
                }
                $baby_age_str .= $lang['fullstop'];
    
                if ($age_month == 0 and $age_day == 0)
                {
                    $baby_age_str .= $lang['happybirthday'];
                }
            }
    
        }
        echo "\n<script type=\"text/javascript\">\n<!--\n    document.getElementById('hollysage').innerHTML = \"<img src='wp-includes/images/smilies/icon_idea.gif' border='0'> $baby_age_str\";\n//-->\n</script>\n\n";
    }
    
    function addhollysageDiv()
    {
    	echo '<div id="hollysage" style="padding-bottom:10px;"></div>';
    }
    
    // Do it.
    add_action('before_sidebar', 'addhollysageDiv');
    add_action('wp_footer', 'hollysage');
    ?>

    language_en.php

    <?php
    
    // English language
    $lang['babyage'] = "Holly Willoughby is ";
    $lang['birthday'] = "Today is Holly Willoughbys birthday.";
    $lang['yearsold'] = " years ";
    $lang['month'] = " months ";
    $lang['day'] = " days";
    $lang['and'] = " and ";
    $lang['fullstop'] = " old.";
    $lang['happybirthday'] = "Happy Birthday Holly Willoughby.";
    
    ?>

    To use it currently I add

    <div id="hollysage" style="padding-bottom:10px;"></div>

    Can someone help me with adding a status update as detailed above at the start of this support topic request?

    Thanks!

    Regards,

    Gareth

Viewing 2 replies - 1 through 2 (of 2 total)
Skip to toolbar