• Resolved UgoDimma

    (@lovecoinz)


    I want to designed some pages using siteorign page buildier, and want to add the contents of that page to the woocommerce My Account menus using the bellow code, but the short code generated with this plugin makes the snippet not to work.

    // ------------------
    // 1. Register new endpoint to use for My Account page
    // Note: Resave Permalinks or it will give 404 error
     
    function bbloomer_add_testing_endpoint() {
        add_rewrite_endpoint( 'testing', EP_ROOT | EP_PAGES );
    }
     
    add_action( 'init', 'bbloomer_add_testing_endpoint' );
     
     
    // ------------------
    // 2. Add new query var
     
    function bbloomer_testing_query_vars( $vars ) {
        $vars[] = 'testing';
        return $vars;
    }
     
    add_filter( 'query_vars', 'bbloomer_testing_query_vars', 0 );
     
     
    // ------------------
    // 3. Insert the new endpoint into the My Account menu
     
    function bbloomer_add_testing_link_my_account( $items ) {
    // Remove the logout menu item.
    		$logout = $items['customer-logout'];
    		unset( $items['customer-logout'] );
        $items['testing'] = 'testing';
    // Insert back the logout item.
    		$items['customer-logout'] = $logout;
        return $items;
    }
     
    add_filter( 'woocommerce_account_menu_items', 'bbloomer_add_testing_link_my_account' );
     
     
    // ------------------
    // 4. Add content to the new endpoint
     
    function bbloomer_testing_content() {
    echo '<h3>Two Factor Athentication</h3><p>Two factor authenticator is an advanvced security for your account. This protects your account from un-authorized access, even when your <strong>username</strong> and <strong>password</strong> has been compromized.</p><p>To learn how this feature work, and how to enable it successfully on your account, visit <a href="#">How to Enable 2 Factor Athenticator</a>';
    echo do_shortcode( ' [insert page='1201' display='content'] ' );
    }
     
    add_action( 'woocommerce_account_testing_endpoint', 'bbloomer_testing_content' );

    When I removed the short code generated with this plugin, and replaces it with either affiliatewp code[affiliates_area], or woocommerce single product short code [product_page id="1724"], it works fine as expected.

    How can I make the code generated with this plugin work with the above snippet in my theme functions.php?

Viewing 1 replies (of 1 total)
  • Thread Starter UgoDimma

    (@lovecoinz)

    I got it now working.

    The code generated by this plugin uses single invited comma. Using it like that in theme function.php file or any other file by calling it using do_shortcode does not work. So, I have to manually change the single invited comma(‘) to double invited comma(“) and use it as I want.

    In that case, instead of having [insert page='1201' display='content'] and now have [insert page="1201" display="content"].

Viewing 1 replies (of 1 total)
  • The topic ‘Code not workin with snippets in theme functions.php’ is closed to new replies.