Skip to content

Commit 7177001

Browse files
authored
Merge pull request #3694 from Parsely/fix-allow-optimal-performance-blending-weight-auto-selection
2 parents 0f4fe99 + 84d4c65 commit 7177001

File tree

9 files changed

+28
-129
lines changed

9 files changed

+28
-129
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-escape-html', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '8acfeb018da81a942e25');
1+
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-escape-html', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '582c1c29d022bacbb8b4');

build/content-helper/dashboard-page.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content-helper/dashboard-page/pages/traffic-boost/provider.ts

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ export const TRAFFIC_BOOST_LOADING_MESSAGES = [
2323
__( 'Checking if extra processing is needed…', 'wp-parsely' ),
2424
];
2525

26-
/**
27-
* The default performance blending weight for the traffic boost provider.
28-
*
29-
* @since 3.19.0
30-
*/
31-
export const TRAFFIC_BOOST_DEFAULT_PERFORMANCE_BLENDING_WEIGHT = 0.5;
32-
3326
/**
3427
* Represents a Traffic Boost link.
3528
*
@@ -297,13 +290,12 @@ export class TrafficBoostProvider extends BaseWordPressProvider {
297290
*
298291
* @since 3.19.0
299292
*
300-
* @param {number} postId The ID of the post to generate suggestions for.
301-
* @param {Object} options The options for the suggestions.
302-
* @param {number} options.maxItems The maximum number of items to generate.
303-
* @param {boolean} options.discardPrevious Whether to discard previous suggestions.
304-
* @param {string[]} options.urlExclusionList The list of URLs to exclude from the suggestions.
305-
* @param {number} options.performanceBlendingWeight The performance blending weight.
306-
* @param {boolean} options.save Whether to save the suggestions.
293+
* @param {number} postId The ID of the post to generate suggestions for.
294+
* @param {Object} options The options for the suggestions.
295+
* @param {number} options.maxItems The maximum number of items to generate.
296+
* @param {boolean} options.discardPrevious Whether to discard previous suggestions.
297+
* @param {string[]} options.urlExclusionList The list of URLs to exclude from the suggestions.
298+
* @param {boolean} options.save Whether to save the suggestions.
307299
*
308300
* @return {Promise<TrafficBoostLink[]>} The list of suggestions.
309301
*/
@@ -314,7 +306,6 @@ export class TrafficBoostProvider extends BaseWordPressProvider {
314306
save?: boolean;
315307
discardPrevious?: boolean;
316308
urlExclusionList?: string[];
317-
performanceBlendingWeight?: number;
318309
},
319310
): Promise<TrafficBoostLink[]> {
320311
const response = await this.fetch<InboundSmartLinkDataResponse>( {
@@ -325,7 +316,6 @@ export class TrafficBoostProvider extends BaseWordPressProvider {
325316
save: options?.save ?? false,
326317
discard_previous: options?.discardPrevious ?? true,
327318
url_exclusion_list: options?.urlExclusionList,
328-
performance_blending_weight: options?.performanceBlendingWeight ?? TRAFFIC_BOOST_DEFAULT_PERFORMANCE_BLENDING_WEIGHT,
329319
},
330320
} );
331321

@@ -340,14 +330,13 @@ export class TrafficBoostProvider extends BaseWordPressProvider {
340330
*
341331
* @since 3.19.0
342332
*
343-
* @param {HydratedPost} sourcePost The source post.
344-
* @param {HydratedPost} destinationPost The destination post.
345-
* @param {TrafficBoostLink} trafficBoostLink The traffic boost link to generate a placement for.
346-
* @param {Object} options The options for the suggestion.
347-
* @param {string[]} options.ignoreKeywords The keywords to ignore.
348-
* @param {boolean} options.save Whether to save the suggestion.
349-
* @param {boolean} options.allowDuplicateLinks Whether to allow duplicate links.
350-
* @param {number} options.performanceBlendingWeight The performance blending weight.
333+
* @param {HydratedPost} sourcePost The source post.
334+
* @param {HydratedPost} destinationPost The destination post.
335+
* @param {TrafficBoostLink} trafficBoostLink The traffic boost link to generate a placement for.
336+
* @param {Object} options The options for the suggestion.
337+
* @param {string[]} options.ignoreKeywords The keywords to ignore.
338+
* @param {boolean} options.save Whether to save the suggestion.
339+
* @param {boolean} options.allowDuplicateLinks Whether to allow duplicate links.
351340
*
352341
* @return {Promise<TrafficBoostLink>} The generated suggestion.
353342
*/
@@ -359,7 +348,6 @@ export class TrafficBoostProvider extends BaseWordPressProvider {
359348
ignoreKeywords?: string[];
360349
save?: boolean;
361350
allowDuplicateLinks?: boolean;
362-
performanceBlendingWeight?: number;
363351
},
364352
): Promise<TrafficBoostLink> {
365353
const requestPath = `/wp-parsely/v2/content-helper/traffic-boost/${ sourcePost.id }/generate-placement/${ destinationPost.id }`;
@@ -369,7 +357,6 @@ export class TrafficBoostProvider extends BaseWordPressProvider {
369357
path: requestPath,
370358
data: {
371359
keyword_exclusion_list: options?.ignoreKeywords,
372-
performance_blending_weight: options?.performanceBlendingWeight ?? TRAFFIC_BOOST_DEFAULT_PERFORMANCE_BLENDING_WEIGHT,
373360
save: options?.save ?? true,
374361
allow_duplicate_links: options?.allowDuplicateLinks ?? false,
375362
},

src/rest-api/content-helper/class-endpoint-traffic-boost.php

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -90,39 +90,32 @@ public function register_routes(): void {
9090
array( 'POST' ),
9191
array( $this, 'generate_link_suggestions' ),
9292
array(
93-
'max_items' => array(
93+
'max_items' => array(
9494
'type' => 'integer',
9595
'description' => __( 'The maximum number of suggestions to return.', 'wp-parsely' ),
9696
'default' => 10,
9797
'required' => false,
9898
),
99-
'save' => array(
99+
'save' => array(
100100
'type' => 'boolean',
101101
'description' => __( 'Whether to save the suggestions.', 'wp-parsely' ),
102102
'default' => false,
103103
'required' => false,
104104
),
105-
'discard_previous' => array(
105+
'discard_previous' => array(
106106
'type' => 'boolean',
107107
'description' => __( 'Whether to discard the previous suggestions.', 'wp-parsely' ),
108108
'default' => true,
109109
'required' => false,
110110
),
111-
'url_exclusion_list' => array(
111+
'url_exclusion_list' => array(
112112
'type' => 'array',
113113
'description' => __( 'The URLs to exclude from the suggestions.', 'wp-parsely' ),
114114
'required' => false,
115115
'default' => array(),
116116
'validate_callback' => array( Validations\Validate_Url_Exclusion_List::class, 'validate' ),
117117
'sanitize_callback' => array( Validations\Validate_Url_Exclusion_List::class, 'sanitize' ),
118118
),
119-
'performance_blending_weight' => array(
120-
'type' => 'float',
121-
'description' => __( 'The performance blending weight.', 'wp-parsely' ),
122-
'default' => 0.5,
123-
'required' => false,
124-
'validate_callback' => array( Validations\Validate_Blending_Weight::class, 'validate' ),
125-
),
126119
)
127120
);
128121

@@ -135,36 +128,29 @@ public function register_routes(): void {
135128
array( 'POST' ),
136129
array( $this, 'generate_placement_suggestions' ),
137130
array(
138-
'source_post_id' => array(
131+
'source_post_id' => array(
139132
'type' => 'integer',
140133
'description' => __( 'The ID of the source post.', 'wp-parsely' ),
141134
'required' => true,
142135
),
143-
'ignore_keywords' => array(
136+
'ignore_keywords' => array(
144137
'type' => 'array',
145138
'description' => __( 'The keywords to ignore.', 'wp-parsely' ),
146139
'required' => false,
147140
),
148-
'keyword_exclusion_list' => array(
141+
'keyword_exclusion_list' => array(
149142
'type' => 'array',
150143
'description' => __( 'The keywords to exclude from the suggestions.', 'wp-parsely' ),
151144
'required' => false,
152145
'default' => array(),
153146
),
154-
'performance_blending_weight' => array(
155-
'type' => 'float',
156-
'description' => __( 'The performance blending weight.', 'wp-parsely' ),
157-
'default' => 0.5,
158-
'required' => false,
159-
'validate_callback' => array( Validations\Validate_Blending_Weight::class, 'validate' ),
160-
),
161-
'allow_duplicate_links' => array(
147+
'allow_duplicate_links' => array(
162148
'type' => 'boolean',
163149
'description' => __( 'Whether to allow duplicate links.', 'wp-parsely' ),
164150
'default' => false,
165151
'required' => false,
166152
),
167-
'save' => array(
153+
'save' => array(
168154
'type' => 'boolean',
169155
'description' => __( 'Whether to save the suggestion.', 'wp-parsely' ),
170156
'default' => true,
@@ -354,19 +340,11 @@ public function generate_link_suggestions( WP_REST_Request $request ) {
354340
*/
355341
$url_exclusion_list = $request->get_param( 'url_exclusion_list' );
356342

357-
/**
358-
* The performance blending weight.
359-
*
360-
* @var float $performance_blending_weight
361-
*/
362-
$performance_blending_weight = $request->get_param( 'performance_blending_weight' );
363-
364343
$inbound_suggestions = $this->suggestions_api->get_inbound_links(
365344
$post,
366345
array(
367-
'max_items' => $max_items,
368-
'url_exclusion_list' => $url_exclusion_list,
369-
'performance_blending_weight' => $performance_blending_weight,
346+
'max_items' => $max_items,
347+
'url_exclusion_list' => $url_exclusion_list,
370348
)
371349
);
372350

@@ -455,13 +433,6 @@ public function generate_placement_suggestions( WP_REST_Request $request ) {
455433
*/
456434
$allow_duplicate_links = $request->get_param( 'allow_duplicate_links' );
457435

458-
/**
459-
* The performance blending weight.
460-
*
461-
* @var float $performance_blending_weight
462-
*/
463-
$performance_blending_weight = $request->get_param( 'performance_blending_weight' );
464-
465436
/**
466437
* Whether to save the suggestion.
467438
*
@@ -480,8 +451,7 @@ public function generate_placement_suggestions( WP_REST_Request $request ) {
480451
$source_post,
481452
$destination_post,
482453
array(
483-
'performance_blending_weight' => $performance_blending_weight,
484-
'keyword_exclusion_list' => $keyword_exclusion_list,
454+
'keyword_exclusion_list' => $keyword_exclusion_list,
485455
)
486456
);
487457

src/rest-api/content-helper/validations/class-validate-blending-weight.php

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/services/suggestions-api/endpoints/class-endpoint-suggest-headline.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* @phpstan-type Endpoint_Suggest_Headline_Options = array{
2626
* persona?: string,
2727
* style?: string,
28-
* performance_blending_weight?: float,
2928
* max_items?: int,
3029
* traffic_sources?: array<int, Traffic_Source>
3130
* }

src/services/suggestions-api/endpoints/class-endpoint-suggest-inbound-link-positions.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
* }
2828
*
2929
* @phpstan-type Endpoint_Suggest_Inbound_Link_Positions_Options = array{
30-
* performance_blending_weight?: float,
3130
* keyword_exclusion_list?: array<string>
3231
* }
3332
*/
@@ -79,9 +78,6 @@ public function get_inbound_link_positions(
7978
'source_url' => array( $source_post_url ),
8079
'title' => $destination_post->post_title,
8180
'text' => wp_strip_all_tags( $destination_post->post_content ),
82-
'output_config' => array(
83-
'performance_blending_weight' => $options['performance_blending_weight'] ?? 0.5,
84-
),
8581
);
8682

8783
if ( isset( $options['keyword_exclusion_list'] ) && count( $options['keyword_exclusion_list'] ) > 0 ) {

src/services/suggestions-api/endpoints/class-endpoint-suggest-inbound-links.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
* @phpstan-type Endpoint_Suggest_Inbound_Links_Options = array{
2222
* max_items?: int,
2323
* url_exclusion_list?: array<string>,
24-
* performance_blending_weight?: float
2524
* }
2625
*/
2726
class Endpoint_Suggest_Inbound_Links extends Suggestions_API_Base_Endpoint {
@@ -61,8 +60,7 @@ public function get_inbound_links(
6160
$request_body = array(
6261
'canonical_url' => $post_url,
6362
'output_config' => array(
64-
'performance_blending_weight' => $options['performance_blending_weight'] ?? 0.5,
65-
'max_items' => $options['max_items'] ?? 10,
63+
'max_items' => $options['max_items'] ?? 10,
6664
),
6765
'title' => $post->post_title,
6866
'text' => wp_strip_all_tags( $post->post_content ),

src/services/suggestions-api/endpoints/class-endpoint-suggest-linked-reference.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* }
2525
*
2626
* @phpstan-type Endpoint_Suggest_Linked_Reference_Options = array{
27-
* performance_blending_weight?: float,
2827
* max_items?: int,
2928
* max_link_words?: int,
3029
* traffic_sources?: array<int, Traffic_Source>,

0 commit comments

Comments
 (0)