Support » Plugin: Breadcrumb NavXT » Filter bcn_settings_init problem

  • Resolved mklusak

    (@mklusak)


    Hi, I found a problem with bcn_settings_init filter – I can’t change bcurrent_item_linked option dynamically.

    Use case – I have this option site-wide off / false, but one custom post type need current item linked. No problem, with bcn_settings_init I can change BC settings when needed. Wrong. I have this code in functions.php (without any custom post type conditions etc.):

    
    function custom_bcn_settings_init( $opt ) {
    	
    	$opt['bcurrent_item_linked'] = true;
    		
    	return $opt;
    }
    add_filter( 'bcn_settings_init', 'custom_bcn_settings_init');
    

    Current item in breadcrumbs is not linked. There is probably something wrong with function get_settings() in breadcrumb-navxt.php and line:

    
    $this->breadcrumb_trail->opt = wp_parse_args(get_option('bcn_options'), $this->opt);
    

    $this->opt are default options altered by my filter, and merged with options saved in DB.

    $this->opt[‘bcurrent_item_linked’] is true, saved bcn_options’ bcurrent_item_linked is false, and $this->breadcrumb_trail->opt[‘bcurrent_item_linked’] is false, after all …

    And I am lost. Does this work as intended? Or am I doing it wrong? Is it possible to overwrite admin settings with that filter?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Havlik

    (@mtekk)

    The bcn_settings_init filter is intended for providing good/safe default values for settings in the plugin. This can be for existing settings, or for extension plugins to Breadcrumb NavXT that have options (the primary user of this filter). If you want to dynamically change a setting, you’re better off using the bcn_before_fill action and modifying the specific option when appropriate (e.g. when on a page for that CPT).

    Thread Starter mklusak

    (@mklusak)

    Hm, I see. Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter bcn_settings_init problem’ is closed to new replies.