__('Free Photo', 'studiou-wc-free-photo-product'), 'target' => 'studiou_fpp_product_data', 'class' => array('show_if_variable'), 'priority' => 80, ); return $tabs; } public function add_product_data_panel() { global $post; $product_id = $post->ID; $enabled = get_post_meta($product_id, '_studiou_fpp_enabled', true); $media_category = get_post_meta($product_id, '_studiou_fpp_media_category', true); $max_file_size = get_post_meta($product_id, '_studiou_fpp_max_file_size', true); if (empty($max_file_size)) { $max_file_size = 50; } $categories = get_terms(array( 'taxonomy' => 'studiou_media_category', 'hide_empty' => false, )); if (is_wp_error($categories)) { $categories = array(); } ?>
'_studiou_fpp_enabled', 'label' => __('Enable Free Photo', 'studiou-wc-free-photo-product'), 'description' => __('Enable custom photo upload for this product', 'studiou-wc-free-photo-product'), 'value' => $enabled, )); ?>

'_studiou_fpp_max_file_size', 'label' => __('Max File Size (MB)', 'studiou-wc-free-photo-product'), 'description' => __('Maximum allowed file size for uploads in megabytes.', 'studiou-wc-free-photo-product'), 'desc_tip' => true, 'type' => 'number', 'custom_attributes' => array( 'step' => '1', 'min' => '1', 'max' => '500', ), 'value' => $max_file_size, )); ?>

[studiou_free_photo_product id=""]

500) $max_size = 500; update_post_meta($product_id, '_studiou_fpp_max_file_size', $max_size); } } public function ajax_add_media_category() { check_ajax_referer('studiou-wcfpp-nonce', 'nonce'); if (!current_user_can('manage_woocommerce')) { wp_send_json_error(array('message' => __('Insufficient permissions.', 'studiou-wc-free-photo-product'))); return; } $name = isset($_POST['name']) ? sanitize_text_field($_POST['name']) : ''; if (empty($name)) { wp_send_json_error(array('message' => __('Category name is required.', 'studiou-wc-free-photo-product'))); return; } $term = wp_insert_term($name, 'studiou_media_category'); if (is_wp_error($term)) { wp_send_json_error(array('message' => $term->get_error_message())); return; } wp_send_json_success(array( 'term_id' => $term['term_id'], 'name' => $name, )); } public static function is_fpp_product($product_id) { return get_post_meta($product_id, '_studiou_fpp_enabled', true) === 'yes'; } public static function get_product_max_file_size($product_id) { $size = get_post_meta($product_id, '_studiou_fpp_max_file_size', true); return !empty($size) ? (int) $size : 50; } public static function get_product_media_category($product_id) { return (int) get_post_meta($product_id, '_studiou_fpp_media_category', true); } }