← All changes
|
includes/public/shortcodes/item/class-wpupg-sc-date.php
+3
-20
4.1.1
→
3.0.0
View file →
| @@ -21,16 +21,8 @@ | ||
| 21 | 21 | public static $shortcode = 'wpupg-item-date'; |
| 22 | 22 | |
| 23 | 23 | public static function init() { |
| 24 | 24 | $atts = array( |
| 25 | - 'date' => array( | |
| 26 | - 'default' => 'published', | |
| 27 | - 'type' => 'dropdown', | |
| 28 | - 'options' => array( | |
| 29 | - 'published' => 'Published Date', | |
| 30 | - 'modified' => 'Modified Date', | |
| 31 | - ), | |
| 32 | - ), | |
| 33 | 25 | 'display' => array( |
| 34 | 26 | 'default' => 'inline', |
| 35 | 27 | 'type' => 'dropdown', |
| 36 | 28 | 'options' => 'display_options', |
| @@ -55,9 +47,9 @@ | ||
| 55 | 47 | ), |
| 56 | 48 | 'date_format' => array( |
| 57 | 49 | 'default' => 'F j, Y', |
| 58 | 50 | 'type' => 'text', |
| 59 | - 'help' => 'Use the PHP date format. Leave empty to use default WordPress date format from the Settings > General page.', | |
| 51 | + 'help' => __( 'Use the PHP date format. Leave empty to use default WordPress date format from the Settings > General page.', 'wp-ultimate-post-grid' ), | |
| 60 | 52 | ), |
| 61 | 53 | ); |
| 62 | 54 | $atts = array_merge( $atts, WPUPG_Template_Helper::get_label_container_atts() ); |
| 63 | 55 | |
| @@ -95,23 +87,14 @@ | ||
| 95 | 87 | if ( ! $format ) { |
| 96 | 88 | $format = get_option( 'date_format' ); |
| 97 | 89 | } |
| 98 | 90 | |
| 99 | - // Date to use. | |
| 100 | - switch( $atts['date'] ) { | |
| 101 | - case 'modified': | |
| 102 | - $date = $item->date_modified(); | |
| 103 | - break; | |
| 104 | - default: | |
| 105 | - $date = $item->date(); | |
| 106 | - } | |
| 91 | + $date = date( $format, strtotime( $item->date() ) ); | |
| 107 | 92 | |
| 108 | - $formatted_date = date_i18n( $format, strtotime( $date ) ); | |
| 109 | - | |
| 110 | 93 | $label_container = WPUPG_Template_Helper::get_label_container( $atts, 'date' ); |
| 111 | 94 | $tag = 'block' === $atts['display'] ? 'div' : 'span'; |
| 112 | - $output = '<' . esc_attr( $tag ) . ' class="' . esc_attr( implode( ' ', $classes ) ) . '">' . $label_container . $formatted_date . '</' . esc_attr( $tag ) . '>'; | |
| 95 | + $output = '<' . $tag . ' class="' . implode( ' ', $classes ) . '">' . $label_container . $date . '</' . $tag . '>'; | |
| 113 | 96 | return apply_filters( parent::get_hook(), $output, $atts, $item ); |
| 114 | 97 | } |
| 115 | 98 | } |
| 116 | 99 | |
| 117 | 100 | WPUPG_SC_Date::init(); |