Example #1
0
function ocwssl_wp_post_thumbnail_html($thumbnail_id = null, $post = null)
{
    global $content_width, $_wp_additional_image_sizes;
    $post = get_post($post);
    $post_type_object = get_post_type_object($post->post_type);
    $set_thumbnail_link = '<p class="hide-if-no-js"><a title="%s" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
    $upload_iframe_src = get_upload_iframe_src('image', $post->ID);
    $content = sprintf($set_thumbnail_link, esc_attr($post_type_object->labels->set_featured_image), esc_url($upload_iframe_src), esc_html($post_type_object->labels->set_featured_image));
    if ($thumbnail_id && get_post($thumbnail_id)) {
        $old_content_width = $content_width;
        $content_width = 1000;
        if (!isset($_wp_additional_image_sizes['full'])) {
            // use 'full' for system defined fullsize image OR use our custom image size instead of 'post-thumbnail'
            $thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
        } else {
            $thumbnail_html = wp_get_attachment_image($thumbnail_id, 'full');
        }
        // use 'full' for system defined fullsize image OR use our custom image size instead of 'post-thumbnail'
        if (!empty($thumbnail_html)) {
            $ajax_nonce = wp_create_nonce('set_post_thumbnail-' . $post->ID);
            $content = sprintf($set_thumbnail_link, esc_attr($post_type_object->labels->set_featured_image), esc_url($upload_iframe_src), $thumbnail_html);
            $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html($post_type_object->labels->remove_featured_image) . '</a></p>';
        }
        $content_width = $old_content_width;
    }
    /**
     * Filter the admin post thumbnail HTML markup to return.
     *
     * @since 2.9.0
     *
     * @param string $content Admin post thumbnail HTML markup.
     * @param int    $post_id Post ID.
     */
    return apply_filters('admin_post_thumbnail_html', $content, $post->ID);
}
function S2FilePicker_btn($editor_id = 'content')
{
    printf('
		<a href="%s" id="add_s2fpicker" class="button thickbox add_s2fpicker" title="%s">
			Link s2member file
		</a>
		', esc_url(get_upload_iframe_src('s2fpicker')), __('Add s2member Secure-File', 's2sfu'));
}
 /**
  * Generate the metabox content
  * 
  * @global int $post_ID
  * @param int $image_id
  * @return string 
  */
 public function animals_kd_meta_box_output($image_id = NULL)
 {
     global $post_ID;
     $output = '';
     $setImageLink = sprintf('<p class="hide-if-no-js"><a title="%2$s" href="%1$s" id="kd_%3$s" class="thickbox">%%s</a></p>', get_upload_iframe_src('image'), $this->labels['set'], $this->id);
     if ($image_id && get_post($image_id)) {
         $nonce_field = wp_create_nonce($this->nonce . $post_ID);
         $thumbnail = wp_get_attachment_image($image_id, array(266, 266));
         $output .= sprintf($setImageLink, $thumbnail);
         $output .= '<p class="hide-if-no-js">';
         $output .= sprintf('<a href="#" id="remove-%1$s-image" onclick="kdMuFeaImgRemove( \'%1$s\', \'%2$s\', \'%3$s\' ); return false;">', $this->id, $this->post_type, $nonce_field);
         $output .= $this->labels['remove'];
         $output .= '</a>';
         $output .= '</p>';
         return $output;
     } else {
         return sprintf($setImageLink, $this->labels['set']);
     }
 }
 public static function render_html($value, $setting_key, $setting_group, $setting_page, $return = false)
 {
     $image_library_url = get_upload_iframe_src('image', null, 'library');
     $image_library_url = remove_query_arg('TB_iframe', $image_library_url);
     $image_library_url = add_query_arg(array('context' => 'voce-image-setting', 'setting_key' => $setting_key, 'setting_group' => $setting_group, 'setting_page' => $setting_page, 'TB_iframe' => 1), $image_library_url);
     $link = '<a href="%s" class="%s button" %s>%s</a>';
     $image = $value && ($src = wp_get_attachment_image_src($value, true));
     // href, extra classes, extra attributes, text
     $link = $image ? sprintf($link, '', 'remove-voce-image-setting', sprintf(' data-nonce="%s"', wp_create_nonce('set_voce_image_setting')), 'Remove Image') : sprintf($link, $image_library_url, 'set-voce-image-setting thickbox', '', 'Set Image');
     $id = $setting_page . '-' . $setting_group . '-' . $setting_key;
     $html = sprintf('<div id="%s" data-setting-page="%s" data-setting-group="%s" data-setting-key="%s" class="voce-image-setting"><div class="ajax-response"></div>', esc_attr($id), esc_attr($setting_page), esc_attr($setting_group), esc_attr($setting_key));
     if ($image) {
         $html .= sprintf('<img src="%s" style="max-width:500px; height:auto;" /><br/>', esc_url($src[0]));
     }
     $html .= $link . '</div>';
     if ($return) {
         return $html;
     }
     echo $html;
 }
Example #5
0
/**
 * For badge pages, change the feature image content to add the designer. This
 * gets called as a filter by WP whenever the content inside the postimagediv
 * needs to be updated (even via AJAX).
 */
function openbadger_badgedesigner_admin_post_thumbnail_html($content, $post_id)
{
    global $openbadger_badge_schema;
    if (get_post_type($post_id) != $openbadger_badge_schema->get_post_type_name()) {
        return $content;
    }
    /* if we already have a thumbnail, don't modify the content, just return */
    if (has_post_thumbnail($post_id)) {
        return $content;
    }
    /* Copied from wp-admin/includes/post.php */
    $upload_iframe_src = esc_url(get_upload_iframe_src('image', $post_id));
    $media_manager_link = sprintf('<a title="%2$s" href="%1$s" id="set-post-thumbnail" class="thickbox">%3$s</a>', $upload_iframe_src, esc_attr__('Media Library'), esc_html__('Media Library'));
    if (!is_multisite()) {
        $origin = network_site_url();
        $email = get_site_option('admin_email');
    } else {
        $origin = site_url();
        $email = get_bloginfo('admin_email');
    }
    $designer_link = sprintf('<a href="https://www.openbadges.me/designer.html?format=json&amp;origin=%3$s&amp;email=%4$s&amp;uniqueID=%7$s" title="%1$s" id="openbadger-badge-designer" data-post-id="%5$d" data-nonce="%6$s" data-badge-source="openbadges.me">%2$s</a>', esc_attr__('Badge Designer', 'rpibadger'), esc_html__('Badge Designer', 'rpibadger'), urlencode($origin), urlencode($email), $post_id, esc_attr(wp_create_nonce('openbadger-badgedesigner')), urlencode(get_current_user_id()));
    return '<p class="hide-if-no-js">' . sprintf(__('Use the %s to upload or select an existing image. Or use the %s to create a new one', 'rpibadger'), $media_manager_link, $designer_link) . '.</p>';
}
Example #6
0
        ksort($sort);
    } else {
        krsort($sort);
    }
}
$sort_url = menu_page_url('premise-buttons', false);
$title_sort = $orderby == 'title' && $order == 'ASC' ? 'DESC' : 'ASC';
$date_sort = $orderby == 'lastsaved' && $order == 'ASC' ? 'DESC' : 'ASC';
$title_url = add_query_arg(array('orderby' => 'title', 'order' => $title_sort), $sort_url);
$date_url = add_query_arg(array('orderby' => 'lastsaved', 'order' => $date_sort), $sort_url);
?>
<h3 id="your-buttons"><?php 
_e('Your Buttons', 'premise');
?>
 <a href="<?php 
