Example #1
0
?>
<div id="commentsdiv" style="padding:1px 0;">
    <style type="text/css" scoped>
        #commentsdiv {padding-top:1px;}
        #commentsdiv > .thumbnail {float:left; margin:0 10px 10px;}
        #commentsdiv > .thumbnail img.gmedia-thumb {max-height:72px;}
        #commentsdiv > h4 {margin-left:10px;}
        #commentsdiv .fixed .column-author {width:20%;}
    </style>
    <?php 
printf('<a target="_blank" href="%s" class="pull-right">%s</a>', esc_url(add_query_arg(array('p' => $post_id), admin_url('edit-comments.php'))), __('Open in new tab'));
if ($gmedia_id) {
    ?>
        <span class="thumbnail">
            <?php 
    echo gmedia_item_thumbnail($gmedia);
    ?>
        </span>
    <?php 
}
?>
    <h4><?php 
echo $post->post_title;
?>
</h4>
    <?php 
post_comment_meta_box($post);
wp_comment_reply();
?>
    <input id="post_ID" name="p" type="hidden" value="<?php 
echo $post_id;
Example #2
0
function gmedia_update_data()
{
    global $gmDB, $gmCore;
    check_ajax_referer("GmediaGallery");
    if (!current_user_can('gmedia_edit_media')) {
        die('-1');
    }
    $data = $gmCore->_post('data');
    wp_parse_str($data, $gmedia);
    if (!empty($gmedia['ID'])) {
        $item = $gmDB->get_gmedia($gmedia['ID']);
        if ((int) $item->author != get_current_user_id()) {
            if (!current_user_can('gmedia_edit_others_media')) {
                die('-2');
            }
        }
        $gmedia['modified'] = current_time('mysql');
        $gmedia['mime_type'] = $item->mime_type;
        $gmedia['gmuid'] = $item->gmuid;
        if (!current_user_can('gmedia_delete_others_media')) {
            $gmedia['author'] = $item->author;
        }
        $gmuid = pathinfo($item->gmuid);
        $gmedia['filename'] = preg_replace('/[^a-z0-9_\\.-]+/i', '_', $gmedia['filename']);
        if ($gmedia['filename'] != $gmuid['filename'] && (current_user_can('gmedia_delete_others_media') || (int) $item->author == get_current_user_id())) {
            $fileinfo = $gmCore->fileinfo($gmedia['filename'] . '.' . $gmuid['extension']);
            if (false !== $fileinfo) {
                if ('image' == $fileinfo['dirname'] && file_is_displayable_image($fileinfo['dirpath'] . '/' . $item->gmuid)) {
                    if (is_file($fileinfo['dirpath_original'] . '/' . $item->gmuid)) {
                        @rename($fileinfo['dirpath_original'] . '/' . $item->gmuid, $fileinfo['filepath_original']);
                    }
                    @rename($fileinfo['dirpath_thumb'] . '/' . $item->gmuid, $fileinfo['filepath_thumb']);
                }
                if (@rename($fileinfo['dirpath'] . '/' . $item->gmuid, $fileinfo['filepath'])) {
                    $gmedia['gmuid'] = $fileinfo['basename'];
                }
            }
        }
        if (!current_user_can('gmedia_terms')) {
            unset($gmedia['terms']);
        }
        $id = $gmDB->insert_gmedia($gmedia);
        if (!is_wp_error($id)) {
            // Meta Stuff
            if (isset($gmedia['meta']) && is_array($gmedia['meta'])) {
                $meta_error = array();
                foreach ($gmedia['meta'] as $key => $value) {
                    if ($gmCore->is_digit($key)) {
                        $mid = (int) $key;
                        //$value = wp_unslash( $value );
                        if (!($meta = $gmDB->get_metadata_by_mid('gmedia', $mid))) {
                            $meta_error[] = array('error' => 'no_meta', 'message' => __('No record in DataBase.', 'grand-media'), 'meta_id' => $mid, 'meta_key' => $meta->meta_key);
                            continue;
                        }
                        if ('' == trim($value)) {
                            $meta_error[] = array('error' => 'empty_value', 'message' => __('Please provide a custom field value.', 'grand-media'), 'meta_id' => $mid, 'meta_key' => $meta->meta_key, 'meta_value' => $meta->meta_value);
                            continue;
                        }
                        if ($meta->meta_value != $value) {
                            if (!($u = $gmDB->update_metadata_by_mid('gmedia', $mid, $value))) {
                                $meta_error[] = array('error' => 'meta_update', 'message' => __('Something goes wrong.', 'grand-media'), 'meta_id' => $mid, 'meta_key' => $meta->meta_key, 'meta_value' => $meta->meta_value);
                            }
                        }
                    } elseif ('_' == $key[0]) {
                        if ('_cover' == $key) {
                            $value = ltrim($value, '#');
                        } elseif ('_gps' == $key) {
                            if ($value) {
                                $latlng = explode(',', $value);
                                $value = array('lat' => trim($latlng[0]), 'lng' => trim($latlng[1]));
                            }
                        }
                        $value = apply_filters('gmedia_protected_meta_value', $value, $key, $id);
                        $gmDB->update_metadata('gmedia', $id, $key, $value);
                    }
                }
            }
            $result = $gmDB->get_gmedia($id);
        } else {
            $result = $gmDB->get_gmedia($id);
        }
        gmedia_item_more_data($result);
        if ('image' != $result->type) {
            $result->thumbnail = gmedia_item_thumbnail($result);
        }
        if (current_user_can('gmedia_terms')) {
            if (!empty($gmedia['terms']['gmedia_album'])) {
                if (isset($gmedia['gmedia_album_order'])) {
                    $album = $gmDB->get_the_gmedia_terms($id, 'gmedia_album');
                    if ($album) {
                        $album = reset($album);
                        if ((int) $gmedia['gmedia_album_order'] != (int) $album->gmedia_order) {
                            $gmDB->update_term_sortorder($album->term_id, array($id => (int) $gmedia['gmedia_album_order']));
                            $result->gmedia_album_order = (int) $gmedia['gmedia_album_order'];
                        }
                    }
                }
                $alb_id = $gmedia['terms']['gmedia_album'];
                $alb = $gmDB->get_term($alb_id, 'gmedia_album');
                $result->album_status = $alb ? $alb->status : 'none';
            } else {
                $result->album_status = 'none';
            }
        }
        if (!empty($meta_error)) {
            $result->meta_error = $meta_error;
        }
        header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
        echo json_encode($result);
    }
    die;
}
Example #3
0
echo $item->type;
?>
">
    <div class="gmedia_id">#<?php 
echo $item->ID;
?>
</div>
    <div class="col-sm-4" style="max-width:340px;">
        <div class="thumbwrap">
            <div class="cb_media-object">
                <span data-clicktarget="gmdataedit<?php 
echo $item->ID;
?>
" class="thumbnail">
                    <?php 
echo gmedia_item_thumbnail($item);
?>
                </span>
            </div>
            <label class="gm-item-check"><input name="doaction[]" type="checkbox"<?php 
echo $item->selected ? ' checked="checked"' : '';
?>
 data-type="<?php 
echo $item->type;
?>
" value="<?php 
echo $item->ID;
?>
"/></label>
            <label class="gm-stack hidden"><input name="stack[]" type="checkbox"<?php 
echo $item->in_stack ? ' checked="checked"' : '';