diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..c2c7f8c --- /dev/null +++ b/.scrutinizer.yml @@ -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 diff --git a/changelog.txt b/changelog.txt index cef1498..ee7cc50 100755 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/classes/class-lsx-testimonials-frontend.php b/classes/class-lsx-testimonials-frontend.php index 8f49164..36161b0 100755 --- a/classes/class-lsx-testimonials-frontend.php +++ b/classes/class-lsx-testimonials-frontend.php @@ -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() { @@ -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(); diff --git a/classes/class-lsx-testimonials-schema.php b/classes/class-lsx-testimonials-schema.php new file mode 100644 index 0000000..186e2ea --- /dev/null +++ b/classes/class-lsx-testimonials-schema.php @@ -0,0 +1,58 @@ +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; + } +}