function kalins_pdf_create_all()
{
    $pdfDir = KALINS_PDF_SINGLES_DIR;
    check_ajax_referer("kalins_pdf_create_all");
    $outputVar = new stdClass();
    kalinsPDF_createPDFDir();
    $postLimit = 25;
    $postCount = 0;
    $myPosts = get_posts('numberposts=-1&post_type=any');
    foreach ($myPosts as $post) {
        if (kalinsPDF_build_pdf($post)) {
            $postCount = $postCount + 1;
            if ($postCount == $postLimit) {
                break;
            }
        }
    }
    $outputVar->createCount = $postCount;
    $outputVar->totalCount = wp_count_posts("post")->publish + wp_count_posts("page")->publish;
    $existCount = 0;
    if ($handle = opendir($pdfDir)) {
        //open pdf directory
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != ".." && substr($file, stripos($file, ".") + 1, 3) == "pdf") {
                //loop to find all relevant files
                $existCount = $existCount + 1;
                //and count them
            }
        }
        closedir($handle);
    }
    $outputVar->existCount = $existCount;
    $outputVar->status = "success";
    die(json_encode($outputVar));
}
<?php

if (!function_exists('add_action')) {
    echo "Hi there!  I'm just a plugin, not much I can do when called directly.";
    exit;
}
//TODO: is this how we add a pdf to the uploads library?
//$return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) );
//found this in add-from-server plugin
kalinsPDF_createPDFDir();
//make sure our PDF dir exists
$create_nonce = wp_create_nonce('kalins_pdf_tool_create');
$save_nonce = wp_create_nonce('kalins_pdf_tool_save');
$delete_template_nonce = wp_create_nonce('kalins_pdf_tool_template_delete');
$delete_nonce = wp_create_nonce('kalins_pdf_tool_delete');
$allPostList = get_posts('numberposts=-1&post_type=any&post_status=any');
$customList = array();
$l = count($allPostList);
for ($i = 0; $i < $l; $i++) {
    if ($allPostList[$i]->post_type === "nav_menu_item" || $allPostList[$i]->post_type === "attachment" || $allPostList[$i]->post_type === "revision") {
        continue;
    }
    $newItem = new stdClass();
    $newItem->ID = $allPostList[$i]->ID;
    $newItem->title = $allPostList[$i]->post_title;
    $newItem->type = $allPostList[$i]->post_type;
    $newItem->menu_order = $allPostList[$i]->menu_order;
    $newItem->date = substr($allPostList[$i]->post_date, 0, strpos($allPostList[$i]->post_date, " "));
    $newItem->status = $allPostList[$i]->post_status;
    $newItem->author = get_the_author_meta("display_name", $allPostList[$i]->post_author);
    $newItem->cats = "";