/** * Add contextual help tabs to the WordPress Edit Media page * * @since 0.90 * * @param string title as shown on the screen * @param string title as shown in the HTML header * * @return void */ public static function mla_edit_add_help_tab($admin_title, $title) { $screen = get_current_screen(); /* * Upload New Media Bulk Edit Area */ if ('media' == $screen->id && 'add' == $screen->action) { $template_array = MLACore::mla_load_template('help-for-upload-new-media.tpl'); if (empty($template_array)) { return $admin_title; } /* * Replace sidebar content */ 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('#\\<!-- title="(.+)" order="(.+)" --\\>#', $content, $matches, PREG_OFFSET_CAPTURE); if ($match_count > 0) { $tab_array[$matches[2][0]] = array('id' => $id, 'title' => $matches[1][0], 'content' => $content); } else { /* translators: 1: ERROR tag 2: function name 3: template key */ error_log(sprintf(_x('%1$s: %2$s discarding "%3$s"; no title/order', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), 'mla_edit_add_help_tab', $id), 0); } } ksort($tab_array, SORT_NUMERIC); foreach ($tab_array as $indx => $value) { $screen->add_help_tab($value); } return $admin_title; } /* * Media/Edit Media submenu */ if ('attachment' != $screen->id || 'attachment' != $screen->post_type || 'post' != $screen->base) { return $admin_title; } $template_array = MLACore::mla_load_template('help-for-edit_attachment.tpl'); if (empty($template_array)) { return $admin_title; } /* * Provide explicit control over tab order */ $tab_array = array(); foreach ($template_array as $id => $content) { $match_count = preg_match('#\\<!-- title="(.+)" order="(.+)" --\\>#', $content, $matches, PREG_OFFSET_CAPTURE); if ($match_count > 0) { $tab_array[$matches[2][0]] = array('id' => $id, 'title' => $matches[1][0], 'content' => $content); } else { /* translators: 1: ERROR tag 2: function name 3: template key */ error_log(sprintf(_x('%1$s: %2$s discarding "%3$s"; no title/order', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), 'mla_edit_add_help_tab', $id), 0); } } ksort($tab_array, SORT_NUMERIC); foreach ($tab_array as $indx => $value) { $screen->add_help_tab($value); } return $admin_title; }
/** * Renders the Settings/Media Library Assistant "Language" tab * * @since 2.11 * * @return array ( 'message' => '', 'body' => '' ) */ public static function mla_render_language_tab() { $page_content = array('message' => '', 'body' => '<h2>' . __('Language', 'media-library-assistant') . '</h2>'); /* * Check for submit buttons to change or reset settings. * Initialize page messages and content. */ if (!empty($_REQUEST['mla-language-options-save'])) { check_admin_referer(MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME); $page_content = self::_save_language_settings(); } elseif (!empty($_REQUEST['mla-language-options-reset'])) { check_admin_referer(MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME); $page_content = self::_reset_language_settings(); } else { $page_content = array('message' => '', 'body' => ''); } if (!empty($page_content['body'])) { return $page_content; } /* * Find WPML Media plugin status */ $installed = false; $active = false; $wpml_media = SitePress::get_installed_plugins(); if (isset($wpml_media['WPML Media'])) { $wpml_media = $wpml_media['WPML Media']; if (!empty($wpml_media['plugin'])) { $installed = true; $active = isset($wpml_media['file']) && is_plugin_active($wpml_media['file']); } } $wpml_media = ''; if (!$installed) { $wpml_media = '<p><strong>' . __('WARNING:', 'media-library-assistant') . __(' WPML Media is not installed.', 'media-library-assistant') . '</strong></p>'; } elseif (!$active) { $wpml_media = '<p><strong>' . __('WARNING:', 'media-library-assistant') . __(' WPML Media is not active.', 'media-library-assistant') . '</strong></p>'; } $page_values = array('Language Options' => __('Language Options', 'media-library-assistant'), 'In this tab' => sprintf(__('In this tab you can find a number of options for controlling WPML-specific operations. Scroll down to find options for %1$s and %2$s. Be sure to click "Save Changes" at the bottom of the tab to save any changes you make.', 'media-library-assistant'), '<strong>' . __('Media/Assistant submenu table', 'media-library-assistant') . '</strong>', '<strong>' . __('Term Management', 'media-library-assistant') . '</strong>'), 'You can find' => sprintf(__('You can find more information about multilingual features in the %1$s section of the Documentation.', 'media-library-assistant'), '<a href="[+settingsURL+]?page=mla-settings-menu-documentation&mla_tab=documentation#mla_language_tab" title="' . __('Language Options documentation', 'media-library-assistant') . '">' . __('WPML & Polylang Multilingual Support; the MLA Language Tab', 'media-library-assistant') . '</a>'), 'WPML Status' => $wpml_media, 'settingsURL' => admin_url('options-general.php'), 'Save Changes' => __('Save Changes', 'media-library-assistant'), 'Delete Language options' => __('Delete Language options and restore default settings', 'media-library-assistant'), '_wpnonce' => wp_nonce_field(MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME, true, false), '_wp_http_referer' => wp_referer_field(false), 'Go to Top' => __('Go to Top', 'media-library-assistant'), 'form_url' => admin_url('options-general.php') . '?page=mla-settings-menu-language&mla_tab=language', 'options_list' => ''); $options_list = ''; foreach (MLA_WPML::$mla_language_option_definitions as $key => $value) { if ('language' == $value['tab']) { $options_list .= MLASettings::mla_compose_option_row($key, $value, MLA_WPML::$mla_language_option_definitions); } } $page_values['options_list'] = $options_list; $page_template = MLACore::mla_load_template('admin-display-language-tab.tpl'); $page_content['body'] = MLAData::mla_parse_template($page_template, $page_values); return $page_content; }
/** * MLA_List_Table inline edit parse * * @since 2.13 * * Adds Bulk Translate form and the Language dropdown * markup used for the Quick and Bulk Edit forms. * * @param string HTML markup returned by the template parser * @param string template used to generate the HTML markup * @param array parameter_name => parameter_value pairs * * @return array updated HTML markup for the Quick and Bulk Edit forms */ public static function mla_list_table_inline_parse($html_markup, $item_template, $item_values) { /* * Add the Thumbnail Generation Markup */ $page_template_array = MLAData::mla_load_template('mla-thumbnail-generation.tpl'); if (!is_array($page_template_array)) { error_log('ERROR: mla-thumbnail-generation.tpl path = ' . var_export(plugin_dir_path(__FILE__) . 'mla-thumbnail-generation.tpl', true), 0); error_log('ERROR: mla-thumbnail-generation.tpl non-array result = ' . var_export($page_template_array, true), 0); return $html_markup; } $page_values = array('colspan' => $item_values['colspan'], 'Generate Thumbnails' => __('Generate Thumbnails', 'media-library-assistant'), 'See Documentation' => __('Pull down the Help menu and select Thumbnail Generation for setting details', 'media-library-assistant'), 'Width' => __('Width', 'media-library-assistant'), 'Height' => __('Height', 'media-library-assistant'), 'Best Fit' => __('Best Fit', 'media-library-assistant'), 'Page' => __('Page', 'media-library-assistant'), 'Resolution' => __('Resolution', 'media-library-assistant'), 'Quality' => __('Quality', 'media-library-assistant'), 'Type' => __('Type', 'media-library-assistant'), 'Existing Items' => __('Existing Items', 'media-library-assistant'), 'Keep' => __('Keep', 'media-library-assistant'), 'Ignore' => __('Ignore', 'media-library-assistant'), 'Trash' => __('Trash', 'media-library-assistant'), 'Delete' => __('Delete', 'media-library-assistant'), 'Suffix' => __('Suffix', 'media-library-assistant'), 'default_suffix' => '-' . __('Thumbnail', 'media-library-assistant'), 'Options' => __('Options', 'media-library-assistant'), 'Clear Filter-by' => __('Clear Filter-by', 'media-library-assistant'), 'Cancel' => __('Cancel', 'media-library-assistant')); $parse_value = MLAData::mla_parse_template($page_template_array['page'], $page_values); return $html_markup . "\n" . $parse_value; }
/** * 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 <form> 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->hierarchical && $tax_object->show_ui && MLAOptions::mla_taxonomy_support($tax_name, 'quick-edit')) { $hierarchical_taxonomies[$tax_name] = $tax_object; } elseif ($tax_object->show_ui && MLAOptions::mla_taxonomy_support($tax_name, 'quick-edit')) { $flat_taxonomies[$tax_name] = $tax_object; } } $page_template_array = MLAData::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 */ error_log(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)), 0); return ''; } if ($authors = self::mla_authors_dropdown()) { $authors_dropdown = ' <label class="inline-edit-author">' . "\n"; $authors_dropdown .= ' <span class="title">' . __('Author', 'media-library-assistant') . '</span>' . "\n"; $authors_dropdown .= $authors . "\n"; $authors_dropdown .= ' </label>' . "\n"; } else { $authors_dropdown = ''; } $custom_fields = ''; foreach (MLAOptions::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., Attachment 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)); $tax_checklist = ob_get_contents(); ob_end_clean(); $page_values = array('tax_html' => esc_html($tax_object->labels->name), 'more' => __('more', 'media-library-assistant'), 'less' => __('less', 'media-library-assistant'), 'tax_attr' => esc_attr($tax_name), 'tax_checklist' => $tax_checklist, '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., Attachment 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)) { $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 = ' <label class="inline-edit-author alignright">' . "\n"; $bulk_authors_dropdown .= ' <span class="title">' . __('Author', 'media-library-assistant') . '</span>' . "\n"; $bulk_authors_dropdown .= $authors . "\n"; $bulk_authors_dropdown .= ' </label>' . "\n"; } else { $bulk_authors_dropdown = ''; } $bulk_custom_fields = ''; foreach (MLAOptions::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(); $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'), 'ALT Text' => __('ALT Text', '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, 'Map IPTC/EXIF metadata' => __('Map IPTC/EXIF metadata', 'media-library-assistant'), '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); $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); }
/** * Build the hidden form for the "Search Terms" popup modal window * * @since 1.90 * * @return string HTML <form> markup for hidden form */ public static function mla_terms_search_form() { $page_template_array = MLACore::mla_load_template('admin-terms-search-form.tpl'); if (!is_array($page_template_array)) { /* translators: 1: ERROR tag 2: function name 3: non-array value */ error_log(sprintf(_x('%1$s: %2$s non-array "%3$s"', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), 'MLA::_build_terms_search_form', var_export($page_template_array, true)), 0); return ''; } $taxonomies = array(); foreach (get_object_taxonomies('attachment', 'objects') as $taxonomy) { if (MLACore::mla_taxonomy_support($taxonomy->name, 'support')) { $taxonomies[] = $taxonomy; } } if (empty($taxonomies)) { $page_values = array('Search Terms' => __('Search Terms', 'media-library-assistant'), 'message' => __('There are no taxonomies to search', 'media-library-assistant')); $terms_search_tpl = MLAData::mla_parse_template($page_template_array['mla-terms-search-empty-div'], $page_values); } else { $taxonomy_list = ''; foreach ($taxonomies as $taxonomy) { $page_values = array('taxonomy_checked' => MLACore::mla_taxonomy_support($taxonomy->name, 'term-search') ? 'checked="checked"' : '', 'taxonomy_slug' => $taxonomy->name, 'taxonomy_label' => esc_attr($taxonomy->label)); $taxonomy_list .= MLAData::mla_parse_template($page_template_array['mla-terms-search-taxonomy'], $page_values); } $page_values = array('Search Terms' => __('Search Terms', 'media-library-assistant'), 'Search' => __('Search', 'media-library-assistant'), 'phrases_and_checked' => 'checked="checked"', 'All phrases' => __('All phrases', 'media-library-assistant'), 'phrases_or_checked' => '', 'Any phrase' => __('Any phrase', 'media-library-assistant'), 'terms_and_checked' => '', 'All terms' => __('All terms', 'media-library-assistant'), 'terms_or_checked' => 'checked="checked"', 'Any term' => __('Any term', 'media-library-assistant'), 'exact_checked' => '', 'Exact' => __('Exact', 'media-library-assistant'), 'mla_terms_search_taxonomies' => $taxonomy_list); $terms_search_tpl = MLAData::mla_parse_template($page_template_array['mla-terms-search-div'], $page_values); } $page_values = array('mla_terms_search_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_terms_search_action' => MLA::MLA_ADMIN_TERMS_SEARCH, 'wpnonce' => wp_nonce_field(MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME, true, false), 'mla_terms_search_div' => $terms_search_tpl); $terms_search_tpl = MLAData::mla_parse_template($page_template_array['mla-terms-search-form'], $page_values); return $terms_search_tpl; }
/** * Handles brace/bracket escaping and parses template for a shortcode parameter * * @since 1.14 * * @param string raw shortcode parameter, e.g., "text {+field+} {brackets} \\{braces\\}" * @param string template substitution values, e.g., ('instance' => '1', ... ) * * @return string parameter with brackets, braces, substitution parameters and templates processed */ private static function _process_shortcode_parameter($text, $markup_values) { $new_text = str_replace('{', '[', str_replace('}', ']', $text)); $new_text = str_replace('\\[', '{', str_replace('\\]', '}', $new_text)); return MLAData::mla_parse_template($new_text, $markup_values); }
/** * Evaluate custom field mapping data source * * @since 2.20 * * @param integer post->ID of attachment * @param string category/scope to evaluate against: custom_field_mapping or single_attachment_mapping * @param array data source specification ( name, *data_source, *keep_existing, *format, mla_column, quick_edit, bulk_edit, *meta_name, *option, no_null ) * @param array (optional) _wp_attachment_metadata, default NULL (use current postmeta database value) * * @return string|array data source value */ private static function _evaluate_data_source($post_id, $category, $data_value, $attachment_metadata = NULL) { global $wpdb; static $upload_dir, $intermediate_sizes = NULL, $wp_attached_files = NULL, $wp_attachment_metadata = NULL; static $current_id = 0, $file_info = NULL, $parent_info = NULL, $references = NULL, $alt_text = NULL; if ('none' == $data_value['data_source']) { return ''; } $data_source = $data_value['data_source']; /* * Do this once per page load; cache attachment metadata if mapping all attachments */ if (NULL == $intermediate_sizes) { $upload_dir = wp_upload_dir(); $upload_dir = $upload_dir['basedir'] . '/'; $intermediate_sizes = get_intermediate_image_sizes(); if ('custom_field_mapping' == $category) { if (!($table = _get_meta_table('post'))) { $wp_attached_files = array(); $wp_attachment_metadata = array(); } else { $wp_attachment_metadata = $wpdb->get_results("SELECT post_id, meta_value FROM {$table} WHERE meta_key = '_wp_attachment_metadata'", OBJECT_K); $wp_attached_files = $wpdb->get_results("SELECT post_id, meta_value FROM {$table} WHERE meta_key = '_wp_attached_file'", OBJECT_K); } } // custom_field_mapping, i.e., mapping all attachments } // first call after page load /* * Do this once per post. Simulate SQL results for $wp_attached_files and $wp_attachment_metadata. */ if ($current_id != $post_id) { $current_id = $post_id; $parent_info = NULL; $references = NULL; $alt_text = NULL; if ('single_attachment_mapping' == $category) { $metadata = get_metadata('post', $post_id, '_wp_attached_file'); if (isset($metadata[0])) { $wp_attached_files = array($post_id => (object) array('post_id' => $post_id, 'meta_value' => $metadata[0])); } else { $wp_attached_files = array(); } if (NULL == $attachment_metadata) { $metadata = get_metadata('post', $post_id, '_wp_attachment_metadata'); if (isset($metadata[0])) { $attachment_metadata = $metadata[0]; } } if (empty($attachment_metadata)) { $attachment_metadata = array(); } $wp_attachment_metadata = array($post_id => (object) array('post_id' => $post_id, 'meta_value' => serialize($attachment_metadata))); } $file_info = MLAData_Source::_evaluate_file_information($upload_dir, $wp_attached_files, $wp_attachment_metadata, $post_id); } $size_info = array('file' => '', 'width' => '', 'height' => ''); $match_count = preg_match('/(.+)\\[(.+)\\]/', $data_source, $matches); if (1 == $match_count) { $data_source = $matches[1] . '[size]'; if (isset($file_info['sizes'][$matches[2]])) { $size_info = $file_info['sizes'][$matches[2]]; } } $result = ''; switch ($data_source) { case 'meta': $attachment_metadata = isset($wp_attachment_metadata[$post_id]->meta_value) ? maybe_unserialize($wp_attachment_metadata[$post_id]->meta_value) : array(); $result = MLAData::mla_find_array_element($data_value['meta_name'], $attachment_metadata, $data_value['option'], $data_value['keep_existing']); break; case 'template': if (in_array($data_value['option'], array('single', 'export', 'array', 'multi'))) { $default_option = 'array'; } else { $default_option = 'text'; } /* * Go through the template and expand the non-prefixed elements * as Data Sources */ $item_values = array(); $placeholders = MLAData::mla_get_template_placeholders($data_value['meta_name'], $default_option); foreach ($placeholders as $key => $placeholder) { if (empty($placeholder['prefix'])) { $field_value = $data_value; $field_value['data_source'] = $placeholder['value']; $field_value['meta_name'] = ''; $field_value['option'] = $placeholder['option']; $field_value['format'] = $placeholder['format']; if (isset($placeholder['args'])) { $field_value['args'] = $placeholder['args']; } $field_value = MLAData_Source::_evaluate_data_source($post_id, $category, $field_value, $attachment_metadata); $item_values[$key] = MLAData::mla_apply_field_level_format($field_value, $placeholder); } // Data Source } // foreach placeholder /* * Now expand the template using the above Data Source values */ $template = '[+template:' . $data_value['meta_name'] . '+]'; $item_values = MLAData::mla_expand_field_level_parameters($template, NULL, $item_values, $post_id, $data_value['keep_existing'], $default_option); if ('array' == $default_option) { $result = MLAData::mla_parse_array_template($template, $item_values); $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); } else { $result = MLAData::mla_parse_template($template, $item_values); } break; case 'parent': $data_source = 'post_parent'; /* fallthru */ /* fallthru */ case 'ID': case 'post_id': case 'post_author': case 'post_parent': case 'menu_order': case 'comment_count': $result = absint(MLAData_Source::_evaluate_post_information($post_id, $category, $data_source)); break; case 'alt_text': if (NULL == $alt_text) { $metadata = get_metadata('post', $post_id, '_wp_attachment_image_alt'); if (is_array($metadata)) { if (count($metadata) == 1) { $alt_text = maybe_unserialize($metadata[0]); } else { $alt_text = array(); foreach ($metadata as $single_key => $single_value) { $alt_text[$single_key] = maybe_unserialize($single_value); } } } } if (!empty($alt_text)) { $result = MLAData_Source::_evaluate_array_result($alt_text, $data_value['option'], $data_value['keep_existing']); } break; case 'mime_type': $data_source = 'post_mime_type'; /* fallthru */ /* fallthru */ case 'post_date': case 'post_date_gmt': case 'post_content': case 'post_title': case 'post_excerpt': case 'post_status': case 'comment_status': case 'ping_status': case 'post_name': case 'post_modified': case 'post_modified_gmt': case 'post_content_filtered': case 'guid': case 'post_mime_type': $result = MLAData_Source::_evaluate_post_information($post_id, $category, $data_source); break; case 'absolute_path': case 'absolute_file_name': case 'base_file': case 'path': case 'file_name': case 'name_only': case 'extension': case 'width': case 'height': case 'orientation': case 'hwstring_small': case 'aperture': case 'credit': case 'camera': case 'caption': case 'created_timestamp': case 'copyright': case 'focal_length': case 'iso': case 'shutter_speed': case 'title': if (isset($file_info[$data_source])) { $result = $file_info[$data_source]; } break; case 'file_size': $filesize = @filesize($file_info['absolute_file_name_raw']); if (!(false === $filesize)) { $result = $filesize; } break; case 'upload_date': $result = MLAData_Source::_evaluate_post_information($post_id, $category, 'post_date'); break; case 'dimensions': $result = $file_info['width'] . 'x' . $file_info['height']; if ('x' == $result) { $result = ''; } break; case 'pixels': $result = absint((int) $file_info['width'] * (int) $file_info['height']); if (0 == $result) { $result = ''; } else { $result = (string) $result; } break; case 'size_keys': $result = array(); foreach ($file_info['sizes'] as $key => $value) { $result[] = $key; } $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); break; case 'size_names': $result = array(); foreach ($file_info['sizes'] as $key => $value) { $result[] = $value['file']; } $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); break; case 'size_bytes': $result = array(); foreach ($file_info['sizes'] as $key => $value) { $filesize = @filesize($file_info['absolute_path_raw'] . $value['file']); if (false === $filesize) { $result[] = '?'; } else { switch ($data_value['format']) { case 'commas': if (is_numeric($filesize)) { $filesize = number_format((double) $filesize); } break; default: // no change } // format $result[] = $filesize; } } $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); break; case 'size_pixels': $result = array(); foreach ($file_info['sizes'] as $key => $value) { $pixels = absint((int) $value['width'] * (int) $value['height']); switch ($data_value['format']) { case 'commas': if (is_numeric($pixels)) { $pixels = number_format((double) $pixels); } break; default: // no change } // format $result[] = $pixels; } $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); break; case 'size_dimensions': $result = array(); foreach ($file_info['sizes'] as $key => $value) { $result[] = $value['width'] . 'x' . $value['height']; } $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); break; case 'size_name[size]': $result = $size_info['file']; break; case 'size_bytes[size]': $result = @filesize($file_info['absolute_path_raw'] . $size_info['file']); if (false === $result) { $result = '?'; } break; case 'size_pixels[size]': $result = absint((int) $size_info['width'] * (int) $size_info['height']); break; case 'size_dimensions[size]': $result = $size_info['width'] . 'x' . $size_info['height']; if ('x' == $result) { $result = ''; } break; case 'parent_date': case 'parent_type': case 'parent_title': if (is_null($parent_info)) { $parent_info = MLAQuery::mla_fetch_attachment_parent_data(MLAData_Source::_evaluate_post_information($post_id, $category, 'post_parent')); } if (isset($parent_info[$data_source])) { $result = $parent_info[$data_source]; } break; case 'parent_issues': if (is_null($references)) { $references = MLAQuery::mla_fetch_attachment_references($post_id, MLAData_Source::_evaluate_post_information($post_id, $category, 'post_parent')); } if (!empty($references['parent_errors'])) { $result = $references['parent_errors']; /* * Remove (ORPHAN... */ $orphan_certain = '(' . __('ORPHAN', 'media-library-assistant') . ')'; $orphan_possible = '(' . __('ORPHAN', 'media-library-assistant') . '?)'; if (false !== strpos($result, $orphan_certain)) { $result = trim(substr($result, strlen($orphan_certain))); } elseif (false !== strpos($result, $orphan_possible)) { $result = trim(substr($result, strlen($orphan_possible))); } } break; case 'reference_issues': if (is_null($references)) { $references = MLAQuery::mla_fetch_attachment_references($post_id, MLAData_Source::_evaluate_post_information($post_id, $category, 'post_parent')); } if (!empty($references['parent_errors'])) { $result = $references['parent_errors']; } break; case 'featured_in': case 'featured_in_title': if (is_null($references)) { $references = MLAQuery::mla_fetch_attachment_references($post_id, MLAData_Source::_evaluate_post_information($post_id, $category, 'post_parent')); } if (!empty($references['features'])) { $result = array(); foreach ($references['features'] as $ID => $value) { if ('featured_in' == $data_source) { $result[] = sprintf('%1$s (%2$s %3$d)', $value->post_title, $value->post_type, $ID); } else { $result[] = $value->post_title; } } $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); } else { $result = ''; } break; case 'inserted_in': case 'inserted_in_title': if (is_null($references)) { $references = MLAQuery::mla_fetch_attachment_references($post_id, MLAData_Source::_evaluate_post_information($post_id, $category, 'post_parent')); } if (!empty($references['inserts'])) { $result = array(); foreach ($references['inserts'] as $base_file => $inserts) { foreach ($inserts as $value) { if ('inserted_in' == $data_source) { $result[] = sprintf('%1$s (%2$s %3$d)', $value->post_title, $value->post_type, $value->ID); } else { $result[] = $value->post_title; } } } ksort($result); $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); } else { $result = ''; } break; case 'gallery_in': case 'gallery_in_title': if (is_null($references)) { $references = MLAQuery::mla_fetch_attachment_references($post_id, MLAData_Source::_evaluate_post_information($post_id, $category, 'post_parent')); } if (!empty($references['galleries'])) { $result = array(); foreach ($references['galleries'] as $ID => $value) { if ('gallery_in' == $data_source) { $result[] = sprintf('%1$s (%2$s %3$d)', $value['post_title'], $value['post_type'], $ID); } else { $result[] = $value['post_title']; } } $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); } else { $result = ''; } break; case 'mla_gallery_in': case 'mla_gallery_in_title': if (is_null($references)) { $references = MLAQuery::mla_fetch_attachment_references($post_id, MLAData_Source::_evaluate_post_information($post_id, $category, 'post_parent')); } if (!empty($references['mla_galleries'])) { $result = array(); foreach ($references['mla_galleries'] as $ID => $value) { if ('mla_gallery_in' == $data_source) { $result[] = sprintf('%1$s (%2$s %3$d)', $value['post_title'], $value['post_type'], $ID); } else { $result[] = $value['post_title']; } } $result = MLAData_Source::_evaluate_array_result($result, $data_value['option'], $data_value['keep_existing']); } else { $result = ''; } break; default: $custom_value = apply_filters('mla_evaluate_custom_data_source', NULL, $post_id, $category, $data_value, $attachment_metadata); if (!is_null($custom_value)) { return $custom_value; } return ''; } // switch $data_source switch ($data_value['format']) { case 'raw': return $result; case 'commas': if (is_numeric($result)) { $result = str_pad(number_format((double) $result), 15, ' ', STR_PAD_LEFT); } break; case 'native': default: /* * Make some numeric values sortable as strings, make all value non-empty */ if (in_array($data_source, array('file_size', 'pixels', 'width', 'height'))) { $result = str_pad($result, 15, ' ', STR_PAD_LEFT); } elseif (empty($result)) { $result = ' '; } } // format return $result; }
/** * Render and manage iptc/exif support options * * @since 1.00 * @uses $mla_option_templates contains row and table templates * * @param string 'render', 'update', 'delete', or 'reset' * @param string option name, e.g., 'iptc_exif_mapping' * @param array option parameters * @param array Optional. null (default) for 'render' else option data, e.g., $_REQUEST * * @return string HTML table row markup for 'render' else message(s) reflecting the results of the operation. */ public static function mla_iptc_exif_option_handler($action, $key, $value, $args = NULL) { $current_values = MLACore::mla_get_option('iptc_exif_mapping'); switch ($action) { case 'render': switch ($key) { case 'iptc_exif_standard_mapping': $row_template = MLAOptions::$mla_option_templates['iptc-exif-standard-row']; $table_rows = ''; foreach ($current_values['standard'] as $row_name => $row_value) { $row_values = array('key' => esc_attr($row_name), 'name_attr' => esc_attr($row_value['name']), 'name' => esc_html($row_value['name']), 'iptc_field_options' => MLAOptions::_compose_iptc_option_list($row_value['iptc_value']), 'exif_size' => MLACoreOptions::MLA_EXIF_SIZE, 'exif_text' => esc_attr($row_value['exif_value']), 'iptc_selected' => '', 'IPTC' => __('IPTC', 'media-library-assistant'), 'exif_selected' => '', 'EXIF' => __('EXIF', 'media-library-assistant'), 'keep_selected' => '', 'Keep' => __('Keep', 'media-library-assistant'), 'replace_selected' => '', 'Replace' => __('Replace', 'media-library-assistant')); if ($row_value['iptc_first']) { $row_values['iptc_selected'] = 'selected="selected"'; } else { $row_values['exif_selected'] = 'selected="selected"'; } if ($row_value['keep_existing']) { $row_values['keep_selected'] = 'selected="selected"'; } else { $row_values['replace_selected'] = 'selected="selected"'; } $table_rows .= MLAData::mla_parse_template($row_template, $row_values); } // foreach row $option_values = array('Field Title' => __('Field Title', 'media-library-assistant'), 'IPTC Value' => __('IPTC Value', 'media-library-assistant'), 'EXIF/Template Value' => __('EXIF/Template Value', 'media-library-assistant'), 'Priority' => __('Priority', 'media-library-assistant'), 'Existing Text' => __('Existing Text', 'media-library-assistant'), 'table_rows' => $table_rows, 'help' => $value['help']); return MLAData::mla_parse_template(MLAOptions::$mla_option_templates['iptc-exif-standard-table'], $option_values); case 'iptc_exif_taxonomy_mapping': $row_template = MLAOptions::$mla_option_templates['iptc-exif-taxonomy-row']; $select_template = MLAOptions::$mla_option_templates['iptc-exif-select']; $table_rows = ''; $taxonomies = get_taxonomies(array('show_ui' => true), 'objects'); foreach ($taxonomies as $row_name => $row_value) { if (!MLACore::mla_taxonomy_support($row_name, 'support')) { continue; } $row_values = array('key' => esc_attr($row_name), 'name' => esc_html($row_value->labels->name), 'hierarchical' => (string) $row_value->hierarchical, 'iptc_field_options' => '', 'exif_size' => MLACoreOptions::MLA_EXIF_SIZE, 'exif_text' => '', 'iptc_selected' => '', 'IPTC' => __('IPTC', 'media-library-assistant'), 'exif_selected' => '', 'EXIF' => __('EXIF', 'media-library-assistant'), 'keep_selected' => '', 'Keep' => __('Keep', 'media-library-assistant'), 'replace_selected' => '', 'Replace' => __('Replace', 'media-library-assistant'), 'delimiters_size' => 4, 'delimiters_text' => '', 'parent_select' => ''); if (array_key_exists($row_name, $current_values['taxonomy'])) { $current_value = $current_values['taxonomy'][$row_name]; $row_values['iptc_field_options'] = MLAOptions::_compose_iptc_option_list($current_value['iptc_value']); $row_values['exif_text'] = esc_attr($current_value['exif_value']); if ($current_value['iptc_first']) { $row_values['iptc_selected'] = 'selected="selected"'; } else { $row_values['exif_selected'] = 'selected="selected"'; } if ($current_value['keep_existing']) { $row_values['keep_selected'] = 'selected="selected"'; } else { $row_values['replace_selected'] = 'selected="selected"'; } $row_values['delimiters_text'] = $current_value['delimiters']; if ($row_value->hierarchical) { $parent = isset($current_value['parent']) ? (int) $current_value['parent'] : 0; $select_values = array('array' => 'taxonomy', 'key' => esc_attr($row_name), 'element' => 'parent', 'options' => MLAOptions::_compose_parent_option_list($row_name, $parent)); $row_values['parent_select'] = MLAData::mla_parse_template($select_template, $select_values); } } else { $row_values['iptc_field_options'] = MLAOptions::_compose_iptc_option_list('none'); $row_values['iptc_selected'] = 'selected="selected"'; $row_values['keep_selected'] = 'selected="selected"'; if ($row_value->hierarchical) { $select_values = array('array' => 'taxonomy', 'key' => esc_attr($row_name), 'element' => 'parent', 'options' => MLAOptions::_compose_parent_option_list($row_name, 0)); $row_values['parent_select'] = MLAData::mla_parse_template($select_template, $select_values); } } $table_rows .= MLAData::mla_parse_template($row_template, $row_values); } // foreach row $option_values = array('Field Title' => __('Field Title', 'media-library-assistant'), 'IPTC Value' => __('IPTC Value', 'media-library-assistant'), 'EXIF/Template Value' => __('EXIF/Template Value', 'media-library-assistant'), 'Priority' => __('Priority', 'media-library-assistant'), 'Existing Text' => __('Existing Text', 'media-library-assistant'), 'Delimiter(s)' => __('Delimiter(s)', 'media-library-assistant'), 'Parent' => __('Parent', 'media-library-assistant'), 'table_rows' => $table_rows, 'help' => $value['help']); return MLAData::mla_parse_template(MLAOptions::$mla_option_templates['iptc-exif-taxonomy-table'], $option_values); case 'iptc_exif_custom_mapping': if (empty($current_values['custom'])) { $table_rows = MLAData::mla_parse_template(MLAOptions::$mla_option_templates['iptc-exif-custom-empty-row'], array('No Mapping Rules' => __('No Custom Field Mapping Rules Defined', 'media-library-assistant'), 'column_count' => 5)); } else { $row_template = MLAOptions::$mla_option_templates['iptc-exif-custom-rule-row']; $table_rows = ''; $index = 0; } /* * One row for each existing rule, case insensitive "natural order" */ $sorted_keys = array(); foreach ($current_values['custom'] as $row_name => $current_value) { $sorted_keys[$current_value['name']] = $current_value['name']; } natcasesort($sorted_keys); $sorted_names = array(); foreach ($sorted_keys as $row_name) { $sorted_names[$row_name] = array(); } /* * Allow for multiple rules mapping the same name (an old bug) */ foreach ($current_values['custom'] as $row_name => $current_value) { $sorted_names[$current_value['name']][] = $row_name; } foreach ($sorted_names as $sorted_keys) { foreach ($sorted_keys as $row_name) { $current_value = $current_values['custom'][$row_name]; $row_values = array('column_count' => 5, 'column_count_meta' => 5 - 2, 'index' => $index++, 'key' => esc_attr($row_name), 'name_attr' => esc_attr($current_value['name']), 'name' => esc_html($current_value['name']), 'iptc_field_options' => MLAOptions::_compose_iptc_option_list($current_value['iptc_value']), 'exif_size' => MLACoreOptions::MLA_EXIF_SIZE, 'exif_text' => esc_attr($current_value['exif_value']), 'iptc_selected' => '', 'IPTC' => __('IPTC', 'media-library-assistant'), 'exif_selected' => '', 'EXIF' => __('EXIF', 'media-library-assistant'), 'keep_selected' => '', 'Keep' => __('Keep', 'media-library-assistant'), 'replace_selected' => '', 'Replace' => __('Replace', 'media-library-assistant'), 'Format' => __('Format', 'media-library-assistant'), 'native_format' => '', 'Native' => __('Native', 'media-library-assistant'), 'commas_format' => '', 'Commas' => __('Commas', 'media-library-assistant'), 'raw_format' => '', 'Raw' => __('Raw', 'media-library-assistant'), 'Option' => __('Option', 'media-library-assistant'), 'text_option' => '', 'Text' => __('Text', 'media-library-assistant'), 'single_option' => '', 'Single' => __('Single', 'media-library-assistant'), 'export_option' => '', 'Export' => __('Export', 'media-library-assistant'), 'array_option' => '', 'Array' => __('Array', 'media-library-assistant'), 'multi_option' => '', 'Multi' => __('Multi', 'media-library-assistant'), 'no_null_checked' => '', 'Delete NULL values' => __('Delete NULL values', 'media-library-assistant'), 'Delete Rule' => __('Delete Rule', 'media-library-assistant'), 'Delete Field' => __('Delete Rule AND Field', 'media-library-assistant'), 'Update Rule' => __('Update Rule', 'media-library-assistant'), 'Map All Attachments' => __('Map All Attachments', 'media-library-assistant')); if ($current_value['iptc_first']) { $row_values['iptc_selected'] = 'selected="selected"'; } else { $row_values['exif_selected'] = 'selected="selected"'; } if ($current_value['keep_existing']) { $row_values['keep_selected'] = 'selected="selected"'; } else { $row_values['replace_selected'] = 'selected="selected"'; } switch ($current_value['format']) { case 'commas': $row_values['commas_format'] = 'selected="selected"'; break; case 'raw': $row_values['raw_format'] = 'selected="selected"'; break; default: $row_values['native_format'] = 'selected="selected"'; } // format switch ($current_value['option']) { case 'single': $row_values['single_option'] = 'selected="selected"'; break; case 'export': $row_values['export_option'] = 'selected="selected"'; break; case 'array': $row_values['array_option'] = 'selected="selected"'; break; case 'multi': $row_values['multi_option'] = 'selected="selected"'; break; default: $row_values['text_option'] = 'selected="selected"'; } // option if ($current_value['no_null']) { $row_values['no_null_checked'] = 'checked="checked"'; } $table_rows .= MLAData::mla_parse_template($row_template, $row_values); } // foreach current_values key } // foreach sorted_name /* * Add a row for defining a new rule, existing Custom Field */ $row_template = MLAOptions::$mla_option_templates['iptc-exif-custom-new-rule-row']; $row_values = array('column_count' => 5, 'column_count_meta' => 5 - 2, 'Add new Rule' => __('Add a new Mapping Rule', 'media-library-assistant'), 'index' => MLACoreOptions::MLA_NEW_CUSTOM_RULE, 'field_name_options' => MLAOptions::_compose_custom_field_option_list('none', $current_values['custom']), 'iptc_field_options' => MLAOptions::_compose_iptc_option_list('none'), 'exif_size' => MLACoreOptions::MLA_EXIF_SIZE, 'exif_text' => '', 'iptc_selected' => 'selected="selected"', 'IPTC' => __('IPTC', 'media-library-assistant'), 'exif_selected' => '', 'EXIF' => __('EXIF', 'media-library-assistant'), 'keep_selected' => 'selected="selected"', 'Keep' => __('Keep', 'media-library-assistant'), 'replace_selected' => '', 'Replace' => __('Replace', 'media-library-assistant'), 'Format' => __('Format', 'media-library-assistant'), 'native_format' => 'selected="selected"', 'Native' => __('Native', 'media-library-assistant'), 'commas_format' => '', 'Commas' => __('Commas', 'media-library-assistant'), 'raw_format' => '', 'Raw' => __('Raw', 'media-library-assistant'), 'Option' => __('Option', 'media-library-assistant'), 'text_option' => '', 'Text' => __('Text', 'media-library-assistant'), 'single_option' => '', 'Single' => __('Single', 'media-library-assistant'), 'export_option' => '', 'Export' => __('Export', 'media-library-assistant'), 'array_option' => '', 'Array' => __('Array', 'media-library-assistant'), 'multi_option' => '', 'Multi' => __('Multi', 'media-library-assistant'), 'no_null_checked' => '', 'Delete NULL values' => __('Delete NULL values', 'media-library-assistant'), 'Add Rule' => __('Add Rule', 'media-library-assistant'), 'Map All Attachments' => __('Add Rule and Map All Attachments', 'media-library-assistant')); $table_rows .= MLAData::mla_parse_template($row_template, $row_values); /* * Add a row for defining a new rule, new Custom Field */ $row_template = MLAOptions::$mla_option_templates['iptc-exif-custom-new-field-row']; $row_values = array('column_count' => 5, 'column_count_meta' => 5 - 2, 'Add new Field' => __('Add a new Field and Mapping Rule', 'media-library-assistant'), 'index' => MLACoreOptions::MLA_NEW_CUSTOM_FIELD, 'field_name_size' => '24', 'iptc_field_options' => MLAOptions::_compose_iptc_option_list('none'), 'exif_size' => MLACoreOptions::MLA_EXIF_SIZE, 'exif_text' => '', 'iptc_selected' => 'selected="selected"', 'IPTC' => __('IPTC', 'media-library-assistant'), 'exif_selected' => '', 'EXIF' => __('EXIF', 'media-library-assistant'), 'keep_selected' => 'selected="selected"', 'Keep' => __('Keep', 'media-library-assistant'), 'replace_selected' => '', 'Replace' => __('Replace', 'media-library-assistant'), 'Format' => __('Format', 'media-library-assistant'), 'native_format' => 'selected="selected"', 'Native' => __('Native', 'media-library-assistant'), 'commas_format' => '', 'Commas' => __('Commas', 'media-library-assistant'), 'raw_format' => '', 'Raw' => __('Raw', 'media-library-assistant'), 'Option' => __('Option', 'media-library-assistant'), 'text_option' => '', 'Text' => __('Text', 'media-library-assistant'), 'single_option' => '', 'Single' => __('Single', 'media-library-assistant'), 'export_option' => '', 'Export' => __('Export', 'media-library-assistant'), 'array_option' => '', 'Array' => __('Array', 'media-library-assistant'), 'multi_option' => '', 'Multi' => __('Multi', 'media-library-assistant'), 'no_null_checked' => '', 'Delete NULL values' => __('Delete NULL values', 'media-library-assistant'), 'Add Field' => __('Add Field', 'media-library-assistant'), 'Map All Attachments' => __('Add Field and Map All Attachments', 'media-library-assistant')); $table_rows .= MLAData::mla_parse_template($row_template, $row_values); $option_values = array('Field Title' => __('Field Title', 'media-library-assistant'), 'IPTC Value' => __('IPTC Value', 'media-library-assistant'), 'EXIF/Template Value' => __('EXIF/Template Value', 'media-library-assistant'), 'Priority' => __('Priority', 'media-library-assistant'), 'Existing Text' => __('Existing Text', 'media-library-assistant'), 'table_rows' => $table_rows, 'help' => $value['help']); return MLAData::mla_parse_template(MLAOptions::$mla_option_templates['iptc-exif-custom-table'], $option_values); default: /* translators: 1: ERROR tag 2: option name */ return '<br>' . sprintf(__('%1$s: Render unknown custom %2$s.', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), $key) . "\r\n"; } // switch $key // switch $key case 'update': case 'delete': $settings_changed = false; $messages = ''; switch ($key) { case 'iptc_exif_standard_mapping': $results = MLAOptions::_update_iptc_exif_standard_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed = $results['changed']; break; case 'iptc_exif_taxonomy_mapping': $results = MLAOptions::_update_iptc_exif_taxonomy_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed = $results['changed']; break; case 'iptc_exif_custom_mapping': $results = MLAOptions::_update_iptc_exif_custom_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed = $results['changed']; break; case 'iptc_exif_mapping': $results = MLAOptions::_update_iptc_exif_standard_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed = $results['changed']; $results = MLAOptions::_update_iptc_exif_taxonomy_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed |= $results['changed']; $results = MLAOptions::_update_iptc_exif_custom_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed |= $results['changed']; break; default: /* translators: 1: ERROR tag 2: option name */ return '<br>' . sprintf(__('%1$s: Update/delete unknown custom %2$s.', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), $key) . "\r\n"; } // switch $key if ($settings_changed) { $settings_changed = MLACore::mla_update_option('iptc_exif_mapping', $current_values); if ($settings_changed) { $results = __('IPTC/EXIF mapping settings updated.', 'media-library-assistant') . "\r\n"; } else { $results = __('ERROR', 'media-library-assistant') . ': ' . __('IPTC/EXIF settings update failed.', 'media-library-assistant') . "\r\n"; } } else { $results = __('IPTC/EXIF no mapping changes detected.', 'media-library-assistant') . "\r\n"; } return $results . $messages; case 'reset': switch ($key) { case 'iptc_exif_standard_mapping': $current_values['standard'] = MLACoreOptions::$mla_option_definitions['iptc_exif_mapping']['std']['standard']; $settings_changed = MLACore::mla_update_option('iptc_exif_mapping', $current_values); if ($settings_changed) { /* translators: 1: field type */ return sprintf(__('%1$s settings saved.', 'media-library-assistant'), 'IPTC/EXIF ' . __('Standard field', 'media-library-assistant')) . "\r\n"; } else { /* translators: 1: ERROR tag 2: field type */ return sprintf(__('%1$s: IPTC/EXIF %2$s settings update failed.', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), __('Standard field', 'media-library-assistant')) . "\r\n"; } case 'iptc_exif_taxonomy_mapping': $current_values['taxonomy'] = MLACoreOptions::$mla_option_definitions['iptc_exif_mapping']['std']['taxonomy']; $settings_changed = MLACore::mla_update_option('iptc_exif_mapping', $current_values); if ($settings_changed) { /* translators: 1: field type */ return sprintf(__('%1$s settings saved.', 'media-library-assistant'), 'IPTC/EXIF ' . __('Taxonomy term', 'media-library-assistant')) . "\r\n"; } else { /* translators: 1: ERROR tag 2: field type */ return sprintf(__('%1$s: IPTC/EXIF %2$s settings update failed.', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), __('Taxonomy term', 'media-library-assistant')) . "\r\n"; } case 'iptc_exif_custom_mapping': $current_values['custom'] = MLACoreOptions::$mla_option_definitions['iptc_exif_mapping']['std']['custom']; $settings_changed = MLACore::mla_update_option('iptc_exif_mapping', $current_values); if ($settings_changed) { /* translators: 1: field type */ return sprintf(__('%1$s settings saved.', 'media-library-assistant'), 'IPTC/EXIF ' . __('Custom field', 'media-library-assistant')) . "\r\n"; } else { /* translators: 1: ERROR tag 2: field type */ return sprintf(__('%1$s: IPTC/EXIF %2$s settings update failed.', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), __('Custom field', 'media-library-assistant')) . "\r\n"; } case 'iptc_exif_mapping': MLACore::mla_delete_option($key); /* translators: 1: option name, e.g., taxonomy_support */ return '<br>' . sprintf(__('Reset custom %1$s', 'media-library-assistant'), $key) . "\r\n"; default: /* translators: 1: ERROR tag 2: option name, e.g., taxonomy_support */ return '<br>' . sprintf(__('%1$s: Reset unknown custom %2$s', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), $key) . "\r\n"; } // switch $key // switch $key default: /* translators: 1: ERROR tag 2: option name 3: action, e.g., update, delete, reset */ return '<br>' . sprintf(__('%1$s: Custom %2$s unknown action "%3$s"', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), $key, $action) . "\r\n"; } // switch $action }
/** * Display a single item sub page; prepare the form to * change the meta data for a single attachment. * * This function is not used in WordPress 3.5 and later. * * @since 0.1 * * @param int The WordPress Post ID of the attachment item * * @return array message and/or HTML content */ private static function _display_single_item($post_id) { global $post; /* * This function sets the global $post */ $post_data = MLAData::mla_get_attachment_by_id($post_id); if (!isset($post_data)) { return array('message' => 'ERROR: Could not retrieve Attachment.', 'body' => ''); } if (!current_user_can('edit_post', $post_id)) { return array('message' => 'You are not allowed to edit this Attachment.', 'body' => ''); } if (!empty($post_data['mla_wp_attachment_metadata'])) { $page_template_array = MLAData::mla_load_template(MLA_PLUGIN_PATH . 'tpls/admin-display-single-image.tpl'); $width = isset($post_data['mla_wp_attachment_metadata']['width']) ? $post_data['mla_wp_attachment_metadata']['width'] : ''; $height = isset($post_data['mla_wp_attachment_metadata']['height']) ? $post_data['mla_wp_attachment_metadata']['height'] : ''; $image_meta = var_export($post_data['mla_wp_attachment_metadata'], true); if (!isset($post_data['mla_wp_attachment_image_alt'])) { $post_data['mla_wp_attachment_image_alt'] = ''; } } else { $page_template_array = MLAData::mla_load_template(MLA_PLUGIN_PATH . 'tpls/admin-display-single-document.tpl'); $width = ''; $height = ''; $image_meta = ''; } if (array($page_template_array)) { $page_template = $page_template_array['page']; $authors_template = $page_template_array['authors']; $postbox_template = $page_template_array['postbox']; } else { error_log("ERROR: MLA::_display_single_item \$page_template_array = " . var_export($page_template_array, true), 0); $page_template = $page_template_array; $authors_template = ''; $postbox_template = ''; } if (empty($post_data['mla_references']['parent_title'])) { $parent_info = $post_data['mla_references']['parent_errors']; } else { $parent_info = sprintf('(%1$s) %2$s %3$s', $post_data['mla_references']['parent_type'], $post_data['mla_references']['parent_title'], $post_data['mla_references']['parent_errors']); } if ($authors = self::_authors_dropdown($post_data['post_author'], 'attachments[' . $post_data['ID'] . '][post_author]')) { $args = array('ID' => $post_data['ID'], 'authors' => $authors); $authors = MLAData::mla_parse_template($authors_template, $args); } else { $authors = ''; } if (MLAOptions::$process_featured_in) { $features = ''; foreach ($post_data['mla_references']['features'] as $feature_id => $feature) { if ($feature_id == $post_data['post_parent']) { $parent = 'PARENT '; } else { $parent = ''; } $features .= sprintf('%1$s (%2$s %3$s), %4$s', $parent, $feature->post_type, $feature_id, $feature->post_title) . "\r\n"; } // foreach $feature } else { $features = 'disabled'; } if (MLAOptions::$process_inserted_in) { $inserts = ''; foreach ($post_data['mla_references']['inserts'] as $file => $insert_array) { $inserts .= $file . "\r\n"; foreach ($insert_array as $insert) { if ($insert->ID == $post_data['post_parent']) { $parent = ' PARENT '; } else { $parent = ' '; } $inserts .= sprintf('%1$s (%2$s %3$s), %4$s', $parent, $insert->post_type, $insert->ID, $insert->post_title) . "\r\n"; } // foreach $insert } // foreach $file } else { $inserts = 'disabled'; } if (MLAOptions::$process_gallery_in) { $galleries = ''; foreach ($post_data['mla_references']['galleries'] as $gallery_id => $gallery) { if ($gallery_id == $post_data['post_parent']) { $parent = 'PARENT '; } else { $parent = ''; } $galleries .= sprintf('%1$s (%2$s %3$s), %4$s', $parent, $gallery['post_type'], $gallery_id, $gallery['post_title']) . "\r\n"; } // foreach $gallery } else { $galleries = 'disabled'; } if (MLAOptions::$process_mla_gallery_in) { $mla_galleries = ''; foreach ($post_data['mla_references']['mla_galleries'] as $gallery_id => $gallery) { if ($gallery_id == $post_data['post_parent']) { $parent = 'PARENT '; } else { $parent = ''; } $mla_galleries .= sprintf('%1$s (%2$s %3$s), %4$s', $parent, $gallery['post_type'], $gallery_id, $gallery['post_title']) . "\r\n"; } // foreach $gallery } else { $mla_galleries = 'disabled'; } /* * WordPress doesn't look in hidden fields to set the month filter dropdown or sorting parameters */ if (isset($_REQUEST['m'])) { $url_args = '&m=' . $_REQUEST['m']; } else { $url_args = ''; } if (isset($_REQUEST['post_mime_type'])) { $url_args .= '&post_mime_type=' . $_REQUEST['post_mime_type']; } if (isset($_REQUEST['order'])) { $url_args .= '&order=' . $_REQUEST['order']; } if (isset($_REQUEST['orderby'])) { $url_args .= '&orderby=' . $_REQUEST['orderby']; } /* * Add the current view arguments */ if (isset($_REQUEST['detached'])) { $view_args = '<input type="hidden" name="detached" value="' . $_REQUEST['detached'] . "\" />\r\n"; } elseif (isset($_REQUEST['status'])) { $view_args = '<input type="hidden" name="status" value="' . $_REQUEST['status'] . "\" />\r\n"; } else { $view_args = ''; } if (isset($_REQUEST['paged'])) { $view_args .= sprintf('<input type="hidden" name="paged" value="%1$s" />', $_REQUEST['paged']) . "\r\n"; } $side_info_column = ''; $taxonomies = get_object_taxonomies('attachment', 'objects'); foreach ($taxonomies as $tax_name => $tax_object) { ob_start(); if ($tax_object->hierarchical && $tax_object->show_ui) { $box = array('id' => $tax_name . 'div', 'title' => esc_html($tax_object->labels->name), 'callback' => 'categories_meta_box', 'args' => array('taxonomy' => $tax_name), 'inside_html' => ''); post_categories_meta_box($post, $box); } elseif ($tax_object->show_ui) { $box = array('id' => 'tagsdiv-' . $tax_name, 'title' => esc_html($tax_object->labels->name), 'callback' => 'post_tags_meta_box', 'args' => array('taxonomy' => $tax_name), 'inside_html' => ''); post_tags_meta_box($post, $box); } $box['inside_html'] = ob_get_contents(); ob_end_clean(); $side_info_column .= MLAData::mla_parse_template($postbox_template, $box); } $page_values = array('ID' => $post_data['ID'], 'post_mime_type' => $post_data['post_mime_type'], 'menu_order' => $post_data['menu_order'], 'post_date' => $post_data['post_date'], 'post_modified' => $post_data['post_modified'], 'post_parent' => $post_data['post_parent'], 'menu_order' => $post_data['menu_order'], 'attachment_icon' => wp_get_attachment_image($post_id, array(160, 120), true), 'file_name' => esc_html($post_data['mla_references']['file']), 'width' => $width, 'height' => $height, 'post_title_attr' => esc_attr($post_data['post_title']), 'post_name_attr' => esc_attr($post_data['post_name']), 'image_alt_attr' => '', 'post_excerpt_attr' => esc_attr($post_data['post_excerpt']), 'post_content' => esc_textarea($post_data['post_content']), 'image_meta' => esc_textarea($image_meta), 'parent_info' => esc_attr($parent_info), 'guid_attr' => esc_attr($post_data['guid']), 'authors' => $authors, 'features' => esc_textarea($features), 'inserts' => esc_textarea($inserts), 'galleries' => esc_textarea($galleries), 'mla_galleries' => esc_textarea($mla_galleries), 'mla_admin_action' => self::MLA_ADMIN_SINGLE_EDIT_UPDATE, 'form_url' => admin_url('upload.php') . '?page=' . self::ADMIN_PAGE_SLUG . $url_args, 'view_args' => $view_args, 'wpnonce' => wp_nonce_field(self::MLA_ADMIN_NONCE, '_wpnonce', true, false), 'side_info_column' => $side_info_column); if (!empty($post_data['mla_wp_attachment_image_alt'])) { $page_values['image_alt_attr'] = esc_attr($post_data['mla_wp_attachment_image_alt']); } return array('message' => '', 'body' => MLAData::mla_parse_template($page_template, $page_values)); }
/** * Compose HTML markup for the import settings if any settings files exist * * @since 1.50 * * @return string HTML markup for the Import All Settings button and dropdown list, if any */ private static function _compose_import_settings() { if (!file_exists(MLA_BACKUP_DIR)) { return ''; } $prefix = (defined(MLA_OPTION_PREFIX) ? MLA_OPTION_PREFIX : 'mla_') . '_options_'; $prefix_length = strlen($prefix); $backup_files = array(); $files = scandir(MLA_BACKUP_DIR, 1); // sort descending foreach ($files as $file) { if (0 === strpos($file, $prefix)) { $tail = substr($file, $prefix_length, strlen($file) - ($prefix_length + 4)); $text = sprintf('%1$s/%2$s/%3$s %4$s', substr($tail, 0, 4), substr($tail, 4, 2), substr($tail, 6, 2), substr($tail, 9)); $backup_files[$text] = $file; } } if (empty($backup_files)) { return ''; } $option_values = array('value' => 'none', 'text' => '— ' . __('select settings', 'media-library-assistant') . ' —', 'selected' => 'selected="selected"'); $select_options = MLAData::mla_parse_template(self::$page_template_array['select-option'], $option_values); foreach ($backup_files as $text => $file) { $option_values = array('value' => esc_attr($file), 'text' => esc_html($text), 'selected' => ''); $select_options .= MLAData::mla_parse_template(self::$page_template_array['select-option'], $option_values); } $option_values = array('key' => 'mla-import-settings-file', 'options' => $select_options); return '<input name="mla-general-options-import" type="submit" class="button-primary" value="' . __('Import ALL Settings', 'media-library-assistant') . '" />' . MLAData::mla_parse_template(self::$page_template_array['select-only'], $option_values); }
/** * Render and manage iptc/exif support options * * @since 1.00 * @uses $mla_option_templates contains row and table templates * * @param string 'render', 'update', 'delete', or 'reset' * @param string option name, e.g., 'iptc_exif_mapping' * @param array option parameters * @param array Optional. null (default) for 'render' else option data, e.g., $_REQUEST * * @return string HTML table row markup for 'render' else message(s) reflecting the results of the operation. */ public static function mla_iptc_exif_option_handler($action, $key, $value, $args = null) { $current_values = self::mla_get_option('iptc_exif_mapping'); switch ($action) { case 'render': switch ($key) { case 'iptc_exif_standard_mapping': $row_template = self::$mla_option_templates['iptc-exif-standard-row']; $table_rows = ''; foreach ($current_values['standard'] as $row_name => $row_value) { $row_values = array('key' => $row_name, 'name' => $row_value['name'], 'iptc_field_options' => self::_compose_iptc_option_list($row_value['iptc_value']), 'exif_size' => self::MLA_EXIF_SIZE, 'exif_text' => $row_value['exif_value'], 'iptc_selected' => '', 'exif_selected' => '', 'keep_selected' => '', 'replace_selected' => ''); if ($row_value['iptc_first']) { $row_values['iptc_selected'] = 'selected="selected"'; } else { $row_values['exif_selected'] = 'selected="selected"'; } if ($row_value['keep_existing']) { $row_values['keep_selected'] = 'selected="selected"'; } else { $row_values['replace_selected'] = 'selected="selected"'; } $table_rows .= MLAData::mla_parse_template($row_template, $row_values); } // foreach row $option_values = array('table_rows' => $table_rows, 'help' => $value['help']); return MLAData::mla_parse_template(self::$mla_option_templates['iptc-exif-standard-table'], $option_values); case 'iptc_exif_taxonomy_mapping': $row_template = self::$mla_option_templates['iptc-exif-taxonomy-row']; $select_template = self::$mla_option_templates['iptc-exif-select']; $table_rows = ''; $taxonomies = get_taxonomies(array('show_ui' => true), 'objects'); foreach ($taxonomies as $row_name => $row_value) { $row_values = array('key' => $row_name, 'name' => esc_html($row_value->labels->name), 'hierarchical' => (string) $row_value->hierarchical, 'iptc_field_options' => '', 'exif_size' => self::MLA_EXIF_SIZE, 'exif_text' => '', 'iptc_selected' => '', 'exif_selected' => '', 'keep_selected' => '', 'replace_selected' => '', 'parent_select' => ''); if (array_key_exists($row_name, $current_values['taxonomy'])) { $current_value = $current_values['taxonomy'][$row_name]; $row_values['iptc_field_options'] = self::_compose_iptc_option_list($current_value['iptc_value']); $row_values['exif_text'] = $current_value['exif_value']; if ($current_value['iptc_first']) { $row_values['iptc_selected'] = 'selected="selected"'; } else { $row_values['exif_selected'] = 'selected="selected"'; } if ($current_value['keep_existing']) { $row_values['keep_selected'] = 'selected="selected"'; } else { $row_values['replace_selected'] = 'selected="selected"'; } if ($row_value->hierarchical) { $parent = isset($current_value['parent']) ? (int) $current_value['parent'] : 0; $select_values = array('array' => 'taxonomy', 'key' => $row_name, 'element' => 'parent', 'options' => self::_compose_parent_option_list($row_name, $parent)); $row_values['parent_select'] = MLAData::mla_parse_template($select_template, $select_values); } } else { $row_values['iptc_field_options'] = self::_compose_iptc_option_list('none'); $row_values['iptc_selected'] = 'selected="selected"'; $row_values['keep_selected'] = 'selected="selected"'; if ($row_value->hierarchical) { $select_values = array('array' => 'taxonomy', 'key' => $row_name, 'element' => 'parent', 'options' => self::_compose_parent_option_list($row_name, 0)); $row_values['parent_select'] = MLAData::mla_parse_template($select_template, $select_values); } } $table_rows .= MLAData::mla_parse_template($row_template, $row_values); } // foreach row $option_values = array('table_rows' => $table_rows, 'help' => $value['help']); return MLAData::mla_parse_template(self::$mla_option_templates['iptc-exif-taxonomy-table'], $option_values); case 'iptc_exif_custom_mapping': if (empty($current_values['custom'])) { $table_rows = MLAData::mla_parse_template(self::$mla_option_templates['iptc-exif-custom-empty-row'], array('column_count' => 5)); } else { $row_template = self::$mla_option_templates['iptc-exif-custom-rule-row']; $table_rows = ''; } /* * One row for each existing rule */ ksort($current_values['custom']); foreach ($current_values['custom'] as $row_name => $current_value) { $row_values = array('column_count' => 5, 'key' => $row_name, 'name' => $row_name, 'iptc_field_options' => '', 'exif_size' => self::MLA_EXIF_SIZE, 'exif_text' => '', 'iptc_selected' => '', 'exif_selected' => '', 'keep_selected' => '', 'replace_selected' => ''); $row_values['iptc_field_options'] = self::_compose_iptc_option_list($current_value['iptc_value']); $row_values['exif_text'] = $current_value['exif_value']; if ($current_value['iptc_first']) { $row_values['iptc_selected'] = 'selected="selected"'; } else { $row_values['exif_selected'] = 'selected="selected"'; } if ($current_value['keep_existing']) { $row_values['keep_selected'] = 'selected="selected"'; } else { $row_values['replace_selected'] = 'selected="selected"'; } $table_rows .= MLAData::mla_parse_template($row_template, $row_values); } // foreach existing rule /* * Add a row for defining a new rule, existing Custom Field */ $row_template = self::$mla_option_templates['iptc-exif-custom-new-rule-row']; $row_values = array('column_count' => 5, 'key' => self::MLA_NEW_CUSTOM_RULE, 'field_name_options' => self::_compose_custom_field_option_list('none', $current_values['custom']), 'iptc_field_options' => self::_compose_iptc_option_list('none'), 'exif_size' => self::MLA_EXIF_SIZE, 'exif_text' => '', 'iptc_selected' => 'selected="selected"', 'exif_selected' => '', 'keep_selected' => 'selected="selected"', 'replace_selected' => ''); $table_rows .= MLAData::mla_parse_template($row_template, $row_values); /* * Add a row for defining a new rule, new Custom Field */ $row_template = self::$mla_option_templates['iptc-exif-custom-new-field-row']; $row_values = array('column_count' => 5, 'key' => self::MLA_NEW_CUSTOM_FIELD, 'field_name_size' => '24', 'iptc_field_options' => self::_compose_iptc_option_list('none'), 'exif_size' => self::MLA_EXIF_SIZE, 'exif_text' => '', 'iptc_selected' => 'selected="selected"', 'exif_selected' => '', 'keep_selected' => 'selected="selected"', 'replace_selected' => ''); $table_rows .= MLAData::mla_parse_template($row_template, $row_values); $option_values = array('table_rows' => $table_rows, 'help' => $value['help']); return MLAData::mla_parse_template(self::$mla_option_templates['iptc-exif-custom-table'], $option_values); default: return "<br>ERROR: Render unknown custom {$key}\r\n"; } // switch $key // switch $key case 'update': case 'delete': $settings_changed = false; $messages = ''; switch ($key) { case 'iptc_exif_standard_mapping': $results = self::_update_iptc_exif_standard_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed = $results['changed']; break; case 'iptc_exif_taxonomy_mapping': $results = self::_update_iptc_exif_taxonomy_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed = $results['changed']; break; case 'iptc_exif_custom_mapping': $results = self::_update_iptc_exif_custom_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed = $results['changed']; break; case 'iptc_exif_mapping': $results = self::_update_iptc_exif_standard_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed = $results['changed']; $results = self::_update_iptc_exif_taxonomy_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed |= $results['changed']; $results = self::_update_iptc_exif_custom_mapping($current_values, $args); $messages .= $results['message']; $current_values = $results['values']; $settings_changed |= $results['changed']; break; default: return "<br>ERROR: Update/delete unknown custom {$key}\r\n"; } // switch $key if ($settings_changed) { $settings_changed = MLAOptions::mla_update_option('iptc_exif_mapping', $current_values); if ($settings_changed) { $results = "IPTC/EXIF mapping settings updated.\r\n"; } else { $results = "ERROR: IPTC/EXIF settings update failed.\r\n"; } } else { $results = "IPTC/EXIF no mapping changes detected.\r\n"; } return $results . $messages; case 'reset': switch ($key) { case 'iptc_exif_standard_mapping': $current_values['standard'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['standard']; $settings_changed = MLAOptions::mla_update_option('iptc_exif_mapping', $current_values); if ($settings_changed) { return "IPTC/EXIF Standard field settings saved.\r\n"; } else { return "ERROR: IPTC/EXIF Standard field settings update failed.\r\n"; } case 'iptc_exif_taxonomy_mapping': $current_values['taxonomy'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['taxonomy']; $settings_changed = MLAOptions::mla_update_option('iptc_exif_mapping', $current_values); if ($settings_changed) { return "IPTC/EXIF Taxonomy term settings saved.\r\n"; } else { return "ERROR: IPTC/EXIF Taxonomy term settings update failed.\r\n"; } case 'iptc_exif_custom_mapping': $current_values['custom'] = self::$mla_option_definitions['iptc_exif_mapping']['std']['custom']; $settings_changed = MLAOptions::mla_update_option('iptc_exif_mapping', $current_values); if ($settings_changed) { return "IPTC/EXIF Custom field settings saved.\r\n"; } else { return "ERROR: IPTC/EXIF Custom field settings reset failed.\r\n"; } case 'iptc_exif_mapping': self::mla_delete_option($key); return "<br>Reset custom {$key}\r\n"; default: return "<br>ERROR: Reset unknown custom {$key}\r\n"; } // switch $key // switch $key default: return "<br>ERROR: Custom {$key} unknown action: {$action}\r\n"; } // switch $action }