diff --git a/src/classes/content/wordpress/class-abstract-wordpress-content-service.php b/src/classes/content/wordpress/class-abstract-wordpress-content-service.php index 44fd6315c..22fe32252 100644 --- a/src/classes/content/wordpress/class-abstract-wordpress-content-service.php +++ b/src/classes/content/wordpress/class-abstract-wordpress-content-service.php @@ -5,6 +5,7 @@ use Exception; use Wordlift\Assertions; use Wordlift\Content\Content_Service; +use Wordlift\Jsonld\Jsonld_Utils; use Wordlift\Object_Type_Enum; use Wordlift_Configuration_Service; @@ -79,7 +80,7 @@ public function set_about_jsonld( $content_id, $value ) { // Cleanup value. $value = ( is_string( $value ) && strlen( $value ) > 2 ) ? $value : null; - $match_name = $this->get_match_name( $value ); + $match_name = Jsonld_Utils::get_about_match_name( $value ); // This `hack` is necessary to ensure the entity exists in the entities table, but we // should revise how this works really. @@ -123,18 +124,4 @@ public function set_about_jsonld( $content_id, $value ) { return $wpdb->query( $wpdb->prepare( $query, $params ) ); } - - /** - * @param $jsonld - * - * @return mixed|null - */ - public function get_match_name( $jsonld ) { - $data = json_decode( $jsonld, true ); - if ( ! $data || ! array_key_exists( 'name', $data ) ) { - return null; - } - - return $data['name']; - } } diff --git a/src/classes/jsonld/class-jsonld-utils.php b/src/classes/jsonld/class-jsonld-utils.php new file mode 100644 index 000000000..4252abcfa --- /dev/null +++ b/src/classes/jsonld/class-jsonld-utils.php @@ -0,0 +1,22 @@ +get_match_name( $row['about_jsonld'] ); + $match_name = Jsonld_Utils::get_about_match_name( $row['about_jsonld'] ); if ( is_null( $match_name ) ) { continue; @@ -70,20 +70,4 @@ public function install() { ); } } - - /** - * Get match name - * - * @param $jsonld - * - * @return mixed|null - */ - public function get_match_name( $jsonld ) { - $data = json_decode( $jsonld, true ); - if ( ! $data || ! array_key_exists( 'name', $data ) ) { - return null; - } - - return $data['name']; - } } diff --git a/src/modules/dashboard/includes/Term_Entity_Match/Term_Query.php b/src/modules/dashboard/includes/Term_Entity_Match/Term_Query.php index 8f40d980b..88131ea3f 100644 --- a/src/modules/dashboard/includes/Term_Entity_Match/Term_Query.php +++ b/src/modules/dashboard/includes/Term_Entity_Match/Term_Query.php @@ -76,10 +76,9 @@ public function __construct( $request, $cursor, $cursor_sort, $limit ) { $this->has_match(); $this->term_contains(); $this->taxonomies(); + $this->group_by(); $this->sort(); $this->limit(); - - $this->sql = " GROUP BY t.term_id"; } public function get_results() { @@ -122,6 +121,10 @@ private function has_match() { } } + private function group_by() { + $this->sql .= ' GROUP BY t.term_id'; + } + private function sort() { switch ( $this->direction . '$' . $this->sort ) { case 'ASCENDING$ASC':