From the course: Custom WordPress Plugins: Design, Develop, and Distribute
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Customizing styles and scripts for social media buttons - WordPress Tutorial
From the course: Custom WordPress Plugins: Design, Develop, and Distribute
Customizing styles and scripts for social media buttons
- We have set the HTML for what our social media plugin will look like. Now it's time to add functionality and style it. Navigate to your social-sharing.js file. Open code file 03_03_a as in apple .js. Paste the code in your JavaScript file. Remember, this is JavaScript. There are no opening PHP tags. Let's go over what our JavaScript is doing. First, we're adding an event listener to the buttons to listen for when they're clicked. We've also set a condition that if the button is clicked the first time, the text inside of the data message is copied to the clipboard. This was our personalized message, like retweet if you agree. You also get pop-up alerts that tell you that your message has been copied. The button text has also been changed. Instead of the set message, share with this audience, the message changes to, go to this platform. So if you clicked on share to Facebook audience, after the click it becomes, go to Facebook. This is the same with X and LinkedIn. We're tailoring our…