Skip to content

Commit

Permalink
Fixing the merge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
krugazul committed Oct 1, 2019
2 parents ffcf228 + 96c5f27 commit d46e75c
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tools:
php_sim: true
php_pdepend: true
php_analyzer: true
filter:
excluded_paths:
- 'tests/*'
- 'assets/*'
- 'vendor/*'
checks:
php:
code_rating: true
duplication: true
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Changelog

### 1.2.0 - In development
### 1.2.0 - 1 October 2019
# Dev - Adding the .gitattributes file to remove unnecessary files from the WordPress version.
* Dev - Added in lazyloading for the sliders.
* Dev - Added in a "Review" Schema using the Yoast API
Expand Down
16 changes: 16 additions & 0 deletions classes/class-lsx-testimonials-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ public function __construct() {
), 15, 2 );
}

add_filter( 'wpseo_schema_graph_pieces', array( $this, 'add_graph_pieces' ), 11, 2 );

add_filter( 'lsx_fonts_css', array( $this, 'customizer_fonts_handler' ), 15 );
add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_archive_title' ), 15 );

add_filter( 'excerpt_more_p', array( $this, 'change_excerpt_more' ) );
add_filter( 'excerpt_length', array( $this, 'change_excerpt_length' ) );
add_filter( 'excerpt_strip_tags', array( $this, 'change_excerpt_strip_tags' ) );

}

public function enqueue_scripts() {
Expand Down Expand Up @@ -207,6 +210,19 @@ public function change_excerpt_strip_tags( $allowed_tags ) {

return $allowed_tags;
}

/**
* Adds Pieces
*/
public function add_graph_pieces( $pieces, $context ) {
// Scheme Class.
if ( class_exists( 'LSX_Schema_Graph_Piece' ) ) {
require_once LSX_TESTIMONIALS_PATH . '/classes/class-lsx-testimonials-schema.php';
$pieces[] = new \LSX_Testimonials_Schema( $context );
}
return $pieces;
}

}

$lsx_testimonials_frontend = new LSX_Testimonials_Frontend();
58 changes: 58 additions & 0 deletions classes/class-lsx-testimonials-schema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* The Review Schema
*
* @package lsx-testimonials
*/
/**
* Returns schema Review data.
*
* @since 10.2
*/
class LSX_Testimonials_Schema extends LSX_Schema_Graph_Piece {
/**
* Constructor.
*
* @param \WPSEO_Schema_Context $context A value object with context variables.
*/
public function __construct( WPSEO_Schema_Context $context ) {
$this->post_type = 'testimonial';
parent::__construct( $context );
}
/**
* Returns Review data.
*
* @return array $data Review data.
*/
public function generate() {
$post = get_post( $this->context->id );
$review_author = $post->post_title;
$review_email = get_post_meta( $post->ID, 'lsx_testimonial_email_gravatar', true );
$description = wp_strip_all_tags( get_the_content() );
$comment_count = get_comment_count( $this->context->id );
$data = array(
'@type' => 'Review',
'@id' => $this->context->canonical . '#review',
'author' => array(
'@type' => 'Person',
'@id' => LSX_Schema_Utils::get_author_schema_id( $review_author, $review_email, $this->context ),
'name' => $review_author,
'email' => $review_email,
),
'headline' => get_the_title(),
'datePublished' => mysql2date( DATE_W3C, $post->post_date_gmt, false ),
'dateModified' => mysql2date( DATE_W3C, $post->post_modified_gmt, false ),
'commentCount' => $comment_count['approved'],
'mainEntityOfPage' => array(
'@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH,
),
'reviewBody' => $description,
);
if ( $this->context->site_represents_reference ) {
$data['publisher'] = $this->context->site_represents_reference;
$data['itemReviewed'] = $this->context->site_represents_reference;
}
$data = LSX_Schema_Utils::add_image( $data, $this->context );
return $data;
}
}

0 comments on commit d46e75c

Please sign in to comment.