Home › Forums › Calendar Products › Events Calendar PRO › Deprecated 4.4 $daysOfWeekShort / shows months instead of days
- This topic has 4 replies, 4 voices, and was last updated 7 years, 3 months ago by Mister.
-
AuthorPosts
-
January 10, 2017 at 1:48 pm #1216140MisterParticipant
Hi,
In a custom template file I use the following code to get weekdays with short name:
$days_of_week = tribe_events_get_days_of_week( 'short' );
Since 4.4 update it doesn’t show days anymore, but a full list of 12 months?! Changing it to (‘min’) shows weekdays again, but only with one letter, which is not what I want.
I tried to check to origin in the plugin code, it is tribe_events_get_days_of_week(), which is in src/functions/template-tags/general.php (Line: 695)
This function refers to Tribe__Events__Main::instance()->daysOfWeekShort; and when I take a look into the plugin’s Main.php I see at line 194 and following:
/** * @deprecated 4.4 */ public $daysOfWeekShort; /** * @deprecated 4.4 */ public $daysOfWeek; /** * @deprecated 4.4 */ public $daysOfWeekMin;
If those are all deprecated, why do you use them still in the general.php?
And how can I fix the above one to get back the short names for weekdays?January 10, 2017 at 10:13 pm #1216370MisterParticipantJust to add some clarification:
Please take a template, e.g. “single-event.php” and copy it to the theme to customize
Then add the following code to see the result of print_r:
<?php print_r(tribe_events_get_days_of_week( 'min' )); // will print Array ( [1] => M [2] => T [3] => W [4] => T [5] => F [6] => S [0] => S ) print_r(tribe_events_get_days_of_week( 'short' )); // will print Array ( [Jan] => Jan [Feb] => Feb [Mar] => Mar [Apr] => Apr [May] => May [Jun] => Jun [Jul] => Jul [Aug] => Aug [Sep] => Sep [Oct] => Oct [Nov] => Nov [Dec] => Dec [0] => ) ?>
As you can see the second statement returns months. This seems definitely a bug since 4.4, because before the update it was working.
Can you please fix asap?
January 11, 2017 at 12:25 pm #1216842JoshParticipantHey Martin,
Thanks for reaching out to us! I apologize for the issues here with the latest update of our plugin.
Looking at the code, you should be able to continue using that function even though the underlying way it is generating the output will be deprecated. There will be a new way of addressing that particular element that will then flow into the “tribe_events_get_days_of_week(‘min’)” function that you’re currently using.
However, it does look like there is an issue with the function being called there that we will need to address at least as a temporary fix.
For now, if you change in the core file, src > Tribe > Main.php on line #2177 the:
$this->daysOfWeekShort = Tribe__Date_Utils::get_localized_months_short();
to
$this->daysOfWeekShort = Tribe__Date_Utils::get_localized_weekdays_short();
This should address the regular usage of that function.
Let me know if this gets it working for you
Thanks!
February 2, 2017 at 8:35 am #1228225Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Deprecated 4.4 $daysOfWeekShort / shows months instead of days’ is closed to new replies.