/** * Compose the MLA Gallery tab content for the Settings subpage * * @since 0.80 * @uses $page_template_array contains tab content template(s) * * @return array 'message' => status/error messages, 'body' => tab content */ private static function _compose_mla_gallery_tab() { /* * Check for submit buttons to change or reset settings. * Initialize page messages and content. */ if (!empty($_REQUEST['mla-gallery-options-save'])) { check_admin_referer(MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME); $page_content = self::_save_gallery_settings(); } else { $page_content = array('message' => '', 'body' => ''); } if (!empty($page_content['body'])) { return $page_content; } $page_values = array('MLA Gallery Options' => __('MLA Gallery Options', 'media-library-assistant'), 'Go to Style Templates' => __('Go to Style Templates', 'media-library-assistant'), 'Go to Markup Templates' => __('Go to Markup Templates', 'media-library-assistant'), 'In this tab' => __('In this tab you can view the default style and markup templates. You can also define additional templates and use the <code>mla_style</code> and <code>mla_markup</code> parameters to apply them in your <code>[mla_gallery]</code> shortcodes. <strong>NOTE:</strong> template additions and changes will not be made permanent until you click "Save Changes" at the bottom of this page.', 'media-library-assistant'), 'form_url' => admin_url('options-general.php') . '?page=mla-settings-menu-mla_gallery&mla_tab=mla_gallery', 'options_list' => '', 'Go to Top' => __('Go to Top', 'media-library-assistant'), 'Style Templates' => __('Style Templates', 'media-library-assistant'), 'style_options_list' => '', 'Markup Templates' => __('Markup Templates', 'media-library-assistant'), 'markup_options_list' => '', 'Save Changes' => __('Save Changes', '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)); /* * Build default template selection lists; leave out the [mla_tag_cloud] templates */ MLACore::$mla_option_definitions['default_style']['options'][] = 'none'; MLACore::$mla_option_definitions['default_style']['texts'][] = '— ' . __('None', 'media-library-assistant') . ' —'; MLACore::$mla_option_definitions['default_style']['options'][] = 'theme'; MLACore::$mla_option_definitions['default_style']['texts'][] = '— ' . __('Theme', 'media-library-assistant') . ' —'; $templates = MLAOptions::mla_get_style_templates(); ksort($templates); foreach ($templates as $key => $value) { if ('tag-cloud' == $key) { continue; } MLACore::$mla_option_definitions['default_style']['options'][] = $key; MLACore::$mla_option_definitions['default_style']['texts'][] = $key; } $templates = MLAOptions::mla_get_markup_templates(); ksort($templates); foreach ($templates as $key => $value) { if (in_array($key, array('tag-cloud', 'tag-cloud-dl', 'tag-cloud-ul'))) { continue; } MLACore::$mla_option_definitions['default_markup']['options'][] = $key; MLACore::$mla_option_definitions['default_markup']['texts'][] = $key; } /* * Check for MLA Viewer Support requirements, * starting with Imagick check */ if (!class_exists('Imagick')) { $not_supported_warning = '<br> ' . __('Imagick support is not installed.', 'media-library-assistant'); } else { $not_supported_warning = ''; } $ghostscript_path = MLACore::mla_get_option('ghostscript_path'); if (!MLAShortcode_Support::mla_ghostscript_present($ghostscript_path, true)) { $not_supported_warning .= '<br> ' . __('Ghostscript support is not installed.', 'media-library-assistant'); } if (!empty($not_supported_warning)) { MLACore::$mla_option_definitions['enable_mla_viewer']['help'] = '<strong>' . __('WARNING:', 'media-library-assistant') . __(' MLA Viewer support may not be available', 'media-library-assistant') . ':</strong>' . $not_supported_warning; } /* * Start with any page-level options */ $options_list = ''; foreach (MLACore::$mla_option_definitions as $key => $value) { if ('mla_gallery' == $value['tab']) { $options_list .= self::mla_compose_option_row($key, $value); } } $page_values['options_list'] = $options_list; /* * Add style templates; defaults go first */ $default_styles = array('default', 'tag-cloud'); $style_options_list = ''; $templates = MLAOptions::mla_get_style_templates(); foreach ($default_styles as $default) { $name = $default; $value = $templates[$default]; if (!empty($value)) { $template_values = array('help' => __('This default template cannot be altered or deleted, but you can copy the styles.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-default'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => "mla_style_templates_name[{$default}]", 'name_id' => "mla_style_templates_name_{$default}", 'readonly' => 'readonly="readonly"', 'name_text' => $default, 'control_cells' => $control_cells, 'Styles' => __('Styles', 'media-library-assistant'), 'value_name' => "mla_style_templates_value[{$default}]", 'value_id' => "mla_style_templates_value_{$default}", 'value_text' => esc_textarea($value), 'value_help' => __('List of substitution parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant')); $style_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-style'], $template_values); } // $value } // foreach default foreach ($templates as $name => $value) { $slug = sanitize_title($name); if (in_array($name, $default_styles)) { continue; // already handled above } $template_values = array('name' => 'mla_style_templates_delete[' . $slug . ']', 'id' => 'mla_style_templates_delete_' . $slug, 'value' => __('Delete this template', 'media-library-assistant'), 'help' => __('Check the box to delete this template when you press Update at the bottom of the page.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-delete'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => 'mla_style_templates_name[' . $slug . ']', 'name_id' => 'mla_style_templates_name_' . $slug, 'readonly' => '', 'name_text' => $slug, 'control_cells' => $control_cells, 'Styles' => __('Styles', 'media-library-assistant'), 'value_name' => 'mla_style_templates_value[' . $slug . ']', 'value_id' => 'mla_style_templates_value_' . $slug, 'value_text' => esc_textarea($value), 'value_help' => __('List of substitution parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant')); $style_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-style'], $template_values); } // foreach $templates /* * Add blank style template for additions */ if (!empty($value)) { $template_values = array('help' => __('Fill in a name and styles to add a new template.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-default'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => 'mla_style_templates_name[blank]', 'name_id' => 'mla_style_templates_name_blank', 'readonly' => '', 'name_text' => '', 'control_cells' => $control_cells, 'Styles' => __('Styles', 'media-library-assistant'), 'value_name' => 'mla_style_templates_value[blank]', 'value_id' => 'mla_style_templates_value_blank', 'value_text' => '', 'value_help' => __('List of substitution parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant')); $style_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-style'], $template_values); } // $value $page_values['style_options_list'] = $style_options_list; /* * Add markup templates; defaults go first */ $default_markups = array('default', 'tag-cloud', 'tag-cloud-ul', 'tag-cloud-dl'); $markup_options_list = ''; $templates = MLAOptions::mla_get_markup_templates(); foreach ($default_markups as $default) { $name = $default; $value = $templates[$default]; if (!empty($value)) { $template_values = array('help' => __('This default template cannot be altered or deleted, but you can copy the markup.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-default'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => "mla_markup_templates_name[{$default}]", 'name_id' => "mla_markup_templates_name_{$default}", 'readonly' => 'readonly="readonly"', 'name_text' => $default, 'control_cells' => $control_cells, 'Open' => __('Open', 'media-library-assistant'), 'open_name' => "mla_markup_templates_open[{$default}]", 'open_id' => "mla_markup_templates_open_{$default}", 'open_text' => isset($value['open']) ? esc_textarea($value['open']) : '', 'open_help' => __('Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant'), 'Row' => __('Row', 'media-library-assistant'), 'row_open_name' => "mla_markup_templates_row_open[{$default}]", 'row_open_id' => "mla_markup_templates_row_open_{$default}", 'row_open_text' => isset($value['row-open']) ? esc_textarea($value['row-open']) : '', 'row_open_help' => __('Markup for the beginning of each row in the gallery.', 'media-library-assistant'), 'Item' => __('Item', 'media-library-assistant'), 'item_name' => "mla_markup_templates_item[{$default}]", 'item_id' => "mla_markup_templates_item_{$default}", 'item_text' => isset($value['item']) ? esc_textarea($value['item']) : '', 'item_help' => __('Markup for each item/cell of the gallery.', 'media-library-assistant'), 'Close' => __('Close', 'media-library-assistant'), 'row_close_name' => "mla_markup_templates_row_close[{$default}]", 'row_close_id' => "mla_markup_templates_row_close_{$default}", 'row_close_text' => isset($value['row-close']) ? esc_textarea($value['row-close']) : '', 'row_close_help' => __('Markup for the end of each row in the gallery.', 'media-library-assistant'), 'close_name' => "mla_markup_templates_close[{$default}]", 'close_id' => "mla_markup_templates_close_{$default}", 'close_text' => isset($value['close']) ? esc_textarea($value['close']) : '', 'close_help' => __('Markup for the end of the gallery.', 'media-library-assistant')); $markup_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-markup'], $template_values); } // $value } // foreach default foreach ($templates as $name => $value) { $slug = sanitize_title($name); if (in_array($name, $default_markups)) { continue; // already handled above } $template_values = array('name' => 'mla_markup_templates_delete[' . $slug . ']', 'id' => 'mla_markup_templates_delete_' . $slug, 'value' => __('Delete this template', 'media-library-assistant'), 'help' => __('Check the box to delete this template when you press Update at the bottom of the page.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-delete'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => 'mla_markup_templates_name[' . $slug . ']', 'name_id' => 'mla_markup_templates_name_' . $slug, 'readonly' => '', 'name_text' => $slug, 'control_cells' => $control_cells, 'Open' => __('Open', 'media-library-assistant'), 'open_name' => 'mla_markup_templates_open[' . $slug . ']', 'open_id' => 'mla_markup_templates_open_' . $slug, 'open_text' => esc_textarea($value['open']), 'open_help' => __('Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant'), 'Row' => __('Row', 'media-library-assistant'), 'row_open_name' => 'mla_markup_templates_row_open[' . $slug . ']', 'row_open_id' => 'mla_markup_templates_row_open_' . $slug, 'row_open_text' => esc_textarea($value['row-open']), 'row_open_help' => __('Markup for the beginning of each row.', 'media-library-assistant'), 'Item' => __('Item', 'media-library-assistant'), 'item_name' => 'mla_markup_templates_item[' . $slug . ']', 'item_id' => 'mla_markup_templates_item_' . $slug, 'item_text' => esc_textarea($value['item']), 'item_help' => __('Markup for each item/cell.', 'media-library-assistant'), 'Close' => __('Close', 'media-library-assistant'), 'row_close_name' => 'mla_markup_templates_row_close[' . $slug . ']', 'row_close_id' => 'mla_markup_templates_row_close_' . $slug, 'row_close_text' => esc_textarea($value['row-close']), 'row_close_help' => __('Markup for the end of each row.', 'media-library-assistant'), 'close_name' => 'mla_markup_templates_close[' . $slug . ']', 'close_id' => 'mla_markup_templates_close_' . $slug, 'close_text' => esc_textarea($value['close']), 'close_help' => __('Markup for the end of the gallery.', 'media-library-assistant')); $markup_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-markup'], $template_values); } // foreach $templates /* * Add blank markup template for additions */ if (!empty($value)) { $template_values = array('help' => __('Fill in a name and markup to add a new template.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-default'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => 'mla_markup_templates_name[blank]', 'name_id' => 'mla_markup_templates_name_blank', 'readonly' => '', 'name_text' => '', 'control_cells' => $control_cells, 'Open' => __('Open', 'media-library-assistant'), 'open_name' => 'mla_markup_templates_open[blank]', 'open_id' => 'mla_markup_templates_open_blank', 'open_text' => '', 'open_help' => __('Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant'), 'Row' => __('Row', 'media-library-assistant'), 'row_open_name' => 'mla_markup_templates_row_open[blank]', 'row_open_id' => 'mla_markup_templates_row_open_blank', 'row_open_text' => '', 'row_open_help' => __('Markup for the beginning of each row in the gallery.', 'media-library-assistant'), 'Item' => __('Item', 'media-library-assistant'), 'item_name' => 'mla_markup_templates_item[blank]', 'item_id' => 'mla_markup_templates_item_blank', 'item_text' => '', 'item_help' => __('Markup for each item/cell of the gallery.', 'media-library-assistant'), 'Close' => __('Close', 'media-library-assistant'), 'row_close_name' => 'mla_markup_templates_row_close[blank]', 'row_close_id' => 'mla_markup_templates_row_close_blank', 'row_close_text' => '', 'row_close_help' => __('Markup for the end of each row in the gallery.', 'media-library-assistant'), 'close_name' => 'mla_markup_templates_close[blank]', 'close_id' => 'mla_markup_templates_close_blank', 'close_text' => '', 'close_help' => __('Markup for the end of the gallery.', 'media-library-assistant')); $markup_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-markup'], $template_values); } // $value $page_values['markup_options_list'] = $markup_options_list; $page_content['body'] = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-tab'], $page_values); return $page_content; }
/** * Compose the MLA Gallery tab content for the Settings subpage * * @since 0.80 * @uses $page_template_array contains tab content template(s) * * @return array 'message' => status/error messages, 'body' => tab content */ private static function _compose_mla_gallery_tab() { /* * Check for submit buttons to change or reset settings. * Initialize page messages and content. */ if (!empty($_REQUEST['mla-gallery-options-save'])) { check_admin_referer(MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME); $page_content = self::_save_gallery_settings(); } else { $page_content = array('message' => '', 'body' => ''); } if (!empty($page_content['body'])) { return $page_content; } /* * Compose shortcode jump table */ $shortcode_jump_rows = ''; foreach (MLATemplate_Support::$mla_template_definitions['style'] as $shortcode => $definition) { $template_values = array('shortcode' => $shortcode, 'Go to Style Templates' => sprintf('%1$s [mla_%2$s] %3$s', __('Go to', 'media-library-assistant'), $shortcode, __('Style Templates', 'media-library-assistant')), 'Go to Markup Templates' => sprintf('%1$s [mla_%2$s] %3$s', __('Go to', 'media-library-assistant'), $shortcode, __('Markup Templates', 'media-library-assistant'))); $shortcode_jump_rows .= MLAData::mla_parse_template(self::$page_template_array['shortcode-jump-row'], $template_values); } $page_values = array('MLA Shortcode Options' => __('MLA Shortcode Options', 'media-library-assistant'), 'Shortcode Jump Rows' => $shortcode_jump_rows, 'In this tab' => __('In this tab you can view the default style and markup templates. You can also define additional templates and use the <code>mla_style</code> and <code>mla_markup</code> parameters to apply them in your <code>[mla_gallery]</code> shortcodes. <strong>NOTE:</strong> template additions and changes will not be made permanent until you click "Save Changes" at the bottom of this page.', 'media-library-assistant'), 'form_url' => admin_url('options-general.php') . '?page=mla-settings-menu-mla_gallery&mla_tab=mla_gallery', 'options_list' => '', 'Go to Top' => __('Go to Top', 'media-library-assistant'), 'Go to Bottom' => __('Go to Bottom', 'media-library-assistant'), 'style_sections_list' => '', 'markup_sections_list' => '', 'Save Changes' => __('Save Changes', '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)); /* * Build default template selection lists */ MLACoreOptions::$mla_option_definitions['default_style']['options'][] = 'none'; MLACoreOptions::$mla_option_definitions['default_style']['texts'][] = '— ' . __('None', 'media-library-assistant') . ' —'; MLACoreOptions::$mla_option_definitions['default_style']['options'][] = 'theme'; MLACoreOptions::$mla_option_definitions['default_style']['texts'][] = '— ' . __('Theme', 'media-library-assistant') . ' —'; $templates = MLATemplate_Support::mla_get_style_templates('gallery'); ksort($templates); foreach ($templates as $key => $value) { MLACoreOptions::$mla_option_definitions['default_style']['options'][] = $key; MLACoreOptions::$mla_option_definitions['default_style']['texts'][] = $key; } $templates = MLATemplate_Support::mla_get_markup_templates('gallery'); ksort($templates); foreach ($templates as $key => $value) { MLACoreOptions::$mla_option_definitions['default_markup']['options'][] = $key; MLACoreOptions::$mla_option_definitions['default_markup']['texts'][] = $key; } /* * Check for MLA Viewer Support requirements, * starting with Imagick check */ if (!class_exists('Imagick')) { $not_supported_warning = '<br> ' . __('Imagick support is not installed.', 'media-library-assistant'); } else { $not_supported_warning = ''; } $ghostscript_path = MLACore::mla_get_option('ghostscript_path'); if (!MLAShortcode_Support::mla_ghostscript_present($ghostscript_path, true)) { $not_supported_warning .= '<br> ' . __('Ghostscript support is not installed.', 'media-library-assistant'); } if (!empty($not_supported_warning)) { MLACoreOptions::$mla_option_definitions['enable_mla_viewer']['help'] = '<strong>' . __('WARNING:', 'media-library-assistant') . __(' MLA Viewer support may not be available', 'media-library-assistant') . ':</strong>' . $not_supported_warning; } /* * Start with any page-level options */ $options_list = ''; foreach (MLACoreOptions::$mla_option_definitions as $key => $value) { if ('mla_gallery' == $value['tab']) { $options_list .= self::mla_compose_option_row($key, $value); } } $page_values['options_list'] = $options_list; /* * Add style templates by shortcode; defaults go first */ $style_sections_list = ''; foreach (MLATemplate_Support::$mla_template_definitions['style'] as $shortcode => $definition) { $templates = MLATemplate_Support::mla_get_style_templates($definition['slug']); $style_options_list = ''; foreach ($definition['default_names'] as $default) { if (!array_key_exists($default, $templates)) { continue; } $value = $templates[$default]; if (!empty($value)) { $template_values = array('help' => __('This default template cannot be altered or deleted, but you can copy the styles.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-default'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => "mla_style_templates_name[{$shortcode}][{$default}]", 'name_id' => "mla_style_templates_name_{$shortcode}_{$default}", 'readonly' => 'readonly="readonly"', 'name_text' => $default, 'control_cells' => $control_cells, 'Styles' => $definition['label'], 'value_name' => "mla_style_templates_value[{$shortcode}][{$default}]", 'value_id' => "mla_style_templates_value_{$shortcode}_{$default}", 'value_text' => esc_textarea($value), 'value_help' => $definition['help']); $style_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-style'], $template_values); } // $value } // foreach default foreach ($templates as $name => $value) { $slug = sanitize_title($name); if (in_array($name, $definition['default_names'])) { continue; // already handled above } $template_values = array('name' => "mla_style_templates_delete[{$shortcode}][{$slug}]", 'id' => "mla_style_templates_delete_{$shortcode}_{$slug}", 'value' => __('Delete this template', 'media-library-assistant'), 'help' => __('Check the box to delete this template when you press Update at the bottom of the page.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-delete'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => "mla_style_templates_name[{$shortcode}][{$slug}]", 'name_id' => "mla_style_templates_name_{$shortcode}_{$slug}", 'readonly' => '', 'name_text' => $slug, 'control_cells' => $control_cells, 'Styles' => $definition['label'], 'value_name' => "mla_style_templates_value[{$shortcode}][{$slug}]", 'value_id' => "mla_style_templates_value_{$shortcode}_{$slug}", 'value_text' => esc_textarea($value), 'value_help' => $definition['help']); $style_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-style'], $template_values); } // foreach $templates /* * Add blank style template for additions */ if (!empty($value)) { $template_values = array('help' => __('Fill in a name and styles to add a new template.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-default'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => "mla_style_templates_name[{$shortcode}][blank]", 'name_id' => "mla_style_templates_name_{$shortcode}_blank", 'readonly' => '', 'name_text' => '', 'control_cells' => $control_cells, 'Styles' => $definition['label'], 'value_name' => "mla_style_templates_value[{$shortcode}][blank]", 'value_id' => "mla_style_templates_value_{$shortcode}_blank", 'value_text' => '', 'value_help' => $definition['help']); $style_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-style'], $template_values); } // $value /* * Compose the Styles section for this shortcode */ $template_values = array('shortcode' => $shortcode, 'template_type' => 'style', 'Go to Top' => __('Go to Top', 'media-library-assistant'), 'Go to Bottom' => __('Go to Bottom', 'media-library-assistant'), 'Templates' => "[mla_{$shortcode}] " . __('Style Templates', 'media-library-assistant'), 'templates_list' => $style_options_list); $style_sections_list .= MLAData::mla_parse_template(self::$page_template_array['templates-list'], $template_values); } // $shortcode $page_values['style_sections_list'] = $style_sections_list; /* * Add markup templates; defaults go first */ $markup_sections_list = ''; foreach (MLATemplate_Support::$mla_template_definitions['markup'] as $shortcode => $definition) { $templates = MLATemplate_Support::mla_get_markup_templates($definition['slug']); $markup_options_list = ''; $sorted_sections = array(); foreach (MLATemplate_Support::$mla_template_definitions['markup'][$shortcode]['sections'] as $section_slug => $section_definition) { $sorted_sections[$section_definition['order']] = $section_definition; $sorted_sections[$section_definition['order']]['slug'] = $section_slug; } ksort($sorted_sections, SORT_NUMERIC); foreach ($definition['default_names'] as $default) { if (!array_key_exists($default, $templates)) { continue; } $value = $templates[$default]; if (!empty($value)) { $sections_list = ''; foreach ($sorted_sections as $section_definition) { $section_slug = $section_definition['slug']; $template_values = array('Label' => $section_definition['label'], 'name' => "mla_markup_templates_sections[{$shortcode}][{$default}][{$section_slug}]", 'id' => "mla_markup_templates_name_{$shortcode}_{$default}_{$section_slug}", 'rows' => $section_definition['rows'], 'readonly' => 'readonly="readonly"', 'text' => isset($value[$section_slug]) ? esc_textarea($value[$section_slug]) : '', 'help' => $section_definition['help']); $sections_list .= MLAData::mla_parse_template(self::$page_template_array['template-section'], $template_values); } // $section $template_values = array('help' => __('This default template cannot be altered or deleted, but you can copy the markup.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-default'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => "mla_markup_templates_name[{$shortcode}][{$default}]", 'name_id' => "mla_markup_templates_name_{$shortcode}_{$default}", 'readonly' => 'readonly="readonly"', 'name_text' => $default, 'control_cells' => $control_cells, 'sections_list' => $sections_list); $markup_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-markup'], $template_values); } // $value } // foreach default foreach ($templates as $name => $value) { $slug = sanitize_title($name); if (in_array($name, $definition['default_names'])) { continue; // already handled above } if (!empty($value)) { $sections_list = ''; foreach ($sorted_sections as $section_definition) { $section_slug = $section_definition['slug']; $template_values = array('Label' => $section_definition['label'], 'name' => "mla_markup_templates_sections[{$shortcode}][{$name}][{$section_slug}]", 'id' => "mla_markup_templates_name_{$shortcode}_{$name}_{$section_slug}", 'rows' => $section_definition['rows'], 'readonly' => '', 'text' => isset($value[$section_slug]) ? esc_textarea($value[$section_slug]) : '', 'help' => $section_definition['help']); $sections_list .= MLAData::mla_parse_template(self::$page_template_array['template-section'], $template_values); } // $section $template_values = array('name' => "mla_markup_templates_delete[{$shortcode}][{$slug}]", 'id' => "mla_markup_templates_delete_{$shortcode}_{$slug}", 'value' => __('Delete this template', 'media-library-assistant'), 'help' => __('Check the box to delete this template when you press Update at the bottom of the page.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-delete'], $template_values); $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => "mla_markup_templates_name[{$shortcode}][{$slug}]", 'name_id' => "mla_markup_templates_name_{$shortcode}_{$slug}", 'readonly' => '', 'name_text' => $slug, 'control_cells' => $control_cells, 'sections_list' => $sections_list); $markup_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-markup'], $template_values); } // $value } // foreach $templates /* * Add blank markup template for additions */ if (!empty($value)) { $template_values = array('help' => __('Fill in a name and markup to add a new template.', 'media-library-assistant')); $control_cells = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-default'], $template_values); $sections_list = ''; foreach ($sorted_sections as $section_definition) { $section_slug = $section_definition['slug']; $template_values = array('Label' => $section_definition['label'], 'name' => "mla_markup_templates_sections[{$shortcode}][blank][{$section_slug}]", 'id' => "mla_markup_templates_name_{$shortcode}_blank_{$section_slug}", 'rows' => $section_definition['rows'], 'readonly' => '', 'text' => '', 'help' => $section_definition['help']); $sections_list .= MLAData::mla_parse_template(self::$page_template_array['template-section'], $template_values); } // $section $template_values = array('Name' => __('Name', 'media-library-assistant'), 'name_name' => "mla_markup_templates_name[{$shortcode}][blank]", 'name_id' => "mla_markup_templates_name_{$shortcode}_blank", 'name_text' => '', 'control_cells' => $control_cells, 'sections_list' => $sections_list); $markup_options_list .= MLAData::mla_parse_template(self::$page_template_array['mla-gallery-markup'], $template_values); } // $value /* * Compose the Markup section for this shortcode */ $template_values = array('shortcode' => $shortcode, 'template_type' => 'markup', 'Go to Top' => __('Go to Top', 'media-library-assistant'), 'Go to Bottom' => __('Go to Bottom', 'media-library-assistant'), 'Templates' => "[mla_{$shortcode}] " . __('Markup Templates', 'media-library-assistant'), 'templates_list' => $markup_options_list); $markup_sections_list .= MLAData::mla_parse_template(self::$page_template_array['templates-list'], $template_values); } // $shortcode $page_values['markup_sections_list'] = $markup_sections_list; $page_content['body'] = MLAData::mla_parse_template(self::$page_template_array['mla-gallery-tab'], $page_values); return $page_content; }