コード例 #1
0
 /**
  * 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 (in_array($record->context, $this->post_types) && get_post($record->object_id)) {
         if ($link = get_edit_post_link($record->object_id)) {
             $posts_connector = new Connector_Posts();
             $post_type_name = $posts_connector->get_post_type_name(get_post_type($record->object_id));
             $links[sprintf(esc_html_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[esc_html__('View', 'stream')] = $link;
         }
     }
     $context_labels = $this->get_context_labels();
     $option_key = $record->get_meta('option', true);
     $option_page = $record->get_meta('page', true);
     $option_tab = $record->get_meta('tab', true);
     $option_section = $record->get_meta('section', true);
     if ($option_key && $option_tab) {
         $text = sprintf(esc_html__('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;
 }
コード例 #2
0
 /**
  * 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)
 {
     // Options
     if ($option = $record->get_meta('option', true)) {
         $key = $record->get_meta('option_key', true);
         $links[esc_html__('Edit', 'stream')] = add_query_arg(array('page' => $record->context), admin_url('admin.php')) . '#stream-highlight-' . esc_attr($key);
     } elseif ('wpseo_files' === $record->context) {
         $links[esc_html__('Edit', 'stream')] = add_query_arg(array('page' => $record->context), admin_url('admin.php'));
     } elseif ('wpseo_meta' === $record->context) {
         $post = get_post($record->object_id);
         if ($post) {
             $posts_connector = new Connector_Posts();
             $post_type_name = $posts_connector->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', 'stream')] = $view_link;
                 }
                 if ($revision_id = $record->get_meta('revision_id', true)) {
                     $links[esc_html__('Revision', 'stream')] = get_edit_post_link($revision_id);
                 }
             }
         }
     }
     return $links;
 }
コード例 #3
0
 /**
  * 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 function check_meta_values($type, $action, $meta_id, $object_id, $key, $value = null)
 {
     unset($action);
     unset($meta_id);
     if (empty($this->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 (1 !== preg_match('#([a-z0-9_-]+)_([\\d]+)_([a-z0-9_-]+)#', $key, $matches)) {
             return false;
         }
         list(, $taxonomy, $term_id, $key) = $matches;
         // Skips 0 index
         $object_key = $taxonomy . '_' . $term_id;
     }
     if (isset($this->cached_field_values_updates[$object_key][$key])) {
         if ('post' === $type) {
             $posts_connector = new Connector_Posts();
             $post = get_post($object_id);
             $title = $post->post_title;
             $type_name = strtolower($posts_connector->get_post_type_name($post->post_type));
         } elseif ('user' === $type) {
             $user = new \WP_User($object_id);
             $title = $user->get('display_name');
             $type_name = esc_html__('user', 'stream');
         } elseif ('taxonomy' === $type && isset($term_id) && isset($taxonomy)) {
             $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 = $this->cached_field_values_updates[$object_key][$key];
         $this->log(esc_html_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;
 }
コード例 #4
0
 /**
  * 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 function action_links($links, $record)
 {
     if (in_array($record->context, array('downloads'))) {
         $posts_connector = new Connector_Posts();
         $links = $posts_connector->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(esc_html__('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(esc_html__('Deactivate %s', 'stream'), $post_type_label)] = add_query_arg(array('edd-action' => 'deactivate_discount', 'discount' => $record->object_id), $base);
         } else {
             $links[sprintf(esc_html__('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(esc_html__('Edit %s', 'stream'), $tax_label)] = get_edit_term_link($record->object_id, $record->get_meta('taxonomy', true));
     } elseif ('api_keys' === $record->context) {
         $user = new \WP_User($record->object_id);
         if (apply_filters('edd_api_log_requests', true)) {
             $links[esc_html__('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[esc_html__('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[esc_html__('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;
 }