Skip to content

Commit

Permalink
Merge pull request #7 from lightspeeddevelopment/schema
Browse files Browse the repository at this point in the history
Schema
  • Loading branch information
krugazul authored Sep 20, 2019
2 parents 8e6ee42 + 8a8963a commit 2f179d4
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 5 deletions.
1 change: 0 additions & 1 deletion classes/class-lsx-team-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ public function change_title_text( $title ) {

return $title;
}

}

$lsx_team_admin = new LSX_Team_Admin();
14 changes: 13 additions & 1 deletion classes/class-lsx-team-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public function __construct() {
add_action( 'pre_get_posts', array( $this, 'pre_get_posts_order_by_role' ) );
add_action( 'lsx_entry_before', array( $this, 'entry_before' ) );
}

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

public function enqueue_scripts( $plugins ) {
Expand Down Expand Up @@ -303,7 +305,17 @@ public function entry_before() {
}
}
}

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

$lsx_team_frontend = new LSX_Team_Frontend();
65 changes: 65 additions & 0 deletions classes/class-lsx-team-schema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* The Team Schema for LSX Team
*
* @package lsx-team
*/
/**
* Returns schema Review data.
*
* @since 10.2
*/
class LSX_Team_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 = 'team';
parent::__construct( $context );
}
/**
* Returns Review data.
*
* @return array $data Review data.
*/
public function generate() {
$data = array(
'@type' => array(
'Person',
),
'@id' => $this->context->canonical . '#person',
'name' => $this->post->post_title,
'description' => wp_strip_all_tags( $this->post->post_content ),
'url' => $this->post_url,
'mainEntityOfPage' => array(
'@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH,
),
);
if ( $this->context->site_represents_reference ) {
$data['worksFor'] = $this->context->site_represents_reference;
$data['memberOf'] = $this->context->site_represents_reference;
}
$data = $this->add_custom_field( $data, 'jobTitle', 'lsx_job_title' );
$data = $this->add_custom_field( $data, 'email', 'lsx_email_contact' );
$data = $this->add_custom_field( $data, 'telephone', 'lsx_tel' );
$data = LSX_Schema_Utils::add_image( $data, $this->context );
return $data;
}
/**
* Adds the projects and testimonials under the 'owns' parameter
*
* @param array $data
* @return array
*/
public function add_products( $data ) {
$connections_array = array();
$connections_array = $this->add_project( $connections_array );
$connections_array = $this->add_testimonial( $connections_array );
if ( ! empty( $connections_array ) ) {
$data['owns'] = $connections_array;
}
return $data;
}
}
2 changes: 1 addition & 1 deletion classes/class-lsx-team-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public function lazyload_slider_images( $img, $post_thumbnail_id, $size, $srcset
* Registers the Widget
*/
function lsx_team_widget() {
register_widget( "LSX_Team_Widget" );
register_widget( 'LSX_Team_Widget' );
}

add_action( 'widgets_init', 'lsx_team_widget' );
4 changes: 2 additions & 2 deletions lsx-team.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: LSX Team
* Plugin URI: https://www.lsdev.biz/product/lsx-team/
* Description: The LSX Team Extension provides a custom post type that allows you to easily show off the people that make up your business.
* Version: 1.1.2
* Version: 1.2
* Author: LightSpeed
* Author URI: https://www.lsdev.biz/
* License: GPL3
Expand All @@ -20,7 +20,7 @@
define( 'LSX_TEAM_PATH', plugin_dir_path( __FILE__ ) );
define( 'LSX_TEAM_CORE', __FILE__ );
define( 'LSX_TEAM_URL', plugin_dir_url( __FILE__ ) );
define( 'LSX_TEAM_VER', '1.1.2' );
define( 'LSX_TEAM_VER', '1.2' );


/* ======================= Below is the Plugin Class init ========================= */
Expand Down

0 comments on commit 2f179d4

Please sign in to comment.