Esempio n. 1
0
function bdn_context_menu()
{
    if (empty($_REQUEST['wpid']) || (int) $_REQUEST['wpid'] == 0) {
        wp_send_json_error();
    }
    $post_id = (int) $_REQUEST['wpid'];
    global $starttime;
    //Get the HTML for the budget line and file item screens for this item
    ob_start();
    bdn_budget_line(get_post($post_id), $_REQUEST['page']);
    $budget_line = ob_get_contents();
    ob_end_clean();
    ob_start();
    bdn_file_item(get_post($post_id), $_REQUEST['page']);
    $file_item = ob_get_contents();
    ob_end_clean();
    wp_send_json_success(array('slug' => get_the_title($post_id), 'page' => $_REQUEST['page'], 'permalink' => get_permalink($post_id), 'folders' => get_the_terms($post_id, 'folder'), 'status' => get_the_terms($post_id, 'status'), 'desk' => get_the_terms($post_id, 'desk'), 'spike' => add_query_arg(array('action' => 'do_spike_item', '_nonce' => wp_create_nonce('spike-nonce-' . $post_id), 'page' => urlencode($_REQUEST['page'])), get_permalink($post_id)), 'markfinal' => add_query_arg(array('action' => 'do_mark_final_published', '_nonce' => wp_create_nonce('final_published-nonce-' . $post_id), 'page' => urlencode($_REQUEST['page'])), get_permalink($post_id)), 'editBudgetLine' => trim($budget_line), 'fileItem' => trim($file_item), 'wpID' => get_post_meta($post_id, '_wpID', true), 'timeItTook' => (double) reset(explode(' ', microtime())) + (double) end(explode(' ', microtime())) - $starttime, 'mysqlTime' => bdn_total_query_time()));
}
        ?>
					<div>Alternatively, you can attach one of these recently created docs to your budget item:</div>
					<?php 
        foreach ($files['items'] as $driveFile) {
            ?>
						<li><a href="<?php 
            echo add_query_arg(array('action' => 'do_attach_doc', 'gdocID' => $driveFile['id'], '_nonce' => wp_create_nonce('attach-nonce-' . $post->ID . '-' . $driveFile['id'])), get_permalink());
            ?>
">Attach "<?php 
            echo $driveFile['title'];
            ?>
"</a></li>
					<?php 
        }
        ?>
				<?php 
    }
    ?>
			</ul>
		</div>
	
	</div>
	
<?php 
}
?>

<?php 
bdn_budget_line($post);
bdn_file_item($post);
get_footer();