render_add_edit_content( $edit_id ); ?>
get_cost_tracker_by( 'id', $edit_id ); if ( $edit_cost ) { $selected_payment_type = $edit_cost->type; $selected_product_type = $edit_cost->product_type; $selected_license_type = $edit_cost->license_type; $selected_cost_tracker_status = $edit_cost->cost_status; $selected_renewal = $edit_cost->renewal_type; $last_renewal = $edit_cost->last_renewal; $selected_payment_method = $edit_cost->payment_method; $slug = $edit_cost->slug; $selected_prod_icon = $edit_cost->cost_icon; $selected_prod_color = $edit_cost->cost_color; $is_plugintheme = 'plugin' === $selected_product_type || 'theme' === $selected_product_type ? true : false; } } $all_defaults = Cost_Tracker_Admin::get_default_fields_values(); $license_types = $all_defaults['license_types']; $product_types = $all_defaults['product_types']; $payment_types = $all_defaults['payment_types']; $payment_methods = $all_defaults['payment_methods']; $renewal_frequency = $all_defaults['renewal_frequency']; $cost_status = $all_defaults['cost_status']; $currency = Cost_Tracker_Utility::get_instance()->get_option( 'currency', 'USD' ); $currency_symbol = Cost_Tracker_Utility::get_instance()->get_currency_symbol( $currency ); $product_icons = Cost_Tracker_Utility::get_product_default_icons(); $cust_prod_src = ''; $cust_prod_icon_file = ''; if ( ! empty( $selected_prod_icon ) ) { if ( false !== strpos( $selected_prod_icon, 'deficon:' ) ) { $selected_default_icon = str_replace( 'deficon:', '', $selected_prod_icon ); $cust_prod_src = ''; } else { $dirs = MainWP_System_Utility::get_mainwp_dir( Cost_Tracker_Settings::$icon_sub_dir, true ); $icon_base = $dirs[1]; $cust_prod_icon_file = $selected_prod_icon; $cust_prod_src = $icon_base . $cust_prod_icon_file; } } // new cost. if ( ! $edit_id ) { $selected_default_icon = 'archive'; $selected_prod_icon = 'deficon:' . $selected_default_icon; $selected_prod_color = '#34424D'; $cust_prod_src = ''; } ?>

name ); ?>

get_product_icon_display( $edit_cost, 'module_cost_tracker_upload_custom_icon_img_display' ); //phpcs:ignore --ok. ?>
>
>
>
>
true ) ); ?>
sites, true ); $sel_groups = json_decode( $edit_cost->groups, true ); $sel_clients = json_decode( $edit_cost->clients, true ); if ( ! is_array( $sel_sites ) ) { $sel_sites = array(); } if ( ! is_array( $sel_groups ) ) { $sel_groups = array(); } if ( ! is_array( $sel_clients ) ) { $sel_clients = array(); } } ?>
secure_request( 'mainwp_module_cost_tracker_upload_product_icon' ); // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $iconfile_slug = isset( $_POST['iconFileSlug'] ) ? sanitize_text_field( wp_unslash( $_POST['iconFileSlug'] ) ) : ''; $delete = isset( $_POST['delete'] ) ? intval( $_POST['delete'] ) : 0; $icon_product_id = isset( $_POST['iconItemId'] ) ? intval( $_POST['iconItemId'] ) : 0; $delnonce = isset( $_POST['delnonce'] ) ? sanitize_key( $_POST['delnonce'] ) : ''; if ( $delete ) { if ( ! MainWP_System_Utility::is_valid_custom_nonce( 'product', $iconfile_slug, $delnonce ) ) { die( 'Invalid nonce!' ); } if ( $icon_product_id ) { $cost = Cost_Tracker_DB::get_instance()->get_cost_tracker_by( 'id', $icon_product_id ); if ( $cost && '' !== $cost->cost_icon && false === strpos( $cost->cost_icon, 'deficon:' ) ) { $update = array( 'id' => $icon_product_id, 'cost_icon' => '', ); Cost_Tracker_DB::get_instance()->update_cost_tracker( $update ); $this->delete_product_icon_file( $cost->cost_icon ); } } elseif ( ! empty( $iconfile_slug ) ) { $this->delete_product_icon_file( $iconfile_slug ); } wp_die( wp_json_encode( array( 'result' => 'success' ) ) ); } $output = isset( $_FILES['mainwp_upload_icon_uploader'] ) ? MainWP_System_Utility::handle_upload_image( Cost_Tracker_Settings::$icon_sub_dir, $_FILES['mainwp_upload_icon_uploader'], 0 ) : null; // phpcs:enable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $uploaded_icon = 'NOTCHANGE'; if ( is_array( $output ) && isset( $output['filename'] ) && ! empty( $output['filename'] ) ) { $uploaded_icon = $output['filename']; } if ( 'NOTCHANGE' !== $uploaded_icon ) { $dirs = MainWP_System_Utility::get_mainwp_dir( Cost_Tracker_Settings::$icon_sub_dir, true ); $cust_icon = $dirs[1] . $uploaded_icon; wp_die( wp_json_encode( array( 'result' => 'success', 'iconfile' => esc_html( $uploaded_icon ), 'iconsrc' => esc_html( $cust_icon ), 'iconimg' => 'Cost custom icon', 'iconnonce' => MainWP_System_Utility::get_custom_nonce( 'product', esc_html( $uploaded_icon ) ), ) ) ); } else { $result = array( 'result' => 'failed', ); $error = MainWP_Post_Handler::get_upload_icon_error( $output ); if ( ! empty( $error ) ) { $result['error'] = esc_html( $error ); } wp_die( wp_json_encode( $result ) ); } } /** * Delete product icon file. * * @param string $cost_icon file icon. */ public function delete_product_icon_file( $cost_icon ) { $valid_file = 0 === validate_file( $cost_icon ) ? true : false; if ( $valid_file ) { $dirs = MainWP_System_Utility::get_mainwp_dir( Cost_Tracker_Settings::$icon_sub_dir, true ); $f = $dirs[0] . $cost_icon; if ( file_exists( $f ) ) { wp_delete_file( $f ); } } } }