Skip to content

Commit ae145d8

Browse files
authored
fix (plugin check): address issues found by Plugin Check (#3391)
Co-authored-by: [email protected] <>
1 parent 81f1002 commit ae145d8

File tree

4 files changed

+55
-20
lines changed

4 files changed

+55
-20
lines changed

plugin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function stackable_php_requirement_activation_check() {
4646
deactivate_plugins( basename( __FILE__ ) );
4747
wp_die(
4848
sprintf(
49-
__( '%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 ),
49+
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 ),
5050
'<strong>',
5151
'</strong><br><br>',
5252
PHP_VERSION,
@@ -70,7 +70,7 @@ function stackable_php_requirement_activation_check() {
7070
function stackable_php_requirement_notice() {
7171
printf(
7272
'<div class="notice notice-error"><p>%s</p></div>',
73-
sprintf( __( '"Stackable" requires PHP version 7.3.0 or higher, but PHP version %s is used on the site.', STACKABLE_I18N ), PHP_VERSION )
73+
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 )
7474
);
7575
}
7676
}
@@ -131,7 +131,7 @@ function stackable_notice_gutenberg_plugin_activated() {
131131
if ( ! $ignore ) {
132132
printf(
133133
'<div class="notice notice-warning is-dismissible stackable_notice_gutenberg_plugin"><p>%s</p>%s</div>',
134-
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>' ),
134+
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>' ),
135135
'<script>( function() {
136136
document.body.addEventListener( "click", function( event ) {
137137
if( event.target.matches( ".notice.stackable_notice_gutenberg_plugin button.notice-dismiss" ) ) {

src/deprecated/v2/design-library/init.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public function register_design_library_route() {
8888
*/
8989
public function delete_design_library_cache() {
9090
global $wpdb;
91+
// This should be okay without using caching since function is used to clear cache.
9192
$transients = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '_transient_stackable_get_block_designs_v2_%'" );
9293

9394
if ( $transients ) {

src/design-library/init.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function delete_cache() {
101101

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

106107
if ( $transients ) {

src/welcome/news.php

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ function stackable_news_feed_links() {
2020

2121
// Get cached.
2222
if ( get_transient( 'stackable_news_feed_links' ) ) {
23-
return get_transient( 'stackable_news_feed_links' );
23+
// We changed the way how news feed is cached, if this is a string,
24+
// then this is still the old way, just discard it.
25+
if ( is_string( get_transient( 'stackable_news_feed_links' ) ) ) {
26+
delete_transient( 'stackable_news_feed_links' );
27+
} else {
28+
return get_transient( 'stackable_news_feed_links' );
29+
}
2430
}
2531

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

42-
ob_start();
48+
$links_data = array();
4349

44-
?><ul><?php
4550
foreach ( $rss_items as $item ) {
4651

4752
$url = add_query_arg(
@@ -60,20 +65,16 @@ function stackable_news_feed_links() {
6065
$title = "🔥 " . $title;
6166
}
6267

63-
?>
64-
<li>
65-
<a href="<?php echo esc_url( $url ) ?>" title="<?php echo esc_attr( $item->get_title() ) ?>" target="stackable">
66-
<?php echo esc_html( $title ) ?>
67-
</a>
68-
<time><?php echo esc_html( $item->get_date( 'M j Y' ) ) ?></time>
69-
</li>
70-
<?php
68+
$links_data[] = array(
69+
'url' => esc_url( $url ),
70+
'title' => esc_attr( $item->get_title() ),
71+
'text' => esc_html( $title ),
72+
'date' => esc_html( $item->get_date( 'M j Y' ) ),
73+
);
7174
}
72-
?></ul><?php
7375

74-
$out = ob_get_clean();
75-
set_transient( 'stackable_news_feed_links', $out, 60 * 60 * 24 );
76-
return $out;
76+
set_transient( 'stackable_news_feed_links', $links_data, 60 * 60 * 24 );
77+
return stackable_news_feed_links_cached( false );
7778
}
7879
}
7980

@@ -84,8 +85,40 @@ function stackable_news_feed_links() {
8485
*
8586
* @return String
8687
*/
87-
function stackable_news_feed_links_cached() {
88-
echo get_transient( 'stackable_news_feed_links' );
88+
function stackable_news_feed_links_cached( $echo = true ) {
89+
$links_data = get_transient( 'stackable_news_feed_links' );
90+
91+
// We changed the way how news feed is cached, if this is a string,
92+
// then this is still the old way, just discard it.
93+
if ( is_string( $links_data ) ) {
94+
delete_transient( 'stackable_news_feed_links' );
95+
return;
96+
}
97+
98+
if ( ! $links_data ) {
99+
return;
100+
}
101+
102+
ob_start();
103+
?>
104+
<ul>
105+
<?php foreach ( $links_data as $link ) : ?>
106+
<li>
107+
<a href="<?php echo esc_url( $link['url'] ) ?>" title="<?php echo esc_attr( $link['title'] ) ?>" target="stackable">
108+
<?php echo esc_html( $link['text'] ) ?>
109+
</a>
110+
<time><?php echo esc_html( $link['date'] ) ?></time>
111+
</li>
112+
<?php endforeach; ?>
113+
</ul>
114+
<?php
115+
116+
$output = ob_get_clean();
117+
if ( $echo ) {
118+
echo $output;
119+
} else {
120+
return $output;
121+
}
89122
}
90123
}
91124

0 commit comments

Comments
 (0)