' . '' . '' . '' . '';
add_menu_page(
'3D Customizer',
// Page Title
'3D Product Customizer',
// Menu Title (Top-level)
'manage_options',
// Capability
'dprcu-settings',
// Slug
'dprcu_settings_page_html',
// Callback
'data:image/svg+xml;base64,' . base64_encode( $icon_svg ),
// Icon
58
);
}
add_action( 'admin_menu', 'dprcu_register_options_page', 9 );
// Priority 9 to run before Freemius
add_action( 'admin_menu', function () {
global $submenu;
if ( isset( $submenu['dprcu-settings'][0] ) ) {
$submenu['dprcu-settings'][0][0] = __( 'Settings', '3d-product-customizer' );
}
}, 999 );
// Run after Freemius and all other submenus are registered
// Register Settings
function dprcu_register_settings() {
register_setting( 'dprcu_options', 'dprcu_settings', array(
'sanitize_callback' => 'dprcu_sanitize_settings',
) );
// --- Display tab ---
add_settings_section(
'display_section',
'',
'__return_false',
'dprcu-tab-display'
);
add_settings_field(
'display_method',
'Display Method',
'dprcu_render_display_method',
'dprcu-tab-display',
'display_section',
array(
'key' => 'display_method',
'default' => 'auto',
'description' => __( 'Choose how to display the customizer on product pages.', '3d-product-customizer' ),
)
);
add_settings_field(
'ar_button_display_method',
'AR Button Display Method',
'dprcu_render_ar_button_display_method',
'dprcu-tab-display',
'display_section',
array(
'key' => 'ar_display_mode',
'default' => 'simple',
'description' => __( 'Choose how to display the AR button on the customizer interface.', '3d-product-customizer' ),
)
);
add_settings_field(
'express_payments_enabled',
'Express Payment Methods',
'dprcu_render_express_payments_enabled',
'dprcu-tab-display',
'display_section',
array(
'key' => 'express_payments_enabled',
'default' => 1,
)
);
add_settings_field(
'step_thumbnails_enabled',
'Step Thumbnails (EXPERIMENTAL)',
'dprcu_render_step_thumbnails_enabled',
'dprcu-tab-display',
'display_section',
array(
'key' => 'step_thumbnails_enabled',
)
);
if ( dprcu_fs()?->can_use_premium_code__premium_only() ) {
add_settings_field(
'hotspot_enabled',
'Hotspot Enabled',
'dprcu_render_hotspot_enabled__premium_only',
'dprcu-tab-display',
'display_section',
array(
'key' => 'hotspot_enabled',
'default' => 1,
'description' => __( 'Toggle the visibility of interactive hotspots on the product.', '3d-product-customizer' ),
)
);
}
// --- Scene tab ---
add_settings_section(
'default_section',
'',
'__return_false',
'dprcu-tab-scene'
);
add_settings_field(
'camera_distance_multiplier',
'Camera Distance (relative to model)',
'dprcu_render_float',
'dprcu-tab-scene',
'default_section',
array(
'key' => 'camera_distance_multiplier',
'default' => 1.2,
'min' => 0.5,
'max' => 3.0,
'step' => 0.1,
'description' => __( 'Adjust how far the camera is from the model. 1.0 = automatic framing, < 1.0 = closer (more zoom), > 1.0 = farther (more space around model).', '3d-product-customizer' ),
)
);
add_settings_field(
'bg_colors',
'Background Colors',
'dprcu_render_textarea',
'dprcu-tab-scene',
'default_section',
array(
'key' => 'bg_colors',
)
);
add_settings_field(
'zoom_limits',
'Zoom Range (Min, Max)',
'dprcu_render_minmax',
'dprcu-tab-scene',
'default_section',
array(
'key' => 'zoom_limits',
'default' => array(1, 10),
)
);
add_settings_field(
'hdr_file',
'HDR Environment Map',
'dprcu_render_hdr_file',
'dprcu-tab-scene',
'default_section',
array(
'key' => 'hdr_file',
)
);
if ( dprcu_fs()?->can_use_premium_code__premium_only() ) {
add_settings_field(
'hide_watermark',
'Hide Watermark',
'dprcu_render_hide_watermark__premium_only',
'dprcu-tab-scene',
'default_section'
);
}
// --- Advanced tab ---
add_settings_section(
'danger_section',
'',
'__return_false',
'dprcu-tab-advanced'
);
add_settings_field(
'delete_on_uninstall',
'Delete data on uninstall',
'dprcu_render_delete_on_uninstall',
'dprcu-tab-advanced',
'danger_section'
);
}
add_action( 'admin_init', 'dprcu_register_settings' );
// Render Callbacks
function dprcu_settings_page_html() {
$tabs = apply_filters( 'dprcu_settings_tabs', array(
'display' => __( 'Display', '3d-product-customizer' ),
'scene' => __( 'Scene', '3d-product-customizer' ),
'advanced' => __( 'Advanced', '3d-product-customizer' ),
) );
$tabs['help'] = __( 'Help', '3d-product-customizer' );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$active = ( isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : 'display' );
if ( !array_key_exists( $active, $tabs ) ) {
$active = array_key_first( $tabs );
}
?>
-
-
-
can_use_premium_code__premium_only() ) {
$new_input['hotspot_enabled'] = ( !empty( $input['hotspot_enabled'] ) ? 1 : 0 );
}
}
if ( 'scene' === $tab ) {
if ( dprcu_fs()?->can_use_premium_code__premium_only() ) {
$new_input['hide_watermark'] = ( !empty( $input['hide_watermark'] ) ? 1 : 0 );
}
}
if ( 'advanced' === $tab ) {
$new_input['delete_on_uninstall'] = ( !empty( $input['delete_on_uninstall'] ) ? 1 : 0 );
}
// Allow other files (e.g. analytics) to handle their own tab's checkboxes.
$new_input = apply_filters(
'dprcu_sanitize_settings_tab',
$new_input,
$input,
$tab
);
unset($new_input['_tab']);
return $new_input;
}
// --- Render Callback for Min/Max ---
function dprcu_render_minmax( $args ) {
$options = get_option( 'dprcu_settings' );
$defaults = $args['default'];
$vals = $options[$args['key']] ?? $defaults;
?>
%2$s | Demo | Docs', '3d-product-customizer' )
),
'https://deosebitsoft.ro/',
'deosebIT Soft',
'https://web-support.eu/',
'https://web-support.eu/documentation/'
);
}
add_filter( 'admin_footer_text', 'dprcu_admin_footer_text' );