0
  • 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.

Mostafa Arian Nejad
  • 1,278
  • 1
  • 19
  • 32
AliZereh
  • 1
  • 2
  • Hello and welcome to stackoverflow, i guess we can't really help you with that little piece of code. Based on what you posted there is no filter named 'lp_orders_woocommerce' so your code in functions.php either does nothing because the filter doesn't exist or we miss something from the post to understand what is going on. Please update your question with more details – Diego Aug 23 '23 at 10:34
  • 1
    Hi Diego, after 7 hours of trying I found that my main problem is finding $hook_name Because the logic of using "add_filter" is correct. In the end, I was able to change the desired text with another method. I will put it. Thank you in advance for your good energy. – AliZereh Aug 23 '23 at 11:09

0 Answers0