Plugin Directory

Changeset 3844587


Ignore:
Timestamp:
12/04/2026 02:06:54 PM (31 hours ago)
Author:
vinhxomdoi
Message:

Release 1.1.0: rename to VinhXD Product 360 & Color Switcher, add plugin icon

Location:
vinhxd-car-colors-360
Files:
2 added
28 edited
1 copied

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 */
    22.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}
    33.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ô – car editor (admin only). */
     1/* Sản Phẩm 360 – product editor (admin only). */
    22( function ( $ ) {
    33        '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. */
    22( function () {
    33        'use strict';
  • vinhxd-car-colors-360/tags/1.1.0/blocks/xe/block.json

    r3838725 r3844587  
    33        "apiVersion": 3,
    44        "name": "mau-xe-o-to/xe",
    5         "title": "Màu Xe Ô Tô",
     5        "title": "Sản Phẩm 360",
    66        "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" ],
    1010        "textdomain": "vinhxd-car-colors-360",
    1111        "attributes": {
  • vinhxd-car-colors-360/tags/1.1.0/blocks/xe/index.asset.php

    r3838725 r3844587  
    1212return array(
    1313        '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',
    1515);
  • vinhxd-car-colors-360/tags/1.1.0/blocks/xe/index.js

    r3838725 r3844587  
    1717                        }, [] );
    1818
    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' ) } ];
    2020                        ( cars || [] ).forEach( function ( p ) {
    2121                                options.push( { value: p.id, label: ( p.title && p.title.rendered ) || ( '#' + p.id ) } );
    2222                        } );
    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' ) };
    2424                        var yesNo = [ inherit, { value: 'yes', label: __( 'Có', 'vinhxd-car-colors-360' ) }, { value: 'no', label: __( 'Không', 'vinhxd-car-colors-360' ) } ];
    2525
    2626                        var picker = el( c.SelectControl, {
    27                                 label: __( 'Xe', 'vinhxd-car-colors-360' ),
     27                                label: __( 'Sản phẩm', 'vinhxd-car-colors-360' ),
    2828                                value: a.carId,
    2929                                options: options,
    … …  
    3232
    3333                        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 },
    3535                                        picker,
    3636                                        el( c.SelectControl, {
    … …  
    4141                                        } ),
    4242                                        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' ),
    4444                                                value: a.size, min: 0, max: 80,
    4545                                                onChange: function ( v ) { set( { size: v || 0 } ); }
    … …  
    5252                        var body = a.carId
    5353                                ? 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 );
    5555
    5656                        return el( 'div', blockProps, inspector, body );
  • vinhxd-car-colors-360/tags/1.1.0/includes/class-mxot-admin.php

    r3838725 r3844587  
    1111
    1212/**
    13  * Admin UI for the car post type.
     13 * Admin UI for the product post type.
    1414 */
    1515class MXOT_Admin {
    … …  
    3030
    3131        /**
    32          * "Thêm xe" link on the Plugins screen.
     32         * "Thêm sản phẩm" link on the Plugins screen.
    3333         *
    3434         * @param array $links Links.
    … …  
    3737        public static function action_links( $links ) {
    3838                $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>' );
    4040                return $links;
    4141        }
    … …  
    4545         */
    4646        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' );
    4848                add_meta_box( 'mxot-options', __( 'Hiển thị', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_options' ), null, 'side' );
    4949                add_meta_box( 'mxot-usage', __( 'Cách chèn vào trang', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_usage' ), null, 'side', 'high' );
    … …  
    5151
    5252        /**
    53          * Admin assets, only on the car edit screen.
     53         * Admin assets, only on the product edit screen.
    5454         *
    5555         * @param string $hook Current admin page.
    … …  
    9090         * Colors meta box.
    9191         *
    92          * @param WP_Post $post Car.
     92         * @param WP_Post $post Product.
    9393         */
    9494        public static function box_colors( $post ) {
    … …  
    9797                ?>
    9898                <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' ); ?>
    100100                </p>
    101101                <div id="mxot-colors-list" class="mxot-colors-list">
    … …  
    151151                                        <p>
    152152                                                <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>
    154154                                        </p>
    155155                                        <p>
    … …  
    162162                                        </p>
    163163                                        <p class="mxot-hex">
    164                                                 <span><?php esc_html_e( 'Màu thứ 2 (xe 2 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>
    165165                                                <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'] ); ?>">
    166166                                        </p>
    … …  
    209209         * Display options meta box.
    210210         *
    211          * @param WP_Post $post Car.
     211         * @param WP_Post $post Product.
    212212         */
    213213        public static function box_options( $post ) {
    … …  
    275275         * Usage meta box.
    276276         *
    277          * @param WP_Post $post Car.
     277         * @param WP_Post $post Product.
    278278         */
    279279        public static function box_usage( $post ) {
    280280                if ( 'auto-draft' === $post->post_status ) {
    281                         echo '<p>' . esc_html__( 'Lưu xe trước, shortcode sẽ hiện ở đây.', 'vinhxd-car-colors-360' ) . '</p>';
    282                         return;
    283                 }
    284                 $code = '[mau_xe_o_to id="' . 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 ) . '"]';
    285285                ?>
    286286                <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>
    288288                <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>
    289289                <?php
    … …  
    347347        public static function column_content( $col, $post_id ) {
    348348                if ( 'mxot_shortcode' === $col ) {
    349                         echo '<input type="text" readonly class="code mxot-code" onfocus="this.select()" value="' . esc_attr( '[mau_xe_o_to id="' . 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 ) . '"]' ) . '">';
    350350                } elseif ( 'mxot_colors' === $col ) {
    351351                        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  
    1111
    1212/**
    13  * Registers the "Màu Xe Ô Tô" block (server-side rendered).
     13 * Registers the "Sản Phẩm 360" block (server-side rendered).
    1414 */
    1515class MXOT_Block {
  • vinhxd-car-colors-360/tags/1.1.0/includes/class-mxot-elementor-widget.php

    r3838725 r3844587  
    1111
    1212/**
    13  * "Màu Xe Ô Tô" Elementor widget.
     13 * "Sản Phẩm 360" Elementor widget.
    1414 */
    1515class MXOT_Elementor_Widget extends \Elementor\Widget_Base {
    … …  
    3030         */
    3131        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' );
    3333        }
    3434
    … …  
    5757         */
    5858        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ô' );
    6060        }
    6161
    … …  
    8282         */
    8383        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' ) );
    8585                $yes_no  = $inherit + array(
    8686                        'yes' => __( 'Có', 'vinhxd-car-colors-360' ),
    … …  
    8888                );
    8989
    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' ) ) );
    9191                $this->add_control(
    9292                        'car_id',
    9393                        array(
    94                                 'label'   => __( 'Xe', 'vinhxd-car-colors-360' ),
     94                                'label'   => __( 'Sản phẩm', 'vinhxd-car-colors-360' ),
    9595                                '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(),
    9797                                'default' => '',
    9898                        )
    … …  
    118118                                'min'         => 20,
    119119                                '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' ),
    121121                        )
    122122                );
  • vinhxd-car-colors-360/tags/1.1.0/includes/class-mxot-post-type.php

    r3838725 r3844587  
    11<?php
    22/**
    3  * Car post type and data helpers.
     3 * Product post type and data helpers.
    44 *
    55 * @package MauXeOTo
    … …  
    1111
    1212/**
    13  * Registers the "Xe" post type and reads/sanitizes its color data.
     13 * Registers the product post type and reads/sanitizes its color data.
    1414 */
    1515class MXOT_Post_Type {
    … …  
    2727
    2828        /**
    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.
    3030         */
    3131        public static function register() {
    … …  
    3434                        array(
    3535                                '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 xe mới', 'vinhxd-car-colors-360' ),
    42                                         'edit_item'          => __( 'Sửa xe', 'vinhxd-car-colors-360' ),
    43                                         'new_item'           => __( 'Xe mới', 'vinhxd-car-colors-360' ),
    44                                         'search_items'       => __( 'Tìm xe', 'vinhxd-car-colors-360' ),
    45                                         'not_found'          => __( 'Chưa có xe nà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' ),
    4646                                        'not_found_in_trash' => __( 'Thùng rác trống.', 'vinhxd-car-colors-360' ),
    4747                                ),
    … …  
    5050                                'show_in_menu'    => true,
    5151                                'show_in_rest'    => true,
    52                                 'menu_icon'       => 'dashicons-car',
     52                                'menu_icon'       => 'dashicons-image-rotate',
    5353                                'menu_position'   => 26,
    5454                                'supports'        => array( 'title' ),
    … …  
    178178
    179179        /**
    180          * Saved colors for a car.
    181          *
    182          * @param int $post_id Car ID.
     180         * Saved colors for a product.
     181         *
     182         * @param int $post_id Product ID.
    183183         * @return array
    184184         */
    … …  
    189189
    190190        /**
    191          * Saved display options for a car.
    192          *
    193          * @param int $post_id Car ID.
     191         * Saved display options for a product.
     192         *
     193         * @param int $post_id Product ID.
    194194         * @return array
    195195         */
    … …  
    199199
    200200        /**
    201          * Published cars as id => title, for block and widget pickers.
     201         * Published products as id => title, for block and widget pickers.
    202202         *
    203203         * @return array
    … …  
    216216                );
    217217                foreach ( $posts as $p ) {
    218                         /* translators: %d: car ID. */
    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 );
    220220                }
    221221                return $out;
  • vinhxd-car-colors-360/tags/1.1.0/includes/class-mxot-render.php

    r3838725 r3844587  
    1111
    1212/**
    13  * Renders a car viewer.
     13 * Renders a product viewer.
    1414 */
    1515class MXOT_Render {
    … …  
    1919         */
    2020        public static function init() {
     21                add_shortcode( 'vxd_product_360', array( __CLASS__, 'shortcode' ) );
     22                // Backward-compatible alias of the original shortcode name.
    2123                add_shortcode( 'mau_xe_o_to', array( __CLASS__, 'shortcode' ) );
    2224                add_action( 'init', array( __CLASS__, 'register_assets' ), 5 );
    … …  
    6365                }
    6466                $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 ) ) ) {
    6668                        wp_enqueue_style( 'mxot-viewer' );
    6769                }
    … …  
    6971
    7072        /**
    71          * Shortcode handler.
     73         * Shortcode handler for [vxd_product_360] and its alias [mau_xe_o_to].
    7274         *
    73          * @param array $atts Attributes.
     75         * @param array  $atts Attributes.
     76         * @param string $content Unused.
     77         * @param string $tag Shortcode tag used.
    7478         * @return string
    7579         */
    76         public static function shortcode( $atts ) {
     80        public static function shortcode( $atts, $content = '', $tag = 'vxd_product_360' ) {
    7781                $atts = shortcode_atts(
    7882                        array(
    … …  
    8488                        ),
    8589                        $atts,
    86                         'mau_xe_o_to'
     90                        $tag
    8791                );
    8892                return self::render(
    … …  
    100104         * Build viewer HTML.
    101105         *
    102          * @param int   $car_id    Car post ID.
     106         * @param int   $car_id    Product post ID.
    103107         * @param array $overrides Option overrides (empty values are ignored).
    104108         * @return string
    … …  
    108112                if ( ! $car || MXOT_Post_Type::POST_TYPE !== $car->post_type || 'publish' !== $car->post_status ) {
    109113                        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 xe chư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>';
    111115                        }
    112116                        return '';
    … …  
    115119                $colors = MXOT_Post_Type::get_colors( $car->ID );
    116120                if ( ! $colors ) {
    117                         return current_user_can( 'edit_posts' ) ? '<p class="mxot-notice">' . esc_html__( 'Màu Xe Ô Tô: xe nà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>' : '';
    118122                }
    119123
    … …  
    188192                                <span class="mxot__note"><?php echo esc_html( $first['note'] ); ?></span>
    189193                        </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' ); ?>">
    191195                                <?php
    192196                                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 ===
    22Contributors: vinhxomdoi
    3 Tags: car color, color swatch, 360 view, product spin, car dealer
     3Tags: 360 viewer, product viewer, color switcher, product colors, 360 spin
    44Requires at least: 6.2
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.2
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Car color switcher with a 360° spin viewer for every color. Shortcode, Gutenberg block and Elementor widget. No WooCommerce needed.
     11Show 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.
    1212
    1313== Description ==
    1414
    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.
    1616
    17 The admin screens are in Vietnamese because the plugin is built for Vietnamese car sellers.
     17It 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
     19The admin screens are in Vietnamese because the plugin is built for Vietnamese sellers. The menu is called "Sản Phẩm 360" (Product 360).
    1820
    1921= Features =
    2022
    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").
    2325* 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.
    2426* 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 car 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.
     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.
    2628* The current angle is kept when switching between 360° colors.
    2729* 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.
    … …  
    2931* Fullscreen button (with a CSS fallback for iPhone) and optional zoom (buttons or double click, drag to pan).
    3032* 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.
    3335* No external requests, no tracking, no ads.
    3436
    3537= Shortcode options =
    3638
    37 `[mau_xe_o_to id="123" shape="circle" size="40" label="yes" autoplay="no"]`
     39`[vxd_product_360 id="123" shape="circle" size="40" label="yes" autoplay="no"]`
    3840
    39 * `id` – car ID (shown on the car edit screen and in the car list).
     41The 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).
    4044* `shape` – `circle`, `rounded` or `square`.
    4145* `size` – swatch size in pixels (20–80).
    … …  
    4347* `autoplay` – `yes` or `no`. Default: `no`.
    4448
    45 Empty options fall back to the settings saved on the car.
     49Empty options fall back to the settings saved on the product.
    4650
    4751== Installation ==
    … …  
    49531. Upload the `vinhxd-car-colors-360` folder to `/wp-content/plugins/`, or install it from the Plugins screen.
    50542. Activate the plugin.
    51 3. Go to **Màu Xe Ô Tô → Thêm xe**, enter the car name and add colors. For each color choose a main image and, optionally, the 360° frames.
    52 4. Publish, then insert the car with the shortcode, the block or the Elementor widget.
     553. 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.
     564. Publish, then insert the product with the shortcode, the block or the Elementor widget.
    5357
    5458== Frequently Asked Questions ==
    5559
     60= What kind of products can I show? =
     61
     62Anything 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
    5664= How many frames should a 360° sequence have? =
    5765
    58 24 to 36 frames taken at equal angles around the car work best. Up to 72 frames per color are accepted.
     6624 to 36 frames taken at equal angles around the product work best. Up to 72 frames per color are accepted.
    5967
    6068= Where can I get 360° images? =
    6169
    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.
     70Shoot 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.
    6371
    64 = The car rotates the wrong way. =
     72= The product rotates the wrong way. =
    6573
    6674Click "Đảo chiều" (reverse) under the frames, or set "Đảo chiều kéo" (reverse drag) to "Có" in the display box.
    … …  
    6876= Does it need WooCommerce? =
    6977
    70 No. Cars are stored in their own post type.
     78No. 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
     82Yes. It is kept as an alias of `[vxd_product_360]`.
    7183
    7284= Does it work with page caching and lazy loading plugins? =
    … …  
    7789
    78901. Color swatches with the 360° viewer on the front end.
    79 2. Car editor: colors, two-tone swatches, main image and 360° frames.
     912. Product editor: colors, two-tone swatches, main image and 360° frames.
    8092
    8193== 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.
    82100
    83101= 1.0.2 =
    … …  
    93111== Upgrade Notice ==
    94112
     113= 1.1.0 =
     114New name and menu label "Sản Phẩm 360", new shortcode [vxd_product_360]. The old [mau_xe_o_to] shortcode keeps working.
     115
    95116= 1.0.2 =
    96117Renamed for the WordPress.org directory. Existing shortcodes, blocks and cars keep working.
  • vinhxd-car-colors-360/tags/1.1.0/uninstall.php

    r3838725 r3844587  
    11<?php
    22/**
    3  * Remove plugin data on uninstall (car entries and their settings). Media files are kept.
     3 * Remove plugin data on uninstall (product entries and their settings). Media files are kept.
    44 *
    55 * @package MauXeOTo
  • vinhxd-car-colors-360/tags/1.1.0/vinhxd-car-colors-360.php

    r3838725 r3844587  
    11<?php
    22/**
    3  * Plugin Name:       VinhXD Car Colors 360
     3 * Plugin Name:       VinhXD Product 360 & Color Switcher
    44 * 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.2
     5 * 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
    77 * Requires at least: 6.2
    88 * Requires PHP:      7.4
    … …  
    2020}
    2121
    22 define( 'MXOT_VERSION', '1.0.2' );
     22define( 'MXOT_VERSION', '1.1.0' );
    2323define( 'MXOT_FILE', __FILE__ );
    2424define( 'MXOT_DIR', plugin_dir_path( __FILE__ ) );
    … …  
    4848
    4949/**
    50  * Flush rewrite rules on activation so the car post type works right away.
     50 * Flush rewrite rules on activation so the product post type works right away.
    5151 */
    5252function 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 */
    22.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}
    33.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ô – car editor (admin only). */
     1/* Sản Phẩm 360 – product editor (admin only). */
    22( function ( $ ) {
    33        '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. */
    22( function () {
    33        'use strict';
  • vinhxd-car-colors-360/trunk/blocks/xe/block.json

    r3838725 r3844587  
    33        "apiVersion": 3,
    44        "name": "mau-xe-o-to/xe",
    5         "title": "Màu Xe Ô Tô",
     5        "title": "Sản Phẩm 360",
    66        "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" ],
    1010        "textdomain": "vinhxd-car-colors-360",
    1111        "attributes": {
  • vinhxd-car-colors-360/trunk/blocks/xe/index.asset.php

    r3838725 r3844587  
    1212return array(
    1313        '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',
    1515);
  • vinhxd-car-colors-360/trunk/blocks/xe/index.js

    r3838725 r3844587  
    1717                        }, [] );
    1818
    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' ) } ];
    2020                        ( cars || [] ).forEach( function ( p ) {
    2121                                options.push( { value: p.id, label: ( p.title && p.title.rendered ) || ( '#' + p.id ) } );
    2222                        } );
    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' ) };
    2424                        var yesNo = [ inherit, { value: 'yes', label: __( 'Có', 'vinhxd-car-colors-360' ) }, { value: 'no', label: __( 'Không', 'vinhxd-car-colors-360' ) } ];
    2525
    2626                        var picker = el( c.SelectControl, {
    27                                 label: __( 'Xe', 'vinhxd-car-colors-360' ),
     27                                label: __( 'Sản phẩm', 'vinhxd-car-colors-360' ),
    2828                                value: a.carId,
    2929                                options: options,
    … …  
    3232
    3333                        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 },
    3535                                        picker,
    3636                                        el( c.SelectControl, {
    … …  
    4141                                        } ),
    4242                                        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' ),
    4444                                                value: a.size, min: 0, max: 80,
    4545                                                onChange: function ( v ) { set( { size: v || 0 } ); }
    … …  
    5252                        var body = a.carId
    5353                                ? 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 );
    5555
    5656                        return el( 'div', blockProps, inspector, body );
  • vinhxd-car-colors-360/trunk/includes/class-mxot-admin.php

    r3838725 r3844587  
    1111
    1212/**
    13  * Admin UI for the car post type.
     13 * Admin UI for the product post type.
    1414 */
    1515class MXOT_Admin {
    … …  
    3030
    3131        /**
    32          * "Thêm xe" link on the Plugins screen.
     32         * "Thêm sản phẩm" link on the Plugins screen.
    3333         *
    3434         * @param array $links Links.
    … …  
    3737        public static function action_links( $links ) {
    3838                $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>' );
    4040                return $links;
    4141        }
    … …  
    4545         */
    4646        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' );
    4848                add_meta_box( 'mxot-options', __( 'Hiển thị', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_options' ), null, 'side' );
    4949                add_meta_box( 'mxot-usage', __( 'Cách chèn vào trang', 'vinhxd-car-colors-360' ), array( __CLASS__, 'box_usage' ), null, 'side', 'high' );
    … …  
    5151
    5252        /**
    53          * Admin assets, only on the car edit screen.
     53         * Admin assets, only on the product edit screen.
    5454         *
    5555         * @param string $hook Current admin page.
    … …  
    9090         * Colors meta box.
    9191         *
    92          * @param WP_Post $post Car.
     92         * @param WP_Post $post Product.
    9393         */
    9494        public static function box_colors( $post ) {
    … …  
    9797                ?>
    9898                <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' ); ?>
    100100                </p>
    101101                <div id="mxot-colors-list" class="mxot-colors-list">
    … …  
    151151                                        <p>
    152152                                                <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>
    154154                                        </p>
    155155                                        <p>
    … …  
    162162                                        </p>
    163163                                        <p class="mxot-hex">
    164                                                 <span><?php esc_html_e( 'Màu thứ 2 (xe 2 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>
    165165                                                <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'] ); ?>">
    166166                                        </p>
    … …  
    209209         * Display options meta box.
    210210         *
    211          * @param WP_Post $post Car.
     211         * @param WP_Post $post Product.
    212212         */
    213213        public static function box_options( $post ) {
    … …  
    275275         * Usage meta box.
    276276         *
    277          * @param WP_Post $post Car.
     277         * @param WP_Post $post Product.
    278278         */
    279279        public static function box_usage( $post ) {
    280280                if ( 'auto-draft' === $post->post_status ) {
    281                         echo '<p>' . esc_html__( 'Lưu xe trước, shortcode sẽ hiện ở đây.', 'vinhxd-car-colors-360' ) . '</p>';
    282                         return;
    283                 }
    284                 $code = '[mau_xe_o_to id="' . 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 ) . '"]';
    285285                ?>
    286286                <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>
    288288                <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>
    289289                <?php
    … …  
    347347        public static function column_content( $col, $post_id ) {
    348348                if ( 'mxot_shortcode' === $col ) {
    349                         echo '<input type="text" readonly class="code mxot-code" onfocus="this.select()" value="' . esc_attr( '[mau_xe_o_to id="' . 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 ) . '"]' ) . '">';
    350350                } elseif ( 'mxot_colors' === $col ) {
    351351                        foreach ( MXOT_Post_Type::get_colors( $post_id ) as $c ) {
  • vinhxd-car-colors-360/trunk/includes/class-mxot-block.php

    r3838725 r3844587  
    1111
    1212/**
    13  * Registers the "Màu Xe Ô Tô" block (server-side rendered).
     13 * Registers the "Sản Phẩm 360" block (server-side rendered).
    1414 */
    1515class MXOT_Block {
  • vinhxd-car-colors-360/trunk/includes/class-mxot-elementor-widget.php

    r3838725 r3844587  
    1111
    1212/**
    13  * "Màu Xe Ô Tô" Elementor widget.
     13 * "Sản Phẩm 360" Elementor widget.
    1414 */
    1515class MXOT_Elementor_Widget extends \Elementor\Widget_Base {
    … …  
    3030         */
    3131        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' );
    3333        }
    3434
    … …  
    5757         */
    5858        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ô' );
    6060        }
    6161
    … …  
    8282         */
    8383        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' ) );
    8585                $yes_no  = $inherit + array(
    8686                        'yes' => __( 'Có', 'vinhxd-car-colors-360' ),
    … …  
    8888                );
    8989
    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' ) ) );
    9191                $this->add_control(
    9292                        'car_id',
    9393                        array(
    94                                 'label'   => __( 'Xe', 'vinhxd-car-colors-360' ),
     94                                'label'   => __( 'Sản phẩm', 'vinhxd-car-colors-360' ),
    9595                                '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(),
    9797                                'default' => '',
    9898                        )
    … …  
    118118                                'min'         => 20,
    119119                                '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' ),
    121121                        )
    122122                );
  • vinhxd-car-colors-360/trunk/includes/class-mxot-post-type.php

    r3838725 r3844587  
    11<?php
    22/**
    3  * Car post type and data helpers.
     3 * Product post type and data helpers.
    44 *
    55 * @package MauXeOTo
    … …  
    1111
    1212/**
    13  * Registers the "Xe" post type and reads/sanitizes its color data.
     13 * Registers the product post type and reads/sanitizes its color data.
    1414 */
    1515class MXOT_Post_Type {
    … …  
    2727
    2828        /**
    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.
    3030         */
    3131        public static function register() {
    … …  
    3434                        array(
    3535                                '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 xe mới', 'vinhxd-car-colors-360' ),
    42                                         'edit_item'          => __( 'Sửa xe', 'vinhxd-car-colors-360' ),
    43                                         'new_item'           => __( 'Xe mới', 'vinhxd-car-colors-360' ),
    44                                         'search_items'       => __( 'Tìm xe', 'vinhxd-car-colors-360' ),
    45                                         'not_found'          => __( 'Chưa có xe nà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' ),
    4646                                        'not_found_in_trash' => __( 'Thùng rác trống.', 'vinhxd-car-colors-360' ),
    4747                                ),
    … …  
    5050                                'show_in_menu'    => true,
    5151                                'show_in_rest'    => true,
    52                                 'menu_icon'       => 'dashicons-car',
     52                                'menu_icon'       => 'dashicons-image-rotate',
    5353                                'menu_position'   => 26,
    5454                                'supports'        => array( 'title' ),
    … …  
    178178
    179179        /**
    180          * Saved colors for a car.
    181          *
    182          * @param int $post_id Car ID.
     180         * Saved colors for a product.
     181         *
     182         * @param int $post_id Product ID.
    183183         * @return array
    184184         */
    … …  
    189189
    190190        /**
    191          * Saved display options for a car.
    192          *
    193          * @param int $post_id Car ID.
     191         * Saved display options for a product.
     192         *
     193         * @param int $post_id Product ID.
    194194         * @return array
    195195         */
    … …  
    199199
    200200        /**
    201          * Published cars as id => title, for block and widget pickers.
     201         * Published products as id => title, for block and widget pickers.
    202202         *
    203203         * @return array
    … …  
    216216                );
    217217                foreach ( $posts as $p ) {
    218                         /* translators: %d: car ID. */
    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 );
    220220                }
    221221                return $out;
  • vinhxd-car-colors-360/trunk/includes/class-mxot-render.php

    r3838725 r3844587  
    1111
    1212/**
    13  * Renders a car viewer.
     13 * Renders a product viewer.
    1414 */
    1515class MXOT_Render {
    … …  
    1919         */
    2020        public static function init() {
     21                add_shortcode( 'vxd_product_360', array( __CLASS__, 'shortcode' ) );
     22                // Backward-compatible alias of the original shortcode name.
    2123                add_shortcode( 'mau_xe_o_to', array( __CLASS__, 'shortcode' ) );
    2224                add_action( 'init', array( __CLASS__, 'register_assets' ), 5 );
    … …  
    6365                }
    6466                $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 ) ) ) {
    6668                        wp_enqueue_style( 'mxot-viewer' );
    6769                }
    … …  
    6971
    7072        /**
    71          * Shortcode handler.
     73         * Shortcode handler for [vxd_product_360] and its alias [mau_xe_o_to].
    7274         *
    73          * @param array $atts Attributes.
     75         * @param array  $atts Attributes.
     76         * @param string $content Unused.
     77         * @param string $tag Shortcode tag used.
    7478         * @return string
    7579         */
    76         public static function shortcode( $atts ) {
     80        public static function shortcode( $atts, $content = '', $tag = 'vxd_product_360' ) {
    7781                $atts = shortcode_atts(
    7882                        array(
    … …  
    8488                        ),
    8589                        $atts,
    86                         'mau_xe_o_to'
     90                        $tag
    8791                );
    8892                return self::render(
    … …  
    100104         * Build viewer HTML.
    101105         *
    102          * @param int   $car_id    Car post ID.
     106         * @param int   $car_id    Product post ID.
    103107         * @param array $overrides Option overrides (empty values are ignored).
    104108         * @return string
    … …  
    108112                if ( ! $car || MXOT_Post_Type::POST_TYPE !== $car->post_type || 'publish' !== $car->post_status ) {
    109113                        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 xe chư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>';
    111115                        }
    112116                        return '';
    … …  
    115119                $colors = MXOT_Post_Type::get_colors( $car->ID );
    116120                if ( ! $colors ) {
    117                         return current_user_can( 'edit_posts' ) ? '<p class="mxot-notice">' . esc_html__( 'Màu Xe Ô Tô: xe nà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>' : '';
    118122                }
    119123
    … …  
    188192                                <span class="mxot__note"><?php echo esc_html( $first['note'] ); ?></span>
    189193                        </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' ); ?>">
    191195                                <?php
    192196                                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 ===
    22Contributors: vinhxomdoi
    3 Tags: car color, color swatch, 360 view, product spin, car dealer
     3Tags: 360 viewer, product viewer, color switcher, product colors, 360 spin
    44Requires at least: 6.2
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.2
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Car color switcher with a 360° spin viewer for every color. Shortcode, Gutenberg block and Elementor widget. No WooCommerce needed.
     11Show 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.
    1212
    1313== Description ==
    1414
    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.
    1616
    17 The admin screens are in Vietnamese because the plugin is built for Vietnamese car sellers.
     17It 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
     19The admin screens are in Vietnamese because the plugin is built for Vietnamese sellers. The menu is called "Sản Phẩm 360" (Product 360).
    1820
    1921= Features =
    2022
    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").
    2325* 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.
    2426* 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 car 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.
     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.
    2628* The current angle is kept when switching between 360° colors.
    2729* 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.
    … …  
    2931* Fullscreen button (with a CSS fallback for iPhone) and optional zoom (buttons or double click, drag to pan).
    3032* 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.
    3335* No external requests, no tracking, no ads.
    3436
    3537= Shortcode options =
    3638
    37 `[mau_xe_o_to id="123" shape="circle" size="40" label="yes" autoplay="no"]`
     39`[vxd_product_360 id="123" shape="circle" size="40" label="yes" autoplay="no"]`
    3840
    39 * `id` – car ID (shown on the car edit screen and in the car list).
     41The 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).
    4044* `shape` – `circle`, `rounded` or `square`.
    4145* `size` – swatch size in pixels (20–80).
    … …  
    4347* `autoplay` – `yes` or `no`. Default: `no`.
    4448
    45 Empty options fall back to the settings saved on the car.
     49Empty options fall back to the settings saved on the product.
    4650
    4751== Installation ==
    … …  
    49531. Upload the `vinhxd-car-colors-360` folder to `/wp-content/plugins/`, or install it from the Plugins screen.
    50542. Activate the plugin.
    51 3. Go to **Màu Xe Ô Tô → Thêm xe**, enter the car name and add colors. For each color choose a main image and, optionally, the 360° frames.
    52 4. Publish, then insert the car with the shortcode, the block or the Elementor widget.
     553. 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.
     564. Publish, then insert the product with the shortcode, the block or the Elementor widget.
    5357
    5458== Frequently Asked Questions ==
    5559
     60= What kind of products can I show? =
     61
     62Anything 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
    5664= How many frames should a 360° sequence have? =
    5765
    58 24 to 36 frames taken at equal angles around the car work best. Up to 72 frames per color are accepted.
     6624 to 36 frames taken at equal angles around the product work best. Up to 72 frames per color are accepted.
    5967
    6068= Where can I get 360° images? =
    6169
    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.
     70Shoot 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.
    6371
    64 = The car rotates the wrong way. =
     72= The product rotates the wrong way. =
    6573
    6674Click "Đảo chiều" (reverse) under the frames, or set "Đảo chiều kéo" (reverse drag) to "Có" in the display box.
    … …  
    6876= Does it need WooCommerce? =
    6977
    70 No. Cars are stored in their own post type.
     78No. 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
     82Yes. It is kept as an alias of `[vxd_product_360]`.
    7183
    7284= Does it work with page caching and lazy loading plugins? =
    … …  
    7789
    78901. Color swatches with the 360° viewer on the front end.
    79 2. Car editor: colors, two-tone swatches, main image and 360° frames.
     912. Product editor: colors, two-tone swatches, main image and 360° frames.
    8092
    8193== 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.
    82100
    83101= 1.0.2 =
    … …  
    93111== Upgrade Notice ==
    94112
     113= 1.1.0 =
     114New name and menu label "Sản Phẩm 360", new shortcode [vxd_product_360]. The old [mau_xe_o_to] shortcode keeps working.
     115
    95116= 1.0.2 =
    96117Renamed for the WordPress.org directory. Existing shortcodes, blocks and cars keep working.
  • vinhxd-car-colors-360/trunk/uninstall.php

    r3838725 r3844587  
    11<?php
    22/**
    3  * Remove plugin data on uninstall (car entries and their settings). Media files are kept.
     3 * Remove plugin data on uninstall (product entries and their settings). Media files are kept.
    44 *
    55 * @package MauXeOTo
  • vinhxd-car-colors-360/trunk/vinhxd-car-colors-360.php

    r3838725 r3844587  
    11<?php
    22/**
    3  * Plugin Name:       VinhXD Car Colors 360
     3 * Plugin Name:       VinhXD Product 360 & Color Switcher
    44 * 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.2
     5 * 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
    77 * Requires at least: 6.2
    88 * Requires PHP:      7.4
    … …  
    2020}
    2121
    22 define( 'MXOT_VERSION', '1.0.2' );
     22define( 'MXOT_VERSION', '1.1.0' );
    2323define( 'MXOT_FILE', __FILE__ );
    2424define( 'MXOT_DIR', plugin_dir_path( __FILE__ ) );
    … …  
    4848
    4949/**
    50  * Flush rewrite rules on activation so the car post type works right away.
     50 * Flush rewrite rules on activation so the product post type works right away.
    5151 */
    5252function mxot_activate() {
Note: See TracChangeset for help on using the changeset viewer.