$30 GRAYBYTE WORDPRESS FILE MANAGER $92

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.162.162 | ADMIN IP 216.73.217.88
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/home/bravetechrwanda/dantho.rw/wp-includes/rest-api/endpoints/

HOME
Current File : /home/bravetechrwanda/dantho.rw/wp-includes/rest-api/endpoints//class-wp-rest-icons-controller.php
<?php

/**
 * REST API: WP_REST_Icons_Controller class
 *
 * @package    WordPress
 * @subpackage REST_API
 * @since      7.0.0
 */

/**
 * Controller which provides a REST endpoint for the editor to read registered
 * icons. For the time being, only core icons are available, which are defined
 * in a single manifest file (wp-includes/assets/icon-library-manifest.php).
 * Icons are comprised of their SVG source, a name and a translatable label.
 *
 * @since 7.0.0
 *
 * @see WP_REST_Controller
 */
class WP_REST_Icons_Controller extends WP_REST_Controller {

	/**
	 * Constructs the controller.
	 */
	public function __construct() {
		$this->namespace = 'wp/v2';
		$this->rest_base = 'icons';
	}

	/**
	 * Registers the routes for the objects of the controller.
	 */
	public function register_routes() {
		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base,
			array(
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_items' ),
					'permission_callback' => array( $this, 'get_items_permissions_check' ),
					'args'                => $this->get_collection_params(),
				),
				'schema' => array( $this, 'get_public_item_schema' ),
			)
		);

		register_rest_route(
			$this->namespace,
			'/' . $this->rest_base . '/(?P<name>[a-z][a-z0-9-]*/[a-z][a-z0-9-]*)',
			array(
				'args'   => array(
					'name' => array(
						'description' => __( 'Icon name.' ),
						'type'        => 'string',
					),
				),
				array(
					'methods'             => WP_REST_Server::READABLE,
					'callback'            => array( $this, 'get_item' ),
					'permission_callback' => array( $this, 'get_item_permissions_check' ),
					'args'                => array(
						'context' => $this->get_context_param( array( 'default' => 'view' ) ),
					),
				),
				'schema' => array( $this, 'get_public_item_schema' ),
			)
		);
	}

	/**
	 * Checks whether a given request has permission to read icons.
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error True if the request has read access, WP_Error object otherwise.
	 */
	public function get_items_permissions_check(
		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
		$request
	) {
		if ( current_user_can( 'edit_posts' ) ) {
			return true;
		}

		foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
			if ( current_user_can( $post_type->cap->edit_posts ) ) {
				return true;
			}
		}

		return new WP_Error(
			'rest_cannot_view',
			__( 'Sorry, you are not allowed to view the registered icons.' ),
			array( 'status' => rest_authorization_required_code() )
		);
	}

	/**
	 * Checks if a given request has access to read a specific icon.
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise.
	 */
	public function get_item_permissions_check( $request ) {
		$check = $this->get_items_permissions_check( $request );
		if ( is_wp_error( $check ) ) {
			return $check;
		}

		return true;
	}

	/**
	 * Retrieves all icons.
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
	 */
	public function get_items( $request ) {
		$response = array();
		$search   = $request->get_param( 'search' );
		$icons    = WP_Icons_Registry::get_instance()->get_registered_icons( $search );
		foreach ( $icons as $icon ) {
			$prepared_icon = $this->prepare_item_for_response( $icon, $request );
			$response[]    = $this->prepare_response_for_collection( $prepared_icon );
		}
		return rest_ensure_response( $response );
	}

	/**
	 * Retrieves a specific icon.
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
	 */
	public function get_item( $request ) {
		$icon = $this->get_icon( $request['name'] );
		if ( is_wp_error( $icon ) ) {
			return $icon;
		}

		$data = $this->prepare_item_for_response( $icon, $request );
		return rest_ensure_response( $data );
	}

	/**
	 * Retrieves a specific icon from the registry.
	 *
	 * @param string $name Icon name.
	 * @return array|WP_Error Icon data on success, or WP_Error object on failure.
	 */
	public function get_icon( $name ) {
		$registry = WP_Icons_Registry::get_instance();
		$icon     = $registry->get_registered_icon( $name );

		if ( null === $icon ) {
			return new WP_Error(
				'rest_icon_not_found',
				sprintf(
					// translators: %s is the name of any user-provided name
					__( 'Icon not found: "%s".' ),
					$name
				),
				array( 'status' => 404 )
			);
		}

		return $icon;
	}

	/**
	 * Prepare a raw icon before it gets output in a REST API response.
	 *
	 * @param array           $item    Raw icon as registered, before any changes.
	 * @param WP_REST_Request $request Request object.
	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
	 */
	public function prepare_item_for_response( $item, $request ) {
		$fields = $this->get_fields_for_response( $request );
		$keys   = array(
			'name'    => 'name',
			'label'   => 'label',
			'content' => 'content',
		);
		$data   = array();
		foreach ( $keys as $item_key => $rest_key ) {
			if ( isset( $item[ $item_key ] ) && rest_is_field_included( $rest_key, $fields ) ) {
				$data[ $rest_key ] = $item[ $item_key ];
			}
		}

		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
		$data    = $this->add_additional_fields_to_object( $data, $request );
		$data    = $this->filter_response_by_context( $data, $context );
		return rest_ensure_response( $data );
	}

	/**
	 * Retrieves the icon schema, conforming to JSON Schema.
	 *
	 * @return array Item schema data.
	 */
	public function get_item_schema() {
		if ( $this->schema ) {
			return $this->add_additional_fields_schema( $this->schema );
		}

		$schema = array(
			'$schema'    => 'http://json-schema.org/draft-04/schema#',
			'title'      => 'icon',
			'type'       => 'object',
			'properties' => array(
				'name'    => array(
					'description' => __( 'The icon name.' ),
					'type'        => 'string',
					'readonly'    => true,
					'context'     => array( 'view', 'edit', 'embed' ),
				),
				'label'   => array(
					'description' => __( 'The icon label.' ),
					'type'        => 'string',
					'readonly'    => true,
					'context'     => array( 'view', 'edit', 'embed' ),
				),
				'content' => array(
					'description' => __( 'The icon content (SVG markup).' ),
					'type'        => 'string',
					'readonly'    => true,
					'context'     => array( 'view', 'edit', 'embed' ),
				),
			),
		);

		$this->schema = $schema;

		return $this->add_additional_fields_schema( $this->schema );
	}

	/**
	 * Retrieves the query params for the icons collection.
	 *
	 * @return array Collection parameters.
	 */
	public function get_collection_params() {
		$query_params                       = parent::get_collection_params();
		$query_params['context']['default'] = 'view';
		return $query_params;
	}
}

