Error Illegal String Offset
-
Theme: 2012 updated
Trying my hand at making a plugin and am running into this warning message. I understand I can turn the warnings off but I am interested in knowing what is causing it and why.
I’ve included all lines of code from 1-85. I’ve tried switching themes and the warning still appeared. Any help or pointers would be great!Warning message:
Warning: Illegal string offset ‘currency_sign’ in /Applications/XAMPP/xamppfiles/apps/wordpress/htdocs/wp-content/plugins/School Store Plugin/Store-plugin.php on line 85
The Code
<?php /* Plugin Name: School Store Plugin-in Plugin URI: patcosta.com Description: A school store plugin for educational institutions Version: 1.0 Author: Pat Costa Author URI: patcosta.com Text Domain: school-store */ register_activation_hook (__FILE__ , 'school_store_install' ); function school_store_install() { //set-up options values $ss_options_arr= array ( 'currency_sign' => '$' ); //save default options update_option ('school_options', $ss_options_arr); } //Action hook to initalize plugin add_action('init', 'school_store_init'); function school_store_init() { //register products in custom post type $labels = array( 'name' => __( 'Products', 'halloween-plugin' ), 'singular_name' => __( 'Product', 'school-plugin' ), 'add_new' => __( 'Add New', 'school-plugin' ), 'add_new_item' => __( 'Add New Product', 'school-plugin' ), 'edit_item' => __( 'Edit Product', 'school-plugin' ), 'new_item' => __( 'New Product', 'school-plugin' ), 'all_items' => __( 'All Products', 'school-plugin' ), 'view_item' => __( 'View Product', 'school-plugin' ), 'search_items' => __( 'Search Products', 'school-plugin' ), 'not_found' => __( 'No products found', 'school-plugin' ), 'not_found_in_trash' => __( 'No products found in Trash', 'school-plugin' ), 'menu_name' => __( 'Products', 'school-plugin' ) ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ) ); register_post_type('school-products', $args); } //action hook to add the post product menu item in the admin dashboard add_action('admin_menu','school_store_menu'); //create submenu item function school_store_menu() { add_options_page (__('School Store Settings Page', 'school-plugin'), __('School Store Settings', 'school-plugin'), 'manage_options', 'school-store-settings', 'school_store_settings_page'); } //build plugin settings page function school_store_settings_page() { //load the plugin array option $ss_options_arr = get_option ('school_options'); //set the option array values to variables $ss_inventory = ( ! empty( $ss_options_arr['show_inventory'] ) ) ? $ss_options_arr['show_inventory'] : ''; $ss_currency_sign = $ss_options_arr [ 'currency_sign' ]; //line 85 ?>
- The topic ‘Error Illegal String Offset’ is closed to new replies.