/**
  * Add action links to Stream drop row in admin list screen
  *
  * @filter wp_stream_action_links_{connector}
  *
  * @param array  $links  Previous links registered
  * @param Record $record Stream record
  *
  * @return array Action links
  */
 public function action_links($links, $record)
 {
     if ($record->object_id && 'deleted' !== $record->action && ($term = get_term_by('term_taxonomy_id', $record->object_id, $record->context))) {
         if (!is_wp_error($term)) {
             $tax_obj = get_taxonomy($term->taxonomy);
             $tax_label = isset($tax_obj->labels->singular_name) ? $tax_obj->labels->singular_name : null;
             if (function_exists('wp_get_split_term')) {
                 $term_id = wp_get_split_term($term->term_id, $term->taxonomy);
             }
             $term_id = empty($term_id) ? $term->term_id : $term_id;
             $links[sprintf(_x('Edit %s', 'Term singular name', 'stream'), $tax_label)] = get_edit_term_link($term_id, $term->taxonomy);
             $links[esc_html__('View', 'stream')] = wp_stream_is_vip() ? \wpcom_vip_get_term_link($term_id, $term->taxonomy) : get_term_link($term_id, $term->taxonomy);
         }
     }
     return $links;
 }
 /**
  * Log Order minor status changes ( pending / on-hold / failed / processing / completed / refunded / cancelled )
  *
  * @action woocommerce_order_status_changed
  *
  * @param int $order_id
  * @param string $old
  * @param string $new
  */
 public function callback_woocommerce_order_status_changed($order_id, $old, $new)
 {
     // Don't track customer actions
     if (!is_admin()) {
         return;
     }
     $old_status = wp_stream_is_vip() ? wpcom_vip_get_term_by('slug', $old, 'shop_order_status') : get_term_by('slug', $old, 'shop_order_status');
     $new_status = wp_stream_is_vip() ? wpcom_vip_get_term_by('slug', $new, 'shop_order_status') : get_term_by('slug', $new, 'shop_order_status');
     // Don't track new statuses
     if (!$old_status) {
         return;
     }
     $message = esc_html_x('%1$s status changed from %2$s to %3$s', '1. Order title, 2. Old status, 3. New status', 'stream');
     $order = new \WC_Order($order_id);
     $order_title = esc_html__('Order number', 'stream') . ' ' . esc_html($order->get_order_number());
     $order_type_name = esc_html__('order', 'stream');
     $new_status_name = strtolower($new_status->name);
     $old_status_name = strtolower($old_status->name);
     $this->log($message, array('post_title' => $order_title, 'old_status_name' => $old_status_name, 'new_status_name' => $new_status_name, 'singular_name' => $order_type_name, 'new_status' => $new, 'old_status' => $old, 'revision_id' => null), $order_id, 'shop_order', $new_status_name);
 }
예제 #3
0
 /**
  * Delete user meta in a way that is also safe for VIP
  *
  * @param int $user_id
  * @param string $meta_key
  * @param mixed $meta_value (optional)
  *
  * @return bool
  */
 function delete_user_meta($user_id, $meta_key, $meta_value = '')
 {
     if (wp_stream_is_vip() && function_exists('delete_user_attribute')) {
         return delete_user_attribute($user_id, $meta_key, $meta_value);
     }
     return delete_user_meta($user_id, $meta_key, $meta_value);
 }