�PNG  IHDR22?�� pHYs  �� OiCCPPhotoshop ICC profilexڝSgTS�=���BK���KoR RB���&*! J�!��Q�EEȠ�����Q, � ��!���������{�kּ������>���� �H3Q5� �B�������.@� $p�d!s�#�~<<+"��x� �M��0���B�\���t�8K�@z�B�@F���&S�`�cb�P-`'������{[�!�� e�Dh;��V�EX0fK�9�-0IWfH���� � 0Q��){`�##x��F�W<�+��*x��<�$9E�[-qWW.(�I+6aa�@.�y�2�4���������x����6��_-��"bb���ϫp@�t~��,/��;�m��%�h^ �u��f�@����W�p�~<�5�j>{�-�]c�K'Xt����o��(�h���w��?�G�%�fI�q^D$.Tʳ?�D��*�A��,���� �`6�B$��BB d�r`)��B(�Ͱ*`/�@4�Qh��p.�U�=p�a��(�� A�a!ڈb�X#����!�H�$ ɈQ"K�5H1R�T UH�=r9�\F��;�2����G1���Q=� �C��7�F� �dt1�����r�=�6��Ыhڏ>C�0��3�l0.��B�8, �c˱"� ���V����cϱw�E� 6wB aAHXLXN�H� $4� 7 �Q�'"��K�&���b21�XH,#��/{�C�7$�C2'��I��T��F�nR#�,��4H#���dk�9�, +ȅ����3��!�[ �b@q��S�(R�jJ��4�e�2AU��Rݨ�T5�ZB���R�Q��4u�9̓IK�����hh�i��t�ݕN��W���G���w ��Ljg(�gw��L�Ӌ�T071���oUX*�*|�� �J�&�*/T����ު U�U�T��^S}�FU3S� Ԗ�U��P�SSg�;���g�oT?�~Y��Y�L�OC�Q��_�� c�x,!k ��u�5�&���|v*�����=���9C3J3W�R�f?�q��tN �(���~���)�)�4L�1e\k����X�H�Q�G�6������E�Y��A�J'\'Gg����S�Sݧ �M=:��.�k���Dw�n��^��Lo��y���}/�T�m���G X� $� �<�5qo</���QC]�@C�a�a�ᄑ��<��F�F�i�\�$�m�mƣ&&!&KM�M�RM��)�;L;L���͢�֙5�=1�2��כ߷`ZxZ,����eI��Z�Yn�Z9Y�XUZ]�F���%ֻ�����N�N���gð�ɶ�����ۮ�m�}agbg�Ů��}�}��= ���Z~s�r:V:ޚΜ�?}����/gX���3��)�i�S��Ggg�s�󈋉K��.�>.���Ƚ�Jt�q]�z���������ۯ�6�i�ܟ�4�)�Y3s���C�Q��? ��0k߬~OCO�g��#/c/�W�װ��w��a�>�>r��>�<7�2�Y_�7��ȷ�O�o�_��C#�d�z����%g��A�[��z|!��?:�e����A���AA�������!h�쐭!��Α�i�P~���a�a��~ '���W�?�p�X�1�5w��Cs�D�D�Dޛg1O9�-J5*>�.j<�7�4�?�.fY��X�XIlK9.*�6nl������� �{�/�]py�����.,:�@L�N8��A*��%�w%� y��g"/�6ш�C\*N�H*Mz�쑼5y$�3�,幄'���L Lݛ:��v m2=:�1����qB�!M��g�g�fvˬe����n��/��k���Y- �B��TZ(�*�geWf�͉�9���+��̳�ې7�����ᒶ��KW-X潬j9�������(�x��oʿ�ܔ���Ĺd�f�f���-�[����n �ڴ �V����E�/��(ۻ��C���<��e����;?T�T�T�T6��ݵa��n��{��4���[���>ɾ�UUM�f�e�I���?�������m]�Nmq����#�׹���=TR��+�G�����w- 6 U����#pDy��� �� :�v�{���vg/jB��F�S��[b[�O�>����z�G��499�?r����C�d�&����ˮ/~�����јѡ�򗓿m|������������x31^�V���w�w��O�| (�h���SЧ��������c3-� cHRMz%������u0�`:�o�_�F5IDATx��ytUս�?�;���fN$$��@B�!�k��� -*�gE���j�O�kQ�ʠ`U�B_ �AÐ0%�Ȕ�@r3ޛ;߳��$�@��v����^�s����������$��ߢ !�W��5�̱'-٘������4�>�Rƫ$�G��0U�H}�_ _� #��k�MJ/=�9Du *ڲ�k�PQ;0��j|�*�$�^컂脛y���>�z×� B��� ��(�:$�ʔ_�6��C!B����MVx��a��ζyY����j��ƋY2�9�F�{r��r�딟F��Q��hY6��� x��[l��RC��������nt@��;P��3��� F�w��7��:�P���ɋ'���mj���Bƪ�$�Q�L��y��߷g��\���z����v5�p�v$�v櫻�`6~K �Y�X����,�:��"�o�e0II"(��,������l_�C���/4�+f�E�!q��:����u����c��樼.UE�@� �]K�W���$-�h]�JG���Dz)�`��.�A/ ���mᏣc�3jK� �!�>���$�Q�!�_�? \�C2(E �M$Z I{�U���s�ǣ���=��@Բe ޻��W�����@ �w����}�9v,)��.}*|"�s��di���,���G�]W�AC�������|<����[��ߕ������K�*�G nߴ!��‹��J�!��6(L�a)��Am��������;adf��:�xm��nh�;֦I��(���o�C~ډa?�=��s����h��E������xp����)���_���t��W�����´;8���`dz=(��@@�+,�;�`�fhl��XȌ�3,uI�~z(J����� �ZX�A����H'�À�㜦�82|��a�n�z2��I���� ���EY�h�ε<�0�q�{��C��v�˅��?"@��χ�x�WS+��N�~�KQ�J�8ل�� _.W��� !TU{�����,��"�� �;�������HI S� ��))�o�1�H�D� ���� (� ;����"Ҕ��,���� �F=���O��&�Ph>�`���y��߲ &S��P�<��'��1s�1cĂ�N����2)����@�u��tv��<�+�-&�����h��[!FSG���' � z z0��<����8d&�����E0�,��<��"!P�b4��� �{S�����X����.�囤���T��hEF��X�q0"-<����h���]�Py*����F⩍��@v�˂�Y08�� .q��a��s����(!<̫1�3�L�H��7sYW�`��qtu�\7��?�@�Y�� %Ka�x�GZ�*W�P��y�����N0r9��Z�c�%���q,��k�����!!,��>���IB��� �x1�Xu�Y���v-���ֺ��N������JP��a�2`�e5��w��u;�6�i���̃��(K���ťa��(l51��JL��O'%���]���ٖ뿉!��{*�p+f ���i8��D�ȑ���ܩ�M��V��ӟz��x�7Z�1i}�^͜���6e����x��)u�d�ˏ�V�eG�\�X1�����=n�U'�~Y����L�\,�(d!x ,�:�TW8� M`r���@��r+v�Q0��>^;˴�VbF��('����� �*O��i��j�Ӆ����^�S3&� ���{������.ی�� N;��NU%d0�Ce\r"�C�b��&t7N�7��� �ȪD�[%l�۪�$��'m?�A9tI�9>��NVL ��� 6v~M�����ъ�B���0����9$&=ώm��W�0���L���&��E���f�f��'+�9��hv��7,���M��6�D�&�^� �����8 D֮�����o��k^z��O��hP�8q�5d*��YVq3�{��������#LX4�?��jP=3�~�؅c�ݰ�̱�ұ��8̲��2�G�����j��έ�9��w7���U�X�w�85C��?!I&���o&����L���I#�^�eV�,�^t5�k� �xs˛\��U�8��."���{���ǵ�l4��ݼ�;��r"���G�/~���gJV�N糦��ZZ^k+NN�D��I$�=OE�z����|*�*{��%k���G��>�`9��b;�s���8,�qs��c��.b��q�%�>r��n�R�Ƨ�%�,�A��le#�8���}; 21�0�b�&�QX�f���q�00����$>�h�N�'�a3��A���/�r ��L5�8�GԲ'�����w;��c#�q1���h$*��V^�k��QĽ�b:i������� ����H F#�_���,��]g����Ը����`RUU���� ��"�qD���>-��ϤI�~��3�̴�����NZ[[555�eeek7�m����YF#[��Đ��R��i��L�H�r ��@��J-�Pŝ��_|�-��6y��ks�V�U~��6���w.����(��0A� 4��f��� /���C�xŊ�ٳ����z=6�����rg���mKo��o�/����a�g���?'9%9��P��斓��~���L{�� �H��{AW��B��$����v�1b�&Mb�ر��ر#�0`�`xMBp! )Z�Nmo�mZ�g�}�eذaWTVV ���'99��C5��&�&+5�bT>|8��PUUETT����&���t��~TE%��'������b�tEGG;RSS�S�N�v��ѯ��t����u1@�ޚ"f��͈���r'L�Ph��m��ƌ�74o��`�x�q�P���NRSS�X,�����l&&&��MFFA!-��`��ҷ�n��Yuu�����x<I�LB%����KԒ50�!�3�bz�����ʸKL���;---�l6[��`��������Ȏ;�����egg4��!D�T��jWujyZ��������K����%����p�^���X,6��sV=�ܖ����6�3�X ���4ҿ��A2�&����_k�;d�� �VfOIEND�B`� 0x0x
PHP 8.1.34
Preview: cloud.php Size: 15.36 KB
/home2/astrociv/www/wp-content/plugins/elementor/includes/template-library/sources/cloud.php
<?php
namespace Elementor\TemplateLibrary;

use Elementor\Core\Base\Document;
use Elementor\Core\Utils\Exceptions;
use Elementor\Modules\CloudLibrary\Connect\Cloud_Library;
use Elementor\Modules\CloudLibrary\Documents\Cloud_Template_Preview;
use Elementor\Plugin;
use Elementor\DB;

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

class Source_Cloud extends Source_Base {
	const FOLDER_RESOURCE_TYPE = 'FOLDER';
	const TEMPLATE_RESOURCE_TYPE = 'TEMPLATE';

	protected function get_app(): Cloud_Library {
		$cloud_library_app = Plugin::$instance->common->get_component( 'connect' )->get_app( 'cloud-library' );

		if ( ! $cloud_library_app ) {
			$error_message = esc_html__( 'Cloud-Library is not instantiated.', 'elementor' );

			throw new \Exception( $error_message, Exceptions::FORBIDDEN ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
		}

		return $cloud_library_app;
	}

	public function get_id(): string {
		return 'cloud';
	}

	public function get_title(): string {
		return esc_html__( 'Cloud Library', 'elementor' );
	}

	public function register_data() {}

	public function supports_quota(): bool {
		return true;
	}

	public function get_items( $args = [] ) {
		return $this->get_app()->get_resources( $args );
	}

	public function get_item_children( array $args = [] ) {
		return $this->get_app()->get_resources( [ 'parentId' => $args['template_id'] ] );
	}

	public function get_item( $id ) {
		return $this->get_app()->get_resource( [ 'id' => $id ] );
	}

	public function get_data( array $args ) {
		$data = $this->get_app()->get_resource( [ 'id' => $args['template_id'] ] );

		if ( is_wp_error( $data ) || empty( $data['content'] ) ) {
			return $data;
		}

		$decoded_data = json_decode( $data['content'], true );
		$data['content'] = $decoded_data['content'];

		Plugin::$instance->uploads_manager->set_elementor_upload_state( true );

		$data['content'] = $this->replace_elements_ids( $data['content'] );
		$data['content'] = $this->process_export_import_content( $data['content'], 'on_import' );

		if ( ! empty( $args['editor_post_id'] ) ) {
			$post_id = $args['editor_post_id'];
			$document = Plugin::$instance->documents->get( $post_id );
			if ( $document ) {
				$data['content'] = $document->get_elements_raw_data( $data['content'], true );
			}
		}

		if ( ! empty( $args['with_page_settings'] ) ) {
			$data['page_settings'] = $decoded_data['page_settings'];
		}

		$snapshots = apply_filters(
			'elementor/template_library/get_data/extract_snapshots',
			[],
			$decoded_data,
			$data
		);

		static::attach_global_styles_to_data_static( $data, $snapshots );

		// After the upload complete, set the elementor upload state back to false
		Plugin::$instance->uploads_manager->set_elementor_upload_state( false );

		return $data;
	}

	public function delete_template( $template_id ) {
		return $this->get_app()->delete_resource( $template_id );
	}

	public function save_item( $template_data ): int {
		$app = $this->get_app();

		$resource_data = $this->format_resource_item_for_create( $template_data );

		$response = $app->post_resource( $resource_data );

		return (int) $response['id'];
	}

	private function format_resource_item_for_create( $template_data ) {
		$content_payload = [
			'content' => $template_data['content'],
			'page_settings' => $template_data['page_settings'],
		];

		if ( is_array( $template_data['content'] ?? null ) ) {
			$this->attach_global_styles_to_data( $content_payload, $template_data['content'], 0 );
		}

		return [
			'title' => $template_data['title'] ?? esc_html__( '(no title)', 'elementor' ),
			'type' => self::TEMPLATE_RESOURCE_TYPE,
			'templateType' => $template_data['type'],
			'parentId' => ! empty( $template_data['parentId'] ) ? (int) $template_data['parentId'] : null,
			'content' => wp_json_encode( $content_payload ),
			'hasPageSettings' => ! empty( $template_data['page_settings'] ),
		];
	}

	public function save_folder( array $folder_data = [] ) {
		$app = $this->get_app();

		$resource_data = [
			'title' => $folder_data['title'] ?? esc_html__( 'New Folder', 'elementor' ),
			'type' => self::FOLDER_RESOURCE_TYPE,
			'templateType' => 'folder',
			'parentId' => null,
		];

		$response = $app->post_resource( $resource_data );

		return (int) $response['id'];
	}

	public function update_item( $template_data ) {
		return $this->get_app()->update_resource( $template_data );
	}

	public function search_templates( array $args = [] ) {
		return $this->get_app()->get_resources( $args );
	}

	public function export_template( $id ) {
		$data = $this->get_app()->get_resource( [ 'id' => $id ] );

		if ( is_wp_error( $data ) ) {
			return new \WP_Error( 'export_template_error', 'An error has occurred' );
		}

		if ( static::TEMPLATE_RESOURCE_TYPE === $data['type'] ) {
			$this->handle_export_file( $data );
		}

		if ( static::FOLDER_RESOURCE_TYPE === $data['type'] ) {
			$this->handle_export_folder( $id );
		}
	}

	protected function handle_export_file( array $data ): void {
		$file_data = $this->prepare_template_export( $data );

		if ( is_wp_error( $file_data ) ) {
			return;
		}

		$this->send_file_headers( $file_data['name'], strlen( $file_data['content'] ) );

		$this->serve_file( $file_data['content'] );
	}

	protected function handle_export_folder( int $folder_id ) {
		$data = $this->get_item_children( [ 'template_id' => $folder_id ] );

		if ( empty( $data['templates'] ) ) {
			throw new \Exception( 'Folder does not have any templates to export' );
		}

		$template_ids = array_map( fn( $template ) => $template['template_id'], $data['templates'] );

		$this->export_multiple_templates( $template_ids );
	}

	private function prepare_template_export( $data ) {
		if ( empty( $data['content'] ) ) {
			throw new \Exception( 'Template data not found' );
		}

		$data['content'] = json_decode( $data['content'], true );

		if ( empty( $data['content']['content'] ) ) {
			throw new \Exception( 'The template is empty' );
		}

		$export_data = [
			'content' => $data['content']['content'],
			'page_settings' => $data['content']['page_settings'] ?? [],
			'version' => DB::DB_VERSION,
			'title' => $data['title'],
			'type' => $data['templateType'],
		];

		$this->attach_global_styles_to_data(
			$export_data,
			$export_data['content'],
			(int) ( $data['id'] ?? 0 ),
			[
				'global_classes' => $data['content']['global_classes'] ?? null,
				'global_variables' => $data['content']['global_variables'] ?? null,
			]
		);

		return [
			'name' => 'elementor-' . $data['id'] . '-' . gmdate( 'Y-m-d' ) . '.json',
			'content' => wp_json_encode( $export_data ),
		];
	}

	public function export_multiple_templates( array $template_ids ) {
		$files = [];
		$temp_path = Plugin::$instance->uploads_manager->create_unique_dir();

		foreach ( $template_ids as $template_id ) {
			$files[] = $this->get_file_item( $template_id, $temp_path );
		}

		if ( empty( $files ) ) {
			throw new \Exception( 'There are no files to export (probably all the requested templates are empty).' );
		}

		list( $zip_archive_filename, $zip_complete_path ) = $this->handle_zip_file( $temp_path, $files );

		$this->send_file_headers( $zip_archive_filename, $this->filesize( $zip_complete_path ) );

		$this->serve_zip( $zip_complete_path );

		Plugin::$instance->uploads_manager->remove_file_or_dir( $temp_path );
	}

	protected function handle_zip_file( string $temp_path, array $files ): array {
		if ( ! class_exists( 'ZipArchive' ) ) {
			throw new \Error( 'ZipArchive module missing' );
		}

		$zip_archive_filename = 'elementor-templates-' . gmdate( 'Y-m-d' ) . '.zip';

		$zip_archive = new \ZipArchive();

		$zip_complete_path = $temp_path . '/' . $zip_archive_filename;

		$zip_archive->open( $zip_complete_path, \ZipArchive::CREATE );

		foreach ( $files as $file ) {
			$zip_archive->addFile( $file['path'], $file['name'] );
		}

		$zip_archive->close();

		return [ $zip_archive_filename, $zip_complete_path ];
	}

	private function get_file_item( $template_id, string $temp_path ) {
		$data      = $this->get_app()->get_resource( [ 'id' => $template_id ] );
		$file_data = $this->prepare_template_export( $data );

		if ( is_wp_error( $file_data ) ) {
			return;
		}

		$complete_path = $temp_path . $file_data['name'];

		$put_contents = file_put_contents( $complete_path, $file_data['content'] );

		if ( ! $put_contents ) {
			throw new \Exception( sprintf( 'Cannot create file "%s".', esc_html( $file_data['name'] ) ) );
		}

		return [
			'path' => $complete_path,
			'name' => $file_data['name'],
		];
	}

	public function move_template_to_folder( array $args = [] ) {
		$move_args = [
			'title' => $args['title'],
			'id' => $args['from_template_id'],
			'parentId' => ! empty( $args['parentId'] ) ? (int) $args['parentId'] : '',
		];

		return $this->update_item( $move_args );
	}

	public function move_bulk_templates_to_folder( array $args = [] ) {
		$move_args = [
			'ids' => $args['from_template_id'],
			'parentId' => ! empty( $args['parentId'] ) ? (int) $args['parentId'] : null,
		];

		return $this->get_app()->bulk_move_templates( $move_args );
	}

	public function save_item_preview( $template_id, $data ) {
		return $this->get_app()->update_resource_preview( $template_id, $data );
	}

	public function mark_preview_as_failed( $template_id, $data ) {
		return $this->get_app()->mark_preview_as_failed( $template_id, $data );
	}

	/**
	 * @param int $template_id
	 * @return Document|\WP_Error
	 * @throws \Exception If the user has no permission or the post is not found.
	 */
	public function create_document_for_preview( int $template_id ) {
		if ( ! current_user_can( 'edit_posts' ) ) {
			return new \WP_Error( Exceptions::FORBIDDEN, esc_html__( 'You do not have permission to create preview documents.', 'elementor' ) );
		}

		$cloud_library_app = $this->get_app();

		$template = $cloud_library_app->get_resource( [ 'id' => $template_id ] );

		if ( is_wp_error( $template ) ) {
			$error_message = $template->get_error_message();
			throw new \Exception( esc_html( $error_message ), Exceptions::FORBIDDEN );  // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
		}

		$decoded_content = json_decode( $template['content'], true );

		return $this->save_document_for_preview( [
			'content' => $decoded_content['content'],
			'page_settings' => $decoded_content['page_settings'],
		] );
	}

	protected function save_document_for_preview( $template_content ) {
		$template_data = [
			'title' => esc_html__( '(no title)', 'elementor' ),
			'page_settings' => $template_content['page_settings'] ?? [],
			'status' => 'draft',
			'type' => 'container',
		];

		$document = Plugin::$instance->documents->create(
			Cloud_Template_Preview::TYPE,
			[
				'post_title' => $template_data['title'],
				'post_status' => $template_data['status'],
			]
		);

		if ( is_wp_error( $document ) ) {
			wp_die();
		}

		$template_data['content'] = $this->replace_elements_ids( $template_content['content'] );

		$document->save( [
			'elements' => $template_data['content'],
			'settings' => $template_data['page_settings'],
		] );

		do_action( 'elementor/template-library/after_save_template', $document->get_main_id(), $template_data );
		do_action( 'elementor/template-library/after_update_template', $document->get_main_id(), $template_data );

		return $document;
	}

	public function bulk_delete_items( array $template_ids ) {
		return $this->get_app()->bulk_delete_resources( $template_ids );
	}


	public function bulk_undo_delete_items( array $template_ids ) {
		return $this->get_app()->bulk_undo_delete_resources( $template_ids );
	}

	public function save_bulk_items( array $data = [] ) {
		$items = [];

		foreach ( $data as $template_data ) {
			$items[] = $this->format_resource_item_for_create( $template_data );
		}

		return $this->get_app()->post_bulk_resources( $items );
	}

	public function get_bulk_items( array $args = [] ) {
		return $this->get_app()->get_bulk_resources_with_content( $args );
	}

	public function get_quota() {
		return $this->get_app()->get_quota();
	}

	public function import_template( $name, $path, $import_mode = 'match_site' ) {
		if ( empty( $path ) ) {
			return new \WP_Error( 'file_error', 'Please upload a file to import' );
		}

		Plugin::$instance->uploads_manager->set_elementor_upload_state( true );

		$items = [];

		$quota = $this->get_quota();

		if ( is_wp_error( $quota ) ) {
			return $quota;
		}

		if ( $quota['currentUsage'] >= $quota['threshold'] ) {
			return new \WP_Error( 'quota_error', 'The upload failed because you’ve saved the maximum templates already.' );
		}

		if ( 'zip' === pathinfo( $name, PATHINFO_EXTENSION ) ) {
			$extracted_files = Plugin::$instance->uploads_manager->extract_and_validate_zip( $path, [ 'json' ] );

			if ( is_wp_error( $extracted_files ) ) {
				Plugin::$instance->uploads_manager->remove_file_or_dir( $extracted_files['extraction_directory'] );

				return $extracted_files;
			}

			$items_to_save = [];

			foreach ( $extracted_files['files'] as $file_path ) {
				// Skip macOS metadata files and folders
				if ( false !== strpos( $file_path, '__MACOSX' ) || '.' === basename( $file_path )[0] ) {
					continue;
				}

				$prepared = $this->prepare_import_template_data( $file_path, $import_mode );

				if ( is_wp_error( $prepared ) ) {
					// Skip failed templates
					continue;
				}

				$items_to_save[] = $this->format_resource_item_for_create( $prepared );
			}

			$is_quota_valid = $this->validate_quota( $items_to_save );

			if ( is_wp_error( $is_quota_valid ) ) {
				return $is_quota_valid;
			}

			if ( ! $is_quota_valid ) {
				return new \WP_Error( 'quota_error', 'The upload failed because it will pass the maximum templates you can save.' );
			}

			$items = $this->get_app()->post_bulk_resources( $items_to_save );

			Plugin::$instance->uploads_manager->remove_file_or_dir( $extracted_files['extraction_directory'] );
		} else {
			$prepared = $this->prepare_import_template_data( $path, $import_mode );

			if ( is_wp_error( $prepared ) ) {
				return $prepared;
			}

			$is_quota_valid = $this->validate_quota( [ $prepared ] );

			if ( is_wp_error( $is_quota_valid ) ) {
				return $is_quota_valid;
			}

			if ( ! $is_quota_valid ) {
				return new \WP_Error( 'quota_error', 'The upload failed because it will pass the maximum templates you can save.' );
			}

			$item = $this->get_app()->post_resource( $this->format_resource_item_for_create( $prepared ) );

			if ( is_wp_error( $item ) ) {
				return $item;
			}

			$items[] = $item;
		}

		return $items;
	}

	public function validate_quota( $items ) {
		$quota = $this->get_quota();

		if ( is_wp_error( $quota ) ) {
			return $quota;
		}

		return $quota['currentUsage'] + count( $items ) <= $quota['threshold'];
	}

	public function format_args_for_bulk_action( $args ) {
		$templates = $this->get_bulk_items( $args );
		$bulk_args = [];

		foreach ( $templates as $template ) {
			$content = json_decode( $template['content'], true );

			$bulk_args[] = array_merge(
				$args,
				[
					'title' => $template['title'],
					'type' => $template['type'],
					'content' => $content['content'],
					'page_settings' => $content['page_settings'],
				]
			);
		}

		return $bulk_args;
	}

	public function format_args_for_single_action( $args ) {
		$data = $this->get_item( $args['from_template_id'] );

		if ( is_wp_error( $data ) || empty( $data['content'] ) ) {
			return new \WP_Error( 'template_error', 'Unable to format template args.' );
		}

		$decoded_data = json_decode( $data['content'], true );
		$args['content'] = $decoded_data['content'];
		$args['page_settings'] = $decoded_data['page_settings'];

		return $args;
	}
}

Directory Contents

Dirs: 1 × Files: 4
Name Size Perms Modified Actions
- drwxr-xr-x 2026-09-08 12:13:50
Edit Download
14.66 KB lrwxr-xr-x 2026-09-08 12:13:50
Edit Download
15.36 KB lrwxr-xr-x 2026-09-08 12:13:50
Edit Download
57.47 KB lrwxr-xr-x 2026-09-08 12:13:50
Edit Download
8.49 KB lrwxr-xr-x 2026-09-08 12:13:50
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 0xNothings — Secure File Manager. All rights reserved. Built with ❤️ & Tailwind x Dark UI