Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cache data issue elementor widgets #1005

Merged
merged 3 commits into from
Dec 12, 2024
Merged
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
4 changes: 2 additions & 2 deletions includes/abstract/feedzy-rss-feeds-admin-abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public function feedzy_rss( $atts, $content = '' ) {
}
$attributes .= 'data-' . esc_attr( $key ) . '="' . esc_attr( $val ) . '"';
}
$lazyload_cache_key = md5( sprintf( 'feedzy-lazy-%s', ( is_array( $feed_url ) ? implode( ',', $feed_url ) : $feed_url ) ) );
$lazyload_cache_key = md5( sprintf( 'feedzy-lazy-%s-%d-%d', ( is_array( $feed_url ) ? implode( ',', $feed_url ) : $feed_url ), ( ! empty( $sc['max'] ) ? $sc['max'] : 1 ), ( ! empty( $sc['offset'] ) ? $sc['offset'] : 0 ) ) );
$content = get_transient( $lazyload_cache_key );

// the first time the shortcode is being called it will not have any content.
Expand Down Expand Up @@ -577,7 +577,7 @@ public function feedzy_lazy_load( $data ) {
$content = $this->render_content( $sc, $feed, $feed_url, '' );

// save the content as a transient so that whenever the feed is refreshed next, this stale content is displayed first.
$lazyload_cache_key = md5( sprintf( 'feedzy-lazy-%s', ( is_array( $feed_url ) ? implode( ',', $feed_url ) : $feed_url ) ) );
$lazyload_cache_key = md5( sprintf( 'feedzy-lazy-%s-%d-%d', ( is_array( $feed_url ) ? implode( ',', $feed_url ) : $feed_url ), ( ! empty( $sc['max'] ) ? $sc['max'] : 1 ), ( ! empty( $sc['offset'] ) ? $sc['offset'] : 0 ) ) );
set_transient( $lazyload_cache_key, $content, apply_filters( 'feedzy_lazyload_cache_time', DAY_IN_SECONDS, $feed_url ) );

wp_send_json_success( array( 'content' => $content ) );
Expand Down
10 changes: 0 additions & 10 deletions includes/admin/feedzy-wp-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ public static function get_instance() {
return self::$instance;
}

/**
* The register method for registering this widget class
*
* @since 3.0.0
* @access public
*/
public function registerWidget() {
register_widget( 'feedzy_wp_widget' );
}

/**
* The widget form creation
*
Expand Down
9 changes: 7 additions & 2 deletions includes/feedzy-rss-feeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,13 @@ private function define_admin_hooks() {

add_shortcode( 'feedzy-rss', array( self::$instance->admin, 'feedzy_rss' ) );

$plugin_widget = new feedzy_wp_widget();
self::$instance->loader->add_action( 'widgets_init', $plugin_widget, 'registerWidget', 10 );
add_action(
'widgets_init',
function () {
register_widget( 'feedzy_wp_widget' );
}
);

self::$instance->loader->add_action( 'rest_api_init', self::$instance->admin, 'rest_route', 10 );

// Wizard screen setup.
Expand Down
Loading