public function wcla_update_options()
 {
     woocommerce_update_options(WCLA_Utilities::get_fields());
 }
Пример #2
0
function wcla_load_designer_iframe($atts)
{
    global $woocommerce;
    $woocommerce->cart->set_quantity($_GET["cart_key"], 0);
    // .
    if (isset($_GET["design_id"])) {
        $url = site_url('/designer/') . '?design_id=' . (string) $_GET["design_id"];
    } else {
        $url = site_url('/designer/') . '?productid=' . ((int) $_GET["productid"] == 0 ? (string) WCLA_Utilities::get_option('wcla_product_id') : (string) $_GET["productid"]);
    }
    echo '<iframe height="' . WCLA_Utilities::get_option('wcla_iframe_height') . '" width="' . WCLA_Utilities::get_option('wcla_iframe_width') . '" scrolling="yes" style="border:none;overflow:hidden;" src="' . $url . '"></iframe>';
}
        function wcla_graphics_details_cb($post)
        {
            ?>
            <p>     
                <?php 
            if (get_post_meta($post->ID, 'wcla_graphics_file_url', true) != '') {
                ?>
                    <a href="<?php 
                echo get_post_meta($post->ID, 'wcla_graphics_file_url', true);
                ?>
" style="float:left"><img src="<?php 
                echo get_post_meta($post->ID, 'wcla_graphics_file_url', true);
                ?>
" height="40" width="40"></a>
                <?php 
            }
            ?>
                             
                <label for="wcla_graphics_image_file"><?php 
            echo __('Image', 'liveart');
            ?>
:</label>
                <input type="file" id="wcla_graphics_image_file" name="wcla_graphics_image_file" value="" accept="image/*" />
            </p>
            <div style="clear:both"></div>
            <p>
                <?php 
            if (get_post_meta($post->ID, 'wcla_graphics_thumb_file_url', true) != '') {
                ?>
                    <a href="<?php 
                echo get_post_meta($post->ID, 'wcla_graphics_thumb_file_url', true);
                ?>
" style="float:left"><img src="<?php 
                echo get_post_meta($post->ID, 'wcla_graphics_thumb_file_url', true);
                ?>
" height="40" width="40"></a>
                <?php 
            }
            ?>
 
                <label for="wcla_graphics_image_thumb_file"><?php 
            echo __('Thumbnail', 'liveart');
            ?>
:</label>
                <input type="file" id="wcla_graphics_image_thumb_file" name="wcla_graphics_image_thumb_file" value="" accept="image/*"/>                
            </p>
            <p>
                <label for="category_id"><?php 
            echo __('Category', 'liveart');
            ?>
:</label>
                <?php 
            echo WCLA_LAGraphics_Post_Type::getTaxonomyCombo('lagraphics_categories', 'category_id', get_post_meta($post->ID, 'wcla_graphics_category_id', true) == '' ? 0 : get_post_meta($post->ID, 'wcla_graphics_category_id', true));
            ?>
            </p>
            <div class="note wide50pct" ><?php 
            echo __('Graphic category', 'liveart');
            ?>
.</div>
            <p>
                <label for="wcla_graphics_desc"><?php 
            echo __('Description', 'liveart');
            ?>
:</label>
                <textarea type="text" id="wcla_graphics_desc" name="wcla_graphics_desc"  class="wide50pct" ><?php 
            echo get_post_meta($post->ID, 'wcla_graphics_desc', true);
            ?>
</textarea>
            </p>
            <p>
                <label for="wcla_graphics_price"><?php 
            echo __('Price', 'liveart');
            ?>
:</label>
                <input type="text" id="wcla_graphics_price" name="wcla_graphics_price" value="<?php 
            echo get_post_meta($post->ID, 'wcla_graphics_price', true);
            ?>
"  class="wide50pct"/>
            </p>
            <div class="note wide50pct" ><?php 
            echo __('Extra price', 'liveart');
            ?>
</div>
            <p>
                <?php 
            echo WCLA_Utilities::selectYesNo('wcla_graphics_colorizable', 'Colorizable', get_post_meta($post->ID, 'wcla_graphics_colorizable', true));
            ?>
            </p>
            <p>
                <label for="wcla_graphics_colors"><?php 
            echo __('Colors', 'liveart');
            ?>
:</label>
                <input type="text" id="wcla_graphics_colors" name="wcla_graphics_colors" value="<?php 
            echo get_post_meta($post->ID, 'wcla_graphics_colors', true);
            ?>
"  class="wide50pct" />
            </p>

            <div class="note wide50pct" >
                <ul>
                    <li> <code class="prettyprint">"-1"</code> — <?php 
            echo __('process colors are required, e.g. if the graphic is photo', 'liveart');
            ?>
; </li>
                    <li> <code class="prettyprint">"0"</code> — default value (need graphic to be <code class="prettyprint">Colorizable = Yes</code> and get colors information from selected fill color/outline/multicolor layers); </li>
                    <li> <?php 
            echo __('integer (e.g. <code class="prettyprint">"5"</code>) — number of unique graphic colors', 'liveart');
            ?>
;</li>
                    <li> <?php 
            echo __('array of hex web colors (e.g. <code class="prettyprint">["#FFFFFF", "#000000"]</code>) — list of colors for accurate counting', 'liveart');
            ?>
</li>
                </ul>
            </div>
            <?php 
            wp_nonce_field(plugin_basename(__FILE__), 'graphic_file_nonce');
            ?>
            <?php 
        }
        function wcla_font_file_cb($post)
        {
            //wp_nonce_field(__FILE__, 'mma_nonce');
            $files = get_post_meta($post->ID, 'wcla_font_file', true);
            ?>
 
            <p>          			
                <label for="wcla_font_family"><?php 
            echo __('Font Family', 'liveart');
            ?>
:</label>            
                <input type="text" id="wcla_font_family" name="wcla_font_family" value="<?php 
            echo get_post_meta($post->ID, 'wcla_font_family', true);
            ?>
" class="wide50pct" />                                                
            </p>
            <div class="note" ><?php 
            echo __('The Font Family', 'liveart');
            ?>
.</div>
            <p>          			
                <label for="wcla_font_system_name"><?php 
            echo __('System Name', 'liveart');
            ?>
:</label>            
                <input type="text" id="wcla_font_system_name" name="wcla_font_system_name" value="<?php 
            echo get_post_meta($post->ID, 'wcla_font_system_name', true);
            ?>
" class="wide50pct" />                       
            </p>
            <div class="note wide50pct" ><?php 
            echo __('Need for converting. Use <b>bold</b> name from System Fonts below (font should appear there after saving)', 'liveart');
            ?>
.</div>

            <p>
                <label for="wcla_font_file">
                    <?php 
            echo __('File(Normal)', 'liveart');
            ?>
:
                </label>
                <input type="file" id="wcla_font_file" name="wcla_font_file[normal_normal]" value="" />                
                <?php 
            if (isset($files["normal_normal"])) {
                ?>
                    <br>
                    <span class="font-filename"><?php 
                echo $files["normal_normal"];
                ?>
</span>
                <?php 
            }
            ?>

            </p>
            <p>
                <label for="wcla_font_file">
                    <?php 
            echo __('File(Bold)', 'liveart');
            ?>
:
                </label>
                <input type="file" id="wcla_font_file" name="wcla_font_file[bold_normal]" value="" />    
                <?php 
            if (isset($files["bold_normal"])) {
                ?>
                    <br>
                    <span class="font-filename"><?php 
                echo $files["bold_normal"];
                ?>
</span>
                <?php 
            }
            ?>
            </p>
            <p>
                <label for="wcla_font_file">
                    <?php 
            echo __('File(Italic)', 'liveart');
            ?>
:
                </label>
                <input type="file" id="wcla_font_file" name="wcla_font_file[normal_italic]" value="" />     
                <?php 
            if (isset($files["normal_italic"])) {
                ?>
                    <br>
                    <span class="font-filename"><?php 
                echo $files["normal_italic"];
                ?>
</span>
                <?php 
            }
            ?>
            </p>
            <p>
                <label for="wcla_font_file">
                    <?php 
            echo __('File(Bold & Italic)', 'liveart');
            ?>
:
                </label>
                <input type="file" id="wcla_font_file" name="wcla_font_file[bold_italic]" value="" />   
                <?php 
            if (isset($files["bold_italic"])) {
                ?>
                    <br>
                    <span class="font-filename"><?php 
                echo $files["bold_italic"];
                ?>
</span>
                <?php 
            }
            ?>
            </p>
            <p>          			
                <label for="wcla_font_ascent"><?php 
            echo __('Ascent', 'liveart');
            ?>
:</label>            
                <input type="text" id="wcla_font_ascent" name="wcla_font_ascent" value="<?php 
            echo get_post_meta($post->ID, 'wcla_font_ascent', true);
            ?>
" class="wide50pct" />                       
            </p>
            <p>
                <?php 
            echo WCLA_Utilities::selectYesNo('wcla_font_bold_allowed', 'Bold Allowed', get_post_meta($post->ID, 'wcla_font_bold_allowed', true));
            ?>
            </p>
            <p>
                <?php 
            echo WCLA_Utilities::selectYesNo('wcla_font_italic_allowed', 'Italic Allowed', get_post_meta($post->ID, 'wcla_font_italic_allowed', true));
            ?>
            </p>
            <p>
                <label for="wcla_font_vector_file">
                    <?php 
            echo __('Vector File', 'liveart');
            ?>
:
                </label>
                <input type="file" id="wcla_font_vector_file" name="wcla_font_vector_file" value="" /> 
                <?php 
            if (get_post_meta($post->ID, 'wcla_font_vector_file', true)) {
                ?>
                    <br>
                    <span class="font-filename"><?php 
                echo get_post_meta($post->ID, 'wcla_font_vector_file', true);
                ?>
</span>
                <?php 
            }
            ?>
            </p>

            <?php 
            wp_nonce_field(plugin_basename(__FILE__), 'font_file_nonce');
            ?>
            <?php 
        }
 public function generateImages($designId, $locations)
 {
     $image = array();
     foreach ($locations as $location) {
         $baseSvg = $location->svg;
         $svg = $baseSvg;
         //$baseSvg = str_replace('NS1:', 'xlink:', $baseSvg);
         if (!is_array($images[$location->name])) {
             $images[$location->name] = array();
         }
         $basePath = DESIGNER_DESIGNS_DIR . $designId . '/';
         if (!file_exists($basePath)) {
             mkdir($basePath, 0777, true);
         }
         $baseSvgForConvert = $baseSvg;
         preg_match_all('|xlink:href="(.*)"|U', $baseSvgForConvert, $matches);
         if (isset($matches[1][0])) {
             $textImageIndex = 0;
             foreach ($matches[1] as $url) {
                 if (strpos($url, DESIGNER_UPLOAD_URL) !== false) {
                     $imagePath = str_replace(DESIGNER_UPLOAD_URL, DESIGNER_UPLOAD_DIR, $url);
                     $imageFilename = pathinfo($imagePath, PATHINFO_BASENAME);
                     copy($imagePath, $basePath . $imageFilename);
                     $baseSvgForConvert = str_replace($url, $imageFilename, $baseSvgForConvert);
                 }
             }
         }
         // Gallery images
         preg_match_all('|la-source-url="(.*)"|U', $baseSvgForConvert, $matches);
         if (isset($matches[1][0])) {
             foreach ($matches[1] as $url) {
                 if (strpos($url, DESIGNER_UPLOAD_URL) !== false) {
                     $imagePath = str_replace(DESIGNER_UPLOAD_URL, DESIGNER_UPLOAD_DIR, $url);
                     $imageFilename = pathinfo($imagePath, PATHINFO_BASENAME);
                     copy($imagePath, $basePath . $imageFilename);
                     $baseSvgForConvert = str_replace($url, $imageFilename, $baseSvgForConvert);
                 }
             }
         }
         // Replace fonts name to system fonts names (need for convertion)
         $fonts = new WP_Query();
         $fonts->query(array('post_type' => 'wcla_fonts', 'nopaging' => true));
         foreach ($fonts->posts as $font) {
             if (!get_post_meta($font->ID, 'wcla_font_system_name', true)) {
                 continue;
             }
             $baseSvgForConvert = str_replace('"' . get_post_meta($font->ID, 'wcla_font_family', true) . '"', '"' . get_post_meta($font->ID, 'wcla_font_system_name', true) . '"', $baseSvgForConvert);
             $baseSvgForConvert = preg_replace('|font-family: [\']*' . get_post_meta($font->ID, 'wcla_font_family', true) . '[\']*;|U', 'font-family: ' . get_post_meta($font->ID, 'wcla_font_system_name', true) . ';', $baseSvgForConvert);
         }
         $imagePathSvg = $basePath . $designId . '_' . $location->name . '.svg';
         $svgForConvert = $baseSvgForConvert;
         file_put_contents($imagePathSvg, $svgForConvert);
         $filename = $designId . '_' . $location->name;
         $convertMethod = WCLA_Utilities::get_option('wcla_convert_method');
         //var_dump($convertMethod);die;
         if (WCLA_Utilities::get_option('wcla_enable_convert')) {
             switch ($convertMethod) {
                 case 'imagick':
                     //exec('convert ' . $imagePathSvg . ' -resize ' . $imageWidth . 'x' . $imageHeight . ' ' . $basePath . $filename . '.jpg', $output);
                     exec('/usr/local/bin/convert ' . $imagePathSvg . ' ' . $basePath . $filename . '.jpg', $output);
                     //echo 'inkscape --export-png=' . $basePath . $filename . '.png' . ' --export-background-opacity=0 --without-gui ' . $imagePathSvg;
                     break;
                 case 'inkscape':
                     exec('inkscape --export-png=' . $basePath . $filename . '.png' . ' --export-background-opacity=0 --without-gui ' . $imagePathSvg, $output);
                     exec('/usr/local/bin/convert ' . $basePath . $filename . '.png' . ' ' . $basePath . $filename . '.jpg', $output);
                     break;
             }
         }
         unlink($imagePathSvg);
         // ************************
         // Save svg
         file_put_contents($imagePathSvg, $svg);
         $images[$location->name]['svg'] = $filename . '.svg';
         if (file_exists($basePath . $filename . '.jpg')) {
             $images[$location->name]['jpg'] = $filename . '.jpg';
         }
         if (file_exists($basePath . $filename . '.png')) {
             $images[$location->name]['png'] = $filename . '.jpg';
         }
     }
     return $images;
 }