Ejemplo n.º 1
0
 /**
  * edit_image()
  *
  * @return void
  **/
 function edit_image()
 {
     if (!is_dir(WP_CONTENT_DIR . '/authors') && !wp_mkdir_p(WP_CONTENT_DIR . '/authors')) {
         echo '<div class="error">' . '<p>' . sprintf(__('Author Images requires that your %s folder be writable by the server', 'sem-author-image'), 'wp-content') . '</p>' . '</div>' . "\n";
         return;
     } elseif (!is_writable(WP_CONTENT_DIR . '/authors')) {
         echo '<div class="error">' . '<p>' . sprintf(__('Author Images requires that your %s folder be writable by the server', 'sem-author-image'), 'wp-content/authors') . '</p>' . '</div>' . "\n";
         return;
     }
     echo '<h3>' . __('Author Image', 'sem-author-image') . '</h3>';
     global $profileuser;
     $author_id = $profileuser->ID;
     $author_image = author_image::get_meta($author_id);
     $author_image_url = content_url() . '/authors/' . str_replace(' ', rawurlencode(' '), $author_image);
     echo '<table class="form-table">';
     if ($author_image) {
         echo '<tr valign="top">' . '<td colspan="2">' . '<img src="' . esc_url($author_image_url) . '" alt="" />' . '<br />' . "\n";
         if (is_writable(WP_CONTENT_DIR . '/authors/' . $author_image)) {
             echo '<label for="delete_author_image">' . '<input type="checkbox"' . ' id="delete_author_image" name="delete_author_image"' . ' />' . '&nbsp;' . __('Delete author image', 'sem-author-image') . '</label>';
         } else {
             echo __('This author image is not writable by the server.', 'sem-author-image');
         }
         echo '</td></tr>' . "\n";
     }
     if (!$author_image || is_writable(WP_CONTENT_DIR . '/authors/' . $author_image)) {
         echo '<tr valign-"top">' . '<th scope="row">' . __('New Image', 'sem-author-image') . '</th>' . '<td>';
         echo '<input type="file"' . ' id="author_image" name="author_image"' . ' />' . ' ';
         if (defined('GLOB_BRACE')) {
             echo __('(jpg, jpeg or png)', 'sem-author-image') . "\n";
         } else {
             echo __('(jpg)', 'sem-author-image') . "\n";
         }
         echo '</td>' . '</tr>' . "\n";
     }
     echo '<tr>' . '<th><label for="sem_aboutme_page">About Me Page</label></th>' . '<td>' . '<input type="text" name="sem_aboutme_page" id="sem_aboutme_page" value="' . esc_attr(get_the_author_meta('sem_aboutme_page', $author_id)) . '" class="regular-text" /><br />' . '<span class="description">Please enter an alternate About Me page for the image' . "'s url.</span>" . '</td>' . '</tr>';
     echo '</table>' . "\n";
 }
 /**
  * get_author_image_url()
  *
  * @param int $author_id
  * @return string $image
  */
 static function get_author_image_url($author_id = null)
 {
     if (!$author_id) {
         $author_id = author_image::get_author_id();
         if (!$author_id) {
             return "";
         }
     }
     $author_image = get_user_meta($author_id, 'author_image', true);
     if ($author_image === '' || $author_image == '0') {
         $author_image = author_image::get_meta($author_id);
     }
     if (!$author_image) {
         return "";
     }
     $author_image = content_url() . '/authors/' . str_replace(' ', rawurlencode(' '), $author_image);
     return $author_image;
 }