echo add_query_arg(array('height' => 700), get_upload_iframe_src('premise-button-create'));
?>
" class="thickbox button button-secondary"><?php 
_e('Add New Button', 'premise');
?>
</a></h3>
<table class="widefat">
	<thead>
		<tr>
			<th scope="col"><?php 
printf('<a href="%s">%s</a>', $title_url, __('Title', 'premise'));
?>
</th>
			<th scope="col"><?php 
_e('Example Button', 'premise');
?>
    /**
     *
     * Creates An AJAX Image Uploader
     *
     * @since 1.0.0
     * @author Andrew Powers
     *
     */
    function _get_image_upload_option($oid, $o)
    {
        $up_url = $this->input_text($o['input_id'], $o['input_name'], esc_url($o['val']), 'regular-text uploaded_url', 'text', '', $o['placeholder']);
        $button_id = isset($o['special']) ? $oid . 'OID' . $o['special'] : $oid;
        $up_button = $this->input_button($button_id, __('Upload Image', 'pagelines'), 'image_upload_button admin-blue', 'title="' . $this->settings_field . '"');
        $reset_button = sprintf('<span title="%1$s" id="%2$s" class="image_reset_button button reset_%1$s">Remove</span>', $button_id, $this->settings_field);
        $ajax_url = $this->input_hidden('', 'wp_ajax_action_url', admin_url("admin-ajax.php"), 'ajax_action_url');
        $preview_size = $this->input_hidden('', 'img_size_' . $oid, $o['imagepreview'], 'image_preview_size');
        ob_start();
        $image_library_url = get_upload_iframe_src('image', null, 'library');
        $image_library_url = remove_query_arg('TB_iframe', $image_library_url);
        $image_library_url = add_query_arg(array('oid' => $o['input_id'], 'context' => 'pl-custom-attach', 'TB_iframe' => 1), $image_library_url);
        ?>

			<a id="choose-from-library-link" class="button thickbox" href="<?php 
        echo esc_url($image_library_url);
        ?>
">
				<?php 
        _e('Select From Library', 'pagelines');
        ?>
			</a>

		<?php 
        $media_lib = ob_get_clean();
        // Output
        $label = $this->input_label($oid, $o['inputlabel']);
        printf('<p>%s %s<br/> %s %s %s %s %s</p>', $label, $up_url, $up_button, $media_lib, $reset_button, $ajax_url, $preview_size);
        $special_image_class = '';
        $select_class = sprintf('pre_%s', $o['input_id']);
        if ($o['val']) {
            $active_image_url = $o['val'];
        } elseif ($o['placeholder']) {
            $active_image_url = $o['placeholder'];
            $special_image_class = 'default-image-preview';
        } else {
            $active_image_url = false;
        }
        printf('<img class="pagelines_image_preview %s %s" id="image_%s" src="%s" style="max-width:%spx; %s"/>', $special_image_class, $select_class, $button_id, $active_image_url, $o['imagepreview'], !$active_image_url ? 'display: none;' : '');
    }
Example #8
0
function _media_button($title, $icon, $type) {
	return "<a href='" . esc_url( get_upload_iframe_src($type) ) . "' id='add_$type' class='thickbox' title='$title'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' /></a>";
}
    function showMenuOptions($item_id)
    {
        global $uberMenu;
        $settings = $uberMenu->getSettings();
        parent::showMenuOptions($item_id);
        $this->showCustomMenuOption('notext', $item_id, array('level' => '0-plus', 'title' => __('Remove the Navigation Label text from the link.  Can be used, for example, with image-only links.', 'ubermenu'), 'label' => __('Disable Text', 'ubermenu'), 'type' => 'checkbox'));
        $this->showCustomMenuOption('floatRight', $item_id, array('level' => '0', 'title' => __('Float the menu item to the right edge of the menu bar.', 'ubermenu'), 'label' => __('Align Menu Item to Right Edge', 'ubermenu'), 'type' => 'checkbox'));
        //CONTENT OVERRIDES AND WIDGET AREAS
        if ($settings->op('wpmega-shortcodes')) {
            $this->showCustomMenuOption('shortcode', $item_id, array('level' => '0-plus', 'title' => __('Display custom content in this menu item.  This input accepts shortcodes so you can display things like contact forms, search boxes, or galleries.  Check "Disable Link" above to display only this content, instead of a link.', 'ubermenu'), 'label' => __('Custom Content (Content Override)', 'ubermenu'), 'type' => 'textarea'));
        }
        $minSidebarLevel = 1;
        if ($settings->op('wpmega-top-level-widgets')) {
            $minSidebarLevel = 0;
        }
        $this->showCustomMenuOption('sidebars', $item_id, array('level' => $minSidebarLevel . '-plus', 'title' => __('Select the widget area to display', 'ubermenu'), 'label' => __('Display a Widget Area', 'ubermenu'), 'type' => 'sidebarselect'));
        do_action('ubermenu_extended_menu_item_options', $item_id, $this);
        global $post_ID;
        $post_ID = $item_id;
        $iframeSrc = get_upload_iframe_src('image') . '&amp;tab=type&amp;width=640&amp;height=589';
        //media-upload.php?post_id=<?php echo $item_id; &amp;type=image&amp;TB_iframe=1&amp;width=640&amp;height=589
        $wp_mega_link = "Set Thumbnail";
        $wp_mega_img = $uberMenu->getImage($item_id);
        if (!empty($wp_mega_img)) {
            $wp_mega_link = $wp_mega_img;
            $ajax_nonce = wp_create_nonce("set_post_thumbnail-{$item_id}");
            $wp_mega_link .= '<div class="remove-item-thumb" id="remove-item-thumb-' . $item_id . '"><a href="#" id="remove-post-thumbnail-' . $item_id . '" onclick="wpmega_remove_thumb(\'' . $ajax_nonce . '\', ' . $item_id . ');return false;">' . esc_html__('Remove image', 'ubermenu') . '</a></div>';
        }
        ?>

		<p class="wpmega-custom-all"><a class="thickbox set-menu-item-thumb button uber_clear" id="set-post-thumbnail-<?php 
        echo $item_id;
        ?>
" href="<?php 
        echo $iframeSrc;
        ?>
" title="Set Thumbnail"><?php 
        echo $wp_mega_link;
        ?>
</a></p>

		<?php 
    }
        /**
         * Output the post thumbnail HTML for the metabox and AJAX callbacks
         *
         * @param string $thumbnail_id The thumbnail's post ID.
         * @return string HTML
         */
        private function post_thumbnail_html($thumbnail_id = null)
        {
            global $content_width, $_wp_additional_image_sizes, $post_ID, $wp_version;
            $url_class = "";
            $ajax_nonce = wp_create_nonce("set_post_thumbnail-{$this->post_type}-{$this->id}-{$post_ID}");
            if (version_compare($wp_version, '3.5', '<')) {
                // Use the old thickbox for versions prior to 3.5
                $image_library_url = get_upload_iframe_src('image');
                // if TB_iframe is not moved to end of query string, thickbox will remove all query args after it.
                $image_library_url = add_query_arg(array('context' => $this->id, 'TB_iframe' => 1), remove_query_arg('TB_iframe', $image_library_url));
                $url_class = "thickbox";
            } else {
                // Use the media modal for 3.5 and up
                $image_library_url = "#";
                $modal_js = sprintf('var mm_%3$s = new MediaModal({
						calling_selector : "#set-%1$s-%2$s-thumbnail",
						cb : function(attachment){
							MultiPostThumbnails.setAsThumbnail(attachment.id, "%2$s", "%1$s", "%4$s");
						}
					});', $this->post_type, $this->id, md5($this->id), $ajax_nonce);
            }
            $format_string = '<p class="hide-if-no-js"><a title="%1$s" href="%2$s" id="set-%3$s-%4$s-thumbnail" class="%5$s" data-thumbnail_id="%7$s" data-uploader_title="%1$s" data-uploader_button_text="%1$s">%%s</a></p>';
            $set_thumbnail_link = sprintf($format_string, sprintf(esc_attr__("Set %s", 'multiple-post-thumbnails'), $this->label), $image_library_url, $this->post_type, $this->id, $url_class, $this->label, $thumbnail_id);
            $content = sprintf($set_thumbnail_link, sprintf(esc_html__("Set %s", 'multiple-post-thumbnails'), $this->label));
            if ($thumbnail_id && get_post($thumbnail_id)) {
                $old_content_width = $content_width;
                $content_width = 266;
                if (!isset($_wp_additional_image_sizes["{$this->post_type}-{$this->id}-thumbnail"])) {
                    $thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
                } else {
                    $thumbnail_html = wp_get_attachment_image($thumbnail_id, "{$this->post_type}-{$this->id}-thumbnail");
                }
                if (!empty($thumbnail_html)) {
                    $content = sprintf($set_thumbnail_link, $thumbnail_html);
                    $format_string = '<p class="hide-if-no-js"><a href="#" id="remove-%1$s-%2$s-thumbnail" onclick="MultiPostThumbnails.removeThumbnail(\'%2$s\', \'%1$s\', \'%4$s\');return false;">%3$s</a></p>';
                    $content .= sprintf($format_string, $this->post_type, $this->id, sprintf(esc_html__("Remove %s", 'multiple-post-thumbnails'), $this->label), $ajax_nonce);
                }
                $content_width = $old_content_width;
            }
            if (version_compare($wp_version, '3.5', '>=')) {
                $content .= sprintf('<script>%s</script>', $modal_js);
            }
            return $content;
        }
