1

I would like to change the rendering of specific part of a plugin from a childe theme, so that I wont loose my changes after plugin updates. Well the plugin start by doing this:

add_action( 'plugins_loaded', 'bptodo_plugin_init' );

function bptodo_plugin_init() {
if ( is_multisite() ) {
    // Makes sure the plugin is defined before trying to use it.
    if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
        require_once ABSPATH . '/wp-admin/includes/plugin.php';
    }
    if ( is_plugin_active_for_network( 'buddypress/bp-loader.php' ) === false ) {
        add_action( 'network_admin_notices', 'bptodo_network_plugin_admin_notice' );
    } else {
        run_wp_bptodo_list();
        add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'bptodo_admin_page_link' );
        add_action( 'bp_include', 'bptodo_create_profile_menu' );
    }
} else {
    $bp_active = in_array( 'buddypress/bp-loader.php', get_option( 'active_plugins' ) );
    if ( current_user_can( 'activate_plugins' ) && true != $bp_active ) {
        add_action( 'admin_notices', 'bptodo_plugin_admin_notice' );
    } else {
        run_wp_bptodo_list();
        add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'bptodo_admin_page_link' );
        add_action( 'bp_include', 'bptodo_create_profile_menu' );
    }
}
}

The function run_wp_bptodo_list:

function run_wp_bptodo_list() {
$include_files = array(
    'inc/class-bptodo-scripts.php',
    'inc/class-bptodo-ajax.php',
    'inc/class-bptodo-cpt.php',
    'inc/class-bptodo-globals.php',
    'inc/class-bptodo-hooks.php',
    'admin/wbcom/wbcom-admin-settings.php',
    'admin/class-bptodo-admin.php',
);
foreach ( $include_files  as $include_file ) {
    include $include_file;
}

// Initialize admin class.
new Bptodo_Admin();

// Initialize globals class.
global $bptodo;
$bptodo = new Bptodo_Globals();
}

Under the file: inc/class-bptodo-hooks.php there is this code:

class Bptodo_Hooks {

    /**
     * Constructor.
     *
     * @since    1.0.0
     * @access   public
     * @author   Wbcom Designs
     */
    public function __construct() {
        add_action( 'init', array( $this, 'bptodo_manage_todo_due_date' ) );
        add_action( 'bp_member_header_actions', array( $this, 'bptodo_add_review_button_on_member_header' ) );
        add_action( 'bp_setup_admin_bar', array( $this, 'bptodo_setup_admin_bar' ), 80 );
        add_filter( 'manage_bp-todo_posts_columns', array( $this, 'bptodo_due_date_column_heading' ), 10 );
        add_action( 'manage_bp-todo_posts_custom_column', array( $this, 'bptodo_due_date_column_content' ), 10, 2 );
        add_filter( 'bp_notifications_get_registered_components', array( $this, 'bptodo_due_date_notifications_component' ) );
        add_filter( 'bp_notifications_get_notifications_for_user', array( $this, 'bptodo_format_due_date_notifications' ), 10, 5 );
        add_shortcode( 'bptodo_by_category', array( $this, 'bptodo_by_categpry_template' ) );
    }

A closer look to add_shortcode 'bptodo_by_category', array( $this, 'bptodo_by_categpry_template':

public function bptodo_by_categpry_template( $atts ) {
        if ( is_user_logged_in() ) {
            $shortcode_template = BPTODO_PLUGIN_PATH . 'inc/todo/bptodo-by-category-template.php';
            if ( file_exists( $shortcode_template ) ) {
                include_once $shortcode_template;
            }
        } else {
            $shortcode_template_loggedout_user = BPTODO_PLUGIN_PATH . 'inc/todo/bptodo-by-category-template-loggedout-user.php';
            if ( file_exists( $shortcode_template_loggedout_user ) ) {
                include_once $shortcode_template_loggedout_user;
            }
        }
    }

And finaly that's the file that I want to change bptodo-by-category-template-loggedout-user.php

Please what is the procedure to make change on the bptodo-by-category-template-loggedout-user.php file

  • 1
    you just need to redefine the shortcode then start by delete the shortcode of this plugin with remove_shortcode("bptodo_by_category"); – Kaperto Nov 22 '19 at 21:23
  • Please more explaination ... – Chaouki Nov 23 '19 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.