Changeset 3844587
- Timestamp:
- 12/04/2026 02:06:54 PM (31 hours ago)
- Location:
- vinhxd-car-colors-360
- Files:
-
- 2 added
- 28 edited
- 1 copied
-
assets/icon-128x128.png (added)
-
assets/icon-256x256.png (added)
-
tags/1.1.0 (copied) (copied from vinhxd-car-colors-360/trunk )
-
tags/1.1.0/assets/css/viewer.css (modified) (1 diff)
-
tags/1.1.0/assets/js/admin.js (modified) (1 diff)
-
tags/1.1.0/assets/js/viewer.js (modified) (1 diff)
-
tags/1.1.0/blocks/xe/block.json (modified) (1 diff)
-
tags/1.1.0/blocks/xe/index.asset.php (modified) (1 diff)
-
tags/1.1.0/blocks/xe/index.js (modified) (4 diffs)
-
tags/1.1.0/includes/class-mxot-admin.php (modified) (12 diffs)
-
tags/1.1.0/includes/class-mxot-block.php (modified) (1 diff)
-
tags/1.1.0/includes/class-mxot-elementor-widget.php (modified) (6 diffs)
-
tags/1.1.0/includes/class-mxot-post-type.php (modified) (9 diffs)
-
tags/1.1.0/includes/class-mxot-render.php (modified) (9 diffs)
-
tags/1.1.0/readme.txt (modified) (7 diffs)
-
tags/1.1.0/uninstall.php (modified) (1 diff)
-
tags/1.1.0/vinhxd-car-colors-360.php (modified) (3 diffs)
-
trunk/assets/css/viewer.css (modified) (1 diff)
-
trunk/assets/js/admin.js (modified) (1 diff)
-
trunk/assets/js/viewer.js (modified) (1 diff)
-
trunk/blocks/xe/block.json (modified) (1 diff)
-
trunk/blocks/xe/index.asset.php (modified) (1 diff)
-
trunk/blocks/xe/index.js (modified) (4 diffs)
-
trunk/includes/class-mxot-admin.php (modified) (12 diffs)
-
trunk/includes/class-mxot-block.php (modified) (1 diff)
-
trunk/includes/class-mxot-elementor-widget.php (modified) (6 diffs)
-
trunk/includes/class-mxot-post-type.php (modified) (9 diffs)
-
trunk/includes/class-mxot-render.php (modified) (9 diffs)
-
trunk/readme.txt (modified) (7 diffs)
-
trunk/uninstall.php (modified) (1 diff)
-
trunk/vinhxd-car-colors-360.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vinhxd-car-colors-360/tags/1.1.0/assets/css/viewer.css
r3838725 r3844587 1 /* Màu Xe Ô Tô– front-end viewer */1 /* Product 360 – front-end viewer */ 2 2 .mxot{--mxot-size:36px;--mxot-accent:#d0021b;--mxot-ratio:16/9;position:relative;max-width:100%;margin:0 auto 1.5em;font-size:15px;line-height:1.4;box-sizing:border-box} 3 3 .mxot *,.mxot *::before,.mxot *::after{box-sizing:border-box} -
vinhxd-car-colors-360/tags/1.1.0/assets/js/admin.js
r3838725 r3844587 1 /* Màu Xe Ô Tô – careditor (admin only). */1 /* Sản Phẩm 360 – product editor (admin only). */ 2 2 ( function ( $ ) { 3 3 'use strict'; -
vinhxd-car-colors-360/tags/1.1.0/assets/js/viewer.js
r3838725 r3844587 1 /*! Màu Xe Ô Tôviewer – vanilla JS, no dependencies. */1 /*! Sản Phẩm 360 viewer – vanilla JS, no dependencies. */ 2 2 ( function () { 3 3 'use strict'; -
vinhxd-car-colors-360/tags/1.1.0/blocks/xe/block.json
r3838725 r3844587 3 3 "apiVersion": 3, 4 4 "name": "mau-xe-o-to/xe", 5 "title": " Màu Xe Ô Tô",5 "title": "Sản Phẩm 360", 6 6 "category": "media", 7 "icon": " car",8 "description": "Bảng chọn màu xe kèm xoay 360 độ.",9 "keywords": [ "màu xe", "360", "ô tô", "car", "color" ],7 "icon": "image-rotate", 8 "description": "Bảng chọn màu sản phẩm kèm xoay 360 độ (ô tô, xe máy, nội thất, giày dép...).", 9 "keywords": [ "màu sản phẩm", "màu xe", "360", "ô tô", "car", "color", "product", "swatch" ], 10 10 "textdomain": "vinhxd-car-colors-360", 11 11 "attributes": { -
vinhxd-car-colors-360/tags/1.1.0/blocks/xe/index.asset.php
r3838725 r3844587 12 12 return array( 13 13 'dependencies' => array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-block-editor', 'wp-server-side-render', 'wp-data', 'wp-core-data', 'wp-i18n' ), 14 'version' => '1. 0.2',14 'version' => '1.1.0', 15 15 ); -
vinhxd-car-colors-360/tags/1.1.0/blocks/xe/index.js
r3838725 r3844587 17 17 }, [] ); 18 18 19 var options = [ { value: 0, label: __( '— Chọn xe—', 'vinhxd-car-colors-360' ) } ];19 var options = [ { value: 0, label: __( '— Chọn sản phẩm —', 'vinhxd-car-colors-360' ) } ]; 20 20 ( cars || [] ).forEach( function ( p ) { 21 21 options.push( { value: p.id, label: ( p.title && p.title.rendered ) || ( '#' + p.id ) } ); 22 22 } ); 23 var inherit = { value: '', label: __( 'Theo cài đặt của xe', 'vinhxd-car-colors-360' ) };23 var inherit = { value: '', label: __( 'Theo cài đặt của sản phẩm', 'vinhxd-car-colors-360' ) }; 24 24 var yesNo = [ inherit, { value: 'yes', label: __( 'Có', 'vinhxd-car-colors-360' ) }, { value: 'no', label: __( 'Không', 'vinhxd-car-colors-360' ) } ]; 25 25 26 26 var picker = el( c.SelectControl, { 27 label: __( ' Xe', 'vinhxd-car-colors-360' ),27 label: __( 'Sản phẩm', 'vinhxd-car-colors-360' ), 28 28 value: a.carId, 29 29 options: options, … … 32 32 33 33 var inspector = el( be.InspectorControls, {}, 34 el( c.PanelBody, { title: __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' ), initialOpen: true },34 el( c.PanelBody, { title: __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ), initialOpen: true }, 35 35 picker, 36 36 el( c.SelectControl, { … … 41 41 } ), 42 42 el( c.RangeControl, { 43 label: __( 'Cỡ ô màu (px, 0 = theo xe)', 'vinhxd-car-colors-360' ),43 label: __( 'Cỡ ô màu (px, 0 = theo sản phẩm)', 'vinhxd-car-colors-360' ), 44 44 value: a.size, min: 0, max: 80, 45 45 onChange: function ( v ) { set( { size: v || 0 } ); } … … 52 52 var body = a.carId 53 53 ? el( SSR, { block: 'mau-xe-o-to/xe', attributes: a } ) 54 : el( c.Placeholder, { icon: ' car', label: __( 'Màu Xe Ô Tô', 'vinhxd-car-colors-360' ), instructions: __( 'Chọn xe đã tạo trong menu Màu Xe Ô Tô.', 'vinhxd-car-colors-360' ) }, picker );54 : el( c.Placeholder, { icon: 'image-rotate', label: __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ), instructions: __( 'Chọn sản phẩm đã tạo trong menu Sản Phẩm 360.', 'vinhxd-car-colors-360' ) }, picker ); 55 55 56 56 return el( 'div', blockProps, inspector, body ); -
vinhxd-car-colors-360/tags/1.1.0/includes/class-mxot-admin.php
r3838725 r3844587 11 11 12 12 /** 13 * Admin UI for the carpost type.13 * Admin UI for the product post type. 14 14 */ 15 15 class MXOT_Admin { … … 30 30 31 31 /** 32 * "Thêm xe" link on the Plugins screen.32 * "Thêm sản phẩm" link on the Plugins screen. 33 33 * 34 34 * @param array $links Links. … … 37 37 public static function action_links( $links ) { 38 38 $url = admin_url( 'post-new.php?post_type=' . MXOT_Post_Type::POST_TYPE ); 39 array_unshift( $links, '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Thêm xe', 'vinhxd-car-colors-360' ) . '</a>' );39 array_unshift( $links, '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Thêm sản phẩm', 'vinhxd-car-colors-360' ) . '</a>' ); 40 40 return $links; 41 41 } … … 45 45 */ 46 46 public static function meta_boxes() { 47 add_meta_box( 'mxot-colors', __( 'Các màu xe', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_colors' ), null, 'normal', 'high' );47 add_meta_box( 'mxot-colors', __( 'Các màu của sản phẩm', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_colors' ), null, 'normal', 'high' ); 48 48 add_meta_box( 'mxot-options', __( 'Hiển thị', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_options' ), null, 'side' ); 49 49 add_meta_box( 'mxot-usage', __( 'Cách chèn vào trang', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_usage' ), null, 'side', 'high' ); … … 51 51 52 52 /** 53 * Admin assets, only on the caredit screen.53 * Admin assets, only on the product edit screen. 54 54 * 55 55 * @param string $hook Current admin page. … … 90 90 * Colors meta box. 91 91 * 92 * @param WP_Post $post Car.92 * @param WP_Post $post Product. 93 93 */ 94 94 public static function box_colors( $post ) { … … 97 97 ?> 98 98 <p class="description"> 99 <?php esc_html_e( 'Mỗi màu gồm tên, mã màu (có thể 2 tông), ảnh chính và bộ ảnh xoay 360 (nên 24 đến 36 ảnh chụp đều quanh xe). Màu nào không có bộ 360 sẽ hiện ảnh chính. Kéo thả để đổi thứ tự màu.', 'vinhxd-car-colors-360' ); ?>99 <?php esc_html_e( 'Mỗi màu gồm tên, mã màu (có thể 2 tông), ảnh chính và bộ ảnh xoay 360 (nên 24 đến 36 ảnh chụp đều quanh sản phẩm). Màu nào không có bộ 360 sẽ hiện ảnh chính. Kéo thả để đổi thứ tự màu.', 'vinhxd-car-colors-360' ); ?> 100 100 </p> 101 101 <div id="mxot-colors-list" class="mxot-colors-list"> … … 151 151 <p> 152 152 <label><?php esc_html_e( 'Tên màu', 'vinhxd-car-colors-360' ); ?><br> 153 <input type="text" class="widefat mxot-f-name" data-field="name" name="<?php echo esc_attr( $base ); ?>[name]" value="<?php echo esc_attr( $color['name'] ); ?>" placeholder="<?php esc_attr_e( 'VD: Trắng Ngọc Trai', 'vinhxd-car-colors-360' ); ?>"></label>153 <input type="text" class="widefat mxot-f-name" data-field="name" name="<?php echo esc_attr( $base ); ?>[name]" value="<?php echo esc_attr( $color['name'] ); ?>" placeholder="<?php esc_attr_e( 'VD: Đỏ Ruby', 'vinhxd-car-colors-360' ); ?>"></label> 154 154 </p> 155 155 <p> … … 162 162 </p> 163 163 <p class="mxot-hex"> 164 <span><?php esc_html_e( 'Màu thứ 2 ( xe2 tông, để trống nếu 1 màu)', 'vinhxd-car-colors-360' ); ?></span><br>164 <span><?php esc_html_e( 'Màu thứ 2 (màu 2 tông, để trống nếu 1 màu)', 'vinhxd-car-colors-360' ); ?></span><br> 165 165 <input type="text" class="mxot-picker mxot-f-hex2" data-field="hex2" name="<?php echo esc_attr( $base ); ?>[hex2]" value="<?php echo esc_attr( $color['hex2'] ); ?>"> 166 166 </p> … … 209 209 * Display options meta box. 210 210 * 211 * @param WP_Post $post Car.211 * @param WP_Post $post Product. 212 212 */ 213 213 public static function box_options( $post ) { … … 275 275 * Usage meta box. 276 276 * 277 * @param WP_Post $post Car.277 * @param WP_Post $post Product. 278 278 */ 279 279 public static function box_usage( $post ) { 280 280 if ( 'auto-draft' === $post->post_status ) { 281 echo '<p>' . esc_html__( 'Lưu xetrước, shortcode sẽ hiện ở đây.', 'vinhxd-car-colors-360' ) . '</p>';282 return; 283 } 284 $code = '[ mau_xe_o_toid="' . absint( $post->ID ) . '"]';281 echo '<p>' . esc_html__( 'Lưu sản phẩm trước, shortcode sẽ hiện ở đây.', 'vinhxd-car-colors-360' ) . '</p>'; 282 return; 283 } 284 $code = '[vxd_product_360 id="' . absint( $post->ID ) . '"]'; 285 285 ?> 286 286 <p><input type="text" readonly class="widefat code mxot-code" value="<?php echo esc_attr( $code ); ?>" onfocus="this.select()"></p> 287 <p class="description"><?php esc_html_e( 'Dán shortcode vào trang, hoặc dùng block " Màu Xe Ô Tô" trong Gutenberg, hoặc widget "Màu Xe Ô Tô" trong Elementor.', 'vinhxd-car-colors-360' ); ?></p>287 <p class="description"><?php esc_html_e( 'Dán shortcode vào trang, hoặc dùng block "Sản Phẩm 360" trong Gutenberg, hoặc widget "Sản Phẩm 360" trong Elementor.', 'vinhxd-car-colors-360' ); ?></p> 288 288 <p class="description"><?php esc_html_e( 'Shortcode nhận thêm: shape="circle|rounded|square", size="40", label="yes|no", autoplay="yes|no".', 'vinhxd-car-colors-360' ); ?></p> 289 289 <?php … … 347 347 public static function column_content( $col, $post_id ) { 348 348 if ( 'mxot_shortcode' === $col ) { 349 echo '<input type="text" readonly class="code mxot-code" onfocus="this.select()" value="' . esc_attr( '[ mau_xe_o_toid="' . absint( $post_id ) . '"]' ) . '">';349 echo '<input type="text" readonly class="code mxot-code" onfocus="this.select()" value="' . esc_attr( '[vxd_product_360 id="' . absint( $post_id ) . '"]' ) . '">'; 350 350 } elseif ( 'mxot_colors' === $col ) { 351 351 foreach ( MXOT_Post_Type::get_colors( $post_id ) as $c ) { -
vinhxd-car-colors-360/tags/1.1.0/includes/class-mxot-block.php
r3838725 r3844587 11 11 12 12 /** 13 * Registers the " Màu Xe Ô Tô" block (server-side rendered).13 * Registers the "Sản Phẩm 360" block (server-side rendered). 14 14 */ 15 15 class MXOT_Block { -
vinhxd-car-colors-360/tags/1.1.0/includes/class-mxot-elementor-widget.php
r3838725 r3844587 11 11 12 12 /** 13 * " Màu Xe Ô Tô" Elementor widget.13 * "Sản Phẩm 360" Elementor widget. 14 14 */ 15 15 class MXOT_Elementor_Widget extends \Elementor\Widget_Base { … … 30 30 */ 31 31 public function get_title() { 32 return __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' );32 return __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ); 33 33 } 34 34 … … 57 57 */ 58 58 public function get_keywords() { 59 return array( ' màu xe', 'mau xe', '360', 'car', 'color', 'ô tô' );59 return array( 'sản phẩm 360', 'màu sản phẩm', 'màu xe', 'mau xe', '360', 'car', 'product', 'color', 'swatch', 'ô tô' ); 60 60 } 61 61 … … 82 82 */ 83 83 protected function register_controls() { 84 $inherit = array( '' => __( 'Theo cài đặt của xe', 'vinhxd-car-colors-360' ) );84 $inherit = array( '' => __( 'Theo cài đặt của sản phẩm', 'vinhxd-car-colors-360' ) ); 85 85 $yes_no = $inherit + array( 86 86 'yes' => __( 'Có', 'vinhxd-car-colors-360' ), … … 88 88 ); 89 89 90 $this->start_controls_section( 'mxot_section', array( 'label' => __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' ) ) );90 $this->start_controls_section( 'mxot_section', array( 'label' => __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ) ) ); 91 91 $this->add_control( 92 92 'car_id', 93 93 array( 94 'label' => __( ' Xe', 'vinhxd-car-colors-360' ),94 'label' => __( 'Sản phẩm', 'vinhxd-car-colors-360' ), 95 95 'type' => \Elementor\Controls_Manager::SELECT, 96 'options' => array( '' => __( '— Chọn xe—', 'vinhxd-car-colors-360' ) ) + MXOT_Post_Type::car_choices(),96 'options' => array( '' => __( '— Chọn sản phẩm —', 'vinhxd-car-colors-360' ) ) + MXOT_Post_Type::car_choices(), 97 97 'default' => '', 98 98 ) … … 118 118 'min' => 20, 119 119 'max' => 80, 120 'description' => __( 'Để trống để theo cài đặt của xe.', 'vinhxd-car-colors-360' ),120 'description' => __( 'Để trống để theo cài đặt của sản phẩm.', 'vinhxd-car-colors-360' ), 121 121 ) 122 122 ); -
vinhxd-car-colors-360/tags/1.1.0/includes/class-mxot-post-type.php
r3838725 r3844587 1 1 <?php 2 2 /** 3 * Carpost type and data helpers.3 * Product post type and data helpers. 4 4 * 5 5 * @package MauXeOTo … … 11 11 12 12 /** 13 * Registers the "Xe"post type and reads/sanitizes its color data.13 * Registers the product post type and reads/sanitizes its color data. 14 14 */ 15 15 class MXOT_Post_Type { … … 27 27 28 28 /** 29 * Register the post type. Not public: cars are shown through shortcode, block or widget.29 * Register the post type. Not public: products are shown through shortcode, block or widget. 30 30 */ 31 31 public static function register() { … … 34 34 array( 35 35 'labels' => array( 36 'name' => __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' ),37 'singular_name' => __( ' Xe', 'vinhxd-car-colors-360' ),38 'menu_name' => __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' ),39 'all_items' => __( 'Tất cả xe', 'vinhxd-car-colors-360' ),40 'add_new' => __( 'Thêm xe', 'vinhxd-car-colors-360' ),41 'add_new_item' => __( 'Thêm xemới', 'vinhxd-car-colors-360' ),42 'edit_item' => __( 'Sửa xe', 'vinhxd-car-colors-360' ),43 'new_item' => __( ' Xemới', 'vinhxd-car-colors-360' ),44 'search_items' => __( 'Tìm xe', 'vinhxd-car-colors-360' ),45 'not_found' => __( 'Chưa có xenào.', 'vinhxd-car-colors-360' ),36 'name' => __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ), 37 'singular_name' => __( 'Sản phẩm', 'vinhxd-car-colors-360' ), 38 'menu_name' => __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ), 39 'all_items' => __( 'Tất cả sản phẩm', 'vinhxd-car-colors-360' ), 40 'add_new' => __( 'Thêm sản phẩm', 'vinhxd-car-colors-360' ), 41 'add_new_item' => __( 'Thêm sản phẩm mới', 'vinhxd-car-colors-360' ), 42 'edit_item' => __( 'Sửa sản phẩm', 'vinhxd-car-colors-360' ), 43 'new_item' => __( 'Sản phẩm mới', 'vinhxd-car-colors-360' ), 44 'search_items' => __( 'Tìm sản phẩm', 'vinhxd-car-colors-360' ), 45 'not_found' => __( 'Chưa có sản phẩm nào.', 'vinhxd-car-colors-360' ), 46 46 'not_found_in_trash' => __( 'Thùng rác trống.', 'vinhxd-car-colors-360' ), 47 47 ), … … 50 50 'show_in_menu' => true, 51 51 'show_in_rest' => true, 52 'menu_icon' => 'dashicons- car',52 'menu_icon' => 'dashicons-image-rotate', 53 53 'menu_position' => 26, 54 54 'supports' => array( 'title' ), … … 178 178 179 179 /** 180 * Saved colors for a car.181 * 182 * @param int $post_id CarID.180 * Saved colors for a product. 181 * 182 * @param int $post_id Product ID. 183 183 * @return array 184 184 */ … … 189 189 190 190 /** 191 * Saved display options for a car.192 * 193 * @param int $post_id CarID.191 * Saved display options for a product. 192 * 193 * @param int $post_id Product ID. 194 194 * @return array 195 195 */ … … 199 199 200 200 /** 201 * Published cars as id => title, for block and widget pickers.201 * Published products as id => title, for block and widget pickers. 202 202 * 203 203 * @return array … … 216 216 ); 217 217 foreach ( $posts as $p ) { 218 /* translators: %d: carID. */219 $out[ $p->ID ] = $p->post_title ? $p->post_title : sprintf( __( ' Xe#%d', 'vinhxd-car-colors-360' ), $p->ID );218 /* translators: %d: product ID. */ 219 $out[ $p->ID ] = $p->post_title ? $p->post_title : sprintf( __( 'Sản phẩm #%d', 'vinhxd-car-colors-360' ), $p->ID ); 220 220 } 221 221 return $out; -
vinhxd-car-colors-360/tags/1.1.0/includes/class-mxot-render.php
r3838725 r3844587 11 11 12 12 /** 13 * Renders a carviewer.13 * Renders a product viewer. 14 14 */ 15 15 class MXOT_Render { … … 19 19 */ 20 20 public static function init() { 21 add_shortcode( 'vxd_product_360', array( __CLASS__, 'shortcode' ) ); 22 // Backward-compatible alias of the original shortcode name. 21 23 add_shortcode( 'mau_xe_o_to', array( __CLASS__, 'shortcode' ) ); 22 24 add_action( 'init', array( __CLASS__, 'register_assets' ), 5 ); … … 63 65 } 64 66 $post = get_post(); 65 if ( $post && ( has_shortcode( $post->post_content, ' mau_xe_o_to' ) || has_block( 'mau-xe-o-to/xe', $post ) ) ) {67 if ( $post && ( has_shortcode( $post->post_content, 'vxd_product_360' ) || has_shortcode( $post->post_content, 'mau_xe_o_to' ) || has_block( 'mau-xe-o-to/xe', $post ) ) ) { 66 68 wp_enqueue_style( 'mxot-viewer' ); 67 69 } … … 69 71 70 72 /** 71 * Shortcode handler .73 * Shortcode handler for [vxd_product_360] and its alias [mau_xe_o_to]. 72 74 * 73 * @param array $atts Attributes. 75 * @param array $atts Attributes. 76 * @param string $content Unused. 77 * @param string $tag Shortcode tag used. 74 78 * @return string 75 79 */ 76 public static function shortcode( $atts ) {80 public static function shortcode( $atts, $content = '', $tag = 'vxd_product_360' ) { 77 81 $atts = shortcode_atts( 78 82 array( … … 84 88 ), 85 89 $atts, 86 'mau_xe_o_to'90 $tag 87 91 ); 88 92 return self::render( … … 100 104 * Build viewer HTML. 101 105 * 102 * @param int $car_id Carpost ID.106 * @param int $car_id Product post ID. 103 107 * @param array $overrides Option overrides (empty values are ignored). 104 108 * @return string … … 108 112 if ( ! $car || MXOT_Post_Type::POST_TYPE !== $car->post_type || 'publish' !== $car->post_status ) { 109 113 if ( current_user_can( 'edit_posts' ) ) { 110 return '<p class="mxot-notice">' . esc_html__( ' Màu Xe Ô Tô: chưa chọn xe hoặc xechưa được đăng.', 'vinhxd-car-colors-360' ) . '</p>';114 return '<p class="mxot-notice">' . esc_html__( 'Sản Phẩm 360: chưa chọn sản phẩm hoặc sản phẩm chưa được đăng.', 'vinhxd-car-colors-360' ) . '</p>'; 111 115 } 112 116 return ''; … … 115 119 $colors = MXOT_Post_Type::get_colors( $car->ID ); 116 120 if ( ! $colors ) { 117 return current_user_can( 'edit_posts' ) ? '<p class="mxot-notice">' . esc_html__( ' Màu Xe Ô Tô: xenày chưa có màu nào.', 'vinhxd-car-colors-360' ) . '</p>' : '';121 return current_user_can( 'edit_posts' ) ? '<p class="mxot-notice">' . esc_html__( 'Sản Phẩm 360: sản phẩm này chưa có màu nào.', 'vinhxd-car-colors-360' ) . '</p>' : ''; 118 122 } 119 123 … … 188 192 <span class="mxot__note"><?php echo esc_html( $first['note'] ); ?></span> 189 193 </div> 190 <div class="mxot__swatches" role="radiogroup" aria-label="<?php esc_attr_e( 'Chọn màu xe', 'vinhxd-car-colors-360' ); ?>">194 <div class="mxot__swatches" role="radiogroup" aria-label="<?php esc_attr_e( 'Chọn màu', 'vinhxd-car-colors-360' ); ?>"> 191 195 <?php 192 196 foreach ( $colors as $i => $c ) : -
vinhxd-car-colors-360/tags/1.1.0/readme.txt
r3838725 r3844587 1 === VinhXD Car Colors 360===1 === VinhXD Product 360 & Color Switcher === 2 2 Contributors: vinhxomdoi 3 Tags: car color, color swatch, 360 view, product spin, car dealer3 Tags: 360 viewer, product viewer, color switcher, product colors, 360 spin 4 4 Requires at least: 6.2 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1. 0.27 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Car color switcher with a 360° spin viewer for every color. Shortcode, Gutenberg block and Elementor widget. No WooCommerce needed.11 Show any product in every color with a 360° spin viewer: cars, motorbikes, furniture, shoes and more. Shortcode, Gutenberg block and Elementor widget. No WooCommerce needed. 12 12 13 13 == Description == 14 14 15 ** Màu Xe Ô Tô** ("car colors" in Vietnamese) lets car dealers and sales consultants show every paint color of a car on their website. Visitors tap a color swatch and the car changes color instantly. If you upload a 360° image sequence for that color, visitors can drag (or swipe on a phone) to rotate the car, and the viewing angle is kept when they switch to another color.15 **VinhXD Product 360 & Color Switcher** lets you show every color of a product on your website. Visitors tap a color swatch and the product image changes instantly. If you upload a 360° image sequence for that color, visitors can drag (or swipe on a phone) to rotate the product, and the viewing angle is kept when they switch to another color. 16 16 17 The admin screens are in Vietnamese because the plugin is built for Vietnamese car sellers. 17 It works for any product you can photograph from all sides: **cars** (still the main use case, for dealers and sales consultants), motorbikes, bicycles, furniture, sofas, shoes, bags, watches, appliances, gadgets, phones and more. WooCommerce is not required. 18 19 The admin screens are in Vietnamese because the plugin is built for Vietnamese sellers. The menu is called "Sản Phẩm 360" (Product 360). 18 20 19 21 = Features = 20 22 21 * Create cars under the "Màu Xe Ô Tô" menu, no WooCommerce required.22 * Each color has a name (for example "Trắng Ngọc Trai" ), a swatch color, an optional second color for two-tone paint, a main image and an optional price note (for example "+8 triệu").23 * Create products under the "Sản Phẩm 360" menu, no WooCommerce required. 24 * Each color has a name (for example "Trắng Ngọc Trai" or "Pearl White"), a swatch color, an optional second color for two-tone products, a main image and an optional price note (for example "+8 triệu"). 23 25 * 360° spin per color: pick or bulk upload 24–36 frames at once from the Media Library. Frames are sorted by file name automatically, and can be re-ordered by drag and drop or reversed with one click. 24 26 * Drag or swipe to rotate, with inertia. Keyboard arrows also rotate. 25 * Optional autoplay rotation, off by default. You can turn it on in the carsettings, with autoplay="yes" on the shortcode, or in the block / Elementor widget. It is disabled automatically for visitors who prefer reduced motion, and it only starts after every 360° frame has loaded.27 * Optional autoplay rotation, off by default. You can turn it on in the product settings, with autoplay="yes" on the shortcode, or in the block / Elementor widget. It is disabled automatically for visitors who prefer reduced motion, and it only starts after every 360° frame has loaded. 26 28 * The current angle is kept when switching between 360° colors. 27 29 * Fast: only the first frame is loaded with the page. The remaining frames are loaded only when the viewer is on screen or when the visitor picks that color, with a progress bar. The first frame of a color is warmed up on hover. … … 29 31 * Fullscreen button (with a CSS fallback for iPhone) and optional zoom (buttons or double click, drag to pan). 30 32 * Swatch style: circle, rounded square or square; swatch size; show or hide color names. 31 * Three ways to insert: shortcode `[ mau_xe_o_to id="123"]`, the "Màu Xe Ô Tô" block, or the "Màu Xe Ô Tô" Elementor widget (loaded only when Elementor is active).32 * Front end is plain JavaScript (no jQuery), under 7 KB gzipped together with the CSS, and is only loaded on pages that show a car.33 * Three ways to insert: shortcode `[vxd_product_360 id="123"]`, the "Sản Phẩm 360" block, or the "Sản Phẩm 360" Elementor widget (loaded only when Elementor is active). 34 * Front end is plain JavaScript (no jQuery), under 7 KB gzipped together with the CSS, and is only loaded on pages that show a product. 33 35 * No external requests, no tracking, no ads. 34 36 35 37 = Shortcode options = 36 38 37 `[ mau_xe_o_toid="123" shape="circle" size="40" label="yes" autoplay="no"]`39 `[vxd_product_360 id="123" shape="circle" size="40" label="yes" autoplay="no"]` 38 40 39 * `id` – car ID (shown on the car edit screen and in the car list). 41 The original shortcode name `[mau_xe_o_to]` still works and takes the same options. 42 43 * `id` – product ID (shown on the product edit screen and in the product list). 40 44 * `shape` – `circle`, `rounded` or `square`. 41 45 * `size` – swatch size in pixels (20–80). … … 43 47 * `autoplay` – `yes` or `no`. Default: `no`. 44 48 45 Empty options fall back to the settings saved on the car.49 Empty options fall back to the settings saved on the product. 46 50 47 51 == Installation == … … 49 53 1. Upload the `vinhxd-car-colors-360` folder to `/wp-content/plugins/`, or install it from the Plugins screen. 50 54 2. Activate the plugin. 51 3. Go to ** Màu Xe Ô Tô → Thêm xe**, enter the carname and add colors. For each color choose a main image and, optionally, the 360° frames.52 4. Publish, then insert the carwith the shortcode, the block or the Elementor widget.55 3. Go to **Sản Phẩm 360 → Thêm sản phẩm**, enter the product name and add colors. For each color choose a main image and, optionally, the 360° frames. 56 4. Publish, then insert the product with the shortcode, the block or the Elementor widget. 53 57 54 58 == Frequently Asked Questions == 55 59 60 = What kind of products can I show? = 61 62 Anything you can photograph from all sides: cars, motorbikes, bicycles, furniture, shoes, bags, watches, appliances, gadgets and more. Cars are the main use case, but nothing in the viewer is specific to cars. 63 56 64 = How many frames should a 360° sequence have? = 57 65 58 24 to 36 frames taken at equal angles around the carwork best. Up to 72 frames per color are accepted.66 24 to 36 frames taken at equal angles around the product work best. Up to 72 frames per color are accepted. 59 67 60 68 = Where can I get 360° images? = 61 69 62 Most car makers and dealers publish 360° images of their cars. Make sure you have the right to use them. Name the files in order (01.jpg, 02.jpg …) so they are sorted automatically.70 Shoot them yourself on a turntable (or walk around a car or motorbike at equal angles), or ask the brand or supplier. Make sure you have the right to use the images. Name the files in order (01.jpg, 02.jpg …) so they are sorted automatically. 63 71 64 = The carrotates the wrong way. =72 = The product rotates the wrong way. = 65 73 66 74 Click "Đảo chiều" (reverse) under the frames, or set "Đảo chiều kéo" (reverse drag) to "Có" in the display box. … … 68 76 = Does it need WooCommerce? = 69 77 70 No. Cars are stored in their own post type. 78 No. Products are stored in their own post type, so it works on any site, with or without a shop. 79 80 = Can I still use the old [mau_xe_o_to] shortcode? = 81 82 Yes. It is kept as an alias of `[vxd_product_360]`. 71 83 72 84 = Does it work with page caching and lazy loading plugins? = … … 77 89 78 90 1. Color swatches with the 360° viewer on the front end. 79 2. Careditor: colors, two-tone swatches, main image and 360° frames.91 2. Product editor: colors, two-tone swatches, main image and 360° frames. 80 92 81 93 == Changelog == 94 95 = 1.1.0 = 96 * Renamed to "VinhXD Product 360 & Color Switcher" and widened from cars to any product: cars, motorbikes, furniture, shoes, bags, gadgets and more. The plugin slug and text domain stay `vinhxd-car-colors-360`. 97 * New generic shortcode `[vxd_product_360 id="123"]`. The old `[mau_xe_o_to]` shortcode still works as an alias. 98 * Admin menu, labels, block and Elementor widget are now product-neutral: "Sản Phẩm 360" (was "Màu Xe Ô Tô"). Saved data and the block are unchanged. 99 * Readme rewritten for all kinds of products. 82 100 83 101 = 1.0.2 = … … 93 111 == Upgrade Notice == 94 112 113 = 1.1.0 = 114 New name and menu label "Sản Phẩm 360", new shortcode [vxd_product_360]. The old [mau_xe_o_to] shortcode keeps working. 115 95 116 = 1.0.2 = 96 117 Renamed for the WordPress.org directory. Existing shortcodes, blocks and cars keep working. -
vinhxd-car-colors-360/tags/1.1.0/uninstall.php
r3838725 r3844587 1 1 <?php 2 2 /** 3 * Remove plugin data on uninstall ( carentries and their settings). Media files are kept.3 * Remove plugin data on uninstall (product entries and their settings). Media files are kept. 4 4 * 5 5 * @package MauXeOTo -
vinhxd-car-colors-360/tags/1.1.0/vinhxd-car-colors-360.php
r3838725 r3844587 1 1 <?php 2 2 /** 3 * Plugin Name: VinhXD Car Colors 3603 * Plugin Name: VinhXD Product 360 & Color Switcher 4 4 * Plugin URI: https://vinhxd.com/plugin 5 * Description: Bảng chọn màu xe ô tô kèm xoay 360 độ cho từng màu. Dùng bằng shortcode, block Gutenberg hoặc widget Elementor. Không cần WooCommerce.6 * Version: 1. 0.25 * Description: Bảng chọn màu sản phẩm kèm xoay 360 độ cho từng màu (ô tô, xe máy, nội thất, giày dép...). Dùng bằng shortcode, block Gutenberg hoặc widget Elementor. Không cần WooCommerce. 6 * Version: 1.1.0 7 7 * Requires at least: 6.2 8 8 * Requires PHP: 7.4 … … 20 20 } 21 21 22 define( 'MXOT_VERSION', '1. 0.2' );22 define( 'MXOT_VERSION', '1.1.0' ); 23 23 define( 'MXOT_FILE', __FILE__ ); 24 24 define( 'MXOT_DIR', plugin_dir_path( __FILE__ ) ); … … 48 48 49 49 /** 50 * Flush rewrite rules on activation so the carpost type works right away.50 * Flush rewrite rules on activation so the product post type works right away. 51 51 */ 52 52 function mxot_activate() { -
vinhxd-car-colors-360/trunk/assets/css/viewer.css
r3838725 r3844587 1 /* Màu Xe Ô Tô– front-end viewer */1 /* Product 360 – front-end viewer */ 2 2 .mxot{--mxot-size:36px;--mxot-accent:#d0021b;--mxot-ratio:16/9;position:relative;max-width:100%;margin:0 auto 1.5em;font-size:15px;line-height:1.4;box-sizing:border-box} 3 3 .mxot *,.mxot *::before,.mxot *::after{box-sizing:border-box} -
vinhxd-car-colors-360/trunk/assets/js/admin.js
r3838725 r3844587 1 /* Màu Xe Ô Tô – careditor (admin only). */1 /* Sản Phẩm 360 – product editor (admin only). */ 2 2 ( function ( $ ) { 3 3 'use strict'; -
vinhxd-car-colors-360/trunk/assets/js/viewer.js
r3838725 r3844587 1 /*! Màu Xe Ô Tôviewer – vanilla JS, no dependencies. */1 /*! Sản Phẩm 360 viewer – vanilla JS, no dependencies. */ 2 2 ( function () { 3 3 'use strict'; -
vinhxd-car-colors-360/trunk/blocks/xe/block.json
r3838725 r3844587 3 3 "apiVersion": 3, 4 4 "name": "mau-xe-o-to/xe", 5 "title": " Màu Xe Ô Tô",5 "title": "Sản Phẩm 360", 6 6 "category": "media", 7 "icon": " car",8 "description": "Bảng chọn màu xe kèm xoay 360 độ.",9 "keywords": [ "màu xe", "360", "ô tô", "car", "color" ],7 "icon": "image-rotate", 8 "description": "Bảng chọn màu sản phẩm kèm xoay 360 độ (ô tô, xe máy, nội thất, giày dép...).", 9 "keywords": [ "màu sản phẩm", "màu xe", "360", "ô tô", "car", "color", "product", "swatch" ], 10 10 "textdomain": "vinhxd-car-colors-360", 11 11 "attributes": { -
vinhxd-car-colors-360/trunk/blocks/xe/index.asset.php
r3838725 r3844587 12 12 return array( 13 13 'dependencies' => array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-block-editor', 'wp-server-side-render', 'wp-data', 'wp-core-data', 'wp-i18n' ), 14 'version' => '1. 0.2',14 'version' => '1.1.0', 15 15 ); -
vinhxd-car-colors-360/trunk/blocks/xe/index.js
r3838725 r3844587 17 17 }, [] ); 18 18 19 var options = [ { value: 0, label: __( '— Chọn xe—', 'vinhxd-car-colors-360' ) } ];19 var options = [ { value: 0, label: __( '— Chọn sản phẩm —', 'vinhxd-car-colors-360' ) } ]; 20 20 ( cars || [] ).forEach( function ( p ) { 21 21 options.push( { value: p.id, label: ( p.title && p.title.rendered ) || ( '#' + p.id ) } ); 22 22 } ); 23 var inherit = { value: '', label: __( 'Theo cài đặt của xe', 'vinhxd-car-colors-360' ) };23 var inherit = { value: '', label: __( 'Theo cài đặt của sản phẩm', 'vinhxd-car-colors-360' ) }; 24 24 var yesNo = [ inherit, { value: 'yes', label: __( 'Có', 'vinhxd-car-colors-360' ) }, { value: 'no', label: __( 'Không', 'vinhxd-car-colors-360' ) } ]; 25 25 26 26 var picker = el( c.SelectControl, { 27 label: __( ' Xe', 'vinhxd-car-colors-360' ),27 label: __( 'Sản phẩm', 'vinhxd-car-colors-360' ), 28 28 value: a.carId, 29 29 options: options, … … 32 32 33 33 var inspector = el( be.InspectorControls, {}, 34 el( c.PanelBody, { title: __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' ), initialOpen: true },34 el( c.PanelBody, { title: __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ), initialOpen: true }, 35 35 picker, 36 36 el( c.SelectControl, { … … 41 41 } ), 42 42 el( c.RangeControl, { 43 label: __( 'Cỡ ô màu (px, 0 = theo xe)', 'vinhxd-car-colors-360' ),43 label: __( 'Cỡ ô màu (px, 0 = theo sản phẩm)', 'vinhxd-car-colors-360' ), 44 44 value: a.size, min: 0, max: 80, 45 45 onChange: function ( v ) { set( { size: v || 0 } ); } … … 52 52 var body = a.carId 53 53 ? el( SSR, { block: 'mau-xe-o-to/xe', attributes: a } ) 54 : el( c.Placeholder, { icon: ' car', label: __( 'Màu Xe Ô Tô', 'vinhxd-car-colors-360' ), instructions: __( 'Chọn xe đã tạo trong menu Màu Xe Ô Tô.', 'vinhxd-car-colors-360' ) }, picker );54 : el( c.Placeholder, { icon: 'image-rotate', label: __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ), instructions: __( 'Chọn sản phẩm đã tạo trong menu Sản Phẩm 360.', 'vinhxd-car-colors-360' ) }, picker ); 55 55 56 56 return el( 'div', blockProps, inspector, body ); -
vinhxd-car-colors-360/trunk/includes/class-mxot-admin.php
r3838725 r3844587 11 11 12 12 /** 13 * Admin UI for the carpost type.13 * Admin UI for the product post type. 14 14 */ 15 15 class MXOT_Admin { … … 30 30 31 31 /** 32 * "Thêm xe" link on the Plugins screen.32 * "Thêm sản phẩm" link on the Plugins screen. 33 33 * 34 34 * @param array $links Links. … … 37 37 public static function action_links( $links ) { 38 38 $url = admin_url( 'post-new.php?post_type=' . MXOT_Post_Type::POST_TYPE ); 39 array_unshift( $links, '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Thêm xe', 'vinhxd-car-colors-360' ) . '</a>' );39 array_unshift( $links, '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Thêm sản phẩm', 'vinhxd-car-colors-360' ) . '</a>' ); 40 40 return $links; 41 41 } … … 45 45 */ 46 46 public static function meta_boxes() { 47 add_meta_box( 'mxot-colors', __( 'Các màu xe', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_colors' ), null, 'normal', 'high' );47 add_meta_box( 'mxot-colors', __( 'Các màu của sản phẩm', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_colors' ), null, 'normal', 'high' ); 48 48 add_meta_box( 'mxot-options', __( 'Hiển thị', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_options' ), null, 'side' ); 49 49 add_meta_box( 'mxot-usage', __( 'Cách chèn vào trang', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_usage' ), null, 'side', 'high' ); … … 51 51 52 52 /** 53 * Admin assets, only on the caredit screen.53 * Admin assets, only on the product edit screen. 54 54 * 55 55 * @param string $hook Current admin page. … … 90 90 * Colors meta box. 91 91 * 92 * @param WP_Post $post Car.92 * @param WP_Post $post Product. 93 93 */ 94 94 public static function box_colors( $post ) { … … 97 97 ?> 98 98 <p class="description"> 99 <?php esc_html_e( 'Mỗi màu gồm tên, mã màu (có thể 2 tông), ảnh chính và bộ ảnh xoay 360 (nên 24 đến 36 ảnh chụp đều quanh xe). Màu nào không có bộ 360 sẽ hiện ảnh chính. Kéo thả để đổi thứ tự màu.', 'vinhxd-car-colors-360' ); ?>99 <?php esc_html_e( 'Mỗi màu gồm tên, mã màu (có thể 2 tông), ảnh chính và bộ ảnh xoay 360 (nên 24 đến 36 ảnh chụp đều quanh sản phẩm). Màu nào không có bộ 360 sẽ hiện ảnh chính. Kéo thả để đổi thứ tự màu.', 'vinhxd-car-colors-360' ); ?> 100 100 </p> 101 101 <div id="mxot-colors-list" class="mxot-colors-list"> … … 151 151 <p> 152 152 <label><?php esc_html_e( 'Tên màu', 'vinhxd-car-colors-360' ); ?><br> 153 <input type="text" class="widefat mxot-f-name" data-field="name" name="<?php echo esc_attr( $base ); ?>[name]" value="<?php echo esc_attr( $color['name'] ); ?>" placeholder="<?php esc_attr_e( 'VD: Trắng Ngọc Trai', 'vinhxd-car-colors-360' ); ?>"></label>153 <input type="text" class="widefat mxot-f-name" data-field="name" name="<?php echo esc_attr( $base ); ?>[name]" value="<?php echo esc_attr( $color['name'] ); ?>" placeholder="<?php esc_attr_e( 'VD: Đỏ Ruby', 'vinhxd-car-colors-360' ); ?>"></label> 154 154 </p> 155 155 <p> … … 162 162 </p> 163 163 <p class="mxot-hex"> 164 <span><?php esc_html_e( 'Màu thứ 2 ( xe2 tông, để trống nếu 1 màu)', 'vinhxd-car-colors-360' ); ?></span><br>164 <span><?php esc_html_e( 'Màu thứ 2 (màu 2 tông, để trống nếu 1 màu)', 'vinhxd-car-colors-360' ); ?></span><br> 165 165 <input type="text" class="mxot-picker mxot-f-hex2" data-field="hex2" name="<?php echo esc_attr( $base ); ?>[hex2]" value="<?php echo esc_attr( $color['hex2'] ); ?>"> 166 166 </p> … … 209 209 * Display options meta box. 210 210 * 211 * @param WP_Post $post Car.211 * @param WP_Post $post Product. 212 212 */ 213 213 public static function box_options( $post ) { … … 275 275 * Usage meta box. 276 276 * 277 * @param WP_Post $post Car.277 * @param WP_Post $post Product. 278 278 */ 279 279 public static function box_usage( $post ) { 280 280 if ( 'auto-draft' === $post->post_status ) { 281 echo '<p>' . esc_html__( 'Lưu xetrước, shortcode sẽ hiện ở đây.', 'vinhxd-car-colors-360' ) . '</p>';282 return; 283 } 284 $code = '[ mau_xe_o_toid="' . absint( $post->ID ) . '"]';281 echo '<p>' . esc_html__( 'Lưu sản phẩm trước, shortcode sẽ hiện ở đây.', 'vinhxd-car-colors-360' ) . '</p>'; 282 return; 283 } 284 $code = '[vxd_product_360 id="' . absint( $post->ID ) . '"]'; 285 285 ?> 286 286 <p><input type="text" readonly class="widefat code mxot-code" value="<?php echo esc_attr( $code ); ?>" onfocus="this.select()"></p> 287 <p class="description"><?php esc_html_e( 'Dán shortcode vào trang, hoặc dùng block " Màu Xe Ô Tô" trong Gutenberg, hoặc widget "Màu Xe Ô Tô" trong Elementor.', 'vinhxd-car-colors-360' ); ?></p>287 <p class="description"><?php esc_html_e( 'Dán shortcode vào trang, hoặc dùng block "Sản Phẩm 360" trong Gutenberg, hoặc widget "Sản Phẩm 360" trong Elementor.', 'vinhxd-car-colors-360' ); ?></p> 288 288 <p class="description"><?php esc_html_e( 'Shortcode nhận thêm: shape="circle|rounded|square", size="40", label="yes|no", autoplay="yes|no".', 'vinhxd-car-colors-360' ); ?></p> 289 289 <?php … … 347 347 public static function column_content( $col, $post_id ) { 348 348 if ( 'mxot_shortcode' === $col ) { 349 echo '<input type="text" readonly class="code mxot-code" onfocus="this.select()" value="' . esc_attr( '[ mau_xe_o_toid="' . absint( $post_id ) . '"]' ) . '">';349 echo '<input type="text" readonly class="code mxot-code" onfocus="this.select()" value="' . esc_attr( '[vxd_product_360 id="' . absint( $post_id ) . '"]' ) . '">'; 350 350 } elseif ( 'mxot_colors' === $col ) { 351 351 foreach ( MXOT_Post_Type::get_colors( $post_id ) as $c ) { -
vinhxd-car-colors-360/trunk/includes/class-mxot-block.php
r3838725 r3844587 11 11 12 12 /** 13 * Registers the " Màu Xe Ô Tô" block (server-side rendered).13 * Registers the "Sản Phẩm 360" block (server-side rendered). 14 14 */ 15 15 class MXOT_Block { -
vinhxd-car-colors-360/trunk/includes/class-mxot-elementor-widget.php
r3838725 r3844587 11 11 12 12 /** 13 * " Màu Xe Ô Tô" Elementor widget.13 * "Sản Phẩm 360" Elementor widget. 14 14 */ 15 15 class MXOT_Elementor_Widget extends \Elementor\Widget_Base { … … 30 30 */ 31 31 public function get_title() { 32 return __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' );32 return __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ); 33 33 } 34 34 … … 57 57 */ 58 58 public function get_keywords() { 59 return array( ' màu xe', 'mau xe', '360', 'car', 'color', 'ô tô' );59 return array( 'sản phẩm 360', 'màu sản phẩm', 'màu xe', 'mau xe', '360', 'car', 'product', 'color', 'swatch', 'ô tô' ); 60 60 } 61 61 … … 82 82 */ 83 83 protected function register_controls() { 84 $inherit = array( '' => __( 'Theo cài đặt của xe', 'vinhxd-car-colors-360' ) );84 $inherit = array( '' => __( 'Theo cài đặt của sản phẩm', 'vinhxd-car-colors-360' ) ); 85 85 $yes_no = $inherit + array( 86 86 'yes' => __( 'Có', 'vinhxd-car-colors-360' ), … … 88 88 ); 89 89 90 $this->start_controls_section( 'mxot_section', array( 'label' => __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' ) ) );90 $this->start_controls_section( 'mxot_section', array( 'label' => __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ) ) ); 91 91 $this->add_control( 92 92 'car_id', 93 93 array( 94 'label' => __( ' Xe', 'vinhxd-car-colors-360' ),94 'label' => __( 'Sản phẩm', 'vinhxd-car-colors-360' ), 95 95 'type' => \Elementor\Controls_Manager::SELECT, 96 'options' => array( '' => __( '— Chọn xe—', 'vinhxd-car-colors-360' ) ) + MXOT_Post_Type::car_choices(),96 'options' => array( '' => __( '— Chọn sản phẩm —', 'vinhxd-car-colors-360' ) ) + MXOT_Post_Type::car_choices(), 97 97 'default' => '', 98 98 ) … … 118 118 'min' => 20, 119 119 'max' => 80, 120 'description' => __( 'Để trống để theo cài đặt của xe.', 'vinhxd-car-colors-360' ),120 'description' => __( 'Để trống để theo cài đặt của sản phẩm.', 'vinhxd-car-colors-360' ), 121 121 ) 122 122 ); -
vinhxd-car-colors-360/trunk/includes/class-mxot-post-type.php
r3838725 r3844587 1 1 <?php 2 2 /** 3 * Carpost type and data helpers.3 * Product post type and data helpers. 4 4 * 5 5 * @package MauXeOTo … … 11 11 12 12 /** 13 * Registers the "Xe"post type and reads/sanitizes its color data.13 * Registers the product post type and reads/sanitizes its color data. 14 14 */ 15 15 class MXOT_Post_Type { … … 27 27 28 28 /** 29 * Register the post type. Not public: cars are shown through shortcode, block or widget.29 * Register the post type. Not public: products are shown through shortcode, block or widget. 30 30 */ 31 31 public static function register() { … … 34 34 array( 35 35 'labels' => array( 36 'name' => __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' ),37 'singular_name' => __( ' Xe', 'vinhxd-car-colors-360' ),38 'menu_name' => __( ' Màu Xe Ô Tô', 'vinhxd-car-colors-360' ),39 'all_items' => __( 'Tất cả xe', 'vinhxd-car-colors-360' ),40 'add_new' => __( 'Thêm xe', 'vinhxd-car-colors-360' ),41 'add_new_item' => __( 'Thêm xemới', 'vinhxd-car-colors-360' ),42 'edit_item' => __( 'Sửa xe', 'vinhxd-car-colors-360' ),43 'new_item' => __( ' Xemới', 'vinhxd-car-colors-360' ),44 'search_items' => __( 'Tìm xe', 'vinhxd-car-colors-360' ),45 'not_found' => __( 'Chưa có xenào.', 'vinhxd-car-colors-360' ),36 'name' => __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ), 37 'singular_name' => __( 'Sản phẩm', 'vinhxd-car-colors-360' ), 38 'menu_name' => __( 'Sản Phẩm 360', 'vinhxd-car-colors-360' ), 39 'all_items' => __( 'Tất cả sản phẩm', 'vinhxd-car-colors-360' ), 40 'add_new' => __( 'Thêm sản phẩm', 'vinhxd-car-colors-360' ), 41 'add_new_item' => __( 'Thêm sản phẩm mới', 'vinhxd-car-colors-360' ), 42 'edit_item' => __( 'Sửa sản phẩm', 'vinhxd-car-colors-360' ), 43 'new_item' => __( 'Sản phẩm mới', 'vinhxd-car-colors-360' ), 44 'search_items' => __( 'Tìm sản phẩm', 'vinhxd-car-colors-360' ), 45 'not_found' => __( 'Chưa có sản phẩm nào.', 'vinhxd-car-colors-360' ), 46 46 'not_found_in_trash' => __( 'Thùng rác trống.', 'vinhxd-car-colors-360' ), 47 47 ), … … 50 50 'show_in_menu' => true, 51 51 'show_in_rest' => true, 52 'menu_icon' => 'dashicons- car',52 'menu_icon' => 'dashicons-image-rotate', 53 53 'menu_position' => 26, 54 54 'supports' => array( 'title' ), … … 178 178 179 179 /** 180 * Saved colors for a car.181 * 182 * @param int $post_id CarID.180 * Saved colors for a product. 181 * 182 * @param int $post_id Product ID. 183 183 * @return array 184 184 */ … … 189 189 190 190 /** 191 * Saved display options for a car.192 * 193 * @param int $post_id CarID.191 * Saved display options for a product. 192 * 193 * @param int $post_id Product ID. 194 194 * @return array 195 195 */ … … 199 199 200 200 /** 201 * Published cars as id => title, for block and widget pickers.201 * Published products as id => title, for block and widget pickers. 202 202 * 203 203 * @return array … … 216 216 ); 217 217 foreach ( $posts as $p ) { 218 /* translators: %d: carID. */219 $out[ $p->ID ] = $p->post_title ? $p->post_title : sprintf( __( ' Xe#%d', 'vinhxd-car-colors-360' ), $p->ID );218 /* translators: %d: product ID. */ 219 $out[ $p->ID ] = $p->post_title ? $p->post_title : sprintf( __( 'Sản phẩm #%d', 'vinhxd-car-colors-360' ), $p->ID ); 220 220 } 221 221 return $out; -
vinhxd-car-colors-360/trunk/includes/class-mxot-render.php
r3838725 r3844587 11 11 12 12 /** 13 * Renders a carviewer.13 * Renders a product viewer. 14 14 */ 15 15 class MXOT_Render { … … 19 19 */ 20 20 public static function init() { 21 add_shortcode( 'vxd_product_360', array( __CLASS__, 'shortcode' ) ); 22 // Backward-compatible alias of the original shortcode name. 21 23 add_shortcode( 'mau_xe_o_to', array( __CLASS__, 'shortcode' ) ); 22 24 add_action( 'init', array( __CLASS__, 'register_assets' ), 5 ); … … 63 65 } 64 66 $post = get_post(); 65 if ( $post && ( has_shortcode( $post->post_content, ' mau_xe_o_to' ) || has_block( 'mau-xe-o-to/xe', $post ) ) ) {67 if ( $post && ( has_shortcode( $post->post_content, 'vxd_product_360' ) || has_shortcode( $post->post_content, 'mau_xe_o_to' ) || has_block( 'mau-xe-o-to/xe', $post ) ) ) { 66 68 wp_enqueue_style( 'mxot-viewer' ); 67 69 } … … 69 71 70 72 /** 71 * Shortcode handler .73 * Shortcode handler for [vxd_product_360] and its alias [mau_xe_o_to]. 72 74 * 73 * @param array $atts Attributes. 75 * @param array $atts Attributes. 76 * @param string $content Unused. 77 * @param string $tag Shortcode tag used. 74 78 * @return string 75 79 */ 76 public static function shortcode( $atts ) {80 public static function shortcode( $atts, $content = '', $tag = 'vxd_product_360' ) { 77 81 $atts = shortcode_atts( 78 82 array( … … 84 88 ), 85 89 $atts, 86 'mau_xe_o_to'90 $tag 87 91 ); 88 92 return self::render( … … 100 104 * Build viewer HTML. 101 105 * 102 * @param int $car_id Carpost ID.106 * @param int $car_id Product post ID. 103 107 * @param array $overrides Option overrides (empty values are ignored). 104 108 * @return string … … 108 112 if ( ! $car || MXOT_Post_Type::POST_TYPE !== $car->post_type || 'publish' !== $car->post_status ) { 109 113 if ( current_user_can( 'edit_posts' ) ) { 110 return '<p class="mxot-notice">' . esc_html__( ' Màu Xe Ô Tô: chưa chọn xe hoặc xechưa được đăng.', 'vinhxd-car-colors-360' ) . '</p>';114 return '<p class="mxot-notice">' . esc_html__( 'Sản Phẩm 360: chưa chọn sản phẩm hoặc sản phẩm chưa được đăng.', 'vinhxd-car-colors-360' ) . '</p>'; 111 115 } 112 116 return ''; … … 115 119 $colors = MXOT_Post_Type::get_colors( $car->ID ); 116 120 if ( ! $colors ) { 117 return current_user_can( 'edit_posts' ) ? '<p class="mxot-notice">' . esc_html__( ' Màu Xe Ô Tô: xenày chưa có màu nào.', 'vinhxd-car-colors-360' ) . '</p>' : '';121 return current_user_can( 'edit_posts' ) ? '<p class="mxot-notice">' . esc_html__( 'Sản Phẩm 360: sản phẩm này chưa có màu nào.', 'vinhxd-car-colors-360' ) . '</p>' : ''; 118 122 } 119 123 … … 188 192 <span class="mxot__note"><?php echo esc_html( $first['note'] ); ?></span> 189 193 </div> 190 <div class="mxot__swatches" role="radiogroup" aria-label="<?php esc_attr_e( 'Chọn màu xe', 'vinhxd-car-colors-360' ); ?>">194 <div class="mxot__swatches" role="radiogroup" aria-label="<?php esc_attr_e( 'Chọn màu', 'vinhxd-car-colors-360' ); ?>"> 191 195 <?php 192 196 foreach ( $colors as $i => $c ) : -
vinhxd-car-colors-360/trunk/readme.txt
r3838725 r3844587 1 === VinhXD Car Colors 360===1 === VinhXD Product 360 & Color Switcher === 2 2 Contributors: vinhxomdoi 3 Tags: car color, color swatch, 360 view, product spin, car dealer3 Tags: 360 viewer, product viewer, color switcher, product colors, 360 spin 4 4 Requires at least: 6.2 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1. 0.27 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Car color switcher with a 360° spin viewer for every color. Shortcode, Gutenberg block and Elementor widget. No WooCommerce needed.11 Show any product in every color with a 360° spin viewer: cars, motorbikes, furniture, shoes and more. Shortcode, Gutenberg block and Elementor widget. No WooCommerce needed. 12 12 13 13 == Description == 14 14 15 ** Màu Xe Ô Tô** ("car colors" in Vietnamese) lets car dealers and sales consultants show every paint color of a car on their website. Visitors tap a color swatch and the car changes color instantly. If you upload a 360° image sequence for that color, visitors can drag (or swipe on a phone) to rotate the car, and the viewing angle is kept when they switch to another color.15 **VinhXD Product 360 & Color Switcher** lets you show every color of a product on your website. Visitors tap a color swatch and the product image changes instantly. If you upload a 360° image sequence for that color, visitors can drag (or swipe on a phone) to rotate the product, and the viewing angle is kept when they switch to another color. 16 16 17 The admin screens are in Vietnamese because the plugin is built for Vietnamese car sellers. 17 It works for any product you can photograph from all sides: **cars** (still the main use case, for dealers and sales consultants), motorbikes, bicycles, furniture, sofas, shoes, bags, watches, appliances, gadgets, phones and more. WooCommerce is not required. 18 19 The admin screens are in Vietnamese because the plugin is built for Vietnamese sellers. The menu is called "Sản Phẩm 360" (Product 360). 18 20 19 21 = Features = 20 22 21 * Create cars under the "Màu Xe Ô Tô" menu, no WooCommerce required.22 * Each color has a name (for example "Trắng Ngọc Trai" ), a swatch color, an optional second color for two-tone paint, a main image and an optional price note (for example "+8 triệu").23 * Create products under the "Sản Phẩm 360" menu, no WooCommerce required. 24 * Each color has a name (for example "Trắng Ngọc Trai" or "Pearl White"), a swatch color, an optional second color for two-tone products, a main image and an optional price note (for example "+8 triệu"). 23 25 * 360° spin per color: pick or bulk upload 24–36 frames at once from the Media Library. Frames are sorted by file name automatically, and can be re-ordered by drag and drop or reversed with one click. 24 26 * Drag or swipe to rotate, with inertia. Keyboard arrows also rotate. 25 * Optional autoplay rotation, off by default. You can turn it on in the carsettings, with autoplay="yes" on the shortcode, or in the block / Elementor widget. It is disabled automatically for visitors who prefer reduced motion, and it only starts after every 360° frame has loaded.27 * Optional autoplay rotation, off by default. You can turn it on in the product settings, with autoplay="yes" on the shortcode, or in the block / Elementor widget. It is disabled automatically for visitors who prefer reduced motion, and it only starts after every 360° frame has loaded. 26 28 * The current angle is kept when switching between 360° colors. 27 29 * Fast: only the first frame is loaded with the page. The remaining frames are loaded only when the viewer is on screen or when the visitor picks that color, with a progress bar. The first frame of a color is warmed up on hover. … … 29 31 * Fullscreen button (with a CSS fallback for iPhone) and optional zoom (buttons or double click, drag to pan). 30 32 * Swatch style: circle, rounded square or square; swatch size; show or hide color names. 31 * Three ways to insert: shortcode `[ mau_xe_o_to id="123"]`, the "Màu Xe Ô Tô" block, or the "Màu Xe Ô Tô" Elementor widget (loaded only when Elementor is active).32 * Front end is plain JavaScript (no jQuery), under 7 KB gzipped together with the CSS, and is only loaded on pages that show a car.33 * Three ways to insert: shortcode `[vxd_product_360 id="123"]`, the "Sản Phẩm 360" block, or the "Sản Phẩm 360" Elementor widget (loaded only when Elementor is active). 34 * Front end is plain JavaScript (no jQuery), under 7 KB gzipped together with the CSS, and is only loaded on pages that show a product. 33 35 * No external requests, no tracking, no ads. 34 36 35 37 = Shortcode options = 36 38 37 `[ mau_xe_o_toid="123" shape="circle" size="40" label="yes" autoplay="no"]`39 `[vxd_product_360 id="123" shape="circle" size="40" label="yes" autoplay="no"]` 38 40 39 * `id` – car ID (shown on the car edit screen and in the car list). 41 The original shortcode name `[mau_xe_o_to]` still works and takes the same options. 42 43 * `id` – product ID (shown on the product edit screen and in the product list). 40 44 * `shape` – `circle`, `rounded` or `square`. 41 45 * `size` – swatch size in pixels (20–80). … … 43 47 * `autoplay` – `yes` or `no`. Default: `no`. 44 48 45 Empty options fall back to the settings saved on the car.49 Empty options fall back to the settings saved on the product. 46 50 47 51 == Installation == … … 49 53 1. Upload the `vinhxd-car-colors-360` folder to `/wp-content/plugins/`, or install it from the Plugins screen. 50 54 2. Activate the plugin. 51 3. Go to ** Màu Xe Ô Tô → Thêm xe**, enter the carname and add colors. For each color choose a main image and, optionally, the 360° frames.52 4. Publish, then insert the carwith the shortcode, the block or the Elementor widget.55 3. Go to **Sản Phẩm 360 → Thêm sản phẩm**, enter the product name and add colors. For each color choose a main image and, optionally, the 360° frames. 56 4. Publish, then insert the product with the shortcode, the block or the Elementor widget. 53 57 54 58 == Frequently Asked Questions == 55 59 60 = What kind of products can I show? = 61 62 Anything you can photograph from all sides: cars, motorbikes, bicycles, furniture, shoes, bags, watches, appliances, gadgets and more. Cars are the main use case, but nothing in the viewer is specific to cars. 63 56 64 = How many frames should a 360° sequence have? = 57 65 58 24 to 36 frames taken at equal angles around the carwork best. Up to 72 frames per color are accepted.66 24 to 36 frames taken at equal angles around the product work best. Up to 72 frames per color are accepted. 59 67 60 68 = Where can I get 360° images? = 61 69 62 Most car makers and dealers publish 360° images of their cars. Make sure you have the right to use them. Name the files in order (01.jpg, 02.jpg …) so they are sorted automatically.70 Shoot them yourself on a turntable (or walk around a car or motorbike at equal angles), or ask the brand or supplier. Make sure you have the right to use the images. Name the files in order (01.jpg, 02.jpg …) so they are sorted automatically. 63 71 64 = The carrotates the wrong way. =72 = The product rotates the wrong way. = 65 73 66 74 Click "Đảo chiều" (reverse) under the frames, or set "Đảo chiều kéo" (reverse drag) to "Có" in the display box. … … 68 76 = Does it need WooCommerce? = 69 77 70 No. Cars are stored in their own post type. 78 No. Products are stored in their own post type, so it works on any site, with or without a shop. 79 80 = Can I still use the old [mau_xe_o_to] shortcode? = 81 82 Yes. It is kept as an alias of `[vxd_product_360]`. 71 83 72 84 = Does it work with page caching and lazy loading plugins? = … … 77 89 78 90 1. Color swatches with the 360° viewer on the front end. 79 2. Careditor: colors, two-tone swatches, main image and 360° frames.91 2. Product editor: colors, two-tone swatches, main image and 360° frames. 80 92 81 93 == Changelog == 94 95 = 1.1.0 = 96 * Renamed to "VinhXD Product 360 & Color Switcher" and widened from cars to any product: cars, motorbikes, furniture, shoes, bags, gadgets and more. The plugin slug and text domain stay `vinhxd-car-colors-360`. 97 * New generic shortcode `[vxd_product_360 id="123"]`. The old `[mau_xe_o_to]` shortcode still works as an alias. 98 * Admin menu, labels, block and Elementor widget are now product-neutral: "Sản Phẩm 360" (was "Màu Xe Ô Tô"). Saved data and the block are unchanged. 99 * Readme rewritten for all kinds of products. 82 100 83 101 = 1.0.2 = … … 93 111 == Upgrade Notice == 94 112 113 = 1.1.0 = 114 New name and menu label "Sản Phẩm 360", new shortcode [vxd_product_360]. The old [mau_xe_o_to] shortcode keeps working. 115 95 116 = 1.0.2 = 96 117 Renamed for the WordPress.org directory. Existing shortcodes, blocks and cars keep working. -
vinhxd-car-colors-360/trunk/uninstall.php
r3838725 r3844587 1 1 <?php 2 2 /** 3 * Remove plugin data on uninstall ( carentries and their settings). Media files are kept.3 * Remove plugin data on uninstall (product entries and their settings). Media files are kept. 4 4 * 5 5 * @package MauXeOTo -
vinhxd-car-colors-360/trunk/vinhxd-car-colors-360.php
r3838725 r3844587 1 1 <?php 2 2 /** 3 * Plugin Name: VinhXD Car Colors 3603 * Plugin Name: VinhXD Product 360 & Color Switcher 4 4 * Plugin URI: https://vinhxd.com/plugin 5 * Description: Bảng chọn màu xe ô tô kèm xoay 360 độ cho từng màu. Dùng bằng shortcode, block Gutenberg hoặc widget Elementor. Không cần WooCommerce.6 * Version: 1. 0.25 * Description: Bảng chọn màu sản phẩm kèm xoay 360 độ cho từng màu (ô tô, xe máy, nội thất, giày dép...). Dùng bằng shortcode, block Gutenberg hoặc widget Elementor. Không cần WooCommerce. 6 * Version: 1.1.0 7 7 * Requires at least: 6.2 8 8 * Requires PHP: 7.4 … … 20 20 } 21 21 22 define( 'MXOT_VERSION', '1. 0.2' );22 define( 'MXOT_VERSION', '1.1.0' ); 23 23 define( 'MXOT_FILE', __FILE__ ); 24 24 define( 'MXOT_DIR', plugin_dir_path( __FILE__ ) ); … … 48 48 49 49 /** 50 * Flush rewrite rules on activation so the carpost type works right away.50 * Flush rewrite rules on activation so the product post type works right away. 51 51 */ 52 52 function mxot_activate() {
Note:
See TracChangeset
for help on using the changeset viewer.