最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - How to change href of a Widget menu item link?

programmeradmin1浏览0评论

I assume that using a filter would be the best way to do this, but I am not so familiar with php code so I require someones masterful input please!

Here is the widgets menu:

This widget comes with the theme that I am using, which does not allow me to manually edit the links. I would like to overwrite the destination of these menu items with a custom link.

If it is at all useful, the widget is called: Thim-login, and the list of items are contained within this class: .widget.widget_thim-login

Here is also some sample html of the widget:

<div class="widget widget_thim-login"><a href="LINK" class="user-name"><span class="author"></span><img alt="" src="GRAVATAR-LINK" srcset="GRAVATAR-LINK" class="avatar avatar-45 photo" height="45" width="45"></a><ul class="user-info"><li class="menu-item menu-item-courses"><a href="LINK">My Courses</a></li></ul></div>

Many thanks! - D

EDIT: Perhaps I can adapt this code to also over-ride the links? ...

    add_filter( 'thim_header_user_dropdown_content', 'handle_menu_dropdown_profile' );
if ( ! function_exists( 'handle_menu_dropdown_profile' ) ) {
    function handle_menu_dropdown_profile( $dropdown_content_args ) {
        if ( isset( $dropdown_content_args['become_a_teacher'] ) ) {
            /*$dropdown_content_args = array(
                'become_a_teacher' => esc_html__( 'Become An Instructor', 'course-builder' ),
                'courses'          => esc_html__( 'My Courses', 'course-builder' ),
                'orders'           => esc_html__( 'My Orders', 'course-builder' ),
                'certificates'     => esc_html__( 'My Certificates', 'course-builder' ),
                'settings'         => esc_html__( 'Edit Profile', 'course-builder' ),
            );*/
            $dropdown_content_args['settings'] = esc_attr__( 'My Profile', 'course-builder' );

            return $dropdown_content_args;
        }
    }
}
发布评论

评论列表(0)

  1. 暂无评论