Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion includes/class-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,20 @@ protected function add_actions() {
* @param Tailor_Elements $element_manager
*/
public function register_widgets( $element_manager ) {
global $wp_widget_factory;
// read and cache the categories and post tags to save on performance.
// previously we did this for every element which is heavy if there are many elements and
// many categories/tags
$categories = wp_cache_get('tailor_cached_categories');
if (!$categories) {
wp_cache_add('tailor_cached_categories', tailor_get_terms());
}

$post_tags = wp_cache_get('tailor_cached_post_tags');
if (!$post_tags) {
wp_cache_add('tailor_cached_post_tags', tailor_get_terms('post_tag'));
}

global $wp_widget_factory;
foreach ( $wp_widget_factory->widgets as $widget_class_name => $wp_widget ) {

if ( ! array_key_exists( 'description', $wp_widget->widget_options ) ) {
Expand Down
8 changes: 8 additions & 0 deletions includes/helpers/helpers-color.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,19 @@ function tailor_modify_colorpicker( $control_args ) {
'8' => '#8224e3', // Purple
);

$control_args = wp_cache_get('tailor_colour_control_args');

if ($control_args['palettes']) {
return $control_args;
}

$control_args['palettes'] = array();
foreach ( $colors as $number => $default ) {
$control_args['palettes'][] = sanitize_hex_color( get_theme_mod( "tailor_color_{$number}", $default ) );
}

wp_cache_add('tailor_colour_control_args', $control_args);

return $control_args;
}

Expand Down
Loading