Permalink
Browse files

sub option names are now joined internally with an underscore instead…

… of a hyphen to prevent feature name collisions

sub option "dot" syntax is now supported for api call parameters
  • Loading branch information...
1 parent c016ca1 commit 302bbbfc1254d2ae00c0b6c0a4d0a1dd20ce2dfd @MrMaz MrMaz committed Apr 26, 2012
@@ -843,7 +843,7 @@ public function get_children()
public function get_suboption( $name )
{
// build up option name
- $option_name = sprintf( '%s-%s', $this->name, $name );
+ $option_name = $this->name . ICE_Registry::SUB_OPTION_GLUE . $name;
// get and return it
return $this->policy()->options()->registry()->get( $option_name );
@@ -27,6 +27,16 @@
abstract class ICE_Registry extends ICE_Componentable implements ICE_Visitable
{
/**
+ * Sub option delimeter
+ */
+ const SUB_OPTION_DELIM = '.';
+
+ /**
+ * Sub option glue
+ */
+ const SUB_OPTION_GLUE = '_';
+
+ /**
* Name of the theme currently being loaded
*
* @var string
@@ -137,13 +147,32 @@ protected function localize_script() {}
}
/**
+ * Normalize a component name which may have "dots" in it
+ *
+ * @param string $name
+ * @return string
+ */
+ final protected function normalize_name( $name )
+ {
+ if ( strpos( $name, self::SUB_OPTION_DELIM ) !== false ) {
+ return str_replace( self::SUB_OPTION_DELIM, self::SUB_OPTION_GLUE, $name );
+ }
+
+ return $name;
+ }
+
+ /**
* Returns true if a component has been registered
*
* @param string $name
* @return boolean
*/
final public function has( $name )
{
+ // normalize name
+ $name = $this->normalize_name( $name );
+
+ // call contains method of map class
return $this->components->contains( $name );
}
@@ -155,6 +184,9 @@ protected function localize_script() {}
*/
final public function get( $name )
{
+ // normalize name
+ $name = $this->normalize_name( $name );
+
// check registry
if ( $this->components->contains( $name ) ) {
// from top of stack
@@ -331,6 +363,9 @@ private function load_config_section( $section_name, $section_array )
*/
final protected function load_config_map( $name, $config_array )
{
+ // normalize name
+ $name = $this->normalize_name( $name );
+
// push theme onto config
$config_array['theme'] = self::theme_scope();
@@ -22,11 +22,6 @@
abstract class ICE_Option_Registry extends ICE_Registry
{
/**
- * Sub option delimeter
- */
- const FEATURE_OPTION_DELIM = '.';
-
- /**
* Enqueue required scripts
*/
public function init_scripts()
@@ -86,16 +81,16 @@ public function load_feature_option( $name, $config )
// feature explicitly set?
if ( isset( $config['feature'] ) ) {
- $option_name = $config['feature'] . '-' . $name;
+ $option_name = $config['feature'] . self::SUB_OPTION_GLUE . $name;
} else {
// split for possible sub option syntax
- $parts = explode( self::FEATURE_OPTION_DELIM, $name );
+ $parts = explode( self::SUB_OPTION_DELIM, $name );
// if has exactly two parts its a feature option
if ( count($parts) == 2 ) {
// feature name is the first string
$config['feature'] = $parts[0];
// option name is both strings glued with a hyphen
- $option_name = implode( '-', $parts );
+ $option_name = implode( self::SUB_OPTION_GLUE, $parts );
}
}
@@ -105,7 +100,7 @@ public function load_feature_option( $name, $config )
$config['required_feature'] = $config['feature'];
// clean up parent
if ( isset( $config['parent'] ) ) {
- $config['parent'] = str_replace( self::FEATURE_OPTION_DELIM, '-', $config['parent'] );
+ $config['parent'] = $this->normalize_name( $config['parent'] );
}
// call parent config loader
if ( $this->load_config_map( $option_name, $config ) ) {
@@ -16,8 +16,8 @@
function infinity_google_analytics()
{
// render analytics code
- echo infinity_option_get( 'infinity-core-options-google-analytics' );
-}
+ echo infinity_option_get( 'infinity-core-options.google-analytics' );
+}
add_action('close_body','infinity_google_analytics');
/**
@@ -29,8 +29,8 @@ function infinity_google_analytics()
function infinity_custom_favicon()
{
// determine the image path
- if ( infinity_option_get( 'infinity-core-options-custom-favicon' ) ) {
- $image = infinity_option_image_url( 'infinity-core-options-custom-favicon', full );
+ if ( infinity_option_get( 'infinity-core-options.custom-favicon' ) ) {
+ $image = infinity_option_image_url( 'infinity-core-options.custom-favicon', full );
} else {
$image = get_template_directory_uri() . '/assets/images/favicon.png';
}
@@ -126,7 +126,7 @@ function infinity_get_sidebar_size()
// must support grid style feature
if ( current_theme_supports( 'infinity-grid-style' ) ) {
// get sidebar size
- $size = infinity_option_get( 'infinity-core-options-sidebar-size' );
+ $size = infinity_option_get( 'infinity-core-options.sidebar-size' );
// did we get one?
if ( $size ) {
return trim( $size );
@@ -186,7 +186,7 @@ function infinity_sidebar_position_css()
{
if (
current_theme_supports( 'infinity-grid-style' ) &&
- infinity_option_get( 'infinity-core-options-sidebar-position' ) != 'right'
+ infinity_option_get( 'infinity-core-options.sidebar-position' ) != 'right'
) {
print ' sidebar-left';
}
@@ -205,7 +205,7 @@ function infinity_sidebar_left_fallback()
{
if (
current_theme_supports( 'infinity-grid-style' ) &&
- infinity_option_get( 'infinity-core-options-sidebar-position' ) != 'right'
+ infinity_option_get( 'infinity-core-options.sidebar-position' ) != 'right'
) {
// render grid fallback script ?>
<script>
View
@@ -57,7 +57,7 @@
?>
</div>
<div id="copyright-info" class="grid_8 omega">
- <?php echo infinity_option_get( 'infinity-core-options-footer-text' ); ?>
+ <?php echo infinity_option_get( 'infinity-core-options.footer-text' ); ?>
</div>
<div style="clear: both;"></div>
</div>

0 comments on commit 302bbbf

Please sign in to comment.