id ) ) { return; } $extra = $this->extra; $placeholder = $extra['placeholder'] ?? ''; $class = ! empty( $extra['class'] ) ? 'class="' . esc_attr( $extra['class'] ) . '"' : ''; $style = ! empty( $extra['style'] ) ? 'style="' . esc_attr( $extra['style'] ) . '"' : ''; $wrapper_class = ! empty( $extra['wrapper_class'] ) ? esc_attr( $extra['wrapper_class'] ) : ''; $meta_exists = LP_Database::getInstance()->check_key_postmeta_exists( $thepostid, $this->id ); $meta = get_post_meta( $thepostid, $this->id, true ); $value = $meta_exists ? $meta : ( $this->default ?? '' ); $value = esc_attr( $extra['value'] ?? $value ); $type_input = $extra['type_input'] ?? 'text'; $desc_tip = $extra['desc_tip'] ?? ''; // Custom attribute handling $custom_attributes = array(); if ( ! empty( $extra['custom_attributes'] ) && is_array( $extra['custom_attributes'] ) ) { foreach ( $extra['custom_attributes'] as $attribute => $custom_attribute ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $custom_attribute ) . '"'; } } echo '
'; echo ' '; if ( ! empty( $this->description ) ) { echo '

'; echo '' . wp_kses_post( $this->description ) . ''; if ( ! empty( $desc_tip ) ) { learn_press_quick_tip( $desc_tip ); } echo '

'; } echo '
'; } public function save( $post_id ) { $type_input = $this->extra['type_input'] ?? 'text'; $meta_value = isset( $_POST[ $this->id ] ) ? wp_unslash( $_POST[ $this->id ] ) : $this->default; if ( $meta_value !== '' && $type_input === 'number' ) { $step = isset( $this->extra['custom_attributes']['step'] ) ? $this->extra['custom_attributes']['step'] : ''; if ( floatval( $step ) !== 1 ) { $meta_value = floatval( $meta_value ); } else { $meta_value = absint( $meta_value ); } } else { $meta_value = LP_Helper::sanitize_params_submitted( $meta_value ); } update_post_meta( $post_id, $this->id, $meta_value ); } }