Example #1
0
function mtphr_dnt_single_image_ajax()
{
    // Get access to the database
    global $wpdb;
    // Check the nonce
    check_ajax_referer('ditty-news-ticker', 'security');
    // Get variables
    $attachment = $_POST['attachment'];
    // Display the image
    if ($attachment['type'] == 'image') {
        mtphr_dnt_render_single_image($attachment['id']);
    }
    die;
    // this is required to return a proper result
}
Example #2
0
 function mtphr_dnt_field_image($args = array())
 {
     if (isset($args['name'])) {
         $name = $args['name'];
         $class = mtphr_dnt_field_class($args);
         $value = isset($args['value']) ? $args['value'] : '';
         echo '<div class="' . $class . '">';
         echo mtphr_dnt_subheading($args);
         echo '<input type="hidden" name="' . $name . '" value="' . $value . '" ' . mtphr_dnt_field_atts($args) . ' />';
         if ($value != '') {
             mtphr_dnt_render_single_image($value);
             echo '<a href="#" class="button mtphr-dnt-single-image-upload" style="display:none;">' . __('Add Image', 'ditty-news-ticker') . '</a>';
         } else {
             echo '<a href="#" class="button mtphr-dnt-single-image-upload">' . __('Add Image', 'ditty-news-ticker') . '</a>';
         }
         echo '</div>';
         mtphr_dnt_field_append($args);
     } else {
         echo __('Missing required data', 'ditty-news-ticker');
     }
 }