[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.22.242.43: ~ $
<?php
defined( 'ABSPATH' ) || die;

/**
 * Media field class which users WordPress media popup to upload and select files.
 */
class RWMB_Media_Field extends RWMB_File_Field {
	public static function admin_enqueue_scripts() {
		parent::admin_enqueue_scripts();

		wp_enqueue_media();
		if ( ! is_admin() ) {
			wp_register_script( 'media-grid', includes_url( 'js/media-grid.min.js' ), [ 'media-editor' ], '4.9.7', true );
		}
		wp_enqueue_style( 'rwmb-media', RWMB_CSS_URL . 'media.css', [], RWMB_VER );
		wp_style_add_data( 'rwmb-media', 'path', RWMB_CSS_DIR . 'media.css' );
		wp_enqueue_script( 'rwmb-media', RWMB_JS_URL . 'media.js', [ 'jquery-ui-sortable', 'underscore', 'backbone', 'media-grid' ], RWMB_VER, true );

		RWMB_Helpers_Field::localize_script_once( 'rwmb-media', 'i18nRwmbMedia', [
			'add'                => apply_filters( 'rwmb_media_add_string', _x( '+ Add Media', 'media', 'meta-box' ) ),
			'single'             => apply_filters( 'rwmb_media_single_files_string', _x( ' file', 'media', 'meta-box' ) ),
			'multiple'           => apply_filters( 'rwmb_media_multiple_files_string', _x( ' files', 'media', 'meta-box' ) ),
			'remove'             => apply_filters( 'rwmb_media_remove_string', _x( 'Remove', 'media', 'meta-box' ) ),
			'edit'               => apply_filters( 'rwmb_media_edit_string', _x( 'Edit', 'media', 'meta-box' ) ),
			'view'               => apply_filters( 'rwmb_media_view_string', _x( 'View', 'media', 'meta-box' ) ),
			'noTitle'            => _x( 'No Title', 'media', 'meta-box' ),
			'loadingUrl'         => admin_url( 'images/spinner.gif' ),
			'extensions'         => static::get_mime_extensions(),
			'select'             => apply_filters( 'rwmb_media_select_string', _x( 'Select Files', 'media', 'meta-box' ) ),
			'or'                 => apply_filters( 'rwmb_media_or_string', _x( 'or', 'media', 'meta-box' ) ),
			'uploadInstructions' => apply_filters( 'rwmb_media_upload_instructions_string', _x( 'Drop files here to upload', 'media', 'meta-box' ) ),
		] );
	}

	public static function add_actions() {
		add_action( 'print_media_templates', [ get_called_class(), 'print_templates' ] );
	}

	/**
	 * Get meta value.
	 *
	 * @param int   $post_id Post ID.
	 * @param bool  $saved   Whether the meta box is saved at least once.
	 * @param array $field   Field parameters.
	 *
	 * @return mixed
	 */
	public static function meta( $post_id, $saved, $field ) {
		$meta = parent::meta( $post_id, $saved, $field );

		/*
		 * Update meta cache for all attachments, preparing for getting data for rendering in JS.
		 * This reduces the number of queries for updating all attachments' meta.
		 * @see get_attributes()
		 */
		$ids = (array) $meta;
		if ( $field['clone'] ) {
			foreach ( $ids as &$value ) {
				$value = (array) $value;
			}
			$ids = call_user_func_array( 'array_merge', $ids );
		}
		update_meta_cache( 'post', $ids );

		return $meta;
	}

	/**
	 * Get field HTML.
	 *
	 * @param mixed $meta  Meta value.
	 * @param array $field Field parameters.
	 *
	 * @return string
	 */
	public static function html( $meta, $field ) {
		$attributes = static::get_attributes( $field, $meta );

		$html = sprintf(
			'<input %s data-options="%s">',
			self::render_attributes( $attributes ),
			esc_attr( wp_json_encode( $field['js_options'] ) )
		);

		return $html;
	}

	/**
	 * Normalize parameters for field.
	 *
	 * @param array $field Field parameters.
	 *
	 * @return array
	 */
	public static function normalize( $field ) {
		$field = parent::normalize( $field );
		$field = wp_parse_args( $field, [
			'std'              => [],
			'mime_type'        => '',
			'max_file_uploads' => 0,
			'force_delete'     => false,
			'max_status'       => true,
			'js_options'       => [],
			'add_to'           => 'end',
		] );

		$field['js_options'] = wp_parse_args( $field['js_options'], [
			'mimeType'    => $field['mime_type'],
			'maxFiles'    => $field['max_file_uploads'],
			'forceDelete' => $field['force_delete'],
			'maxStatus'   => $field['max_status'],
			'addTo'       => $field['add_to'],
		] );

		$field['multiple'] = true;

		return $field;
	}

	/**
	 * Get the attributes for a field.
	 *
	 * @param array $field Field parameters.
	 * @param mixed $value Meta value.
	 *
	 * @return array
	 */
	public static function get_attributes( $field, $value = null ) {
		$value = (array) $value;

		$attributes           = parent::get_attributes( $field, $value );
		$attributes['type']   = 'hidden';
		$attributes['name']   = $field['clone'] ? str_replace( '[]', '', $attributes['name'] ) : $attributes['name'];
		$attributes['id']     = false;
		$attributes['value']  = implode( ',', $value );
		$attributes['class'] .= ' rwmb-media';

		// Add attachment details.
		$attachments                    = array_values( array_filter( array_map( 'wp_prepare_attachment_for_js', $value ) ) );
		$attributes['data-attachments'] = wp_json_encode( $attachments );

		if ( empty( $attachments ) ) {
			unset( $attributes['value'] );
		}

		return $attributes;
	}

	protected static function get_mime_extensions() : array {
		$mime_types = wp_get_mime_types();
		$extensions = [];
		foreach ( $mime_types as $ext => $mime ) {
			$ext                 = explode( '|', $ext );
			$extensions[ $mime ] = $ext;

			$mime_parts = explode( '/', $mime );
			if ( empty( $extensions[ $mime_parts[0] ] ) ) {
				$extensions[ $mime_parts[0] ] = [];
			}
			$extensions[ $mime_parts[0] ]        = array_merge( $extensions[ $mime_parts[0] ], $ext );
			$extensions[ $mime_parts[0] . '/*' ] = $extensions[ $mime_parts[0] ];
		}

		return $extensions;
	}

	/**
	 * Get meta values to save.
	 *
	 * @param mixed $new     The submitted meta value.
	 * @param mixed $old     The existing meta value.
	 * @param int   $post_id The post ID.
	 * @param array $field   The field parameters.
	 *
	 * @return array
	 */
	public static function value( $new, $old, $post_id, $field ) {
		$new = wp_parse_id_list( $new );

		if ( empty( $new ) ) {
			return [];
		}

		// Attach the uploaded images to the post if needed.
		global $wpdb;
		$ids = implode( ',', $new );
		// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
		$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent=%d WHERE post_parent=0 AND ID IN ($ids)", $post_id ) );

		return $new;
	}

	/**
	 * Save meta value.
	 *
	 * @param mixed $new     The submitted meta value.
	 * @param mixed $old     The existing meta value.
	 * @param int   $post_id The post ID.
	 * @param array $field   The field parameters.
	 */
	public static function save( $new, $old, $post_id, $field ) {
		if ( empty( $field['id'] ) || ! $field['save_field'] ) {
			return;
		}
		$storage = $field['storage'];
		$storage->delete( $post_id, $field['id'] );
		parent::save( $new, [], $post_id, $field );
	}

	/**
	 * Template for media item.
	 */
	public static function print_templates() {
		require RWMB_INC_DIR . 'templates/media.php';
	}
}

Filemanager

Name Type Size Permission Actions
autocomplete.php File 2.94 KB 0644
background.php File 5.32 KB 0644
button-group.php File 1.84 KB 0644
button.php File 1.26 KB 0644
checkbox-list.php File 468 B 0644
checkbox.php File 1.25 KB 0644
choice.php File 1.84 KB 0644
color.php File 2.48 KB 0644
custom-html.php File 602 B 0644
date.php File 611 B 0644
datetime.php File 9.83 KB 0644
divider.php File 609 B 0644
fieldset-text.php File 3.36 KB 0644
file-input.php File 1.93 KB 0644
file-upload.php File 1.09 KB 0644
file.php File 15.39 KB 0644
heading.php File 678 B 0644
icon.php File 8.4 KB 0644
image-advanced.php File 2.35 KB 0644
image-select.php File 2.32 KB 0644
image-upload.php File 880 B 0644
image.php File 4.78 KB 0644
input-list.php File 2.62 KB 0644
input.php File 2.95 KB 0644
key-value.php File 2.86 KB 0644
map.php File 6.36 KB 0644
media.php File 6.85 KB 0644
multiple-values.php File 1.33 KB 0644
number.php File 910 B 0644
object-choice.php File 4.37 KB 0644
oembed.php File 4.05 KB 0644
osm.php File 5.11 KB 0644
password.php File 537 B 0644
post.php File 7.18 KB 0644
radio.php File 270 B 0644
range.php File 1.51 KB 0644
select-advanced.php File 2.39 KB 0644
select-tree.php File 1.51 KB 0644
select.php File 2.49 KB 0644
sidebar.php File 1.22 KB 0644
single-image.php File 1.73 KB 0644
slider.php File 2.28 KB 0644
switch.php File 2.32 KB 0644
taxonomy-advanced.php File 2.84 KB 0644
taxonomy.php File 9.08 KB 0644
text-list.php File 3.36 KB 0644
textarea.php File 1.57 KB 0644
time.php File 938 B 0644
user.php File 5.03 KB 0644
video.php File 3.94 KB 0644
wysiwyg.php File 2.28 KB 0644