| @@ -173,8 +173,9 @@ | ||
| 173 | 173 | $this->add_group_control( |
| 174 | 174 | Group_Control_Image_Size::get_type(), |
| 175 | 175 | [ |
| 176 | 176 | 'name' => 'cat_image_size', |
| 177 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 177 | 178 | 'exclude' => [ 'custom' ], |
| 178 | 179 | 'include' => [], |
| 179 | 180 | 'default' => 'thumbnail', |
| 180 | 181 | 'condition' => [ |
| @@ -826,15 +827,19 @@ | ||
| 826 | 827 | |
| 827 | 828 | public function render() { |
| 828 | 829 | $settings = $this->get_settings_for_display(); |
| 829 | 830 | $image_settings = ultimate_post_kit_option( 'category_image', 'ultimate_post_kit_other_settings', 'off' ); |
| 831 | + $taxonomy = ! empty( $settings['taxonomy'] ) ? $settings['taxonomy'] : 'category'; | |
| 832 | + $taxonomy_object = get_taxonomy( $taxonomy ); | |
| 833 | + $taxonomy_label = $taxonomy_object ? $taxonomy_object->labels->name : ucwords( str_replace( [ '-', '_' ], ' ', $taxonomy ) ); | |
| 830 | 834 | $orderby = $settings['orderby']; |
| 831 | 835 | $categories = get_categories( |
| 832 | 836 | [ |
| 833 | - 'taxonomy' => $settings["taxonomy"], | |
| 837 | + 'taxonomy' => $taxonomy, | |
| 834 | 838 | 'orderby' => $orderby === 'rand' ? 'name' : $orderby, |
| 835 | 839 | 'order' => $settings["order"], |
| 836 | 840 | 'hide_empty' => 0, |
| 841 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 837 | 842 | 'exclude' => explode( ',', esc_attr( $settings["exclude"] ) ), |
| 838 | 843 | 'parent' => $settings["parent"], |
| 839 | 844 | ] |
| 840 | 845 | ); |
| @@ -867,9 +872,10 @@ | ||
| 867 | 872 | $multiple_bg = explode( ',', rtrim( $multi_bg, ',' ) ); |
| 868 | 873 | $total_category = count( $categories ); |
| 869 | 874 | |
| 870 | 875 | // re-creating array for the multiple colors |
| 871 | - $jCount = count( $multiple_bg ); | |
| 876 | + $multiple_bg_create = []; | |
| 877 | + $jCount = count( $multiple_bg ); | |
| 872 | 878 | $j = 0; |
| 873 | 879 | for ( $i = 0; $i < $total_category; $i++ ) { |
| 874 | 880 | if ( $j == $jCount ) { |
| 875 | 881 | $j = 0; |
| @@ -890,9 +896,9 @@ | ||
| 890 | 896 | $category_image_id = get_term_meta( $cat->cat_ID, 'upk-category-image-id', true ); |
| 891 | 897 | |
| 892 | 898 | if ( ! empty( $category_image_id ) ) { |
| 893 | 899 | $category_url = wp_get_attachment_image_url( $category_image_id, $settings['cat_image_size_size'] ); |
| 894 | - $category_image = '<div class="upk-category-image"><img src="' . $category_url . '" alt=""></div>'; | |
| 900 | + $category_image = '<div class="upk-category-image"><img src="' . esc_url( $category_url ) . '" alt="' . esc_attr( $cat->cat_name ) . '"></div>'; | |
| 895 | 901 | } else { |
| 896 | 902 | $category_image = ''; |
| 897 | 903 | } |
| 898 | 904 | //=============================== |
| @@ -921,9 +927,9 @@ | ||
| 921 | 927 | </span> |
| 922 | 928 | |
| 923 | 929 | <?php if ( ! empty( $cat->category_description ) and $settings['show_text'] == 'yes' ) : ?> |
| 924 | 930 | <span class="upk-category-text"> |
| 925 | - <?php echo wp_trim_words( $cat->category_description, $settings['text_length'] ); ?> | |
| 931 | + <?php echo esc_html( wp_trim_words( $cat->category_description, $settings['text_length'] ) ); ?> | |
| 926 | 932 | </span> |
| 927 | 933 | <?php endif; ?> |
| 928 | 934 | |
| 929 | 935 | <?php if ( $settings['show_count'] == 'yes' ) : ?> |
| @@ -955,9 +961,13 @@ | ||
| 955 | 961 | </div> |
| 956 | 962 | <?php |
| 957 | 963 | else : |
| 958 | 964 | |
| 959 | - echo '<div class="upk-alert">' . esc_html__( 'Category Not Found!', 'ultimate-post-kit' ) . '</div>'; | |
| 965 | + echo '<div class="upk-alert">' . esc_html( sprintf( | |
| 966 | + /* translators: %s: taxonomy label */ | |
| 967 | + __( '%s Categories Not Found!', 'ultimate-post-kit' ), | |
| 968 | + $taxonomy_label | |
| 969 | + ) ) . '</div>'; | |
| 960 | 970 | |
| 961 | 971 | endif; |
| 962 | 972 | } |
| 963 | 973 | } |