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/wp-conte.../plugins/wordpres.../src/routes
File: workouts-route.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Routes;
[2] Fix | Delete
[3] Fix | Delete
use WP_REST_Request;
[4] Fix | Delete
use WP_REST_Response;
[5] Fix | Delete
use Yoast\WP\SEO\Conditionals\No_Conditionals;
[6] Fix | Delete
use Yoast\WP\SEO\Helpers\Options_Helper;
[7] Fix | Delete
use Yoast\WP\SEO\Main;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Workouts_Route class.
[11] Fix | Delete
*/
[12] Fix | Delete
class Workouts_Route implements Route_Interface {
[13] Fix | Delete
[14] Fix | Delete
use No_Conditionals;
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Represents workouts route.
[18] Fix | Delete
*
[19] Fix | Delete
* @var string
[20] Fix | Delete
*/
[21] Fix | Delete
public const WORKOUTS_ROUTE = '/workouts';
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* The Options helper.
[25] Fix | Delete
*
[26] Fix | Delete
* @var Options_Helper
[27] Fix | Delete
*/
[28] Fix | Delete
private $options_helper;
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Workouts_Route constructor.
[32] Fix | Delete
*
[33] Fix | Delete
* @param Options_Helper $options_helper The options helper.
[34] Fix | Delete
*/
[35] Fix | Delete
public function __construct(
[36] Fix | Delete
Options_Helper $options_helper
[37] Fix | Delete
) {
[38] Fix | Delete
$this->options_helper = $options_helper;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Registers routes with WordPress.
[43] Fix | Delete
*
[44] Fix | Delete
* @return void
[45] Fix | Delete
*/
[46] Fix | Delete
public function register_routes() {
[47] Fix | Delete
$edit_others_posts = static function () {
[48] Fix | Delete
return \current_user_can( 'edit_others_posts' );
[49] Fix | Delete
};
[50] Fix | Delete
[51] Fix | Delete
$workouts_route = [
[52] Fix | Delete
[
[53] Fix | Delete
'methods' => 'GET',
[54] Fix | Delete
'callback' => [ $this, 'get_workouts' ],
[55] Fix | Delete
'permission_callback' => $edit_others_posts,
[56] Fix | Delete
],
[57] Fix | Delete
[
[58] Fix | Delete
'methods' => 'POST',
[59] Fix | Delete
'callback' => [ $this, 'set_workouts' ],
[60] Fix | Delete
'permission_callback' => $edit_others_posts,
[61] Fix | Delete
'args' => $this->get_workouts_routes_args(),
[62] Fix | Delete
],
[63] Fix | Delete
];
[64] Fix | Delete
[65] Fix | Delete
\register_rest_route( Main::API_V1_NAMESPACE, self::WORKOUTS_ROUTE, $workouts_route );
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Returns the workouts as configured for the site.
[70] Fix | Delete
*
[71] Fix | Delete
* @return WP_REST_Response the configuration of the workouts.
[72] Fix | Delete
*/
[73] Fix | Delete
public function get_workouts() {
[74] Fix | Delete
$workouts_option = $this->options_helper->get( 'workouts_data' );
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Filter: 'Yoast\WP\SEO\workouts_options' - Allows adding workouts options by the add-ons.
[78] Fix | Delete
*
[79] Fix | Delete
* @param array $workouts_option The content of the `workouts_data` option in Free.
[80] Fix | Delete
*/
[81] Fix | Delete
$workouts_option = \apply_filters( 'Yoast\WP\SEO\workouts_options', $workouts_option );
[82] Fix | Delete
[83] Fix | Delete
return new WP_REST_Response(
[84] Fix | Delete
[ 'json' => $workouts_option ]
[85] Fix | Delete
);
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Sets the workout configuration.
[90] Fix | Delete
*
[91] Fix | Delete
* @param WP_REST_Request $request The request object.
[92] Fix | Delete
*
[93] Fix | Delete
* @return WP_REST_Response the configuration of the workouts.
[94] Fix | Delete
*/
[95] Fix | Delete
public function set_workouts( $request ) {
[96] Fix | Delete
$workouts_data = $request->get_json_params();
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Filter: 'Yoast\WP\SEO\workouts_route_save' - Allows the add-ons to save the options data in their own options.
[100] Fix | Delete
*
[101] Fix | Delete
* @param mixed|null $result The result of the previous saving operation.
[102] Fix | Delete
*
[103] Fix | Delete
* @param array $workouts_data The full set of workouts option data to save.
[104] Fix | Delete
*/
[105] Fix | Delete
$result = \apply_filters( 'Yoast\WP\SEO\workouts_route_save', null, $workouts_data );
[106] Fix | Delete
[107] Fix | Delete
return new WP_REST_Response(
[108] Fix | Delete
[ 'json' => $result ]
[109] Fix | Delete
);
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* Gets the args for all the registered workouts.
[114] Fix | Delete
*
[115] Fix | Delete
* @return array
[116] Fix | Delete
*/
[117] Fix | Delete
private function get_workouts_routes_args() {
[118] Fix | Delete
$args_array = [];
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* Filter: 'Yoast\WP\SEO\workouts_route_args' - Allows the add-ons add their own arguments to the route registration.
[122] Fix | Delete
*
[123] Fix | Delete
* @param array $args_array The array of arguments for the route registration.
[124] Fix | Delete
*/
[125] Fix | Delete
return \apply_filters( 'Yoast\WP\SEO\workouts_route_args', $args_array );
[126] Fix | Delete
}
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function