Skip to main content
edited body
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148

My theme options save routine is below. I'm finding that if the $value['id'] being passed from my options array has a period in it, the data does not get passed and the options appear to break at that point. Should I opt for another character or is theirthere a workaround for using the period character asin an option name?

For example, this works fine:

 "id" => "myTheme_color|sidebar",

but this does not (no data is passed for the value):

 "id" => "myTheme_color.sidebar",

The save function is:

function mytheme_add_admin(){
global $themename, $shortname, $options; 
if ( $_GET['page'] == basename(__FILE__) )
{
    if ( 'save' == $_REQUEST['action'] ) 
    {
        foreach ($options as $value) 
        {
            update_option( $value['id'], stripslashes($_REQUEST[$value['id']]) ); 
        }
        foreach ($options as $value) 
        {
            if( isset( $_REQUEST[ $value['id'] ] ) ) 
            {
                update_option( $value['id'], stripslashes($_REQUEST[ $value['id'] ])  ); 
            echo $value['id'].": ".$_REQUEST[$value['id']]."<br>";
            echo $value['id'].": ".stripslashes($_REQUEST[$value['id']])."<br>";
            } 
        }
    }
}

My theme options save routine is below. I'm finding that if the $value['id'] being passed from my options array has a period in it, the data does not get passed and the options appear to break at that point. Should I opt for another character or is their a workaround for using the period character as an option name?

For example, this works fine:

 "id" => "myTheme_color|sidebar",

but this does not (no data is passed for the value):

 "id" => "myTheme_color.sidebar",

The save function is:

function mytheme_add_admin(){
global $themename, $shortname, $options; 
if ( $_GET['page'] == basename(__FILE__) )
{
    if ( 'save' == $_REQUEST['action'] ) 
    {
        foreach ($options as $value) 
        {
            update_option( $value['id'], stripslashes($_REQUEST[$value['id']]) ); 
        }
        foreach ($options as $value) 
        {
            if( isset( $_REQUEST[ $value['id'] ] ) ) 
            {
                update_option( $value['id'], stripslashes($_REQUEST[ $value['id'] ])  ); 
            echo $value['id'].": ".$_REQUEST[$value['id']]."<br>";
            echo $value['id'].": ".stripslashes($_REQUEST[$value['id']])."<br>";
            } 
        }
    }
}

My theme options save routine is below. I'm finding that if the $value['id'] being passed from my options array has a period in it, the data does not get passed and the options appear to break at that point. Should I opt for another character or is there a workaround for using the period character in an option name?

For example, this works fine:

 "id" => "myTheme_color|sidebar",

but this does not (no data is passed for the value):

 "id" => "myTheme_color.sidebar",

The save function is:

function mytheme_add_admin(){
global $themename, $shortname, $options; 
if ( $_GET['page'] == basename(__FILE__) )
{
    if ( 'save' == $_REQUEST['action'] ) 
    {
        foreach ($options as $value) 
        {
            update_option( $value['id'], stripslashes($_REQUEST[$value['id']]) ); 
        }
        foreach ($options as $value) 
        {
            if( isset( $_REQUEST[ $value['id'] ] ) ) 
            {
                update_option( $value['id'], stripslashes($_REQUEST[ $value['id'] ])  ); 
            echo $value['id'].": ".$_REQUEST[$value['id']]."<br>";
            echo $value['id'].": ".stripslashes($_REQUEST[$value['id']])."<br>";
            } 
        }
    }
}
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148

Dot "." in option value foobars save options function

My theme options save routine is below. I'm finding that if the $value['id'] being passed from my options array has a period in it, the data does not get passed and the options appear to break at that point. Should I opt for another character or is their a workaround for using the period character as an option name?

For example, this works fine:

 "id" => "myTheme_color|sidebar",

but this does not (no data is passed for the value):

 "id" => "myTheme_color.sidebar",

The save function is:

function mytheme_add_admin(){
global $themename, $shortname, $options; 
if ( $_GET['page'] == basename(__FILE__) )
{
    if ( 'save' == $_REQUEST['action'] ) 
    {
        foreach ($options as $value) 
        {
            update_option( $value['id'], stripslashes($_REQUEST[$value['id']]) ); 
        }
        foreach ($options as $value) 
        {
            if( isset( $_REQUEST[ $value['id'] ] ) ) 
            {
                update_option( $value['id'], stripslashes($_REQUEST[ $value['id'] ])  ); 
            echo $value['id'].": ".$_REQUEST[$value['id']]."<br>";
            echo $value['id'].": ".stripslashes($_REQUEST[$value['id']])."<br>";
            } 
        }
    }
}