예제 #1
0
 /**
  * Prints all the restrictions for a field (for instance outputs 'required=""' on required fields). Used while printing form elements.
  *
  * @access private
  *
  * @param array $field An array containing field data.
  * @return string A string containing all the restrictions for the field, ready to be inserted in the form element.
  **/
 private function print_restrictions($field)
 {
     $restriction_array = array();
     if (isset($field['multiple']) && $field['multiple']) {
         $restriction_array[] = 'multiple';
     }
     if (wpfepp_current_user_has($this->settings['no_restrictions'])) {
         $restriction_string = implode(' ', $restriction_array);
         return $restriction_string;
     }
     if (isset($field['required']) && $field['required']) {
         if ($field['type'] == 'thumbnail') {
             $restriction_array[] = 'hiddenrequired="1"';
         } else {
             $restriction_array[] = 'required';
         }
     }
     if (isset($field['min_words']) && $field['min_words'] && is_numeric($field['min_words'])) {
         $restriction_array[] = sprintf('minwords="%d"', $field['min_words']);
     }
     if (isset($field['max_words']) && $field['max_words'] && is_numeric($field['max_words'])) {
         $restriction_array[] = sprintf('maxwords="%d"', $field['max_words']);
     }
     if (isset($field['min_links']) && $field['min_links'] && is_numeric($field['min_links'])) {
         $restriction_array[] = sprintf('minlinks="%d"', $field['min_links']);
     }
     if (isset($field['max_links']) && $field['max_links'] && is_numeric($field['max_links'])) {
         $restriction_array[] = sprintf('maxlinks="%d"', $field['max_links']);
     }
     if (isset($field['min_count']) && $field['min_count'] && is_numeric($field['min_count'])) {
         $restriction_array[] = sprintf('minsegments="%d"', $field['min_count']);
     }
     if (isset($field['max_count']) && $field['max_count'] && is_numeric($field['max_count'])) {
         $restriction_array[] = sprintf('maxsegments="%d"', $field['max_count']);
     }
     $restriction_string = implode(' ', $restriction_array);
     return $restriction_string;
 }
예제 #2
0
파일: form.php 프로젝트: poweronio/mbsite
                    ?>
-field" class="wpfepp-<?php 
                    echo $field_key;
                    ?>
-plain-field wpfepp-form-field" name="<?php 
                    echo $field_key;
                    ?>
"><?php 
                    echo esc_textarea($field_current);
                    ?>
</textarea>
						<?php 
                }
                ?>
						<?php 
                if (!wpfepp_current_user_has($this->settings['no_restrictions'])) {
                    ?>
							<script>
								function wpfepp_set_content_restrictions($){
									<?php 
                    if ($field['required']) {
                        ?>
$('textarea#wpfepp-<?php 
                        echo $unique_key;
                        ?>
-field').attr('required', 'true');<?php 
                    }
                    ?>
									<?php 
                    if ($field["min_words"] && is_numeric($field["min_words"])) {
                        ?>
 /**
  * This function prevents the users from uploading files larger than the size specified in the plugin's control panel.
  * @var $file The file uploaded by the user.
  * @return $file The file uploaded by the user.
  **/
 public function upload_size($file)
 {
     if (wpfepp_current_user_has($this->media_settings['exempt_roles'])) {
         return $file;
     }
     $max_upload_size = $this->media_settings['max_upload_size'];
     $size = $file['size'];
     if ($size > $max_upload_size * 1024) {
         $file['error'] = sprintf(__("Files larger than %s kilobytes are not allowed.", 'wpfepp-plugin'), $max_upload_size);
     }
     return $file;
 }