Snippet not activated due to syntax error
-
Hi,
I had been using Code Snippets plugin for codes. Few days back, I tried this plugin and imported all snippets from the former plugin. However, out of 7 snippets, one code snippet is giving me this error “Snippet not activated, the following error was encountered: syntax error, unexpected token “&”
This is the php codefunction blogger_query_vars_filter( $vars ) { $vars[] = "blogger"; return $vars; } add_filter('query_vars', 'blogger_query_vars_filter'); function blogger_template_redirect() { global $wp_query; $blogger = $wp_query->query_vars['blogger']; if ( isset ( $blogger ) ) { wp_redirect( get_wordpress_url ( $blogger ) , 301 ); exit; } } add_action( 'template_redirect', 'blogger_template_redirect' ); function get_wordpress_url($blogger) { if ( preg_match('@^(?:https?://)?([^/]+)(.*)@i', $blogger, $url_parts) ) { $query = new WP_Query ( array ( "meta_key" => "blogger_permalink", "meta_value" => $url_parts[2] ) ); if ($query->have_posts()) { $query->the_post(); $url = get_permalink(); } wp_reset_postdata(); } return $url ? $url : home_url(); }
Code snippets plugin was working fine with this snippet. I have checked this code on few online code checkers and all said the code is fine. But only this plugin shows the error and snippet is not activated.
Please suggest.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Snippet not activated due to syntax error’ is closed to new replies.