<?php

global $wp_version;
define('UC_PER_LOAD_LIMIT', 24);
list($wp_ver_main, $wp_ver_major) = explode('.', $wp_version);
$api = uploadcare_api();
wp_enqueue_script('uploadcare-main');
wp_enqueue_style('media');
wp_enqueue_style('uploadcare-style');
$type = 'uploadcare_files';
$files = $api->getFileList(array('request_limit' => UC_PER_LOAD_LIMIT));
$pages = ceil(count($files) / UC_PER_LOAD_LIMIT);
$page = isset($_GET['page_num']) ? (int) $_GET['page_num'] : 1;
if ($page < 1 || $page > $pages) {
    $page = 1;
}
$start = ($page - 1) * UC_PER_LOAD_LIMIT;
$end = min($start + UC_PER_LOAD_LIMIT, count($files));
function change_param($param, $value)
{
    $uri = str_replace('%7E', '~', $_SERVER['REQUEST_URI']);
    $parsed = parse_url($uri);
    $path = $parsed['path'];
    $query = array();
    parse_str($parsed['query'], $query);
    $query[$param] = $value;
    return $path . '?' . http_build_query($query);
}
$paginator = function () use($pages, $page, $start, $end, $files) {
    if ($pages > 1) {
        ?>
Exemplo n.º 2
0
function uploadcare_shortcode_handle()
{
    // store file
    $api = uploadcare_api();
    $file_id = $_POST['file_id'];
    $post_id = $_POST['post_id'];
    $file = $api->getFile($file_id);
    $file->store();
    // create user image
    uploadcare_attach_user_image($file, $post_id);
}