Skip to content

Commit 48b2280

Browse files
update
1 parent 575453b commit 48b2280

File tree

3 files changed

+218
-1
lines changed

3 files changed

+218
-1
lines changed

class-plugin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ private function include_files()
867867
include_once WCF_ADDONS_PATH . 'inc/trait-wcf-button.php';
868868
include_once WCF_ADDONS_PATH . 'inc/trait-wcf-slider.php';
869869
include_once WCF_ADDONS_PATH . 'inc/post-rating-handler.php';
870+
include_once WCF_ADDONS_PATH . 'inc/category-fields.php';
870871

871872
//extensions
872873
$this->register_extensions();

inc/category-fields.php

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
<?php
2+
3+
add_action('category_add_form_fields', 'aae_add_category_light_custom_fields');
4+
add_action('category_edit_form_fields', 'aae_edit_category_light_custom_fields');
5+
6+
function aae_add_category_light_custom_fields($taxonomy)
7+
{
8+
?>
9+
<div class="form-field">
10+
<label
11+
for="aae_cate_additional_text"><?php echo esc_html__('Additional Text', 'animation-addons-for-elementor-pro'); ?></label>
12+
<textarea name="aae_cate_additional_text" id="aae_cate_additional_text" rows="2"></textarea>
13+
<p class="description">
14+
<?php echo esc_html__('Enter additional information for this category.', 'animation-addons-for-elementor-pro'); ?>
15+
</p>
16+
</div>
17+
<div class="form-field">
18+
<label
19+
for="aae_category_image"><?php echo esc_html__('Upload Image', 'animation-addons-for-elementor-pro'); ?></label>
20+
<input type="button" class="button aae-category-image-upload" value="Upload Image">
21+
<input type="hidden" name="aae_category_image" id="aae_category_image" value="">
22+
<div id="aae_category_image_preview"></div>
23+
<p class="description">
24+
<?php echo esc_html__('Upload an image for this category.', 'animation-addons-for-elementor-pro'); ?></p>
25+
</div>
26+
<div class="form-field">
27+
<label
28+
for="aae_category_icon"><?php echo esc_html__('Upload Icon', 'animation-addons-for-elementor-pro'); ?></label>
29+
<input type="button" class="button aae-category-icon-upload" value="Upload Icon">
30+
<input type="hidden" name="aae_category_icon" id="aae_category_icon" value="">
31+
<div id="aae_category_icon_preview"></div>
32+
<p class="description">
33+
<?php echo esc_html__('Upload an image as a icon for this category.', 'animation-addons-for-elementor-pro'); ?>
34+
</p>
35+
</div>
36+
<div class="form-field">
37+
<label for="aae_cat_color"><?php echo esc_html__('Color', 'animation-addons-for-elementor-pro'); ?></label>
38+
<input type="color" class="cat-color-picker" data-default-color="#ffffff">
39+
<input type="hidden" name="aae_cat_color" id="aae_cat_color" value="">
40+
</div>
41+
<div class="form-field">
42+
<label
43+
for="aae_cat_bg_color"><?php echo esc_html__('Background Color', 'animation-addons-for-elementor-pro'); ?></label>
44+
<input type="color" class="color-picker" data-default-color="#ffffff">
45+
<input type="hidden" name="aae_cat_bg_color" id="aae_cat_bg_color" value="">
46+
</div>
47+
<?php
48+
}
49+
50+
function aae_edit_category_light_custom_fields($term)
51+
{
52+
$category_text = get_term_meta($term->term_id, 'aae_cate_additional_text', true);
53+
$category_image = get_term_meta($term->term_id, 'aae_category_image', true);
54+
$category_icon = get_term_meta($term->term_id, 'aae_category_icon', true);
55+
$background_color = get_term_meta($term->term_id, 'aae_cat_bg_color', true);
56+
$cat_color = get_term_meta($term->term_id, 'aae_cat_color', true);
57+
?>
58+
<tr class="form-field">
59+
<th scope="row" valign="top"><label for="aae_cate_additional_text">Additional Text</label></th>
60+
<td>
61+
<textarea name="aae_cate_additional_text" id="aae_cate_additional_text"
62+
rows="2"><?php echo esc_textarea($category_text); ?></textarea>
63+
<p class="description">
64+
<?php echo esc_html__('Enter additional information for this category.', 'animation-addons-for-elementor-pro'); ?>
65+
</p>
66+
</td>
67+
</tr>
68+
<tr class="form-field">
69+
<th scope="row" valign="top"><label
70+
for="aae_category_image"><?php echo esc_html__('Upload Image', 'animation-addons-for-elementor-pro'); ?></label>
71+
</th>
72+
<td>
73+
<input type="button" class="button aae-category-image-upload" value="Upload Image">
74+
<input type="hidden" name="aae_category_image" id="aae_category_image"
75+
value="<?php echo esc_url($category_image); ?>">
76+
<div id="aae_category_image_preview">
77+
<?php if ($category_image): ?>
78+
<img src="<?php echo esc_url($category_image); ?>" alt="Category Image" style="max-width: 150px;">
79+
<?php endif; ?>
80+
</div>
81+
<p class="description">
82+
<?php echo esc_html__('Update the image for this category.', 'animation-addons-for-elementor-pro'); ?></p>
83+
</td>
84+
</tr>
85+
<tr class="form-field">
86+
<th scope="row" valign="top"><label
87+
for="aae_category_icon"><?php echo esc_html__('Upload Icon', 'animation-addons-for-elementor-pro'); ?></label>
88+
</th>
89+
<td>
90+
<input type="button" class="button aae-category-icon-upload" value="Upload Icon">
91+
<input type="hidden" name="aae_category_icon" id="aae_category_icon"
92+
value="<?php echo esc_url($category_icon); ?>">
93+
<div id="aae_category_icon_preview">
94+
<?php if ($category_icon): ?>
95+
<img src="<?php echo esc_url($category_icon); ?>" alt="Category Icon" style="max-width: 50px;">
96+
<?php endif; ?>
97+
</div>
98+
<p class="description">
99+
<?php echo esc_html__('Update the icon for this category.', 'animation-addons-for-elementor-pro'); ?></p>
100+
</td>
101+
</tr>
102+
103+
<tr class="form-field">
104+
<th scope="row" valign="top"><label for="aae_cat_color">Color</label></th>
105+
<td>
106+
<input type="color" name="aae_cat_color" id="aae_cat_color" value="<?php echo $cat_color; ?>">
107+
</td>
108+
</tr>
109+
110+
<tr class="form-field">
111+
<th scope="row" valign="top"><label for="aae_cat_bg_color">Background Color</label></th>
112+
<td>
113+
<input type="color" name="aae_cat_bg_color" id="aae_cat_bg_color" value="<?php echo $background_color; ?>">
114+
</td>
115+
</tr>
116+
<?php
117+
}
118+
119+
add_action('edited_category', 'aae_save_category_light_custom_fields');
120+
add_action('create_category', 'aae_save_category_light_custom_fields');
121+
122+
function aae_save_category_light_custom_fields($term_id)
123+
{
124+
if (isset($_POST['aae_cate_additional_text'])) {
125+
update_term_meta($term_id, 'aae_cate_additional_text', sanitize_textarea_field($_POST['aae_cate_additional_text']));
126+
}
127+
if (isset($_POST['aae_category_image'])) {
128+
update_term_meta($term_id, 'aae_category_image', esc_url_raw($_POST['aae_category_image']));
129+
}
130+
if (isset($_POST['aae_category_icon'])) {
131+
update_term_meta($term_id, 'aae_category_icon', esc_url_raw($_POST['aae_category_icon']));
132+
}
133+
if (isset($_POST['aae_cat_color'])) {
134+
update_term_meta($term_id, 'aae_cat_color', esc_url_raw($_POST['aae_cat_color']));
135+
}
136+
if (isset($_POST['aae_cat_bg_color'])) {
137+
update_term_meta($term_id, 'aae_cat_bg_color', esc_url_raw($_POST['aae_cat_bg_color']));
138+
}
139+
}
140+
141+
142+
add_action('admin_head', 'aae_inline_category_light_media_uploader');
143+
function aae_inline_category_light_media_uploader()
144+
{
145+
if (! isset($_GET['taxonomy']) || $_GET['taxonomy'] !== 'category') {
146+
return; // Only load on the category taxonomy pages
147+
}
148+
wp_enqueue_media();
149+
?>
150+
<script>
151+
jQuery(document).ready(function($) {
152+
var mediaUploader;
153+
154+
function openMediaUploader(button, inputField, previewContainer) {
155+
mediaUploader = wp.media({
156+
title: 'Choose Image',
157+
button: {
158+
text: 'Use this image'
159+
},
160+
multiple: false
161+
});
162+
163+
mediaUploader.on('select', function() {
164+
var attachment = mediaUploader.state().get('selection').first().toJSON();
165+
$(inputField).val(attachment.url);
166+
$(previewContainer).html('<img src="' + attachment.url + '" style="max-width: 100px;">');
167+
});
168+
169+
mediaUploader.open();
170+
}
171+
172+
// Image Upload
173+
$('.aae-category-image-upload').click(function(e) {
174+
e.preventDefault();
175+
openMediaUploader(this, '#aae_category_image', '#aae_category_image_preview');
176+
});
177+
178+
// Icon Upload
179+
$('.aae-category-icon-upload').click(function(e) {
180+
e.preventDefault();
181+
openMediaUploader(this, '#aae_category_icon', '#aae_category_icon_preview');
182+
});
183+
});
184+
</script>
185+
<?php
186+
}
187+
188+
189+
function aae_addon_tax_category_light_styles()
190+
{
191+
$custom_css = '';
192+
$categories = get_terms(array(
193+
'taxonomy' => 'category',
194+
'hide_empty' => false,
195+
));
196+
197+
if (! empty($categories) && ! is_wp_error($categories)) {
198+
foreach ($categories as $category) {
199+
$background_color = get_term_meta($category->term_id, 'aae_cat_bg_color', true);
200+
$cat_color = get_term_meta($category->term_id, 'aae_cat_color', true);
201+
if ($background_color) {
202+
$custom_css .= sprintf('
203+
.aae-cat-%1$s {
204+
background-color: %2$s;
205+
color: %3$s;
206+
}', $category->slug, $background_color, $cat_color);
207+
}
208+
}
209+
}
210+
211+
if ($custom_css != '') {
212+
wp_add_inline_style('wcf--addons', $custom_css);
213+
}
214+
}
215+
216+
add_action('wp_enqueue_scripts', 'aae_addon_tax_category_light_styles', 20);

widgets/advance-accordion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected function register_controls()
140140
'default' => '',
141141
'options' => [
142142
'' => esc_html__('Default', 'animation-addons-for-elementor'),
143-
'2' => esc_html__('Two', 'animation-addons-for-elementor'),
143+
'2' => esc_html__('One', 'animation-addons-for-elementor'),
144144
],
145145
'separator' => 'after',
146146
]

0 commit comments

Comments
 (0)