function fpd_has_content($post_id)
{
    $source_type = get_post_meta($post_id, 'fpd_source_type', true);
    if (empty($source_type) || $source_type == 'category') {
        if (!fpd_table_exists(FPD_CATEGORIES_TABLE)) {
            return false;
        }
    } else {
        if (!fpd_table_exists(FPD_VIEWS_TABLE)) {
            return false;
        }
    }
    //get assigned categories
    $product_settings = new FPD_Product_Settings($post_id);
    $ids = $product_settings->get_content_ids();
    //check if categories are not empty
    return empty($ids) ? false : $ids;
}
        public function add_product_designer_form()
        {
            global $post;
            $product_settings = new FPD_Product_Settings($post->ID);
            $open_in_lightbox = $product_settings->get_option('open_in_lightbox') && trim($product_settings->get_option('start_customizing_button')) != '';
            if (is_fancy_product($post->ID) && (!$product_settings->customize_button_enabled || $open_in_lightbox)) {
                ?>
				<input type="hidden" value="" name="fpd_product" />
				<input type="hidden" value="" name="fpd_product_price" />
				<input type="hidden" value="" name="fpd_product_thumbnail" />
				<input type="hidden" value="<?php 
                echo isset($_GET['cart_item_key']) ? $_GET['cart_item_key'] : '';
                ?>
" name="fpd_remove_cart_item" />
				<?php 
            }
        }
Esempio n. 3
0
 public static function do_upgrade($to_version)
 {
     global $wpdb;
     if ($to_version === '1.1.3') {
         $wpdb->query("ALTER TABLE " . FPD_VIEWS_TABLE . " ADD view_order INT COLLATE utf8_general_ci NULL DEFAULT 0;");
     } else {
         if ($to_version === '2.0.0') {
             $views = $wpdb->get_results("SELECT * FROM " . FPD_VIEWS_TABLE . " GROUP BY product_id");
             foreach ($views as $view) {
                 //check if product exists, otherwise delete it from views table
                 if (get_post_status($view->product_id) === false) {
                     $wpdb->query($wpdb->prepare("DELETE FROM " . FPD_VIEWS_TABLE . " WHERE product_id=%d", $view->product_id));
                 } else {
                     $check_title = get_the_title($view->product_id);
                     if (!empty($check_title)) {
                         $product_id = Fancy_Product::create($check_title);
                         //create product
                         $fancy_product_settings = new FPD_Product_Settings($view->product_id);
                         //get stage dimensions and add them in the product options
                         $product_options = array();
                         if ($fancy_product_settings->get_individual_option('stage_width')) {
                             $product_options['stage_width'] = $fancy_product_settings->get_individual_option('stage_width');
                         }
                         if ($fancy_product_settings->get_individual_option('stage_height')) {
                             $product_options['stage_height'] = $fancy_product_settings->get_individual_option('stage_height');
                         }
                         $fancy_product = new Fancy_Product($product_id);
                         if (sizeof($product_options) !== 0) {
                             $fancy_product->update(null, json_encode($product_options));
                         }
                         //assign product to wc product
                         update_post_meta($view->product_id, 'fpd_source_type', 'product');
                         $product_array = array($product_id);
                         update_post_meta($view->product_id, 'fpd_products', $product_array);
                         //update product id of views
                         $wpdb->update(FPD_VIEWS_TABLE, array('product_id' => $product_id), array('product_id' => $view->product_id), array('%d'), array('%d'));
                     }
                 }
             }
             //add options to views table
             $wpdb->query("ALTER TABLE " . FPD_VIEWS_TABLE . " ADD options TEXT COLLATE utf8_general_ci NULL DEFAULT '';");
         }
     }
 }
        public function enqueue_styles()
        {
            global $post;
            if (fpd_get_option('fpd_sharing')) {
                wp_enqueue_style('fpd-jssocials');
            }
            wp_enqueue_style('jquery-fpd');
            wp_enqueue_style('fpd-single-product', plugins_url('/css/fancy-product.css', FPD_PLUGIN_ROOT_PHP), false, Fancy_Product_Designer::VERSION);
            //only enqueue css and js files when necessary
            $product_settings = new FPD_Product_Settings($post->ID);
            if (is_fancy_product($post->ID)) {
                ?>
					<style type="text/css">

						/* Styling */

						.fancy-product .fpd-primary-bg-color {
							background-color: <?php 
                echo fpd_get_option('fpd_designer_primary_color');
                ?>
;
						}

						.fancy-product .fpd-primary-text-color,
						.fancy-product .fpd-primary-text-color:hover {
							color:  <?php 
                echo fpd_get_option('fpd_designer_primary_text_color');
                ?>
;
						}

						.fancy-product .fpd-secondary-bg-color {
							background-color: <?php 
                echo fpd_get_option('fpd_designer_secondary_color');
                ?>
 !important;
						}

						.fancy-product .fpd-secondary-text-color,
						.fancy-product .fpd-secondary-text-color:hover {
							color:  <?php 
                echo fpd_get_option('fpd_designer_secondary_text_color');
                ?>
 !important;
						}

						.fancy-product .fpd-tabs > .fpd-btn.fpd-checked {
							border-color: <?php 
                echo fpd_get_option('fpd_designer_secondary_color');
                ?>
;
						}

						.fancy-product .fpd-checked i {
							color: <?php 
                echo fpd_get_option('fpd_designer_secondary_color');
                ?>
 !important;
						}

						<?php 
                if ($product_settings->get_option('background_type')) {
                    ?>
						.fpd-product-stage {
							background: <?php 
                    echo $product_settings->get_option('background_type') == 'color' ? $product_settings->get_option('background_color') : 'url(' . $product_settings->get_option('background_image') . ')';
                    ?>
 !important;
						}
						<?php 
                }
                ?>


						<?php 
                echo stripslashes(get_option('fpd_custom_css'));
                ?>

					</style>
					<?php 
                FPD_Fonts::output_webfont_links();
            }
        }