Current_dir [ WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
30 Mar 2026 1.32 AM
bravetechrwanda / bravetechrwanda
0755
class-wp-rest-abilities-v1-categories-controller.php
7.896 KB
3 Dec 2025 5.00 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-abilities-v1-list-controller.php
13.07 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-abilities-v1-run-controller.php
6.87 KB
3 Dec 2025 5.00 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-application-passwords-controller.php
23.748 KB
3 Dec 2025 5.00 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-attachments-controller.php
56.796 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-autosaves-controller.php
15.139 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-block-directory-controller.php
9.677 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-block-pattern-categories-controller.php
4.701 KB
11 Mar 2025 6.19 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-block-patterns-controller.php
9.078 KB
13 Jun 2024 7.06 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-block-renderer-controller.php
5.727 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-block-types-controller.php
26.247 KB
11 Mar 2025 6.19 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-blocks-controller.php
3.055 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-comments-controller.php
61.56 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-controller.php
18.593 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-edit-site-export-controller.php
2.061 KB
4 Mar 2025 11.07 AM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-font-collections-controller.php
10.393 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-font-faces-controller.php
29.404 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-font-families-controller.php
17.438 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-global-styles-controller.php
23.255 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-global-styles-revisions-controller.php
12.983 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-icons-controller.php
7.063 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-menu-items-controller.php
32.489 KB
3 Dec 2025 5.00 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-menu-locations-controller.php
8.675 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-menus-controller.php
16.677 KB
28 Jan 2025 9.09 AM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-navigation-fallback-controller.php
5.05 KB
16 Oct 2023 7.17 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-pattern-directory-controller.php
12.578 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-plugins-controller.php
27.86 KB
18 Sep 2024 1.33 AM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-post-statuses-controller.php
10.067 KB
9 Jul 2024 5.53 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-post-types-controller.php
13.948 KB
11 Mar 2025 6.19 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-posts-controller.php
102.466 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-revisions-controller.php
27.272 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-search-controller.php
11.212 KB
11 Mar 2025 6.19 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-settings-controller.php
10.088 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-sidebars-controller.php
15.528 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-site-health-controller.php
9.605 KB
12 Sep 2023 7.23 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-taxonomies-controller.php
13.687 KB
11 Mar 2025 6.19 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-template-autosaves-controller.php
7.642 KB
3 Mar 2025 3.07 AM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-template-revisions-controller.php
8.52 KB
3 Mar 2025 3.07 AM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-templates-controller.php
37.34 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-terms-controller.php
34.614 KB
30 Sep 2025 8.52 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-themes-controller.php
22.912 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-url-details-controller.php
20.071 KB
11 Jul 2024 10.24 AM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-users-controller.php
48.673 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-widget-types-controller.php
18.752 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
class-wp-rest-widgets-controller.php
26.232 KB
21 May 2026 3.20 PM
bravetechrwanda / bravetechrwanda
0644
error_log
62.141 KB
23 May 2026 10.20 PM
bravetechrwanda / bravetechrwanda
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF Static GIF