The Media Library Assistant cannot activate multi-language support. Another plugin or theme has declared conflicting class, function or constant names:

'."\r\n"; echo "\r\n"; echo '

You must resolve these conflicts before multi-language support can be activated.

'."\r\n"; } /** * Initialization function, similar to __construct() * * This function contains add_action and add_filter calls * to set up the Ajax handlers, enqueue JavaScript and CSS files, and * set up the Assistant submenu. * * @since 0.1 * * @return void */ public static function initialize( ) { global $sitepress, $polylang; if ( 'checked' == MLACore::mla_get_option( 'enable_featured_image_generation' ) ) { if ( class_exists( 'MLA_Thumbnail' ) ) { self::$mla_language_support_error_messages .= "
  • class MLA_Thumbnail
  • "; } else { require_once( MLA_PLUGIN_PATH . 'includes/class-mla-thumbnail-generation.php' ); MLA_Thumbnail::initialize(); } } /* * Check for WPML/Polylang presence before loading language support class, * then immediately initialize it since we're already in the "init" action. */ if ( is_object( $sitepress ) ) { if ( class_exists( 'MLA_WPML' ) ) { self::$mla_language_support_error_messages .= "
  • class MLA_WPML
  • "; } if ( class_exists( 'MLA_WPML_List_Table' ) ) { self::$mla_language_support_error_messages .= "
  • class MLA_WPML_List_Table
  • "; } if ( class_exists( 'MLA_WPML_Table' ) ) { self::$mla_language_support_error_messages .= "
  • class MLA_WPML_Table
  • "; } if ( empty( self::$mla_language_support_error_messages ) ) { require_once( MLA_PLUGIN_PATH . 'includes/class-mla-wpml-support.php' ); MLA_WPML::initialize(); } } elseif ( is_object( $polylang ) ) { if ( class_exists( 'MLA_Polylang' ) ) { self::$mla_language_support_error_messages .= "
  • class MLA_Polylang
  • "; } if ( empty( self::$mla_language_support_error_messages ) ) { require_once( MLA_PLUGIN_PATH . 'includes/class-mla-polylang-support.php' ); MLA_Polylang::initialize(); } } if ( ! empty( self::$mla_language_support_error_messages ) ) { add_action( 'admin_notices', 'MLA::mla_name_conflict_reporting_action' ); } add_action( 'admin_init', 'MLA::mla_admin_init_action' ); add_action( 'admin_enqueue_scripts', 'MLA::mla_admin_enqueue_scripts_action' ); add_action( 'admin_menu', 'MLA::mla_admin_menu_action' ); add_filter( 'set-screen-option', 'MLA::mla_set_screen_option_filter', 10, 3 ); // $status, $option, $value add_filter( 'screen_options_show_screen', 'MLA::mla_screen_options_show_screen_filter', 10, 2 ); // $show_screen, $this } /** * Load the plugin's Ajax handler or process Edit Media update actions * * @since 0.20 * * @return void */ public static function mla_admin_init_action() { //static $count = 0; //error_log( __LINE__ . ' MLA::mla_admin_init_action $count = ' . var_export( $count++, true ), 0 ); //error_log( __LINE__ . ' MLA::mla_admin_init_action referer = ' . var_export( wp_get_referer(), true ), 0 ); //error_log( __LINE__ . ' MLA::mla_admin_init_action $_REQUEST = ' . var_export( $_REQUEST, true ), 0 ); //error_log( __LINE__ . ' MLA::mla_admin_init_action $_POST = ' . var_export( $_POST, true ), 0 ); //error_log( __LINE__ . ' MLA::mla_admin_init_action $_GET = ' . var_export( $_GET, true ), 0 ); // Process secure file download requests if ( isset( $_REQUEST['mla_download_file'] ) && isset( $_REQUEST['mla_download_type'] ) ) { check_admin_referer( MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ); self::_process_mla_download_file( $_REQUEST, true ); exit(); } // Process example plugin download requests from the Documentation tab if ( isset( $_REQUEST['mla_download_example_plugin'] ) ) { check_admin_referer( MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ); $request = array ( 'mla_download_file' => str_replace( '\\', '/', MLA_PLUGIN_PATH . 'examples/plugins/' . stripslashes( $_REQUEST['mla_download_example_plugin'] ) ), 'mla_download_type' => 'text/plain', ); self::_process_mla_download_file( $request, false ); exit(); } // Process error log download requests from the Debug tab if ( isset( $_REQUEST['mla_download_error_log'] ) ) { check_admin_referer( MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ); // Find the appropriate error log file $error_log_name = MLACore::mla_get_option( MLACoreOptions::MLA_DEBUG_FILE ); if ( empty( $error_log_name ) ) { $error_log_name = ini_get( 'error_log' ); } else { $first = substr( $error_log_name, 0, 1 ); if ( ( '/' != $first ) && ( '\\' != $first ) ) { $error_log_name = '/' . $error_log_name; } $error_log_name = WP_CONTENT_DIR . $error_log_name; } if ( file_exists ( $error_log_name ) ) { $request = array ( 'mla_download_file' => addslashes( $error_log_name ), 'mla_download_type' => 'text/plain', ); self::_process_mla_download_file( $request, false ); } exit(); } $bulk_action = ''; if ( isset( $_REQUEST['action'] ) && 'download-zip' == $_REQUEST['action']) { $bulk_action = 'download-zip'; } elseif ( isset( $_REQUEST['action2'] ) && 'download-zip' == $_REQUEST['action2']) { $bulk_action = 'download-zip'; } if ( 'download-zip' == $bulk_action ) { // Exits after redirect unless it returns an error $_REQUEST['mla_zip_archive_error_message'] = self::_process_zip_archive_download( $_REQUEST ); MLACore::mla_debug_add( __LINE__ . " MLA::_process_zip_archive_download message = " . var_export( $_REQUEST['mla_zip_archive_error_message'], true ), MLACore::MLA_DEBUG_CATEGORY_ANY ); return; } // Process row-level actions from the Edit Media screen if ( !empty( $_REQUEST['mla_admin_action'] ) ) { if ( isset( $_REQUEST['mla-set-parent-ajax-nonce'] ) ) { check_admin_referer( 'mla_find_posts', 'mla-set-parent-ajax-nonce' ); } else { check_admin_referer( MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ); } if ( apply_filters( 'mla_list_table_admin_action', true, $_REQUEST['mla_admin_action'], ( isset( $_REQUEST['mla_item_ID'] ) ? $_REQUEST['mla_item_ID'] : 0 ) ) ) { switch ( $_REQUEST['mla_admin_action'] ) { case MLACore::MLA_ADMIN_SINGLE_CUSTOM_FIELD_MAP: if ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_ALLOW_CUSTOM_FIELD_MAPPING ) ) { do_action( 'mla_begin_mapping', 'single_custom', $_REQUEST['mla_item_ID'] ); $updates = MLAOptions::mla_evaluate_custom_field_mapping( $_REQUEST['mla_item_ID'], 'single_attachment_mapping' ); do_action( 'mla_end_mapping' ); if ( !empty( $updates ) ) { $item_content = MLAData::mla_update_single_item( $_REQUEST['mla_item_ID'], $updates ); } $message = '101'; } else { $message = '103'; } $view_args = isset( $_REQUEST['mla_source'] ) ? array( 'mla_source' => $_REQUEST['mla_source']) : array(); wp_redirect( add_query_arg( $view_args, admin_url( 'post.php' ) . '?post=' . $_REQUEST['mla_item_ID'] . '&action=edit&message=' . $message ), 302 ); exit; case MLACore::MLA_ADMIN_SINGLE_MAP: if ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_ALLOW_IPTC_EXIF_MAPPING ) ) { $item = get_post( $_REQUEST['mla_item_ID'] ); do_action( 'mla_begin_mapping', 'single_iptc_exif', $_REQUEST['mla_item_ID'] ); $updates = MLAOptions::mla_evaluate_iptc_exif_mapping( $item, 'iptc_exif_mapping' ); do_action( 'mla_end_mapping' ); $page_content = MLAData::mla_update_single_item( $_REQUEST['mla_item_ID'], $updates ); $message = '102'; } else { $message = '104'; } $view_args = isset( $_REQUEST['mla_source'] ) ? array( 'mla_source' => $_REQUEST['mla_source']) : array(); wp_redirect( add_query_arg( $view_args, admin_url( 'post.php' ) . '?post=' . $_REQUEST['mla_item_ID'] . '&action=edit&message=' . $message ), 302 ); exit; default: do_action( 'mla_list_table_custom_admin_action', $_REQUEST['mla_admin_action'], ( isset( $_REQUEST['mla_item_ID'] ) ? $_REQUEST['mla_item_ID'] : 0 ) ); // ignore the rest } // switch ($_REQUEST['mla_admin_action']) } // apply_filters mla_list_table_admin_action } // (!empty($_REQUEST['mla_admin_action']) if ( is_admin() ) { if ( defined('DOING_AJAX') && DOING_AJAX ) { add_action( 'wp_ajax_' . MLACore::JAVASCRIPT_INLINE_EDIT_SLUG, 'MLA::mla_inline_edit_ajax_action' ); } } } /** * Print optional in-lne styles for Media/Assistant submenu table * * @since 2.13 */ public static function mla_admin_print_styles_action() { echo "\n"; } /** * Load the plugin's Style Sheet and Javascript files * * @since 0.1 * * @param string Name of the page being loaded * * @return void */ public static function mla_admin_enqueue_scripts_action( $page_hook ) { global $wp_locale; $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; if ( 'checked' != MLACore::mla_get_option( MLACoreOptions::MLA_SCREEN_DISPLAY_LIBRARY ) ) { wp_register_style( MLACore::STYLESHEET_SLUG . '-nolibrary', MLA_PLUGIN_URL . 'css/mla-nolibrary.css', false, MLACore::CURRENT_MLA_VERSION ); wp_enqueue_style( MLACore::STYLESHEET_SLUG . '-nolibrary' ); } if ( 'edit-tags.php' == $page_hook ) { wp_register_style( MLACore::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-edit-tags-style.css', false, MLACore::CURRENT_MLA_VERSION ); wp_enqueue_style( MLACore::STYLESHEET_SLUG ); return; } if ( 'media_page_' . MLACore::ADMIN_PAGE_SLUG != $page_hook ) { return; } // Add the styles for variable-size icon and WP 4.3 primary column display add_action( 'admin_print_styles', 'MLA::mla_admin_print_styles_action' ); if ( $wp_locale->is_rtl() ) { wp_register_style( MLACore::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-style-rtl.css', false, MLACore::CURRENT_MLA_VERSION ); } else { wp_register_style( MLACore::STYLESHEET_SLUG, MLA_PLUGIN_URL . 'css/mla-style.css', false, MLACore::CURRENT_MLA_VERSION ); } wp_enqueue_style( MLACore::STYLESHEET_SLUG ); wp_register_style( MLACore::STYLESHEET_SLUG . '-set-parent', MLA_PLUGIN_URL . 'css/mla-style-set-parent.css', false, MLACore::CURRENT_MLA_VERSION ); wp_enqueue_style( MLACore::STYLESHEET_SLUG . '-set-parent' ); wp_enqueue_script( MLACore::JAVASCRIPT_INLINE_EDIT_SLUG, MLA_PLUGIN_URL . "js/mla-inline-edit-scripts{$suffix}.js", array( 'wp-lists', 'suggest', 'jquery' ), MLACore::CURRENT_MLA_VERSION, false ); if ( MLACore::mla_supported_taxonomies( 'checklist-add-term' ) ) { wp_enqueue_script( MLACore::JAVASCRIPT_INLINE_EDIT_SLUG . '-add-term', MLA_PLUGIN_URL . "js/mla-add-term-scripts{$suffix}.js", array( 'wp-ajax-response', 'jquery', MLACore::JAVASCRIPT_INLINE_EDIT_SLUG ), MLACore::CURRENT_MLA_VERSION, false ); } wp_enqueue_script( MLACore::JAVASCRIPT_INLINE_EDIT_SLUG . '-set-parent', MLA_PLUGIN_URL . "js/mla-set-parent-scripts{$suffix}.js", array( 'wp-lists', 'suggest', 'jquery', MLACore::JAVASCRIPT_INLINE_EDIT_SLUG ), MLACore::CURRENT_MLA_VERSION, false ); MLAModal::mla_add_terms_search_scripts(); $fields = array( 'post_title', 'post_name', 'post_excerpt', 'post_content', 'image_alt', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_parent', 'post_parent_title', 'menu_order', 'post_author' ); $custom_fields = MLACore::mla_custom_field_support( 'quick_edit' ); $custom_fields = array_merge( $custom_fields, MLACore::mla_custom_field_support( 'bulk_edit' ) ); foreach ( $custom_fields as $slug => $details ) { $fields[] = $slug; } $fields = apply_filters( 'mla_list_table_inline_fields', $fields ); $script_variables = array( 'fields' => $fields, 'ajaxFailError' => __( 'An ajax.fail error has occurred. Please reload the page and try again.', 'media-library-assistant' ), 'ajaxDoneError' => __( 'An ajax.done error has occurred. Please reload the page and try again.', 'media-library-assistant' ), 'error' => __( 'Error while saving the changes.', 'media-library-assistant' ), 'ntdelTitle' => __( 'Remove From Bulk Edit', 'media-library-assistant' ), 'noTitle' => __( '(no title)', 'media-library-assistant' ), 'bulkTitle' => __( 'Bulk Edit items', 'media-library-assistant' ), 'bulkWaiting' => __( 'Waiting', 'media-library-assistant' ), 'bulkComplete' => __( 'Complete', 'media-library-assistant' ), 'bulkUnchanged' => __( 'Unchanged', 'media-library-assistant' ), 'bulkSuccess' => __( 'Succeeded', 'media-library-assistant' ), 'bulkFailure' => __( 'Failed', 'media-library-assistant' ), 'bulkCanceled' => __( 'CANCELED', 'media-library-assistant' ), 'bulkChunkSize' => MLACore::mla_get_option( MLACoreOptions::MLA_BULK_CHUNK_SIZE ), 'comma' => _x( ',', 'tag_delimiter', 'media-library-assistant' ), 'useSpinnerClass' => false, 'ajax_action' => MLACore::JAVASCRIPT_INLINE_EDIT_SLUG, 'ajax_nonce' => wp_create_nonce( MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ), 'deleteAcpBulkEdit' => false, ); if ( version_compare( get_bloginfo( 'version' ), '4.2', '>=' ) ) { $script_variables['useSpinnerClass'] = true; } if ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_BULK_EDITOR ) ) { $script_variables['quickTagsInit'] = array( 'post_content' => array( 'id' => 'post_content', 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close', 'active' => true, ) ); } if ( function_exists( 'ACP' ) && ( version_compare( ACP()->get_version(), '4.5', '>=' ) ) ) { if ( version_compare( ACP()->get_version(), '4.5.4', '<' ) ) { $script_variables['deleteAcpBulkEdit'] = true; } } wp_localize_script( MLACore::JAVASCRIPT_INLINE_EDIT_SLUG, self::JAVASCRIPT_INLINE_EDIT_OBJECT, $script_variables ); } /** * Add the submenu pages * * Add a submenu page in the "Media" section, * add settings page in the "Settings" section. * add settings link in the Plugins section entry for MLA. * * @since 0.1 * * @return void */ public static function mla_admin_menu_action( ) { global $submenu; add_action( 'load-upload.php', 'MLA::mla_load_media_action' ); // Disable the MLA Download ZIP Example plugin, if necessary if ( isset( $_REQUEST['page'] ) && 'mla-menu' === $_REQUEST['page'] ) { $bulk_action = ''; if ( isset( $_REQUEST['action'] ) && 'download-zip' === $_REQUEST['action']) { $bulk_action = 'download-zip'; } elseif ( isset( $_REQUEST['action2'] ) && 'download-zip' === $_REQUEST['action2']) { $bulk_action = 'download-zip'; } if ( 'download-zip' === $bulk_action ) { if ( is_plugin_active( 'mla-zip-archive-example/mla-zip-archive-example.php' ) ) { deactivate_plugins( 'mla-zip-archive-example/mla-zip-archive-example.php', true ); } if ( is_plugin_active( 'mla-zip-archive-example.php' ) ) { deactivate_plugins( 'mla-zip-archive-example.php', true ); } } } $page_title = MLACore::mla_get_option( MLACoreOptions::MLA_SCREEN_PAGE_TITLE ); if ( empty( $page_title ) ) { $page_title = MLACore::mla_get_option( MLACoreOptions::MLA_SCREEN_PAGE_TITLE, true ); } $menu_title = MLACore::mla_get_option( MLACoreOptions::MLA_SCREEN_MENU_TITLE ); if ( empty( $menu_title ) ) { $menu_title = MLACore::mla_get_option( MLACoreOptions::MLA_SCREEN_MENU_TITLE, true ); } $hook = add_submenu_page( 'upload.php', $page_title, $menu_title, 'upload_files', MLACore::ADMIN_PAGE_SLUG, 'MLA::mla_render_admin_page' ); add_action( 'load-' . $hook, 'MLA::mla_add_menu_options' ); add_action( 'load-' . $hook, 'MLA::mla_add_help_tab' ); self::$page_hooks[ $hook ] = $hook; $taxonomies = get_object_taxonomies( 'attachment', 'objects' ); if ( !empty( $taxonomies ) ) { foreach ( $taxonomies as $tax_name => $tax_object ) { /* * The page_hook we need for taxonomy edits is slightly different */ $hook = 'edit-' . $tax_name; self::$page_hooks[ $hook ] = 't_' . $tax_name; } // foreach $taxonomies /* * Load here, not 'load-edit-tags.php', to put our tab after the defaults */ add_action( 'admin_head-edit-tags.php', 'MLA::mla_add_help_tab' ); } /* * If we are suppressing the Media/Library submenu, force Media/Assistant to come first */ if ( 'checked' != MLACore::mla_get_option( MLACoreOptions::MLA_SCREEN_DISPLAY_LIBRARY ) ) { $menu_position = 4; } else { $menu_position = (integer) MLACore::mla_get_option( MLACoreOptions::MLA_SCREEN_ORDER ); } if ( $menu_position && !empty( $submenu['upload.php'] ) ) { foreach ( $submenu['upload.php'] as $menu_order => $menu_item ) { if ( MLACore::ADMIN_PAGE_SLUG == $menu_item[2] ) { $menu_item[2] = 'upload.php?page=' . MLACore::ADMIN_PAGE_SLUG; $submenu['upload.php'][$menu_position] = $menu_item; unset( $submenu['upload.php'][$menu_order] ); ksort( $submenu['upload.php'] ); break; } } } add_filter( 'parent_file', 'MLA::mla_parent_file_filter', 10, 1 ); } /** * Redirect to Media/Assistant if Media/Library is hidden or a trash/delete * returns from Media/Edit Media initiated from Media/Assistant * * @since 1.60 * * @return void */ public static function mla_load_media_action( ) { $mla_source = isset( $_REQUEST['mla_source'] ) && in_array( $_REQUEST['mla_source'], array ( 'trash', 'delete' ) ); if ( $mla_source || ( 'checked' != MLACore::mla_get_option( MLACoreOptions::MLA_SCREEN_DISPLAY_LIBRARY ) ) ) { // Allow "grid" view even if the list view is suppressed if ( isset( $_REQUEST['mode'] ) && 'grid' === $_REQUEST['mode'] ) { return; } $query_args = '?page=' . MLACore::ADMIN_PAGE_SLUG; // Compose a message if returning from the Edit Media screen if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) { $query_args .= '&mla_admin_message=' . urlencode( sprintf( _n( 'Item permanently deleted.', '%d items permanently deleted.', $deleted, 'media-library-assistant' ), number_format_i18n( $_GET['deleted'] ) ) ); } if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) { /* translators: 1: post ID */ $query_args .= '&mla_admin_message=' . urlencode( sprintf( __( 'Item %1$d moved to Trash.', 'media-library-assistant' ), $_GET['ids'] ) ); } wp_redirect( admin_url( 'upload.php' ) . $query_args, 302 ); exit; } } /** * Add the "XX Entries per page" filter to the Screen Options tab * * @since 0.1 * * @return void */ public static function mla_add_menu_options( ) { $option = 'per_page'; $args = array( 'label' => __( 'Entries per page', 'media-library-assistant' ), 'default' => 10, 'option' => MLA_OPTION_PREFIX . 'entries_per_page' ); add_screen_option( $option, $args ); } /** * Add contextual help tabs to all the MLA pages * * @since 0.1 * * @return void */ public static function mla_add_help_tab( ) { $screen = get_current_screen(); // Is this one of our pages? if ( !array_key_exists( $screen->id, self::$page_hooks ) ) { return; } if ( 'edit-tags' == $screen->base && 'attachment' != $screen->post_type ) { return; } $file_suffix = $screen->id; // Use a generic page for edit taxonomy screens if ( 't_' == substr( self::$page_hooks[ $file_suffix ], 0, 2 ) ) { $taxonomy = substr( self::$page_hooks[ $file_suffix ], 2 ); switch ( $taxonomy ) { case 'attachment_category': case 'attachment_tag': break; default: $tax_object = get_taxonomy( $taxonomy ); if ( $tax_object->hierarchical ) { $file_suffix = 'edit-hierarchical-taxonomy'; } else { $file_suffix = 'edit-flat-taxonomy'; } } // $taxonomy switch } // is taxonomy $template_array = apply_filters( 'mla_list_table_help_template', NULL, 'help-for-' . $file_suffix . '.tpl', $file_suffix ); if ( is_null( $template_array ) ) { $template_array = MLACore::mla_load_template( 'help-for-' . $file_suffix . '.tpl' ); } if ( empty( $template_array ) ) { return; } // Don't add sidebar to the WordPress category and post_tag screens if ( ! ( 'edit-tags' == $screen->base && in_array( $screen->taxonomy, array( 'post_tag', 'category' ) ) ) ) { if ( !empty( $template_array['sidebar'] ) ) { $page_values = array( 'settingsURL' => admin_url('options-general.php') ); $content = MLAData::mla_parse_template( $template_array['sidebar'], $page_values ); $screen->set_help_sidebar( $content ); } } unset( $template_array['sidebar'] ); // Provide explicit control over tab order $tab_array = array(); foreach ( $template_array as $id => $content ) { $match_count = preg_match( '#\\n"; /* * Insert the hidden form and table for inline edits (quick & bulk) */ echo self::_build_inline_edit_form( $MLAListTable ); echo "
    \n"; echo "
    \n"; echo "\n"; } // display attachments list } /** * Ajax handler for bulk editing and mapping * * @since 2.00 * * @return void echo json results or error message, then die() */ private static function _bulk_edit_ajax_handler() { /* * The category taxonomy (edit screens) is a special case because * post_categories_meta_box() changes the input name */ if ( !isset( $_REQUEST['tax_input'] ) ) { $_REQUEST['tax_input'] = array(); } if ( isset( $_REQUEST['post_category'] ) ) { $_REQUEST['tax_input']['category'] = $_REQUEST['post_category']; unset ( $_REQUEST['post_category'] ); } /* * Convert bulk_action to the old button name/value variables */ switch ( $_REQUEST['bulk_action'] ) { case 'bulk_custom_field_map': $_REQUEST['bulk_custom_field_map'] = __( 'Map Custom Field metadata', 'media-library-assistant' ); break; case 'bulk_map': $_REQUEST['bulk_map'] = __( 'Map IPTC/EXIF metadata', 'media-library-assistant' ); break; case 'bulk_edit': $_REQUEST['bulk_edit'] = __( 'Update', 'media-library-assistant' ); } $item_content = (object) self::mla_process_bulk_action( 'edit' ); wp_send_json_success( $item_content ); } /** * Ajax handler for inline editing * * Adapted for Quick Edit from wp_ajax_inline_save in /wp-admin/includes/ajax-actions.php * * @since 0.20 * * @return void echo HTML markup for updated row or error message, then die() */ public static function mla_inline_edit_ajax_action() { set_current_screen( $_REQUEST['screen'] ); check_ajax_referer( MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ); if ( ! empty( $_REQUEST['bulk_action'] ) ) { self::_bulk_edit_ajax_handler(); // calls wp_send_json_success and die() } if ( empty( $_REQUEST['post_ID'] ) ) { echo __( 'ERROR', 'media-library-assistant' ) . ': ' . __( 'No post ID found', 'media-library-assistant' ); die(); } else { $post_id = $_REQUEST['post_ID']; } if ( ! current_user_can( 'edit_post', $post_id ) ) { wp_die( __( 'ERROR', 'media-library-assistant' ) . ': ' . __( 'You are not allowed to edit this Attachment.', 'media-library-assistant' ) ); } // Custom field support $custom_fields = array(); foreach ( MLACore::mla_custom_field_support( 'quick_edit' ) as $slug => $details ) { if ( isset( $_REQUEST[ $slug ] ) ) { $value = trim( $_REQUEST[ $slug ] ); unset ( $_REQUEST[ $slug ] ); // '(Array)' indicates an existing array value in the field, which we preserve if ( 'array' == $details['option'] ) { $value = explode( ',', $value ); } elseif ( '(Array)' == $value ) { continue; } if ( $details['no_null'] && empty( $value ) ) { $custom_fields[ $details['name'] ] = NULL; } else { $custom_fields[ $details['name'] ] = $value; } } } if ( ! empty( $custom_fields ) ) { $_REQUEST[ 'custom_updates' ] = $custom_fields; } // The category taxonomy is a special case because post_categories_meta_box() changes the input name if ( !isset( $_REQUEST['tax_input'] ) ) { $_REQUEST['tax_input'] = array(); } if ( isset( $_REQUEST['post_category'] ) ) { $_REQUEST['tax_input']['category'] = $_REQUEST['post_category']; unset ( $_REQUEST['post_category'] ); } if ( ! empty( $_REQUEST['tax_input'] ) ) { // Flat taxonomy strings must be cleaned up and duplicates removed $tax_output = array(); foreach ( $_REQUEST['tax_input'] as $tax_name => $tax_value ) { if ( is_array( $tax_value ) ) { // Make sure term_id values are integers, not strings, for flat-checklist $tax_value = array_map( 'absint', $tax_value ); } else { $comma = _x( ',', 'tag_delimiter', 'media-library-assistant' ); if ( ',' != $comma ) { $tax_value = str_replace( $comma, ',', $tax_value ); } $tax_value = preg_replace( '#\s*,\s*#', ',', $tax_value ); $tax_value = preg_replace( '#,+#', ',', $tax_value ); $tax_value = preg_replace( '#[,\s]+$#', '', $tax_value ); $tax_value = preg_replace( '#^[,\s]+#', '', $tax_value ); if ( ',' != $comma ) { $tax_value = str_replace( ',', $comma, $tax_value ); } $tax_array = array(); $dedup_array = explode( $comma, $tax_value ); foreach ( $dedup_array as $tax_value ) $tax_array [$tax_value] = $tax_value; $tax_value = implode( $comma, $tax_array ); } // ! array( $tax_value ) $tax_output[$tax_name] = $tax_value; } // foreach tax_input $_REQUEST['tax_input'] = $tax_output; } // ! empty( $_REQUEST['tax_input'] ) $item_content = apply_filters( 'mla_list_table_inline_action', NULL, $post_id ); if ( is_null( $item_content ) ) { $prevent_default = false; $custom_message = ''; } else { $prevent_default = isset( $item_content['prevent_default'] ) ? $item_content['prevent_default'] : false; $custom_message = isset( $item_content['message'] ) ? $page_content['message'] : ''; } if ( ! $prevent_default ) { MLACore::mla_debug_add( __LINE__ . " MLA::mla_inline_edit_ajax_action( {$post_id} ) \$_REQUEST = " . var_export( $_REQUEST, true ), MLACore::MLA_DEBUG_CATEGORY_AJAX ); $new_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $_REQUEST['aa'], $_REQUEST['mm'], $_REQUEST['jj'], $_REQUEST['hh'], $_REQUEST['mn'], $_REQUEST['ss'] ); if ( wp_checkdate( $_REQUEST['mm'], $_REQUEST['jj'], $_REQUEST['aa'], $new_date ) ) { $_REQUEST['post_date'] = $new_date; $_REQUEST['post_date_gmt'] = get_gmt_from_date( $new_date ); } $results = MLAData::mla_update_single_item( $post_id, $_REQUEST, $_REQUEST['tax_input'] ); MLACore::mla_debug_add( __LINE__ . " MLA::mla_inline_edit_ajax_action( {$post_id} ) results = " . var_export( $results, true ), MLACore::MLA_DEBUG_CATEGORY_AJAX ); } $new_item = (object) MLAData::mla_get_attachment_by_id( $post_id ); MLACore::mla_debug_add( __LINE__ . " MLA::mla_inline_edit_ajax_action( {$post_id} ) new_item = " . var_export( $new_item, true ), MLACore::MLA_DEBUG_CATEGORY_AJAX ); // Create an instance of our package class and echo the new HTML $MLAListTable = apply_filters( 'mla_list_table_new_instance', NULL ); if ( is_null( $MLAListTable ) ) { $MLAListTable = new MLA_List_Table(); } $MLAListTable->single_row( $new_item ); die(); // this is required to return a proper result } /** * Compose a Post Type Options list with current selection * * @since 1.90 * * @param array template parts * @param string current selection or 'all' (default) * * @return string HTML markup with select field options */ private static function _compose_post_type_select( &$templates, $selection = 'all' ) { $option_template = $templates['post-type-select-option']; $option_values = array ( 'selected' => ( 'all' == $selection ) ? 'selected="selected"' : '', 'value' => 'all', 'text' => '— ' . __( 'All Post Types', 'media-library-assistant' ) . ' —' ); $options = MLAData::mla_parse_template( $option_template, $option_values ); $post_types = get_post_types( array( 'public' => true ), 'objects' ); unset( $post_types['attachment'] ); foreach ( $post_types as $key => $value ) { $option_values = array ( 'selected' => ( $key == $selection ) ? 'selected="selected"' : '', 'value' => $key, 'text' => $value->labels->name ); $options .= MLAData::mla_parse_template( $option_template, $option_values ); } // foreach post_type $select_template = $templates['post-type-select']; $select_values = array ( 'options' => $options, ); $select = MLAData::mla_parse_template( $select_template, $select_values ); return $select; } // _compose_post_type_select /** * Build the hidden form for the "Set Parent" popup modal window * * @since 1.90 * * @param boolean true to return complete form, false to return mla-set-parent-div * * @return string HTML
    markup for hidden form */ public static function mla_set_parent_form( $return_form = true ) { $set_parent_template = MLACore::mla_load_template( 'admin-set-parent-form.tpl' ); if ( ! is_array( $set_parent_template ) ) { /* translators: 1: ERROR tag 2: function name 3: non-array value */ MLACore::mla_debug_add( sprintf( _x( '%1$s: %2$s non-array "%3$s"', 'error_log', 'media-library-assistant' ), __( 'ERROR', 'media-library-assistant' ), 'MLA::_build_inline_edit_form', var_export( $set_parent_template, true ) ), MLACore::MLA_DEBUG_CATEGORY_ANY ); return ''; } $page_values = array( 'Select Parent' => __( 'Select Parent', 'media-library-assistant' ), 'Search' => __( 'Search', 'media-library-assistant' ), 'post_type_dropdown' => self::_compose_post_type_select( $set_parent_template, 'all' ), 'For' => __( 'For', 'media-library-assistant' ), 'Previous' => '«', 'Next' => '»', 'count' => '50', 'paged' => '1', 'found' => '0', 'Title' => __( 'Title', 'media-library-assistant' ), 'Type' => __( 'Type', 'media-library-assistant' ), 'Date' => __( 'Date', 'media-library-assistant' ), 'Status' => __( 'Status', 'media-library-assistant' ), 'Unattached' => __( 'Unattached', 'media-library-assistant' ), 'mla_find_posts_nonce' => wp_nonce_field( 'mla_find_posts', 'mla-set-parent-ajax-nonce', false, false ), ); ob_start(); submit_button( __( 'Cancel', 'media-library-assistant' ), 'button-secondary cancel alignleft', 'mla-set-parent-cancel', false ); $page_values['mla_set_parent_cancel'] = ob_get_clean(); ob_start(); submit_button( __( 'Update', 'media-library-assistant' ), 'button-primary alignright', 'mla-set-parent-submit', false ); $page_values['mla_set_parent_update'] = ob_get_clean(); $set_parent_div = MLAData::mla_parse_template( $set_parent_template['mla-set-parent-div'], $page_values ); if ( ! $return_form ) { return $set_parent_div; } $page_values = array( 'mla_set_parent_url' => esc_url( add_query_arg( array_merge( MLA_List_Table::mla_submenu_arguments( false ), array( 'page' => MLACore::ADMIN_PAGE_SLUG ) ), admin_url( 'upload.php' ) ) ), 'mla_set_parent_action' => MLACore::MLA_ADMIN_SET_PARENT, 'wpnonce' => wp_nonce_field( MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME, true, false ), 'mla_set_parent_div' => $set_parent_div, ); $set_parent_form = MLAData::mla_parse_template( $set_parent_template['mla-set-parent-form'], $page_values ); return $set_parent_form; } /** * Generate HTML form elements for editing uploaded on date * * Adapted from /wp-admin/includes/template.php function touch_time() * * @since 2.71 * * @global WP_Locale $wp_locale for month name abbreviations * * @return string HTML markup for the Uploaded on edit form */ private static function _generate_time_edit_form() { global $wp_locale; $current = current_time('timestamp'); $jj = gmdate( 'd', $current ); $mm = gmdate( 'm', $current ); $aa = gmdate( 'Y', $current ); $hh = gmdate( 'H', $current ); $mn = gmdate( 'i', $current ); $ss = gmdate( 's', $current ); $month = ''; $day = ''; $year = ''; $hour = ''; $minute = ''; $time_edit_form = '
    ' . "\n"; $time_edit_form .= '' . sprintf( __( 'Uploaded on: %s' ), '' ) . '' . "\n"; $time_edit_form .= '
    ' . "\n"; $time_edit_form .= sprintf( __( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month, $day, $year, $hour, $minute ); $time_edit_form .= "
    \n"; $time_edit_form .= '' . "\n"; $time_edit_form .= "
    \n"; return $time_edit_form; } /** * Build the hidden row templates for inline editing (quick and bulk edit) * * inspired by inline_edit() in wp-admin\includes\class-wp-posts-list-table.php. * * @since 0.20 * * @param object MLA List Table object * * @return string HTML markup for hidden rows */ private static function _build_inline_edit_form( $MLAListTable ) { $taxonomies = get_object_taxonomies( 'attachment', 'objects' ); $hierarchical_taxonomies = array(); $flat_taxonomies = array(); foreach ( $taxonomies as $tax_name => $tax_object ) { if ( $tax_object->show_ui && MLACore::mla_taxonomy_support($tax_name, 'quick-edit') ) { if ( $tax_object->hierarchical ) { $hierarchical_taxonomies[$tax_name] = $tax_object; } else { $flat_taxonomies[$tax_name] = $tax_object; } } } $page_template_array = MLACore::mla_load_template( 'admin-inline-edit-form.tpl' ); if ( ! is_array( $page_template_array ) ) { /* translators: 1: ERROR tag 2: function name 3: non-array value */ MLACore::mla_debug_add( sprintf( _x( '%1$s: %2$s non-array "%3$s"', 'error_log', 'media-library-assistant' ), __( 'ERROR', 'media-library-assistant' ), 'MLA::_build_inline_edit_form', var_export( $page_template_array, true ) ), MLACore::MLA_DEBUG_CATEGORY_ANY ); return ''; } if ( $authors = self::mla_authors_dropdown() ) { $authors_dropdown = ' ' . "\n"; } else { $authors_dropdown = ''; } $custom_fields = ''; foreach ( MLACore::mla_custom_field_support( 'quick_edit' ) as $slug => $details ) { $page_values = array( 'slug' => $slug, 'label' => esc_attr( $details['name'] ), ); $custom_fields .= MLAData::mla_parse_template( $page_template_array['custom_field'], $page_values ); } // The middle column contains the hierarchical taxonomies, e.g., Att. Category $quick_middle_column = ''; $bulk_middle_column = ''; if ( count( $hierarchical_taxonomies ) ) { $quick_category_blocks = ''; $bulk_category_blocks = ''; foreach ( $hierarchical_taxonomies as $tax_name => $tax_object ) { if ( current_user_can( $tax_object->cap->assign_terms ) ) { ob_start(); wp_terms_checklist( NULL, array( 'taxonomy' => $tax_name, 'popular_cats' => array(), ) ); $tax_checklist = ob_get_contents(); ob_end_clean(); if ( MLACore::mla_taxonomy_support( $tax_name, 'checklist-add-term' ) ) { $page_values = array( 'tax_attr' => esc_attr( $tax_name ), 'Add New Term' => __( '+ Add New Term', 'media-library-assistant' ), 'Add Reader' => __( 'Add New', 'media-library-assistant' ) . ' ' . esc_html( $tax_object->labels->singular_name ), 'tax_parents' => wp_dropdown_categories( array( 'taxonomy' => $tax_name, 'hide_empty' => 0, 'name' => "new{$tax_name}_parent", 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax_object->labels->parent_item . ' —', 'echo' => 0 ) ), 'Add Button' => esc_html( $tax_object->labels->add_new_item ), 'ajax_nonce_field' => wp_nonce_field( 'add-'.$tax_name, '_ajax_nonce-add-'.$tax_name, false ), ); $category_add_link = MLAData::mla_parse_template( $page_template_array['category_add_link'], $page_values ); $category_adder = MLAData::mla_parse_template( $page_template_array['category_adder'], $page_values ); } else { $category_add_link = ''; $category_adder = ''; } $page_values = array( 'tax_html' => esc_html( $tax_object->labels->name ), 'tax_attr' => esc_attr( $tax_name ), 'tax_checklist' => $tax_checklist, 'category_add_link' => $category_add_link, 'Search' => __( '? Search', 'media-library-assistant' ), 'category_adder' => $category_adder, 'Search Reader' => __( 'Search', 'media-library-assistant' ) . ' ' . esc_html( $tax_object->labels->name ), 'Add' => __( 'Add', 'media-library-assistant' ), 'Remove' => __( 'Remove', 'media-library-assistant' ), 'Replace' => __( 'Replace', 'media-library-assistant' ), ); $category_block = MLAData::mla_parse_template( $page_template_array['category_block'], $page_values ); $taxonomy_options = MLAData::mla_parse_template( $page_template_array['taxonomy_options'], $page_values ); $quick_category_blocks .= $category_block; $bulk_category_blocks .= $category_block . $taxonomy_options; } // current_user_can } // foreach $hierarchical_taxonomies $page_values = array( 'category_blocks' => $quick_category_blocks ); $quick_middle_column = MLAData::mla_parse_template( $page_template_array['category_fieldset'], $page_values ); $page_values = array( 'category_blocks' => $bulk_category_blocks ); $bulk_middle_column = MLAData::mla_parse_template( $page_template_array['category_fieldset'], $page_values ); } // count( $hierarchical_taxonomies ) // The right-hand column contains the flat taxonomies, e.g., Att. Tag $quick_right_column = ''; $bulk_right_column = ''; if ( count( $flat_taxonomies ) ) { $quick_tag_blocks = ''; $bulk_tag_blocks = ''; foreach ( $flat_taxonomies as $tax_name => $tax_object ) { if ( current_user_can( $tax_object->cap->assign_terms ) ) { if ( MLACore::mla_taxonomy_support( $tax_name, 'flat-checklist' ) ) { ob_start(); wp_terms_checklist( NULL, array( 'taxonomy' => $tax_name, 'popular_cats' => array(), ) ); $tax_checklist = ob_get_contents(); ob_end_clean(); if ( MLACore::mla_taxonomy_support( $tax_name, 'checklist-add-term' ) ) { $page_values = array( 'tax_attr' => esc_attr( $tax_name ), 'Add New Term' => __( '+ Add New Term', 'media-library-assistant' ), 'Add Reader' => __( 'Add New', 'media-library-assistant' ) . ' ' . esc_html( $tax_object->labels->singular_name ), 'tax_parents' => "", 'Add Button' => esc_html( $tax_object->labels->add_new_item ), 'ajax_nonce_field' => wp_nonce_field( 'add-'.$tax_name, '_ajax_nonce-add-'.$tax_name, false ), ); $category_add_link = MLAData::mla_parse_template( $page_template_array['category_add_link'], $page_values ); $category_adder = MLAData::mla_parse_template( $page_template_array['category_adder'], $page_values ); } else { $category_add_link = ''; $category_adder = ''; } $page_values = array( 'tax_html' => esc_html( $tax_object->labels->name ), 'tax_attr' => esc_attr( $tax_name ), 'tax_checklist' => $tax_checklist, 'category_add_link' => $category_add_link, 'Search' => __( '? Search', 'media-library-assistant' ), 'category_adder' => $category_adder, 'Search Reader' => __( 'Search', 'media-library-assistant' ) . ' ' . esc_html( $tax_object->labels->name ), 'Add' => __( 'Add', 'media-library-assistant' ), 'Remove' => __( 'Remove', 'media-library-assistant' ), 'Replace' => __( 'Replace', 'media-library-assistant' ), ); $tag_block = MLAData::mla_parse_template( $page_template_array['category_block'], $page_values ); } else { $page_values = array( 'tax_html' => esc_html( $tax_object->labels->name ), 'tax_attr' => esc_attr( $tax_name ), 'Add' => __( 'Add', 'media-library-assistant' ), 'Remove' => __( 'Remove', 'media-library-assistant' ), 'Replace' => __( 'Replace', 'media-library-assistant' ), ); $tag_block = MLAData::mla_parse_template( $page_template_array['tag_block'], $page_values ); } $taxonomy_options = MLAData::mla_parse_template( $page_template_array['taxonomy_options'], $page_values ); $quick_tag_blocks .= $tag_block; $bulk_tag_blocks .= $tag_block . $taxonomy_options; } // current_user_can } // foreach $flat_taxonomies $page_values = array( 'tag_blocks' => $quick_tag_blocks ); $quick_right_column = MLAData::mla_parse_template( $page_template_array['tag_fieldset'], $page_values ); $page_values = array( 'tag_blocks' => $bulk_tag_blocks ); $bulk_right_column = MLAData::mla_parse_template( $page_template_array['tag_fieldset'], $page_values ); } // count( $flat_taxonomies ) if ( $authors = self::mla_authors_dropdown( -1 ) ) { $bulk_authors_dropdown = ' ' . "\n"; } else { $bulk_authors_dropdown = ''; } $bulk_custom_fields = ''; foreach ( MLACore::mla_custom_field_support( 'bulk_edit' ) as $slug => $details ) { $page_values = array( 'slug' => $slug, 'label' => esc_attr( $details['name'] ), ); $bulk_custom_fields .= MLAData::mla_parse_template( $page_template_array['custom_field'], $page_values ); } $set_parent_form = MLA::mla_set_parent_form(); if ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_BULK_EDITOR ) ) { $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); ob_start(); wp_editor( '', 'post_content', array( 'media_buttons' => false, 'tinymce' => false, 'textarea_rows' => 5, 'quicktags' => $quicktags_settings ) ); $description_field = ob_get_contents(); ob_end_clean(); } else { $description_field = ''; } $page_values = array( 'colspan' => $MLAListTable->get_column_count(), 'Quick Edit' => __( 'Quick Edit', 'media-library-assistant' ), 'Title' => __( 'Title', 'media-library-assistant' ), 'Name/Slug' => __( 'Name/Slug', 'media-library-assistant' ), 'Caption' => __( 'Caption', 'media-library-assistant' ), 'Description' => __( 'Description', 'media-library-assistant' ), 'description_field' => $description_field, 'ALT Text' => __( 'ALT Text', 'media-library-assistant' ), 'Uploaded on' => self::_generate_time_edit_form(), 'Bulk Uploaded on' => __( 'Uploaded on', 'media-library-assistant' ), 'Parent ID' => __( 'Parent ID', 'media-library-assistant' ), 'Select' => __( 'Select', 'media-library-assistant' ), 'Menu Order' => __( 'Menu Order', 'media-library-assistant' ), 'authors' => $authors_dropdown, 'custom_fields' => $custom_fields, 'quick_middle_column' => $quick_middle_column, 'quick_right_column' => $quick_right_column, 'Cancel' => __( 'Cancel', 'media-library-assistant' ), 'Reset' => __( 'Reset', 'media-library-assistant' ), 'Update' => __( 'Update', 'media-library-assistant' ), 'Bulk Edit' => __( 'Bulk Edit', 'media-library-assistant' ), 'bulk_middle_column' => $bulk_middle_column, 'bulk_right_column' => $bulk_right_column, 'bulk_authors' => $bulk_authors_dropdown, 'Comments' => __( 'Comments', 'media-library-assistant' ), 'Pings' => __( 'Pings', 'media-library-assistant' ), 'No Change' => __( 'No Change', 'media-library-assistant' ), 'Allow' => __( 'Allow', 'media-library-assistant' ), 'Do not allow' => __( 'Do not allow', 'media-library-assistant' ), 'bulk_custom_fields' => $bulk_custom_fields, 'bulk_map_style' => '', 'Map IPTC/EXIF metadata' => __( 'Map IPTC/EXIF metadata', 'media-library-assistant' ), 'bulk_custom_field_map_style' => '', 'Map Custom Field metadata' => __( 'Map Custom Field metadata', 'media-library-assistant' ), 'Bulk Waiting' => __( 'Waiting', 'media-library-assistant' ), 'Bulk Running' => __( 'In-process', 'media-library-assistant' ), 'Bulk Complete' => __( 'Complete', 'media-library-assistant' ), 'Refresh' => __( 'Refresh', 'media-library-assistant' ), 'set_parent_form' => $set_parent_form, ); if ( 'checked' != MLACore::mla_get_option( MLACoreOptions::MLA_ALLOW_CUSTOM_FIELD_MAPPING ) ) { $page_values['bulk_custom_field_map_style'] = 'display: none'; } if ( 'checked' != MLACore::mla_get_option( MLACoreOptions::MLA_ALLOW_IPTC_EXIF_MAPPING ) ) { $page_values['bulk_map_style'] = 'display: none'; } $page_values = apply_filters( 'mla_list_table_inline_values', $page_values ); $page_template = apply_filters( 'mla_list_table_inline_template', $page_template_array['page'] ); $parse_value = MLAData::mla_parse_template( $page_template, $page_values ); return apply_filters( 'mla_list_table_inline_parse', $parse_value, $page_template, $page_values ); } /** * Get the edit Authors dropdown box, if user has suitable permissions * * @since 0.20 * * @param integer Optional User ID of the current author, default 0 * @param string Optional HTML name attribute, default 'post_author' * @param string Optional HTML class attribute, default 'authors' * * @return string|false HTML markup for the dropdown field or False */ public static function mla_authors_dropdown( $author = 0, $name = 'post_author', $class = 'authors' ) { $post_type_object = get_post_type_object('attachment'); if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) { $users_opt = array( 'hide_if_only_one_author' => false, 'who' => 'authors', 'name' => $name, 'class'=> $class, 'multi' => 1, 'echo' => 0 ); if ( $author > 0 ) { $users_opt['selected'] = $author; $users_opt['include_selected'] = true; } elseif ( -1 == $author ) { $users_opt['show_option_none'] = '— ' . __( 'No Change', 'media-library-assistant' ) . ' —'; } if ( $authors = wp_dropdown_users( $users_opt ) ) { return $authors; } } return false; } /** * Get the current action selected from the bulk actions dropdown * * @since 0.1 * * @return string|false The action name or False if no action was selected */ private static function _current_bulk_action( ) { $action = false; if ( isset( $_REQUEST['action'] ) ) { if ( -1 != $_REQUEST['action'] ) { return $_REQUEST['action']; } else { $action = 'none'; } } // isset action if ( isset( $_REQUEST['action2'] ) ) { if ( -1 != $_REQUEST['action2'] ) { return $_REQUEST['action2']; } else { $action = 'none'; } } // isset action2 return $action; } /** * Delete a single item permanently * * @since 0.1 * * @param array The form POST data * * @return array success/failure message and NULL content */ private static function _delete_single_item( $post_id ) { if ( !current_user_can( 'delete_post', $post_id ) ) { return array( 'message' => __( 'ERROR', 'media-library-assistant' ) . ': ' . __( 'You are not allowed to delete this item.', 'media-library-assistant' ), 'body' => '' ); } if ( !wp_delete_attachment( $post_id, true ) ) { return array( /* translators: 1: ERROR tag 2: post ID */ 'message' => sprintf( __( '%1$s: Item %2$d could NOT be deleted.', 'media-library-assistant' ), __( 'ERROR', 'media-library-assistant' ), $post_id ), 'body' => '' ); } return array( /* translators: 1: post ID */ 'message' => sprintf( __( 'Item %1$d permanently deleted.', 'media-library-assistant' ), $post_id ), 'body' => '' ); } /** * Restore a single item from the Trash * * @since 0.1 * * @param integer The WordPress Post ID of the attachment item * * @return array success/failure message and NULL content */ private static function _restore_single_item( $post_id ) { if ( !current_user_can( 'delete_post', $post_id ) ) { return array( 'message' => __( 'ERROR', 'media-library-assistant' ) . ': ' . __( 'You are not allowed to move this item out of the Trash.', 'media-library-assistant' ), 'body' => '' ); } if ( !wp_untrash_post( $post_id ) ) { return array( /* translators: 1: ERROR tag 2: post ID */ 'message' => sprintf( __( '%1$s: Item %2$d could NOT be restored from Trash.', 'media-library-assistant' ), __( 'ERROR', 'media-library-assistant' ), $post_id ), 'body' => '' ); } /* * Posts are restored to "draft" status, so this must be updated. */ $update_post = array(); $update_post['ID'] = $post_id; $update_post['post_status'] = 'inherit'; wp_update_post( $update_post ); return array( /* translators: 1: post ID */ 'message' => sprintf( __( 'Item %1$d restored from Trash.', 'media-library-assistant' ), $post_id ), 'body' => '' ); } /** * Move a single item to Trash * * @since 0.1 * * @param integer The WordPress Post ID of the attachment item * * @return array success/failure message and NULL content */ private static function _trash_single_item( $post_id ) { if ( !current_user_can( 'delete_post', $post_id ) ) { return array( 'message' => __( 'ERROR', 'media-library-assistant' ) . ': ' . __( 'You are not allowed to move this item to the Trash.', 'media-library-assistant' ), 'body' => '' ); } if ( !wp_trash_post( $post_id, false ) ) { return array( /* translators: 1: ERROR tag 2: post ID */ 'message' => sprintf( __( '%1$s: Item %2$d could NOT be moved to Trash.', 'media-library-assistant' ), __( 'ERROR', 'media-library-assistant' ), $post_id ), 'body' => '' ); } return array( /* translators: 1: post ID */ 'message' => sprintf( __( 'Item %1$d moved to Trash.', 'media-library-assistant' ), $post_id ), 'body' => '' ); } } // class MLA ?>