Example #1
0
 public static function get_meta_types()
 {
     $types = (object) array();
     $default = (object) array('separator' => array('_id' => array('meta', 'separator'), '_name' => array('meta', 'separator'), 'type' => 'text', 'size' => 'tiny', 'class' => array(), 'value' => ',', 'placeholder' => __('E.g.: , ', self::plugin), 'label' => __('Separator', self::plugin)), 'weight' => array('_id' => array('meta', 'weight'), '_name' => array('meta', 'weight'), 'type' => 'number', 'class' => array(), 'value' => 90, 'min' => 0, 'max' => 100, 'placeholder' => __('E.g.: 55', self::plugin), 'label' => __('Weight', self::plugin)), 'qty' => array('_id' => array('meta', 'qty'), '_name' => array('meta', 'qty'), 'type' => 'range', 'class' => array(), 'label' => __('Quantity', self::plugin)));
     foreach ($default as $key => $field) {
         $default->{$key} = (object) $field;
     }
     $types->numbers = array('value' => 'numbers', 'text' => __('Number', self::plugin), 'template' => function ($field, $type) use($default) {
         $range = clone $field;
         $range->_id = array('meta', 'number');
         $range->_name = array('meta', 'number');
         $range->type = 'range';
         $range->class = array();
         $range->label = __('Range of possible numbers', Field::plugin);
         $range->_min = 0;
         $range->_max = 9;
         $html[] = Field::wrapper(Field::type_range($range, null, 'string'), $range);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->wp_query = array('value' => 'wp_query', 'text' => __('WP_Query', self::plugin), 'template' => function ($field, $type) use($default) {
         $query = clone $field;
         $query->_id = array('meta', 'query');
         $query->_name = array('meta', 'query');
         $query->type = 'text';
         $query->class = array();
         $query->size = 'large';
         $query->placeholder = __('category=2&posts_per_page=10', Field::plugin);
         $query->label = __('Uses <a href="http://codex.wordpress.org/Class_Reference/WP_Query" target="_blank">WP_Query</a>', Field::plugin);
         $html[] = Field::wrapper(Field::type_text($query, null, 'string'), $query);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->elements = array('value' => 'elements', 'text' => __('Elements', self::plugin), 'template' => function ($field, $type) use($default) {
         $tags = clone $field;
         $tags->_id = array('meta', 'elements');
         $tags->_name = array('meta', 'elements');
         $tags->type = 'dropdown';
         $tags->multiple = true;
         $tags->{'data-options'} = array();
         $tags->{'data-tags'} = true;
         $tags->class = array();
         $tags->placeholder = __('Type all possible elements (Tab or Return)', Field::plugin);
         $tags->label = __('', Field::plugin);
         $html[] = Field::wrapper(Field::type_dropdown($tags, null, 'string'), $tags);
         $html[] = Field::wrapper(Field::type_range($default->qty, null, 'string'), $default->qty);
         $html[] = Field::wrapper(Field::type_text($default->separator, null, 'string'), $default->separator);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->letter = array('value' => 'letter', 'text' => __('Letter', self::plugin), 'template' => function ($field, $type) use($default) {
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->words = array('value' => 'words', 'text' => __('Words', self::plugin), 'template' => function ($field, $type) use($default) {
         $html[] = Field::wrapper(Field::type_range($default->qty, null, 'string'), $default->qty);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->text = array('value' => 'text', 'text' => __('Text', self::plugin), 'template' => function ($field, $type) use($default) {
         $text = clone $field;
         $text->_id = array('meta', 'text_type');
         $text->_name = array('meta', 'text_type');
         $text->type = 'dropdown';
         $text->options = array(array('text' => __('Sentences', Field::plugin), 'value' => 'sentences'), array('text' => __('Paragraphs', Field::plugin), 'value' => 'paragraphs'));
         $text->value = 'paragraphs';
         $text->class = array();
         $separator = clone $default->separator;
         $separator->value = '\\n';
         $separator->label = __('Separator <b space>&mdash;</b> New Line: "\\n"', Field::plugin);
         $html[] = Field::wrapper(Field::type_dropdown($text, null, 'string'), $text);
         $html[] = Field::wrapper(Field::type_range($default->qty, null, 'string'), $default->qty);
         $html[] = Field::wrapper(Field::type_text($separator, null, 'string'), $separator);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->html = array('value' => 'html', 'text' => __('HTML', self::plugin), 'template' => function ($field, $type) use($default) {
         $elements = clone $field;
         $elements->_id = array('meta', 'elements');
         $elements->_name = array('meta', 'elements');
         $elements->type = 'dropdown';
         $elements->multiple = true;
         $elements->{'data-tags'} = true;
         $elements->{'data-options'} = array_merge(\Faker\Provider\HTML::$sets['header'], \Faker\Provider\HTML::$sets['list'], \Faker\Provider\HTML::$sets['block'], \Faker\Provider\HTML::$sets['self_close']);
         $elements->value = implode(',', $elements->{'data-options'});
         $elements->class = array();
         $elements->label = __('HTML Tags, without &lt; or &gt;', Field::plugin);
         $html[] = Field::wrapper(Field::type_dropdown($elements, null, 'string'), $elements);
         $html[] = Field::wrapper(Field::type_range($default->qty, null, 'string'), $default->qty);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->lexify = array('value' => 'lexify', 'text' => __('Lexify', self::plugin), 'template' => function ($field, $type) use($default) {
         $template = clone $field;
         $template->_id = array('meta', 'template');
         $template->_name = array('meta', 'template');
         $template->type = 'text';
         $template->class = array();
         $template->placeholder = __('E.g.: John ##??', Field::plugin);
         $template->label = __('John ##?? <b spacer>&raquo;</b> John 29ze', Field::plugin);
         $html[] = Field::wrapper(Field::type_text($template, null, 'string'), $template);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->asciify = array('value' => 'asciify', 'text' => __('Asciify', self::plugin), 'template' => function ($field, $type) use($default) {
         $template = clone $field;
         $template->_id = array('meta', 'template');
         $template->_name = array('meta', 'template');
         $template->type = 'text';
         $template->class = array();
         $template->placeholder = __('E.g.: John ****', Field::plugin);
         $template->label = __('John **** <b spacer>&raquo;</b> John r9"+', Field::plugin);
         $html[] = Field::wrapper(Field::type_text($template, null, 'string'), $template);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->regexify = array('value' => 'regexify', 'text' => __('Regexify', self::plugin), 'template' => function ($field, $type) use($default) {
         $template = clone $field;
         $template->_id = array('meta', 'template');
         $template->_name = array('meta', 'template');
         $template->type = 'text';
         $template->class = array();
         $template->placeholder = __('E.g.: [A-Z0-9._%+-]+@[A-Z0-9.-]', Field::plugin);
         $template->label = __('[A-Z0-9._%+-]+@[A-Z0-9.-] <b spacer>&raquo;</b> sm0@y8k96a', Field::plugin);
         $html[] = Field::wrapper(Field::type_text($template, null, 'string'), $template);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->person = array('value' => 'person', 'text' => __('Person', self::plugin), 'template' => function ($field, $type) use($default) {
         $template = clone $field;
         $template->_id = array('meta', 'template');
         $template->_name = array('meta', 'template');
         $template->type = 'dropdown';
         $template->multiple = true;
         $template->{'data-tags'} = true;
         $template->{'data-options'} = array(array('text' => __('Title', Field::plugin), 'value' => '{% title %}'), array('text' => __('First Name', Field::plugin), 'value' => '{% first_name %}'), array('text' => __('Last Name', Field::plugin), 'value' => '{% last_name %}'), array('text' => __('Suffix', Field::plugin), 'value' => '{% suffix %}'));
         $template->value = 'title,first_name,last_name,suffix';
         $template->value = '{% title %}|{% first_name %}|{% last_name %}|{% suffix %}';
         $template->{'data-separator'} = '|';
         $template->class = array();
         $template->label = __('Name Template', Field::plugin);
         $gender = clone $field;
         $gender->_id = array('meta', 'gender');
         $gender->_name = array('meta', 'gender');
         $gender->type = 'radio';
         $gender->options = array(array('text' => __('Male', Field::plugin), 'value' => 'male'), array('text' => __('Female', Field::plugin), 'value' => 'female'));
         $gender->value = 'female';
         $gender->class = array();
         $html[] = Field::wrapper(Field::type_dropdown($template, null, 'string'), $template);
         $html[] = Field::wrapper(Field::type_radio($gender, null, 'string'), $gender);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->geo = array('value' => 'geo', 'text' => __('Geo Information', self::plugin), 'template' => function ($field, $type) use($default) {
         $template = clone $field;
         $template->_id = array('meta', 'template');
         $template->_name = array('meta', 'template');
         $template->type = 'dropdown';
         $template->multiple = true;
         $template->{'data-tags'} = true;
         $template->{'data-options'} = array(array('text' => __('Country', Field::plugin), 'value' => '{% country %}'), array('text' => __('City Prefix', Field::plugin), 'value' => '{% city_prefix %}'), array('text' => __('City Suffix', Field::plugin), 'value' => '{% city_suffix %}'), array('text' => __('City', Field::plugin), 'value' => '{% city %}'), array('text' => __('State', Field::plugin), 'value' => '{% state %}'), array('text' => __('State Abbr', Field::plugin), 'value' => '{% state_abbr %}'), array('text' => __('Address', Field::plugin), 'value' => '{% address %}'), array('text' => __('Secondary Address', Field::plugin), 'value' => '{% secondary_address %}'), array('text' => __('Building Number', Field::plugin), 'value' => '{% building_number %}'), array('text' => __('Street Name', Field::plugin), 'value' => '{% street_name %}'), array('text' => __('Street Address', Field::plugin), 'value' => '{% street_address %}'), array('text' => __('Postal Code', Field::plugin), 'value' => '{% postalcode %}'), array('text' => __('Latitude', Field::plugin), 'value' => '{% latitude %}'), array('text' => __('Longitude', Field::plugin), 'value' => '{% longitude %}'));
         $template->value = '{% latitude %}|,|{% longitude %}';
         $template->{'data-separator'} = '|';
         $template->class = array();
         $template->label = __('Address Format', Field::plugin);
         $html[] = Field::wrapper(Field::type_dropdown($template, null, 'string'), $template);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->phone = array('value' => 'company', 'text' => __('Company', self::plugin), 'template' => function ($field, $type) use($default) {
         $template = clone $field;
         $template->_id = array('meta', 'template');
         $template->_name = array('meta', 'template');
         $template->type = 'dropdown';
         $template->multiple = true;
         $template->{'data-tags'} = true;
         $template->{'data-options'} = array(array('text' => __('Catch Phrase', Field::plugin), 'value' => '{% catch_phrase %}'), array('text' => __('BS', Field::plugin), 'value' => '{% bs %}'), array('text' => __('Company', Field::plugin), 'value' => '{% company %}'), array('text' => __('Suffix', Field::plugin), 'value' => '{% suffix %}'));
         $template->value = '{% company %}|&nbsp;|{% suffix %}';
         $template->{'data-separator'} = '|';
         $template->class = array();
         $template->label = __('Company Format', Field::plugin);
         $html[] = Field::wrapper(Field::type_dropdown($template, null, 'string'), $template);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->date = array('value' => 'date', 'text' => __('Date', self::plugin), 'template' => function ($field, $type) use($default) {
         $template = clone $field;
         $template->_id = array('meta', 'interval');
         $template->_name = array('meta', 'interval');
         $template->type = 'interval';
         $template->class = array();
         $format = clone $field;
         $format->_id = array('meta', 'format');
         $format->_name = array('meta', 'format');
         $format->type = 'text';
         $format->class = array();
         $format->value = 'Y-m-d H:i:s';
         $format->label = __('Date Format <b space>&mdash;</b> See <a href="http://php.net/manual/function.date.php" target="_blank">PHP Date</a>', Field::plugin);
         $html[] = Field::wrapper(Field::type_interval($template, null, 'string'), $template);
         $html[] = Field::wrapper(Field::type_text($format, null, 'string'), $format);
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->timezone = array('value' => 'timezone', 'text' => __('TimeZone', self::plugin), 'template' => function ($field, $type) use($default) {
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->email = array('value' => 'email', 'text' => __('Email', self::plugin), 'template' => function ($field, $type) use($default) {
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->domain = array('value' => 'domain', 'text' => __('Domain', self::plugin), 'template' => function ($field, $type) use($default) {
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->ip = array('value' => 'ip', 'text' => __('IP', self::plugin), 'template' => function ($field, $type) use($default) {
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     $types->user_agent = array('value' => 'user_agent', 'text' => __('Browser User Agent', self::plugin), 'template' => function ($field, $type) use($default) {
         $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight);
         return implode("\r\n", $html);
     });
     foreach ($types as $key => $type) {
         $types->{$key} = (object) $type;
     }
     return apply_filters(self::plugin . '/fields/meta_types', $types);
 }