HTML Link tag not working in this code

Hi,

I wanted to have this in dashboard under custom widget. Everything works fine. But when I try to add link inside the accordion, it is not working after clicking. But if I try open it in New tab, the link works.
Please take a look and help me. The html code is below,

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Smooth Responsive Accordion Widget</title>
<link href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css" rel="stylesheet" type="text/css">
<style>
* {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

body { font-family: 'Lato'; }

h1 {
  font-size: 2em;
  padding: 2em;
  text-align: center;
}

.accordion dl { border: 1px solid #ddd; }

.accordion dl:after {
  content: "";
  display: block;
  height: 1em;
  width: 100%;
  background-color: #c0392b;
}

.accordion dt > a {
  text-align: center;
  font-weight: 700;
  padding: 2em;
  display: block;
  text-decoration: none;
  color: #fff;
  -webkit-transition: background-color 0.5s ease-in-out;
  -moz-transition: background-color 0.5s ease-in-out;
  transition: background-color 0.5s ease-in-out;
}

.accordion dd {
  background-color: #eee;
  font-size: 1em;
  line-height: 1.5em;
}

.accordion dd > p {
  padding: 1em 2em 1em 2em;
  margin: 0;
}

.accordion {
  position: relative;
  background-color: #eee;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2em 0 2em 0;
}

.accordionTitle {
  background-color: #e74c3c;
  border-bottom: 1px solid #c0392b;
}

.accordionTitle:before {
  content: "+";
  font-size: 1.5em;
  line-height: 0.5em;
  float: left;
  -moz-transition: -moz-transform 0.3s ease-in-out;
  -o-transition: -o-transform 0.3s ease-in-out;
  -webkit-transition: -webkit-transform 0.3s ease-in-out;
  transition: transform 0.3s ease-in-out;
}

.accordionTitle:hover { background-color: #c0392b; }

.accordionTitleActive { background-color: #c0392b; }

.accordionTitleActive:before {
  -webkit-transform: rotate(-225deg);
  -moz-transform: rotate(-225deg);
  transform: rotate(-225deg);
}

.accordionItem {
  height: auto;
  overflow: hidden;
}
@media all {

.accordionItem {
  max-height: 50em;
  -moz-transition: max-height 1s;
  -o-transition: max-height 1s;
  -webkit-transition: max-height 1s;
  transition: max-height 1s;
}
}
@media screen and (min-width: 48em) {

.accordionItem {
  max-height: 15em;
  -moz-transition: max-height 0.5s;
  -o-transition: max-height 0.5s;
  -webkit-transition: max-height 0.5s;
  transition: max-height 0.5s;
}
}

.accordionItemCollapsed { max-height: 0; }

.animateIn {
  -webkit-animation-name: accordionIn;
  -webkit-animation-duration: 0.65s;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-direction: normal;
  -webkit-animation-timing-function: ease-in-out;
  -webkit-animation-fill-mode: both;
  -webkit-animation-delay: 0s;
  -moz-animation-name: normal;
  -moz-animation-duration: 0.65s;
  -moz-animation-iteration-count: 1;
  -moz-animation-direction: alternate;
  -moz-animation-timing-function: ease-in-out;
  -moz-animation-fill-mode: both;
  -moz-animation-delay: 0s;
  animation-name: accordionIn;
  animation-duration: 0.65s;
  animation-iteration-count: 1;
  animation-direction: normal;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
  animation-delay: 0s;
}

.animateOut {
  -webkit-animation-name: accordionOut;
  -webkit-animation-duration: 0.75s;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-direction: alternate;
  -webkit-animation-timing-function: ease-in-out;
  -webkit-animation-fill-mode: both;
  -webkit-animation-delay: 0s;
  -moz-animation-name: accordionOut;
  -moz-animation-duration: 0.75s;
  -moz-animation-iteration-count: 1;
  -moz-animation-direction: alternate;
  -moz-animation-timing-function: ease-in-out;
  -moz-animation-fill-mode: both;
  -moz-animation-delay: 0s;
  animation-name: accordionOut;
  animation-duration: 0.75s;
  animation-iteration-count: 1;
  animation-direction: alternate;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
  animation-delay: 0s;
}
 @-webkit-keyframes
accordionIn {  0% {
 opacity: 0;
 -webkit-transform: scale(0.8);
}
 100% {
 opacity: 1;
 -webkit-transform: scale(1);
}
}
@-moz-keyframes
accordionIn {  0% {
 opacity: 0;
 -moz-transform: scale(0.8);
}
 100% {
 opacity: 1;
 -moz-transform: scale(1);
}
}
@keyframes
accordionIn {  0% {
 opacity: 0;
 transform: scale(0.8);
}
 100% {
 opacity: 1;
 transform: scale(1);
}
}
@-webkit-keyframes
accordionOut {  0% {
 opacity: 1;
 -webkit-transform: scale(1);
}
 100% {
 opacity: 0;
 -webkit-transform: scale(0.8);
}
}
@-moz-keyframes
accordionOut {  0% {
 opacity: 1;
 -moz-transform: scale(1);
}
 100% {
 opacity: 0;
 -moz-transform: scale(0.8);
}
}
@keyframes
accordionOut {  0% {
 opacity: 1;
 transform: scale(1);
}
 100% {
 opacity: 0;
 transform: scale(0.8);
}
}
</style>
</head>

<body>
<div class="container">
  <h1>Smooth Responsive Accordion Widget</h1>
  <div class="css-script-ads" align="center"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2783044520727903";
/* CSSScript Demo Page */
google_ad_slot = "3025259193";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
      <script type="text/javascript"
src="//pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
  <div class="accordion">
    <dl>
      <dt><a class="accordionTitle" href="#">First Accordion heading</a></dt>
      <dd class="accordionItem accordionItemCollapsed">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris. </p>
        <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p>
      </dd>
      <dt><a href="#" class="accordionTitle">Second Accordion heading</a></dt>
      <dd class="accordionItem accordionItemCollapsed">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris. </p>
        <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p>
      </dd>
      <dt><a href="#" class="accordionTitle">Third Accordion heading</a></dt>
      <dd class="accordionItem accordionItemCollapsed">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris. </p>
        <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p>
      </dd>
    </dl>
  </div>
</div>
<script>
/*!
 * classie - class helper functions
 * from bonzo https://github.com/ded/bonzo
 *
 * classie.has( elem, 'my-class' ) -> true/false
 * classie.add( elem, 'my-new-class' )
 * classie.remove( elem, 'my-unwanted-class' )
 * classie.toggle( elem, 'my-class' )
 */

/*jshint browser: true, strict: true, undef: true */
/*global define: false */

( function( window ) {

'use strict';

// class helper functions from bonzo https://github.com/ded/bonzo

function classReg( className ) {
  return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
}

// classList support for class management
// altho to be fair, the api sucks because it won't accept multiple classes at once
var hasClass, addClass, removeClass;

if ( 'classList' in document.documentElement ) {
  hasClass = function( elem, c ) {
    return elem.classList.contains( c );
  };
  addClass = function( elem, c ) {
    elem.classList.add( c );
  };
  removeClass = function( elem, c ) {
    elem.classList.remove( c );
  };
}
else {
  hasClass = function( elem, c ) {
    return classReg( c ).test( elem.className );
  };
  addClass = function( elem, c ) {
    if ( !hasClass( elem, c ) ) {
      elem.className = elem.className + ' ' + c;
    }
  };
  removeClass = function( elem, c ) {
    elem.className = elem.className.replace( classReg( c ), ' ' );
  };
}

function toggleClass( elem, c ) {
  var fn = hasClass( elem, c ) ? removeClass : addClass;
  fn( elem, c );
}

var classie = {
  // full names
  hasClass: hasClass,
  addClass: addClass,
  removeClass: removeClass,
  toggleClass: toggleClass,
  // short names
  has: hasClass,
  add: addClass,
  remove: removeClass,
  toggle: toggleClass
};

// transport
if ( typeof define === 'function' && define.amd ) {
  // AMD
  define( classie );
} else {
  // browser global
  window.classie = classie;
}

})( window );

//fake jQuery
var $ = function(selector){
  return document.querySelector(selector);
}
var accordion = $('.accordion');

//add event listener to all anchor tags with accordion title class
accordion.addEventListener("click",function(e) {
  e.stopPropagation();
  e.preventDefault();
  if(e.target && e.target.nodeName == "A") {
    var classes = e.target.className.split(" ");
    if(classes) {
      for(var x = 0; x < classes.length; x++) {
        if(classes[x] == "accordionTitle") {
          var title = e.target;

          //next element sibling needs to be tested in IE8+ for any crashing problems
          var content = e.target.parentNode.nextElementSibling;

          //use classie to then toggle the active class which will then open and close the accordion

          classie.toggle(title, 'accordionTitleActive');
          //this is just here to allow a custom animation to treat the content
          if(classie.has(content, 'accordionItemCollapsed')) {
            if(classie.has(content, 'animateOut')){
              classie.remove(content, 'animateOut');
            }
            classie.add(content, 'animateIn');

          }else{
             classie.remove(content, 'animateIn');
             classie.add(content, 'animateOut');
          }
          //remove or add the collapsed state
          classie.toggle(content, 'accordionItemCollapsed');

        }
      }
    }

  }
});
</script>
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-46156385-1', 'cssscript.com');
  ga('send', 'pageview');

</script>
</body>
</html>
  • CatMan

    Hi,

    Yup it works now. But when I use the same code inside custom widget it is not working. I will paste the code below of my custom-welcome-panel.php

    <?php
    /*
    Plugin Name: Custom Welcome Panel
    Plugin URI: _
    Description: Replaces the default WordPress Welcome panel with a custom one on the dashboard of all sites in a network
    Author: _
    Version: 1.0
    Author URI: _
    */
    
    function rc_my_welcome_panel() {
    
    	?>
    <script type="text/javascript">
    /* Hide default welcome message */
    jQuery(document).ready( function($)
    {
    	$('div.welcome-panel-content').hide();
    });
    </script>
    
    	<div class="custom-welcome-panel-content">
    	<!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Get Started With 4 Simple Steps</title>
    <link href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css" rel="stylesheet" type="text/css">
    <style>
    * {
      -moz-box-sizing: border-box;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
    }
    
    body { font-family: 'Special Elite'; }
    
    h1 {
      font-size: 2em;
      padding: 2em;
      text-align: center;
    }
    
    .accordion dl { border: 20px solid #FFF; }
    
    .accordion dl:after {
      content: "Click Dismiss Icon found at top right corner to hide Getting Started Steps";
      display: block;
      height: 2em;
      width: 100%;
      background-color: #FFF;
    }
    
    .accordion dt > a {
      text-align: center;
      font-weight: 900;
      padding: 0.7em;
      display: block;
      text-decoration: none;
       font-size: 16px;
       color: #fff;
      -webkit-transition: background-color 0.5s ease-in-out;
      -moz-transition: background-color 0.5s ease-in-out;
      transition: background-color 0.5s ease-in-out;
    }
    
    .accordion dd {
      background-color: #eee;
      font-size: 1em;
      line-height: 1.5em;
    }
    
    .accordion dd > p {
      padding: 1em 2em 1em 2em;
      margin: 0;
    }
    
    .accordion {
      position: relative;
      background-color: #eee;
    }
    
    .container {
      max-width: 960px;
      margin: 0 auto;
      padding: 2em 0 2em 0;
    }
    
    .accordionTitle {
      background-color: #e74c3c;
      border-bottom: 1px solid #c0392b;
    }
    
    .accordionTitle:before {
      content: "+";
      font-size: 1.5em;
      line-height: 0.5em;
      float: left;
      -moz-transition: -moz-transform 0.3s ease-in-out;
      -o-transition: -o-transform 0.3s ease-in-out;
      -webkit-transition: -webkit-transform 0.3s ease-in-out;
      transition: transform 0.3s ease-in-out;
    }
    
    .accordionTitle:hover { background-color: #008900; }
    
    .accordionTitleActive { background-color: #008900; }
    
    .accordionTitleActive:before {
      -webkit-transform: rotate(-225deg);
      -moz-transform: rotate(-225deg);
      transform: rotate(-225deg);
    }
    
    .accordionItem {
      height: auto;
      overflow: hidden;
    }
    @media all {
    
    .accordionItem {
      max-height: 50em;
      -moz-transition: max-height 1s;
      -o-transition: max-height 1s;
      -webkit-transition: max-height 1s;
      transition: max-height 1s;
    }
    }
    @media screen and (min-width: 48em) {
    
    .accordionItem {
      max-height: 15em;
      -moz-transition: max-height 0.5s;
      -o-transition: max-height 0.5s;
      -webkit-transition: max-height 0.5s;
      transition: max-height 0.5s;
    }
    }
    
    .accordionItemCollapsed { max-height: 0; }
    
    .animateIn {
      -webkit-animation-name: accordionIn;
      -webkit-animation-duration: 0.65s;
      -webkit-animation-iteration-count: 1;
      -webkit-animation-direction: normal;
      -webkit-animation-timing-function: ease-in-out;
      -webkit-animation-fill-mode: both;
      -webkit-animation-delay: 0s;
      -moz-animation-name: normal;
      -moz-animation-duration: 0.65s;
      -moz-animation-iteration-count: 1;
      -moz-animation-direction: alternate;
      -moz-animation-timing-function: ease-in-out;
      -moz-animation-fill-mode: both;
      -moz-animation-delay: 0s;
      animation-name: accordionIn;
      animation-duration: 0.65s;
      animation-iteration-count: 1;
      animation-direction: normal;
      animation-timing-function: ease-in-out;
      animation-fill-mode: both;
      animation-delay: 0s;
    }
    
    .animateOut {
      -webkit-animation-name: accordionOut;
      -webkit-animation-duration: 0.75s;
      -webkit-animation-iteration-count: 1;
      -webkit-animation-direction: alternate;
      -webkit-animation-timing-function: ease-in-out;
      -webkit-animation-fill-mode: both;
      -webkit-animation-delay: 0s;
      -moz-animation-name: accordionOut;
      -moz-animation-duration: 0.75s;
      -moz-animation-iteration-count: 1;
      -moz-animation-direction: alternate;
      -moz-animation-timing-function: ease-in-out;
      -moz-animation-fill-mode: both;
      -moz-animation-delay: 0s;
      animation-name: accordionOut;
      animation-duration: 0.75s;
      animation-iteration-count: 1;
      animation-direction: alternate;
      animation-timing-function: ease-in-out;
      animation-fill-mode: both;
      animation-delay: 0s;
    }
     @-webkit-keyframes
    accordionIn {  0% {
     opacity: 0;
     -webkit-transform: scale(0.8);
    }
     100% {
     opacity: 1;
     -webkit-transform: scale(1);
    }
    }
    @-moz-keyframes
    accordionIn {  0% {
     opacity: 0;
     -moz-transform: scale(0.8);
    }
     100% {
     opacity: 1;
     -moz-transform: scale(1);
    }
    }
    @keyframes
    accordionIn {  0% {
     opacity: 0;
     transform: scale(0.8);
    }
     100% {
     opacity: 1;
     transform: scale(1);
    }
    }
    @-webkit-keyframes
    accordionOut {  0% {
     opacity: 1;
     -webkit-transform: scale(1);
    }
     100% {
     opacity: 0;
     -webkit-transform: scale(0.8);
    }
    }
    @-moz-keyframes
    accordionOut {  0% {
     opacity: 1;
     -moz-transform: scale(1);
    }
     100% {
     opacity: 0;
     -moz-transform: scale(0.8);
    }
    }
    @keyframes
    accordionOut {  0% {
     opacity: 1;
     transform: scale(1);
    }
     100% {
     opacity: 0;
     transform: scale(0.8);
    }
    }
    </style>
    </head>
    <body>
    <div class="container">
      <h1>Get Started With Below 4 Simple Steps</h1>
     <div class="accordion">
        <dl>
          <dt><a href="#">1st tab</a></dt>
          <dd class="accordionItem accordionItemCollapsed">
             <p><a href="http://google.com">Google</a></p>
    		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris. </p>
         	</dd>
    	  <dt><a href="#">2nd tab</a></dt>
          <dd class="accordionItem accordionItemCollapsed">
            <p>consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris. </p>
            <p>venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p>
          </dd>
    	  <dt><a href="#">3rd tab</a></dt>
          <dd class="accordionItem accordionItemCollapsed">
            <p>eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris. </p>
            <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p>
          </dd>
          <dt><a href="#">4th Tab</a></dt>
          <dd class="accordionItem accordionItemCollapsed">
            <p><a href="/wp-admin/plugins.php">Plugins</a>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris. </p>
            <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p>
          </dd>
          <dt><a href="#">5th Tab</a></dt>
          <dd class="accordionItem accordionItemCollapsed">
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu interdum diam. Donec interdum porttitor risus non bibendum. Maecenas sollicitudin eros in quam imperdiet placerat. Cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum. Donec dignissim arcu nec elit faucibus condimentum. Donec facilisis consectetur enim sit amet varius. Pellentesque justo dui, sodales quis luctus a, iaculis eget mauris. </p>
            <p>Aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, at elementum libero quam ac ligula. Pellentesque at rhoncus dolor. Duis porttitor nibh ut lobortis aliquam. Nullam eu dolor venenatis mauris placerat tristique eget id dolor. Quisque blandit adipiscing erat vitae dapibus. Nulla aliquam magna nec elementum tincidunt.</p>
          </dd>
        </dl>
      </div>
    </div>
    <script>
    /*!
     * classie - class helper functions
     * from bonzo https://github.com/ded/bonzo
     *
     * classie.has( elem, 'my-class' ) -> true/false
     * classie.add( elem, 'my-new-class' )
     * classie.remove( elem, 'my-unwanted-class' )
     * classie.toggle( elem, 'my-class' )
     */
    
    /*jshint browser: true, strict: true, undef: true */
    /*global define: false */
    
    ( function( window ) {
    
    'use strict';
    
    // class helper functions from bonzo https://github.com/ded/bonzo
    
    function classReg( className ) {
      return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
    }
    
    // classList support for class management
    // altho to be fair, the api sucks because it won't accept multiple classes at once
    var hasClass, addClass, removeClass;
    
    if ( 'classList' in document.documentElement ) {
      hasClass = function( elem, c ) {
        return elem.classList.contains( c );
      };
      addClass = function( elem, c ) {
        elem.classList.add( c );
      };
      removeClass = function( elem, c ) {
        elem.classList.remove( c );
      };
    }
    else {
      hasClass = function( elem, c ) {
        return classReg( c ).test( elem.className );
      };
      addClass = function( elem, c ) {
        if ( !hasClass( elem, c ) ) {
          elem.className = elem.className + ' ' + c;
        }
      };
      removeClass = function( elem, c ) {
        elem.className = elem.className.replace( classReg( c ), ' ' );
      };
    }
    
    function toggleClass( elem, c ) {
      var fn = hasClass( elem, c ) ? removeClass : addClass;
      fn( elem, c );
    }
    
    var classie = {
      // full names
      hasClass: hasClass,
      addClass: addClass,
      removeClass: removeClass,
      toggleClass: toggleClass,
      // short names
      has: hasClass,
      add: addClass,
      remove: removeClass,
      toggle: toggleClass
    };
    
    // transport
    if ( typeof define === 'function' && define.amd ) {
      // AMD
      define( classie );
    } else {
      // browser global
      window.classie = classie;
    }
    
    })( window );
    
    //fake jQuery
    var $ = function(selector){
      return document.querySelector(selector);
    }
    var accordion = $('.accordion');
    
    //add event listener to all anchor tags with accordion title class
    accordion.addEventListener("click",function(e) {
      e.stopPropagation();
      e.preventDefault();
      if(e.target && e.target.nodeName == "A") {
        var classes = e.target.className.split(" ");
        if(classes) {
          for(var x = 0; x < classes.length; x++) {
            if(classes[x] == "accordionTitle") {
              var title = e.target;
    
              //next element sibling needs to be tested in IE8+ for any crashing problems
              var content = e.target.parentNode.nextElementSibling;
    
              //use classie to then toggle the active class which will then open and close the accordion
    
              classie.toggle(title, 'accordionTitleActive');
              //this is just here to allow a custom animation to treat the content
              if(classie.has(content, 'accordionItemCollapsed')) {
                if(classie.has(content, 'animateOut')){
                  classie.remove(content, 'animateOut');
                }
                classie.add(content, 'animateIn');
    
              }else{
                 classie.remove(content, 'animateIn');
                 classie.add(content, 'animateOut');
              }
              //remove or add the collapsed state
              classie.toggle(content, 'accordionItemCollapsed');
    
            }
          }
        }
    
      }
    });
    </script>
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-46156385-1', 'cssscript.com');
      ga('send', 'pageview');
    
    </script>
    </body>
    </html>
    
    	</div>
    <style>
    
    .welcome-panel .welcome-widgets-menus:before,
    .welcome-panel .welcome-comments:before,
    .welcome-panel .welcome-learn-more:before{
    content: '';
    }
    .welcome-panel .welcome-widgets-menus{
    background: url(/path/to/icon) 0 50% no-repeat;
    }
    .welcome-panel .welcome-comments{
    background: url(/path/to/icon) 0 50% no-repeat;
    }
    .welcome-panel .welcome-learn-more{
    background: url(/path/to/icon) 0 50% no-repeat;
    }
    </style>
    <script type="text/javascript">
    jQuery(function($) {
      $('.welcome-panel-column a.button-primary').attr( 'href', 'google.com' );
    });
    </script>
    <?php
    }
    
    add_action( 'welcome_panel', 'rc_my_welcome_panel' );

    Put this code in notepad, save it as .php and put it in plugins folder and check your WordPress Dashboard. Now try clicking that link inside the accordion. It won't work.

    Another question is,

    Under each accordion I wanted to link it to admin pages like
    1. Add page
    2. Add Post
    3. Add Categories etc

    What is the linking code? It should be like
    <?php printf( '' . __( 'Turn comments on or off' ) . '', admin_url( 'options-discussion.php' ) ); ?>
    right?

    Please help. I hope you know what I wanted to do. I know it is easy just linking tags but it is not working inside WordPress. My wamp server uses Crome.

  • Ash

    Hello @CatMan

    But the color of tabs changed to white. I tried changing the colors but it is not working.

    Because, you have changed color code and removed class name from html at the last code you sent to me.

    I have customized again, you may still need little css tweaks, please try this code: http://pastebin.com/Ax0CGpJ9

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • CatMan

    You are the Man! Now everything works fine! Thank you so much for taking lot of effort.

    My last question in this thread.
    When using php link code to point to admin pages, how do I use Image as hyperlink. Like, clicking on the images takes to the admin page.

    This is the code right,
    <?php printf( '' . __( 'Turn comments on or off' ) . '', admin_url( 'options-discussion.php' ) ); ?>

    How do I have an image as hyperlink in the above code?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.