Skip to content

Commit

Permalink
Merge pull request #1 from upsellpl/delete-schema-org
Browse files Browse the repository at this point in the history
removed microdata
  • Loading branch information
upsellpl committed Jan 15, 2021
2 parents e996904 + 94b13d9 commit ddb61f0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 123 deletions.
3 changes: 1 addition & 2 deletions includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,7 @@ function edd_downloads_query( $atts, $content = null ) {
ob_start(); ?>
<div class="edd_downloads_list <?php echo apply_filters( 'edd_downloads_list_wrapper_class', $wrapper_class, $atts ); ?>">
<?php while ( $downloads->have_posts() ) : $downloads->the_post(); ?>
<?php $schema = edd_add_schema_microdata() ? 'itemscope itemtype="http://schema.org/Product" ' : ''; ?>
<div <?php echo $schema; ?>class="<?php echo apply_filters( 'edd_download_class', 'edd_download', get_the_ID(), $atts, $i ); ?>" id="edd_download_<?php echo get_the_ID(); ?>">
<div class="<?php echo apply_filters( 'edd_download_class', 'edd_download', get_the_ID(), $atts, $i ); ?>" id="edd_download_<?php echo get_the_ID(); ?>">
<div class="edd_download_inner">
<?php

Expand Down
116 changes: 2 additions & 114 deletions includes/template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ function edd_purchase_variable_pricing( $download_id = 0, $args = array() ) {

$type = edd_single_price_option_mode( $download_id ) ? 'checkbox' : 'radio';
$mode = edd_single_price_option_mode( $download_id ) ? 'multi' : 'single';
$schema = edd_add_schema_microdata() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '';

if ( edd_item_in_cart( $download_id ) && ! edd_single_price_option_mode( $download_id ) ) {
return;
Expand All @@ -267,10 +266,10 @@ function edd_purchase_variable_pricing( $download_id = 0, $args = array() ) {
if ( $prices ) :
$checked_key = isset( $_GET['price_option'] ) ? absint( $_GET['price_option'] ) : edd_get_default_variable_price( $download_id );
foreach ( $prices as $key => $price ) :
echo '<li id="edd_price_option_' . $download_id . '_' . sanitize_key( $price['name'] ) . '"' . $schema . '>';
echo '<li id="edd_price_option_' . $download_id . '_' . sanitize_key( $price['name'] ) . '">';
echo '<label for="' . esc_attr( 'edd_price_option_' . $download_id . '_' . $key ) . '">';
echo '<input type="' . $type . '" ' . checked( apply_filters( 'edd_price_option_checked', $checked_key, $download_id, $key ), $key, false ) . ' name="edd_options[price_id][]" id="' . esc_attr( 'edd_price_option_' . $download_id . '_' . $key ) . '" class="' . esc_attr( 'edd_price_option_' . $download_id ) . '" value="' . esc_attr( $key ) . '" data-price="' . edd_get_price_option_amount( $download_id, $key ) .'"/>&nbsp;';
echo '<span class="edd_price_option_name" itemprop="description">' . esc_html( $price['name'] ) . '</span><span class="edd_price_option_sep">&nbsp;&ndash;&nbsp;</span><span class="edd_price_option_price" itemprop="price">' . edd_currency_filter( edd_format_amount( $price['amount'] ) ) . '</span>';
echo '<span class="edd_price_option_name">' . esc_html( $price['name'] ) . '</span><span class="edd_price_option_sep">&nbsp;&ndash;&nbsp;</span><span class="edd_price_option_price">' . edd_currency_filter( edd_format_amount( $price['amount'] ) ) . '</span>';
echo '</label>';
do_action( 'edd_after_price_option', $key, $price, $download_id );
echo '</li>';
Expand Down Expand Up @@ -688,117 +687,6 @@ function edd_get_theme_template_dir_name() {
return trailingslashit( apply_filters( 'edd_templates_dir', 'edd_templates' ) );
}

/**
* Should we add schema.org microdata?
*
* @since 1.7
* @return bool
*/
function edd_add_schema_microdata() {
// Don't modify anything until after wp_head() is called
$ret = (bool)did_action( 'wp_head' );
return apply_filters( 'edd_add_schema_microdata', $ret );
}

/**
* Add Microdata to download titles
*
* @since 1.5
* @author Sunny Ratilal
* @param string $title Post Title
* @param int $id Post ID
* @return string $title New title
*/
function edd_microdata_title( $title, $id = 0 ) {
global $post;

if( ! edd_add_schema_microdata() || ! is_object( $post ) ) {
return $title;
}

if ( $post->ID == $id && is_singular( 'download' ) && 'download' == get_post_type( intval( $id ) ) ) {
$title = '<span itemprop="name">' . $title . '</span>';
}

return $title;
}
add_filter( 'the_title', 'edd_microdata_title', 10, 2 );

/**
* Start Microdata to wrapper download
*
* @since 2.3
* @author Chris Klosowski
*
* @return void
*/
function edd_microdata_wrapper_open( $query ) {
global $post;

static $microdata_open = NULL;

if( ! edd_add_schema_microdata() || true === $microdata_open || ! is_object( $query ) ) {
return;
}

if ( $query && ! empty( $query->query['post_type'] ) && $query->query['post_type'] == 'download' && is_singular( 'download' ) && $query->is_main_query() ) {
$microdata_open = true;
echo '<span itemscope itemtype="http://schema.org/Product">';
}

}
add_action( 'loop_start', 'edd_microdata_wrapper_open', 10 );

/**
* End Microdata to wrapper download
*
* @since 2.3
* @author Chris Klosowski
*
* @return void
*/
function edd_microdata_wrapper_close() {
global $post;

static $microdata_close = NULL;

if( ! edd_add_schema_microdata() || true === $microdata_close || ! is_object( $post ) ) {
return;
}

if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() ) {
$microdata_close = true;
echo '</span>';
}
}
add_action( 'loop_end', 'edd_microdata_wrapper_close', 10 );

/**
* Add Microdata to download description
*
* @since 1.5
* @author Sunny Ratilal
*
* @param $content
* @return mixed|void New title
*/
function edd_microdata_description( $content ) {
global $post;

static $microdata_description = NULL;

if( ! edd_add_schema_microdata() || true === $microdata_description || ! is_object( $post ) ) {
return $content;
}

if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() ) {
$microdata_description = true;
$content = apply_filters( 'edd_microdata_wrapper', '<div itemprop="description">' . $content . '</div>' );
}
return $content;
}
add_filter( 'the_content', 'edd_microdata_description', 10 );

/**
* Add no-index and no-follow to EDD checkout and purchase confirmation pages
*
Expand Down
4 changes: 2 additions & 2 deletions templates/shortcode-content-excerpt.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php $excerpt_length = apply_filters( 'excerpt_length', 30 ); ?>

<?php if ( has_excerpt() ) : ?>
<div itemprop="description" class="edd_download_excerpt">
<div class="edd_download_excerpt">
<?php echo apply_filters( 'edd_downloads_excerpt', wp_trim_words( get_post_field( 'post_excerpt', get_the_ID() ), $excerpt_length ) ); ?>
</div>
<?php elseif ( get_the_content() ) : ?>
<div itemprop="description" class="edd_download_excerpt">
<div class="edd_download_excerpt">
<?php echo apply_filters( 'edd_downloads_excerpt', wp_trim_words( get_post_field( 'post_content', get_the_ID() ), $excerpt_length ) ); ?>
</div>
<?php endif; ?>
2 changes: 1 addition & 1 deletion templates/shortcode-content-full.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div itemprop="description" class="edd_download_full_content">
<div class="edd_download_full_content">
<?php echo apply_filters( 'edd_downloads_content', get_post_field( 'post_content', get_the_ID() ) ); ?>
</div>
4 changes: 2 additions & 2 deletions templates/shortcode-content-price.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php if ( ! edd_has_variable_prices( get_the_ID() ) ) : ?>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<div itemprop="price" class="edd_price">
<div>
<div class="edd_price">
<?php edd_price( get_the_ID() ); ?>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/shortcode-content-title.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
use bpmj\wpidea\View_Hooks;
?>
<h3 itemprop="name" class="edd_download_title">
<a <?php View_Hooks::run(View_Hooks::RENDER_INLINE_ELEMENTS_IN_HYPERLINK_PRODUCT, get_the_ID()); ?> title="<?php the_title_attribute(); ?>" itemprop="url" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<h3 class="edd_download_title">
<a <?php View_Hooks::run(View_Hooks::RENDER_INLINE_ELEMENTS_IN_HYPERLINK_PRODUCT, get_the_ID()); ?> title="<?php the_title_attribute(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h3>

0 comments on commit ddb61f0

Please sign in to comment.