This WordPress plugin automatically fetches data from an external resource every 10 minutes and creates posts on your WordPress site. It uses cURL to retrieve HTML from web pages and Google Translate API to translate content into different languages.
1.0
acvid3 (Email: acvid3@gmail.com)
- WordPress 5.0 or higher
- PHP 7.3 or higher
- Access to Google Cloud Translation API and a corresponding API key
- Download the plugin into the
/wp-content/plugins/
directory of your WordPress site. - Navigate to the WordPress admin panel and activate the plugin through the "Plugins" menu.
- Ensure that WP Cron tasks are enabled in your
wp-config.php
file or set up a system cron to callwp-cron.php
every 10 minutes.
To configure the plugin:
- Set up Google Cloud Translation API and obtain an API key.
- Create a
service-account.json
file with your Google API credentials and save it in the root directory of the plugin.
After activation and configuration, the plugin operates automatically. Every 10 minutes, it will:
- Fetch HTML from an external resource.
- Parse the HTML to extract new post data.
- Create new posts based on the extracted data.
- Translate posts into Ukrainian and Russian using Google Translate.
fetch_and_create_posts()
: The main function that is scheduled to run, handling the entire process of data fetching and post creation.fetch_html_with_curl($url)
: Function for obtaining HTML from external sites.fetch_and_parse_html($url)
: Function for parsing HTML and extracting data for posts.google_translate($text, $sourceLang, $targetLang, $apiKey)
: Function for translating text using Google API.
- Ensure you have the appropriate rights to extract data from external websites.
- Adhering to data usage policies and copyright laws is crucial when extracting content.
For questions or issues with the plugin, contact the author at the provided email.