PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,79 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Endpoints
*/
/**
* Represents an implementation of the WPSEO_Endpoint interface to register one or multiple endpoints.
*/
class WPSEO_Endpoint_File_Size implements WPSEO_Endpoint {
/**
* @var string
*/
const REST_NAMESPACE = 'yoast/v1';
/**
* @var string
*/
const ENDPOINT_SINGULAR = 'file_size';
/**
* @var string
*/
const CAPABILITY_RETRIEVE = 'manage_options';
/**
* The service provider.
*
* @var WPSEO_File_Size_Service
*/
private $service;
/**
* Sets the service provider.
*
* @param WPSEO_File_Size_Service $service The service provider.
*/
public function __construct( WPSEO_File_Size_Service $service ) {
$this->service = $service;
}
/**
* Registers the routes for the endpoints.
*
* @return void
*/
public function register() {
$route_args = array(
'methods' => 'GET',
'args' => array(
'url' => array(
'required' => true,
'type' => 'string',
'description' => 'The url to retrieve',
),
),
'callback' => array(
$this->service,
'get',
),
'permission_callback' => array(
$this,
'can_retrieve_data',
),
);
register_rest_route( self::REST_NAMESPACE, self::ENDPOINT_SINGULAR, $route_args );
}
/**
* Determines whether or not data can be retrieved for the registered endpoints.
*
* @return bool Whether or not data can be retrieved.
*/
public function can_retrieve_data() {
return current_user_can( self::CAPABILITY_RETRIEVE );
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Endpoints
*/
/**
* Represents an implementation of the WPSEO_Endpoint interface to register one or multiple endpoints.
*/
class WPSEO_Endpoint_Indexable implements WPSEO_Endpoint, WPSEO_Endpoint_Storable {
/**
* @var string
*/
const REST_NAMESPACE = 'yoast/v1';
/**
* @var string
*/
const ENDPOINT_SINGULAR = 'indexables/(?P<object_type>\w+)/(?P<object_id>\d+)';
/**
* @var string
*/
const CAPABILITY_RETRIEVE = 'manage_options';
/**
* @var string
*/
const CAPABILITY_STORE = 'manage_options';
/**
* The indexable service.
*
* @var WPSEO_Indexable_Service
*/
private $service;
/**
* Sets the service provider.
*
* @param WPSEO_Indexable_Service $service The service provider.
*/
public function __construct( WPSEO_Indexable_Service $service ) {
$this->service = $service;
}
/**
* Registers the routes for the endpoints.
*
* @return void
*/
public function register() {
$endpoints = array();
$endpoints[] = new WPSEO_Endpoint_Factory(
self::REST_NAMESPACE,
self::ENDPOINT_SINGULAR,
array( $this->service, 'get_indexable' ),
array( $this, 'can_retrieve_data' )
);
$endpoints[] = new WPSEO_Endpoint_Factory(
self::REST_NAMESPACE,
self::ENDPOINT_SINGULAR,
array( $this->service, 'patch_indexable' ),
array( $this, 'can_store_data' ),
'PATCH'
);
foreach ( $endpoints as $endpoint ) {
$endpoint->register();
}
}
/**
* Determines whether or not data can be retrieved for the registered endpoints.
*
* @return bool Whether or not data can be retrieved.
*/
public function can_retrieve_data() {
return current_user_can( self::CAPABILITY_RETRIEVE );
}
/**
* Determines whether or not data can be stored for the registered endpoints.
*
* @return bool Whether or not data can be stored.
*/
public function can_store_data() {
return current_user_can( self::CAPABILITY_STORE );
}
}

View File

@ -0,0 +1,65 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\OnPage
*/
/**
* Represents an implementation of the WPSEO_Endpoint interface to register one or multiple endpoints.
*/
class WPSEO_Endpoint_Ryte implements WPSEO_Endpoint {
/**
* @var string
*/
const REST_NAMESPACE = 'yoast/v1';
/**
* @var string
*/
const ENDPOINT_RETRIEVE = 'ryte';
/**
* @var string
*/
const CAPABILITY_RETRIEVE = 'manage_options';
/**
* Service to use.
*
* @var WPSEO_Ryte_Service
*/
protected $service;
/**
* Constructs the WPSEO_Endpoint_Ryte class and sets the service to use.
*
* @param WPSEO_Ryte_Service $service Service to use.
*/
public function __construct( WPSEO_Ryte_Service $service ) {
$this->service = $service;
}
/**
* Registers the REST routes that are available on the endpoint.
*/
public function register() {
// Register fetch config.
$route_args = array(
'methods' => 'GET',
'callback' => array( $this->service, 'get_statistics' ),
'permission_callback' => array( $this, 'can_retrieve_data' ),
);
register_rest_route( self::REST_NAMESPACE, self::ENDPOINT_RETRIEVE, $route_args );
}
/**
* Determines whether or not data can be retrieved for the registered endpoints.
*
* @return bool Whether or not data can be retrieved.
*/
public function can_retrieve_data() {
return current_user_can( self::CAPABILITY_RETRIEVE );
}
}

View File

@ -0,0 +1,65 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Statistics
*/
/**
* Represents an implementation of the WPSEO_Endpoint interface to register one or multiple endpoints.
*/
class WPSEO_Endpoint_Statistics implements WPSEO_Endpoint {
/**
* @var string
*/
const REST_NAMESPACE = 'yoast/v1';
/**
* @var string
*/
const ENDPOINT_RETRIEVE = 'statistics';
/**
* @var string
*/
const CAPABILITY_RETRIEVE = 'read';
/**
* Service to use.
*
* @var WPSEO_Statistics_Service
*/
protected $service;
/**
* Constructs the WPSEO_Endpoint_Statistics class and sets the service to use.
*
* @param WPSEO_Statistics_Service $service Service to use.
*/
public function __construct( WPSEO_Statistics_Service $service ) {
$this->service = $service;
}
/**
* Registers the REST routes that are available on the endpoint.
*/
public function register() {
// Register fetch config.
$route_args = array(
'methods' => 'GET',
'callback' => array( $this->service, 'get_statistics' ),
'permission_callback' => array( $this, 'can_retrieve_data' ),
);
register_rest_route( self::REST_NAMESPACE, self::ENDPOINT_RETRIEVE, $route_args );
}
/**
* Determines whether or not data can be retrieved for the registered endpoints.
*
* @return bool Whether or not data can be retrieved.
*/
public function can_retrieve_data() {
return current_user_can( self::CAPABILITY_RETRIEVE );
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Endpoints
*/
/**
* Dictates the required methods for an Endpoint implementation.
*/
interface WPSEO_Endpoint {
/**
* Registers the routes for the endpoints.
*
* @return void
*/
public function register();
/**
* Determines whether or not data can be retrieved for the registered endpoints.
*
* @return bool Whether or not data can be retrieved.
*/
public function can_retrieve_data();
}

View File

@ -0,0 +1,19 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Endpoints
*/
/**
* Dictates the required methods for a storable implementation.
*/
interface WPSEO_Endpoint_Storable {
/**
* Determines whether or not data can be stored for the registered endpoints.
*
* @return bool Whether or not data can be stored.
*/
public function can_store_data();
}