/**
  * Add action links to Stream drop row in admin list screen
  *
  * @filter wp_stream_action_links_{connector}
  *
  * @param  array  $links     Previous links registered
  * @param  object $record    Stream record
  *
  * @return array             Action links
  */
 public static function action_links($links, $record)
 {
     if (in_array($record->context, self::$post_types) && get_post($record->object_id)) {
         if ($link = get_edit_post_link($record->object_id)) {
             $post_type_name = WP_Stream_Connector_Posts::get_post_type_name(get_post_type($record->object_id));
             $links[sprintf(_x('Edit %s', 'Post type singular name', 'stream'), $post_type_name)] = $link;
         }
         if (post_type_exists(get_post_type($record->object_id)) && ($link = get_permalink($record->object_id))) {
             $links[__('View', 'stream')] = $link;
         }
     }
     $context_labels = self::get_context_labels();
     $option_key = wp_stream_get_meta($record, 'option', true);
     $option_page = wp_stream_get_meta($record, 'page', true);
     $option_tab = wp_stream_get_meta($record, 'tab', true);
     $option_section = wp_stream_get_meta($record, 'section', true);
     if ($option_key && $option_tab) {
         $text = sprintf(__('Edit WooCommerce %s', 'stream'), $context_labels[$record->context]);
         $url = add_query_arg(array('page' => $option_page, 'tab' => $option_tab, 'section' => $option_section), admin_url('admin.php'));
         $links[$text] = $url . '#wp-stream-highlight:' . $option_key;
     }
     return $links;
 }
 /**
  * Add action links to Stream drop row in admin list screen
  *
  * @filter wp_stream_action_links_{connector}
  *
  * @param  array  $links     Previous links registered
  * @param  object $record    Stream record
  *
  * @return array             Action links
  */
 public static function action_links($links, $record)
 {
     $contexts = self::get_context_labels();
     // Options
     if ($option = wp_stream_get_meta($record, 'option', true)) {
         $key = wp_stream_get_meta($record, 'option_key', true);
         $links[__('Edit', 'default')] = add_query_arg(array('page' => $record->context), admin_url('admin.php')) . '#stream-highlight-' . esc_attr($key);
     } elseif ('wpseo_files' === $record->context) {
         $links[__('Edit', 'default')] = add_query_arg(array('page' => $record->context), admin_url('admin.php'));
     } elseif ('wpseo_meta' === $record->context) {
         $post = get_post($record->object_id);
         if ($post) {
             $post_type_name = WP_Stream_Connector_Posts::get_post_type_name(get_post_type($post->ID));
             if ('trash' === $post->post_status) {
                 $untrash = wp_nonce_url(add_query_arg(array('action' => 'untrash', 'post' => $post->ID), admin_url('post.php')), sprintf('untrash-post_%d', $post->ID));
                 $delete = wp_nonce_url(add_query_arg(array('action' => 'delete', 'post' => $post->ID), admin_url('post.php')), sprintf('delete-post_%d', $post->ID));
                 $links[sprintf(esc_html_x('Restore %s', 'Post type singular name', 'stream'), $post_type_name)] = $untrash;
                 $links[sprintf(esc_html_x('Delete %s Permenantly', 'Post type singular name', 'stream'), $post_type_name)] = $delete;
             } else {
                 $links[sprintf(esc_html_x('Edit %s', 'Post type singular name', 'stream'), $post_type_name)] = get_edit_post_link($post->ID);
                 if ($view_link = get_permalink($post->ID)) {
                     $links[esc_html__('View', 'default')] = $view_link;
                 }
                 if ($revision_id = wp_stream_get_meta($record, 'revision_id', true)) {
                     $links[esc_html__('Revision', 'default')] = get_edit_post_link($revision_id);
                 }
             }
         }
     }
     return $links;
 }
 /**
  * Track changes to ACF values within rendered post meta forms
  *
  * @param string     $type      Type of object, post or user
  * @param string     $action    Added, updated, deleted
  * @param integer    $meta_id
  * @param integer    $object_id
  * @param string     $key
  * @param mixed|null $value
  *
  * @return bool
  */
 public static function check_meta_values($type, $action, $meta_id, $object_id, $key, $value = null)
 {
     if (empty(self::$cached_field_values_updates)) {
         return false;
     }
     $object_key = $object_id;
     if ('user' === $type) {
         $object_key = 'user_' . $object_id;
     } elseif ('taxonomy' === $type) {
         if (0 === strpos($key, '_')) {
             // Ignore the 'revision' stuff!
             return false;
         }
         if (preg_match('#([a-z0-9_-]+)_([\\d]+)_([a-z0-9_-]+)#', $key, $matches) !== 1) {
             return false;
         }
         list(, $taxonomy, $term_id, $key) = $matches;
         // Skips 0 index
         $object_key = $taxonomy . '_' . $term_id;
     }
     if (isset(self::$cached_field_values_updates[$object_key][$key])) {
         if ('post' === $type) {
             $post = get_post($object_id);
             $title = $post->post_title;
             $type_name = strtolower(WP_Stream_Connector_Posts::get_post_type_name($post->post_type));
         } elseif ('user' === $type) {
             $user = new WP_User($object_id);
             $title = $user->get('display_name');
             $type_name = __('user', 'stream');
         } elseif ('taxonomy' === $type) {
             $term = get_term($term_id, $taxonomy);
             $title = $term->name;
             $tax_obj = get_taxonomy($taxonomy);
             $type_name = strtolower(get_taxonomy_labels($tax_obj)->singular_name);
         } else {
             return false;
         }
         $cache = self::$cached_field_values_updates[$object_key][$key];
         self::log(_x('"%1$s" of "%2$s" %3$s updated', 'acf', 'stream'), array('field_label' => $cache['field']['label'], 'title' => $title, 'singular_name' => $type_name, 'meta_value' => $value, 'meta_key' => $key, 'meta_type' => $type), $object_id, 'values', 'updated');
     }
     return true;
 }
 /**
  * Add action links to Stream drop row in admin list screen
  *
  * @filter wp_stream_action_links_{connector}
  *
  * @param  array  $links     Previous links registered
  * @param  object $record    Stream record
  *
  * @return array             Action links
  */
 public static function action_links($links, $record)
 {
     if (in_array($record->context, array('downloads'))) {
         $links = WP_Stream_Connector_Posts::action_links($links, $record);
     } elseif (in_array($record->context, array('discounts'))) {
         $post_type_label = get_post_type_labels(get_post_type_object('edd_discount'))->singular_name;
         $base = admin_url('edit.php?post_type=download&page=edd-discounts');
         $links[sprintf(__('Edit %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'edit_discount', 'discount' => $record->object_id), $base);
         if ('active' === get_post($record->object_id)->post_status) {
             $links[sprintf(__('Deactivate %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'deactivate_discount', 'discount' => $record->object_id), $base);
         } else {
             $links[sprintf(__('Activate %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'activate_discount', 'discount' => $record->object_id), $base);
         }
     } elseif (in_array($record->context, array('download_category', 'download_tag'))) {
         $tax_label = get_taxonomy_labels(get_taxonomy($record->context))->singular_name;
         $links[sprintf(__('Edit %s', 'stream'), $tax_label)] = get_edit_term_link($record->object_id, wp_stream_get_meta($record, 'taxonomy', true));
     } elseif ('api_keys' === $record->context) {
         $user = new WP_User($record->object_id);
         if (apply_filters('edd_api_log_requests', true)) {
             $links[__('View API Log', 'stream')] = add_query_arg(array('view' => 'api_requests', 'post_type' => 'download', 'page' => 'edd-reports', 'tab' => 'logs', 's' => $user->user_email), 'edit.php');
         }
         $links[__('Revoke', 'stream')] = add_query_arg(array('post_type' => 'download', 'user_id' => $record->object_id, 'edd_action' => 'process_api_key', 'edd_api_process' => 'revoke'), 'edit.php');
         $links[__('Reissue', 'stream')] = add_query_arg(array('post_type' => 'download', 'user_id' => $record->object_id, 'edd_action' => 'process_api_key', 'edd_api_process' => 'regenerate'), 'edit.php');
     }
     return $links;
 }