Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make date format filterable #1347

Closed
michaeltorbert opened this issue Nov 8, 2017 · 7 comments

Comments

Projects
None yet
3 participants
@michaeltorbert
Copy link
Member

commented Nov 8, 2017

For at least current_date, if not post_date as well: https://github.com/semperfiwebdesign/all-in-one-seo-pack/blob/master/aioseop_class.php#L2084

Either as a single filter or as multiple filters.

@michaeltorbert michaeltorbert added the API label Nov 8, 2017

@contactashish13 contactashish13 self-assigned this Nov 9, 2017

@contactashish13

This comment has been minimized.

Copy link
Contributor

commented Nov 9, 2017

@michaeltorbert I have 2 questions:

  1. Is there a reason https://github.com/semperfiwebdesign/all-in-one-seo-pack/blob/master/aioseop_class.php#L2085 uses date_i18n and https://github.com/semperfiwebdesign/all-in-one-seo-pack/blob/master/aioseop_class.php#L2087 does not?

https://codex.wordpress.org/Function_Reference/date_i18n says

If the locale specifies the locale month and weekday, then the locale will take over the format for the date. If it isn't, then the date format string will be used instead.

This means if we do

date_i18n( apply_filters('filtername', get_option( 'date_format' ) )) 

this will end up modifying format w.r.t to the format of the locale (https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/functions.php#L103)

on the other hand, get_the_date() is a lot more straightforward. So the user has to be made aware of the above fact. Alternatively, both functions have their own native filters which users can use. Suggestions?

@contactashish13

This comment has been minimized.

Copy link
Contributor

commented Nov 22, 2017

@michaeltorbert could you please review my comments and let me know how to proceed?

@michaeltorbert

This comment has been minimized.

Copy link
Member Author

commented Dec 14, 2017

@contactashish13

  1. Not that I'm aware of. Oversight?
  2. Maybe we can just filter the built-in filter? apply_filters(add_filter('date_i18n or something?
    What are your thoughts?
@contactashish13

This comment has been minimized.

Copy link
Contributor

commented Dec 15, 2017

@michaeltorbert I'd prefer to change both form to date_i18n and then add a filter for date_i18n

@michaeltorbert

This comment has been minimized.

Copy link
Member Author

commented Dec 15, 2017

Ok let's go with that. @contactashish13 You take charge of this

@contactashish13

This comment has been minimized.

Copy link
Contributor

commented Dec 15, 2017

@contactashish13 contactashish13 added this to the 2.4.4 milestone Jan 3, 2018

@wpsmort wpsmort modified the milestones: 2.4.4, 2.4.5 Jan 11, 2018

@michaeltorbert michaeltorbert modified the milestones: 2.4.5, 2.4.6 Jan 31, 2018

@wpsmort wpsmort assigned contactashish13 and unassigned wpsmort Mar 15, 2018

@michaeltorbert michaeltorbert modified the milestones: 2.4.6, 2.4.7 Mar 15, 2018

contactashish13 added a commit to contactashish13/all-in-one-seo-pack that referenced this issue Mar 16, 2018

@contactashish13 contactashish13 removed their assignment Mar 16, 2018

@wpsmort wpsmort modified the milestones: 2.4.7, 2.5 Mar 20, 2018

@contactashish13

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2018

@wpsmort you can use this

add_filter( 'aioseop_format_date', 'aioseop_format_date', 10, 3); function aioseop_format_date( $formatted_date, $date, $form ) { return $formatted_date; // or format the $date using date( 'l jS \of F Y h:i:s A', $date ); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.