本文整理汇总了PHP中wc_trim_string函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_trim_string函数的具体用法?PHP wc_trim_string怎么用?PHP wc_trim_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_trim_string函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_request
/**
* Get refund request args
* @param WC_Order $order
* @param float $amount
* @param string $reason
* @return array
*/
public static function get_request($order, $amount = null, $reason = '')
{
$request = array('VERSION' => '84.0', 'SIGNATURE' => self::$api_signature, 'USER' => self::$api_username, 'PWD' => self::$api_password, 'METHOD' => 'RefundTransaction', 'TRANSACTIONID' => $order->get_transaction_id(), 'NOTE' => html_entity_decode(wc_trim_string($reason, 255), ENT_NOQUOTES, 'UTF-8'), 'REFUNDTYPE' => 'Full');
if (!is_null($amount)) {
$request['AMT'] = number_format($amount, 2, '.', '');
$request['CURRENCYCODE'] = $order->get_order_currency();
$request['REFUNDTYPE'] = 'Partial';
}
return apply_filters('woocommerce_paypal_refund_request', $request, $order, $amount, $reason);
}
开发者ID:flasomm,项目名称:Montkailash,代码行数:17,代码来源:class-wc-gateway-paypal-refund.php
示例2: add_line_item
/**
* Add PayPal Line Item
* @param string $item_name
* @param integer $quantity
* @param integer $amount
* @param string $item_number
* @return bool successfully added or not
*/
protected function add_line_item($item_name, $quantity = 1, $amount = 0, $item_number = '')
{
$index = sizeof($this->line_items) / 4 + 1;
if ($amount < 0 || $index > 9) {
return false;
}
$this->line_items['item_name_' . $index] = html_entity_decode(wc_trim_string($item_name ? $item_name : __('Item', 'woocommerce'), 127), ENT_NOQUOTES, 'UTF-8');
$this->line_items['quantity_' . $index] = $quantity;
$this->line_items['amount_' . $index] = $amount;
$this->line_items['item_number_' . $index] = $item_number;
return true;
}
开发者ID:slavic18,项目名称:cats,代码行数:20,代码来源:class-wc-gateway-paypal-request.php
示例3: test_wc_trim_string
/**
* Test wc_trim_string().
*
* @since 2.2
*/
public function test_wc_trim_string()
{
$this->assertEquals('string', wc_trim_string('string'));
$this->assertEquals('s...', wc_trim_string('string', 4));
$this->assertEquals('st.', wc_trim_string('string', 3, '.'));
$this->assertEquals('string¥', wc_trim_string('string¥', 7, ''));
}
开发者ID:jimlove7273,项目名称:woocommerce,代码行数:12,代码来源:functions.php
示例4: add_line_item
/**
* Add PayPal Line Item.
* @param string $item_name
* @param int $quantity
* @param float $amount
* @param string $item_number
* @return bool successfully added or not
*/
protected function add_line_item($item_name, $quantity = 1, $amount = 0, $item_number = '')
{
$index = sizeof($this->line_items) / 4 + 1;
if ($amount < 0 || $index > 9) {
return false;
}
$item = apply_filters('woocommerce_paypal_line_item', array('item_name' => html_entity_decode(wc_trim_string($item_name ? $item_name : __('Item', 'woocommerce'), 127), ENT_NOQUOTES, 'UTF-8'), 'quantity' => (int) $quantity, 'amount' => (double) $amount, 'item_number' => $item_number), $item_name, $quantity, $amount, $item_number);
$this->line_items['item_name_' . $index] = $item['item_name'];
$this->line_items['quantity_' . $index] = $item['quantity'];
$this->line_items['amount_' . $index] = $item['amount'];
$this->line_items['item_number_' . $index] = $item['item_number'];
return true;
}
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:21,代码来源:class-wc-gateway-paypal-request.php
示例5: column_default
/**
* Print the columns information
*
* @param $review
* @param $column_name
*
* @return string
*/
public function column_default($review, $column_name)
{
switch ($column_name) {
case $this->ywar->custom_column_review:
$post = get_post($review->ID);
if (empty($post->post_title) && empty($post->post_content)) {
return;
}
$edit_link = get_edit_post_link($review->ID);
echo '<a class="row-title" href="' . $edit_link . '">';
if (!empty($post->post_title)) {
echo '<span class="review-title">' . wc_trim_string($post->post_title, 80) . '</span>';
echo "<br>";
}
if (!empty($post->post_content)) {
echo '<span class="review-content">' . wc_trim_string($post->post_content, 80) . '</span>';
}
echo '</a>';
$post_type_object = get_post_type_object($this->ywar->post_type_name);
if ('trash' == $post->post_status) {
$actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the bin') . "' href='" . $this->ywar->untrash_review_url($post) . "'>" . __('Restore') . "</a>";
} elseif (EMPTY_TRASH_DAYS) {
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__('Move this item to the bin') . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Bin') . "</a>";
}
if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this item permanently') . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete permanently') . "</a>";
}
$actions = apply_filters('yith_advanced_reviews_row_actions', $actions, $post);
echo $this->row_actions($actions);
break;
case $this->ywar->custom_column_rating:
if (0 == $review->post_parent) {
$rating = get_post_meta($review->ID, $this->ywar->meta_key_rating, true);
echo '<div class="woocommerce">
<div class="star-rating" title="' . sprintf(__("Rated %d out of 5", 'yith-woocommerce-advanced-reviews'), $rating) . '">
<span style="width:' . $rating / 5 * 100 . '%"><strong>' . $rating . '</strong>' . __("out of 5", 'yith-woocommerce-advanced-reviews') . ' </span>
</div>
</div>';
}
break;
case $this->ywar->custom_column_product:
$product_id = get_post_meta($review->ID, $this->ywar->meta_key_product_id, true);
echo get_the_title($product_id) . "<br>";
if (current_user_can('edit_post', $product_id)) {
echo "<a class='edit-product-review' href='" . get_edit_post_link($product_id) . "'>" . __("Edit", 'yith-woocommerce-advanced-reviews') . '</a>';
}
echo "<a class='view-product-review' href='" . get_permalink($product_id) . "' target='_blank'>" . __("View", 'yith-woocommerce-advanced-reviews') . '</a>';
break;
case $this->ywar->custom_column_author:
if ($review->post_author) {
$user = get_userdata($review->post_author);
$author_name = $user ? $user->display_name : __('Anonymous', 'yith-woocommerce-advanced-reviews');
} else {
$user = yit_get_post_meta($review->ID, $this->ywar->meta_key_review_author);
if ($user) {
$author_name = $user ? $user : __('Anonymous', 'yith-woocommerce-advanced-reviews');
}
}
echo $author_name;
break;
case $this->ywar->custom_column_date:
$t_time = get_the_time(__('Y/m/d g:i:s a'));
$m_time = $review->post_date;
$time = get_post_time('G', true, $review);
$time_diff = time() - $time;
if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
$h_time = sprintf(__('%s ago'), human_time_diff($time));
} else {
$h_time = mysql2date(__('Y/m/d'), $m_time);
}
echo '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
break;
default:
do_action('yith_advanced_reviews_show_advanced_reviews_columns', $column_name, $review->ID);
}
return null;
}
开发者ID:VitaliyProdan,项目名称:wp_shop,代码行数:85,代码来源:class.yith-advanced-reviews-list-table.php
示例6: add_line_item_own
public function add_line_item_own($item_name, $quantity = 1, $amount = 0, $item_number = '', $productid = 0)
{
$index = sizeof($this->line_items) / 5 + 1;
if (!$item_name || $amount < 0) {
return false;
}
$this->line_items['item_name_' . $index] = html_entity_decode(wc_trim_string($item_name, 127), ENT_NOQUOTES, 'UTF-8');
$this->line_items['quantity_' . $index] = $quantity;
$this->line_items['amount_' . $index] = $amount;
$this->line_items['item_number_' . $index] = $item_number;
$this->line_items['product_number_' . $index] = $productid;
$_SESSION['line_item'] = $this->line_items;
return true;
}
开发者ID:ujam-dev,项目名称:paypal-woocommerce,代码行数:14,代码来源:wc-gateway-paypal-express-angelleye.php
注:本文中的wc_trim_string函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论