Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Template Name: Edit Posts
- */
- $user_id = get_current_user_id();
- global $get_admin_blog;
- global $post;
- global $switched;
- $postTitleError = '';
- $postPriceError = '';
- if($user_id == 1) {
- $blogs = get_user_blogs_by_role( $user_id, 'administrator' );
- } else {
- $blogs = get_user_blogs_by_role( $user_id, 'editor');
- }
- if(isset($_GET['blog'])) {
- $get_admin_blog = $_GET['blog'];
- // Check user if he's using right shop
- $i = 0;
- $is_admin = false;
- foreach ($blogs as $blog) {
- if($blog != 3 && $blog == $get_admin_blog) {
- $is_admin = true;
- }
- }
- if($is_admin == true) {
- switch_to_blog($get_admin_blog);
- } else {
- $postTitleError = 'You are using someone else\'s blog';
- $hasError = true;
- die('<br />'.$postTitleError.'<br />');
- }
- } else {
- $i = 0;
- foreach ($blogs as $blog) {
- if($blog != 3) {
- $blogarray[$i] = $blog;
- $i++;
- }
- }
- if($i == 1) {
- $get_admin_blog = $blogarray[0];
- switch_to_blog($get_admin_blog);
- } else {
- $postTitleError = 'Please Select your Shop from dropdown';
- $hasError = true;
- die('<br />'.$postTitleError.'<br />');
- }
- }
- // Go and grab currently editing product and it's children
- $query = new WP_Query( array( 'post_type' => 'wpsc-product', 'posts_per_page' => '-1', 'post_status' => 'any') );
- if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
- if ( isset( $_GET['post'] ) ) {
- if ( $_GET['post'] == $post->ID ) {
- $current_post = $post->ID;
- $current_post_parent = $post->post_parent;
- $cur_title = get_the_title();
- $cur_content = get_the_content();
- $cur_size = array(32,32);
- $cur_imgage = get_the_post_thumbnail($post->ID, $cur_size);
- $cur_stock = get_post_meta($post->ID, '_wpsc_stock', $single);
- $cur_price = get_post_meta($post->ID, '_wpsc_price', $single);
- $cur_special_price = get_post_meta($post->ID, '_wpsc_special_price', $single);
- $cur_sku = get_post_meta($post->ID, '_wpsc_sku', $single);
- $defaults = array(
- 'post_parent' => $post->ID,
- 'post_type' => 'wpsc-product',
- 'numberposts' => -1,
- 'post_status' => 'any'
- );
- // Get post thumbnail
- $parentThumb = get_the_post_thumbnail($current_post, 'medium', array('class' => 'img-polaroid pull-right span12'));
- // Get parent children if exist
- $queryVariations = get_children( $defaults );
- // IF it does not has children, check if it got parent
- $post_is_parent = true;
- if (empty($queryVariations)) {
- if ($current_post_parent == 0) {
- $post_is_parent = true;
- $query_post_status = 'publish';
- } else {
- $post_is_parent = false;
- $query_post_status = 'inherit';
- }
- }
- // Get variations terms if exist
- $parentVariations = wp_get_post_terms( $current_post, 'wpsc-variation' );
- // get permalink
- $permalink = get_permalink( $current_post );
- }
- }
- endwhile; endif;
- wp_reset_query();
- global $current_post;
- // get product media library
- $mediaArgs = array(
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'numberposts' => -1,
- 'post_status' => null,
- 'post_parent' => $current_post,
- );
- $MediaAttachments = get_posts($mediaArgs);
- $parentMediaArray = array();
- foreach ($MediaAttachments as $MediaAttachment) {
- $parentMediaArray[] = $MediaAttachment->ID;
- }
- // get ALL the media library exept that I'm using now
- $mediaArgs2 = array(
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'numberposts' => -1,
- 'post_status' => null,
- 'exclude' => $parentMediaArray,
- 'post_parent' => 'any', // any parent
- );
- $MediaAttachmentsALL = get_posts($mediaArgs2);
- // add 'Selected' argument where ID == current_post category ID
- //get categories dropdown
- $term_name = strip_tags( get_the_term_list( $current_post, 'wpsc_product_category', '', ', ', '' ) );
- $term_obj = get_term_by('name', $term_name, 'wpsc_product_category');
- if($term_obj) {
- $rterm_id = $term_obj->term_id;
- } else {
- $rterm_id = '';
- }
- $args2 = array(
- 'show_option_all' => '-- აირჩიეთ კატეგორია --',
- 'selected' => $rterm_id,
- 'hide_empty' => 0,
- 'tab_index' => 4,
- 'echo' => 0,
- 'name' => 'cat',
- 'hierarchical' => 1,
- 'taxonomy' => 'wpsc_product_category',
- 'hide_empty' => false );
- $dropdowncats = wp_dropdown_categories( $args2 );
- //get variations
- $args=array(
- 'orderby' => 'id',
- 'order' => 'ASC',
- 'taxonomy' => 'wpsc-variation',
- 'hierarchical' => 1,
- 'hide_empty' => 0
- );
- $variationCategories=get_categories($args);
- $hasError = false;
- // EDIT POST
- if(isset($_POST['submitted']) && isset($_POST['post_nonce_field']) && wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) {
- if(trim($_POST['postTitle']) === '') {
- $postTitleError = 'პროდუქტს აუცილებლად უნდა ქონდეს დასახელება.';
- $hasError = true;
- } else {
- $postTitle = trim($_POST['postTitle']);
- }
- if(trim($_POST['postPrice']) === '') {
- $postPriceError = 'პროდუქტს აუცილებლად უნდა ქონდეს ფასი.';
- $hasError = true;
- } else {
- $postPrice = trim($_POST['postPrice']);
- }
- if ($hasError == false) {
- // Create post object
- $new_entry = array();
- $new_entry['ID'] = $current_post;
- $new_entry['post_title'] = esc_attr(strip_tags($_POST['postTitle']));
- $new_entry['post_content'] = esc_attr(strip_tags($_POST['postContent']));
- $new_entry['post_status'] = $query_post_status;
- // $new_entry['post_category'] = $_POST['cat'];
- $new_entry['post_type'] = 'wpsc-product';
- $new_entry['post_author'] = $user_id;
- $post_id = wp_update_post($new_entry);
- if($post_id) {
- // ON success
- $price = esc_attr(strip_tags($_POST['postPrice']));
- $special_price = esc_attr(strip_tags($_POST['postSpecialPrice']));
- $sku = esc_attr(strip_tags($_POST['postSKU']));
- $stock = esc_attr(strip_tags($_POST['postStock']));
- if(isset($_POST['updateThumb'])) {
- $updateThumb = true;
- } else {
- $updateThumb = false;
- }
- if ($post_is_parent == true) {
- $terms = $_POST['cat'];
- wp_set_post_terms($post_id, $terms, 'wpsc_product_category');
- }
- update_post_meta($post_id, '_wpsc_price', $price);
- update_post_meta($post_id, '_wpsc_special_price', $special_price);
- update_post_meta($post_id, '_wpsc_sku', $sku);
- update_post_meta($post_id, '_wpsc_stock', $stock);
- if ($_FILES) {
- foreach ($_FILES as $file => $array) {
- if ($updateThumb == true) {
- $newupload = insert_attachment($file,$post_id, true);
- } else {
- $newupload = insert_attachment($file,$post_id, false);
- }
- }
- }
- $varArray = array();
- foreach($parentVariations as $variation) {
- $varArray[] = $variation->term_id;
- }
- if(isset($_POST['variationChild'])) {
- $parent = array();
- $children = array();
- $parent = $_POST['variationParent'];
- $children = $_POST['variationChild'];
- if(!empty($parent)) {
- $affparent = wp_set_post_terms( $post_id, $parent, 'wpsc-variation', true );
- $affchildren = wp_set_post_terms( $post_id, $children, 'wpsc-variation', true );
- $N = count($children);
- // here loop *(children power of parents times)
- for($i=0; $i < $N; $i++) {
- $cat_id = (int) $children[$i];
- if(!in_array($cat_id,$varArray)){
- $cat = get_term( $cat_id, 'wpsc-variation' );
- $new_entr = array();
- $new_entr['post_title'] = esc_attr(strip_tags($_POST['postTitle'])) . " (" . $cat->name . ")";
- $new_entr['post_content'] = esc_attr(strip_tags($_POST['postContent']));
- $new_entr['post_status'] = 'inherit';
- $new_entr['post_category'] = $cat->term_id;
- $new_entr['post_type'] = 'wpsc-product';
- $new_entr['post_parent'] = $post_id;
- $new_entr['post_author'] = $user_id;
- $var_id = wp_insert_post($new_entr);
- wp_set_post_terms( $var_id, $cat->term_id, 'wpsc-variation' );
- update_post_meta($var_id, '_wpsc_price', $price);
- update_post_meta($var_id, '_wpsc_special_price', $special_price);
- update_post_meta($var_id, '_wpsc_sku', $sku);
- update_post_meta($var_id, '_wpsc_stock', $stock);
- }
- }
- }
- }
- }
- }
- }
- restore_current_blog();
- ?>
- <?php get_header(); ?>
- <form action="" id="primaryPostForm" method="POST" enctype="multipart/form-data">
- <section class="section">
- <div class="row-fluid">
- <?php get_sidebar( 'left' ) ?>
- <div class="span11">
- <div class="content">
- <div class="content-header">
- <ul class="content-header-action pull-right">
- <li>
- <a href="#">
- <canvas width="32" height="32"></canvas><span style="display: none;" data-chart="peity-bar" data-height="32" data-colours="["#00A600", "#00A600"]">5,3,9,6,5,9,7,3,5,2</span>
- <div class="action-text color-green">8765 <span class="helper-font-small color-silver-dark">ვიზიტი</span></div>
- </a>
- </li>
- <li class="divider"></li>
- <li>
- <a href="#">
- <canvas width="32" height="32"></canvas><span style="display: none;" data-chart="peity-bar" data-height="32" data-colours="["#00A0B1", "#00A0B1"]">9,7,9,6,3,5,3,5,5,2</span>
- <div class="action-text color-teal">1437 <span class="helper-font-small color-silver-dark">მომხმა.</span></div>
- </a>
- </li>
- <li class="divider"></li>
- <li>
- <a href="#">
- <canvas width="32" height="32"></canvas><span style="display: none;" data-chart="peity-bar" data-height="32" data-colours="["#BF1E4B", "#BF1E4B"]">6,5,9,7,3,5,2,5,3,9</span>
- <div class="action-text color-red">4367 <span class="helper-font-small color-silver-dark">შეკვეთა</span></div>
- </a>
- </li>
- </ul>
- <h2><i class="icofont-home"></i> Dashboard <small>შენ შემოგევლე</small></h2>
- </div>
- <div class="content-breadcrumb">
- <ul class="breadcrumb-nav pull-right">
- <li class="divider"></li>
- <li class="btn-group">
- <button type="submit" href="#" class="btn btn-small btn-link">
- <i class="icofont-ok-sign color-green"></i>შენახვა
- </button>
- </li>
- <li class="divider"></li>
- <li class="btn-group">
- <button href="#" class="btn btn-small btn-link">
- <i class="icofont-remove-sign color-red"></i>წაშლა
- </button>
- </li>
- <li class="divider"></li>
- <li class="btn-group">
- <a href="<?php echo $permalink ?>" target="_blank" class="btn btn-small btn-link">
- <i class="icofont-external-link"></i>პროდუქტის ნახვა
- </a>
- </li>
- <li class="divider"></li>
- <li class="btn-group">
- <a href="#" class="btn btn-small btn-link dropdown-toggle" data-toggle="dropdown">
- <i class="icofont-tasks"></i> მაღაზია
- <i class="icofont-caret-down"></i>
- </a>
- <ul class="dropdown-menu">
- <?php
- foreach ($blogs as $blog) {
- if($blog != 3) {
- $blog_details = get_blog_details($blog);
- echo "<li><a href='?blog=" . $blog . "'>" . $blog_details->blogname . "</a></li>";
- }
- }
- ?>
- </ul>
- </li>
- </ul>
- <ul class="breadcrumb">
- <li><a href="/"><i class="icofont-home"></i> Dashboard</a> <span class="divider">›</span></li>
- <li class="active">აქ ვარ მე</li>
- </ul>
- </div>
- <div class="content-body" style="padding-top:20px">
- <div class="insert-post">
- <div class="row-fluid">
- <div class="span8">
- <div class="box corner-all">
- <div class="box-header corner-top" style="text-align:center;">
- <span>პროდუქტის დახასიათება</span>
- </div>
- <div class="box-body">
- <?php if($postTitleError != '') { ?>
- <div class="alert alert-error">
- <?php echo $postTitleError; ?>
- </div>
- <div class="clearfix"></div>
- <?php } ?>
- <fieldset>
- <input type="text" name="postTitle" id="postTitle" placeholder="პროდუქტის დასახელება" value="<?php echo $cur_title; ?>" class="required span12" />
- </fieldset>
- <fieldset>
- <textarea name="postContent" class="span12" id="postContent" placeholder="პროდუქტის დახასიათება" rows="8" cols="30"><?php echo $cur_content; ?></textarea>
- </fieldset>
- </div>
- </div>
- <?php // CHECK IF WE HAVE SOME VARIATIONS
- if (empty($queryVariations)) {
- if ($post_is_parent == true) {
- ?>
- <fieldset>
- <ul class="formVariations"><li>
- <?php
- $parentArray = array();
- foreach ($parentVariations as $variation) {
- $parentArray[] = $variation->term_id;
- }
- foreach($variationCategories as $category) {
- if (in_array($category->term_id, $parentArray)) {
- if ($category->parent == 0) {
- echo "</li><li class='formVariationParent'><input type='checkbox' checked name='variationParent[]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "";
- } else {
- echo "<ul><li class='formVariationChild'><input type='checkbox' name='variationChild[]' checked autocomplete='off' value='". $category->term_id ."'>" . $category->name . "</li></ul>";
- }
- } else {
- if ($category->parent == 0) {
- echo "</li><li class='formVariationParent'><input type='checkbox' name='variationParent[]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "";
- } else {
- echo "<ul><li class='formVariationChild'><input type='checkbox' name='variationChild[]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "</li></ul>";
- }
- }
- }
- ?>
- </ul>
- </fieldset>
- <?php } } else { ?>
- <div class="box-tab corner-all">
- <div class="box-header corner-top">
- <ul class="nav nav-tabs">
- <li class="pull-right"><a data-toggle="tab" href="#boxtab-2">დამატება</a></li>
- <li class="pull-right active"><a data-toggle="tab" href="#boxtab-1">მართვა</a></li>
- <li style="padding-top:8px;padding-left:8px;font-size:1.2em;font-weight:400;">ვარიაციები</li>
- </ul>
- </div>
- <div class="box-body">
- <div class="tab-content">
- <div class="tab-pane fade active in" id="boxtab-1">
- <table aria-describedby="datatables_info" id="datatables" class="table table-striped responsive dataTable table-condensed">
- <thead>
- <tr role="row">
- <th aria-label="" class="span12" aria-sort="ascending" colspan="1" rowspan="1" aria-controls="datatables" tabindex="0" role="columnheader" class="sorting">სახელი</th>
- <th aria-label="" colspan="1" rowspan="1" aria-controls="datatables" tabindex="0" role="columnheader" class="sorting">SKU</th>
- <th aria-label="" colspan="1" rowspan="1" aria-controls="datatables" tabindex="0" role="columnheader" class="sorting">ფასი</th>
- <th aria-label="" colspan="1" rowspan="1" aria-controls="datatables" tabindex="0" role="columnheader" class="sorting">ფასდაკლება</th>
- <th aria-label="" colspan="1" rowspan="1" aria-controls="datatables" tabindex="0" role="columnheader" class="sorting">საწყობი</th>
- <th aria-label="" colspan="1" rowspan="1" aria-controls="datatables" tabindex="0" role="columnheader" class="sorting">მართვა</th>
- </tr>
- </thead>
- <tbody aria-relevant="all" aria-live="polite" role="alert">
- <?php
- // Go and grab currently editing product variations
- switch_to_blog($get_admin_blog);
- $size = array(32,32);
- $sizeOfVariations = count($queryVariations);
- foreach($queryVariations as $variation) {
- ?>
- <tr class="gradeA" id="trvar<?php echo $variation->ID?>">
- <td class="span12">
- <?php echo get_the_post_thumbnail($current_post, $size); ?>
- <?php echo $variation->post_title; ?>
- </td>
- <td class=""><?php echo get_post_meta($variation->ID, '_wpsc_sku', $single); ?></td>
- <td class=""><?php echo get_post_meta($variation->ID, '_wpsc_price', $single); ?></td>
- <td class=""><?php echo get_post_meta($variation->ID, '_wpsc_special_price', $single); ?></td>
- <td class=""><?php echo get_post_meta($variation->ID, '_wpsc_stock', $single); ?></td>
- <td class="">
- <div class="btn-group">
- <?php $editVariation = add_query_arg('post', $variation->ID, get_permalink(239)); ?>
- <a class="btn btn-new btn-success" target="_blank" href="<?php echo $editVariation; ?>">
- <i class="icofont-edit"></i>
- </a>
- <a class="btn btn-new btn-danger" onclick="apfDeleteVariation(<?php echo $variation->ID ?>,<?php echo $current_post ?>,<?php echo $sizeOfVariations ?>,<?php echo $get_admin_blog ?>)">
- <i class="icofont-trash"></i>
- </a>
- </div>
- </td>
- </tr>
- <?php } ?>
- <?php restore_current_blog(); ?>
- </tbody>
- </table>
- </div>
- <div class="tab-pane fade" id="boxtab-2">
- <fieldset>
- <ul class="formVariations" id="formVariationsID"><li>
- <?php
- $parentArray = array();
- foreach ($parentVariations as $variation) {
- $parentArray[] = $variation->term_id;
- }
- foreach($variationCategories as $category) {
- if (in_array($category->term_id, $parentArray)) {
- if ($category->parent == 0) {
- echo "</li><li class='formVariationParent'><input type='checkbox' checked name='variationParent[]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "";
- } else {
- echo "<ul><li class='formVariationChild'><input type='checkbox' name='variationChild[]' checked autocomplete='off' value='". $category->term_id ."'>" . $category->name . "</li></ul>";
- }
- } else {
- if ($category->parent == 0) {
- echo "</li><li class='formVariationParent'><input type='checkbox' name='variationParent[]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "";
- } else {
- echo "<ul><li class='formVariationChild'><input type='checkbox' name='variationChild[]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "</li></ul>";
- }
- }
- }
- ?>
- </ul>
- </fieldset>
- </div>
- </div>
- </div>
- </div>
- <?php } ?>
- </div>
- <div class="span4">
- <div class="box corner-all">
- <div class="box-header bg-black color-white corner-top" style="text-align:center;">
- <div class="header-control">
- <a data-box="collapse"><i class="icofont-caret-up"></i></a>
- </div>
- <span>დამატებითი ინფორმაცია</span>
- </div>
- <div class="box-body corner-bottom">
- <?php if($postPriceError != '') { ?>
- <div class="alert alert-error">
- <?php echo $postPriceError; ?>
- </div>
- <div class="clearfix"></div>
- <?php } ?>
- <?php if ($post_is_parent == true) {
- ?>
- <fieldset>
- <p><?php echo $dropdowncats; ?></p>
- </fieldset>
- <?php } ?>
- <div class="form-inline">
- <fieldset>
- <input type="text" name="postPrice" id="postPrice" placeholder="ფასი" value="<?php echo $cur_price; ?>" class="required span6" />
- <input type="text" name="postSpecialPrice" id="postSpecialPrice" placeholder="ფასდაკლება" value="<?php echo $cur_special_price; ?>" class="required span6" />
- </fieldset>
- </div><p>
- <div class="form-inline">
- <fieldset>
- <input type="text" name="postSKU" id="postSKU" placeholder="SKU" value="<?php echo $cur_sku; ?>" class="required span6" />
- <input type="text" name="postStock" id="postStock" placeholder="საწყობი" value="<?php echo $cur_stock; ?>" class="required span6" />
- </fieldset>
- </div><p>
- <div class="">
- <fieldset id="fieldThumb">
- <?php echo $parentThumb; ?>
- </fieldset><br />
- <span class="pull-right"><a href="#mediaManager" class="btn btn-primary" role="button" data-toggle="modal">მედიის მართვა</a></span>
- <br><br>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="form-actions">
- <fieldset>
- <?php wp_nonce_field('post_nonce', 'post_nonce_field'); ?>
- <input type="hidden" name="submitted" id="submitted" value="true" />
- <button type="submit" class="btn btn-primary"><?php _e('Edit Post', 'framework') ?></button>
- <button type="button" class="btn">Cancel</button>
- </fieldset>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </section>
- <div id="mediaManager" class="modal bigModal hide fade" tabindex="-1" role="dialog" aria-labelledby="mediaManagerLabel" aria-hidden="true">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3 id="mediaManagerLabel">მედიის მართვა</h3>
- </div>
- <div class="modal-body">
- <div class="box-tab corner-all">
- <div class="box-header corner-top">
- <ul class="nav nav-tabs">
- <!--tab menus-->
- <li class="active"><a data-toggle="tab" href="#prodimages">პროდუქტის სურათები</a></li>
- <li class=""><a data-toggle="tab" href="#mediaimages">მედია სურათები</a></li>
- <li class=""><a data-toggle="tab" href="#mediaUpload">მედიის ატვირთვა</a></li>
- </ul>
- </div>
- <div class="box-body">
- <!-- widgets-tab-body -->
- <div class="tab-content">
- <div class="tab-pane fade" id="mediaUpload">
- <div class="row-fluid">
- <div class="span9">
- <fieldset class="images">
- <label class="pull-left" for="image1">სურათის დამატება</label>
- <button type="button" class="btn btn-mini btn-primary pull-left" style="margin-left:15px;" id="plusimage"> + </button>
- <button type="button" class="btn btn-mini btn-primary pull-left" style="margin-left:5px;" id="minusimage"> - </button>
- <input type="checkbox" class="pull-left" name="updateThumb" style="margin-left:5px;" id="updateThumb"><span class="pull-left"><i class="icofont-star"></i>განახლება </span></input>
- <div class="clearfix"></div>
- <input type="file" name="image1" id="image1" size="35">
- </fieldset>
- </div>
- <div class="span3">
- <div class="mediaManagerImage"></div>
- </div>
- </div>
- </div>
- <div class="tab-pane fade active in" id="prodimages">
- <table class="table table-hover responsive table-condensed">
- <thead>
- <tr>
- <th>#რიგი</th>
- <th>სურათი</th>
- <th style="text-align:center;">ზომა</th>
- <th style="text-align:center">მოქმედება</th>
- </tr>
- </thead>
- <tbody>
- <div id="apf-text">
- <div id="apf-response2" style="background-color:#E6E6FA ;color:blue;"></div>
- <?php
- if($MediaAttachments) {
- $k = 1;
- switch_to_blog($get_admin_blog);
- $size = array(32,32);
- $post_thumbnail_id = get_post_thumbnail_id($current_post);
- foreach ($MediaAttachments as $post) {
- setup_postdata($post);
- $image_metadata = wp_get_attachment_metadata( $post->ID );
- ?>
- <tr id="attach<?php echo $post->ID ?>">
- <td><input style="width:25px;" value="<?php echo $k ?>"></input></td>
- <td class="attachImage span12"><?php echo wp_get_attachment_image( $post->ID, 'medium' ); echo " " . $post->post_title; ?></td>
- <td><?php echo $image_metadata['width'] . "x" . $image_metadata['height'] . "px" ?></td>
- <td style="text-align:right">
- <div class="btn-group">
- <?php if($post_thumbnail_id) { ?>
- <a class="btn btn-new btn-primary" onclick="apfSetAsThumb(<?php echo $post->ID?>,<?php echo $current_post ?>,<?php echo $get_admin_blog ?>,<?php echo $post_thumbnail_id ?>);" style="cursor: pointer"><b><i class="icofont-star"></i></b></a></i>
- <?php } else { ?>
- <a class="btn btn-new btn-primary" onclick="apfSetAsThumb(<?php echo $post->ID?>,<?php echo $current_post ?>,<?php echo $get_admin_blog ?>);" style="cursor: pointer"><b><i class="icofont-star"></i></b></a></i>
- <?php } ?>
- <button class="btn btn-new btn-success"><i class="icofont-edit"></i></button>
- <a class="btn btn-new btn-danger" onclick="apfUncheckThumb(<?php echo $post->ID?>,<?php echo $current_post ?>,<?php echo $get_admin_blog ?>);" style="cursor: pointer"><b><i class="icofont-trash"></b></a></i>
- </div>
- </td>
- </tr>
- <?php $k++; }
- }
- restore_current_blog();
- ?>
- </div>
- </tbody>
- </table>
- </div>
- <div class="tab-pane fade" id="mediaimages">
- <table class="table table-hover responsive table-condensed">
- <thead>
- <tr>
- <th>#რიგი</th>
- <th>სურათი</th>
- <th>ზომა</th>
- <th style="text-align:center">მოქმედება</th>
- </tr>
- </thead>
- <tbody>
- <?php
- if($MediaAttachmentsALL) {
- $k = 1;
- switch_to_blog($get_admin_blog);
- $size = array(32,32);
- $post_thumbnail_id = get_post_thumbnail_id($current_post);
- foreach ($MediaAttachmentsALL as $post) {
- setup_postdata($post);
- $image_metadata = wp_get_attachment_metadata( $post->ID );
- ?>
- <tr id="attach<?php echo $post->ID ?>">
- <td><?php echo $k ?></td>
- <td class="attachImage span12"><?php echo wp_get_attachment_image( $post->ID, 'medium' ); echo " " . $post->post_title; ?></td>
- <td><?php echo $image_metadata['width'] . "x" . $image_metadata['height'] . "px" ?></td>
- <td style="text-align:right">
- <div class="btn-group">
- <?php if($post_thumbnail_id) { ?>
- <a class="btn btn-new btn-primary" onclick="apfSetAsThumb(<?php echo $post->ID?>,<?php echo $current_post ?>,<?php echo $get_admin_blog ?>,<?php echo $post_thumbnail_id ?>);" style="cursor: pointer"><b><i class="icofont-star"></i></b></a></i>
- <?php } else { ?>
- <a class="btn btn-new btn-primary" onclick="apfSetAsThumb(<?php echo $post->ID?>,<?php echo $current_post ?>,<?php echo $get_admin_blog ?>, false);" style="cursor: pointer"><b><i class="icofont-star"></i></b></a></i>
- <?php } ?>
- <button class="btn btn-new btn-success"><i class="icofont-plus"></i></button>
- </div>
- </td>
- </tr>
- <?php $k++;
- }
- }
- restore_current_blog();
- ?>
- </tbody>
- </table>
- </div>
- </div><!--/widgets-tab-body-->
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-danger" data-dismiss="modal" aria-hidden="true">დახურვა</button>
- </div>
- </div>
- </form>
- <?php dynamic_sidebar( 'sidebar-blog' ) ?>
- <?php get_footer(); ?>
- <script>
- // insertPost variation collapse/expand
- jQuery('.formVariations > li:first-child').hide();
- jQuery('.formVariationParent > input').change(function() {
- if(this.checked) {
- jQuery(this).parent('li').find('ul input').prop('checked', true);
- } else {
- jQuery(this).parent('li').find('ul input').prop('checked', false);
- }
- });
- jQuery('.formVariationChild > input').change(function() {
- if(this.checked) {
- if (jQuery(this).parent('li').parent('ul').parent('li').find('> input').is(":not(:checked)")) {
- jQuery(this).parent('li').parent('ul').parent('li').find('> input').prop('checked', true);
- }
- }
- });
- // insertPost appendImage eventhandler
- var imageid = 1;
- jQuery('#plusimage').on('click', function() {
- imageid++;
- if (imageid === 7) {
- alert('სამწუხაროდ, ერთ ატვირთვაზე მაქსიმუმ 6 სურათის ატვირთვა შეიძლება, გთხოვთ გამოიყენოთ მედია კატეგორია სურათების დასამატებლად და მერე მედია მენეჯერი რათა პროდუქტს მიაბათ სურათი.');
- } else {
- jQuery(this).parent('fieldset').parent('div').append('<fieldset id="imagefield' + imageid + '" class="images"><input type="file" name="image' + imageid + '" id="image' + imageid + '" size="35">');
- }
- });
- jQuery('#minusimage').on('click', function() {
- if (imageid === 1) {
- alert('ერთი ფორმა მაინც უნდა იყოს');
- } else {
- jQuery(this).parent('fieldset').parent('div').find('#imagefield' + imageid).remove();
- imageid--;
- }
- });
- //make category dropdown fullwidth
- jQuery('#cat').addClass('span12');
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement