ID, 'v3d_app_id', true);
54 | if (empty($app_id))
55 | $app_id = '';
56 |
57 | $app_posts = get_posts(array(
58 | 'posts_per_page' => -1,
59 | 'post_type' => 'v3d_app',
60 | 'post_status' => 'publish',
61 | ));
62 |
63 | $app_options[''] = __('None (select a value)', 'verge3d');
64 |
65 | foreach ($app_posts as $app_post)
66 | $app_options[$app_post->ID] = $app_post->post_title;
67 |
68 | woocommerce_wp_select(array(
69 | 'id' => 'v3d_app_id',
70 | 'label' => __('Application', 'verge3d'),
71 | 'options' => $app_options,
72 | 'value' => $app_id,
73 | 'desc_tip' => 'true',
74 | 'description' => __('Verge3D application which will be displayed on the product page.', 'verge3d'),
75 | ));
76 |
77 |
78 | woocommerce_wp_checkbox(array(
79 | 'id' => 'v3d_app_show_gallery',
80 | 'label' => __('Show as gallery item', 'verge3d'),
81 | 'value' => get_post_meta(get_the_ID(), 'v3d_app_show_gallery', true),
82 | 'desc_tip' => 'true',
83 | 'description' => __('Show application as last thumbnail in the gallery. If disabled, all 2D images will be replaced by 3D app.', 'verge3d'),
84 | ));
85 |
86 | woocommerce_wp_checkbox(array(
87 | 'id' => 'v3d_app_switch_on_update',
88 | 'label' => __('Switch to 3D on update', 'verge3d'),
89 | 'value' => get_post_meta(get_the_ID(), 'v3d_app_switch_on_update', true),
90 | 'desc_tip' => 'true',
91 | 'description' => __('Automatically slide to 3D app when product updates (gallery mode only).', 'verge3d'),
92 | ));
93 |
94 | ?>
95 |
107 |
-1,
133 | 'post_type' => 'v3d_app',
134 | 'post_status' => 'publish',
135 | ));
136 |
137 | if (!empty($app_posts)) {
138 | $app_id = get_post_meta($product->get_id(), 'v3d_app_id', true);
139 | if (!empty($app_id) && !empty(get_post($app_id))) {
140 | return v3d_gen_app_iframe_html($app_id);
141 | } else
142 | return '';
143 | }
144 | }
145 |
146 |
147 | function v3d_product_image($html) {
148 | global $product;
149 |
150 | if (get_post_meta(get_the_ID(), 'v3d_app_show_gallery', true))
151 | return $html;
152 |
153 | $app_iframe = v3d_get_product_iframe($product);
154 | if (!empty($app_iframe))
155 | return $app_iframe;
156 | else
157 | return $html;
158 | }
159 | add_filter('woocommerce_single_product_image_thumbnail_html', 'v3d_product_image');
160 |
161 |
162 | function v3d_show_product_thumbnails() {
163 | global $product;
164 |
165 | if (!get_post_meta(get_the_ID(), 'v3d_app_show_gallery', true))
166 | return;
167 |
168 | $app_iframe = v3d_get_product_iframe($product);
169 | if (empty($app_iframe))
170 | return;
171 |
172 | $app_id = get_post_meta($product->get_id(), 'v3d_app_id', true);
173 | if (!empty($app_id) && !empty(get_post($app_id))) {
174 | $cover_att_id = get_post_meta($app_id, 'cover_attachment_id', true);
175 |
176 | $thumbnail_src = wp_get_attachment_image_src($cover_att_id, 'thumbnail');
177 | $full_src = wp_get_attachment_image_src($cover_att_id, 'full');
178 | $alt_text = trim(strip_tags(get_post_meta($cover_att_id, '_wp_attachment_image_alt', true)));
179 | }
180 |
181 | if (!is_array($thumbnail_src)) {
182 | $default_url = plugin_dir_url(__FILE__) . 'images/product_thumbnail.png';
183 | $thumbnail_src = [$default_url];
184 | $full_src = [$default_url];
185 | $alt_text = '3D preview';
186 | }
187 |
188 | $html = '