Jump to content

WordPress Changing an Array Value in Parent Theme from Child Theme


mengland

Recommended Posts

Hello PHP freaks, I'm new to the forum but am here due to an problem I haven't been able to solve. I am working on something which I believe is a simple problem / solution. I'm still a beginner at PHP and love the language so far. I'm trying to override a value in my WordPress Theme so that it outputs an h3 instead of h5. If anyone would be able to walk me through a solution I'd be really grateful. I'm looking forward to learning from my mistakes on this one.

 

I would like the 'selector' line to read as 'selector' => '.et_pb_toggle.et_pb_toggle_item h3',

/* Source Code from Parent Theme Toggle Found on line 7170*/
et_pb_print_module_styles_css( 'et_pb_toggle', array(
  array(
    'type'         => 'font-size',
    'key'         => 'title_font_size',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item h5',
  ),
  array(
    'type'         => 'font-style',
    'key'         => 'title_font_style',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item.et_pb_toggle_open h5',
  ),
  array(
    'type'         => 'font-style',
    'key'         => 'inactive_title_font_style',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item.et_pb_toggle_close h5',
  ),
  array(
    'type'         => 'font-size',
    'key'         => 'toggle_icon_size',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item .et_pb_toggle_title:before',
  ),
  array(
    'type'         => 'padding',
    'key'         => 'custom_padding',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item',
  ),
) );

Here is what I tried that didn't work and I have a few ideas but am not really sure how to execute them properly. As this code below gave a PHP error.

Fatal error: Call to undefined function et_pb_toggle() in /home/content/p3pnexwpnas05_data01/49/3127149/html/wp-content/themes/Holmes Child Theme/functions.php on line 17

//modifies array for toggle switching h5 => h3
function hms_module_modifier() {
 et_pb_toggle( array(
      'selector' 	=> '.et_pb_toggle.et_pb_toggle_item h3'
    )
  );
}
//Runs module modifier
 hms_module_modifier();
Link to comment
Share on other sites

Look for a call to the function apply_filters() right around this area. The apply_filters() and do_action() functions are how WordPress allows themes and plugin to programmatically override core and extended functionality. If there is an apply_filter() call, I would think it would allow you to change the contents of the array the above function is creating. Of course, without knowing what theme you're using or what the rest of the code around this function looks like, I can't guarantee anything.

Link to comment
Share on other sites

Look for a call to the function apply_filters() right around this area. The apply_filters() and do_action() functions are how WordPress allows themes and plugin to programmatically override core and extended functionality. If there is an apply_filter() call, I would think it would allow you to change the contents of the array the above function is creating. Of course, without knowing what theme you're using or what the rest of the code around this function looks like, I can't guarantee anything.

Thank you for sharing this I'll look into this and see if I can find the filter. I do believe there is a filter being applied in this scenario. I'll report back once I have something to share.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.