/** * 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; }
/** * End an MLA_List_Table bulk action * * Add the query arguments required for the "Generated Thumbnails" filter. * * @since 2.13 * * @param array $item_content NULL, to indicate no handler. * @param string $bulk_action the requested action. */ public static function mla_list_table_end_bulk_action($item_content, $bulk_action) { if (self::MLA_GFI_ACTION != $bulk_action) { return $item_content; } if (!empty(MLA_Thumbnail::$bulk_action_includes)) { MLA::mla_clear_filter_by(array('ids')); // Reset the current view to "All" to ensure that thumbnails are displayed unset($_REQUEST['post_mime_type']); unset($_POST['post_mime_type']); unset($_GET['post_mime_type']); unset($_REQUEST['meta_query']); unset($_GET['meta_query']); unset($_REQUEST['meta_slug']); unset($_GET['meta_slug']); // Clear the "extra_nav" controls and the Search Media box, too unset($_REQUEST['m']); unset($_POST['m']); unset($_GET['m']); unset($_REQUEST['mla_filter_term']); unset($_POST['mla_filter_term']); unset($_GET['mla_filter_term']); unset($_REQUEST['s']); unset($_POST['s']); unset($_GET['s']); $_REQUEST['ids'] = MLA_Thumbnail::$bulk_action_includes; $_REQUEST['heading_suffix'] = __('Generated Thumbnails', 'media-library-assistant'); } return $item_content; }