## Change the variable value in an other plugin function with PHP

Question

I try to change a class, which is stored in a variable without making any changes in the plugin file. I’m not sure how to target the variable inside the function.

This is the function: function learndash_mark_complete( $post,$atts = array() ) { Inside this function, there is a variable called $button_class. if ( isset($atts['button']['class'] ) ) {
$button_class = ' class="learndash_mark_complete_button ' . esc_attr($atts['button']['class'] ) . '" ';
} else {
$button_class = ' class="learndash_mark_complete_button" '; }  Is there a simple way to change the code to.. if ( isset($atts['button']['class'] ) ) {
$button_class = ' class="myclass' . esc_attr($atts['button']['class'] ) . '" ';
} else {
\$button_class = ' class="myclass" ';
}


without change the plugin file. Maybe to create a function in functions.php or in a seperate (new) plugin?

I saw articles on the internet about add_filter, but I’m not sure how to target the part I need without wipe the whole function.

I know I could change the class with jQuery or something, and maybe it should be a lot easier, but I like to learn new things.

0
2 years 2020-09-04T08:10:25-05:00 0 Answers 68 views 0