@o"`F0t€"`à[‰"`PF\`€Ž"`€—€"`¾ù°‹"`G€Ž"`pB‰"`2†"`àQ}`<X|Ž"`p"`XF\`Pñ‰"`€—€"`>®Y`B€Ž"`C‰"`2†"`!¨H@Ž"`ÈÅ‹"``F\`hñ‰"`€—€"`E{ÀS}`:IŽ"`ÀC‰"`2†"`!8F„ƒ"`@"3$`hF\`€—€"`„¥À0‰"`*ÀŒƒ"`ˆŠ"`2†"` &3$` H&Xˆ"`xF\`pF\`ÐuQ`€—€"`®Ê@öŠ"`%À\ˆ"` Š"`2†"`€'3$`0&{R`€}2$`€F\`àuQ`€—€"`Õì["`ÀR`!ØŠ"`2†"` P}`0$‚R`€ñ‰"`ˆF\`€—€"`ù^[`€†R`  E‰"`2†"``w2$`x0ž‡"`ðuQ`F\`€—€"`&`û-`+¤‡"` ðŠ"`2†"`u2$`h&‰R`vQ`˜F\`€—€"`-;ú-`#ÀR`!ÐE‰"`2†"`àŽ"`¨/`ˆ"`¨F\` F\`€—€"`FX€1‰"`"àeˆ"`!Š"`2†"` Ž"`˜L`Ž"`vQ`°F\`À Ž"`€—€"`c„@2‰"`R€iŽ"`!èŠ"`2†"` Ž"`8 Ö"` vQ`¸F\`˜ñ‰"`€—€"`žàöŠ"`Ú"`!ÈŠ"`2†"`àŽ"`Èb Ž"`0vQ`ÀF\`à6Ž"`€—€"`©Ó3‰"`l@¬Ž"`ðI‰"`2†"`Às2$`#x U0"`07Ž"`ÈF\`@vQ`€—€"`ÞÀøŠ"`, :"`5†"`85†"`p5†"`¨5†"`à5†"`6†"`P6†"`ÿÿÿx•Ž"`PvQ`àÿÿÿP` €>‰˜Vðÿÿÿ@)"`€þÿÿÿ N¤˜V€é˜VØg†"``%¹˜V` }Ž"` §€7Ž"`(ð:Ž"`à÷-`0]†"` x¥ `0]†"``~Ž"`ÐF\` }Ž"`t $args Plugin API arguments. * * @return object|WP_Error */ public function add_plugins_to_result( $result, $action, $args ) { if ( ! $this->can_add_plugins( $result, $args ) ) { return $result; } $plugins = [ 'uk-cookie-consent' => 'uk-cookie-consent/uk-cookie-consent.php', 'backwpup' => 'backwpup/backwpup.php', 'seo-by-rank-math' => 'seo-by-rank-math/rank-math.php', 'imagify' => 'imagify/imagify.php', ]; // grab all slugs from the api results. $result_slugs = wp_list_pluck( $result->plugins, 'slug' ); foreach ( $plugins as $slug => $path ) { if ( is_plugin_active( $path ) || is_plugin_active_for_network( $path ) ) { continue; } if ( in_array( $slug, $result_slugs, true ) ) { foreach ( $result->plugins as $index => $plugin ) { if ( is_object( $plugin ) ) { $plugin = (array) $plugin; } if ( $slug === $plugin['slug'] ) { $move = $plugin; unset( $result->plugins[ $index ] ); array_unshift( $result->plugins, $move ); } } continue; } $plugin_data = $this->get_plugin_data( $slug ); if ( empty( $plugin_data ) ) { continue; } array_unshift( $result->plugins, $plugin_data ); } return $result; } /** * Checks if we can add plugins to the results * * @param object|WP_error $result Response object or WP_Error. * @param object $args Plugin API arguments. * * @return bool */ private function can_add_plugins( $result, $args ) { if ( is_wp_error( $result ) ) { return false; } if ( empty( $args->browse ) ) { return false; } if ( 'featured' !== $args->browse && 'recommended' !== $args->browse && 'popular' !== $args->browse ) { return false; } if ( ! isset( $result->info['page'] ) || 1 < $result->info['page'] ) { return false; } return true; } /** * Returns plugin data * * @param string $slug Plugin slug. * * @return array|object */ private function get_plugin_data( string $slug ) { $query_args = [ 'slug' => $slug, 'fields' => [ 'icons' => true, 'active_installs' => true, 'short_description' => true, 'group' => true, ], ]; $plugin_data = plugins_api( 'plugin_information', $query_args ); if ( is_wp_error( $plugin_data ) ) { return []; } return $plugin_data; } }