diff --git a/fape.module b/fape.module
index e2f8cd0..1d84f0f 100644
--- a/fape.module
+++ b/fape.module
@@ -355,32 +355,27 @@ function fape_panels_pane_content_alter($content, $pane, $args, $context) {
   }
 
   if ($pane->type == 'entity_field') {
+    $entity =_fape_extract_entity_from_context($pane, $context);
     list($entity_type, $field_name) = explode(':', $pane->subtype);
-
-    // Extract the entity from the context.
-    $plugin = ctools_get_content_type($pane->type);
-    $pane_context = ctools_content_select_context($plugin, $pane->subtype, $pane->configuration, $context);
-
-    list($id, $vid, $bundle) = entity_extract_ids($entity_type, $pane_context->data);
-    if (entity_access('update', $entity_type, $pane_context->data) &&
-        field_access('edit', $field_name, $entity_type, $pane_context->data)) {
-      $content->admin_links[] = array(
-        'title' => t('Edit field'),
-        'alt' => t("Edit the data in this field."),
-        'href' => "admin/field/edit/$entity_type/$id/$field_name",
-        'query' => drupal_get_destination(),
-      );
+    if (entity_access('update', $entity_type, $entity)) {
+      $field = field_info_field($field_name);
+      if (field_access('edit', $field, $entity_type, $entity)) {
+        list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+        $content->admin_links[] = array(
+          'title' => t('Edit field'),
+          'alt' => t("Edit the data in this field."),
+          'href' => "admin/field/edit/$entity_type/$id/$field_name",
+          'query' => drupal_get_destination(),
+        );
+      }
     }
   }
 
   // We also support the node title field specifically.
-  if ($pane->type == 'node_title') {
-    $plugin = ctools_get_content_type($pane->type);
-    $pane_context = ctools_content_select_context($plugin, $pane->subtype, $pane->configuration, $context);
-
-    $nid = $pane_context->data->nid;
-
-    if (node_access('update', $pane_context->data)) {
+  else if ($pane->type == 'node_title') {
+    $entity =_fape_extract_entity_from_context($pane, $context);
+    $nid = $entity->nid;
+    if (node_access('update', $entity)) {
       $content->admin_links[] = array(
         'title' => t('Edit field'),
         'alt' => t("Edit the data in this field."),
@@ -389,6 +384,13 @@ function fape_panels_pane_content_alter($content, $pane, $args, $context) {
       );
     }
   }
-
 }
 
+/**
+ * Extract the entity from the context
+ */
+function _fape_extract_entity_from_context($pane, $context) {
+  $plugin = ctools_get_content_type($pane->type);
+  $pane_context = ctools_content_select_context($plugin, $pane->subtype, $pane->configuration, $context);
+  return $pane_context->data;
+}
