/** * Creates new items from the "Bulk Translate" list. * * @since 2.11 * * @param array $item_content NULL, to indicate no handler. * @param string $bulk_action the requested action. * @param integer $post_id the affected attachment. * * @return object updated $item_content. NULL if no handler, otherwise * ( 'message' => error or status message(s), 'body' => '' ) */ public static function mla_list_table_custom_bulk_action($item_content, $bulk_action, $post_id) { global $polylang; MLA::mla_debug_add(__LINE__ . " MLA_Polylang::mla_list_table_bulk_action_item_request( {$bulk_action}, {$post_id} )", MLA::MLA_DEBUG_CATEGORY_LANGUAGE); if ('pll-translate' == $bulk_action) { $translations = array(); if (isset($_REQUEST['bulk_tr_languages'])) { $bulk_tr_languages = $_REQUEST['bulk_tr_languages']; // Expand All Languages selection if (isset($bulk_tr_languages['all'])) { foreach ($polylang->model->get_languages_list() as $language) { $bulk_tr_languages[$language->slug] = 'translate'; } unset($bulk_tr_languages['all']); } // Process language selection(s) foreach ($bulk_tr_languages as $language => $action) { $new_id = MLA_Polylang::_get_translation($post_id, $language); $translations[] = $new_id; } } // Clear all the "Filter-by" parameters if (isset($_REQUEST['bulk_tr_options']['clear_filters'])) { MLA::mla_clear_filter_by(); } if (empty($translations)) { $item_content = array('message' => "Item {$post_id}, no translations."); } else { $_REQUEST['heading_suffix'] = __('Bulk Translations', 'media-library-assistant'); MLA_Polylang::$bulk_action_includes = array_merge(MLA_Polylang::$bulk_action_includes, $translations); $translations = implode(',', $translations); $item_content = array('message' => "Item {$post_id}, translation(s): {$translations}."); } } return $item_content; }