REQUIRED: Found add_meta_boxes in the file inc/cs-framework/classes/metabox.class.php.

wordpress

#1

When I am checking my theme using Envato theme check plugin, then it’s showing that issue. I didn’t see this error before two months ago for developing another theme.
Please help how to overcome that or good suggestion?


#2

It’s Codestar framework, I suppose. Do not include the framework files under the theme files but instead use TMGA to load the framework as a plugin


#3

I have tried that, there showing an error when trying to see live preview of the theme before plugin activation.
i.e. Fatal error: Uncaught Error: Call to undefined function cs_get_option()

thanks


#4

Create a function in your theme for getting options. Let’s call it theme_get_option
In this function, check if plugin is activated, if so, call cs_get_option, if it’s not, return a default value for this option. You can store default option values as an array.

pseude-code:

function theme_get_option($optionName)
{
    if( ...is plugin activated ) {
         return plugin_get_option($optionName);
    } else {
        return OptionDefaults::getOption($optionName);
    }
}

/**
 * Option defaults storage.
 */
class OptionDefaults
{
    $defaults=  [
        'logo_ttile' => 'Awesome theme',
    ];

   public static function getOption($optioName) {
       return self::$defaults[ $optionName ];
   }
}

/**
 * You can also use this class when registering options, for default values.
 * Pseudo-example:
 */

...
array(
   'type' => 'input',
  'name' => 'logo_title'
  'default_value' => OptionDefaults::getOption('logo_title')
   // This way you can make sure that your default values forthis option will be the same regardless if  plugin is activated or not activated.
),