← All changes
|
src/content-helper/dashboard-widget/class-dashboard-widget.php
+8
-9
3.16.1
→
3.24.3
View file →
| @@ -9,14 +9,12 @@ | ||
| 9 | 9 | declare(strict_types=1); |
| 10 | 10 | |
| 11 | 11 | namespace Parsely\Content_Helper; |
| 12 | 12 | |
| 13 | -use Parsely\Endpoints\User_Meta\Dashboard_Widget_Settings_Endpoint; | |
| 14 | 13 | use Parsely\Parsely; |
| 15 | -use Parsely\RemoteAPI\Analytics_Posts_API; | |
| 14 | +use Parsely\Utils\Utils; | |
| 15 | +use Parsely\REST_API\Settings\Endpoint_Dashboard_Widget_Settings; | |
| 16 | 16 | |
| 17 | -use function Parsely\Utils\get_asset_info; | |
| 18 | - | |
| 19 | 17 | use const Parsely\PARSELY_FILE; |
| 20 | 18 | |
| 21 | 19 | /** |
| 22 | 20 | * Class that generates and manages the PCH Dashboard Widget. |
| @@ -88,14 +86,15 @@ | ||
| 88 | 86 | * |
| 89 | 87 | * @return bool Whether the Dashboard Widget can be enabled. |
| 90 | 88 | */ |
| 91 | 89 | public function can_enable_widget(): bool { |
| 92 | - $screen = get_current_screen(); | |
| 93 | - $posts_api = new Analytics_Posts_API( $GLOBALS['parsely'] ); | |
| 90 | + $screen = get_current_screen(); | |
| 94 | 91 | |
| 95 | 92 | return $this->can_enable_feature( |
| 96 | 93 | null !== $screen && 'dashboard' === $screen->id, |
| 97 | - $posts_api->is_available_to_current_user() | |
| 94 | + $this->parsely->get_rest_api_controller()->is_available_to_current_user( | |
| 95 | + '/stats/posts' | |
| 96 | + ) | |
| 98 | 97 | ); |
| 99 | 98 | } |
| 100 | 99 | |
| 101 | 100 | /** |
| @@ -124,9 +123,9 @@ | ||
| 124 | 123 | if ( ! $this->can_enable_widget() ) { |
| 125 | 124 | return; |
| 126 | 125 | } |
| 127 | 126 | |
| 128 | - $asset_php = get_asset_info( 'build/content-helper/dashboard-widget.asset.php' ); | |
| 127 | + $asset_php = Utils::get_asset_info( 'build/content-helper/dashboard-widget.asset.php' ); | |
| 129 | 128 | $built_assets_url = plugin_dir_url( PARSELY_FILE ) . 'build/content-helper/'; |
| 130 | 129 | |
| 131 | 130 | wp_enqueue_script( |
| 132 | 131 | static::get_script_id(), |
| @@ -135,9 +134,9 @@ | ||
| 135 | 134 | $asset_php['version'], |
| 136 | 135 | true |
| 137 | 136 | ); |
| 138 | 137 | |
| 139 | - $this->inject_inline_scripts( Dashboard_Widget_Settings_Endpoint::get_route() ); | |
| 138 | + $this->inject_inline_scripts( Endpoint_Dashboard_Widget_Settings::get_endpoint_name() ); | |
| 140 | 139 | |
| 141 | 140 | wp_enqueue_style( |
| 142 | 141 | static::get_style_id(), |
| 143 | 142 | $built_assets_url . 'dashboard-widget.css', |