Example #11
0
/**
 * Output HTML for the post thumbnail meta-box.
 *
 * @since 2.9.0
 *
 * @param int $thumbnail_id ID of the attachment used for thumbnail
 * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
 * @return string html
 */
function _wp_post_thumbnail_html($thumbnail_id = null, $post = null)
{
    $_wp_additional_image_sizes = wp_get_additional_image_sizes();
    $post = get_post($post);
    $post_type_object = get_post_type_object($post->post_type);
    $set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>';
    $upload_iframe_src = get_upload_iframe_src('image', $post->ID);
    $content = sprintf($set_thumbnail_link, esc_url($upload_iframe_src), '', esc_html($post_type_object->labels->set_featured_image));
    if ($thumbnail_id && get_post($thumbnail_id)) {
        $size = isset($_wp_additional_image_sizes['post-thumbnail']) ? 'post-thumbnail' : array(266, 266);
        /**
         * Filters the size used to display the post thumbnail image in the 'Featured Image' meta box.
         *
         * Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail'
         * image size is registered, which differs from the 'thumbnail' image size
         * managed via the Settings > Media screen. See the `$size` parameter description
         * for more information on default values.
         *
         * @since 4.4.0
         *
         * @param string|array $size         Post thumbnail image size to display in the meta box. Accepts any valid
         *                                   image size, or an array of width and height values in pixels (in that order).
         *                                   If the 'post-thumbnail' size is set, default is 'post-thumbnail'. Otherwise,
         *                                   default is an array with 266 as both the height and width values.
         * @param int          $thumbnail_id Post thumbnail attachment ID.
         * @param WP_Post      $post         The post object associated with the thumbnail.
         */
        $size = apply_filters('admin_post_thumbnail_size', $size, $thumbnail_id, $post);
        $thumbnail_html = wp_get_attachment_image($thumbnail_id, $size);
        if (!empty($thumbnail_html)) {
            $content = sprintf($set_thumbnail_link, esc_url($upload_iframe_src), ' aria-describedby="set-post-thumbnail-desc"', $thumbnail_html);
            $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __('Click the image to edit or update') . '</p>';
            $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">' . esc_html($post_type_object->labels->remove_featured_image) . '</a></p>';
        }
    }
    $content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="' . esc_attr($thumbnail_id ? $thumbnail_id : '-1') . '" />';
    /**
     * Filters the admin post thumbnail HTML markup to return.
     *
     * @since 2.9.0
     * @since 3.5.0 Added the `$post_id` parameter.
     * @since 4.6.0 Added the `$thumbnail_id` parameter.
     *
     * @param string $content      Admin post thumbnail HTML markup.
     * @param int    $post_id      Post ID.
     * @param int    $thumbnail_id Thumbnail ID.
     */
    return apply_filters('admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id);
}
Example #12
0
 /**
  * Builds URI for media upload iframe
  * @param string $type Type of media to upload
  * @return string Upload URI
  */
 function get_upload_iframe_src($type = 'media', $args = null)
 {
     //Build Upload URI
     $ret = $this->upload_url(get_upload_iframe_src($type), $args);
     //Return URI
     return $ret;
 }
/**
 * Adds the pick a pic icon to the media bar.
 *
 * @param it editor_id.
 * @return noting.
 **/
function pac_pickapic_media_buttons($editor_id = '')
{
    $img = '<img src="' . esc_url(plugin_dir_url(dirname(__FILE__) . '/pick-a-pic.php') . 'icoWPcam.png') . '" width="15" height="15" />';
    // TODO: postear esto!!
    echo '<a href="' . add_query_arg('tab', 'pickapictab', esc_url(get_upload_iframe_src())) . '" class="thickbox add_media" id="' . esc_attr($editor_id) . '-add_media" title="' . esc_attr__('Flickr - pick a pic', 'pickapic') . '" onclick="return false;">' . sprintf($img) . ' Freies Foto suchen</a>';
}
Example #14
0
function _media_button($title, $icon, $type, $id)
{
    return "<a href='" . esc_url(get_upload_iframe_src($type)) . "' id='{$id}-add_{$type}' class='thickbox add_{$type}' title='" . esc_attr($title) . "'><img src='" . esc_url(admin_url($icon)) . "' alt='{$title}' onclick='return false;' /></a>";
}
Example #15
0
?>
-icon"><?php 
_e('Icon URL', 'premise');
?>
</label>
                	</th>
                	<td>
                		<input class="regular-text premise-content-scrollers-icon" type="text" name="premise[content-scrollers][<?php 
echo $key;
?>
][icon]" id="premise-content-scrollers-<?php 
echo $key;
?>
-icon" value="<?php 
echo esc_attr($icon);
?>
" />
                		<?php 
