$91 GRAYBYTE WORDPRESS FILE MANAGER $78

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

/home/bravrvjk/dantho.rw/wp-content/plugins/elementor/modules/components/

HOME
Current File : /home/bravrvjk/dantho.rw/wp-content/plugins/elementor/modules/components//components-repository.php
<?php

namespace Elementor\Modules\Components;

use Elementor\Modules\Components\Documents\Component as Component_Document;
use Elementor\Plugin;
use Elementor\Modules\Components\Components_REST_API;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

class Components_Repository {

	public static function make(): Components_Repository {
		return new self();
	}

	public function all() {
		// Components count is limited to 50, if we increase this number, we need to iterate the posts in batches.
		$posts = get_posts( [
			'post_type' => Component_Document::TYPE,
			'post_status' => 'publish',
			'posts_per_page' => Components_REST_API::MAX_COMPONENTS,
		] );

		$components = [];

		foreach ( $posts as $post ) {
			$doc = Plugin::$instance->documents->get( $post->ID );

			if ( ! $doc ) {
				continue;
			}

			$components[] = [
				'id' => $doc->get_main_id(),
				'name' => $doc->get_post()->post_title,
				'styles' => $this->extract_styles( $doc->get_elements_data() ),
			];
		}

		return Components::make( $components );
	}

	public function create( string $name, array $content ) {
		$document = Plugin::$instance->documents->create(
			Component_Document::get_type(),
			[
				'post_title' => $name,
				'post_status' => 'publish',
			]
		);

		$saved = $document->save( [
			'elements' => $content,
		] );

		if ( ! $saved ) {
			throw new \Exception( 'Failed to create component' );
		}

		return $document->get_main_id();
	}
	private function extract_styles( array $elements, array $styles = [] ) {
		foreach ( $elements as $element ) {
			if ( isset( $element['styles'] ) ) {
				$styles = array_merge( $styles, $element['styles'] );
			}

			if ( isset( $element['elements'] ) ) {
				$styles = $this->extract_styles( $element['elements'], $styles );
			}
		}

		return $styles;
	}
}


Current_dir [ WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
6 Nov 2025 10.43 AM
bravrvjk / bravrvjk
0755
documents
--
6 Nov 2025 10.43 AM
bravrvjk / bravrvjk
0755
styles
--
6 Nov 2025 10.43 AM
bravrvjk / bravrvjk
0755
widgets
--
6 Nov 2025 10.43 AM
bravrvjk / bravrvjk
0755
components-parser.php
0.946 KB
15 Sep 2025 2.10 PM
bravrvjk / bravrvjk
0644
components-repository.php
1.783 KB
15 Sep 2025 2.10 PM
bravrvjk / bravrvjk
0644
components-rest-api.php
4.463 KB
15 Sep 2025 2.10 PM
bravrvjk / bravrvjk
0644
components.php
0.482 KB
15 Sep 2025 2.10 PM
bravrvjk / bravrvjk
0644
module.php
1.911 KB
15 Sep 2025 2.10 PM
bravrvjk / bravrvjk
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF