Modify php code from plugin

I'd like to modify a plugin's php file that has only a bunch of if/else and echo statements. I can do it by copying the file into the child theme folder and changing the one little thing, but if the theme gets updated, these updates won't get into the copied file, will they?

Here is part of the file:

a class="logout with-icon" href="?php echo wp_logout_url( get_permalinks() ) ?" data-icon="#xf08b;"?php _e('Log out', 'franklin') ?/a

?php elseif ( $crowdfunding_enabled  ! is_user_logged_in() ) : ?

    a class="user-login button with-icon button-alt button-small" href="#" data-reveal-id="login-form" data-icon="#xf007;"?php _e('Login / Register', 'franklin') ?/a

?php endif ?

I want to change

wp_logout_url( get_permalinks() )

to

wp_logout_url( home_url() )

There are no actions or filters in this file to add/remove. I've seen other answers that say to fork the plugin first. But then the forked version doesn't get any updates. Is there any other way to make this small modification?

Update:

The reason I wanted to do this in the first place was to have the user go to the home page after logging out. After some research (an some more learning), I found out that all that was needed was this line in the child-theme's function file:

add_action('wp_logout',create_function('','wp_redirect(home_url());exit();'));

Topic plugins Wordpress

Category Web


Given that there are no filters in the theme that you could manipulate, this is a bit tougher but you can alter the logout URL in general with the logout_url filter:

function hack_logout_url_wpse_193113($logout_url, $redirect) {
  $logout_url = parse_url($logout_url);
  if (!empty($logout_url['query'])) {
    parse_str(html_entity_decode($logout_url['query']),$qry_str);
    $qry_str['redirect_to'] = urlencode(home_url());
  }
  $logout_url['query'] = build_query($qry_str);
  $ret = '';
  foreach ($logout_url as $k=>$v) {
    switch ($k) {
      case 'scheme':
        $ret .= $v.'://';
        break;
      case 'host':
      case 'query':
        $ret .= $v;
        break;
      default :
        $ret .= $v.'/';
    }
  }
  return $ret;
}
add_filter('logout_url','hack_logout_url_wpse_193113',10,2);
echo wp_logout_url(get_permalink());

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.