[ 'type' => 'select', 'label' => __( 'عکس صورت مشتری', 'rahkar-toolkit' ), 'options' => [ FormConfig::PHOTO_REQUIRED => __( 'اجباری', 'rahkar-toolkit' ), FormConfig::PHOTO_OPTIONAL => __( 'اختیاری', 'rahkar-toolkit' ), FormConfig::PHOTO_OFF => __( 'پرسیده نشود', 'rahkar-toolkit' ), ], 'help' => __( 'عکسی که کنار نام مشتری روی کارت نظر می‌آید. اگر پرسیده نشود یا مشتری نفرستد، حرف اول نامش جای عکس را می‌گیرد.', 'rahkar-toolkit' ), 'default' => FormConfig::PHOTO_REQUIRED, 'section' => 'form', ], 'media_image' => [ 'type' => 'checkbox', 'label' => __( 'ارسال عکس', 'rahkar-toolkit' ), 'help' => __( 'عکس‌های اضافه، مثلاً از محصولی که خریده. حداکثر ۴ مگابایت برای هر عکس.', 'rahkar-toolkit' ), 'default' => true, 'section' => 'form', ], 'media_audio' => [ 'type' => 'checkbox', 'label' => __( 'ارسال ویس', 'rahkar-toolkit' ), 'help' => __( 'حداکثر ۱۰ مگابایت.', 'rahkar-toolkit' ), 'default' => true, 'section' => 'form', ], 'media_video' => [ 'type' => 'checkbox', 'label' => __( 'ارسال ویدئو', 'rahkar-toolkit' ), 'help' => __( 'حداکثر ۴۰ مگابایت. ویدئو بیشترین فضای هاست را می‌گیرد؛ اگر فضا محدود است، خاموشش کنید.', 'rahkar-toolkit' ), 'default' => true, 'section' => 'form', ], 'instagram_id' => [ 'type' => 'checkbox', 'label' => __( 'فیلد آیدی اینستاگرام', 'rahkar-toolkit' ), 'help' => __( 'آیدی زیر نام مشتری روی کارت نظر نمایش داده می‌شود و به صفحهٔ اینستاگرامش لینک می‌شود.', 'rahkar-toolkit' ), 'default' => true, 'section' => 'form', ], 'instagram_purchase' => [ 'type' => 'checkbox', 'label' => __( 'تیک «از اینستاگرام خریداری کردم»', 'rahkar-toolkit' ), 'help' => __( 'برای فروشگاه‌هایی که در اینستاگرام هم می‌فروشند. روی کارت نظر نشان «خرید از اینستاگرام» می‌گیرد. این را مشتری خودش اعلام می‌کند و سیستم بررسی‌اش نمی‌کند.', 'rahkar-toolkit' ), 'default' => false, 'section' => 'form', ], ]; // Without WooCommerce there is nothing to tag, and the setting would // describe a field that never appears. if ( $shop ) { $schema['product_pick'] = [ 'type' => 'select', 'label' => __( 'انتخاب محصول توسط مشتری', 'rahkar-toolkit' ), 'options' => [ FormConfig::PRODUCT_OFF => __( 'خاموش', 'rahkar-toolkit' ), FormConfig::PRODUCT_PURCHASED => __( 'فقط محصولاتی که از سایت خریده', 'rahkar-toolkit' ), FormConfig::PRODUCT_ALL => __( 'همهٔ محصولات', 'rahkar-toolkit' ), ], 'help' => __( 'مشتری نام محصول را جستجو و انتخاب می‌کند و بعد از تأیید، عکس‌های نظرش در صفحهٔ همان محصول هم نمایش داده می‌شود. «فقط خریده‌ها» جلوی نظر گذاشتن زیر محصولی که مشتری نخریده را می‌گیرد، ولی کسی که از اینستاگرام خریده سفارشی در سایت ندارد و محصولی پیدا نمی‌کند. اگر محصول انتخاب‌شده در سفارش‌های مشتری باشد، نظر نشان «خریدار سایت» می‌گیرد.', 'rahkar-toolkit' ), 'default' => FormConfig::PRODUCT_OFF, 'section' => 'form', ]; } return $schema; } /** * {@inheritDoc} */ public function settingsSections(): array { return [ 'form' => __( 'فرم ارسال نظر', 'rahkar-toolkit' ), ]; } /** * {@inheritDoc} */ public function register(): void { // The post type and its meta are registered everywhere: a theme queries // them on the front, the editor reads them over REST, and the endpoint // below writes them from a REST request. add_action( 'init', static fn() => Plugin::make( TestimonialType::class )->register() ); add_action( 'init', static fn() => Plugin::make( TestimonialType::class )->registerMeta() ); add_action( 'rest_api_init', static fn() => Plugin::make( SubmitEndpoint::class )->registerRoute() ); add_action( 'rest_api_init', static fn() => Plugin::make( ProductSearch::class )->registerRoute() ); /* * What the submission form accepts, for a theme drawing it. A filter and * not a function the theme calls, so the theme keeps working (with its * old, everything-on form) when this module is off or the plugin absent: * `apply_filters( 'rahkar_wp_testimonials_form', null )` answers null. */ add_filter( 'rahkar_wp_testimonials_form', static fn() => FormConfig::forTheme() ); if ( ! is_admin() ) { return; } add_filter( 'manage_' . TestimonialType::POST_TYPE . '_posts_columns', static fn( $columns ) => Plugin::make( ListColumns::class )->columns( $columns ) ); add_action( 'manage_' . TestimonialType::POST_TYPE . '_posts_custom_column', static fn( $column, $postId ) => Plugin::make( ListColumns::class )->cell( $column, $postId ), 10, 2 ); // The literal, not ListColumns::ACTION: reading the constant here would // load that class on every admin request (DEVELOPMENT.md §9 rule 3). add_action( 'admin_post_rh_tm_toggle_pin', static fn() => Plugin::make( ListColumns::class )->toggle() ); add_action( 'add_meta_boxes', static fn() => Plugin::make( MetaBox::class )->register() ); add_action( 'save_post_' . TestimonialType::POST_TYPE, static fn( $postId, $post ) => Plugin::make( MetaBox::class )->save( $postId, $post ), 10, 2 ); add_action( 'admin_enqueue_scripts', static fn() => Plugin::make( MetaBox::class )->assets() ); } }