Skip to:
Content
Pages
Categories
Search
Top
Bottom

override ajax and js files in bp-default theme

  • Avatar of tifire
    tifire
    Participant

    @tifire

    I know the bp-default theme can be overridden in child theme by copying the same folders and files to the child theme directory. I tried to do this for two files:
    bp-default/_inc/ajax.php
    bp-default/_inc/global.js

    but it doesn’t seem to work. The changes I made in the child theme doesn’t seem to work at all.

    Can someone help? Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Avatar of Mr Brainz
    Mr Brainz
    Member

    @mr-brainz

    The way I did it was to re-register the JS in the child functions.php file

    `wp_deregister_script( ‘dtheme-ajax-js’);
    wp_enqueue_script( ‘dtheme-ajax-js’, get_bloginfo(‘stylesheet_directory’) . ‘/_inc/global.js’, array( ‘jquery’ ), $version );`

    Avatar of tifire
    tifire
    Participant

    @tifire

    thanks for the kind response. that makes sense. I will try your way.

    Avatar of tifire
    tifire
    Participant

    @tifire

    Mr Brainz, i have just tested it. It works! Thanks again.

    Do you happen to know how to override bp-default/_inc/ajax.php in child theme?

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    It’s not recommended to override /_inc/ajax.php, is there a specific reason why you’d want to do that? There are hooks in /_inc/ajax.php that you can use to add functionality.

    If you need to override both ajax.php and the JS, you might as well create your own parent theme instead of creating a child theme of bp-default.

    Avatar of tifire
    tifire
    Participant

    @tifire

    hi ray, thanks for the post. I tried to use hooks in /_inc/ajax.php, but it didn’t seem to work in my case. Here is what I would like to achieve:
    When an activity post is DELETED, an image will be automatically updated right below the group admin avatar.

    I added some code in /_inc/ajax.php, pass on the new image url by json. In /_inc/global.js, when the “delete_activity” action is fired, the new image url is returned as response. Then show the new image. The code at /_inc/global.js is like: jq(‘#myimage’).attr(“src”, new_image_url);

    If it is not recommended to override /_inc/ajax.php, is there a better way to do so? Thanks again.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.