/** * 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; }
/** * Load style and markup templates to $mla_custom_templates * * @since 2.30 * * @return void */ public static function mla_load_custom_templates() { if (empty(MLATemplate_Support::$mla_template_definitions)) { MLATemplate_Support::mla_localize_template_definitions(); } MLATemplate_Support::$mla_custom_templates = NULL; $default_templates = MLACore::mla_load_template('mla-custom-templates.tpl'); /* * Load the default templates */ if (is_null($default_templates)) { MLACore::mla_debug_add('<strong>mla_debug mla_load_custom_templates()</strong> ' . __('error loading tpls/mla-custom-templates.tpl', 'media-library-assistant'), MLACore::MLA_DEBUG_CATEGORY_ANY); return; } elseif (!$default_templates) { MLACore::mla_debug_add('<strong>mla_debug mla_load_custom_templates()</strong> ' . __('tpls/mla-custom-templates.tpl not found', 'media-library-assistant'), MLACore::MLA_DEBUG_CATEGORY_ANY); return; } /* * Record explicit shortcode assignments */ $mla_shortcode_slugs = array(); foreach ($default_templates as $key => $value) { $mla_shortcode_slug = NULL; $match_count = preg_match('#\\<!-- mla_shortcode_slug="(.+)" --\\>[\\r\\n]*#', $value, $matches, PREG_OFFSET_CAPTURE); if ($match_count == 0) { $match_count = preg_match('#mla_shortcode_slug="(.+)"[ \\r\\n]*#', $value, $matches, PREG_OFFSET_CAPTURE); } if ($match_count > 0) { $mla_shortcode_slug = $matches[1][0]; //error_log( __LINE__ . " default template {$key}, {$mla_shortcode_slug} matches = " . var_export( $matches, true ), 0 ); $value = substr_replace($value, '', $matches[0][1], strlen($matches[0][0])); if (empty($value)) { unset($default_templates[$key]); //error_log( __LINE__ . " unset default template {$key}, {$mla_shortcode_slug}", 0 ); } else { $default_templates[$key] = $value; //error_log( __LINE__ . " replace default template {$key}, {$mla_shortcode_slug} value = " . MLAData::mla_hex_dump( $value ), 0 ); } } if (!empty($mla_shortcode_slug)) { $tail = strrpos($key, '-style'); if (!(false === $tail)) { $mla_shortcode_slugs['style'][substr($key, 0, $tail)] = $mla_shortcode_slug; } else { $tail = strrpos($key, '-arguments-markup'); if (!(false === $tail)) { $mla_shortcode_slugs['markup'][substr($key, 0, $tail)] = $mla_shortcode_slug; } } } } //error_log( __LINE__ . " mla_shortcode_slugs = " . var_export( $mla_shortcode_slugs, true ), 0 ); /* * Find the shortcode and template type for array indices */ foreach ($default_templates as $key => $value) { $tail = strrpos($key, '-style'); if (!(false === $tail)) { $name = substr($key, 0, $tail); if (isset($mla_shortcode_slugs['style'][$name])) { // Assign to the declared shortcode MLATemplate_Support::$mla_custom_templates['style'][$mla_shortcode_slugs['style'][$name]][$name] = $value; $name = NULL; } else { // Guess at the shortcode foreach (MLATemplate_Support::$mla_template_definitions['style'] as $slug => $definition) { if (isset($definition['default_names']) && in_array($name, $definition['default_names'])) { MLATemplate_Support::$mla_custom_templates['style'][$definition['slug']][$name] = $value; $name = NULL; break; } } } // Can't find the shortcode; assume it's mla_gallery if ($name) { MLATemplate_Support::$mla_custom_templates['style']['gallery'][$name] = $value; } continue; } $tail = strrpos($key, '-markup'); if (!(false === $tail)) { $name = substr($key, 0, $tail); // Look for explicit assignment foreach ($mla_shortcode_slugs['markup'] as $root_name => $mla_shortcode_slug) { $root = strpos($name, $root_name); if (0 === $root) { $section_name = substr($name, strlen($root_name) + 1); //error_log( __LINE__ . " assign default template {$key}, to [{$mla_shortcode_slug}][{$root_name}][{$section_name}]", 0 ); // Assign to the declared shortcode MLATemplate_Support::$mla_custom_templates['markup'][$mla_shortcode_slug][$root_name][$section_name] = $value; $name = NULL; break; } } if ($name) { // Guess at the shortcode foreach (MLATemplate_Support::$mla_template_definitions['markup'] as $slug => $definition) { if (isset($definition['default_names'])) { foreach ($definition['default_names'] as $default_name) { $root = strpos($name, $default_name); if (0 === $root) { foreach ($definition['sections'] as $section_name => $section_value) { $tail = strrpos($name, '-' . $section_name); if (!(false === $tail)) { $name = substr($name, 0, $tail); MLATemplate_Support::$mla_custom_templates['markup'][$definition['slug']][$name][$section_name] = $value; } } $name = NULL; break; } } } } } // Can't find the shortcode; assume it's mla_gallery if ($name) { foreach (MLATemplate_Support::$mla_template_definitions['markup']['gallery']['sections'] as $section_name => $section_value) { $tail = strrpos($name, '-' . $section_name); if (!(false === $tail)) { $name = substr($name, 0, $tail); MLATemplate_Support::$mla_custom_templates['markup']['gallery'][$name][$section_name] = $value; } } } } } /* * Add user-defined Style and Markup templates * * MLA versions before 2.40 will not have separate 'attributes' and 'content' elements, * but version 2.3x must "go both ways" to allow for reversions. */ $templates = MLACore::mla_get_option('style_templates'); if (is_array($templates)) { foreach ($templates as $name => $value) { // Check for 2.40+ format if (is_array($value)) { $attributes = $value['attributes']; MLATemplate_Support::$mla_custom_templates['style'][$attributes['mla_shortcode_slug']][$name] = $value['content']; continue; } // Check for explicit assignment $match_count = preg_match('#\\<!-- mla_shortcode_slug="(.+)" --\\>[\\r\\n]*#', $value, $matches, PREG_OFFSET_CAPTURE); if ($match_count > 0) { //error_log( __LINE__ . " default template {$name} matches = " . var_export( $matches, true ), 0 ); $value = substr_replace($value, '', $matches[0][1], strlen($matches[0][0])); //error_log( __LINE__ . " replace default template {$name} value = " . MLAData::mla_hex_dump( $value ), 0 ); MLATemplate_Support::$mla_custom_templates['style'][$matches[1][0]][$name] = $value; continue; } // Guess from content foreach (MLATemplate_Support::$mla_template_definitions['style'] as $slug => $definition) { if (false !== strpos($value, '.' . $definition['slug'])) { MLATemplate_Support::$mla_custom_templates['style'][$definition['slug']][$name] = $value; $name = NULL; break; } } if ($name) { MLATemplate_Support::$mla_custom_templates['style']['gallery'][$name] = $value; } } // foreach $templates } // is_array $templates = MLACore::mla_get_option('markup_templates'); if (is_array($templates)) { foreach ($templates as $name => $value) { // Check for 2.40+ format if (isset($value['attributes'])) { $attributes = $value['attributes']; unset($value['attributes']); MLATemplate_Support::$mla_custom_templates['markup'][$attributes['mla_shortcode_slug']][$name] = $value['content']; continue; } // Check for explicit assignment if (isset($value['arguments'])) { $match_count = preg_match('#mla_shortcode_slug="(.+)"[ \\r\\n]*#', $value['arguments'], $matches, PREG_OFFSET_CAPTURE); } else { $match_count = 0; } if ($match_count > 0) { //error_log( __LINE__ . " user template {$key} matches = " . var_export( $matches, true ), 0 ); $value['arguments'] = substr_replace($value['arguments'], '', $matches[0][1], strlen($matches[0][0])); if (empty($value['arguments'])) { //error_log( __LINE__ . " unset user template {$key}", 0 ); unset($value['arguments']); } else { //error_log( __LINE__ . " replace user {$key} value = " . MLAData::mla_hex_dump( $value['arguments'] ), 0 ); } MLATemplate_Support::$mla_custom_templates['markup'][$matches[1][0]][$name] = $value; continue; } // Guess from content $full_text = ''; // for guessing shortcode name foreach ($value as $section_name => $section_value) { $full_text .= $section_value; } foreach (MLATemplate_Support::$mla_template_definitions['markup'] as $slug => $definition) { if (preg_match('#class=[\'\\"]*.*' . $definition['slug'] . '#', $full_text, $matches)) { MLATemplate_Support::$mla_custom_templates['markup'][$definition['slug']][$name] = $value; $name = NULL; break; } } if ($name) { MLATemplate_Support::$mla_custom_templates['markup']['gallery'][$name] = $value; } } // foreach $templates } // is_array //error_log( __LINE__ . ' mla_load_custom_templates MLATemplate_Support::$mla_custom_templates = ' . var_export( MLATemplate_Support::$mla_custom_templates, true ), 0 ); }
/** * 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; }
/** * Load option settings templates to $mla_option_templates * * @since 0.80 * * @return void */ private static function _load_option_templates() { MLAOptions::$mla_option_templates = MLACore::mla_load_template('mla-option-templates.tpl'); /* * Load the option settings templates */ if (is_null(MLAOptions::$mla_option_templates)) { MLACore::mla_debug_add('<strong>mla_debug _load_option_templates()</strong> ' . __('error loading tpls/mla-option-templates.tpl', 'media-library-assistant')); return; } elseif (!MLAOptions::$mla_option_templates) { MLACore::mla_debug_add('<strong>mla_debug _load_option_templates()</strong> ' . __('tpls/mla-option-templates.tpl not found', 'media-library-assistant')); MLAOptions::$mla_option_templates = NULL; return; } }
/** * Assemble the in-memory representation of the (read-only) Optional Upload MIME Types * * @since 1.40 * * @return boolean Success (true) or failure (false) of the operation */ private static function _get_optional_upload_mime_templates() { if (NULL != self::$mla_optional_upload_mime_templates) { return true; } self::$mla_optional_upload_mime_templates = array(); $template_array = MLACore::mla_load_template('mla-default-mime-types.tpl'); if (isset($template_array['mla-optional-mime-types'])) { $mla_mime_types = preg_split('/[\\r\\n]+/', $template_array['mla-optional-mime-types']); $ID = 0; foreach ($mla_mime_types as $mla_type) { // Ignore blank lines if (empty($mla_type)) { continue; } $array = explode(',', $mla_type); // Bypass damaged entries if (3 > count($array)) { MLACore::mla_debug_add(__LINE__ . " _get_upload_mime_templates mla-default-mime-types.tpl section mla-optional-mime-types( {$ID} '{$mla_type}' ) \$array = " . var_export($array, true), MLACore::MLA_DEBUG_CATEGORY_ANY); continue; } $slug = $array[0]; if ($matched_type = self::mla_get_upload_mime($slug)) { $core_type = $matched_type['core_type']; $mla_type = $matched_type['mla_type']; } else { $core_type = ''; $mla_type = ''; } self::$mla_optional_upload_mime_templates[++$ID] = array('ID' => $ID, 'slug' => $slug, 'mime_type' => $array[1], 'core_type' => $core_type, 'mla_type' => $mla_type, 'description' => $array[2]); } } return true; }
/** * 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 = MLACore::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 && MLACore::mla_taxonomy_support($tax_name, 'quick-edit')) { $hierarchical_taxonomies[$tax_name] = $tax_object; } elseif ($tax_object->show_ui && MLACore::mla_taxonomy_support($tax_name, 'quick-edit')) { $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 */ 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 (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., 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 (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(); $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); }
/** * Render (echo) the "Media Library Assistant" subpage in the Settings section * * @since 0.1 * * @return void Echoes HTML markup for the Settings subpage */ public static function mla_render_settings_page() { if (!current_user_can('manage_options')) { echo __('Media Library Assistant', 'media-library-assistant') . ' - ' . __('ERROR', 'media-library-assistant') . "</h2>\r\n"; wp_die(__('You do not have permission to manage plugin settings.', 'media-library-assistant')); } /* * Load template array and initialize page-level values. */ $development_version = MLA::MLA_DEVELOPMENT_VERSION; $development_version = !empty($development_version) ? ' (' . $development_version . ')' : ''; self::$page_template_array = MLACore::mla_load_template('admin-display-settings-page.tpl'); $current_tab_slug = isset($_REQUEST['mla_tab']) ? $_REQUEST['mla_tab'] : 'general'; $current_tab = self::mla_get_options_tablist($current_tab_slug); $page_values = array('Support Our Work' => __('Support Our Work', 'media-library-assistant'), 'Donate' => __('Donate', 'media-library-assistant'), 'version' => 'v' . MLACore::CURRENT_MLA_VERSION, 'development' => $development_version, 'messages' => '', 'tablist' => self::_compose_settings_tabs($current_tab_slug), 'tab_content' => '', 'Media Library Assistant' => __('Media Library Assistant', 'media-library-assistant'), 'Settings' => __('Settings', 'media-library-assistant')); /* * Compose tab content */ if ($current_tab) { if (isset($current_tab['render'])) { $handler = $current_tab['render']; $page_content = call_user_func($handler); } else { $page_content = array('message' => __('ERROR', 'media-library-assistant') . ': ' . __('Cannot render content tab', 'media-library-assistant'), 'body' => ''); } } else { $page_content = array('message' => __('ERROR', 'media-library-assistant') . ': ' . __('Unknown content tab', 'media-library-assistant'), 'body' => ''); } if (!empty($page_content['message'])) { if (false !== strpos($page_content['message'], __('ERROR', 'media-library-assistant'))) { $messages_class = 'mla_errors'; } else { $messages_class = 'mla_messages'; } $page_values['messages'] = MLAData::mla_parse_template(self::$page_template_array['messages'], array('messages' => $page_content['message'], 'mla_messages_class' => $messages_class)); } $page_values['tab_content'] = $page_content['body']; echo MLAData::mla_parse_template(self::$page_template_array['page'], $page_values); }