PluginProbe
Parse.ly / 3.14.1
Parse.ly v3.14.1
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
← All changes | src/RemoteAPI/content-suggestions/class-suggest-linked-reference-api.php +15 -22 3.16.13.14.1 View file →
@@ -9,12 +9,13 @@
9 9 declare(strict_types=1);
10 10
11 11 namespace Parsely\RemoteAPI\ContentSuggestions;
12 12
13 -use Parsely\Models\Smart_Link;
14 13 use Parsely\Parsely;
15 14 use WP_Error;
16 15
16 +require_once __DIR__ . '/class-link-suggestion.php';
17 +
17 18 /**
18 19 * Class for Content Suggestions Suggest Linked Reference (Smart Links) API.
19 20 *
20 21 * @since 3.14.0
@@ -29,21 +30,19 @@
29 30 * Gets suggested smart links for the given content.
30 31 *
31 32 * @since 3.14.0
32 33 *
33 - * @param string $content The content to generate links for.
34 - * @param int $max_link_words The maximum number of words in links.
35 - * @param int $max_links The maximum number of links to return.
36 - * @param string[] $url_exclusion_list A list of URLs to exclude from the suggestions.
34 + * @param string $content The content to generate links for.
35 + * @param int $max_link_words The maximum number of words in links.
36 + * @param int $max_links The maximum number of links to return.
37 37 *
38 - * @return Smart_Link[]|WP_Error The response from the remote API, or a WP_Error
38 + * @return Link_Suggestion[]|WP_Error The response from the remote API, or a WP_Error
39 39 * object if the response is an error.
40 40 */
41 41 public function get_links(
42 42 string $content,
43 43 int $max_link_words = 4,
44 - int $max_links = 10,
45 - array $url_exclusion_list = array()
44 + int $max_links = 10
46 45 ) {
47 46 $body = array(
48 47 'output_config' => array(
49 48 'max_link_words' => $max_link_words,
@@ -48,15 +47,11 @@
48 47 'output_config' => array(
49 48 'max_link_words' => $max_link_words,
50 49 'max_items' => $max_links,
51 50 ),
52 - 'text' => wp_strip_all_tags( $content ),
51 + 'text' => $content,
53 52 );
54 53
55 - if ( count( $url_exclusion_list ) > 0 ) {
56 - $body['url_exclusion_list'] = $url_exclusion_list;
57 - }
58 -
59 54 $decoded = $this->post_request( array(), $body );
60 55
61 56 if ( is_wp_error( $decoded ) ) {
62 57 return $decoded;
@@ -69,19 +64,17 @@
69 64 __( 'Unable to parse suggested links from upstream API', 'wp-parsely' )
70 65 );
71 66 }
72 67
73 - // Convert the links to Smart_Link objects.
68 + // Convert the links to Link_Suggestion objects.
74 69 $links = array();
75 70 foreach ( $decoded->result as $link ) {
76 - $link = apply_filters( 'wp_parsely_suggest_linked_reference_link', $link );
77 - $link_obj = new Smart_Link(
78 - esc_url( $link->canonical_url ),
79 - esc_attr( $link->title ),
80 - wp_kses_post( $link->text ),
81 - $link->offset
82 - );
83 - $links[] = $link_obj;
71 + $link_obj = new Link_Suggestion();
72 + $link_obj->href = $link->canonical_url;
73 + $link_obj->title = $link->title;
74 + $link_obj->text = $link->text;
75 + $link_obj->offset = $link->offset;
76 + $links[] = $link_obj;
84 77 }
85 78
86 79 return $links;
87 80 }