Plugin Directory

Changeset 3186406


Ignore:
Timestamp:
11/12/2024 10:22:29 AM (15 months ago)
Author:
sirv
Message:

Release 7.3.1

Location:
sirv/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • sirv/trunk/plugdata/css/wp-options.css

    r3162079 r3186406  
    771771
    772772.optiontable.form-table h3 {
    773     margin: 0px 0 10px 0;
     773    margin: 5px 0 10px 0;
    774774}
    775775
     
    21162116    height: 40px;
    21172117}
     2118
     2119.sirv-media-lib-title{
     2120    padding: 0 10px !important;
     2121}
     2122.sirv-media-lib-title h3{
     2123    margin-bottom: 0 !important;
     2124}
  • sirv/trunk/plugdata/css/wp-sirv.css

    r3039643 r3186406  
    13641364    width: 100%;
    13651365}
     1366
     1367
     1368.ui-tooltip {
     1369    padding: 8px;
     1370    position: absolute;
     1371    z-index: 99999999;
     1372    max-width: 400px;
     1373    background-color: white !important;
     1374    background-image: none;
     1375}
     1376
     1377.sirv-ui-widget-content {
     1378    border: none;
     1379    background-image: none;
     1380}
     1381
     1382/* Corner radius */
     1383.sirv-ui-corner-all {
     1384    border-radius: 3px;
     1385}
     1386
     1387.sirv-ui-widget-shadow {
     1388    box-shadow: 0px 0px 5px #666666 !important;
     1389}
  • sirv/trunk/plugdata/htmlBuilders/elementor/SirvControl.php

    r3115018 r3186406  
    2626        wp_register_style( 'sirv_mce_style', SIRV_PLUGIN_SUBDIR_URL_PATH . 'css/wp-sirv-shortcode-view.css' );
    2727        wp_enqueue_style('sirv_mce_style');
    28         wp_register_script( 'sirv_logic', SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv.js', array( 'jquery', 'jquery-ui-sortable, sirv_toast_js' ), false);
     28        wp_register_script( 'sirv_logic', SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv.js', array( 'jquery','jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'sirv_toast_js' ), false);
    2929        wp_localize_script( 'sirv_logic', 'sirv_ajax_object', array(
    3030            'ajaxurl' => admin_url( 'admin-ajax.php' ),
  • sirv/trunk/plugdata/includes/classes/utils.class.php

    r3162079 r3186406  
    103103  public static function get_file_extension($filepath){
    104104    return pathinfo($filepath, PATHINFO_EXTENSION);
     105  }
     106
     107
     108  public static function parse_html_tag_attrs($html_data){
     109  $tag_metadata = array();
     110
     111  if ( ! empty($html_data) ) {
     112    preg_match_all('/\s(\w*)=\"([^"]*)\"/ims', $html_data, $matches_tag_attrs, PREG_SET_ORDER);
     113    $tag_metadata = self::convert_matches_to_assoc_array($matches_tag_attrs);
     114  }
     115
     116  return $tag_metadata;
     117}
     118
     119
     120  public static function convert_matches_to_assoc_array($matches){
     121    $assoc_array = array();
     122
     123    for ($i=0; $i < count($matches); $i++) {
     124      $assoc_array[$matches[$i][1]] = $matches[$i][2];
     125    }
     126
     127    return $assoc_array;
     128  }
     129
     130
     131  public static function join_tag_attrs($tag_metadata, $skip_attrs = array()){
     132    $tag_attrs = array();
     133
     134    foreach ($tag_metadata as $attr_name => $value) {
     135      if( in_array($attr_name, $skip_attrs) ) continue;
     136
     137      $tag_attrs[] = $attr_name . '="' . $value . '"';
     138    }
     139
     140    return implode(' ', $tag_attrs);
     141  }
     142
     143
     144
     145  public static function get_sirv_item_info($sirv_url){
     146    $context = stream_context_create(array('http' => array('method' => "GET")));
     147    $sirv_item_metadata = @json_decode(@file_get_contents($sirv_url . '?info', false, $context));
     148
     149    return empty($sirv_item_metadata) ? false : $sirv_item_metadata;
     150  }
     151
     152
     153  public static function build_html_tag($tag_name, $tag_metadata, $skip_attrs = array()){
     154    $tag_attrs = self::join_tag_attrs($tag_metadata, $skip_attrs);
     155
     156    return '<' . $tag_name . ' ' . $tag_attrs . '>';
    105157  }
    106158
  • sirv/trunk/plugdata/includes/classes/wc.product.helper.class.php

    r2972273 r3186406  
    2626        "_wp_attachment_image_alt" => preg_replace('/\.[^.]+$/', '', basename($sirv_url)),
    2727        "sirv_woo_product_image_attachment" => $sirv_url,
    28         "_wp_attachment_metadata" => self::get_sirv_item_metadata($sirv_url, $sirv_item_type_data['sirv_type']),
     28        "_wp_attachment_metadata" => self::get_sirv_item_metadata($sirv_url, $sirv_item_type_data),
    2929      ),
    3030    );
     
    4141
    4242  public static function get_sirv_item_type($sirv_url){
    43     $sirv_type = array("sirv_type" => '');
     43    $sirv_type = array("type" => '', "ext" => '', "mime_type" => '');
    4444
    45     $filetype = wp_check_filetype(basename($sirv_url), null);
     45    $filetype = wp_check_filetype(basename($sirv_url));
    4646
    47     if( !empty($filetype) && !empty($filetype['type'])){
     47    if( !empty($filetype['type']) ){
    4848      $sirv_type['ext'] = $filetype['ext'];
    49       $sirv_type['type'] = $filetype['type'];
     49      $sirv_type['mime_type'] = $filetype['type'];
    5050      list($type, $ext) = explode('/', $filetype['type']);
    5151      switch ($type) {
    5252        case 'sirv':
    53           if($ext == 'spin') $sirv_type['sirv_type'] = 'spin';
     53          if($ext == 'spin') $sirv_type['type'] = 'spin';
    5454          break;
    5555
    5656        default:
    57           $sirv_type['sirv_type'] = $type;
     57          $sirv_type['type'] = $type;
    5858          break;
    5959      }
     60    }else{
     61      $sirv_type['ext'] = pathinfo($sirv_url, PATHINFO_EXTENSION);
    6062    }
    6163
     
    6466
    6567
    66   protected static function get_sirv_item_metadata($sirv_url, $sirv_item_type){
     68  protected static function get_sirv_item_metadata($sirv_url, $sirv_item_type_data){
    6769
    68     $sirv_metadata = array("sirv_type" => $sirv_item_type);
    69 
     70    $sirv_metadata = array("sirv_type" => '');
    7071    $allow_dimensions_types = array('image', 'video');
    7172
    72     if( in_array($sirv_item_type, $allow_dimensions_types) ){
    73       $string_metadata = @file_get_contents($sirv_url . '?info');
     73    $sirv_item_metadata = Utils::get_sirv_item_info($sirv_url);
    7474
    75       if( !empty($string_metadata)){
    76         $metadata = json_decode($string_metadata, true);
     75    if ( $sirv_item_type_data['type'] ) {
     76      $sirv_metadata["sirv_type"] = $sirv_item_type_data['type'];
     77    } else {
     78      if( $sirv_item_metadata ){
     79        if (isset($sirv_item_metadata->original->File->MIMEType)) {
     80          $sirv_metadata['sirv_type'] = explode('/', $sirv_item_metadata->original->File->MIMEType)[0];
     81        }
    7782
     83        if (isset($sirv_item_metadata->layers)) {
     84          $sirv_metadata['sirv_type'] = 'spin';
     85        }
     86      }else{
     87        $sirv_metadata['sirv_type'] = 'image';
     88      }
    7889
    79         if (isset($metadata['original']['width'])) $sirv_metadata['width'] = $metadata['original']['width'];
    80         if (isset($metadata['original']['height'])) $sirv_metadata['height'] = $metadata['original']['height'];
     90    }
     91
     92    if( in_array($sirv_metadata['sirv_type'], $allow_dimensions_types) ){
     93
     94      if( !empty($sirv_item_metadata)){
     95
     96        if ( isset($sirv_item_metadata->original->width) ) $sirv_metadata['width'] = $sirv_item_metadata->original->width;
     97        if ( isset($sirv_item_metadata->original->height) ) $sirv_metadata['height'] = $sirv_item_metadata->original->height;
    8198      }
    8299    }else{
     
    89106    }
    90107
    91     $filesize = self::get_filesize($sirv_url, $sirv_item_type);
     108    $filesize = self::get_filesize($sirv_url, $sirv_metadata['sirv_type'])  ;
    92109
    93110    if( !empty($filesize) ) $sirv_metadata['filesize'] = $filesize;
  • sirv/trunk/plugdata/includes/classes/woo.class.php

    r3162079 r3186406  
    4040        $cached_data = self::get_post_sirv_data($id, '_sirv_woo_viewf_data');
    4141        $prod_path = $this->getProductPath($id, $isVariation);
    42         $headers = $this->get_HEAD_request($prod_path . '.view');
     42        //$headers = $this->get_HEAD_request($prod_path . '.view');
     43        $headers = Utils::get_head_request($prod_path . '.view');
    4344        if ((!isset($cached_data->file_version) && isset($headers['X-File-VersionId'])) || (isset($headers['X-File-VersionId']) && $cached_data->file_version !== $headers['X-File-VersionId'])) {
    4445
     
    322323      <div class="sirv-woo-gallery-toolbar hide-if-no-js">
    323324        <div class="sirv-woo-gallery-toolbar-main">
    324           <a class="button button-primary button-large sirv-woo-add-media" data-type="<?php echo $type; ?>" data-id="<?php echo $id; ?>">Add Sirv Media</a>
    325           <a class="button button-primary button-large sirv-woo-add-online-video" data-id="<?php echo $id; ?>">Add Online Video</a>
     325          <a class="button button-primary button-large sirv-woo-add-media" data-type="<?php echo $type; ?>" data-id="<?php echo $id; ?>">Add Sirv media</a>
     326          <a class="button button-primary button-large sirv-woo-add-online-video" data-id="<?php echo $id; ?>">Add online video</a>
    326327        </div>
    327328        <div class="sirv-add-online-videos-container" id="sirv-add-online-videos-container_<?php echo $id; ?>">
     
    400401    if (!isset($sirv_remote_data->items)) $sirv_remote_data->items = array();
    401402
     403    $sirv_data = $this->merge_object_data($sirv_local_data->items, $sirv_remote_data->items, true);
     404
    402405    $main_product_image_data = $this->get_main_image($this->product_id);
    403 
    404     $sirv_data = $this->merge_object_data($sirv_local_data->items, $sirv_remote_data->items, true);
    405406
    406407    $wc_gallery = $this->parse_wc_gallery($this->product_id);
     
    413414
    414415    return $html;
     416  }
     417
     418
     419  protected function get_sirv_items_data($isVariation){
     420    $sirv_local_data = (object) $this->get_sirv_local_data($this->product_id);
     421    $sirv_remote_data = (object) $this->get_sirv_remote_data($this->product_id, $isVariation);
     422
     423    if (!isset($sirv_local_data->items)) $sirv_local_data->items = array();
     424    if (!isset($sirv_remote_data->items)) $sirv_remote_data->items = array();
     425
     426    return $this->merge_object_data($sirv_local_data->items, $sirv_remote_data->items, true);
     427  }
     428
     429
     430  public function get_export_data_to_csv_column($isVariation){
     431    $sirv_gallery = $this->get_sirv_items_data($isVariation);
     432    $sirv_item_urls = array();
     433
     434    if( !$isVariation && $this->isSirvProductImage($this->product_id) ){
     435        $sirv_main_image_url = self::get_post_sirv_data($this->product_id, 'sirv_woo_product_image', false, false);
     436
     437        if( $sirv_main_image_url ){
     438          $sirv_item_urls[] = $sirv_main_image_url;
     439        }
     440    }
     441
     442    foreach ($sirv_gallery as $sirv_item) {
     443      $sirv_item_urls[] = $sirv_item->url;
     444    }
     445
     446    return implode(", ", $sirv_item_urls);
    415447  }
    416448
     
    550582  protected function get_HEAD_request($url)
    551583  {
    552     //TODO: use curl to get HEAD request.
    553     $default_stream = stream_context_get_default();
    554     $default_stream_options = stream_context_get_options($default_stream);
    555 
    556     stream_context_set_default(
     584
     585    $context = stream_context_create(
    557586      array(
    558587        'http' => array(
     
    562591    );
    563592
    564     $headers = get_headers($url, true);
    565 
    566     stream_context_set_default(array());
     593    $headers = get_headers($url, true, $context);
    567594
    568595    return $headers;
     
    746773  protected function get_product_sku($product_id)
    747774  {
    748     $product = new WC_Product($product_id);
    749     $sku = $product->get_sku();
    750     $sku = empty($sku) ? 'error-no-sku' : $sku;
     775    try{
     776      $product = new WC_Product($product_id);
     777      $sku = $product->get_sku();
     778      $sku = empty($sku) ? 'error-no-sku' : $sku;
     779    }catch(Exception $e){
     780      $sku = 'error-no-sku';
     781    }
    751782
    752783    return $sku;
     
    9741005    $sirv_remote_variation = $this->get_sirv_remote_data($variation_id, true);
    9751006
    976     if (!empty($sirv_local_variation->items) && !empty($sirv_remote_variation->items)) {
     1007    $sirv_local_variation = $this->fix_item_viewIds($variation_id, $sirv_local_variation);
     1008
     1009
     1010    if (!empty($sirv_local_variation->items) && !empty($sirv_remote_variation)) {
    9771011      $variation_data = $this->merge_object_data($sirv_local_variation->items, $sirv_remote_variation->items, true);
    9781012    } else {
     
    9891023
    9901024    return $variation_data;
     1025  }
     1026
     1027
     1028  function fix_item_viewIds($currnet_item_id, $sirv_variation_data){
     1029    if( !empty($sirv_variation_data->items) && $sirv_variation_data->items[0]->viewId !== $currnet_item_id){
     1030      foreach($sirv_variation_data->items as $item){
     1031        $item->viewId = $currnet_item_id;
     1032      }
     1033      $sirv_variation_data->id = $currnet_item_id;
     1034    }
     1035
     1036    return $sirv_variation_data;
    9911037  }
    9921038
     
    12091255  }
    12101256
    1211   protected function remove_script_tag($string)
     1257  public function remove_script_tag($string)
    12121258  {
    12131259    return preg_replace('/<(\/)*script.*?>/im', '', $string);
     
    14191465    $isCaption = false;
    14201466
    1421     $mv_custom_options = $this->remove_script_tag(get_option('SIRV_WOO_MV_CUSTOM_OPTIONS'));
    1422     $mv_custom_options_block = !empty($mv_custom_options) ? '<script nowprocket>' . $mv_custom_options . '</script>' . PHP_EOL : '';
     1467    /* $mv_custom_options = $this->remove_script_tag(get_option('SIRV_WOO_MV_CUSTOM_OPTIONS'));
     1468    $mv_custom_options_block = !empty($mv_custom_options) ? '<script nowprocket>' . $mv_custom_options . '</script>' . PHP_EOL : ''; */
    14231469
    14241470    $mv_custom_css = get_option('SIRV_WOO_MV_CUSTOM_CSS');
     
    14841530    $json_data_block = '<div style="display: none;" ' . $data_item_by_variation_id . 'data-existings-ids=\'' . json_encode($existings_ids, JSON_HEX_QUOT | JSON_HEX_APOS) . '\' id="sirv-woo-gallery_data_' . $this->product_id . '" data-is-caption="' . $isCaption . '"></div>' . PHP_EOL;
    14851531
    1486     return $json_data_block . '<div class="Sirv' . $opacityClass . '" id="sirv-woo-gallery_' . $this->product_id . '"' . $this->render_viewer_options($viewer_options) . '>' . PHP_EOL . $items_html . '</div>' . PHP_EOL . $mv_custom_options_block . $mv_custom_css . $max_height_style;
     1532    return /* $mv_custom_options_block . PHP_EOL .  */$json_data_block . '<div class="Sirv' . $opacityClass . '" id="sirv-woo-gallery_' . $this->product_id . '"' . $this->render_viewer_options($viewer_options) . '>' . PHP_EOL . $items_html . '</div>' . PHP_EOL. $mv_custom_css . $max_height_style;
    14871533  }
    14881534
  • sirv/trunk/plugdata/js/wp-sirv.js

    r3162079 r3186406  
    794794                    meta.main = formatVideoDuration(data.meta.duration);
    795795                    break;
     796                case 'model':
     797                    meta.main = shortDate;
     798                    break;
    796799
    797800                default:
     
    18891892            let groupedImages = groupedFiles(files, maxFileSize, maxFilesCount, sirvFileSizeLimit);
    18901893            let countFiles = files.length;
    1891 
    18921894            //let currentDir = htmlDecode($('#filesToUpload').attr('data-current-folder'));
    18931895            let currentDir = getCurrentDir(hasLastSlash = true);
     
    19661968                let fileItem = overSizedImages[index];
    19671969                let reader = new FileReader();
     1970
    19681971                uploadImageByChunk(fileItem, 0, reader, 1, totalOverSizedFiles, currentDir);
    19691972            }
     
    19891992                data.append('action', 'sirv_upload_file_by_chunks');
    19901993                data.append("_ajax_nonce", sirv_ajax_object.ajaxnonce);
    1991                 data.append("filename", file.name);
     1994                //data.append("filename", file.name);
     1995                data.append("filename", fileItem.fullPath);
    19921996                data.append('totalParts', totalSlices);
    19931997                data.append('totalFiles', totalOverSizedFiles);
     
    20242028
    20252029                            if(!!json_res.error){
     2030                                toastr.error(`Error: ${json_res.error}`, "", {preventDuplicates: true, timeOut: 5000, positionClass: "toast-top-center"});
     2031                            }
     2032
     2033                            if(!!json_res.critical_error){
    20262034                                $(".sirv-upload-ajax").hide();
    2027                                 toastr.error(`Error: ${json_res.error}`, "", {preventDuplicates: true, timeOut: 4000, positionClass: "toast-top-center"});
     2035                                toastr.error(`Error: ${json_res.error}`, "", {preventDuplicates: true, timeOut: 5000, positionClass: "toast-top-center"});
    20282036                                getContentFromSirv(window.sirvGetPath);
    20292037                                return;
    2030                             }
    2031 
    2032                             if ( nextSlice < file.size ) {
    2033                                 uploadImageByChunk(fileItem, nextSlice, reader, partNum + 1, totalOverSizedFiles, currentDir);
    20342038                            }
    20352039
     
    20392043                                realRequestSize = 0;
    20402044                            }
     2045
     2046                            if ( nextSlice < file.size ) {
     2047                                uploadImageByChunk(fileItem, nextSlice, reader, partNum + 1, totalOverSizedFiles, currentDir);
     2048                            }
     2049
    20412050                        }
    20422051                    },
     
    38733882        getPhpFilesLimitations();
    38743883
     3884        $(document).tooltip({
     3885            classes:{
     3886                "ui-tooltip": "sirv-ui-widget-content sirv-ui-corner-all sirv-ui-widget-shadow",
     3887            },
     3888            show: false,
     3889            hide: false,
     3890            position: {
     3891                my: "left bottom-25",
     3892                at: "left bottom",
     3893                collision: "flipfit",
     3894            },
     3895        });
     3896
    38753897        if($('.sirv-items-container').length > 0) getContentFromSirv();
    38763898
  • sirv/trunk/plugdata/media_library.php

    r3039643 r3186406  
    2626        wp_enqueue_style('sirv_style');
    2727
    28         wp_enqueue_script( 'sirv_logic', plugins_url('js/wp-sirv.js', __FILE__), array( 'jquery', 'jquery-ui-sortable', 'sirv_toast_js' ), false);
     28        wp_enqueue_script( 'sirv_logic', plugins_url('js/wp-sirv.js', __FILE__), array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'sirv_toast_js' ), false);
    2929        wp_localize_script( 'sirv_logic', 'sirv_ajax_object', array(
    3030            'ajaxurl' => admin_url( 'admin-ajax.php' ),
  • sirv/trunk/plugdata/submenu_pages/sync.php

    r3162079 r3186406  
    2222    </tr>
    2323    <tr>
    24       <td>
    25         <h2>WordPress media</h2>
     24      <td class="sirv-media-lib-title">
     25        <h3>Your WordPress media library</h3>
    2626      </td>
    2727    </tr>
     
    4242          </div>
    4343          <div class="sirv-calc-library-size-view-column sirv-calc-library-size-view-data">
    44             <div class="sirv-calc-library-size-show-analizing"><span class="sirv-traffic-loading-ico"></span>Analizing...<span class="sirv-calc-library-size-analizing-progress">0%</span></div>
     44            <div class="sirv-calc-library-size-show-analizing"><span class="sirv-traffic-loading-ico"></span>Analizing...&nbsp<span class="sirv-calc-library-size-analizing-progress">0%</span></div>
    4545            <div class="sirv-calc-media-size-data">
    4646              <span class="sirv-calc-media-size-approx_symbol"><?php echo $approximately_symbol; ?></span>
     
    7171    <tr>
    7272      <td colspan="2">
    73         <h3>Status</h3>
    74         <p class="sirv-options-desc">Images are copied to Sirv the first time they are viewed, which can take 1-2 seconds per image. To perform a full synchronization now, click Sync images:</p>
     73        <h3>Sync to Sirv</h3>
     74        <p class="sirv-options-desc">Your images will automatically copy to Sirv the first time they're viewed. This usually takes 1-2 seconds per image.</p>
    7575      </td>
    7676    </tr>
     
    204204            <span class="sirv-traffic-loading-ico" style="display: none;"></span>
    205205          </div>
     206        </td>
     207      </tr>
     208      <tr>
     209        <td>
     210          <p>You can pre-sync all images to Sirv. This will remove the 1-2 second delay the first time an image is requested.</p>
    206211        </td>
    207212      </tr>
  • sirv/trunk/readme.txt

    r3162079 r3186406  
    55Requires PHP: 5.6
    66Requires at least: 3.0.1
    7 Tested up to: 6.6
     7Tested up to: 6.7
    88Stable tag: trunk
    99License: GPLv2 or later
     
    240240== Changelog ==
    241241
     242= 7.3.1 (2024-11-12) =
     243* Tested with the latest WordPress version 6.7.
     244* Improved security for uploading large images.
     245* Improved integration with WooCommerce variation images.
     246* Improved detection of media uploaded to Sirv folders.
     247* Improved loading of custom Sirv JS global options.
     248* Improved design of the Synchronization tab.
     249* Fixed issue with incorrect initialization of Advanced Editor Tools (TinyMCE plugin).
     250* Many small fixes and optimizations.
     251
    242252= 7.3.0 (2024-10-03) =
    243253* Improved plugin security.
  • sirv/trunk/sirv.php

    r3162079 r3186406  
    55 * Plugin URI: http://sirv.com
    66 * Description: Fully-automatic image optimization, next-gen formats (WebP), responsive resizing, lazy loading and CDN delivery. Every best-practice your website needs. Use "Add Sirv Media" button to embed images, galleries, zooms, 360 spins and streaming videos in posts / pages. Stunning media viewer for WooCommerce. Watermarks, text titles... every WordPress site deserves this plugin! <a href="admin.php?page=sirv/data/options.php">Settings</a>
    7  * Version:           7.3.0
     7 * Version:           7.3.1
    88 * Requires PHP:      5.6
    99 * Requires at least: 3.0.1
     
    1616
    1717
    18 define('SIRV_PLUGIN_VERSION', '7.3.0');
     18define('SIRV_PLUGIN_VERSION', '7.3.1');
    1919define('SIRV_PLUGIN_DIR', 'sirv');
    2020define('SIRV_PLUGIN_SUBDIR', 'plugdata');
     
    121121
    122122
     123//filters for export products woo feature
     124add_filter('woocommerce_product_export_column_names', 'sirv_add_column_to_export_csv');
     125add_filter('woocommerce_product_export_product_default_columns', 'sirv_add_column_to_export_csv');
     126function sirv_add_column_to_export_csv( $columns ) {
     127
     128    // column slug => column name
     129    $columns['sirv_woo_all_urls'] = 'Sirv product media URLs';
     130
     131    return $columns;
     132}
     133
     134
     135// Filter you want to hook into will be: 'woocommerce_product_export_product_column_{$column_slug}'.
     136add_filter('woocommerce_product_export_product_column_sirv_woo_all_urls', 'sirv_add_export_data', 10, 2);
     137function sirv_add_export_data( $value, $product ) {
     138  //$product_id = $product->get_id();
     139  $post_type = $product->post_type;
     140  $is_variation = $post_type == 'product_variation' ? true : false;
     141
     142  $woo = new Woo($product->get_id());
     143    $value = $woo->get_export_data_to_csv_column($is_variation);
     144/*   sirv_qdebug($product_id, '$product_id');
     145  sirv_qdebug($value, '$value');
     146
     147  $value = "TEST TEST TEST"; */
     148    return $value;
     149}
     150
     151
    123152add_action('woocommerce_init', 'sirv_wc_init');
    124153function sirv_wc_init(){
     
    264293//TODO: Add posibillity to get size from html
    265294function sirv_variation_image_html($image_html, $product_id, $variaition_id){
    266   $modified_image_html = $image_html;
     295  //$modified_image_html = $image_html;
    267296  $sirv_url = '';
    268297
    269298  if ($variaition_id > 0) {
     299    $image_tag_metadata = Utils::parse_html_tag_attrs($image_html);
     300    $width = isset($image_tag_metadata['width']) ? $image_tag_metadata['width'] : 300;
     301    $height = isset($image_tag_metadata['height']) ? $image_tag_metadata['height'] : 300;
     302
    270303    $woo = new Woo($product_id);
    271304
     
    275308      if ($wc_variation[0]->provider == 'sirv') {
    276309        $sirv_url = $wc_variation[0]->url;
    277         $sirv_parametrized_url = sirv_get_parametrized_url($sirv_url, array(250, 250), true);
    278         $modified_image_html = preg_replace('/(src=".*?")/', "src=\"$sirv_parametrized_url\"", $image_html);
     310        $sirv_parametrized_url = sirv_get_parametrized_url($sirv_url, array($width, $height), true);
     311        //$modified_image_html = preg_replace('/(src=".*?")/', "src=\"$sirv_parametrized_url\"", $image_html);
     312        $image_tag_metadata['src'] = $sirv_parametrized_url;
    279313      } else {
    280314        return $image_html;
     
    291325
    292326      if (!empty($sirv_url)) {
    293         $sirv_parametrized_url = sirv_get_parametrized_url($sirv_url, array(250, 250), true);
    294         $modified_image_html = preg_replace('/(src=".*?")/', "src=\"$sirv_parametrized_url\"", $image_html);
     327        $sirv_parametrized_url = sirv_get_parametrized_url($sirv_url, array($width, $height), true);
     328        //$modified_image_html = preg_replace('/(src=".*?")/', "src=\"$sirv_parametrized_url\"", $image_html);
     329        $image_tag_metadata['src'] = $sirv_parametrized_url;
    295330      }
    296     }
    297   }
    298 
    299   return $modified_image_html;
     331      //return $modified_image_html;
     332      return Utils::build_html_tag('img', $image_tag_metadata, array('srcset', 'sizes', 'data-src'));
     333    }
     334  }
     335
     336    return $image_html;
    300337}
    301338
     
    13631400  wp_enqueue_style('sirv_mce_style');
    13641401
    1365   wp_register_script('sirv_logic', SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv.js', array('jquery', 'jquery-ui-sortable', 'sirv_toast_js'), false);
     1402  wp_register_script('sirv_logic', SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv.js', array('jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'sirv_toast_js'), false);
    13661403  wp_localize_script('sirv_logic', 'sirv_ajax_object', array(
    13671404    'ajaxurl' => admin_url('admin-ajax.php'),
     
    14541491      wp_register_style('sirv_mce_style', SIRV_PLUGIN_SUBDIR_URL_PATH . 'css/wp-sirv-shortcode-view.css');
    14551492      wp_enqueue_style('sirv_mce_style');
    1456       wp_register_script('sirv_logic', SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv.js', array('jquery', 'jquery-ui-sortable', 'sirv_toast_js'), '1.1.0');
     1493      wp_register_script('sirv_logic', SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv.js', array('jquery','jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'sirv_toast_js'), '1.1.0');
    14571494      wp_localize_script('sirv_logic', 'sirv_ajax_object', array(
    14581495        'ajaxurl' => admin_url('admin-ajax.php'),
     
    15301567    wp_register_style('sirv_style', SIRV_PLUGIN_SUBDIR_URL_PATH . 'css/wp-sirv.css');
    15311568    wp_enqueue_style('sirv_style');
    1532     wp_enqueue_script('sirv_logic', SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv.js', array('jquery', 'jquery-ui-sortable', 'sirv_toast_js'), false);
     1569    wp_enqueue_script('sirv_logic', SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv.js', array('jquery','jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'sirv_toast_js'), false);
    15331570    wp_localize_script('sirv_logic', 'sirv_ajax_object', array(
    15341571      'ajaxurl' => admin_url('admin-ajax.php'),
     
    15711608add_filter('mce_external_plugins', 'sirv_tinyMCE_plugin_shortcode_view');
    15721609
    1573 function sirv_tinyMCE_plugin_shortcode_view(){
    1574   return array('sirvgallery' => SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv-shortcode-view.js');
     1610function sirv_tinyMCE_plugin_shortcode_view($plugins){
     1611  $plugins['sirvgallery'] = SIRV_PLUGIN_SUBDIR_URL_PATH . 'js/wp-sirv-shortcode-view.js';
     1612
     1613  return $plugins;
    15751614}
    15761615
     
    18531892  $sirv_js_path = getValue::getOption('SIRV_JS_FILE');
    18541893
     1894  global $post;
     1895
    18551896  wp_register_script('sirv-js', $sirv_js_path, array(), false, false);
    18561897  wp_enqueue_script('sirv-js');
     1898
     1899  if (isset($post->post_type) && $post->post_type == 'product') {
     1900    $sirv_woo_is_enable_option = get_option('SIRV_WOO_IS_ENABLE');
     1901    $sirv_woo_is_enable = !empty($sirv_woo_is_enable_option) && $sirv_woo_is_enable_option == '2' ? true : false;
     1902    if( $sirv_woo_is_enable ){
     1903      $woo = new Woo($post->ID);
     1904      $mv_custom_options = $woo->remove_script_tag(get_option('SIRV_WOO_MV_CUSTOM_OPTIONS'));
     1905
     1906      wp_add_inline_script('sirv-js', $mv_custom_options, 'after');
     1907    }
     1908  }
    18571909}
    18581910
     
    18961948        $sirv_js_path = getValue::getOption('SIRV_JS_FILE');
    18971949
     1950        global $post;
     1951
     1952        $mv_custom_options_block = '';
     1953
     1954        if (isset($post->post_type) && $post->post_type == 'product') {
     1955          $sirv_woo_is_enable_option = get_option('SIRV_WOO_IS_ENABLE');
     1956          $sirv_woo_is_enable = !empty($sirv_woo_is_enable_option) && $sirv_woo_is_enable_option == '2' ? true : false;
     1957          if ($sirv_woo_is_enable) {
     1958            $woo = new Woo($post->ID);
     1959            $mv_custom_options = $woo->remove_script_tag(get_option('SIRV_WOO_MV_CUSTOM_OPTIONS'));
     1960            $mv_custom_options_block = !empty($mv_custom_options) ?  PHP_EOL . '<script nowprocket>' . PHP_EOL . $mv_custom_options . PHP_EOL . '</script>' . PHP_EOL : '';
     1961
     1962          }
     1963        }
     1964
    18981965        if(preg_match($link_prefetch_pattern, $content) === 1){
    1899           $content = preg_replace($link_prefetch_pattern, '$1<script src="' . $sirv_js_path . '"></script>', $content, 1);
     1966          $content = preg_replace($link_prefetch_pattern,  '$1'. PHP_EOL .'<script src="' . $sirv_js_path . '"></script>'. $mv_custom_options_block, $content, 1);
    19001967        }else{
    19011968          $content = preg_replace('/(<\/head>)/is', '<script src="' . $sirv_js_path . '"></script>$1', $content, 1);
     
    20292096  $url = wp_get_attachment_url($attachment_id);
    20302097
     2098  if( !$url ) return false;
     2099
    20312100  if (sirv_is_sirv_item($url)) {
    20322101    $post = get_post($attachment_id);
     
    20782147
    20792148function sirv_is_sirv_item($url){
    2080     if( empty($url) ) return false;
    2081     //$sirv_cdn_url = get_option('SIRV_CDN_URL');
    2082     $sirv_cdn_url = sirv_get_cached_cdn_url();
    2083     $sirv_url = empty($sirv_cdn_url) ? 'sirv.com' : $sirv_cdn_url;
    2084     return stripos($url, $sirv_url) !== false;
     2149  if( empty($url) ) return false;
     2150
     2151  //does not give 100% guarantee that this is sirv image
     2152  $count = substr_count($url, 'http');
     2153  if( $count > 1 ) return true;
     2154
     2155  //$sirv_cdn_url = get_option('SIRV_CDN_URL');
     2156  $sirv_cdn_url = sirv_get_cached_cdn_url();
     2157  $sirv_url = empty($sirv_cdn_url) ? 'sirv.com' : $sirv_cdn_url;
     2158  return stripos($url, $sirv_url) !== false;
    20852159  }
    20862160
     
    26162690
    26172691  if( empty($size)){
    2618     if( $sirv_item_type_data['sirv_type'] == 'video' ) return sirv_add_profile($sirv_image . "?thumbnail=500");
    2619     if( $sirv_item_type_data['sirv_type'] == 'spin' ) return sirv_add_profile($sirv_image . "?thumb");
     2692    if( $sirv_item_type_data['type'] == 'video' ) return sirv_add_profile($sirv_image . "?thumbnail=500");
     2693    if( $sirv_item_type_data['type'] == 'spin' ) return sirv_add_profile($sirv_image . "?thumb");
    26202694
    26212695    return sirv_add_profile($sirv_image);
     
    26242698  $item_show_pattern = '';
    26252699
    2626   if( $sirv_item_type_data['sirv_type'] == 'video' ){
     2700  if( $sirv_item_type_data['type'] == 'video' ){
    26272701    $image = sirv_get_correct_item_size($size, $isCrop);
    26282702    $url = $sirv_image . "?thumbnail=" . $image['width'];
    26292703    return sirv_add_profile($url);
    26302704
    2631   }else if( $sirv_item_type_data['sirv_type'] == 'spin' ){
     2705  }else if( $sirv_item_type_data['type'] == 'spin' ){
    26322706    $item_show_pattern = "?thumb";
    26332707  }
     
    46944768function sirv_upload_file_by_chunks_callback(){
    46954769  if (!(is_array($_POST) && isset($_POST['binPart']) && defined('DOING_AJAX') && DOING_AJAX)) {
    4696     return;
     4770    echo json_encode(array('critical_error' => 'AJAX not allowed'));
     4771    wp_die();
    46974772  }
    46984773
    46994774  if (!sirv_is_allow_ajax_connect('sirv_logic_ajax_validation_nonce', 'edit_posts')) {
    4700     echo json_encode(array('error' => 'Access to the requested resource is forbidden'));
     4775    echo json_encode(array('critical_error' => 'Access to the requested resource is forbidden'));
    47014776    wp_die();
    47024777  }
    47034778
     4779  $response = array();
     4780  $error = '';
    47044781  $is_upload_file = true;
    4705 
    47064782  $arr_content = array();
    47074783
     
    47184794
    47194795  if( !$tmp_filepath ){
    4720     echo json_encode(array('error' => 'Can\'t create tmp file. Please check if php tmp path is correctly set.'));
     4796    echo json_encode(array('critical_error' => 'Can\'t create tmp file. Please check if php tmp path is correctly set'));
    47214797    wp_die();
    47224798  }
     
    47364812
    47374813  if($partNum < $totalParts){
    4738     echo json_encode(array('status' => 'processing', 'stop' => false));
     4814    $response['status'] = 'processing';
     4815    $response['stop'] = false;
    47394816
    47404817  }
     
    47444821
    47454822    $mime_type = Utils::get_mime_type($tmp_filepath);
    4746 
    47474823    if( in_array($mime_type, $disallowed_types) ){
    47484824      unlink($tmp_filepath);
    4749       delete_option($filename);
    4750 
    4751       echo json_encode(array('error' => 'File type is not allowed'));
    4752       wp_die();
    4753     }
    4754 
    4755     //sanitize svg file before upload
    4756     if (Utils::get_mime_subtype($tmp_filepath) == 'svg+xml') {
    4757       $is_upload_file = sirv_sanitize_svg($tmp_filepath);
    4758     }
    4759 
    4760 
    4761 
    4762     if($is_upload_file){
    4763       $APIClient = sirv_getAPIClient();
    4764       $result = $APIClient->uploadImage($tmp_filepath, $sirv_path);
    4765 
    4766       unlink($tmp_filepath);
    4767       delete_option($filename);
    4768     }else{
    4769       $filename = basename(urldecode($sirv_path));
    4770       $result['error'] = "SVG file $filename cannot be sanitized. Upload is forbidden";
    4771     }
    4772 
    4773 
    4774     if( isset($result["error"]) ){
    4775       echo json_encode(array('error' => $result["error"]));
    4776       wp_die();
    4777     }
     4825      sirv_remove_tmp_option($filename);
     4826
     4827      $error ="File $filename type is not allowed";
     4828    }
     4829
     4830    if( !$error ){
     4831      //sanitize svg file before upload
     4832      if ( Utils::get_mime_subtype($tmp_filepath) == 'svg+xml' ) {
     4833        $is_upload_file = sirv_sanitize_svg($tmp_filepath);
     4834      }
     4835
     4836      if( $is_upload_file ){
     4837        $APIClient = sirv_getAPIClient();
     4838        $result = $APIClient->uploadImage($tmp_filepath, $sirv_path);
     4839      }else{
     4840        $filename = basename(urldecode($sirv_path));
     4841        $error = "SVG file $filename cannot be sanitized. Upload is forbidden";
     4842      }
     4843
     4844
     4845      @unlink($tmp_filepath);
     4846      sirv_remove_tmp_option($filename);
     4847    }
     4848
    47784849
    47794850    session_id("image-uploading-status");
     
    47884859
    47894860    if ($arr_content['processedImage'] == $arr_content['count']){
    4790       echo json_encode(array('stop' => true));
     4861      $response['stop'] = true;
     4862      $response['status'] = 'done';
    47914863    }else{
    4792       echo json_encode(array('status' => 'processing', 'stop' => false));
    4793     }
    4794   }
    4795 
     4864      $response['status'] = 'processing';
     4865      $response['stop'] = false;
     4866    }
     4867  }
     4868
     4869  if ($error) $response['error'] = $error;
     4870
     4871  echo json_encode($response);
    47964872  wp_die();
    47974873}
    47984874
    47994875
    4800 function sirv_get_tmp_filename($db_key){
    4801   $tmp_filepath = get_option($db_key);
     4876function sirv_get_tmp_filename($raw_option_key){
     4877
     4878  $option_key = sirv_get_tmp_option_name($raw_option_key);
     4879  $tmp_filepath = get_option($option_key);
    48024880
    48034881  if( $tmp_filepath ){
     
    48084886
    48094887  if($tmp_filepath){
    4810     update_option($db_key, $tmp_filepath);
     4888    update_option($option_key, $tmp_filepath);
    48114889  }
    48124890
     
    48154893  return $tmp_filepath;
    48164894
     4895}
     4896
     4897
     4898function sirv_get_tmp_option_name($filename){
     4899  return "SIRV_TMP_FILEPATH" . '_' . md5($filename);
     4900}
     4901
     4902
     4903function sirv_remove_tmp_option($raw_option_key){
     4904  $option_key = sirv_get_tmp_option_name($raw_option_key);
     4905  delete_option($option_key);
    48174906}
    48184907
     
    58935982  ); */
    58945983  $media_storage_data =  array(
    5895         'date' => date('\o\n F d, Y'),
     5984        'date' => date('\o\n F j, Y'),
    58965985        'size' => Utils::getFormatedFileSize($upload_space),
    58975986        'img_count' => $post_images_count
     
    59536042  if( in_array($stored_data['status'], array('initial', 'done', 'stopped')) ){
    59546043    $stored_data['all_images_count'] = sirv_get_all_post_images_count();
    5955     $stored_data['date'] = date('F d, Y');
     6044    $stored_data['date'] = date('F j, Y');
    59566045  }
    59576046
     
    64766565  //if (is_admin() || $isAdmin) return;
    64776566
     6567  $forbidden_actions = array('query-attachments');
     6568
    64786569  if (defined('DOING_AJAX') && DOING_AJAX) {
    64796570    $action = '';
     
    64846575      $action = isset($_GET['action']) ? $_GET['action'] : '';
    64856576    }
     6577
     6578    if(in_array($action, $forbidden_actions)) return;
    64866579
    64876580    if (!empty($action) && sirv_is_frontend_ajax($action)) {
Note: See TracChangeset for help on using the changeset viewer.