Skip to content

Commit c71003d

Browse files
committed
Rewrites the latest feed label feature in the Feeds meta box to not load all registered add-ons. Instead, load add-ons as their slugs are encountered.
1 parent cdb1737 commit c71003d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

includes/class-gravityforms-power-boost.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,15 @@ public static function meta_box_feeds( $args, $metabox ) {
306306
<p class="description"><?php esc_html_e( 'This form has no active feeds.', 'power-boost-for-gravity-forms' ); ?></p>
307307
<?php
308308
} else {
309-
// We want to look up add-on names, so get all of them.
310-
$addons = GFAddOn::get_registered_addons( true, true );
309+
// Cache addon instances as we encounter them to avoid reloading.
310+
$addons = array();
311311
foreach ( $feeds as $feed ) {
312+
// Load addon instance only if we haven't encountered this addon yet.
313+
$addon_slug = $feed['addon_slug'];
314+
if ( ! isset( $addons[ $addon_slug ] ) ) {
315+
$addons[ $addon_slug ] = GFAddOn::get_addon_by_slug( $addon_slug );
316+
}
317+
312318
$feed_name = '';
313319
if ( ! empty( rgars( $feed, 'meta/feed_name' ) ) ) {
314320
$feed_name = rgars( $feed, 'meta/feed_name' );
@@ -320,9 +326,9 @@ public static function meta_box_feeds( $args, $metabox ) {
320326
} else {
321327
$feed_name = __( 'Unnamed: ', 'power-boost-for-gravity-forms' ) . rgar( $feed, 'addon_slug' );
322328
}
323-
$addon_title = $addons[ $feed['addon_slug'] ]->plugin_page_title();
324-
$short_title = $addons[ $feed['addon_slug'] ]->get_short_title();
325-
$title_attribute = $addon_title . ', ' . $feed['addon_slug'];
329+
$addon_title = isset( $addons[ $addon_slug ] ) ? $addons[ $addon_slug ]->plugin_page_title() : $addon_slug;
330+
$short_title = isset( $addons[ $addon_slug ] ) ? $addons[ $addon_slug ]->get_short_title() : $addon_slug;
331+
$title_attribute = $addon_title . ', ' . $addon_slug;
326332
?>
327333
<input type="checkbox" class="gform_feeds" value="<?php echo esc_attr( $feed['id'] ); ?>" id="feed_<?php echo esc_attr( $feed['id'] ); ?>" title="<?php echo esc_attr( $title_attribute ); ?>" />
328334
<label for="feed_<?php echo esc_attr( $feed['id'] ); ?>" title="<?php echo esc_attr( $title_attribute ); ?>"><?php echo esc_html( $short_title . ': ' . $feed_name ); ?></label>

0 commit comments

Comments
 (0)