• Resolved legentlemanfr

    (@legentlemanfr)


    Hi Greg,

    I have some problem in using ‘My Ads’ Panel Slug with WooCommerce Payments add-on.
    I have changed the endpoint name to “Mes annonces” (in french) and save the configuration. It works well but for an unknown reason, the endpoint returns a 404 page after a certain time. The problem is still there whatever the language.

    Of course, I have saved the permalinks under WP settings.

    Do you have an idea of the origin of this problem ?

    Kind regards. Antoine

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    hmm does the endpoint redirect to 404 page after some time if you leave the default value?

    Also, do you have some other plugins installed on site? From your description, it looks like there is some other plugin which resets the WP router, but it is doing it in a way which does not allow WPAdverts to register its own endpoint. You can tr disabling the plugin one by one and see if it helps.

    One other thing you can try is open the file wpadverts-wc/wpadverts-wc.php and modify the function adext_wc_payments_init_wc() to look like this

    
    function adext_wc_payments_init_wc() {
    
        if( !class_exists( 'WooCommerce' ) || !defined( 'ADVERTS_PATH' ) ) {
            return;
        }
        
        if( adverts_config( 'wc_payments.show_manage_adverts' ) != 0 ) {
            include_once plugin_dir_path( __FILE__ ) . "/includes/class-adverts-wc-user-panel.php";
            $wpadverts_wc_user_panel = new Adverts_WC_User_Panel();
        }
        
        if( adverts_config( 'wc_payments.my_packages_show' ) != 0 ) {
            include_once plugin_dir_path( __FILE__ ) . "/includes/class-adverts-wc-user-packages.php";
            $wpadverts_wc_user_panel = new Adverts_WC_User_Packages();
        }
    }
    

    The function starts on line about 229.

    Thread Starter legentlemanfr

    (@legentlemanfr)

    Hi Greg,

    Thank you for your support.
    I have executed both methods without any positive effect (sorry).
    A majority of my plugins reset my wpadvert’s endpoint.
    Hence, I tried the second suggested method. The modification proposed is already present in wpadverts-wc.php file.

    After reading the document about rewriting endpoints, I have found a declaration missing in your wpadvert-wc plugin. All plugins flush the rewriting rules during activation. Why not yours ?
    I have add the following line in wpadverts-wc.php file into adext_wc_payments_activate function.

    $endpoint = adverts_config( ‘wc_payments.user_panel_endpoint’ );
    add_rewrite_endpoint( __($endpoint,’adverts’), EP_ROOT | EP_PAGES );
    flush_rewrite_rules();

    Since this modification, the endpoint rewriting is working as expected.
    Hope this may help.

    Best regards.

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, thanks for the feedback, i will test this code and include it in the next WPAdverts WC release.

    One note i think the second line should be

    
    add_rewrite_endpoint( $endpoint, EP_ROOT | EP_PAGES );
    

    as the $endpoint is not a phrase for translation.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘My ads endpoint’ is closed to new replies.