コード例 #1
0
 /**
  * Get translation for posts of any post type.
  *
  * @param  int  $content_id
  * @param  bool $strict
  * @return array|bool
  */
 private function get_post_translation($content_id, $strict)
 {
     $post = get_post($content_id);
     if (!$post) {
         return FALSE;
     }
     $title = get_the_title($content_id);
     $editable = current_user_can('edit_post', $content_id);
     // edit post screen
     if (is_admin()) {
         if (!$editable) {
             return FALSE;
         }
         return ['remote_title' => $title, 'remote_url' => $this->type_factory->create_url([get_edit_post_link($content_id)])];
     }
     // frontend
     do_action('mlp_before_link');
     $url = get_permalink($content_id);
     do_action('mlp_after_link');
     if ('publish' === $post->post_status || $editable) {
         return ['remote_title' => $title, 'remote_url' => $this->type_factory->create_url([$url ?: ''])];
     }
     // unpublished post, not editable
     if ($strict) {
         return FALSE;
     }
     return ['remote_title' => $title, 'remote_url' => ''];
 }
コード例 #2
0
 /**
  * Get term in backend
  *
  * @param  array  $term
  * @param  string $taxonomy
  * @return array|bool
  */
 private function get_admin_translation(array $term, $taxonomy)
 {
     if (!current_user_can('edit_terms', $taxonomy)) {
         return FALSE;
     }
     return ['remote_url' => $this->type_factory->create_url([get_edit_term_link((int) $term['term_id'], $taxonomy)]), 'remote_title' => $term['name']];
 }
 /**
  * Returns the URL to be used in the according form.
  *
  * @since 3.0.0
  *
  * @return URL URL to submit updates to.
  */
 public function url()
 {
     return $this->type_factory->create_url([admin_url('admin-post.php')]);
 }