How to use add_filter to change a text string in php? (to change "Order Woocommerce" in learnpress profile)

105 views Asked by At
  • My data: I want to change a text without manipulating the main code in PHP for a WordPress site. (WordPress theme: "Eduma") (Plugins: "LearnPress", "Woocommerce") (Add-on: "WooCommerce for LearnPress")

  • The main code in the theme (class-lp-wc-hooks.php):

public function profile_tabs_woo_order( $tabs ) {
        $tabs['lp_orders_woocommerce'] = array(
            'title'    => esc_html__( 'Order Woocommerce', 'learnpress-woo-payment' ),
            'slug'     => 'orders_woocommerce',
            'callback' => array( $this, 'profile_tabs_woo_order_content' ),
            'priority' => 25,
            'icon'     => '<i class="fas fa-shopping-cart" aria-hidden="true"></i>',
        );

        return $tabs;
    }
  • The code I wrote (and it didn't work):
    add_filter( 'lp_orders_woocommerce', 'change_woocommerce_order_text', 10, 2 );
function change_woocommerce_order_text( $title, $tab_id ) {
    if ( $tab_id === 'orders_woocommerce' ) {
        $new_title = 'New Order Title';
        $title = esc_html__( $new_title, 'learnpress-woo-payment' );
    }
    return $title;
}
  • My request: I would be grateful if anybody could check my code and see where I went wrong.

I put my final code in the theme-editor menu of the eduma child theme in the "functions.php" file and it doesn't work.

0

There are 0 answers