0

I knew many question about this, I try to read but still got this error message on my Wordpress :

"Creating default object from empty value in /home/forthemde/public_html/wp-content/themes/mayadeep/admin/admin.php on line 225"

Here the code on admin.php and:

 function upfw_setup_theme_options(){
     $up_options_db = get_option('up_themes_'.UPTHEMES_SHORT_NAME);
     global $up_options;
     //Check if options are stored properly
     if( isset($up_options_db) && is_array($up_options_db) ):
         //Check array to an object
         foreach ($up_options_db as $k => $v) {
                 $up_options -> {$k} = $v;
         }
     else:
         do_action('upfw_theme_activation');
     endif;
 }
 add_action('upfw_theme_init','upfw_setup_theme_options',10);
 add_action('upfw_admin_init','upfw_setup_theme_options',100);

Line 225 is here:

 $up_options -> {$k} = $v;

I try to fix by myself, but no result. Please help me, really appreciate for any help.

Regards.

1 Answer 1

0

This error is because the global object global $up_options is not defined.

Try to var_dump $up_options, it might be null.

Also check if you have spelled the variable name correctly.

Run this code, and check the output:

function upfw_setup_theme_options(){
     $up_options_db = get_option('up_themes_'.UPTHEMES_SHORT_NAME);
     global $up_options;

 $up_options = new stdClass();

     //Check if options are stored properly
     if( isset($up_options_db) && is_array($up_options_db) ):
         //Check array to an object
         foreach ($up_options_db as $k => $v) {
                 $up_options -> {$k} = $v;
         }
     else:
         do_action('upfw_theme_activation');
     endif;
 }
 add_action('upfw_theme_init','upfw_setup_theme_options');
 add_action('upfw_admin_init','upfw_setup_theme_options');
Sign up to request clarification or add additional context in comments.

8 Comments

Thanks, MortalViews. Unfortunatelly, I am not familiar with the code. How can I var_dump $up_options? Please help. Really appreciate for your help.
Thanks, Mortal. I tried but unfortunately did not work. My page become blank, and just display a text "NULL". The error code is in line 225: $up_options -> {$k} = $v;
ya, that's cos of the exit(); 'null' means the $up_option object is not defined.that's the problem.You need to make sure the global object is created before using it. var_dump, and exit was for debugging. you should remove it from your actual code, it's not a FIX.
When I delete the exit(); I got this notify: NULL Warning: Creating default object from empty value in C:\xampp-PHPBARU\apps\wordpress\htdocs\wp-content\themes\forthemde\admin\admin.php on line 233
that error is cos the object $up_option is having null value.you can't call property of a 'null' object.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.