Skip to content

Commit

Permalink
fix (plugin check): address issues found by Plugin Check (#3391)
Browse files Browse the repository at this point in the history
Co-authored-by: bfintal@gmail.com <>
  • Loading branch information
bfintal authored Jan 15, 2025
1 parent 81f1002 commit ae145d8
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 20 deletions.
6 changes: 3 additions & 3 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function stackable_php_requirement_activation_check() {
deactivate_plugins( basename( __FILE__ ) );
wp_die(
sprintf(
__( '%s"Stackable" can not be activated. %s It requires PHP version 7.3.0 or higher, but PHP version %s is used on the site. Please upgrade your PHP version first ✌️ %s Back %s', STACKABLE_I18N ),
esc_html__( '%s"Stackable" can not be activated. %s It requires PHP version 7.3.0 or higher, but PHP version %s is used on the site. Please upgrade your PHP version first ✌️ %s Back %s', STACKABLE_I18N ),
'<strong>',
'</strong><br><br>',
PHP_VERSION,
Expand All @@ -70,7 +70,7 @@ function stackable_php_requirement_activation_check() {
function stackable_php_requirement_notice() {
printf(
'<div class="notice notice-error"><p>%s</p></div>',
sprintf( __( '"Stackable" requires PHP version 7.3.0 or higher, but PHP version %s is used on the site.', STACKABLE_I18N ), PHP_VERSION )
sprintf( esc_html__( '"Stackable" requires PHP version 7.3.0 or higher, but PHP version %s is used on the site.', STACKABLE_I18N ), PHP_VERSION )
);
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ function stackable_notice_gutenberg_plugin_activated() {
if ( ! $ignore ) {
printf(
'<div class="notice notice-warning is-dismissible stackable_notice_gutenberg_plugin"><p>%s</p>%s</div>',
sprintf( __( '%sStackable Notice%s: We noticed that the Gutenberg plugin is active! Please be aware the Gutenberg plugin is used to try out the new Block Editor features, and Stackable might not be compatible with it. Click the close button on the side to dismiss this notice.', STACKABLE_I18N ), '<strong>', '</strong>' ),
sprintf( esc_html__( '%sStackable Notice%s: We noticed that the Gutenberg plugin is active! Please be aware the Gutenberg plugin is used to try out the new Block Editor features, and Stackable might not be compatible with it. Click the close button on the side to dismiss this notice.', STACKABLE_I18N ), '<strong>', '</strong>' ),
'<script>( function() {
document.body.addEventListener( "click", function( event ) {
if( event.target.matches( ".notice.stackable_notice_gutenberg_plugin button.notice-dismiss" ) ) {
Expand Down
1 change: 1 addition & 0 deletions src/deprecated/v2/design-library/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function register_design_library_route() {
*/
public function delete_design_library_cache() {
global $wpdb;
// This should be okay without using caching since function is used to clear cache.
$transients = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '_transient_stackable_get_block_designs_v2_%'" );

if ( $transients ) {
Expand Down
1 change: 1 addition & 0 deletions src/design-library/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function delete_cache() {

// Delete designs.
global $wpdb;
// This should be okay without using caching since function is used to clear cache.
$transients = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '_transient_stackable_get_design_%'" );

if ( $transients ) {
Expand Down
67 changes: 50 additions & 17 deletions src/welcome/news.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ function stackable_news_feed_links() {

// Get cached.
if ( get_transient( 'stackable_news_feed_links' ) ) {
return get_transient( 'stackable_news_feed_links' );
// We changed the way how news feed is cached, if this is a string,
// then this is still the old way, just discard it.
if ( is_string( get_transient( 'stackable_news_feed_links' ) ) ) {
delete_transient( 'stackable_news_feed_links' );
} else {
return get_transient( 'stackable_news_feed_links' );
}
}

include_once( ABSPATH . WPINC . '/feed.php' );
Expand All @@ -39,9 +45,8 @@ function stackable_news_feed_links() {
return;
}

ob_start();
$links_data = array();

?><ul><?php
foreach ( $rss_items as $item ) {

$url = add_query_arg(
Expand All @@ -60,20 +65,16 @@ function stackable_news_feed_links() {
$title = "🔥 " . $title;
}

?>
<li>
<a href="<?php echo esc_url( $url ) ?>" title="<?php echo esc_attr( $item->get_title() ) ?>" target="stackable">
<?php echo esc_html( $title ) ?>
</a>
<time><?php echo esc_html( $item->get_date( 'M j Y' ) ) ?></time>
</li>
<?php
$links_data[] = array(
'url' => esc_url( $url ),
'title' => esc_attr( $item->get_title() ),
'text' => esc_html( $title ),
'date' => esc_html( $item->get_date( 'M j Y' ) ),
);
}
?></ul><?php

$out = ob_get_clean();
set_transient( 'stackable_news_feed_links', $out, 60 * 60 * 24 );
return $out;
set_transient( 'stackable_news_feed_links', $links_data, 60 * 60 * 24 );
return stackable_news_feed_links_cached( false );
}
}

Expand All @@ -84,8 +85,40 @@ function stackable_news_feed_links() {
*
* @return String
*/
function stackable_news_feed_links_cached() {
echo get_transient( 'stackable_news_feed_links' );
function stackable_news_feed_links_cached( $echo = true ) {
$links_data = get_transient( 'stackable_news_feed_links' );

// We changed the way how news feed is cached, if this is a string,
// then this is still the old way, just discard it.
if ( is_string( $links_data ) ) {
delete_transient( 'stackable_news_feed_links' );
return;
}

if ( ! $links_data ) {
return;
}

ob_start();
?>
<ul>
<?php foreach ( $links_data as $link ) : ?>
<li>
<a href="<?php echo esc_url( $link['url'] ) ?>" title="<?php echo esc_attr( $link['title'] ) ?>" target="stackable">
<?php echo esc_html( $link['text'] ) ?>
</a>
<time><?php echo esc_html( $link['date'] ) ?></time>
</li>
<?php endforeach; ?>
</ul>
<?php

$output = ob_get_clean();
if ( $echo ) {
echo $output;
} else {
return $output;
}
}
}

Expand Down

0 comments on commit ae145d8

Please sign in to comment.