Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordpres.../src/integrat.../third-pa...
File: wincher-publish.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Third_Party;
[2] Fix | Delete
[3] Fix | Delete
use WP_Post;
[4] Fix | Delete
use Yoast\WP\SEO\Actions\Wincher\Wincher_Account_Action;
[5] Fix | Delete
use Yoast\WP\SEO\Actions\Wincher\Wincher_Keyphrases_Action;
[6] Fix | Delete
use Yoast\WP\SEO\Conditionals\Wincher_Automatically_Track_Conditional;
[7] Fix | Delete
use Yoast\WP\SEO\Conditionals\Wincher_Conditional;
[8] Fix | Delete
use Yoast\WP\SEO\Conditionals\Wincher_Enabled_Conditional;
[9] Fix | Delete
use Yoast\WP\SEO\Conditionals\Wincher_Token_Conditional;
[10] Fix | Delete
use Yoast\WP\SEO\Helpers\Options_Helper;
[11] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Handles automatically tracking published posts with Wincher.
[15] Fix | Delete
*/
[16] Fix | Delete
class Wincher_Publish implements Integration_Interface {
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* The Wincher enabled conditional.
[20] Fix | Delete
*
[21] Fix | Delete
* @var Wincher_Enabled_Conditional
[22] Fix | Delete
*/
[23] Fix | Delete
protected $wincher_enabled;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* The options helper.
[27] Fix | Delete
*
[28] Fix | Delete
* @var Options_Helper
[29] Fix | Delete
*/
[30] Fix | Delete
protected $options_helper;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* The Wincher keyphrases action handler.
[34] Fix | Delete
*
[35] Fix | Delete
* @var Wincher_Keyphrases_Action
[36] Fix | Delete
*/
[37] Fix | Delete
protected $keyphrases_action;
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* The Wincher account action handler.
[41] Fix | Delete
*
[42] Fix | Delete
* @var Wincher_Account_Action
[43] Fix | Delete
*/
[44] Fix | Delete
protected $account_action;
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Wincher publish constructor.
[48] Fix | Delete
*
[49] Fix | Delete
* @param Wincher_Enabled_Conditional $wincher_enabled The WPML WPSEO conditional.
[50] Fix | Delete
* @param Options_Helper $options_helper The options helper.
[51] Fix | Delete
* @param Wincher_Keyphrases_Action $keyphrases_action The keyphrases action class.
[52] Fix | Delete
* @param Wincher_Account_Action $account_action The account action class.
[53] Fix | Delete
*/
[54] Fix | Delete
public function __construct(
[55] Fix | Delete
Wincher_Enabled_Conditional $wincher_enabled,
[56] Fix | Delete
Options_Helper $options_helper,
[57] Fix | Delete
Wincher_Keyphrases_Action $keyphrases_action,
[58] Fix | Delete
Wincher_Account_Action $account_action
[59] Fix | Delete
) {
[60] Fix | Delete
$this->wincher_enabled = $wincher_enabled;
[61] Fix | Delete
$this->options_helper = $options_helper;
[62] Fix | Delete
$this->keyphrases_action = $keyphrases_action;
[63] Fix | Delete
$this->account_action = $account_action;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Initializes the integration.
[68] Fix | Delete
*
[69] Fix | Delete
* @return void
[70] Fix | Delete
*/
[71] Fix | Delete
public function register_hooks() {
[72] Fix | Delete
/**
[73] Fix | Delete
* Called in the REST API when submitting the post copy in the Block Editor.
[74] Fix | Delete
* Runs the republishing of the copy onto the original.
[75] Fix | Delete
*/
[76] Fix | Delete
\add_action( 'rest_after_insert_post', [ $this, 'track_after_rest_api_request' ] );
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Called by `wp_insert_post()` when submitting the post copy, which runs in two cases:
[80] Fix | Delete
* - In the Classic Editor, where there's only one request that updates everything.
[81] Fix | Delete
* - In the Block Editor, only when there are custom meta boxes.
[82] Fix | Delete
*/
[83] Fix | Delete
\add_action( 'wp_insert_post', [ $this, 'track_after_post_request' ], \PHP_INT_MAX, 2 );
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* Returns the conditionals based in which this loadable should be active.
[88] Fix | Delete
*
[89] Fix | Delete
* This integration should only be active when the feature is enabled, a token is available and automatically tracking is enabled.
[90] Fix | Delete
*
[91] Fix | Delete
* @return array The conditionals.
[92] Fix | Delete
*/
[93] Fix | Delete
public static function get_conditionals() {
[94] Fix | Delete
return [
[95] Fix | Delete
Wincher_Conditional::class,
[96] Fix | Delete
Wincher_Enabled_Conditional::class,
[97] Fix | Delete
Wincher_Automatically_Track_Conditional::class,
[98] Fix | Delete
Wincher_Token_Conditional::class,
[99] Fix | Delete
];
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Determines whether the current request is a REST request.
[104] Fix | Delete
*
[105] Fix | Delete
* @return bool Whether the request is a REST request.
[106] Fix | Delete
*/
[107] Fix | Delete
public function is_rest_request() {
[108] Fix | Delete
return \defined( 'REST_REQUEST' ) && \REST_REQUEST;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Sends the keyphrases associated with the post to Wincher for automatic tracking.
[113] Fix | Delete
*
[114] Fix | Delete
* @param WP_Post $post The post to extract the keyphrases from.
[115] Fix | Delete
*
[116] Fix | Delete
* @return void
[117] Fix | Delete
*/
[118] Fix | Delete
public function track_request( $post ) {
[119] Fix | Delete
if ( ! $post instanceof WP_Post ) {
[120] Fix | Delete
return;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
// Filter out empty entries.
[124] Fix | Delete
$keyphrases = \array_filter( $this->keyphrases_action->collect_keyphrases_from_post( $post ) );
[125] Fix | Delete
[126] Fix | Delete
if ( ! empty( $keyphrases ) ) {
[127] Fix | Delete
$this->keyphrases_action->track_keyphrases( $keyphrases, $this->account_action->check_limit() );
[128] Fix | Delete
}
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
/**
[132] Fix | Delete
* Republishes the original post with the passed post, when using the Block Editor.
[133] Fix | Delete
*
[134] Fix | Delete
* @param WP_Post $post The copy's post object.
[135] Fix | Delete
*
[136] Fix | Delete
* @return void
[137] Fix | Delete
*/
[138] Fix | Delete
public function track_after_rest_api_request( $post ) {
[139] Fix | Delete
$this->track_request( $post );
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
/**
[143] Fix | Delete
* Republishes the original post with the passed post, when using the Classic Editor.
[144] Fix | Delete
*
[145] Fix | Delete
* Runs also in the Block Editor to save the custom meta data only when there
[146] Fix | Delete
* are custom meta boxes.
[147] Fix | Delete
*
[148] Fix | Delete
* @param int $post_id The copy's post ID.
[149] Fix | Delete
* @param WP_Post $post The copy's post object.
[150] Fix | Delete
*
[151] Fix | Delete
* @return void
[152] Fix | Delete
*/
[153] Fix | Delete
public function track_after_post_request( $post_id, $post ) {
[154] Fix | Delete
if ( $this->is_rest_request() ) {
[155] Fix | Delete
return;
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
$this->track_request( $post );
[159] Fix | Delete
}
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function