-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1413 from insideout10/release/3.31.7
Release/3.31.7
- Loading branch information
Showing
16 changed files
with
282 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-rich-text'), 'version' => '53f09426a509199c8303f0308bcf9283'); | ||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-rich-text'), 'version' => '77de224def1a73a8f57d51790cd7803d'); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/wordlift/duplicate-markup-remover/class-videoobject-duplicate-remover.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Wordlift\Duplicate_Markup_Remover; | ||
|
||
/** | ||
* @author Naveen Muthusamy <[email protected]> | ||
* @since 3.31.7 | ||
* Class Videoobject_Duplicate_Remover | ||
* @package Wordlift\Duplicate_Markup_Remover | ||
*/ | ||
class Videoobject_Duplicate_Remover { | ||
|
||
public function __construct() { | ||
add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 2 ); | ||
} | ||
|
||
/** | ||
* @param $jsonld array The final jsonld. | ||
* @param $post_id int The post id. | ||
* | ||
* @return array Filtered jsonld. | ||
*/ | ||
public function wl_after_get_jsonld( $jsonld, $post_id ) { | ||
|
||
if ( ! is_array( $jsonld ) | ||
|| ! count( $jsonld ) > 1 | ||
|| ! array_key_exists( 0, $jsonld ) ) { | ||
// Return early if there are no referenced entities. | ||
return $jsonld; | ||
} | ||
|
||
$post_jsonld = array_shift( $jsonld ); | ||
|
||
// we need to loop through all the items and remove the faq markup. | ||
foreach ( $jsonld as $key => &$value ) { | ||
if ( ! array_key_exists( '@type', $value ) ) { | ||
continue; | ||
} | ||
$type = $value['@type']; | ||
|
||
if ( ( is_string( $type ) && $type !== 'Article' ) | ||
|| ( is_array( $type ) && ! in_array( 'Article', $type ) ) ) { | ||
continue; | ||
} | ||
// Video doesnt exist, dont try to remove it. | ||
if ( ! array_key_exists( 'video', $value ) ) { | ||
continue; | ||
} | ||
unset( $jsonld[ $key ]['video'] ); | ||
} | ||
|
||
// Add the post jsonld to front of jsonld array. | ||
array_unshift( $jsonld, $post_jsonld ); | ||
|
||
return $jsonld; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
namespace Wordlift\Synonym; | ||
|
||
use Wordlift\Common\Loader\Default_Loader; | ||
|
||
|
||
/** | ||
* @since 3.31.7 | ||
* @author Naveen Muthusamy <[email protected]> | ||
*/ | ||
class Loader extends Default_Loader { | ||
|
||
public function init_all_dependencies() { | ||
new Rest_Field(); | ||
} | ||
|
||
protected function get_feature_slug() { | ||
return 'add-synonyms'; | ||
} | ||
|
||
protected function get_feature_default_value() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace Wordlift\Synonym; | ||
|
||
use Wordlift_Entity_Service; | ||
|
||
class Rest_Field { | ||
|
||
public function __construct() { | ||
add_action( 'rest_api_init', array( $this, 'register_rest_field' ) ); | ||
} | ||
|
||
public function register_rest_field() { | ||
|
||
if ( ! function_exists( 'register_rest_field' ) ) { | ||
return; | ||
} | ||
|
||
|
||
$post_types = Wordlift_Entity_Service::valid_entity_post_types(); | ||
|
||
foreach ( $post_types as $post_type ) { | ||
|
||
register_rest_field( | ||
$post_type, | ||
\Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, | ||
array( | ||
'get_callback' => array( $this, 'get_value' ), | ||
'update_callback' => array( $this, 'update_value' ) | ||
) | ||
); | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
/** | ||
* @param $meta_values array | ||
* @param $post \WP_Post | ||
* @param $meta_key string | ||
*/ | ||
public function update_value( $meta_values, $post, $meta_key ) { | ||
|
||
if ( ! is_array( $meta_values ) ) { | ||
return; | ||
} | ||
delete_post_meta( $post->ID, Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ); | ||
|
||
// @todo: check if the keys have to be unique. | ||
$meta_values = array_unique( $meta_values ); | ||
|
||
foreach ( $meta_values as $item ) { | ||
add_post_meta( $post->ID, \Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, $item ); | ||
} | ||
} | ||
|
||
/** | ||
* @param $post array Post array. | ||
* | ||
* @return array|mixed | ||
*/ | ||
public function get_value( $post ) { | ||
$data = get_post_meta( (int) $post["id"], \Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ); | ||
if ( ! is_array( $data ) ) { | ||
return array(); | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.