get_id(); $labels = AWL_Helpers::get_awl_labels(); $labels_to_show = array(); foreach ( $labels as $label_id ) { $label_options = AWL()->get_label_settings( $label_id ); $label_is_active = isset( $label_options['awl_label_status'] ) ? $label_options['awl_label_status']['status'] : true; $label_conditions = isset( $label_options['conditions'] ) ? $label_options['conditions'] : false; $label_settings = isset( $label_options['settings'] ) ? $label_options['settings'] : false; if ( $label_is_active && $label_conditions && $label_settings ) { $label_settings['id'] = $label_id; $label_position_type = $label_settings['position_type']; if ( $position_type === 'all' || $label_position_type === $position_type ) { $match_condition = AWL_Helpers::match_conditions( $label_conditions ); $match_condition = apply_filters( 'awl_show_label_for_product', $match_condition, $product, $label_id ); if ( $match_condition ) { $label_settings['position_type'] = 'before_title'; $label_settings['position'] = 'left_top'; $label_settings['position_x'] = 'left'; $label_settings['margin']['top'] = '0'; $label_settings['margin']['right'] = '0'; $label_settings['margin']['bottom'] = '0'; $label_settings['margin']['left'] = '0'; $labels_to_show[] = $label_settings; } } } } if ( ! empty( $labels_to_show ) ) { $label_html .= AWL_Helpers::get_label_html( $labels_to_show, 'before_title' ); } if ( $product_force ) { wp_reset_postdata(); } return $label_html; } } /** * Get label markup by label ID * @since 1.45 * @param integer $label_id Labels ID * @param string $position_type Labels position type * @return string */ if ( ! function_exists( 'awl_get_label_html_by_id' ) ) { function awl_get_label_html_by_id( $label_id, $label_position_type = 'before_title' ) { $label_options = AWL()->get_label_settings( $label_id ); $label_settings = isset( $label_options['settings'] ) ? $label_options['settings'] : false; $label_html = ''; if ( $label_settings ) { $label_settings['position_type'] = $label_position_type; $label_settings['position'] = 'left_top'; $label_settings['position_x'] = 'left'; $label_settings['margin']['top'] = '0'; $label_settings['margin']['right'] = '0'; $label_settings['margin']['bottom'] = '0'; $label_settings['margin']['left'] = '0'; $labels = array( $label_settings ); $global_settings = AWL()->get_settings(); $label_html_obj = new AWL_Label_View( $labels, $label_position_type, $global_settings ); $label_html = $label_html_obj->html(); } return $label_html; } }