printf(__('You can upload one via the <a class="thickbox" href="%s">WordPress uploader</a>.', 'premise'), esc_attr(add_query_arg(array('post_id' => 0, 'send_to_premise_field_id' => "premise-content-scrollers-{$key}-icon", 'TB_iframe' => 1, 'width' => 640, 'height' => 459), add_query_arg('TB_iframe', null, get_upload_iframe_src('image')))));
?>
                	</td>
                </tr>
            </tbody>
        </table>

        <?php 
premise_the_editor($text, 'premise[content-scrollers][' . $key . '][text]', '', true, $key + 2);
?>
    </div>
</div>
Example #16
0
 function custom_banners_post_thumbnail_html($post)
 {
     $thumbnail_id = get_post_meta($post->ID, '_thumbnail_id', true);
     $upload_iframe_src = esc_url(get_upload_iframe_src('image', $post->ID));
     $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__('Set featured image') . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
     $content = sprintf($set_thumbnail_link, $upload_iframe_src, esc_html__('Set featured image'));
     if ($thumbnail_id && get_post($thumbnail_id)) {
         $thumbnail_html = wp_get_attachment_image($thumbnail_id, "full");
         if (!empty($thumbnail_html)) {
             $ajax_nonce = wp_create_nonce('set_post_thumbnail-' . $post->ID);
             $content = sprintf($set_thumbnail_link, $upload_iframe_src, $thumbnail_html);
             $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__('Remove featured image') . '</a></p>';
         }
     }
     // output the finalized HTML
     echo apply_filters('admin_post_thumbnail_html', $content, $post->ID);
 }
Example #17
0
_e('Enter the URL to a favicon you would like to use for your landing pages.  You can override this per landing page, but the value here will be used by default.', 'premise');
?>
</small>
			</td>
		</tr>
		<tr>
			<th scope="row"><label for="premise-main-default-header-image"><?php 
_e('Default Header Image', 'premise');
?>
</label></th>
			<td>
				<input class="regular-text" type="text" name="premise[main][default-header-image]" id="premise-main-default-header-image" value="<?php 
echo esc_attr($main['default-header-image']);
?>
" /> <a class="thickbox" href="<?php 
echo esc_attr(add_query_arg(array('send_to_premise_field_id' => 'premise-main-default-header-image', 'TB_iframe' => 1, 'width' => 640, 'height' => 459), add_query_arg('TB_iframe', null, get_upload_iframe_src('image'))));
?>
"><?php 
_e('Upload', 'premise');
?>
</a><br />
				<small><?php 
_e('Enter the URL to an image that you wish to use in the header of your landing pages by default.', 'premise');
?>
</small>
			</td>
		</tr>
		<tr>
			<th scope="row"><label for="premise-main-default-header-image-url"><?php 
_e('Default Header Image Link', 'premise');
?>
function s2sfu_media_button($editor_id = 'content')
{
    echo "<a href='" . esc_url(get_upload_iframe_src('s2sfu')) . "' id='add_s2sfu' class='thickbox add_s2sfu' title='" . __('Add s2member Secure-File', 's2sfu') . "'><img src='" . plugins_url() . '/' . dirname(plugin_basename(__FILE__)) . "/images/secure_files.gif' alt='" . __('s2member Secure-File Upload', 's2sfu') . "' onclick='return false;' /></a>";
}
 /**
  * Output the post thumbnail HTML for the metabox and AJAX callbacks
  *
  * @param string $thumbnail_id The thumbnail's post ID.
  * @return string HTML
  */
 private function post_thumbnail_html($thumbnail_id = null)
 {
     global $content_width, $_wp_additional_image_sizes, $post_ID;
     $image_library_url = get_upload_iframe_src('image');
     // if TB_iframe is not moved to end of query string, thickbox will remove all query args after it.
     $image_library_url = add_query_arg(array('context' => $this->id, 'TB_iframe' => 1), remove_query_arg('TB_iframe', $image_library_url));
     $format_string = '<p class="hide-if-no-js"><a title="%1$s" href="%2$s" id="set-%3$s-%4$s-thumbnail" class="thickbox">%%s</a></p>';
     $set_thumbnail_link = sprintf($format_string, sprintf(esc_attr__("Set %s", 'multiple-post-thumbnails'), $this->label), $image_library_url, $this->post_type, $this->id);
     $content = sprintf($set_thumbnail_link, sprintf(esc_html__("Set %s", 'multiple-post-thumbnails'), $this->label));
     if ($thumbnail_id && get_post($thumbnail_id)) {
         $old_content_width = $content_width;
         $content_width = 266;
         if (!isset($_wp_additional_image_sizes["{$this->post_type}-{$this->id}-thumbnail"])) {
             $thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
         } else {
             $thumbnail_html = wp_get_attachment_image($thumbnail_id, "{$this->post_type}-{$this->id}-thumbnail");
         }
         if (!empty($thumbnail_html)) {
             $ajax_nonce = wp_create_nonce("set_post_thumbnail-{$this->post_type}-{$this->id}-{$post_ID}");
             $content = sprintf($set_thumbnail_link, $thumbnail_html);
             $format_string = '<p class="hide-if-no-js"><a href="#" id="remove-%1$s-%2$s-thumbnail" onclick="MultiPostThumbnails.removeThumbnail(\'%2$s\', \'%1$s\', \'%4$s\');return false;">%3$s</a></p>';
             $content .= sprintf($format_string, $this->post_type, $this->id, sprintf(esc_html__("Remove %s", 'multiple-post-thumbnails'), $this->label), $ajax_nonce);
         }
         $content_width = $old_content_width;
     }
     return $content;
 }
