get_plugin_information(); } /** * Retrieve the arguments for the plugins to fetch information. * * This method returns an array of plugin arguments that will be used * to retrieve information about the plugins via the WordPress Plugin API. * * @return array An array of plugin arguments. */ public static function get_plugin_args() { return array( array( 'slug' => 'wc-order-analytics-add-on', 'fields' => array( 'short_description' => true, 'icons' => true, 'sections' => false, 'rating' => false, 'ratings' => false, 'downloaded' => true, 'last_updated' => false, 'added' => false, 'tags' => false, 'homepage' => false, 'donate_link' => false, ), ), array( 'slug' => 'flagged-phone-field', 'fields' => array( 'short_description' => true, 'icons' => true, 'sections' => false, 'rating' => false, 'ratings' => false, 'downloaded' => true, 'last_updated' => false, 'added' => false, 'tags' => false, 'homepage' => false, 'donate_link' => false, ), ), array( 'slug' => 'max-upload-file-size-manager', 'fields' => array( 'short_description' => true, 'icons' => true, 'sections' => false, 'rating' => false, 'ratings' => false, 'downloaded' => true, 'last_updated' => false, 'added' => false, 'tags' => false, 'homepage' => false, 'donate_link' => false, ), ), ); } /** * Fetch and process plugin information. * * This method uses the WordPress Plugin API to retrieve information about * the plugins specified in the get_plugin_args method. It processes the * response and returns an array of plugin data. * * @return array An array of plugin data including title, download link, * description, icons, and slug. If an error occurs, the array * contains an error message. */ public function get_plugin_information() { $cached_data = get_transient('ai_writeX_plugin_data'); if ($cached_data !== false) { return $cached_data; } $plugins = self::get_plugin_args(); $data = array(); foreach ($plugins as $plugin) { $pinfo = plugins_api('plugin_information', $plugin); if (! is_wp_error($pinfo)) { $data[] = array( 'title' => $pinfo->name, 'download' => $pinfo->download_link, 'description' => $pinfo->short_description, 'icons' => $pinfo->icons['1x'], 'slug' => $pinfo->slug, ); } } // Cache data for 7 days. set_transient('ai_writeX_plugin_data', $data, 60 * 60 * 24 * 7); return $data; } /** * Includes required WordPress core files for plugin information. */ public function include_plugin_api_files() { if (is_admin()) { if (file_exists(ABSPATH . 'wp-admin/includes/plugin-install.php')) { require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; } if (file_exists(ABSPATH . 'wp-admin/includes/plugin.php')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } } } } new AI_WRTX_Card_Helper();