/** * Assemble the in-memory representation of the Post MIME Types * * @since 1.40 * * @param boolean Force a reload/recalculation of types * * @return boolean Success (true) or failure (false) of the operation */ private static function _get_post_mime_templates($force_refresh = false) { if (false == $force_refresh && NULL != self::$mla_post_mime_templates) { return true; } /* * Start with MLA standard types */ $mla_types = MLAOptions::mla_get_option(MLAOptions::MLA_POST_MIME_TYPES, true); if (!is_array($mla_types)) { $mla_types = array(); } /* * If this is the first time MLA Post MIME support is invoked, match to the * filter-enhanced extensions, retain anything new as a custom type. * Otherwise, add the current MLA custom types. */ $custom_types = MLAOptions::mla_get_option(MLAOptions::MLA_POST_MIME_TYPES, false, true); if (is_array($custom_types)) { $mla_types = array_merge($mla_types, $custom_types); } else { /* * Add existing types that are not already in the MLA list */ self::$disable_mla_filtering = true; $post_mime_types = get_post_mime_types(); self::$disable_mla_filtering = false; foreach ($post_mime_types as $slug => $value) { if (!isset($mla_types[$slug])) { $mla_types[$slug] = array('singular' => substr($value[2][0], 0, strpos($value[2][0], ' <')), 'plural' => $value[0], 'specification' => '', 'post_mime_type' => true, 'table_view' => true, 'menu_order' => 0, 'description' => _x('Copied from previous filter/plugin', 'post_mime_types_description', 'media-library-assistant')); } } // new type } // First time called self::$mla_post_mime_templates = array(); self::$mla_post_mime_highest_ID = 0; /* * Load and number the entries */ foreach ($mla_types as $slug => $value) { self::$mla_post_mime_templates[$slug] = $value; self::$mla_post_mime_templates[$slug]['post_ID'] = ++self::$mla_post_mime_highest_ID; } self::_put_post_mime_templates(); return true; }