public function _action_setup_modules() { if (!is_admin()) { return; } Module\Meta::instance(); Module\Post::instance(); Module\Attachment::instance(); Module\Comment::instance(); Module\Term::instance(); Module\User::instance(); }
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.: , ', 'fakerpress'), 'label' => __('Separator', 'fakerpress')), 'weight' => array('_id' => array('meta', 'weight'), '_name' => array('meta', 'weight'), 'type' => 'number', 'class' => array(), 'value' => 90, 'min' => 0, 'max' => 100, 'placeholder' => __('E.g.: 55', 'fakerpress'), 'label' => __('Weight', 'fakerpress')), 'qty' => array('_id' => array('meta', 'qty'), '_name' => array('meta', 'qty'), 'type' => 'range', 'class' => array(), 'label' => __('Quantity', 'fakerpress'))); foreach ($default as $key => $field) { $default->{$key} = (object) $field; } $types->numbers = array('value' => 'numbers', 'text' => __('Number', 'fakerpress'), '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', 'fakerpress'); $range->_min = 0; $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', 'fakerpress'), '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', 'fakerpress'); $query->label = __('Uses <a href="http://codex.wordpress.org/Class_Reference/WP_Query" target="_blank">WP_Query</a>', 'fakerpress'); $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->attachment = array('value' => 'attachment', 'text' => __('Attachment', 'fakerpress'), 'template' => function ($field, $type) use($default) { $store = clone $field; $store->_id = array('meta', 'store'); $store->_name = array('meta', 'store'); $store->type = 'dropdown'; $store->value = 'id'; $store->options = array(array('id' => 'id', 'text' => esc_attr__('Attachment ID')), array('id' => 'url', 'text' => esc_attr__('Attachment URL'))); $store->class = array(); $store->placeholder = __('Which value should be saved on the Meta', 'fakerpress'); $store->label = __('Stored Data', 'fakerpress'); $providers = clone $field; $providers->_id = array('meta', 'provider'); $providers->_name = array('meta', 'provider'); $providers->type = 'dropdown'; $providers->class = array(); $providers->multiple = true; $providers->placeholder = __('Select at one Provider', 'fakerpress'); $providers->label = __('Which image services will the generator use?', 'fakerpress'); $providers->value = implode(',', wp_list_pluck(Module\Attachment::get_providers(), 'id')); $providers->{'data-options'} = Module\Attachment::get_providers(); $html[] = Field::wrapper(Field::type_dropdown($store, null, 'string'), $store); $html[] = Field::wrapper(Field::type_dropdown($providers, null, 'string'), $providers); $html[] = Field::wrapper(Field::type_number($default->weight, null, 'string'), $default->weight); return implode("\r\n", $html); }); $types->elements = array('value' => 'elements', 'text' => __('Elements', 'fakerpress'), '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)', 'fakerpress'); $tags->label = __('', 'fakerpress'); $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', 'fakerpress'), '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', 'fakerpress'), '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', 'fakerpress'), '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', 'fakerpress'), 'value' => 'sentences'), array('text' => __('Paragraphs', 'fakerpress'), 'value' => 'paragraphs')); $text->value = 'paragraphs'; $text->class = array(); $separator = clone $default->separator; $separator->value = '\\n'; $separator->label = __('Separator <b space>—</b> New Line: "\\n"', 'fakerpress'); $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', 'fakerpress'), '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 < or >', 'fakerpress'); $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', 'fakerpress'), '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 ##??', 'fakerpress'); $template->label = __('John ##?? <b spacer>»</b> John 29ze', 'fakerpress'); $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', 'fakerpress'), '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 ****', 'fakerpress'); $template->label = __('John **** <b spacer>»</b> John r9"+', 'fakerpress'); $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', 'fakerpress'), '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.-]', 'fakerpress'); $template->label = __('[A-Z0-9._%+-]+@[A-Z0-9.-] <b spacer>»</b> sm0@y8k96a', 'fakerpress'); $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', 'fakerpress'), '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', 'fakerpress'), 'value' => '{% title %}'), array('text' => __('First Name', 'fakerpress'), 'value' => '{% first_name %}'), array('text' => __('Last Name', 'fakerpress'), 'value' => '{% last_name %}'), array('text' => __('Suffix', 'fakerpress'), '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', 'fakerpress'); $gender = clone $field; $gender->_id = array('meta', 'gender'); $gender->_name = array('meta', 'gender'); $gender->type = 'radio'; $gender->options = array(array('text' => __('Male', 'fakerpress'), 'value' => 'male'), array('text' => __('Female', 'fakerpress'), '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', 'fakerpress'), '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', 'fakerpress'), 'value' => '{% country %}'), array('text' => __('Country Code (e.g.: US)', 'fakerpress'), 'value' => '{% country_code %}'), array('text' => __('Country ABBR (e.g.: USA', 'fakerpress'), 'value' => '{% country_abbr %}'), array('text' => __('City Prefix', 'fakerpress'), 'value' => '{% city_prefix %}'), array('text' => __('City Suffix', 'fakerpress'), 'value' => '{% city_suffix %}'), array('text' => __('City', 'fakerpress'), 'value' => '{% city %}'), array('text' => __('State', 'fakerpress'), 'value' => '{% state %}'), array('text' => __('State Abbr', 'fakerpress'), 'value' => '{% state_abbr %}'), array('text' => __('Address', 'fakerpress'), 'value' => '{% address %}'), array('text' => __('Secondary Address', 'fakerpress'), 'value' => '{% secondary_address %}'), array('text' => __('Building Number', 'fakerpress'), 'value' => '{% building_number %}'), array('text' => __('Street Name', 'fakerpress'), 'value' => '{% street_name %}'), array('text' => __('Street Address', 'fakerpress'), 'value' => '{% street_address %}'), array('text' => __('Postal Code', 'fakerpress'), 'value' => '{% postalcode %}'), array('text' => __('Latitude', 'fakerpress'), 'value' => '{% latitude %}'), array('text' => __('Longitude', 'fakerpress'), 'value' => '{% longitude %}')); $template->value = '{% latitude %}|,|{% longitude %}'; $template->{'data-separator'} = '|'; $template->class = array(); $template->label = __('Address Format', 'fakerpress'); $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', 'fakerpress'), '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', 'fakerpress'), 'value' => '{% catch_phrase %}'), array('text' => __('BS', 'fakerpress'), 'value' => '{% bs %}'), array('text' => __('Company', 'fakerpress'), 'value' => '{% company %}'), array('text' => __('Suffix', 'fakerpress'), 'value' => '{% suffix %}')); $template->value = '{% company %}| |{% suffix %}'; $template->{'data-separator'} = '|'; $template->class = array(); $template->label = __('Company Format', 'fakerpress'); $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', 'fakerpress'), '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>—</b> See <a href="http://php.net/manual/function.date.php" target="_blank">PHP Date</a>', 'fakerpress'); $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', 'fakerpress'), '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', 'fakerpress'), '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', 'fakerpress'), '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', 'fakerpress'), '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', 'fakerpress'), '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); }