Skip to content

Commit

Permalink
Merge pull request #48 from AmanWebDev2/main
Browse files Browse the repository at this point in the history
Added feature :Add text color to settings #47
  • Loading branch information
dmotts authored Oct 20, 2024
2 parents 665e475 + 4518ab2 commit e82d56a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions includes/frontend-custom-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
function vacw_add_custom_color_to_chatbot() {
// Retrieve the theme color from the settings, with a fallback to the default
$theme_color = esc_attr(get_option('vacw_theme_color', '#dbe200'));
$text_color = esc_attr(get_option('vacw_text_color', '#000000'));

// Output dynamic CSS to apply the theme color to the chatbot widget
echo "<style>
Expand All @@ -17,6 +18,9 @@ function vacw_add_custom_color_to_chatbot() {
.main-title { background-color: {$theme_color}; }
button.input-send svg { fill: {$theme_color}; }
.line { background-color: {$theme_color}; }
.chat-message-received { color: {$text_color}; }
.chat-message-sent { color: {$text_color}; }
.main-title { color: {$text_color}; }
</style>";
}
add_action('wp_footer', 'vacw_add_custom_color_to_chatbot');
11 changes: 11 additions & 0 deletions includes/settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,16 @@ function vacw_register_settings() {
'sanitize_callback' => 'sanitize_hex_color' // Sanitize hex color value
)
);

// Text Color field (with sanitization for hex color values)
register_setting(
'vacw_settings_group',
'vacw_text_color',
array(
'type' => 'string',
'default' => '#000000', // Default text color
'sanitize_callback' => 'sanitize_hex_color' // Sanitize hex color value
)
);
}
add_action('admin_init', 'vacw_register_settings');
12 changes: 12 additions & 0 deletions includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ class="rounded-circle me-3"
</p>
</div>

<!-- Add a color picker option for text -->
<div class="mb-3">
<label for="vacw_text_color" class="form-label">
<?php _e('Text Color', 'customer-support-bot'); ?>
</label>
<input type="text" name="vacw_text_color" id="vacw_text_color" class="vacw-color-field"
value="<?php echo esc_attr(get_option('vacw_text_color', '#000000')); ?>" />
<p class="form-text text-muted">
<?php _e('Choose the text color for the chat widget.', 'customer-support-bot'); ?>
</p>
</div>

<!-- Save Button -->
<?php submit_button(__('Save Changes', 'customer-support-bot'), 'btn btn-primary'); ?>
</form>
Expand Down

0 comments on commit e82d56a

Please sign in to comment.