{"action":"closed","issue":{"url":"https://api.github.com/repos/cferdinandi/smooth-scroll/issues/206","labels_url":"https://api.github.com/repos/cferdinandi/smooth-scroll/issues/206/labels{/name}","comments_url":"https://api.github.com/repos/cferdinandi/smooth-scroll/issues/206/comments","events_url":"https://api.github.com/repos/cferdinandi/smooth-scroll/issues/206/events","html_url":"https://github.com/cferdinandi/smooth-scroll/issues/206","id":124480610,"number":206,"title":"Advanced WordPress menu filter allows cross-page navigation","user":{"login":"lkraav","id":147228,"avatar_url":"https://avatars.githubusercontent.com/u/147228?v=3","gravatar_id":"","url":"https://api.github.com/users/lkraav","html_url":"https://github.com/lkraav","followers_url":"https://api.github.com/users/lkraav/followers","following_url":"https://api.github.com/users/lkraav/following{/other_user}","gists_url":"https://api.github.com/users/lkraav/gists{/gist_id}","starred_url":"https://api.github.com/users/lkraav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lkraav/subscriptions","organizations_url":"https://api.github.com/users/lkraav/orgs","repos_url":"https://api.github.com/users/lkraav/repos","events_url":"https://api.github.com/users/lkraav/events{/privacy}","received_events_url":"https://api.github.com/users/lkraav/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-31T15:34:28Z","updated_at":"2016-01-05T20:12:00Z","closed_at":"2016-01-05T20:12:00Z","body":"Follow up for #94. This should perhaps be a pull request on README.md. Let me know.\r\n\r\nThis will check whether the navigation menu links have been configured with any `#` anchors and if they point to the current page or somewhere else. All outbound links must avoid `data-scroll` attribute.\r\n\r\n```php\r\nadd_filter( \"nav_menu_link_attributes\", function( $atts ) {\r\n\r\n    if ( isset( $_SERVER[\"REQUEST_URI\"] ) && $_SERVER[\"REQUEST_URI\"] ) {\r\n\r\n        if ( isset( $atts[\"href\"] ) && false !== strpos( $atts[\"href\"], $_SERVER[\"REQUEST_URI\"] . \"#\" ) ) {\r\n\r\n            $atts[\"data-scroll\"] = \"true\";\r\n\r\n        }\r\n\r\n    }\r\n\r\n    return $atts;\r\n\r\n} );\r\n```\r\n\r\nUse `if ( isset( $_SERVER[\"REQUEST_URI\"] ) && $REQUEST_URI = sanitize_text_field( wp_unslash( $_SERVER[\"REQUEST_URI\"] ) ) ) {}` if you want to pass WordPress Coding Standards  (0.8.0) compliance."}}