| @@ -19,9 +19,9 @@ | ||
| 19 | 19 | * Represents workouts route. |
| 20 | 20 | * |
| 21 | 21 | * @var string |
| 22 | 22 | */ |
| 23 | - const WORKOUTS_ROUTE = '/workouts'; | |
| 23 | + public const WORKOUTS_ROUTE = '/workouts'; | |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * The Options helper. |
| 27 | 27 | * |
| @@ -33,11 +33,9 @@ | ||
| 33 | 33 | * Workouts_Route constructor. |
| 34 | 34 | * |
| 35 | 35 | * @param Options_Helper $options_helper The options helper. |
| 36 | 36 | */ |
| 37 | - public function __construct( | |
| 38 | - Options_Helper $options_helper | |
| 39 | - ) { | |
| 37 | + public function __construct( Options_Helper $options_helper ) { | |
| 40 | 38 | $this->options_helper = $options_helper; |
| 41 | 39 | } |
| 42 | 40 | |
| 43 | 41 | /** |
| @@ -45,9 +43,9 @@ | ||
| 45 | 43 | * |
| 46 | 44 | * @return void |
| 47 | 45 | */ |
| 48 | 46 | public function register_routes() { |
| 49 | - $edit_others_posts = static function() { | |
| 47 | + $edit_others_posts = static function () { | |
| 50 | 48 | return \current_user_can( 'edit_others_posts' ); |
| 51 | 49 | }; |
| 52 | 50 | |
| 53 | 51 | $workouts_route = [ |
| @@ -77,14 +75,14 @@ | ||
| 77 | 75 | |
| 78 | 76 | /** |
| 79 | 77 | * Filter: 'Yoast\WP\SEO\workouts_options' - Allows adding workouts options by the add-ons. |
| 80 | 78 | * |
| 81 | - * @api array $workouts_option The content of the `workouts_data` option in Free. | |
| 79 | + * @param array $workouts_option The content of the `workouts_data` option in Free. | |
| 82 | 80 | */ |
| 83 | 81 | $workouts_option = \apply_filters( 'Yoast\WP\SEO\workouts_options', $workouts_option ); |
| 84 | 82 | |
| 85 | 83 | return new WP_REST_Response( |
| 86 | - [ 'json' => $workouts_option ] | |
| 84 | + [ 'json' => $workouts_option ], | |
| 87 | 85 | ); |
| 88 | 86 | } |
| 89 | 87 | |
| 90 | 88 | /** |
| @@ -89,9 +87,9 @@ | ||
| 89 | 87 | |
| 90 | 88 | /** |
| 91 | 89 | * Sets the workout configuration. |
| 92 | 90 | * |
| 93 | - * @param WP_Rest_Request $request The request object. | |
| 91 | + * @param WP_REST_Request $request The request object. | |
| 94 | 92 | * |
| 95 | 93 | * @return WP_REST_Response the configuration of the workouts. |
| 96 | 94 | */ |
| 97 | 95 | public function set_workouts( $request ) { |
| @@ -96,28 +94,19 @@ | ||
| 96 | 94 | */ |
| 97 | 95 | public function set_workouts( $request ) { |
| 98 | 96 | $workouts_data = $request->get_json_params(); |
| 99 | 97 | |
| 100 | - $free_workouts_data = []; | |
| 101 | - $free_workouts_data['configuration'] = $workouts_data['configuration']; | |
| 102 | - | |
| 103 | - $result = $this->options_helper->set( 'workouts_data', $free_workouts_data ); | |
| 104 | - | |
| 105 | - if ( count( $free_workouts_data['configuration']['finishedSteps'] ) === 5 ) { | |
| 106 | - $this->options_helper->set( 'first_time_install', false ); | |
| 107 | - } | |
| 108 | - | |
| 109 | 98 | /** |
| 110 | 99 | * Filter: 'Yoast\WP\SEO\workouts_route_save' - Allows the add-ons to save the options data in their own options. |
| 111 | 100 | * |
| 112 | - * @api mixed|null $result The result of the previous saving operation. | |
| 101 | + * @param mixed|null $result The result of the previous saving operation. | |
| 113 | 102 | * |
| 114 | 103 | * @param array $workouts_data The full set of workouts option data to save. |
| 115 | 104 | */ |
| 116 | - $result = \apply_filters( 'Yoast\WP\SEO\workouts_route_save', $result, $workouts_data ); | |
| 105 | + $result = \apply_filters( 'Yoast\WP\SEO\workouts_route_save', null, $workouts_data ); | |
| 117 | 106 | |
| 118 | 107 | return new WP_REST_Response( |
| 119 | - [ 'json' => $result ] | |
| 108 | + [ 'json' => $result ], | |
| 120 | 109 | ); |
| 121 | 110 | } |
| 122 | 111 | |
| 123 | 112 | /** |
| @@ -125,18 +114,14 @@ | ||
| 125 | 114 | * |
| 126 | 115 | * @return array |
| 127 | 116 | */ |
| 128 | 117 | private function get_workouts_routes_args() { |
| 129 | - $args_array = [ | |
| 130 | - 'configuration' => [ | |
| 131 | - 'required' => true, | |
| 132 | - ], | |
| 133 | - ]; | |
| 118 | + $args_array = []; | |
| 134 | 119 | |
| 135 | 120 | /** |
| 136 | 121 | * Filter: 'Yoast\WP\SEO\workouts_route_args' - Allows the add-ons add their own arguments to the route registration. |
| 137 | 122 | * |
| 138 | - * @api array $args_array The array of arguments for the route registration. | |
| 123 | + * @param array $args_array The array of arguments for the route registration. | |
| 139 | 124 | */ |
| 140 | 125 | return \apply_filters( 'Yoast\WP\SEO\workouts_route_args', $args_array ); |
| 141 | 126 | } |
| 142 | 127 | } |