Skip to:
Content
Pages
Categories
Search
Top
Bottom

My customized version of 2.8

  • Avatar of chestnut_jp
    chestnut_jp
    Member

    @chestnut_jp

    Thank you very much for the latest version release.

    Just like the previous post of My customized version of 2.7.9.2, I customized the latest version of 2.8.

    In particular, I once again focused on “timezome” setting.

    1) “hint” will show in admin page back-end if you choose timezone from “Manual Offset”.
    2) For people, who choose timezone from “Manual Offset”, the example of time calculation for their wanted delivery time of Daily Digest is displayed.
    3) You do not need to specify timezone in admin panel or even in the script, the timezone you choose in “General Setting” is automatically selected.
    4) In the preview mode, you can see how long will it be until the next Daily Digest is sent, along with your selection of Weekly Digest.

    My customized version can be available at:
    http://staff.blog.bng.net/downloads/buddypress-group-email-subscription-2.8.zip

    I hope everyone will find the plugin useful. Any comments are welcomed.

    In order to use my customized version, just overwrite everything to the original plugin. The easiest way is unzipping the package and upload the whole folder/directory to /wp-content/plugins/ via FTP software.

    You can find the place I changed/deleted/added by searching the word “chestnut_jp” in the scripts (php files).

Viewing 8 replies - 1 through 8 (of 8 total)
  • Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    @chestnut_jp – Any chance you would consider exporting these changes (either together or separately) into svn or git style patches? They sound pretty good, and should probably go into the plugin itself. But it’s a pain for me to merge it on my own.

    Avatar of Dwenaus
    Dwenaus
    Participant

    @dwenaus

    @chestnut_jp has been incredibly helpful with other plugin fixes in the past, but honestly, I don’t understand these changes very well and don’t have the time to figure them out. The time zone issue does not seem to affect my sites. So I second boone’s suggestion.

    Avatar of chestnut_jp
    chestnut_jp
    Member

    @chestnut_jp

    Hi @boonebgorges and @dwenaus,

    Thank you for releasing 2.8.1, and for your comments.

    To begin with, please understand that I am not trying to disturbing the plugin development. I just want to make it more easy to use, tryin to help on my own way. As I have not yet tried svn and git, it currently is hard for me to make a patch.

    As for timezone, I have been saying that it is obviously an issue. As Dwenaus himeself said, however, that he has never experienced the issue, my customization regardin timezone has not yet been introduced.

    I have customized the plugin due mainly to the timezone issue.

    Please look at the following picture:
    http://photos.yahoo.co.jp/ph/cookie_tkjp/vwp2?.tok=bcPemMgBUkWH8.A5&.dir=/e49d&.dnm=5500.jpg&.src=ph&.view=t&.hires=t

    This is a screen shot taken after upgrading to 2.8.1, the latest version.
    As you can see, it says that the server timezone is UTC (UTC), though I set the timezone as Tokyo in the General Setting, which should be “JST (Asia/Tokyo)”.

    Well, you may think that this is because of my PHP setting. The answer is No.
    My php setting is surely “date_default_timezone_set(‘Asia/Tokyo’);”, which as you know is ignored by WordPress features. WordPress ignores date_default_timezone_set setting and changes it to UTC.

    Looking at line 30 of wp-settings.php, it reads:
    `
    // Set default timezone in PHP 5.
    if ( function_exists( ‘date_default_timezone_set’ ) )
    date_default_timezone_set( ‘UTC’ );
    `

    As a result, my local timezone of Tokyo is ignored and the plugin says that the server timezone is UTC.

    Subsequently, the plugin says that “the current server time is 1:18pm (13:18); and the day is Thursday, which is 9 hours behind the real local time because Tokyo/Asia timezone is UTC+9.

    In these environments, I have to calculate the time for digest delivery which is very much irritating.

    At the same time, declaration of date_default_timezone_set in the plugin also affects the buddypress site overall. Because buddypress sometimes utilize time calculation based on UTC, not on the local timezone.

    For this reason, some plugins, such as WP Events Calendar and Visitor Maps and Who’s Online, are imcompatible with buddypress, because these plugins declare date_default_timezone_set in themselves and this affects buddypress’ features, especially activities time display.

    As a result, I decided to set global setting, and it is called within each function, which does not affects other plugins neighter buddypress overall.

    Looking at bp-activity-subscription.php, you can see:
    `
    /**
    * Added by chestnut_jp starts
    */
    global $localzone;
    if (get_option(‘timezone_string’)) {
    $localzone = get_option(‘timezone_string’);
    } else {
    $localzone = ‘NO/SETTING’;
    }
    /**
    * Added by chestnut_jp ends
    */
    `
    And a function handling the time calls “global $localzone”.

    Secondly, this is also regarding time. It sometimes comfusing people on the usage of date() and time(). Since WordPress fixess timezone to UTC, date() and time() is exclusively based on UTC, not localtime zone. If wanting to calculate time and date on the basis of the user’s local timezone, date_i18n() should be used instead.

    Thus, I changed line 18 or so of bp-activity-subscription-digest.php as following:
    [ Original ]
    `
    $until = ( (int)$sched – time() ) / ( 60 * 60 );
    `
    [ Changed to ]
    `
    if ($localzone != ‘NO/SETTING’) { $lcd = date_i18n(‘U’); }
    else if ($localzone == ‘NO/SETTING’) { $lcd = time(); }
    $until = date(‘H’, (int)$sched – $lcd ).__(‘ hour(s)’,’bp-ass’).’ ‘.da
    te(‘i’, (int)$sched – $lcd ).__(‘ minute(s)’,’bp-ass’).’ ‘.date(‘s’, (int)$sch
    ed – $lcd ).__(‘ second(s)’,’bp-ass’);
    `
    Note that the my change is a little bit complicated because I wanted to show xx hours xx minues xx seconds format. Anyway, time() or date_i18n() should be chosen case by case.

    Third, some parts are not translated.

    For instance, an email is sent right after posting an update, as the group forum option is set to “All Email”. The content of email is written in Japanese, except for the part of “To view or reply, log in and got to:”.

    I am not perfectly sure, but I think this is due to the setting of the function handling this case.

    Look at the line 207 in bp-activity-subscription-functions.php. The function calls global $bp, which consequently tries to read translation from buddypress language files.

    In order to make correct translation, I add “activitysub_textdomain();” right after the line of “global $bp”.

    So, I add “activitysub_textdomain();” after each line of “global $bp”. This is very much helpful.

    Speaking of translation, the line of 434 in bp-activity-subscription-functions.php should be changed to as following, otherwise the sentence cannot be translated properly:

    `
    [ Original ]
    bp_core_add_message( __( $security.’Your email notific
    ations are set to ‘ . ass_subscribe_translate( $action ) . ‘ for this group.’,
    ‘bp-ass’ ) );

    [ Changed to ]
    bp_core_add_message( __( $security.’Your email notific
    ations are set to ‘, ‘bp-ass’ ) . ass_subscribe_translate( $action ) . __(‘ fo
    r this group.’, ‘bp-ass’ ) );
    `
    This change is also included in my customization.

    I will take some time to see the latest version, and will once again customize according to the above issues.

    I do not hope all my customization is included into the original plugin, but I hope the way of timezone setting is.

    Note: if a user set its timezone according to Manual Offsets, my customization will not work for the user. This is because timezone setting from Manual Offsets are not granted as date_default_timezone_set, so the timezone cannot be changed from UTC. For this reason, my cusomization includes “hint” for the case. But, I do not think it should be included into the original plugin.

    Thank you for readin this long sentence written in POOR english.

    Avatar of Dwenaus
    Dwenaus
    Participant

    @dwenaus

    hi @chestnut_jp, If I understand correctly, the time zone issue is more of a general wordpress issue rather than one specific to our plugin. In that case, for the benefit of yourself and others, you should look in wordpress Trac to see if someone has posted this as a bug already, and if not, to post it yourself. If you provide suggestions for a patch, that is much better. and learning svn to create diff patches is the best.

    To solve the immediate problem, we could easily insert filters where ever necessary so you can over-ride the timezone values without editing the core code. HOWEVER the code that you need changed concerning $until is in our debug code – so now i’m totally confused once again.

    Maybe you could read up about wordpress filters and actions, add see how they work, then suggest where we can put them in our plugin to make your life easier. that way each time we upgrade the plugin, you don’t need to keep making a new one.

    the other issue about activitysub_textdomain() I totally don’t understand what the issue is. I guess we can just add that code right after $bp, but I’d rather figure it out properly and fix it properly.

    I fixed the line 434 to use sprintf:
    `bp_core_add_message( sprintf( __( $security.’Your email notifications are set to %s for this group.’, ‘bp-ass’ ), ass_subscribe_translate( $action ) ) );`

    boone, any luck?

    Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    sprintf is being used wrong. It should be
    `bp_core_add_message( $security . sprintf( __( ‘Your email notifications are set to %s for this group.’, ‘bp-ass’ ), ass_subscribe_translate( $action ) ) );`

    Avatar of Dwenaus
    Dwenaus
    Participant

    @dwenaus

    looking closer at the code. $security is an empty var. how odd. it seems the nonce is disabled a few lines up. yikes!

    Avatar of chestnut_jp
    chestnut_jp
    Member

    @chestnut_jp

    Thank you for your advice, @dwenaus.

    Timezone issue is yes due to WordPress features. Because I started using WordPress from version 3.0, I do not know the process but WordPress fixes date_default_timezone_set to UTC since version 2.9 or so.

    The simple solution is just comment out the setting starting from the line 30 of wp-settings.php, and WordPress will never changes the user’s date_default_timezone_set to UTC. But, I think this solution will affect BuddyPress features.

    For this reason, some plugins sensitive to date and time, declares date_default_timezone in themselves.

    As WordPress decides to fix date_default_timezone to UTC, I currently do not think it is a bug but its design. So, I think each plugin, if it needs to handle date and time, must decides the way to timezone handling.

    This is just my own individual opinion, I hope you will understand.

    Well, I already customized 2.8.1 just in the same way, but do not put the link here because I do not want to disgust you. It is publicly open in my site and I think it will be still helpful for people, especially Japanese, facing timezone issue.

    Regarding activitysub_textdomain(), people who use English will not see the problem, because sentences never need to be translated. I think you will see what is wrong when you set the language to other than English.

    Anyway, I will continue to think about the better way for the timezone matter.

    Avatar of Dwenaus
    Dwenaus
    Participant

    @dwenaus

    you should post the wordpress bug on trac.wordpress.org.

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

You must be logged in to reply to this topic.