array(
'gallery' => array(
'label' => _x( 'Gallery', 'table_view_singular', 'media_library-assistant' ),
'default_names' => array( 'default' ),
'sections' => array(
'description' => array(
'label' => __( 'Description', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Notes for the Shortcodes tab submenu table.', 'media-library-assistant' ),
'order' => 0,
),
'styles' => array(
'label' => __( 'Styles', 'media-library-assistant' ),
'rows' => 10,
'help' => __( 'List of substitution parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' ),
'order' => 1,
),
),
),
'tag-cloud' => array(
'label' => _x( 'Tag Cloud', 'table_view_singular', 'media_library-assistant' ),
'default_names' => array( 'tag-cloud' ),
'sections' => array(
'description' => array(
'label' => __( 'Description', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Notes for the Shortcodes tab submenu table.', 'media-library-assistant' ),
'order' => 0,
),
'styles' => array(
'label' => __( 'Styles', 'media-library-assistant' ),
'rows' => 10,
'help' => __( 'List of substitution parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' ),
'order' => 1,
),
),
),
'term-list' => array(
'label' => _x( 'Term List', 'table_view_singular', 'media_library-assistant' ),
'default_names' => array( 'term-list' ),
'sections' => array(
'description' => array(
'label' => __( 'Description', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Notes for the Shortcodes tab submenu table.', 'media-library-assistant' ),
'order' => 0,
),
'styles' => array(
'label' => __( 'Styles', 'media-library-assistant' ),
'rows' => 10,
'help' => __( 'List of substitution parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' ),
'order' => 1,
),
),
),
),
'markup' => array(
'gallery' => array(
'label' => _x( 'Gallery', 'table_view_singular', 'media_library-assistant' ),
'default_names' => array( 'default' ),
'sections' => array(
'description' => array(
'label' => __( 'Description', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Notes for the Shortcodes tab submenu table.', 'media-library-assistant' ),
'order' => 0,
),
'arguments' => array(
'label' => __( 'Arguments', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Default shortcode parameter values.', 'media-library-assistant' ),
'order' => 2,
),
'row-open' => array(
'label' => __( 'Row', 'media-library-assistant' ) . ' ' . __( 'Open', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the beginning of each row in the gallery.', 'media-library-assistant' ),
'order' => 4,
),
'open' => array(
'label' => __( 'Open', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the beginning of the gallery. List of parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' ),
'order' => 3,
),
'item' => array(
'label' => __( 'Item', 'media-library-assistant' ),
'rows' => 6,
'help' => __( 'Markup for each item/cell of the gallery.', 'media-library-assistant' ),
'order' => 5,
),
'row-close' => array(
'label' => __( 'Row', 'media-library-assistant' ) . ' ' . __( 'Close', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the end of each row in the gallery.', 'media-library-assistant' ),
'order' => 9,
),
'close' => array(
'label' => __( 'Close', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the end of the gallery.', 'media-library-assistant' ),
'order' => 10,
),
),
),
'tag-cloud' => array(
'label' => _x( 'Tag Cloud', 'table_view_singular', 'media_library-assistant' ),
'default_names' => array( 'tag-cloud', 'tag-cloud-ul', 'tag-cloud-dl' ),
'sections' => array(
'description' => array(
'label' => __( 'Description', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Notes for the Shortcodes tab submenu table.', 'media-library-assistant' ),
'order' => 0,
),
'arguments' => array(
'label' => __( 'Arguments', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Default shortcode parameter values.', 'media-library-assistant' ),
'order' => 2,
),
'row-open' => array(
'label' => __( 'Row', 'media-library-assistant' ) . ' ' . __( 'Open', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the beginning of each row in the cloud; grid format only.', 'media-library-assistant' ),
'order' => 4,
),
'open' => array(
'label' => __( 'Open', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the beginning of the cloud. List of parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' ),
'order' => 3,
),
'item' => array(
'label' => __( 'Item', 'media-library-assistant' ),
'rows' => 6,
'help' => __( 'Markup for each item/cell of the cloud.', 'media-library-assistant' ),
'order' => 5,
),
'row-close' => array(
'label' => __( 'Row', 'media-library-assistant' ) . ' ' . __( 'Close', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the end of each row in the cloud; grid format only.', 'media-library-assistant' ),
'order' => 9,
),
'close' => array(
'label' => __( 'Close', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the end of the cloud.', 'media-library-assistant' ),
'order' => 10,
),
),
),
'term-list' => array(
'label' => _x( 'Term List', 'table_view_singular', 'media_library-assistant' ),
'default_names' => array( 'term-list-ul', 'term-list-dl', 'term-list-dropdown', 'term-list-checklist' ),
'sections' => array(
'description' => array(
'label' => __( 'Description', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Notes for the Shortcodes tab submenu table.', 'media-library-assistant' ),
'order' => 0,
),
'arguments' => array(
'label' => __( 'Arguments', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Default shortcode parameter values.', 'media-library-assistant' ),
'order' => 1,
),
'child-open' => array(
'label' => __( 'Child', 'media-library-assistant' ) . ' ' . __( 'Open', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the beginning of each level in the hierarchy; list format only.', 'media-library-assistant' ),
'order' => 6,
),
'child-item' => array(
'label' => __( 'Child', 'media-library-assistant' ) . ' ' . __( 'Item', 'media-library-assistant' ),
'rows' => 6,
'help' => __( 'Markup for each lower-level item in the hierarchy; list format only.', 'media-library-assistant' ),
'order' => 7,
),
'child-close' => array(
'label' => __( 'Child', 'media-library-assistant' ) . ' ' . __( 'Close', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the end of each level in the hierarchy; list format only.', 'media-library-assistant' ),
'order' => 8,
),
'open' => array(
'label' => __( 'Open', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the beginning of the list. List of parameters, e.g., [+selector+], on Documentation tab.', 'media-library-assistant' ),
'order' => 3,
),
'item' => array(
'label' => __( 'Item', 'media-library-assistant' ),
'rows' => 6,
'help' => __( 'Markup for each item/cell in the list.', 'media-library-assistant' ),
'order' => 5,
),
'close' => array(
'label' => __( 'Close', 'media-library-assistant' ),
'rows' => 3,
'help' => __( 'Markup for the end of the list.', 'media-library-assistant' ),
'order' => 10,
),
),
),
),
);
//error_log( __LINE__ . ' mla_localize_template_definitions MLATemplate_Support::$mla_template_definitions = ' . var_export( MLATemplate_Support::$mla_template_definitions, true ), 0 );
}
/**
* Style and Markup templates.
*
* @since 2.30
* @access private
* @var array $mla_custom_templates {
* Templates by type. Key $$type is 'markup' or 'style'.
*
* @type array $$type {
* Templates by shortcode. Key $$shortcode_slug is 'gallery', 'tag-cloud' or 'term-list'
*
* @type array $$shortcode_slug {
* Templates by name. Key $$template_name is the template name/slug, which must be unique within type.
*
* @type array $$template_name {
* Template content by section. Key $$section_name is the section name/slug.
*
* @type string $$section_name HTML markup/CSS styles for the template section.
* }
* }
* }
* }
*/
private static $mla_custom_templates = NULL;
/**
* Load style and markup templates to $mla_custom_templates.
*
* @since 2.30
*
* @return null
*/
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( 'mla_debug mla_load_custom_templates() ' . __( 'error loading tpls/mla-custom-templates.tpl', 'media-library-assistant' ), MLACore::MLA_DEBUG_CATEGORY_ANY );
return;
} elseif ( !$default_templates ) {
MLACore::mla_debug_add( 'mla_debug mla_load_custom_templates() ' . __( 'tpls/mla-custom-templates.tpl not found', 'media-library-assistant' ), MLACore::MLA_DEBUG_CATEGORY_ANY );
return;
}
// Record explicit shortcode assignments, extract the style template description "section"
$mla_shortcode_slugs = array();
$mla_descriptions = array();
foreach ( $default_templates as $key => $value ) {
$mla_shortcode_slug = NULL;
$mla_description = NULL;
$match_count = preg_match( '#\\r\n%2\$s", $sections['description'], $styles );
}
$new_templates[ $name ] = $styles;
}
if ( MLACore::mla_update_option( 'style_templates', $new_templates ) ) {
MLATemplate_Support::mla_load_custom_templates();
return true;
}
return false;
}
/**
* Get ALL markup templates from $mla_custom_templates, including default(s).
*
* @since 2.30
*
* @param string $shortcode Optional. Shortcode to which the template(s) apply. Default 'gallery'.
* @return array|null Array ( name => value ) for all markup templates or null if no templates.
*/
public static function mla_get_markup_templates( $shortcode = '' ) {
if ( ! is_array( MLATemplate_Support::$mla_custom_templates ) ) {
MLACore::mla_debug_add( 'mla_debug mla_get_markup_templates() ' . __( 'no templates exist', 'media-library-assistant' ) );
return NULL;
}
if ( !empty( $shortcode ) ) {
if ( array_key_exists( $shortcode, MLATemplate_Support::$mla_custom_templates['markup'] ) ) {
return MLATemplate_Support::$mla_custom_templates['markup'][ $shortcode ];
}
return NULL;
}
$templates = array();
foreach ( MLATemplate_Support::$mla_custom_templates['markup'] as $shortcode => $value ) {
$templates = array_merge( $templates, $value );
} // foreach
return $templates;
}
/**
* Put user-defined markup templates to $mla_custom_templates and database
*
* @since 2.30
*
* @param array $templates Array ( name => value ) for all user-defined markup templates.
* @return boolean true if success, false if failure.
*/
public static function mla_put_markup_templates( $templates ) {
if ( MLACore::mla_update_option( 'markup_templates', $templates ) ) {
MLATemplate_Support::mla_load_custom_templates();
return true;
}
return false;
}
} // Class MLATemplate_Support
MLATemplate_Support::mla_load_custom_templates();
?>