Ejemplo n.º 1
0
 /**
  * Gets an Array with all the providers based on a given Type
  *
  * @param  string $type Which type of provider you are looking for
  *
  * @return array  With ID, Text and Type
  */
 public static function get_providers($type = 'image')
 {
     $providers = array(array('id' => 'placeholdit', 'text' => esc_attr__('Placehold.it', 'fakerpress'), 'type' => 'image'), array('id' => 'unsplashit', 'text' => esc_attr__('Unsplash.it', 'fakerpress'), 'type' => 'image'), array('id' => 'lorempixel', 'text' => esc_attr__('LoremPixel', 'fakerpress'), 'type' => 'image'));
     if (FakerPress\Plugin::get(array('500px', 'key'), false)) {
         $providers[] = array('id' => '500px', 'text' => esc_attr__('500px', 'fakerpress'), 'type' => 'image');
     }
     return $providers;
 }
Ejemplo n.º 2
0
 protected function request($endpoint = 'photos', $args = array())
 {
     $key = \FakerPress\Plugin::get(array('500px', 'key'), false);
     if (!$key) {
         return false;
     }
     $defaults = array('consumer_key' => $key);
     $args = wp_parse_args($args, $defaults);
     // Determine the Transient Key
     array_multisort($args);
     $hashed_id = substr(md5(json_encode($args)), 0, 10);
     $transient_id = Plugin::$slug . '-request-500px-' . $hashed_id;
     if (false === ($response = get_transient($transient_id))) {
         $response = wp_remote_get(add_query_arg($args, self::$base_url . $endpoint));
         $response = wp_remote_retrieve_body($response);
         if (!$response) {
             return false;
         }
         $response = json_decode($response);
         set_transient($transient_id, $response, 6 * HOUR_IN_SECONDS);
     }
     return $response;
 }
Ejemplo n.º 3
0
$fields[] = new Field('dropdown', array('id' => 'post_types', 'multiple' => true, 'data-options' => $_json_post_types_output, 'value' => 'post'), array('label' => __('Post Type', 'fakerpress'), 'description' => __('Sampling group of Post Types', 'fakerpress')));
$fields[] = new Field('dropdown', array('id' => 'post_parent', 'multiple' => true, 'data-source' => 'WP_Query'), array('label' => __('Parents', 'fakerpress'), 'description' => __('What posts can be choosen as Parent to the ones created', 'fakerpress')));
$fields[] = new Field('dropdown', array('id' => 'comment_status', 'multiple' => true, 'value' => 'open', 'data-options' => array(array('id' => 'open', 'text' => esc_attr__('Allow Comments', 'fakerpress')), array('id' => 'closed', 'text' => esc_attr__('Comments closed', 'fakerpress')))), array('label' => __('Comments Status', 'fakerpress'), 'description' => __('Sampling group of options for the comment status of the posts', 'fakerpress')));
$fields[] = new Field('checkbox', array('id' => 'use_html', 'options' => array(array('text' => __('Use HTML on your randomized post content?', 'fakerpress'), 'value' => 1)), 'value' => 1), array('label' => __('Use HTML', 'fakerpress')));
$_elements = array_merge(\Faker\Provider\HTML::$sets['header'], \Faker\Provider\HTML::$sets['list'], \Faker\Provider\HTML::$sets['block'], \Faker\Provider\HTML::$sets['self_close']);
$fields[] = new Field('dropdown', array('id' => 'html_tags', 'multiple' => true, 'data-tags' => true, 'data-options' => $_elements, 'value' => implode(',', $_elements)), array('label' => __('HTML tags', 'fakerpress'), 'description' => __('Select the group of tags that can be selected to print on the Post Content', 'fakerpress')));
$taxonomies = get_taxonomies(array('public' => true), 'object');
$_json_taxonomies_output = array();
foreach ($taxonomies as $key => $taxonomy) {
    $_json_taxonomies_output[] = array('id' => $taxonomy->name, 'text' => $taxonomy->labels->name);
}
$fields[] = new Field('dropdown', array('id' => 'taxonomies', 'multiple' => true, 'value' => 'post_tag, category', 'data-options' => $_json_taxonomies_output), array('label' => __('Taxonomies', 'fakerpress'), 'description' => __('From which taxonomies the related terms should be selected', 'fakerpress')));
$fields[] = new Field('number', array('id' => 'featured_image_rate', 'placeholder' => __('e.g.: 75', 'fakerpress'), 'min' => 0, 'max' => 100, 'value' => 75), array('label' => __('Featured Image Rate', 'fakerpress'), 'description' => __('Percentage of the posts created that will have an Featured Image', 'fakerpress')));
$_image_providers[] = array('id' => 'placeholdit', 'text' => 'Placehold.it');
$_image_providers[] = array('id' => 'lorempixel', 'text' => 'LoremPixel');
if (Plugin::get(array('500px', 'key'), false)) {
    $_image_providers[] = array('id' => '500px', 'text' => '500px');
}
$fields[] = new Field('dropdown', array('id' => 'images_origin', 'multiple' => true, 'value' => implode(',', wp_list_pluck($_image_providers, 'id')), 'data-options' => $_image_providers), array('label' => __('Image Providers', 'fakerpress'), 'description' => __('Which image services will the generator use?', 'fakerpress')));
// Mount the options for Users
$users = get_users(array('blog_id' => $GLOBALS['blog_id'], 'count_total' => false, 'fields' => array('ID', 'display_name')));
$_json_users_output = array();
foreach ($users as $user) {
    $_json_users_output[] = array('id' => $user->ID, 'text' => esc_attr($user->display_name));
}
$fields[] = new Field('dropdown', array('id' => 'author', 'multiple' => true, 'data-options' => $_json_users_output), array('label' => __('Author', 'fakerpress'), 'description' => __('Choose some users to be authors of posts generated.', 'fakerpress')));
$fields[] = new Field('meta', array('id' => 'meta'), array('label' => __('Meta Field Rules', 'fakerpress'), 'description' => __('Use the fields below to configure a set of rules for your generated Posts', 'fakerpress')));
?>
<div class='wrap'>
	<h2><?php 
echo esc_attr(Admin::$view->title);