• I am working on a plugin function that has the configuration array in this format:

    protected function get_configuration() {
     $configuration = array(
        ....
        ....
        'dimensions'  => (object) array(
          'width' => 780,
          'height' => 500
        )
      );
    
      return apply_filters('pluginname_configuration', $configuration);
    }

    I would like to override the default values of width and height in functions.php. I tried using add_filter() function and defining my own function but it doesn’t look this this is the right way to do it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • wrlp

    You can add this code in your functions.php, this should work.

    add_filter('pluginname_configuration', 'my_custom_config');
    
    function my_custom_config($config) {
        $config['dimensions'] = (object) array(
                    'width' => 780, //Your Custom Width
                    'height' => 500 //Your Custom Height
        );
        return $config;
    }

    protected function get_configuration() {

    Does that work on a protected function or will the OP need to access a public function to include a filter?

    Pioneer Web Design

    Yes that will work on protected function as well, since that function is asking for the filter to run.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to override the settings array on the plugin?’ is closed to new replies.