Example #20
0
    /**
     * Display the custom background page.
     *
     * @since 3.0.0
     */
    function admin_page()
    {
        ?>
<div class="wrap" id="custom-background">
<?php 
        screen_icon();
        ?>
<h2><?php 
        _e('Custom Background');
        ?>
</h2>
<?php 
        if (!empty($this->updated)) {
            ?>
<div id="message" class="updated">
<p><?php 
            printf(__('Background updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url('/'));
            ?>
</p>
</div>
<?php 
        }
        if ($this->admin_image_div_callback) {
            call_user_func($this->admin_image_div_callback);
        } else {
            ?>
<h3><?php 
            _e('Background Image');
            ?>
</h3>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row"><?php 
            _e('Preview');
            ?>
</th>
<td>
<?php 
            $background_styles = '';
            if ($bgcolor = get_background_color()) {
                $background_styles .= 'background-color: #' . $bgcolor . ';';
            }
            if (get_background_image()) {
                // background-image URL must be single quote, see below
                $background_styles .= ' background-image: url(\'' . get_theme_mod('background_image_thumb', '') . '\');' . ' background-repeat: ' . get_theme_mod('background_repeat', 'repeat') . ';' . ' background-position: top ' . get_theme_mod('background_position_x', 'left');
            }
            ?>
<div id="custom-background-image" style="<?php 
            echo $background_styles;
            ?>
"><?php 
            // must be double quote, see above
            if (get_background_image()) {
                ?>
<img class="custom-background-image" src="<?php 
                echo get_theme_mod('background_image_thumb', '');
                ?>
" style="visibility:hidden;" alt="" /><br />
<img class="custom-background-image" src="<?php 
                echo get_theme_mod('background_image_thumb', '');
                ?>
" style="visibility:hidden;" alt="" />
<?php 
            }
            ?>
</div>
<?php 
        }
        ?>
</td>
</tr>
<?php 
        if (get_background_image()) {
            ?>
<tr valign="top">
<th scope="row"><?php 
            _e('Remove Image');
            ?>
</th>
<td>
<form method="post" action="">
<?php 
            wp_nonce_field('custom-background-remove', '_wpnonce-custom-background-remove');
            submit_button(__('Remove Background Image'), 'button', 'remove-background', false);
            ?>
<br/>
<?php 
            _e('This will remove the background image. You will not be able to restore any customizations.');
            ?>
</form>
</td>
</tr>
<?php 
        }
        ?>

<?php 
        if (get_theme_support('custom-background', 'default-image')) {
            ?>
<tr valign="top">
<th scope="row"><?php 
            _e('Restore Original Image');
            ?>
</th>
<td>
<form method="post" action="">
<?php 
            wp_nonce_field('custom-background-reset', '_wpnonce-custom-background-reset');
            submit_button(__('Restore Original Image'), 'button', 'reset-background', false);
            ?>
<br/>
<?php 
            _e('This will restore the original background image. You will not be able to restore any customizations.');
            ?>
</form>
</td>
</tr>

<?php 
        }
        ?>
<tr valign="top">
<th scope="row"><?php 
        _e('Upload Image');
        ?>
</th>
<td><form enctype="multipart/form-data" id="upload-form" method="post" action="">
<label for="upload"><?php 
        _e('Choose an image from your computer:');
        ?>
</label><br /><input type="file" id="upload" name="import" />
<input type="hidden" name="action" value="save" />
<?php 
        wp_nonce_field('custom-background-upload', '_wpnonce-custom-background-upload');
        submit_button(__('Upload'), 'button', 'submit', false);
        $image_library_url = get_upload_iframe_src('image', null, 'library');
        $image_library_url = remove_query_arg('TB_iframe', $image_library_url);
        $image_library_url = add_query_arg(array('context' => 'custom-background', 'TB_iframe' => 1), $image_library_url);
        ?>
	</form>
	<span class="howto"><?php 
        _ex('or', 'Custom Background: Choose an image from your computer - or - Choose from image library');
        ?>
</span> <a class="thickbox" href="<?php 
        echo $image_library_url;
        ?>
"><?php 
        _e('Choose from image library');
        ?>
</a>
</td>
</tr>
</tbody>
</table>

<h3><?php 
        _e('Display Options');
        ?>
</h3>
<form method="post" action="">
<table class="form-table">
<tbody>
<?php 
        if (get_background_image()) {
            ?>
<tr valign="top">
<th scope="row"><?php 
            _e('Position');
            ?>
</th>
<td><fieldset><legend class="screen-reader-text"><span><?php 
            _e('Background Position');
            ?>
</span></legend>
<label>
<input name="background-position-x" type="radio" value="left"<?php 
            checked('left', get_theme_mod('background_position_x', 'left'));
            ?>
 />
<?php 
            _e('Left');
            ?>
</label>
<label>
<input name="background-position-x" type="radio" value="center"<?php 
            checked('center', get_theme_mod('background_position_x', 'left'));
            ?>
 />
<?php 
            _e('Center');
            ?>
</label>
<label>
<input name="background-position-x" type="radio" value="right"<?php 
            checked('right', get_theme_mod('background_position_x', 'left'));
            ?>
 />
<?php 
            _e('Right');
            ?>
</label>
</fieldset></td>
</tr>

<tr valign="top">
<th scope="row"><?php 
            _e('Repeat');
            ?>
</th>
<td><fieldset><legend class="screen-reader-text"><span><?php 
            _e('Background Repeat');
            ?>
</span></legend>
<label><input type="radio" name="background-repeat" value="no-repeat"<?php 
            checked('no-repeat', get_theme_mod('background_repeat', 'repeat'));
            ?>
 /> <?php 
            _e('No Repeat');
            ?>
</label>
	<label><input type="radio" name="background-repeat" value="repeat"<?php 
            checked('repeat', get_theme_mod('background_repeat', 'repeat'));
            ?>
 /> <?php 
            _e('Tile');
            ?>
</label>
	<label><input type="radio" name="background-repeat" value="repeat-x"<?php 
            checked('repeat-x', get_theme_mod('background_repeat', 'repeat'));
            ?>
 /> <?php 
            _e('Tile Horizontally');
            ?>
</label>
	<label><input type="radio" name="background-repeat" value="repeat-y"<?php 
            checked('repeat-y', get_theme_mod('background_repeat', 'repeat'));
            ?>
 /> <?php 
            _e('Tile Vertically');
            ?>
</label>
</fieldset></td>
</tr>

<tr valign="top">
<th scope="row"><?php 
            _e('Attachment');
            ?>
</th>
<td><fieldset><legend class="screen-reader-text"><span><?php 
            _e('Background Attachment');
            ?>
</span></legend>
<label>
<input name="background-attachment" type="radio" value="scroll" <?php 
            checked('scroll', get_theme_mod('background_attachment', 'scroll'));
            ?>
 />
<?php 
            _e('Scroll');
            ?>
</label>
<label>
<input name="background-attachment" type="radio" value="fixed" <?php 
            checked('fixed', get_theme_mod('background_attachment', 'scroll'));
            ?>
 />
<?php 
            _e('Fixed');
            ?>
</label>
</fieldset></td>
</tr>
<?php 
        }
        // get_background_image()
        ?>
<tr valign="top">
<th scope="row"><?php 
        _e('Background Color');
        ?>
</th>
<td><fieldset><legend class="screen-reader-text"><span><?php 
        _e('Background Color');
        ?>
</span></legend>
<?php 
        $show_clear = get_background_color() ? '' : ' style="display:none"';
        ?>
<input type="text" name="background-color" id="background-color" value="#<?php 
        echo esc_attr(get_background_color());
        ?>
" />
<a class="hide-if-no-js" href="#" id="pickcolor"><?php 
        _e('Select a Color');
        ?>
</a> <span<?php 
        echo $show_clear;
        ?>
 class="hide-if-no-js" id="clearcolor"> (<a href="#"><?php 
        _e('Clear');
        ?>
</a>)</span>
<div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
</fieldset></td>
</tr>
</tbody>
</table>

<?php 
        wp_nonce_field('custom-background');
        submit_button(null, 'primary', 'save-background-options');
        ?>
</form>

</div>
<?php 
    }
Example #21
0
    /**
     * Display first step of custom header image page.
     *
     * @since 2.1.0
     */
    function step_1()
    {
        $this->process_default_headers();
        ?>

<div class="wrap">
<?php 
        screen_icon();
        ?>
<h2><?php 
        _e('Custom Header');
        ?>
</h2>

<?php 
        if (!empty($this->updated)) {
            ?>
<div id="message" class="updated">
<p><?php 
            printf(__('Header updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url('/'));
            ?>
</p>
</div>
<?php 
        }
        ?>

<h3><?php 
        _e('Header Image');
        ?>
</h3>

<table class="form-table">
<tbody>

<tr valign="top">
<th scope="row"><?php 
        _e('Preview');
        ?>
</th>
<td>
	<?php 
        if ($this->admin_image_div_callback) {
            call_user_func($this->admin_image_div_callback);
        } else {
            ?>
	<div id="headimg" style="background-image:url(<?php 
            esc_url(header_image());
            ?>
);max-width:<?php 
            echo get_custom_header()->width;
            ?>
px;height:<?php 
            echo get_custom_header()->height;
            ?>
px;">
		<?php 
            if (display_header_text()) {
                $style = ' style="color:#' . get_header_textcolor() . ';"';
            } else {
                $style = ' style="display:none;"';
            }
            ?>
		<h1><a id="name" class="displaying-header-text" <?php 
            echo $style;
            ?>
 onclick="return false;" href="<?php 
            bloginfo('url');
            ?>
"><?php 
            bloginfo('name');
            ?>
</a></h1>
		<div id="desc" class="displaying-header-text" <?php 
            echo $style;
            ?>
><?php 
            bloginfo('description');
            ?>
</div>
	</div>
	<?php 
        }
        ?>
</td>
</tr>
<?php 
        if (current_theme_supports('custom-header', 'uploads')) {
            ?>
<tr valign="top">
<th scope="row"><?php 
            _e('Upload Image');
            ?>
</th>
<td>
	<p><?php 
            _e('You can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.');
            ?>
<br />
	<?php 
            if (!current_theme_supports('custom-header', 'flex-height') && !current_theme_supports('custom-header', 'flex-width')) {
                printf(__('Images of exactly <strong>%1$d &times; %2$d pixels</strong> will be used as-is.') . '<br />', get_theme_support('custom-header', 'width'), get_theme_support('custom-header', 'height'));
            } elseif (current_theme_supports('custom-header', 'flex-height')) {
                if (!current_theme_supports('custom-header', 'flex-width')) {
                    printf(__('Images should be at least <strong>%1$d pixels</strong> wide.') . ' ', get_theme_support('custom-header', 'width'));
                }
            } elseif (current_theme_supports('custom-header', 'flex-width')) {
                if (!current_theme_supports('custom-header', 'flex-height')) {
                    printf(__('Images should be at least <strong>%1$d pixels</strong> tall.') . ' ', get_theme_support('custom-header', 'height'));
                }
            }
            if (current_theme_supports('custom-header', 'flex-height') || current_theme_supports('custom-header', 'flex-width')) {
                if (current_theme_supports('custom-header', 'width')) {
                    printf(__('Suggested width is <strong>%1$d pixels</strong>.') . ' ', get_theme_support('custom-header', 'width'));
                }
                if (current_theme_supports('custom-header', 'height')) {
                    printf(__('Suggested height is <strong>%1$d pixels</strong>.') . ' ', get_theme_support('custom-header', 'height'));
                }
            }
            ?>
</p>
	<form enctype="multipart/form-data" id="upload-form" method="post" action="<?php 
            echo esc_attr(add_query_arg('step', 2));
            ?>
">
	<p>
		<label for="upload"><?php 
            _e('Choose an image from your computer:');
            ?>
</label><br />
		<input type="file" id="upload" name="import" />
		<input type="hidden" name="action" value="save" />
		<?php 
            wp_nonce_field('custom-header-upload', '_wpnonce-custom-header-upload');
            ?>
		<?php 
            submit_button(__('Upload'), 'button', 'submit', false);
            ?>
	</p>
	</form>
	<?php 
            $image_library_url = get_upload_iframe_src('image', null, 'library');
            $image_library_url = remove_query_arg('TB_iframe', $image_library_url);
            $image_library_url = add_query_arg(array('context' => 'custom-header', 'TB_iframe' => 1), $image_library_url);
            ?>
	<span class="howto"><?php 
            _ex('or', 'Custom Header: Choose an image from your computer - or - Choose from image library');
            ?>
</span> <a class="thickbox" href="<?php 
            echo $image_library_url;
            ?>
"><?php 
            _e('Choose from image library');
            ?>
</a>
</td>
</tr>
<?php 
        }
        ?>
</tbody>
</table>

<form method="post" action="<?php 
        echo esc_attr(add_query_arg('step', 1));
        ?>
">
<table class="form-table">
<tbody>
	<?php 
        if (get_uploaded_header_images()) {
            ?>
<tr valign="top">
<th scope="row"><?php 
            _e('Uploaded Images');
            ?>
</th>
<td>
	<p><?php 
            _e('You can choose one of your previously uploaded headers, or show a random one.');
            ?>
</p>
	<?php 
            $this->show_header_selector('uploaded');
            ?>
</td>
</tr>
	<?php 
        }
        if (!empty($this->default_headers)) {
            ?>
<tr valign="top">
<th scope="row"><?php 
            _e('Default Images');
            ?>
</th>
<td>
<?php 
            if (current_theme_supports('custom-header', 'uploads')) {
                ?>
	<p><?php 
                _e('If you don&lsquo;t want to upload your own image, you can use one of these cool headers, or show a random one.');
                ?>
</p>
<?php 
            } else {
                ?>
	<p><?php 
                _e('You can use one of these cool headers or show a random one on each page.');
                ?>
</p>
<?php 
            }
            ?>
	<?php 
            $this->show_header_selector('default');
            ?>
</td>
</tr>
	<?php 
        }
        if (get_header_image()) {
            ?>
<tr valign="top">
<th scope="row"><?php 
            _e('Remove Image');
            ?>
</th>
<td>
	<p><?php 
            _e('This will remove the header image. You will not be able to restore any customizations.');
            ?>
</p>
	<?php 
            submit_button(__('Remove Header Image'), 'button', 'removeheader', false);
            ?>
</td>
</tr>
	<?php 
        }
        if (current_theme_supports('custom-header', 'default-image')) {
            ?>
<tr valign="top">
<th scope="row"><?php 
            _e('Reset Image');
            ?>
</th>
<td>
	<p><?php 
            _e('This will restore the original header image. You will not be able to restore any customizations.');
            ?>
</p>
	<?php 
            submit_button(__('Restore Original Header Image'), 'button', 'resetheader', false);
            ?>
</td>
</tr>
	<?php 
        }
        ?>
</tbody>
</table>

<?php 
        if (current_theme_supports('custom-header', 'header-text')) {
            ?>

<h3><?php 
            _e('Header Text');
            ?>
</h3>

<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row"><?php 
            _e('Header Text');
            ?>
</th>
<td>
	<p>
	<label><input type="checkbox" name="display-header-text" id="display-header-text"<?php 
            checked(display_header_text());
            ?>
 /> <?php 
            _e('Show header text with your image.');
            ?>
</label>
	</p>
</td>
</tr>

<tr valign="top" class="displaying-header-text">
<th scope="row"><?php 
            _e('Text Color');
            ?>
</th>
<td>
	<p>
<?php 
            if (display_header_text()) {
                ?>
		<input type="text" name="text-color" id="text-color" value="#<?php 
                echo esc_attr(get_header_textcolor());
                ?>
" />
<?php 
            } else {
                ?>
		<input type="text" name="text-color" id="text-color" value="#<?php 
                echo esc_attr(get_theme_support('custom-header', 'default-text-color'));
                ?>
" />
<?php 
            }
            ?>
		<a href="#" class="hide-if-no-js" id="pickcolor"><?php 
            _e('Select a Color');
            ?>
</a>
	</p>
	<div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
</td>
</tr>

	<?php 
            if (current_theme_supports('custom-header', 'default-text-color') && get_theme_mod('header_textcolor')) {
                ?>
<tr valign="top">
<th scope="row"><?php 
                _e('Reset Text Color');
                ?>
</th>
<td>
	<p><?php 
                _e('This will restore the original header text. You will not be able to restore any customizations.');
                ?>
</p>
	<?php 
                submit_button(__('Restore Original Header Text'), 'button', 'resettext', false);
                ?>
</td>
</tr>
	<?php 
            }
            ?>

</tbody>
</table>
<?php 
        }
        do_action('custom_header_options');
        wp_nonce_field('custom-header-options', '_wpnonce-custom-header-options');
        ?>

<?php 
        submit_button(null, 'primary', 'save-header-options');
        ?>
</form>
</div>

<?php 
    }
Example #22
0
 function _set_featured_image_link_to_gallery_tab($html)
 {
     return str_replace(esc_url(get_upload_iframe_src('image')), add_query_arg('tab', 'gallery', esc_url(get_upload_iframe_src('image'))), $html);
 }
 /**
  * Output HTML for the post thumbnail meta-box.
  *
  * @see wp-admin\includes\post.php
  * @param int $thumbnail_id ID of the image used for thumbnail
  * @return string html output
  */
 function _wp_post_thumbnail_html($thumbnail_id = NULL)
 {
     global $_wp_additional_image_sizes, $post_ID;
     $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__('Set featured image') . '" href="' . esc_url(get_upload_iframe_src('image')) . '" id="set-post-thumbnail" class="thickbox">%s</a></p>';
     $content = sprintf($set_thumbnail_link, esc_html__('Set featured image'));
     $image = nggdb::find_image($thumbnail_id);
     $img_src = false;
     // get the options
     $ngg_options = nggGallery::get_option('ngg_options');
     if ($image) {
         if (is_array($_wp_additional_image_sizes) && isset($_wp_additional_image_sizes['post-thumbnail'])) {
             // Use post thumbnail settings if defined
             $width = absint($_wp_additional_image_sizes['post-thumbnail']['width']);
             $height = absint($_wp_additional_image_sizes['post-thumbnail']['height']);
             $mode = $_wp_additional_image_sizes['post-thumbnail']['crop'] ? 'crop' : '';
             // check fo cached picture
             $img_src = $image->cached_singlepic_file($width, $height, $mode);
         }
         // if we didn't use a cached image then we take the on-the-fly mode
         if ($img_src == false) {
             $img_src = trailingslashit(home_url()) . 'index.php?callback=image&amp;pid=' . $image->pid . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;mode=crop';
         }
         $thumbnail_html = '<img width="266" src="' . $img_src . '" alt="' . $image->alttext . '" title="' . $image->alttext . '" />';
         if (!empty($thumbnail_html)) {
             $ajax_nonce = wp_create_nonce("set_post_thumbnail-{$post_ID}");
             $content = sprintf($set_thumbnail_link, $thumbnail_html);
             $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__('Remove featured image') . '</a></p>';
         }
     }
     return $content;
 }
<?php

//html of advertisement of image
global $wpdb;
?>
<h2>Advertisement image</h2>
<div id="advertisement_image_div">
	<?php 
// Get WordPress' media upload URL
$upload_link = esc_url(get_upload_iframe_src('image', $user->ID));
// See if there's a media id already saved as post meta
$adv_img_id = $wpdb->get_results("SELECT image_id FROM wp_advertisement_images WHERE user_id=" . $user->ID . "", OBJECT);
if ($adv_img_id) {
    $adv_img_id = $adv_img_id[0]->image_id;
}
// Get the image src
$adv_img_src = wp_get_attachment_image_src($adv_img_id, 'full');
// For convenience, see if the array is valid
$adv_img = is_array($adv_img_src);
?>

	<!-- Your image container, which can be manipulated with js -->
	<div class="custom-img-container">
		<?php 
if ($adv_img) {
    ?>
			<img src="<?php 
    echo $adv_img_src[0];
    ?>
" alt="" style="max-width:100%;" />
		<?php 
Example #25
0
/**
 * Output HTML for the post thumbnail meta-box.
 *
 * @since 2.9.0
 *
 * @param int $thumbnail_id ID of the attachment used for thumbnail
 * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
 * @return string html
 */
function _wp_post_thumbnail_html($thumbnail_id = null, $post = null)
{
    global $content_width, $_wp_additional_image_sizes;
    $post = get_post($post);
    $upload_iframe_src = esc_url(get_upload_iframe_src('image', $post->ID));
    $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__('Set featured image') . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
    $content = sprintf($set_thumbnail_link, $upload_iframe_src, esc_html__('Set featured image'));
    if ($thumbnail_id && get_post($thumbnail_id)) {
        $old_content_width = $content_width;
        $content_width = 266;
        if (!isset($_wp_additional_image_sizes['post-thumbnail'])) {
            $thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
        } else {
            $thumbnail_html = wp_get_attachment_image($thumbnail_id, 'post-thumbnail');
        }
        if (!empty($thumbnail_html)) {
            $ajax_nonce = wp_create_nonce('set_post_thumbnail-' . $post->ID);
            $content = sprintf($set_thumbnail_link, $upload_iframe_src, $thumbnail_html);
            $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__('Remove featured image') . '</a></p>';
        }
        $content_width = $old_content_width;
    }
    return apply_filters('admin_post_thumbnail_html', $content, $post->ID);
}
Example #26
0
function custom_second_featured_image()
{
    global $post;
    // Meta key (need to update the save_metabox function below to reflect this too!)
    $meta_key = '_second_post_thumbnail';
    // Get WordPress' media upload URL
    $upload_link = esc_url(get_upload_iframe_src('image', $post->ID));
    // See if there's a media id already saved as post meta
    $image_id = get_post_meta($post->ID, $meta_key, true);
    // Get the image src
    $image_src = wp_get_attachment_image_src($image_id, 'post-thumbnail');
    // For convenience, see if the array is valid
    $has_image = is_array($image_src);
    ?>
        
        <div class="custom-meta custom-image-uploader">

            <!-- A hidden input to set and post the chosen image id -->
            <input class="custom-image-id" name="<?php 
    echo $meta_key;
    ?>
" type="hidden" value="<?php 
    echo $image_id;
    ?>
" />        
        
            <!-- Image container, which is manipulated with js -->
            <div class="custom-image-container">
                <?php 
    if ($has_image) {
        ?>
                    <img src="<?php 
        echo $image_src[0];
        ?>
"/>
                <?php 
    }
    ?>
            </div>
            
            <!-- Add & remove image links -->
            <p class="hide-if-no-js">
                <a class="upload-custom-image <?php 
    if ($has_image) {
        echo 'hidden';
    }
    ?>
" href="<?php 
    echo $upload_link;
    ?>
">
                    <?php 
    _e('Set banner ad');
    ?>
                </a>
                <a class="delete-custom-image <?php 
    if (!$has_image) {
        echo 'hidden';
    }
    ?>
" href="#">
                    <?php 
    _e('Remove banner ad');
    ?>
                </a>
            </p>

        </div>

        <?php 
}
 /**
  * Output the post thumbnail HTML for the metabox and AJAX callbacks
  *
  * @param string $thumbnail_id The thumbnail's post ID.
  * @return string HTML
  */
 private function post_thumbnail_html($thumbnail_id = NULL)
 {
     global $content_width, $_wp_additional_image_sizes, $post_ID;
     $set_thumbnail_link = sprintf('<p class="hide-if-no-js"><a title="%1$s" href="%2$s" id="set-%3$s-%4$s-thumbnail" class="thickbox">%%s</a></p>', esc_attr__("Set {$this->label}"), get_upload_iframe_src('image'), $this->post_type, $this->id);
     $content = sprintf($set_thumbnail_link, esc_html__("Set {$this->label}"));
     if ($thumbnail_id && get_post($thumbnail_id)) {
         $old_content_width = $content_width;
         $content_width = 266;
         if (!isset($_wp_additional_image_sizes["{$this->post_type}-{$this->id}-thumbnail"])) {
             $thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
         } else {
             $thumbnail_html = wp_get_attachment_image($thumbnail_id, "{$this->post_type}-{$this->id}-thumbnail");
         }
         if (!empty($thumbnail_html)) {
             $ajax_nonce = wp_create_nonce("set_post_thumbnail-{$this->post_type}-{$this->id}-{$post_ID}");
             $content = sprintf($set_thumbnail_link, $thumbnail_html);
             $content .= sprintf('<p class="hide-if-no-js"><a href="#" id="remove-%1$s-%2$s-thumbnail" onclick="MultiPostThumbnailsRemoveThumbnail(\'%2$s\', \'%1$s\', \'%4$s\');return false;">%3$s</a></p>', $this->post_type, $this->id, esc_html__("Remove {$this->label}"), $ajax_nonce);
         }
         $content_width = $old_content_width;
     }
     return $content;
 }
/**
 * Output HTML for the post thumbnail meta-box.
 *
 * @since 2.9.0
 *
 * @global int   $content_width
 * @global array $_wp_additional_image_sizes
 *
 * @param int $thumbnail_id ID of the attachment used for thumbnail
 * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
 * @return string html
 */
function _wp_post_thumbnail_html($thumbnail_id = null, $post = null)
{
    global $content_width, $_wp_additional_image_sizes;
    $post = get_post($post);
    $post_type_object = get_post_type_object($post->post_type);
    $set_thumbnail_link = '<p class="hide-if-no-js"><a title="%s" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
    $upload_iframe_src = get_upload_iframe_src('image', $post->ID);
    $content = sprintf($set_thumbnail_link, esc_attr($post_type_object->labels->set_featured_image), esc_url($upload_iframe_src), esc_html($post_type_object->labels->set_featured_image));
    if ($thumbnail_id && get_post($thumbnail_id)) {
        $size = isset($_wp_additional_image_sizes['post-thumbnail']) ? 'post-thumbnail' : array(266, 266);
        /**
         * Filter the size used to display the post thumbnail image in the 'Featured Image' meta box.
         *
         * Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail'
         * image size is registered, which differs from the 'thumbnail' image size
         * managed via the Settings > Media screen. See the `$size` parameter description
         * for more information on default values.
         *
         * @since 4.4.0
         *
         * @param string|array $size         Post thumbnail image size to display in the meta box. Accepts any valid
         *                                   image size, or an array of width and height values in pixels (in that order).
         *                                   If the 'post-thumbnail' size is set, default is 'post-thumbnail'. Otherwise,
         *                                   default is an array with 266 as both the height and width values.
         * @param int          $thumbnail_id Post thumbnail attachment ID.
         * @param WP_Post      $post         The post object associated with the thumbnail.
         */
        $size = apply_filters('admin_post_thumbnail_size', $size, $thumbnail_id, $post);
        $thumbnail_html = wp_get_attachment_image($thumbnail_id, $size);
        if (!empty($thumbnail_html)) {
            $ajax_nonce = wp_create_nonce('set_post_thumbnail-' . $post->ID);
            $content = sprintf($set_thumbnail_link, esc_attr($post_type_object->labels->set_featured_image), esc_url($upload_iframe_src), $thumbnail_html);
            $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html($post_type_object->labels->remove_featured_image) . '</a></p>';
        }
    }
    /**
     * Filter the admin post thumbnail HTML markup to return.
     *
     * @since 2.9.0
     *
     * @param string $content Admin post thumbnail HTML markup.
     * @param int    $post_id Post ID.
     */
    return apply_filters('admin_post_thumbnail_html', $content, $post->ID);
}
Example #29
0
    echo $company->logo;
    ?>
">
                                <a href="#" class="remove-logo"><?php 
    _e('Remove company logo', 'wp-erp');
    ?>
</a>
                            </p>

                        <?php 
} else {
    ?>

                            <p class="hide-if-no-js">
                                <a href="<?php 
    echo get_upload_iframe_src('image');
    ?>
" id="set-company-thumbnail" class="thickbox"><?php 
    _e('Upload company logo', 'wp-erp');
    ?>
</a>
                            </p>

                        <?php 
}
?>
                    </div>
                </div><!-- .postbox -->

                <div class="postbox company-postbox">
                    <h3 class="hndle"><span><?php 
/**
 * We really need to either bake this functionality in for 3.9.0 or rip it out into Gold Cart or something else.
 * So not awesome to have this exposed and unusable.
 *
 * @param  WP_Post $post Product
 * @return void
 */
function wpsc_product_gallery($post)
{
    // pull the old iframe source for non JS users
    $upload_iframe_src = esc_url(get_upload_iframe_src('image', $post->ID));
    // get our gallery image IDs if present
    $images = wpsc_get_admin_product_gallery($post->ID);
    // begin HTML output
    $output = '<div id="wpsc_product_gallery">';
    $output .= '<ul>';
    // check for images before beginngin loop
    if ($images) {
        // now loop images
        foreach ($images as $image_id) {
            // get the thumbnail URL
            $thumb_url = wp_get_attachment_thumb_url(absint($image_id));
            // output each item
            $output .= '<li><div class="list_gallery_image">';
            $output .= '<img src="' . esc_url($thumb_url) . '">';
            $output .= '<input type="hidden" name="wpsc-product-gallery-imgs[]" value="' . absint($image_id) . '">';
            $output .= '<span class="product_gallery_image_delete_button dashicons dashicons-no-alt"></span></div>';
            $output .= '<input type="hidden" class="product_gallery_image_id" value="' . $image_id . '">';
            $output .= '<input type="hidden" class="product_gallery_post_id" value="' . $post->ID . '">';
            $output .= '</li>';
        }
    }
    $output .= '</ul>';
    $output .= '<div class="clear"></div>';
    $output .= '</div>';
    $nonce_var = wp_create_nonce('wpsc_gallery_nonce');
    ?>
  <input type="hidden" class="nonce_class" value="<?php 
    echo $nonce_var;
    ?>
">
  <?php 
    // button for old iframe for non JS people
    $output .= '<p class="hide-if-no-js">';
    $output .= '<a class="button button-small thickbox" title="' . esc_attr__('Manage Product Image Gallery...', 'wp-e-commerce') . '" href="' . $upload_iframe_src . '" id="wpsc-manage-product-gallery">';
    $output .= esc_html__('Manage Product Image Gallery...', 'wp-e-commerce');
    $output .= '</a>';
    $output .= '</p>';
    // include a nonce for verification
    $output .= wp_nonce_field('wpec_product_gallery_nonce', 'wpec_product_gallery_nonce', false, false);
    // echo the gallery output
    echo $output;
}