/** * Get menu item meta value * * @since 0.3.0 * @since 0.9.0 Add $defaults parameter. * @param int $id Menu item ID. * @param array $defaults Optional. Default value. * @return array */ public static function get($id, $defaults = array()) { $defaults = wp_parse_args($defaults, self::$defaults); $value = get_post_meta($id, self::KEY, true); $value = wp_parse_args((array) $value, $defaults); // Backward-compatibility. if (empty($value['icon']) && !empty($value['type']) && !empty($value["{$value['type']}-icon"])) { $value['icon'] = $value["{$value['type']}-icon"]; } if (!empty($value['width'])) { $value['svg_width'] = $value['width']; } unset($value['width']); if (isset($value['position']) && !in_array($value['position'], array('before', 'after'))) { $value['position'] = $defaults['position']; } if (isset($value['size']) && !isset($value['font_size'])) { $value['font_size'] = $value['size']; unset($value['size']); } // The values below will NOT be saved if (!empty($value['icon']) && in_array($value['type'], array('image', 'svg'))) { $value['url'] = wp_get_attachment_image_url($value['icon'], 'thumbnail', false); } return $value; }
function get_the_post_thumbnail_url($post = null, $size = 'post-thumbnail') { $post_thumbnail_id = get_post_thumbnail_id($post); if (!$post_thumbnail_id) { return false; } return wp_get_attachment_image_url($post_thumbnail_id, $size); }
public function get_html_noresp($media_id, $size = null, array $attrs = array(), $square = false, $use_fallback = false) { $img_src = wp_get_attachment_image_url($media_id, $size); if (empty($img_src)) { $result = $use_fallback ? call_user_func_array(array($this, 'get_html_fallback'), func_get_args()) : false; return $result; } $attrs = array_merge(array('src' => $img_src), $attrs); $result = \Cibulka::Base('HTML', 'img', $attrs, true); return $result; }
/** * Get Icon URL * * @since 0.2.0 * * @param string $type Icon type. * @param mixed $id Icon ID. * @param string $size Optional. Icon size, defaults to 'thumbnail'. * * @return string */ function icon_picker_get_icon_url($type, $id, $size = 'thumbnail') { $url = ''; if (!in_array($type, array('image', 'svg'))) { return $url; } if (empty($id)) { return $url; } return wp_get_attachment_image_url($id, $size, false); }
protected function formatted_items($type) { $formatted_items = []; switch ($type) { case 'tree-selection': foreach ($this->items as $tree) { $attachment_id = get_post_thumbnail_id($tree->ID); $img_thumb_url = wp_get_attachment_image_src($attachment_id, 'selection-thumb'); $img_url = wp_get_attachment_image_url($attachment_id, 'full'); $formatted_items[] = array('ID' => ForestUtils::get_instance()->get_js_object(array('ID' => $tree->ID, 'title' => $tree->post_title), true), 'post_title' => $tree->post_title, 'img' => sprintf('<a href="%s" class="thickbox"><img src="%s" style="width:%dpx;height:%dpx"/></a>', $img_url, $img_thumb_url[0], $img_thumb_url[1], $img_thumb_url[2])); } break; } return $formatted_items; }
function cultiv8_get_site_logo() { if (function_exists('get_custom_logo')) { // Try to use WP4.5 built in site logo feature return wp_get_attachment_image_url(get_theme_mod('custom_logo'), 'full'); } elseif (function_exists('jetpack_get_site_logo')) { // If not available, try Jetpack's site logo feature return jetpack_get_site_logo(); } else { // Last resort, try our own feature if (get_theme_mod('cultiv8_site_logo')) { return get_theme_mod('cultiv8_site_logo'); } else { return ''; } } }
public function get_company_info($mode = '', $for_date = null, $logo_size = 'medium') { $company = Util::get_relevant($this->get_meta('company'), $for_date); if (empty($mode)) { return $company; } switch ($mode) { case 'name': return $company['name']; case 'logo_url': return wp_get_attachment_image_url($company['logo'], $logo_size); case 'logo_path': return Util::get_attachment_image_path($company['logo'], $logo_size); case 'logo_id': default: return $company['logo']; } }
/** * Convert markdown image to html image tag * * @return string */ public function convert() { $time = get_the_time('Y/m', $this->post_id); $wp_upload_dir = wp_upload_dir($time, $this->post_id); $this->upload_url = untrailingslashit($wp_upload_dir['url']); return preg_replace_callback('/\\!\\[(.*?)\\]\\((.+?)\\)/sm', function ($matches) { $pathinfo = pathinfo($matches[2]); $Unicode_Normalization = new Markdown_Importer_Unicode_Normalization($matches[2]); $filename = $Unicode_Normalization->convert(); $filename = sha1($filename) . '.' . $pathinfo['extension']; $attachment_url = $this->upload_url . '/' . $filename; $attachment_id = attachment_url_to_postid($attachment_url); $full = wp_get_attachment_image_url($attachment_id, 'full'); $large = wp_get_attachment_image_url($attachment_id, 'large'); if (!$full || !$large) { return; } return sprintf('<a class="markdown-importer-image-link" href="%1$s"><img class="size-large wp-image-%2$d markdown-importer-image" src="%3$s" alt="%4$s" /></a>', esc_url($full), esc_attr($attachment_id), esc_url($large), esc_attr($matches[1])); }, $this->content); }
/** * */ function gannet_responsive_thumbnail($attachment_id) { $src = wp_get_attachment_image_url($attachment_id, 'medium'); $srcset = wp_get_attachment_image_srcset($attachment_id, 'medium'); $alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); ?> <img src="<?php echo esc_url($src); ?> " class="post-thumbnail" alt="<?php echo esc_textarea($alt); ?> " srcset="<?php echo esc_attr($srcset); ?> " sizes="768px, (min-width: 768px) 300px"> <?php }
/** * @return string */ protected function get_brick_html() { // Some stuff just to show off features $this->set_data_item('demo_data_item', 'I am some test data set on the fly by the brick.'); $this->set_data_item('demo_data_item', 'I am some test data set on the fly by the brick in a group.', true, 'demo_group'); $this->set_data_item('demo_data_item_2', 'I am some _more_ test data set on the fly by the brick in a group.', true, 'demo_group'); // Example of how to check if brick has layout // var_dump($this->has_brick_layout('demo-layout-1')); // Example of how to get all layouts // var_dump($this->get_brick_layouts()); $bg_img = $this->get_field('bg_img'); if (!empty($bg_img)) { $this->set_inline_css('padding-top', '50px'); $this->set_inline_css('background-image', 'url(' . wp_get_attachment_image_url($bg_img, 'full') . ')', 'inner'); } $this->set_inline_css('border', 'solid 2px #000', 'inner'); $html = ' <div class="row"> <div class="col-xs-12"> <h2>' . $this->get_field('headline') . '</h2> </div> </div> <div class="row"> <div class="col-xs-12"> <ul>'; if ($this->have_rows('buttons')) { while ($this->have_rows('buttons')) { $this->the_row(); $html .= '<li>' . $this->get_child_brick_in_repeater('buttons', 'button', 'demo_button')->get_html() . '</li>'; } } $html .= ' </ul> </div> </div> '; return $html; }
/** * Return the markup for an image specifying a different srcset parameter according * to the available densities. * * @since 1.0.0 * @param array $data The image data. * @param string $type The image size. * @param string $breakpoint The breakpoint name. * @return string */ function ev_get_density_image($data, $size = 'full', $breakpoint = 'desktop') { if (empty($data[$breakpoint]['1']['id'])) { return ''; } $src = wp_get_attachment_image_url($data[$breakpoint]['1']['id'], $size); if (empty($src)) { return ''; } $srcset = array(); $densities = ev_get_densities(); array_shift($densities); foreach ($densities as $density => $label) { $density_src = wp_get_attachment_image_url($data[$breakpoint][$density]['id'], $size); if (!empty($density_src)) { $srcset[] = $density_src . ' ' . $density . 'x'; } } $args = array(); if (!empty($srcset)) { $args['srcset'] = esc_attr(implode(', ', $srcset)); } return wp_get_attachment_image($data[$breakpoint]['1']['id'], $size, false, $args); }
// (thumbnail, medium, large, full or custom size) if ($image) { echo wp_get_attachment_image($image, $size); } ?> </div> <?php the_content(); ?> <div class="links-wrap"> <div class="addthis_sharing_toolbox"></div> <!-- <a class="gold-button" href="">Share This Project</a> --> <a class="gold-button" href="">Get a Quote</a> <a class="gold-button" href="">Leave a Review</a> <a class="gold-button" href="<?php echo wp_get_attachment_image_url($image, 'full'); ?> " target="_blank">View Larger Size</a> </div> <?php } ?> <?php } //end regular loop ?> <?php } //end acf conditional featured_at_top ?>
function get_site_icon_url($size = 512, $url = '', $blog_id = 0) { if (is_multisite() && (int) $blog_id !== get_current_blog_id()) { switch_to_blog($blog_id); } $site_icon_id = get_option('site_icon'); if ($site_icon_id) { if ($size >= 512) { $size_data = 'full'; } else { $size_data = array($size, $size); } $url = wp_get_attachment_image_url($site_icon_id, $size_data); } if (is_multisite() && ms_is_switched()) { restore_current_blog(); } return apply_filters('get_site_icon_url', $url, $size, $blog_id); }
public function getUrl($size) { return wp_get_attachment_image_url($this->id, $size); }
<?php $arr = json_decode(stripslashes(Cookie::get('basket')), true, 4); foreach ($arr as $k => $prod) { $priceProd = 0; $countProd = 0; foreach ($prod as $p) { $priceProd += $p['count'] * $p['price']; $countProd += $p['count']; } ?> <!-- open .basket__box--line --> <div class="basket__box--line"> <!-- open .basket__box--thumb --> <div class="basket__box--thumb"> <img src="<?php echo wp_get_attachment_image_url(get_post_thumbnail_id($k)); ?> " alt="" /> </div> <!-- close .basket__box--thumb --> <!-- open .basket__box--info --> <div class="basket__box--info"> <!-- open .basket__box--info--name --> <div class="basket__box--info--name"><?php echo $prod[0]['title']; ?> </div> <!-- close .basket__box--info--name --> <!-- open .basket__box--info--count --> <div class="basket__box--info--count"><?php echo $countProd;
/** * Output the form field * * @since 0.1.0 * * @param $term */ protected function form_field($term = '') { $term_id = !empty($term->term_id) ? $term->term_id : 0; // Remove image URL $remove_url = add_query_arg(array('action' => 'remove-wp-term-images', 'term_id' => $term_id, '_wpnonce' => false)); // Get the meta value $value = $this->get_meta($term_id); $hidden = empty($value) ? ' style="display: none;"' : ''; ?> <div> <img id="wp-term-images-photo" src="<?php echo esc_url(wp_get_attachment_image_url($value, 'full')); ?> "<?php echo $hidden; ?> /> <input type="hidden" name="term-<?php echo esc_attr($this->meta_key); ?> " id="term-<?php echo esc_attr($this->meta_key); ?> " value="<?php echo esc_attr($value); ?> " /> </div> <a class="button-secondary wp-term-images-media"> <?php esc_html_e('Choose Image', 'wp-term-images'); ?> </a> <a href="<?php echo esc_url($remove_url); ?> " class="button wp-term-images-remove"<?php echo $hidden; ?> > <?php esc_html_e('Remove', 'wp-user-avatars'); ?> </a> <?php }
"> <!-- Twitter Cards --> <meta property="twitter:card" content="summary"> <meta property="twitter:site" content="@sophieuliano"> <meta property="twitter:title" content="<?php single_post_title(''); ?> "> <meta property="twitter:description" content="<?php echo strip_tags(get_the_excerpt()); ?> "> <meta property="twitter:creator" content="@sophieuliano"> <meta property="twitter:image" content="<?php if (function_exists('wp_get_attachment_thumb_url')) { echo wp_get_attachment_image_url(get_post_thumbnail_id($post->ID), 'medium', false); } ?> "> <meta property="twitter:url" content="<?php the_permalink(); ?> " /> <meta property="twitter:domain" content="<?php echo site_url(); ?> "> <?php } else { ?> <!-- Open Graph -->
/** * Callback function * @param [type] $atts [description] * @return [type] [description] */ function dunhakdis_team($atts) { extract(shortcode_atts(array('avatar' => '', 'name' => '', 'title' => '', 'website' => '', 'facebook' => '', 'googleplus' => '', 'twitter' => '', 'linkedin' => '', 'about' => ''), $atts)); ob_start(); ?> <div class="dunhakdis-team-container"> <?php if (is_numeric($avatar)) { ?> <?php $avatar = wp_get_attachment_image_url(intval($avatar), 'thumbnail'); ?> <?php } ?> <?php if (!empty($avatar)) { ?> <div class="dunhakdis-team-avatar"> <img class="avatar" src="<?php echo esc_url($avatar); ?> " alt="<?php _e('Profile', 'shoemaker'); ?> "> </div> <?php } ?> <div class="dunhakdis-team-details"> <?php if (!empty($name)) { ?> <h3 class="dunhakdis-team-name"> <?php if (function_exists('vc_build_link')) { ?> <?php $website = vc_build_link($website); ?> <?php if (is_array($website)) { ?> <?php if (!empty($website['url'])) { ?> <?php $website = $website['url']; ?> <?php } ?> <?php } ?> <?php } ?> <?php if (!empty($website)) { ?> <a href="<?php echo esc_url($website); ?> " title="<?php echo esc_attr($name); ?> "> <?php } ?> <?php echo esc_html($name); ?> <?php if (!empty($website)) { ?> </a> <?php } ?> </h3> <?php } ?> <?php if (!empty($title)) { ?> <h4 class="dunhakdis-team-title"> <?php echo esc_html($title); ?> </h4> <?php } ?> <div class="dunhakdis-team-social"> <?php $social_media_collection = array('facebook' => array('icon' => 'fa fa-facebook', 'class' => 'dunhakdis-team-fb', 'link' => $facebook, 'title' => __('Facebook', 'shoemaker')), 'twitter' => array('icon' => 'fa fa-twitter', 'class' => 'dunhakdis-team-tw', 'link' => $twitter, 'title' => __('Twitter', 'shoemaker')), 'googleplus' => array('icon' => 'fa fa-google-plus', 'class' => 'dunhakdis-team-gplus', 'link' => $googleplus, 'title' => __('Google+', 'shoemaker')), 'linkedin' => array('icon' => 'fa fa-linkedin', 'class' => 'dunhakdis-team-linkedin', 'link' => $linkedin, 'title' => __('LinkedIn', 'shoemaker'))); ?> <ul> <?php foreach ($social_media_collection as $social_media) { ?> <?php if (!empty($social_media['link'])) { ?> <li> <a class="<?php echo esc_attr($social_media['class']); ?> " href="<?php echo esc_url($social_media['link']); ?> " title="<?php echo esc_attr($social_media['title']); ?> "> <span class="<?php echo esc_attr($social_media['icon']); ?> "></span> </a> </li> <?php } ?> <?php } ?> </ul> </div> <?php if (!empty($about)) { ?> <div class="dunhakdis-team-about"> <p> <?php echo esc_html($about); ?> </p> </div> <?php } ?> </div><!--.dunhakdis-team-details--> </div> <?php return ob_get_clean(); }
/** * Adds Schema.org markup for order in JSON-LD format. * * @since 2.6.0 * @param mixed $order * @param bool $sent_to_admin (default: false) * @param bool $plain_text (default: false) */ public function order_schema_markup($order, $sent_to_admin = false, $plain_text = false) { if ($plain_text) { return; } $accepted_offers = array(); foreach ($order->get_items() as $item) { if (!apply_filters('woocommerce_order_item_visible', true, $item)) { continue; } $product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item); $is_visible = $product && $product->is_visible(); $item_offered = array('@type' => 'Product', 'name' => apply_filters('woocommerce_order_item_name', $item['name'], $item, $is_visible)); if ($sku = $product->get_sku()) { $item_offered['sku'] = $sku; } if ($is_visible) { $item_offered['url'] = get_permalink($product->get_id()); } else { $item_offered['url'] = get_home_url(); } if ($image_id = $product->get_image_id()) { $item_offered['image'] = wp_get_attachment_image_url($image_id, 'thumbnail'); } $accepted_offer = (object) array('@type' => 'Offer', 'itemOffered' => $item_offered, 'price' => $order->get_line_subtotal($item), 'priceCurrency' => $order->get_order_currency(), 'eligibleQuantity' => (object) array('@type' => 'QuantitativeValue', 'value' => apply_filters('woocommerce_email_order_item_quantity', $item['qty'], $item)), 'url' => get_home_url()); $accepted_offers[] = $accepted_offer; } $markup = array('@context' => 'http://schema.org', '@type' => 'Order', 'merchant' => (object) array('@type' => 'Organization', 'name' => get_bloginfo('name')), 'orderNumber' => strval($order->get_order_number()), 'priceCurrency' => $order->get_order_currency(), 'price' => $order->get_total(), 'acceptedOffer' => count($accepted_offers) > 1 ? $accepted_offers : $accepted_offers[0], 'url' => $order->get_view_order_url()); switch ($order->get_status()) { case 'pending': $markup['orderStatus'] = 'http://schema.org/OrderPaymentDue'; break; case 'processing': $markup['orderStatus'] = 'http://schema.org/OrderProcessing'; break; case 'on-hold': $markup['orderStatus'] = 'http://schema.org/OrderProblem'; break; case 'completed': $markup['orderStatus'] = 'http://schema.org/OrderDelivered'; break; case 'cancelled': $markup['orderStatus'] = 'http://schema.org/OrderCancelled'; break; case 'refunded': $markup['orderStatus'] = 'http://schema.org/OrderReturned'; break; case 'failed': $markup['orderStatus'] = 'http://schema.org/OrderProblem'; break; } if ($sent_to_admin) { $markup['potentialAction'] = (object) array('@type' => 'ViewAction', 'target' => admin_url('post.php?post=' . absint($order->id) . '&action=edit')); } $markup = apply_filters('woocommerce_email_order_schema_markup', $markup, $sent_to_admin, $order); echo '<div style="display:none;"><script type="application/ld+json">' . wp_json_encode((object) $markup) . '</script></div>'; }
} ?> <?php $whois_id = 65; $whois = posts::getPost($whois_id); if ($whois) { $twitter_href = get_theme_mod('twitter_href'); $twitter_href = $twitter_href ? $twitter_href : '#'; $google_href = get_theme_mod('google_href'); $google_href = $google_href ? $google_href : '#'; $facebook_href = get_theme_mod('facebook_href'); $facebook_href = $facebook_href ? $facebook_href : '#'; $youtube_href = get_theme_mod('youtube_href'); $youtube_href = $youtube_href ? $youtube_href : '#'; $whois_bg = wp_get_attachment_image_url(get_post_thumbnail_id($whois_id), 'full'); $whois_bg = $whois_bg ? 'background-image: url(' . $whois_bg . ');' : ''; $site_descr = get_bloginfo('description'); ?> <div style="<?php echo $whois_bg; ?> " class="container-fluid whois-wrap"> <div class="trans-bg"></div> <div class="container"> <div class="row"> <div class="col-md-12 header-wrap"> <h2><?php echo $whois['title']; ?> </h2>
/** * @ticket 33878 */ function test_wp_get_attachment_image_url() { $this->assertFalse(wp_get_attachment_image_url(0)); $post_id = self::factory()->post->create(); $attachment_id = self::factory()->attachment->create_object($this->img_name, $post_id, array('post_mime_type' => 'image/jpeg', 'post_type' => 'attachment')); $image = wp_get_attachment_image_src($attachment_id, 'thumbnail', false); $this->assertEquals($image[0], wp_get_attachment_image_url($attachment_id)); }
alt="<?php echo $thumbs['alt']; ?> " title="<?php echo $thumbs['title']; ?> " > </label> </li> <?php $i = 1; while (the_repeater_field('galeria_de_imagenes')) { $thumb = get_sub_field('gallery_image'); $slide_src = wp_get_attachment_image_url($thumb['id'], 'full-size'); $slides_srcset = wp_get_attachment_image_srcset($thumb['id'], 'full-size'); ?> <li class="slider__extra-images--thumb"> <label for="slider__image--<?php echo $i; ?> " class="slider__extra-images--thumbnail" id="img-dot-<?php echo $i; ?> "> <img src="<?php echo esc_url($img_src); ?> "
<?php get_header(); ?> <?php $hero_bg = wp_get_attachment_image_url(get_post_thumbnail_id($post->ID), 'full'); $hero_bg = $hero_bg ? $hero_bg : get_theme_mod('hero_bg'); $hero_bg = $hero_bg ? 'background-image: url(' . $hero_bg . ');' : ''; ?> <div style="<?php echo $hero_bg; ?> " class="container-fluid hero-wrap inner"> <div class="container"> <div class="row"> <div class="col-md-12"> <h1>404</h1> </div> </div> </div> </div> <article class="container inner"> <?php if (have_posts()) { ?> <div class="text"> <p><?php _e('This page does not exist. :(');
<!-- open .contain --> <div class="contain"> <h3><span><?php echo $catName; ?> </span></h3> <?php foreach ($arr as $k => $v) { ?> <article class="goods__item"> <!-- open .goods__item--img --> <div class="goods__item--img"> <a href="#"> <img src="<?php echo wp_get_attachment_image_url($k); ?> " alt="" /> </a> </div> <!-- close .goods__item--img --> <!-- open .goods__item--info --> <div class="goods__item--info"> <!-- open .goods__item--line --> <?php foreach ($v as $p) { ?> <?php $post = get_post($p); ?> <div class="goods__item--line">
/** * @ticket 33641 */ function test_wp_calculate_image_srcset_no_width() { $file = get_attached_file(self::$large_id); $image_url = wp_get_attachment_image_url(self::$large_id, 'medium'); $image_meta = wp_generate_attachment_metadata(self::$large_id, $file); $size_array = array(0, 0); $srcset = wp_calculate_image_srcset($size_array, $image_url, $image_meta); // The srcset should be false. $this->assertFalse($srcset); }
function slug_get_imagem($object, $field_name, $request) { return wp_get_attachment_image_url($object['featured_media']); }
/** * @package download-image * ajax function to download image */ function ajax_download_image() { $id = intval($_REQUEST['id']); $post = get_post($id); if (empty($post)) { echo 'Wrong post ID'; wp_die(); } $full_url = wp_get_attachment_image_url($id, 'full'); if (!$full_url) { echo 'Error, file does not exists'; } else { $helper = new grabimage_helper(); echo "<a href='{$full_url}' target='_blank'>{$full_url}</a>"; $sizes = array('full', 'large', 'medium', 'thumbnail'); // download attachment foreach ($sizes as $size) { echo '<br/>' . ucfirst($size) . ' size,'; $url = wp_get_attachment_image_url($id, $size); $helper->media_download($url); } } wp_die(); }
var y = -(e.pageY + this.offsetTop) / 10; $(".project-patern").css('background-position', x + 'px ' + y + 'px'); }); </script> <?php } else { ?> <div class="project-name"><?php the_title(); ?> </div> <?php if (get_field("project-image")) { ?> <img src="<?php wp_get_attachment_image_url(the_field("project-image")); ?> " style="width: 100%"> <?php } ?> <div style="clear: both"></div> <?php if ($post->post_content) { ?> <div class="description"> <p class="desc-title"> <?php echo $post->post_title; ?> </p>
/** * Returns the Site Icon URL. * * @since 4.3.0 * * @param int $size Optional. Size of the site icon. Default 512 (pixels). * @param string $url Optional. Fallback url if no site icon is found. Default empty. * @param int $blog_id Optional. ID of the blog to get the site icon for. Default current blog. * @return string Site Icon URL. */ function get_site_icon_url($size = 512, $url = '', $blog_id = 0) { if (is_multisite() && (int) $blog_id !== get_current_blog_id()) { switch_to_blog($blog_id); } $site_icon_id = get_option('site_icon'); if ($site_icon_id) { if ($size >= 512) { $size_data = 'full'; } else { $size_data = array($size, $size); } $url = wp_get_attachment_image_url($site_icon_id, $size_data); } if (is_multisite() && ms_is_switched()) { restore_current_blog(); } /** * Filter the site icon URL. * * @site 4.4.0 * * @param string $url Site icon URL. * @param int $size Size of the site icon. * @param int $blog_id ID of the blog to get the site icon for. */ return apply_filters('get_site_icon_url', $url, $size, $blog_id); }
/** * Generates Order structured data. * * Hooked into `woocommerce_email_order_details` action hook. * * @param WP_Order $order Order data. * @param bool $sent_to_admin Send to admin (default: false). * @param bool $plain_text Plain text email (default: false). */ public function generate_order_data($order, $sent_to_admin = false, $plain_text = false) { if ($plain_text) { return; } $order_statuses = array('pending' => 'http://schema.org/OrderPaymentDue', 'processing' => 'http://schema.org/OrderProcessing', 'on-hold' => 'http://schema.org/OrderProblem', 'completed' => 'http://schema.org/OrderDelivered', 'cancelled' => 'http://schema.org/OrderCancelled', 'refunded' => 'http://schema.org/OrderReturned', 'failed' => 'http://schema.org/OrderProblem'); $markup_offers = array(); foreach ($order->get_items() as $item) { if (!apply_filters('woocommerce_order_item_visible', true, $item)) { continue; } $product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item); $product_exists = is_object($product); $is_visible = $product_exists && $product->is_visible(); $order_url = $sent_to_admin ? admin_url('post.php?post=' . absint($order->get_id()) . '&action=edit') : $order->get_view_order_url(); $markup_offers[] = array('@type' => 'Offer', 'price' => $order->get_line_subtotal($item), 'priceCurrency' => $order->get_currency(), 'priceSpecification' => array('price' => $order->get_line_subtotal($item), 'priceCurrency' => $order->get_currency(), 'eligibleQuantity' => array('@type' => 'QuantitativeValue', 'value' => apply_filters('woocommerce_email_order_item_quantity', $item['qty'], $item))), 'itemOffered' => array('@type' => 'Product', 'name' => apply_filters('woocommerce_order_item_name', $item['name'], $item, $is_visible), 'sku' => $product_exists ? $product->get_sku() : '', 'image' => $product_exists ? wp_get_attachment_image_url($product->get_image_id()) : '', 'url' => $is_visible ? get_permalink($product->get_id()) : get_home_url()), 'seller' => array('@type' => 'Organization', 'name' => get_bloginfo('name'), 'url' => get_bloginfo('url'))); } $markup = array(); $markup['@type'] = 'Order'; $markup['url'] = $order_url; $markup['orderStatus'] = isset($order_status[$order->get_status()]) ? $order_status[$order->get_status()] : ''; $markup['orderNumber'] = $order->get_order_number(); $markup['orderDate'] = date('c', $order->get_date_created()); $markup['acceptedOffer'] = $markup_offers; $markup['discount'] = $order->get_total_discount(); $markup['discountCurrency'] = $order->get_currency(); $markup['price'] = $order->get_total(); $markup['priceCurrency'] = $order->get_currency(); $markup['priceSpecification'] = array('price' => $order->get_total(), 'priceCurrency' => $order->get_currency(), 'valueAddedTaxIncluded' => true); $markup['billingAddress'] = array('@type' => 'PostalAddress', 'name' => $order->get_formatted_billing_full_name(), 'streetAddress' => $order->get_billing_address_1(), 'postalCode' => $order->get_billing_postcode(), 'addressLocality' => $order->get_billing_city(), 'addressRegion' => $order->get_billing_state(), 'addressCountry' => $order->get_billing_country(), 'email' => $order->get_billing_email(), 'telephone' => $order->get_billing_phone()); $markup['customer'] = array('@type' => 'Person', 'name' => $order->get_formatted_billing_full_name()); $markup['merchant'] = array('@type' => 'Organization', 'name' => get_bloginfo('name'), 'url' => get_bloginfo('url')); $markup['potentialAction'] = array('@type' => 'ViewAction', 'name' => 'View Order', 'url' => $order_url, 'target' => $order_url); $this->set_data(apply_filters('woocommerce_structured_data_order', $markup, $sent_to_admin, $order), true); }