function instagram_feeds_plugins_import_feed in Instagram Feeds 7
Implements multiple page importing of feed in one call without batch UI.
Parameters
string $importer_id: Importer ID.
File
- modules/
instagram_feeds_plugins/ instagram_feeds_plugins.module, line 44 - Code for the Instagram Feeds Plugin module.
Code
function instagram_feeds_plugins_import_feed($importer_id) {
$importer = feeds_importer($importer_id);
$config = $importer
->getConfig();
// Fetch all Instagram importer node nids.
$nids = db_select('node', 'node')
->fields('node', array(
'nid',
))
->condition('type', $config['content_type'])
->condition('status', 1)
->execute()
->fetchCol();
// Iterate each importer.
foreach ($nids as $nid) {
// Load the Feed.
if ($feed = feeds_source($importer_id, $nid)) {
// Invoke the pre-import hooks.
module_invoke_all('feeds_before_import', $feed);
// Start the import batch in the background.
$batch = array(
'title' => t('Importing'),
'operations' => array(
array(
'feeds_batch',
array(
'import',
$feed->id,
$feed->feed_nid,
),
),
),
'progress_message' => '',
);
batch_set($batch);
// This allows the batch to run without the UI.
$batch =& batch_get();
$batch['progressive'] = FALSE;
batch_process();
}
}
}