Last active
March 6, 2018 11:00
-
-
Save MjHead/ce52499b041a5a1f6fc1fc965a6156a0 to your computer and use it in GitHub Desktop.
Add own callback function for meta controls in Smart List for JetBlog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add callback function for date formatting into available callbacks list in control. | |
*/ | |
function my_update_meta_controls( $widget ) { | |
foreach ( array( 'title_related', 'content_related' ) as $position ) { | |
$control = $widget->get_controls( $position . '_meta' ); | |
$control['fields'][3]['options'] = array_merge( | |
$control['fields'][3]['options'], | |
array( 'my_date_format' => 'my_date_format' ) | |
); | |
$widget->update_control( $position . '_meta', $control ); | |
} | |
} | |
add_action( | |
'elementor/element/jet-blog-smart-listing/section_custom_fields/before_section_end', | |
'my_update_meta_controls', | |
10 | |
); | |
/** | |
* Formatting date callback | |
*/ | |
function my_date_format( $timestamp ) { | |
// Change format as you need | |
$format = 'F j, Y'; | |
$date = DateTime::createFromFormat( 'Ymd', $timestamp ); | |
return $date->format( $format ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment