本文整理汇总了PHP中wc_time_format函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_time_format函数的具体用法?PHP wc_time_format怎么用?PHP wc_time_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_time_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_checkout_time_to_booking_end_time
public function add_checkout_time_to_booking_end_time($date, $booking)
{
$product = wc_get_product($booking->product_id);
if (empty($product) || 'accommodation-booking' !== $product->product_type) {
return $date;
}
$check_out = get_option('woocommerce_accommodation_bookings_check_out', '');
$date_format = apply_filters('woocommerce_bookings_date_format', wc_date_format());
$time_format = apply_filters('woocommerce_bookings_time_format', ', ' . wc_time_format());
return date_i18n($date_format, $booking->end) . date_i18n($time_format, strtotime("Today " . $check_out));
}
开发者ID:solaceten,项目名称:woocommerce-accommodation-bookings,代码行数:11,代码来源:class-wc-accommodation-booking.php
示例2: woocommerce_time_format
/**
* @deprecated
*/
function woocommerce_time_format()
{
return wc_time_format();
}
示例3: esc_html
<code>…<?php
echo esc_html($key_data['truncated_key']);
?>
</code>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<?php
_e('Last access', 'woocommerce');
?>
</th>
<td class="forminp">
<span><?php
if (!empty($key_data['last_access'])) {
$date = sprintf(_x('%1$s at %2$s', 'date and time', 'woocommerce'), date_i18n(wc_date_format(), strtotime($key_data['last_access'])), date_i18n(wc_time_format(), strtotime($key_data['last_access'])));
echo apply_filters('woocommerce_api_key_last_access_datetime', $date, $key_data['last_access']);
} else {
_e('Unknown', 'woocommerce');
}
?>
</span>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
示例4: esc_html
* @since 1.0
* @param string $profile_identifier See https://github.com/opauth/opauth/wiki/Opauth-configuration - Strategy
*/
echo esc_html(apply_filters('wc_social_login_profile_identifier', $profile->has_email() ? $profile->get_email() : $profile->get_nickname()));
?>
</td>
<td data-title="<?php
esc_attr_e('Last login', 'woocommerce-social-login');
?>
">
<?php
if ($login_timestamp) {
?>
<?php
/* translators: Placeholders: %1$s - date, %2$s - time */
printf(esc_html__('%1$s @ %2$s', 'woocommerce-social-login'), date_i18n(wc_date_format(), $login_timestamp), date_i18n(wc_time_format(), $login_timestamp));
?>
<?php
} else {
?>
<?php
esc_html_e('Never', 'woocommerce-social-login');
?>
<?php
}
?>
</td>
<td class="profile-actions">
<a href="<?php
echo esc_url($provider->get_auth_url($return_url, 'unlink'));
?>
示例5: create_keys
/**
* Create keys.
*
* @since 2.4.0
*
* @param string $app_name
* @param string $app_user_id
* @param string $scope
*
* @return array
*/
protected function create_keys($app_name, $app_user_id, $scope)
{
global $wpdb;
$description = sprintf(__('%s - API %s (created on %s at %s).', 'woocommerce'), wc_clean($app_name), $this->get_i18n_scope($scope), date_i18n(wc_date_format()), date_i18n(wc_time_format()));
$user = wp_get_current_user();
// Created API keys.
$permissions = in_array($scope, array('read', 'write', 'read_write')) ? sanitize_text_field($scope) : 'read';
$consumer_key = 'ck_' . wc_rand_hash();
$consumer_secret = 'cs_' . wc_rand_hash();
$wpdb->insert($wpdb->prefix . 'woocommerce_api_keys', array('user_id' => $user->ID, 'description' => $description, 'permissions' => $permissions, 'consumer_key' => wc_api_hash($consumer_key), 'consumer_secret' => $consumer_secret, 'truncated_key' => substr($consumer_key, -7)), array('%d', '%s', '%s', '%s', '%s', '%s'));
return array('key_id' => $wpdb->insert_id, 'user_id' => $app_user_id, 'consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'key_permissions' => $permissions);
}
示例6: test_wc_time_format
/**
* Test wc_time_format().
*
* @since 2.2
*/
public function test_wc_time_format()
{
$this->assertEquals(get_option('time_format'), wc_time_format());
}
示例7: column_last_access
/**
* Return last access column.
*
* @param array $key
* @return string
*/
public function column_last_access($key)
{
if (!empty($key['last_access'])) {
/* translators: 1: last access date 2: last access time */
$date = sprintf(__('%1$s at %2$s', 'woocommerce'), date_i18n(wc_date_format(), strtotime($key['last_access'])), date_i18n(wc_time_format(), strtotime($key['last_access'])));
return apply_filters('woocommerce_api_key_last_access_datetime', $date, $key['last_access']);
}
return __('Unknown', 'woocommerce');
}
示例8: strtotime
<td style="border-top: 0;">
<?php
$timestamp_gmt = strtotime($order->post->post_date_gmt);
if ($timestamp_gmt > 0) {
// translators: php date format
$t_time = get_the_time(_x('Y/m/d g:i:s A', 'post date', 'woocommerce-subscriptions'), $post);
$time_diff = $timestamp_gmt - current_time('timestamp', true);
if ($time_diff > 0 && $time_diff < WEEK_IN_SECONDS) {
// translators: placeholder is human time difference (e.g. "3 weeks")
$date_to_display = sprintf(_x('In %s', 'used in "Related Orders" as the date when the related order happened in relation to now. Date is in the future.', 'woocommerce-subscriptions'), human_time_diff(current_time('timestamp', true), $timestamp_gmt));
} elseif ($time_diff < 0 && absint($time_diff) < WEEK_IN_SECONDS) {
// translators: placeholder is human time difference (e.g. "3 weeks")
$date_to_display = sprintf(_x('%s ago', 'used in "Related Orders" as the date when the related order happened in relation to now. Date is in the past.', 'woocommerce-subscriptions'), human_time_diff(current_time('timestamp', true), $timestamp_gmt));
} else {
$timestamp_site = strtotime(get_date_from_gmt(date('Y-m-d H:i:s', $timestamp_gmt)));
$date_to_display = date_i18n(wc_date_format(), $timestamp_site) . ' ' . date_i18n(wc_time_format(), $timestamp_site);
}
} else {
$t_time = $date_to_display = __('Unpublished', 'woocommerce-subscriptions');
}
?>
<abbr title="<?php
echo esc_attr($t_time);
?>
">
<?php
echo esc_html(apply_filters('post_date_column_time', $date_to_display, $order->post));
?>
</abbr>
</td>
<td style="border-top: 0;">
示例9: meta_box_save
public function meta_box_save($post_id)
{
if (!isset($_POST['wc_bookings_details_meta_box_nonce']) || !wp_verify_nonce($_POST['wc_bookings_details_meta_box_nonce'], 'wc_bookings_details_meta_box')) {
return $post_id;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
if (!in_array($_POST['post_type'], $this->post_types)) {
return $post_id;
}
global $wpdb, $post;
// Save simple fields
$booking_order_id = absint($_POST['_booking_order_id']);
$booking_status = wc_clean($_POST['_booking_status']);
$customer_id = absint($_POST['_booking_customer_id']);
$product_id = wc_clean($_POST['product_or_resource_id']);
$parent_id = absint($_POST['_booking_parent_id']);
$all_day = isset($_POST['_booking_all_day']) ? '1' : '0';
// Update post_parent and status via query to prevent endless loops
$wpdb->update($wpdb->posts, array('post_parent' => $booking_order_id), array('ID' => $post_id));
$wpdb->update($wpdb->posts, array('post_status' => $booking_status), array('ID' => $post_id));
// Trigger actions manually
$old_status = $post->post_status;
do_action('woocommerce_booking_' . $booking_status, $post_id);
do_action('woocommerce_booking_' . $old_status . '_to_' . $booking_status, $post_id);
clean_post_cache($post_id);
// Note in the order
if ($booking_order_id && function_exists('wc_get_order') && ($order = wc_get_order($booking_order_id))) {
$order->add_order_note(sprintf(__('Booking #%d status changed manually from "%s" to "%s', 'woocommerce-bookings'), $post_id, $old_status, $booking_status));
}
// Save product and resource
if (strstr($product_id, '=>')) {
list($product_id, $resource_id) = explode('=>', $product_id);
} else {
$resource_id = 0;
}
update_post_meta($post_id, '_booking_resource_id', $resource_id);
update_post_meta($post_id, '_booking_product_id', $product_id);
// Update meta
update_post_meta($post_id, '_booking_customer_id', $customer_id);
update_post_meta($post_id, '_booking_parent_id', $parent_id);
update_post_meta($post_id, '_booking_all_day', $all_day);
// Persons
$saved_persons = get_post_meta($post_id, '_booking_persons', true);
$product = wc_get_product($product_id);
$person_types = $product->get_person_types();
if (!empty($person_types) && is_array($person_types)) {
$booking_persons = array();
foreach ($person_types as $person_type) {
if (!empty($_POST['_booking_person_' . $person_type->ID])) {
$booking_persons[$person_type->ID] = absint($_POST['_booking_person_' . $person_type->ID]);
}
}
update_post_meta($post_id, '_booking_persons', $booking_persons);
} else {
if (empty($person_types) && !empty($saved_persons) && is_array($saved_persons)) {
$booking_persons = array();
foreach (array_keys($saved_persons) as $person_id) {
$booking_persons[$person_id] = absint($_POST['_booking_person_' . $person_id]);
}
update_post_meta($post_id, '_booking_persons', $booking_persons);
}
}
// Update date
if (empty($_POST['booking_date'])) {
$date = current_time('timestamp');
} else {
$date = strtotime($_POST['booking_date'] . ' ' . (int) $_POST['booking_date_hour'] . ':' . (int) $_POST['booking_date_minute'] . ':00');
}
$date = date_i18n('Y-m-d H:i:s', $date);
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_date = %s, post_date_gmt = %s WHERE ID = %s", $date, get_gmt_from_date($date), $post_id));
// Do date and time magic and save them in one field
$start_date = explode('-', wc_clean($_POST['booking_start_date']));
$end_date = explode('-', wc_clean($_POST['booking_end_date']));
$start_time = explode(':', wc_clean($_POST['booking_start_time']));
$end_time = explode(':', wc_clean($_POST['booking_end_time']));
$start = mktime($start_time[0], $start_time[1], 0, $start_date[1], $start_date[2], $start_date[0]);
$end = mktime($end_time[0], $end_time[1], 0, $end_date[1], $end_date[2], $end_date[0]);
update_post_meta($post_id, '_booking_start', date('YmdHis', $start));
update_post_meta($post_id, '_booking_end', date('YmdHis', $end));
if ($order && $booking_order_id) {
// Update order metas
foreach ($order->get_items() as $item_id => $item) {
if ('line_item' != $item['type'] || !in_array($product_id, $item['item_meta']['_product_id'])) {
continue;
}
$product = wc_get_product($product_id);
$is_all_day = isset($_POST['_booking_all_day']) && $_POST['_booking_all_day'] == 'yes';
// Update date
if (metadata_exists('order_item', $item_id, __('Booking Date', 'woocommerce-bookings'))) {
$date = mktime(0, 0, 0, $start_date[1], $start_date[2], $start_date[0]);
wc_update_order_item_meta($item_id, __('Booking Date', 'woocommerce-bookings'), date_i18n(wc_date_format(), $date));
}
// Update time
if (!$is_all_day) {
if (metadata_exists('order_item', $item_id, __('Booking Time', 'woocommerce-bookings'))) {
$time = mktime($start_time[0], $start_time[1], 0, $start_date[1], $start_date[2], $start_date[0]);
wc_update_order_item_meta($item_id, __('Booking Time', 'woocommerce-bookings'), date_i18n(wc_time_format(), $time));
}
//.........这里部分代码省略.........
示例10: format_order_note
/**
* Formats order note
*
* @since 1.0
* @param string $to number SMS message was sent to
* @param int $sent_timestamp integer timestamp for when message was sent
* @param string $message SMS message sent
* @param string $status order status
* @param bool $error true if there was an error sending SMS, false otherwise
* @return string HTML-formatted order note
*/
private function format_order_note($to, $sent_timestamp, $message, $status, $error)
{
try {
// get datetime object from unix timestamp
$datetime = new DateTime("@{$sent_timestamp}", new DateTimeZone('UTC'));
// change timezone to site timezone
$datetime->setTimezone(new DateTimeZone(wc_timezone_string()));
// return datetime localized to site date/time settings
$formatted_datetime = date_i18n(wc_date_format() . ' ' . wc_time_format(), $sent_timestamp + $datetime->getOffset());
} catch (Exception $e) {
// log error and set datetime for SMS to 'N/A'
wc_twilio_sms()->log($e->getMessage());
$formatted_datetime = __('N/A', WC_Twilio_SMS::TEXT_DOMAIN);
}
ob_start();
?>
<p><strong><?php
_e('SMS Notification', WC_Twilio_SMS::TEXT_DOMAIN);
?>
</strong></p>
<p><strong><?php
_e('To', WC_Twilio_SMS::TEXT_DOMAIN);
?>
: </strong><?php
echo esc_html($to);
?>
</p>
<p><strong><?php
_e('Date Sent', WC_Twilio_SMS::TEXT_DOMAIN);
?>
: </strong><?php
echo esc_html($formatted_datetime);
?>
</p>
<p><strong><?php
_e('Message', WC_Twilio_SMS::TEXT_DOMAIN);
?>
: </strong><?php
echo esc_html($message);
?>
</p>
<p><strong><?php
_e('Status', WC_Twilio_SMS::TEXT_DOMAIN);
?>
: <span style="<?php
echo $error ? 'color: red;' : 'color: green;';
?>
"><?php
echo esc_html($status);
?>
</span></strong></p>
<?php
return ob_get_clean();
}
示例11: printf
<li rel="<?php
echo $note->ID;
?>
" class="note">
<div class="note_content">
<p><?php
echo $note->description;
?>
</p>
</div>
<p class="meta">
<abbr class="exact-date" title="<?php
echo $note->note_date;
?>
"><?php
printf(__('added on %1$s at %2$s', 'woocommerce'), date_i18n(wc_date_format(), strtotime($note->note_date)), date_i18n(wc_time_format(), strtotime($note->note_date)));
?>
</abbr>
</p>
</li>
<?php
}
?>
<?php
} else {
?>
<li><?php
_e('There are no notes yet.', 'woocommerce');
?>
</li>
<?php
示例12: absint
echo absint($note->comment_ID);
?>
" class="<?php
echo implode(' ', array_map('sanitize_html_class', $note_classes));
?>
">
<div class="note-content">
<?php
/* translators: Placeholders represent membership plan name and a note. Example "Gold: Membership cancelled" */
echo wpautop(sprintf(__('%s: %s', WC_Memberships::TEXT_DOMAIN), wp_kses_post($plan_name), wptexturize(wp_kses_post($note->comment_content))));
?>
</div>
<p class="meta">
<abbr class="exact-date" title="<?php
echo esc_attr($note->comment_date);
?>
"><?php
printf(esc_html__('On %1$s at %2$s', WC_Memberships::TEXT_DOMAIN), date_i18n(wc_date_format(), strtotime($note->comment_date)), date_i18n(wc_time_format(), strtotime($note->comment_date)));
?>
</abbr>
<?php
if ($note->comment_author !== __('WooCommerce', WC_Memberships::TEXT_DOMAIN)) {
printf(' ' . esc_html__('by %s', WC_Memberships::TEXT_DOMAIN), $note->comment_author);
}
?>
</p>
</li>
示例13: wc_time_format
/**
* Compatibility for the woocommerce_time_format() function which is soft-deprecated in 2.1+
*
* @since 2.0
* @return string time format
*/
public static function wc_time_format()
{
return self::is_wc_version_gte_2_1() ? wc_time_format() : woocommerce_time_format();
}
示例14: output_notes
public function output_notes($post)
{
global $post, $wpdb;
$sql = "SELECT * FROM {$wpdb->comments} as comments\n\t\t\t\tLEFT JOIN {$wpdb->commentmeta} as commentmeta ON(comments.comment_ID = commentmeta.comment_id AND commentmeta.meta_key = 'comment_post_ID')\n\t\t\t\tWHERE (comment_post_ID = 0 AND commentmeta.meta_value = {$post->ID}) OR comment_post_ID = {$post->ID}";
$notes = $wpdb->get_results($sql);
echo '<ul class="order_notes">';
if ($notes) {
foreach ($notes as $note) {
$note_classes = get_comment_meta($note->comment_ID, 'is_customer_note', true) ? array('customer-note', 'note') : array('note');
?>
<li rel="<?php
echo absint($note->comment_ID);
?>
" class="<?php
echo implode(' ', $note_classes);
?>
">
<div class="note_content">
<?php
echo wpautop(wptexturize(wp_kses_post($note->comment_content)));
?>
</div>
<p class="meta">
<abbr class="exact-date" title="<?php
echo $note->comment_date;
?>
"><?php
printf(__('added on %1$s at %2$s', 'woocommerce'), date_i18n(wc_date_format(), strtotime($note->comment_date)), date_i18n(wc_time_format(), strtotime($note->comment_date)));
?>
</abbr>
<?php
if ($note->comment_author !== __('WooCommerce', 'woocommerce')) {
printf(' ' . __('by %s', 'woocommerce'), $note->comment_author);
}
?>
<a href="#" class="delete_note"><?php
_e('Delete note', 'woocommerce');
?>
</a>
</p>
</li>
<?php
}
} else {
echo '<li>' . __('There are no notes yet.', 'woocommerce') . '</li>';
}
echo '</ul>';
?>
<div class="add_note">
<h4><?php
_e('Add note', 'woocommerce');
?>
</h4>
<p>
<textarea type="text" name="order_note" id="add_order_note" class="input-text" cols="20" rows="5"></textarea>
</p>
<p>
<select name="order_note_type" id="order_note_type" style="display: none;">
<option value=""><?php
_e('Private note', 'woocommerce');
?>
</option>
</select>
<a href="#" class="add_account_note button"><?php
_e('Add', 'woocommerce');
?>
</a>
</p>
</div>
<?php
}
示例15: _e
</td>
</tr>
<tr>
<td data-export-label="Next Export"><?php
_e('Next Export', 'woocommerce-customer-order-csv-export');
?>
:</td>
<td class="help"><?php
echo SV_WC_Plugin_Compatibility::wc_help_tip(__('The automatic export start interval in minutes.', 'woocommerce-customer-order-csv-export'));
?>
</td>
<td>
<?php
if ($scheduled_timestamp = wp_next_scheduled('wc_customer_order_csv_export_auto_export_orders')) {
$scheduled_desc = sprintf(__('Scheduled on %s', 'woocommerce-customer-order-csv-export'), get_date_from_gmt(date('Y-m-d H:i:s', $scheduled_timestamp), wc_date_format() . ' ' . wc_time_format()));
} else {
$scheduled_desc = sprintf(__('%1$sNot scheduled%2$s', 'woocommerce-customer-order-csv-export'), '<mark class="error">', '</mark>');
}
echo $scheduled_desc;
?>
</td>
</tr>
<tr>
<td data-export-label="Order Statuses"><?php
_e('Order Statuses', 'woocommerce-customer-order-csv-export');
?>
:</td>
<td class="help"><?php
echo SV_WC_Plugin_Compatibility::wc_help_tip(__('The order statuses to be included in the automatic export.', 'woocommerce-customer-order-csv-export'));