0

got this error that prevents access to wordpress backend and cannot event change theme. ERROR: Warning: Illegal string offset 'Name' in /home/holiday1/public_html/reviewmyvisit.com/wp-content/themes/themia-lite/functions/theme-options.php on line 9

here is the code but I am not very familiar with php...just learning. any help is appreciated.

<?php

add_action('init', 'inkthemes_options');
if (!function_exists('inkthemes_options')) {

    function inkthemes_options() {
        // VARIABLES
        $themename = function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_current_theme();
        $themename = $themename['Name'];
        $shortname = "of";
        // Populate OptionsFramework option in array for use in theme
        global $of_options;
        $of_options = inkthemes_get_option('of_options');

        // Background Defaults

        $background_defaults = array('color' => '', 'image' => '', 'repeat' => 'repeat', 'position' => 'top center', 'attachment' => 'scroll');


        // Pull all the categories into an array
        $options_categories = array();
        $options_categories_obj = get_categories();
        foreach ($options_categories_obj as $category) {
            $options_categories[$category->cat_ID] = $category->cat_name;
        }

        // Pull all the pages into an array
        $options_pages = array();
        $options_pages_obj = get_pages('sort_column=post_parent,menu_order');
        $options_pages[''] = 'Select a page:';
        foreach ($options_pages_obj as $page) {
            $options_pages[$page->ID] = $page->post_title;
        }

        // If using image radio buttons, define a directory path
        $imagepath = get_template_directory_uri() . '/images/';

        $options = array(
            array("name" => "General Settings",
                "type" => "heading"),
            array("name" => "Custom Logo",
                "desc" => "Choose your own logo. Optimal Size: 160px Wide by 30px Height",
                "id" => "inkthemes_logo",
                "type" => "upload"),
            array("name" => "Custom Favicon",
                "desc" => "Specify a 16px x 16px image that will represent your website's favicon.",
                "id" => "inkthemes_favicon",
                "type" => "upload"),
            array("name" => "Tracking Code",
                "desc" => "Paste your Google Analytics (or other) tracking code here.",
                "id" => "inkthemes_analytics",
                "std" => "",
                "type" => "textarea"),
//****=============================================================================****//
//****-----------This code is used for creating home page feature content----------****//                           
//****=============================================================================****//   
            array("name" => "Home Page Settings",
                "type" => "heading"),
            array("name" => "Top Feature Image",
                "desc" => "Choose a image for top feature. Optimal size: 928px x 355px",
                "id" => "inkthemes_featureimg",
                "std" => "",
                "type" => "upload"),
            //***Code for first column***//
            array("name" => "First Feature Heading",
                "desc" => "Enter your heading line one",
                "id" => "inkthemes_headline1",
                "std" => "",
                "type" => "textarea"),
            array("name" => "First Feature Image",
                "desc" => "Upload image for your feature column one",
                "id" => "inkthemes_img1",
                "std" => "",
                "type" => "upload"),
            array("name" => "First Feature Content",
                "desc" => "Paste your feature content here... you can also put embed html code but the html
                            content should not exceed the maximum width size. Any content of maximum width is 272px.",
                "id" => "inkthemes_feature1",
                "std" => "",
                "type" => "textarea"),
            array("name" => "First Feature link",
                "desc" => "Enter your link for feature content column one",
                "id" => "inkthemes_link1",
                "std" => "",
                "type" => "text"),
            //***Code for second column***//                        
            array("name" => "Second Feature Heading",
                "desc" => "Enter your heading line second",
                "id" => "inkthemes_headline2",
                "std" => "",
                "type" => "textarea"),
            array("name" => "Second Feature Image",
                "desc" => "Upload image for your feature column second",
                "id" => "inkthemes_img2",
                "std" => "",
                "type" => "upload"),
            array("name" => "Second Feature Content",
                "desc" => "Paste your feature content here... you can also put embed html code but the html
                            content should not exceed the maximum width size. Any content of maximum width is 272px.",
                "id" => "inkthemes_feature2",
                "std" => "",
                "type" => "textarea"),
            array("name" => "Second Feature link",
                "desc" => "Enter your link for feature content column second",
                "id" => "inkthemes_link2",
                "std" => "",
                "type" => "text"),
            //***Code for third column***//                     
            array("name" => "Third Feature Heading",
                "desc" => "Enter your heading line third",
                "id" => "inkthemes_headline3",
                "std" => "",
                "type" => "textarea"),
            array("name" => "Third Feature Image",
                "desc" => "Upload image for your feature column third",
                "id" => "inkthemes_img3",
                "std" => "",
                "type" => "upload"),
            array("name" => "Third Feature Content",
                "desc" => "Paste your feature content here... you can also put embed html code but the html
                            content should not exceed the maximum width size. Any content of maximum width is 272px.",
                "id" => "inkthemes_feature3",
                "std" => "",
                "type" => "textarea"),
            array("name" => "Third Feature link",
                "desc" => "Enter your link for feature content column third",
                "id" => "inkthemes_link3",
                "std" => "",
                "type" => "text"));
        inkthemes_update_option('of_template', $options);
        inkthemes_update_option('of_themename', $themename);
        inkthemes_update_option('of_shortname', $shortname);
    }

}
?>
idmean
  • 14,540
  • 9
  • 54
  • 83
  • @wumm I'm thinking its `$themename = $themename['Name'];`, but it would be nice for OP to clarify. – ʰᵈˑ Sep 23 '14 at 20:09
  • I think the PHP upgrade may be enforcing stricter rules. Have you checked the related SO questions? For example http://stackoverflow.com/questions/16264115/warning-illegal-string-offset-in-php-5-4 or http://stackoverflow.com/questions/9869150/illegal-string-offset-warning-php ? – DannyB Sep 23 '14 at 20:14
  • @ʰᵈˑ: makes sense, because that's the only line which contains `Name`. Imo there's some important information missing: Wordpress version, old php version, new php version. – Arjan Sep 23 '14 at 20:14
  • @Arjan I completely agree. – ʰᵈˑ Sep 23 '14 at 20:15

1 Answers1

1

Having a look at the documentation: http://codex.wordpress.org/Function_Reference/get_current_theme it looks like it's not returning an array.

I'd then make the assumption that you don't have the function wp_get_theme. http://codex.wordpress.org/Function_Reference/wp_get_theme

From reading the docs, and your original post, I would change the logic to be;

$themename = get_current_theme();
if(function_exists( 'wp_get_theme' )) {
   $themename = wp_get_theme();
   $themename = $themename->get('Name');
}
ʰᵈˑ
  • 11,279
  • 3
  • 26
  • 49
  • Thanks so much..that removed the error message but I still just get a left hand menu and a blank screen to the right side when in the admin. So I cannot see or change any options. Am learning any direction is appreciated on this or on etiquette posting thx.. ![enter image description here][1] [1]: http://i.stack.imgur.com/2Bt09.png – Thomas Fulmer Sep 24 '14 at 16:41
  • You're welcome :) - Hmm, I'd check your error log and see if there is anything in there, most likely a FATAL error, which is causing the white screen. – ʰᵈˑ Sep 24 '14 at 16:45