• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_attachment_fields_to_edit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_attachment_fields_to_edit函数的典型用法代码示例。如果您正苦于以下问题:PHP get_attachment_fields_to_edit函数的具体用法?PHP get_attachment_fields_to_edit怎么用?PHP get_attachment_fields_to_edit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_attachment_fields_to_edit函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get_media_item

/**
 * Retrieve HTML form for modifying the image attachment.
 *
 * @since 2.5.0
 *
 * @param int $attachment_id Attachment ID for modification.
 * @param string|array $args Optional. Override defaults.
 * @return string HTML form for attachment.
 */
function get_media_item($attachment_id, $args = null)
{
    global $redir_tab;
    if (($attachment_id = intval($attachment_id)) && ($thumb_url = wp_get_attachment_image_src($attachment_id, 'thumbnail', true))) {
        $thumb_url = $thumb_url[0];
    } else {
        $thumb_url = false;
    }
    $post = get_post($attachment_id);
    $current_post_id = !empty($_GET['post_id']) ? (int) $_GET['post_id'] : 0;
    $default_args = array('errors' => null, 'send' => $current_post_id ? post_type_supports(get_post_type($current_post_id), 'editor') : true, 'delete' => true, 'toggle' => true, 'show_title' => true);
    $args = wp_parse_args($args, $default_args);
    /**
     * Filter the arguments used to retrieve an image for the edit image form.
     *
     * @since 3.1.0
     *
     * @see get_media_item
     *
     * @param array $args An array of arguments.
     */
    $r = apply_filters('get_media_item_args', $args);
    $toggle_on = __('Show');
    $toggle_off = __('Hide');
    $filename = esc_html(wp_basename($post->guid));
    $title = esc_attr($post->post_title);
    $post_mime_types = get_post_mime_types();
    $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
    $type = array_shift($keys);
    $type_html = "<input type='hidden' id='type-of-{$attachment_id}' value='" . esc_attr($type) . "' />";
    $form_fields = get_attachment_fields_to_edit($post, $r['errors']);
    if ($r['toggle']) {
        $class = empty($r['errors']) ? 'startclosed' : 'startopen';
        $toggle_links = "\n\t<a class='toggle describe-toggle-on' href='#'>{$toggle_on}</a>\n\t<a class='toggle describe-toggle-off' href='#'>{$toggle_off}</a>";
    } else {
        $class = '';
        $toggle_links = '';
    }
    $display_title = !empty($title) ? $title : $filename;
    // $title shouldn't ever be empty, but just in case
    $display_title = $r['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt($display_title, 60, '&hellip;') . "</span></div>" : '';
    $gallery = isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab'] || isset($redir_tab) && 'gallery' == $redir_tab;
    $order = '';
    foreach ($form_fields as $key => $val) {
        if ('menu_order' == $key) {
            if ($gallery) {
                $order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[{$attachment_id}][menu_order]' name='attachments[{$attachment_id}][menu_order]' value='" . esc_attr($val['value']) . "' /></div>";
            } else {
                $order = "<input type='hidden' name='attachments[{$attachment_id}][menu_order]' value='" . esc_attr($val['value']) . "' />";
            }
            unset($form_fields['menu_order']);
            break;
        }
    }
    $media_dims = '';
    $meta = wp_get_attachment_metadata($post->ID);
    if (isset($meta['width'], $meta['height'])) {
        $media_dims .= "<span id='media-dims-{$post->ID}'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
    }
    /**
     * Filter the media metadata.
     *
     * @since 2.5.0
     *
     * @param string  $media_dims The HTML markup containing the media dimensions.
     * @param WP_Post $post       The WP_Post attachment object.
     */
    $media_dims = apply_filters('media_meta', $media_dims, $post);
    $image_edit_button = '';
    if (wp_attachment_is_image($post->ID) && wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
        $nonce = wp_create_nonce("image_editor-{$post->ID}");
        $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
    }
    $attachment_url = get_permalink($attachment_id);
    $item = "\n\t{$type_html}\n\t{$toggle_links}\n\t{$order}\n\t{$display_title}\n\t<table class='slidetoggle describe {$class}'>\n\t\t<thead class='media-item-info' id='media-head-{$post->ID}'>\n\t\t<tr>\n\t\t\t<td class='A1B1' id='thumbnail-head-{$post->ID}'>\n\t\t\t<p><a href='{$attachment_url}' target='_blank'><img class='thumbnail' src='{$thumb_url}' alt='' /></a></p>\n\t\t\t<p>{$image_edit_button}</p>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t<p><strong>" . __('File name:') . "</strong> {$filename}</p>\n\t\t\t<p><strong>" . __('File type:') . "</strong> {$post->post_mime_type}</p>\n\t\t\t<p><strong>" . __('Upload date:') . "</strong> " . mysql2date(get_option('date_format'), $post->post_date) . '</p>';
    if (!empty($media_dims)) {
        $item .= "<p><strong>" . __('Dimensions:') . "</strong> {$media_dims}</p>\n";
    }
    $item .= "</td></tr>\n";
    $item .= "\n\t\t</thead>\n\t\t<tbody>\n\t\t<tr><td colspan='2' class='imgedit-response' id='imgedit-response-{$post->ID}'></td></tr>\n\t\t<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-{$post->ID}'></td></tr>\n";
    $defaults = array('input' => 'text', 'required' => false, 'value' => '', 'extra_rows' => array());
    if ($r['send']) {
        $r['send'] = get_submit_button(__('Insert into Post'), 'button', "send[{$attachment_id}]", false);
    }
    $delete = empty($r['delete']) ? '' : $r['delete'];
    if ($delete && current_user_can('delete_post', $attachment_id)) {
        if (!EMPTY_TRASH_DAYS) {
            $delete = "<a href='" . wp_nonce_url("post.php?action=delete&amp;post={$attachment_id}", 'delete-post_' . $attachment_id) . "' id='del[{$attachment_id}]' class='delete-permanently'>" . __('Delete Permanently') . '</a>';
        } elseif (!MEDIA_TRASH) {
            $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_{$attachment_id}').style.display='block';return false;\">" . __('Delete') . "</a>\n\t\t\t <div id='del_attachment_{$attachment_id}' class='del-attachment' style='display:none;'><p>" . sprintf(__('You are about to delete <strong>%s</strong>.'), $filename) . "</p>\n\t\t\t <a href='" . wp_nonce_url("post.php?action=delete&amp;post={$attachment_id}", 'delete-post_' . $attachment_id) . "' id='del[{$attachment_id}]' class='button'>" . __('Continue') . "</a>\n\t\t\t <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a>\n\t\t\t </div>";
        } else {
//.........这里部分代码省略.........
开发者ID:HaraShun,项目名称:WordPress,代码行数:101,代码来源:media.php


示例2: get_media_item

/**
 * Retrieve HTML form for modifying the image attachment.
 *
 * @since unknown
 *
 * @param int $attachment_id Attachment ID for modification.
 * @param string|array $args Optional. Override defaults.
 * @return string HTML form for attachment.
 */
function get_media_item($attachment_id, $args = null)
{
    global $redir_tab;
    $default_args = array('errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true);
    $args = wp_parse_args($args, $default_args);
    extract($args, EXTR_SKIP);
    global $post_mime_types;
    if (($attachment_id = intval($attachment_id)) && ($thumb_url = get_attachment_icon_src($attachment_id))) {
        $thumb_url = $thumb_url[0];
    } else {
        return false;
    }
    $toggle_on = __('Show');
    $toggle_off = __('Hide');
    $post = get_post($attachment_id);
    $filename = basename($post->guid);
    $title = esc_attr($post->post_title);
    if ($_tags = get_the_tags($attachment_id)) {
        foreach ($_tags as $tag) {
            $tags[] = $tag->name;
        }
        $tags = esc_attr(join(', ', $tags));
    }
    $type = '';
    if (isset($post_mime_types)) {
        $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
        $type = array_shift($keys);
        $type = "<input type='hidden' id='type-of-{$attachment_id}' value='" . esc_attr($type) . "' />";
    }
    $form_fields = get_attachment_fields_to_edit($post, $errors);
    if ($toggle) {
        $class = empty($errors) ? 'startclosed' : 'startopen';
        $toggle_links = "\r\n\t<a class='toggle describe-toggle-on' href='#'>{$toggle_on}</a>\r\n\t<a class='toggle describe-toggle-off' href='#'>{$toggle_off}</a>";
    } else {
        $class = 'form-table';
        $toggle_links = '';
    }
    $display_title = !empty($title) ? $title : $filename;
    // $title shouldn't ever be empty, but just in case
    $display_title = $show_title ? "<div class='filename new'>" . wp_html_excerpt($display_title, 60) . "</div>" : '';
    $gallery = isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab'] || isset($redir_tab) && 'gallery' == $redir_tab ? true : false;
    $order = '';
    foreach ($form_fields as $key => $val) {
        if ('menu_order' == $key) {
            if ($gallery) {
                $order = '<div class="menu_order"> <input class="menu_order_input" type="text" id="attachments[' . $attachment_id . '][menu_order]" name="attachments[' . $attachment_id . '][menu_order]" value="' . $val['value'] . '" /></div>';
            } else {
                $order = '<input type="hidden" name="attachments[' . $attachment_id . '][menu_order]" value="' . $val['value'] . '" />';
            }
            unset($form_fields['menu_order']);
            break;
        }
    }
    $item = "\r\n\t{$type}\r\n\t{$toggle_links}\r\n\t{$order}\r\n\t{$display_title}\r\n\t<table class='slidetoggle describe {$class}'>\r\n\t\t<thead class='media-item-info'>\r\n\t\t<tr>\r\n\t\t\t<td class='A1B1' rowspan='4'><img class='thumbnail' src='{$thumb_url}' alt='' /></td>\r\n\t\t\t<td>{$filename}</td>\r\n\t\t</tr>\r\n\t\t<tr><td>{$post->post_mime_type}</td></tr>\r\n\t\t<tr><td>" . mysql2date($post->post_date, get_option('time_format')) . "</td></tr>\r\n\t\t<tr><td>" . apply_filters('media_meta', '', $post) . "</td></tr>\r\n\t\t</thead>\r\n\t\t<tbody>\n";
    $defaults = array('input' => 'text', 'required' => false, 'value' => '', 'extra_rows' => array());
    $delete_href = wp_nonce_url("post.php?action=delete-post&amp;post={$attachment_id}", 'delete-post_' . $attachment_id);
    if ($send) {
        $send = "<input type='submit' class='button' name='send[{$attachment_id}]' value='" . esc_attr__('Insert into Post') . "' />";
    }
    if ($delete) {
        $delete = "<a href=\"#\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_{$attachment_id}').style.display='block';return false;\">" . __('Delete') . "</a>";
    }
    if (($send || $delete) && !isset($form_fields['buttons'])) {
        $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>{$send} {$delete}\r\n\t\t<div id=\"del_attachment_{$attachment_id}\" class=\"del-attachment\" style=\"display:none;\">" . sprintf(__("You are about to delete <strong>%s</strong>."), $filename) . " <a href=\"{$delete_href}\" id=\"del[{$attachment_id}]\" class=\"delete\">" . __('Continue') . "</a>\r\n\t\t<a href=\"#\" class=\"del-link\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div></td></tr>\n");
    }
    $hidden_fields = array();
    foreach ($form_fields as $id => $field) {
        if ($id[0] == '_') {
            continue;
        }
        if (!empty($field['tr'])) {
            $item .= $field['tr'];
            continue;
        }
        $field = array_merge($defaults, $field);
        $name = "attachments[{$attachment_id}][{$id}]";
        if ($field['input'] == 'hidden') {
            $hidden_fields[$name] = $field['value'];
            continue;
        }
        $required = $field['required'] ? '<abbr title="required" class="required">*</abbr>' : '';
        $aria_required = $field['required'] ? " aria-required='true' " : '';
        $class = $id;
        $class .= $field['required'] ? ' form-required' : '';
        $item .= "\t\t<tr class='{$class}'>\n\t\t\t<th valign='top' scope='row' class='label'><label for='{$name}'><span class='alignleft'>{$field['label']}</span><span class='alignright'>{$required}</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>";
        if (!empty($field[$field['input']])) {
            $item .= $field[$field['input']];
        } elseif ($field['input'] == 'textarea') {
            $item .= "<textarea type='text' id='{$name}' name='{$name}'" . $aria_required . ">" . esc_html($field['value']) . "</textarea>";
        } else {
            $item .= "<input type='text' id='{$name}' name='{$name}' value='" . esc_attr($field['value']) . "'" . $aria_required . "/>";
//.........这里部分代码省略.........
开发者ID:Alenjandro,项目名称:data-my-share,代码行数:101,代码来源:media.php


示例3: get_media_item

/**
 * Retrieve HTML form for modifying the image attachment.
 *
 * @since unknown
 *
 * @param int $attachment_id Attachment ID for modification.
 * @param string|array $args Optional. Override defaults.
 * @return string HTML form for attachment.
 */
function get_media_item( $attachment_id, $args = null ) {
	global $redir_tab;

	if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) )
		$thumb_url = $thumb_url[0];
	else
		$thumb_url = false;

	$post = get_post( $attachment_id );

	$default_args = array( 'errors' => null, 'send' => post_type_supports(get_post_type($post->post_parent), 'editor'), 'delete' => true, 'toggle' => true, 'show_title' => true );
	$args = wp_parse_args( $args, $default_args );
	extract( $args, EXTR_SKIP );

	$toggle_on  = __( 'Show' );
	$toggle_off = __( 'Hide' );

	$filename = basename( $post->guid );
	$title = esc_attr( $post->post_title );

	if ( $_tags = get_the_tags( $attachment_id ) ) {
		foreach ( $_tags as $tag )
			$tags[] = $tag->name;
		$tags = esc_attr( join( ', ', $tags ) );
	}

	$post_mime_types = get_post_mime_types();
	$keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
	$type = array_shift( $keys );
	$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";

	$form_fields = get_attachment_fields_to_edit( $post, $errors );

	if ( $toggle ) {
		$class = empty( $errors ) ? 'startclosed' : 'startopen';
		$toggle_links = "
	<a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
	<a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
	} else {
		$class = 'form-table';
		$toggle_links = '';
	}

	$display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
	$display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : '';

	$gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
	$order = '';

	foreach ( $form_fields as $key => $val ) {
		if ( 'menu_order' == $key ) {
			if ( $gallery )
				$order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[$attachment_id][menu_order]' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ). "' /></div>";
			else
				$order = "<input type='hidden' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ) . "' />";

			unset( $form_fields['menu_order'] );
			break;
		}
	}

	$media_dims = '';
	$meta = wp_get_attachment_metadata( $post->ID );
	if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
		$media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
	$media_dims = apply_filters( 'media_meta', $media_dims, $post );

	$image_edit_button = '';
	if ( gd_edit_image_support( $post->post_mime_type ) ) {
		$nonce = wp_create_nonce( "image_editor-$post->ID" );
		$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <img src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' class='imgedit-wait-spin' alt='' />";
	}

	$attachment_url = get_permalink( $attachment_id );

	$item = "
	$type_html
	$toggle_links
	$order
	$display_title
	<table class='slidetoggle describe $class'>
		<thead class='media-item-info' id='media-head-$post->ID'>
		<tr valign='top'>
			<td class='A1B1' id='thumbnail-head-$post->ID'>
			<p><a href='$attachment_url' target='_blank'><img class='thumbnail' src='$thumb_url' alt='' style='margin-top: 3px' /></a></p>
			<p>$image_edit_button</p>
			</td>
			<td>
			<p><strong>" . __('File name:') . "</strong> $filename</p>
			<p><strong>" . __('File type:') . "</strong> $post->post_mime_type</p>
			<p><strong>" . __('Upload date:') . "</strong> " . mysql2date( get_option('date_format'), $post->post_date ). '</p>';
//.........这里部分代码省略.........
开发者ID:realfluid,项目名称:umbaugh,代码行数:101,代码来源:media.php


示例4: get_media_item

function get_media_item($attachment_id, $args = null)
{
    $default_args = array('errors' => null, 'send' => true, 'delete' => true, 'toggle' => true);
    $args = wp_parse_args($args, $default_args);
    extract($args, EXTR_SKIP);
    global $post_mime_types;
    if (($attachment_id = intval($attachment_id)) && ($thumb_url = get_attachment_icon_src($attachment_id))) {
        $thumb_url = $thumb_url[0];
    } else {
        return false;
    }
    $title_label = __('Title');
    $description_label = __('Description');
    $tags_label = __('Tags');
    $toggle_on = __('Show');
    $toggle_off = __('Hide');
    $post = get_post($attachment_id);
    $filename = basename($post->guid);
    $title = attribute_escape($post->post_title);
    $description = attribute_escape($post->post_content);
    if ($_tags = get_the_tags($attachment_id)) {
        foreach ($_tags as $tag) {
            $tags[] = $tag->name;
        }
        $tags = attribute_escape(join(', ', $tags));
    }
    if (isset($post_mime_types)) {
        $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
        $type = array_shift($keys);
        $type = "<input type='hidden' id='type-of-{$attachment_id}' value='" . attribute_escape($type) . "' />";
    }
    $form_fields = get_attachment_fields_to_edit($post, $errors);
    if ($toggle) {
        $class = empty($errors) ? 'startclosed' : 'startopen';
        $toggle_links = "\n\t<a class='toggle describe-toggle-on' href='#'>{$toggle_on}</a>\n\t<a class='toggle describe-toggle-off' href='#'>{$toggle_off}</a>";
    } else {
        $class = 'form-table';
        $toggle_links = '';
    }
    $display_title = !empty($title) ? $title : $filename;
    // $title shouldn't ever be empty, but just in case
    $item = "\n\t{$type}\n\t{$toggle_links}\n\t<div class='filename new'>{$display_title}</div>\n\t<table class='slidetoggle describe {$class}'>\n\t\t<thead class='media-item-info'>\n\t\t<tr>\n\t\t\t<td class='A1B1' rowspan='4'><img class='thumbnail' src='{$thumb_url}' alt='' /></td>\n\t\t\t<td>{$filename}</td>\n\t\t</tr>\n\t\t<tr><td>{$post->post_mime_type}</td></tr>\n\t\t<tr><td>" . mysql2date($post->post_date, get_option('time_format')) . "</td></tr>\n\t\t<tr><td>" . apply_filters('media_meta', '', $post) . "</td></tr>\n\t\t</thead>\n\t\t<tbody>\n";
    $defaults = array('input' => 'text', 'required' => false, 'value' => '', 'extra_rows' => array());
    $delete_href = wp_nonce_url("post.php?action=delete-post&amp;post={$attachment_id}", 'delete-post_' . $attachment_id);
    if ($send) {
        $send = "<input type='submit' class='button' name='send[{$attachment_id}]' value='" . attribute_escape(__('Insert into Post')) . "' />";
    }
    if ($delete) {
        $delete = "<a href='{$delete_href}' id='del[{$attachment_id}]' disabled='disabled' class='delete'>" . __('Delete') . "</button>";
    }
    if (($send || $delete) && !isset($form_fields['buttons'])) {
        $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>{$send} {$delete}</td></tr>\n");
    }
    $hidden_fields = array();
    foreach ($form_fields as $id => $field) {
        if ($id[0] == '_') {
            continue;
        }
        if (!empty($field['tr'])) {
            $item .= $field['tr'];
            continue;
        }
        $field = array_merge($defaults, $field);
        $name = "attachments[{$attachment_id}][{$id}]";
        if ($field['input'] == 'hidden') {
            $hidden_fields[$name] = $field['value'];
            continue;
        }
        $required = $field['required'] ? '<abbr title="required" class="required">*</abbr>' : '';
        $class = $id;
        $class .= $field['required'] ? ' form-required' : '';
        $item .= "\t\t<tr class='{$class}'>\n\t\t\t<th valign='top' scope='row' class='label'><label for='{$name}'><span class='alignleft'>{$field['label']}</span><span class='alignright'>{$required}</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>";
        if (!empty($field[$field['input']])) {
            $item .= $field[$field['input']];
        } elseif ($field['input'] == 'textarea') {
            $item .= "<textarea type='text' id='{$name}' name='{$name}'>" . attribute_escape($field['value']) . "</textarea>";
        } else {
            $item .= "<input type='text' id='{$name}' name='{$name}' value='" . attribute_escape($field['value']) . "' />";
        }
        if (!empty($field['helps'])) {
            $item .= "<p class='help'>" . join("</p>\n<p class='help'>", array_unique((array) $field['helps'])) . '</p>';
        }
        $item .= "</td>\n\t\t</tr>\n";
        $extra_rows = array();
        if (!empty($field['errors'])) {
            foreach (array_unique((array) $field['errors']) as $error) {
                $extra_rows['error'][] = $error;
            }
        }
        if (!empty($field['extra_rows'])) {
            foreach ($field['extra_rows'] as $class => $rows) {
                foreach ((array) $rows as $html) {
                    $extra_rows[$class][] = $html;
                }
            }
        }
        foreach ($extra_rows as $class => $rows) {
            foreach ($rows as $html) {
                $item .= "\t\t<tr><td></td><td class='{$class}'>{$html}</td></tr>\n";
            }
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:media.php


示例5: get_jw_playlist_item

/**
 * Retrieves a sepecific playlist item.  In this case it is a media attachment.
 * @global string $redir_tab The tab to redirect to.
 * @param int $attachment_id The id of the attachment we are retrieving.
 * @param array $args Any additional arguments for query the database.
 * @param int $current_playlist The currently selected playlist.
 * @return string The HTML representing the playlist item.
 */
function get_jw_playlist_item($attachment_id, $args, $current_playlist, $prefix = "")
{
    global $redir_tab, $p_items;
    if (($attachment_id = intval($attachment_id)) && ($thumb_url = get_attachment_icon_src($attachment_id))) {
        $thumb_url = $thumb_url[0];
    } else {
        return false;
    }
    $default_args = array('errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true);
    $args = wp_parse_args($args, $default_args);
    extract($args, EXTR_SKIP);
    $post = get_post($attachment_id);
    $filename = basename($post->guid);
    $title = esc_attr($post->post_title);
    if ($_tags = get_the_tags($attachment_id)) {
        foreach ($_tags as $tag) {
            $tags[] = $tag->name;
        }
        $tags = esc_attr(join(', ', $tags));
    }
    $post_mime_types = get_post_mime_types();
    $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
    $type = array_shift($keys);
    $type_html = "<input type='hidden' id='type-of-{$attachment_id}' value='" . esc_attr($type) . "' />";
    $form_fields = get_attachment_fields_to_edit($post, $errors);
    $display_title = !empty($title) ? $title : $filename;
    // $title shouldn't ever be empty, but just in case
    $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt($display_title, 60) . "</span></div>" : '';
    $gallery = isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab'] || isset($redir_tab) && 'gallery' == $redir_tab ? true : false;
    $order = '';
    $checked = "";
    foreach ($p_items as $playlist_item) {
        if ($playlist_item == $attachment_id) {
            $checked = "checked='true'";
            break;
        }
    }
    foreach ($form_fields as $key => $val) {
        if ('menu_order' == $key) {
            if (true) {
                $order = '<div class="menu_order">';
                $order .= '<input class="menu_order_input" type="checkbox" id="' . $prefix . 'attachments[' . $attachment_id . '][enabled]" name="' . $prefix . 'attachments[' . $attachment_id . '][enabled]" value="' . $val['value'] . '"' . $checked . ' onclick="updatePlaylist(this);" /></div>';
            } else {
                $order = '<input type="hidden" name="' . $prefix . 'attachments[' . $attachment_id . '][menu_order]" value="' . $val['value'] . '" />';
            }
            unset($form_fields['menu_order']);
            break;
        }
    }
    $media_dims = '';
    $meta = wp_get_attachment_metadata($post->ID);
    if (is_array($meta) && array_key_exists('width', $meta) && array_key_exists('height', $meta)) {
        $media_dims .= "<span id='playlist-dims-{$post->ID}'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
    }
    $media_dims = apply_filters('media_meta', $media_dims, $post);
    $image_edit_button = '';
    if (gd_edit_image_support($post->post_mime_type)) {
        $nonce = wp_create_nonce("image_editor-{$post->ID}");
        $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open({$post->ID}, \"{$nonce}\")' class='button' value='" . esc_attr__('Edit image') . "' /> <img src='images/wpspin_light.gif' class='imgedit-wait-spin' alt='' />";
    }
    $item = "\n\t{$type_html}\n\t{$toggle_links}\n\t{$order}\n\t{$display_title}\n  <table class='slidetoggle describe startclosed'>\n\t\t<thead class='media-item-info' id='media-head-{$post->ID}'>\n\t\t<tr>\n\t\t\t<td class='A1B1' id='thumbnail-head-{$post->ID}' rowspan='5'><img class='thumbnail' src='{$thumb_url}' alt='' /></td>\n\t\t\t<td><strong>" . __('File name:') . "</strong> {$filename}</td>\n\t\t</tr>\n\t\t<tr><td><strong>" . __('File type:') . "</strong> {$post->post_mime_type}</td></tr>\n\t\t<tr><td><strong>" . __('Upload date:') . "</strong> " . mysql2date(get_option('date_format'), $post->post_date) . "</td></tr>\n";
    if (!empty($media_dims)) {
        $item .= "<tr><td><strong>" . __('Dimensions:') . "</strong> {$media_dims}</td></tr>\n";
    }
    $item .= "\n\t\t<tr><td class='A1B1'>{$image_edit_button}</td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t<tr><td colspan='2' class='imgedit-response' id='imgedit-response-{$post->ID}'></td></tr>\n\t\t<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-{$post->ID}'></td></tr>\n";
    $defaults = array('input' => 'text', 'required' => false, 'value' => '', 'extra_rows' => array());
    $thumbnail = '';
    $calling_post_id = 0;
    if (isset($_GET['post_id'])) {
        $calling_post_id = $_GET['post_id'];
    } elseif (isset($_POST) && count($_POST)) {
        // Like for async-upload where $_GET['post_id'] isn't set
        $calling_post_id = $post->post_parent;
    }
    if ('image' == $type && $calling_post_id && current_theme_supports('post-thumbnails', get_post_type($calling_post_id)) && get_post_thumbnail_id($calling_post_id) != $attachment_id) {
        $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"{$attachment_id}\");return false;'>" . esc_html__("Use as thumbnail") . "</a>";
    }
    if (($send || $thumbnail || $delete) && !isset($form_fields['buttons'])) {
        $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>{$send} {$thumbnail} {$delete}</td></tr>\n");
    }
    $hidden_fields = array();
    foreach ($form_fields as $id => $field) {
        if ($id[0] == '_') {
            continue;
        }
        if (!empty($field['tr'])) {
            $item .= $field['tr'];
            continue;
        }
        $field = array_merge($defaults, $field);
        $name = "attachments[{$attachment_id}][{$id}]";
        if ($field['input'] == 'hidden') {
//.........这里部分代码省略.........
开发者ID:thejimbirch,项目名称:unionrockyards,代码行数:101,代码来源:EmbedManager.php


示例6: getMediaFields

 /**
  * @param object $attachmentPost
  * @return array
  */
 public function getMediaFields($attachmentPost)
 {
     add_filter('attachment_fields_to_edit', array(&$this, 'filterMediaFields'), 10, 2);
     return get_attachment_fields_to_edit($attachmentPost);
 }
开发者ID:nikolaskarica,项目名称:bds-alliance,代码行数:9,代码来源:media.php



注:本文中的get_attachment_fields_to_edit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_attachment_icon函数代码示例发布时间:2022-05-15
下一篇:
PHP get_attachment函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap