load_scripts(); $criteria_edit->render($criterion_id); class AFFLCriteriaEdit { public function load_scripts() { wp_enqueue_style('affililabs-criteria-edit', AFFILILABS_CRITERIA_EDIT_CSS_URL, array(), AFFILILABS_VERSION); wp_enqueue_script('affililabs-criteria-edit', AFFILILABS_CRITERIA_EDIT_JS_URL, array('jquery'), AFFILILABS_VERSION, true); wp_localize_script('affililabs-criteria-edit', 'affililabs_criteria_edit', array( 'i18n' => array( 'field_name' => esc_html__('Field Name', 'affililabs'), 'field_type' => esc_html__('Field Type', 'affililabs'), 'remove' => esc_html__('Remove', 'affililabs'), 'save_success_title' => esc_html__('Success', 'affililabs'), 'save_success_message' => esc_html__('Criterion saved successfully.', 'affililabs'), 'save_error_title' => esc_html__('Error', 'affililabs'), 'save_error_message' => esc_html__('Failed to save criterion.', 'affililabs'), 'save_error_unknown' => esc_html__('An unknown error occurred while trying to save the criterion.', 'affililabs'), ), 'nonce' => wp_create_nonce('affl_admin_nonce'), 'ajax_url' => admin_url('admin-ajax.php') )); } public function render($criterion_id=null) { $criterion_details = array(); if ($criterion_id) { try { if (class_exists('AFFLCriteriaService')) { $criterion_details = AFFLCriteriaService::get_criterion($criterion_id); } else { AFFL_LoggerService::log('AFFLCriteriaService not found in AFFLCriteriaEdit::render', 'ERROR'); $criterion_id = null; } } catch (Exception $e) { AFFL_LoggerService::log("Error fetching criterion data for ID " . esc_html($criterion_id) . ": " . esc_html($e->getMessage()), 'ERROR'); $criterion_id = null; } } if (empty($criterion_details)) { $criterion_details = array( 'id' => null, 'title' => '', 'description' => '', 'fields' => array(), 'linked_products' => array(), 'linked_categories' => array(), 'linked_product_lists' => array(), ); } $navbar = new AffiliLabs_Navbar(); $navbar->load_scripts(); $button = new AffiliLabs_Button(); $modal = new AffiliLabs_Modal(); $modal->load_scripts(); $modal->init(); $spinner = new AffiliLabs_Spinner(); $spinner->load_scripts(); $spinner->init(); $video_frame = new AffiliLabs_VideoFrame(); $video_frame->load_scripts(); $video_frame->init(); ?>