Here are the most popular pizza toppings that make crowd-pleasing homemade pizzas! From classic Margherita to creative combinations, find inspiration for your next pizza night.

Hosting a pizza night and looking for inspiration? Sure, you can throw just about anything on a pizza. But as a homemade pizza expert, I’ve found that there are certain pizza topping ideas that make crowd-pleasing pizzas every time: from the classic Margherita pizza to unique pies like taco pizza and pickle pizza.
Of course, the classics are classics for a reason: like the mighty pepperoni, chicken BBQ, and Hawaiian pizza. But the true magic happens when you start playing with your own ideas: like fresh basil, prosciutto, sauteed portobello mushrooms, and a little hot honey or drizzle of truffle oil. Of course, my favorite pizza sauce always seals the deal!
25 popular pizza toppings
One of the most popular pizza toppings…ever? Margherita pizza! Invented in the 1800s, pizza margherita showcases the colors of the Italian flag: red from the tomato sauce, white from the mozzarella, and green from the basil.
The supreme pizza is another highly popular pizza topping, though the exact definition varies on the pizzeria! It starts with a base of pizza sauce and mozzarella cheese. The most common supreme toppings are pepperoni, sausage, green bell pepper, black olives, and red onions. Often sautéed mushrooms are added, or even hot peppers.
Here’s a pie that’s one of the Italian greats: Quattro Formaggi! This classic Italian combination of four cheese is popular for a reason: combine each flavor and texture and it makes one completely irresistible slice! There’s the melty mozzarella, sharp and salty Parmesan and Pecorino cheese, and the subtle funk of gorgonzola.
Another great pizza topping? Artichokes! This spinach artichoke pizza replicates the popular hot dip right on a pizza crust. Brush the crust with oil, then top it with mozzarella and Parmesan cheese, garlic, sautéed spinach, and tangy artichoke hearts.
Another in the most common pizza toppings? Cheese pizza. This one tastes infinitely better than your standard delivery pizza, pairing my popular tangy pizza sauce with shredded mozzarella and fresh mozzarella to get the gooiest, cheesiest pie.
Try this red pepper pizza with feta and oregano! It's topped with my famous 5 minute pizza sauce. mozzarella cheese, jarred roasted red pepper strips and salty feta cheese. Baked until the crust is golden and showered with fresh oregano, it’s one unforgettable pie!
Taco pizza is a popular pizza topping that replicates the experience of a taco right on a pizza. This version is a fan-favorite that replicates the Pizza Hut special. Top the dough with refried beans and Mexican style cheese, then add tomatoes, black olives, green onion and crunchy lettuce. Top it off with crunchy tortilla chips and a drizzle of ranch.
White pizza, or pizza bianca in Italian, is a pizza made without a red tomato sauce. Instead, it uses either a white-colored sauce or a fine brushing of olive oil over the dough before topping it. The white sauce can be a cream sauce like an alfredo, or a soft cheese like ricotta cheese. This recipe stars ricotta cheese mixed with garlic as the base, with mozzarella and Parmesan cheese over the top.
Pesto is another ultra popular pizza topping, and you don't even need a recipe! Spread the dough base with basil pesto, then top with mozzarella cheese and thinly sliced fresh tomatoes (adding a pinch of salt to the tomatoes before cooking). Step it up with homemade basil pesto.
Greek pizza is a colorful pizza topping idea that's always a hit! Top the dough with tomato sauce, then mozzarella cheese and a load of veggies: spinach, black olives, tomatoes, and red onion. Cover it all with a generous sprinkling of feta cheese.
Calling all seafood lovers! This pie is just for you! This delectable seafood pizza is full of bold flavors, featuring shrimp and scallops sauteed with garlic until they’re succulent and tender. They’re sprinkled onto a layer of seasoned ricotta cheese, then topped with gooey mozzarella, red onion and herbs.
The simpler the better with Italian cuisine, and I've found that with pizza, a few curated ingredients can make magic. Here a mix of briny green and black olives interplay with thin slivers of red onion, pops of salty capers, and gooey mozzarella cheese. It’s one dream pie for olive lovers!
What's better than fluffy dollops of goat cheese on a pizza? (Not much.) This one features my top rated tomato pizza sauce, mozzarella cheese, and generous dollops of goat cheese. Top it off with fresh basil, and this one's a pie to write home about.
Breakfast pizza means one thing: scrambled eggs on pizza! This pizza topping is a popular way to turn this beloved food into a morning meal. Top the dough with tomato sauce and mozzarella cheese, then add scrambled eggs, sausage (optional), bell peppers, and red onion.
Go big on mushrooms with this pizza! This pizza topping idea features mushrooms sautéed with fresh thyme and oregano, finished with a pop of lemon. Top the dough with olive oil, then mozzarella cheese. Add the mushrooms, dollops of goat cheese, and a sprinkle more of fresh herbs. It's heavenly!
A fun, simple pizza topping? Arugula! Bake up any toppings you like. When the pizza comes out of the oven, top it with peppery baby arugula, dressed simply with a hint of olive oil and salt. It adds a fresh crunchy to each bite! (Make sure to find baby arugula for this; standard arugula is much too strong.)
Shrimp makes a surprisingly tasty pizza topping. The garlicky, buttery shrimp against creamy ricotta, mozzarella and Parmesan cheese is one of the best pizza toppings you'll have. It tastes shrimp alfredo on a pizza crust instead of noodles…which is just as good as it sounds.
Rich and creamy burrata cheese is one of life’s greatest pleasures. So why not use it as a pizza topping? Here’s the ultimate pizza: a traditional Margherita pizza with gooey burrata cheese on top. Slather the crust with red sauce, then add mozzarella and halfway through the cook time, burrata cheese. Top with fresh basil leaves and enjoy.
Pickles as a pizza topping? This unusual pizza pairs a creamy garlic dill sauce with loads of gooey cheese and tangy bursts of pickle. It might sound odd: until you take the first bite. The flavors work remarkably well together.
Are you basil obsessed? Try Everything Basil Pizza! That means garlicky, thick homemade basil pesto slathered onto perfect pizza dough, topped with gooey mozzarella and a huge handful of fresh basil leaves. It’s the brightest green pizza you’ll make.
Love heat in your pizza toppings? Jalapeno peppers are ideal for adding bright zingy flavor to your pie. This pizza has a base of tangy salsa verde, topped with mozzarella cheese. Pair the heat of the jalapeno with savory zucchini and bright sweet corn, and it’s a uniquely delicious pie.
The best way to eat your greens? On pizza! This pizza is all about garlicky, savory flavor. Ricotta makes for a creamy base, and mozzarella and Parmesan add stretchy texture and savory flavor. Top it off with herbed spinach and a few colorful vegetables, and it’s a crowd-pleaser that everyone will love.
Looking for gourmet pizza toppings? Try Truffle Pizza! Truffle oil is earthy, it’s intoxicating, and it makes anything taste nuanced and intriguing. This pizza is all about channeling that vibe: savory mushrooms, gooey mozzarella cheese, drizzled with the oil that infuses the entire pie in luxury.
Looking to amp up your pizza night? This spicy pizza diavola is a fan favorite! Top the dough with tomato sauce, then add Kalamata olives, spicy peppers, and gooey mozzarella cheese.
Avocado on pizza might sound counterintuitive, but they're perfection on this pie! Start with a base of pizza sauce and mozzarella cheese, then add fresh bell peppers, red onion, dollops of fresh avocado, and dollops of goat cheese. After you bake, sprinkle with fresh basil. It's fresh and hearty all at once!
Essential Tools for Pizza Success
After years of making pizza at home, I’ve learned that having the right equipment makes a huge difference in the final result.
- First up is a pizza stone. The high heat from a preheated stone creates that crispy, chewy crust that’s impossible to achieve on a regular baking sheet. I preheat mine for at least 45 minutes before baking. Here’s the pizza stone I use.
- A pizza peel is essential for safely transferring your topped pizza onto the hot stone. I dust mine with cornmeal or semolina flour to help the pizza slide off easily. If you don’t have a peel, a rimless baking sheet works as a temporary solution. But I like this conveyor pizza peel.
- For the dough itself, my Best Pizza Dough recipe is my favorite traditional, chewy crust, or my Thin Crust Dough is crispier and lighter. Both are straightforward to make and rest for about 45 minutes.
- My five-minute pizza sauce has become a staple in my kitchen. It’s just fire-roasted tomatoes, garlic, olive oil, oregano, and salt blended together: no cooking required!
Pro Tips for Perfect Pizza
I’ve made enough pizzas to learn some lessons the hard way. Here’s what actually matters:
- Preheat your oven properly. I set mine to 500°F and let the pizza stone heat for at least 45 minutes.
- Don’t overload your pizza. This is the biggest beginner mistake! Too many toppings create a soggy pizza that won’t cook properly. Remember to go light on wet ingredients like fresh tomatoes or mushrooms.
- Use quality mozzarella. I’ve found that whole milk mozzarella melts significantly better than part-skim.
- Season your toppings. Before they go on the pizza, vegetables benefit from a light drizzle of olive oil and a pinch of salt.
Alternative Pizza Methods
Not everyone has a pizza stone or wants to invest in one, and that’s completely fine! I’ve developed a few dough methods that work with other equipment.
- Cast iron pizza is my favorite alternative method. The hot cast iron pan makes for a crispy-on-the-outside crust, and you don’t need to worry about stretching the dough or transferring it. Just press the dough into the pan, add toppings, and bake.
- Sheet pan pizza is perfect for feeding a crowd or when you want a thicker crust. This makes the equivalent of 3 medium pizzas on a large sheet pan, and the method is very forgiving for beginners.
- I also have some fun cheater pizzas that use premade crust, like Naan Pizza, Pita Pizza, or Tortilla Pizza.
For those with an outdoor pizza oven, my Pizza Oven Dough recipe is specifically formulated for the super-high heat those ovens produce. The pizzas cook in just 90 seconds!
25 Popular Pizza Toppings
Here’s the only homemade pizza recipe you need! Learn how to make the best pizza dough, sauce, and toppings. For the topping ideas, see the recipes list above.
- Prep Time: 1 hour
- Cook Time: 7 minutes
- Total Time: 1 hour 7 minutes
- Yield: 1 medium pizza
- Category: Pizza
- Method: Baked
- Cuisine: Pizza
- Diet: Vegetarian
Ingredients
For the pizza dough
- 1 ball Best Pizza Dough or Thin Crust Dough (or go to Cast Iron Pizza, Sheet Pan Pizza, or Pizza Oven Dough)
- Semolina flour or cornmeal, for dusting
For the pizza sauce (use ⅓ cup for topping)
- 1 small garlic clove (1/2 medium)
- 15 ounces crushed fire roasted tomatoes (or high quality organic canned tomatoes)
- 1 tablespoon extra virgin olive oil
- ½ teaspoon dried oregano
- Scant ½ teaspoon kosher salt
For the toppings — or use topping ideas from 25 Top Pizza Recipes
- ¾ cup shredded mozzarella cheese (or ½ cup shredded mozzarella and 2 to 3 ounces goat cheese, in dollops)
- Parmesan cheese, for topping
- Fresh basil leaves, for garnish
Instructions
- Make the pizza dough: Follow the Best Pizza Dough or Thin Crust Dough recipe to prepare the dough. (These takes about 15 minutes to make and 45 minutes to rest.)
- Place a pizza stone in the oven and preheat to 500°F. OR preheat your pizza oven (here’s the pizza oven we use).
- Make the pizza sauce: Peel and cut the garlic into a few rough pieces. Place the garlic, fire roasted tomatoes, olive oil, oregano and kosher salt in a blender. Blend until fully combined. (You’ll use about ⅓ cup for the pizza; reserve the remaining sauce and refrigerate for up to 1 week.)
- Prepare the dough: When the oven is ready, dust a pizza peel with cornmeal or semolina flour. (If you don’t have a pizza peel, you can use a rimless baking sheet or the back of a rimmed baking sheet. But a pizza peel is well worth the investment!)
- Stretch the dough (Best Pizza Dough): For the Best Pizza Dough recipe, stretch the dough into a circle: place the dough on a lightly floured surface and dust the top of the dough with flour. Use your fingers to gently press the dough into a circle, flipping several times and adding a pinch of flour if it is too sticky. Once you have about an 8-inch circle, pick up the dough and gently drape it over the knuckles on both of your hands. Slowly rotate it around, allowing gravity to stretch it into a circle about 11 inches in diameter. If the dough starts to resist stretching, put it down and allow it to rest for a few minutes, at which point it will stretch more easily. Then repeat Step 3 until you have an 11-inch circle! See How to Stretch Pizza Dough for step by step photos.
- Roll the dough (Thin Crust Pizza Dough): If you’re making Thin Crust Dough, place it on a lightly floured surface and gently press it into a circle, adding a pinch of flour if it is too sticky. Then roll out the dough into a circle about 11 inches in diameter, using just enough flour on each side to keep it from sticking. If the dough starts to resist rolling, wait for a minute or two, at which point it will roll out more easily.
- Spread a thin layer of the pizza sauce over the dough, using about ⅓ cup. Add the mozzarella cheese (and if using, goat cheese or other types of cheese). Top with a thin layer of fresh grated Parmesan cheese and a few pinches of kosher salt.
- Use the pizza peel to carefully transfer the pizza onto the preheated pizza stone. Bake the pizza until the cheese and crust are nicely browned, about 5 to 7 minutes in the oven (or 1 minute in a pizza oven).
- Allow the pizza to cool for a minute or two before adding the basil leaves on top (whole leaves, lightly torn, or thinly sliced). Slice into pieces and serve immediately.
Notes
The Cast Iron Pizza and Sheet Pan Pizza methods are easier because they don’t require stretching the dough, but they take slightly longer. All you need are a large cast iron skillet or 13×18 sheet pan; you can use the same toppings as above. For dough and baking instructions, go to Pan Pizza or Sheet Pan Pizza. If you’re using an outdoor pizza oven, go to Pizza Oven Dough.
window.trCommon={“minRating”:6,”ajaxurl”:”https:\/\/www.acouplecooks.com\/wp-admin\/admin-ajax.php”,”ratingNonce”:””,”postId”:128295};
window.TastyRecipes = window.TastyRecipes || {};
window.TastyRecipes.smoothScroll = {
init() {
document.addEventListener( ‘click’, ( e ) => {
let anchor = e.target;
if ( anchor.tagName !== ‘A’ ) {
anchor = anchor.closest( ‘a.tasty-recipes-scrollto’ );
}
if ( ! anchor || ! anchor.classList.contains( ‘tasty-recipes-scrollto’ ) ) {
return;
}
const elementHref = anchor.getAttribute( ‘href’ );
if ( ! elementHref ) {
return;
}
e.preventDefault();
this.goToSelector( elementHref );
});
},
goToSelector( selector ) {
const element = document.querySelector( selector );
if ( ! element ) {
return;
}
element.scrollIntoView( { behavior: ‘smooth’ } );
}
};
document.addEventListener(
‘DOMContentLoaded’,
() => window.TastyRecipes.smoothScroll.init()
);
window.TastyRecipes = window.TastyRecipes || {};
window.TastyRecipes.cookMode = {
wakeLockApi: false,
wakeLock: false,
cookModeSelector: ‘.tasty-recipes-cook-mode’,
init() {
if (“wakeLock” in navigator && “request” in navigator.wakeLock) {
this.wakeLockApi = navigator.wakeLock;
}
const cookModes = document.querySelectorAll(this.cookModeSelector);
if (cookModes.length > 0) {
for (const cookMode of cookModes) {
if (this.wakeLockApi) {
cookMode.querySelector(‘input[type=”checkbox”]’).addEventListener(“change”, event => {
this.checkboxChange(event.target);
}, false);
} else {
cookMode.style.display = “none”;
}
}
}
},
checkboxChange(checkbox) {
if (checkbox.checked) {
this.lock();
} else {
this.unlock();
}
},
setCheckboxesState(state) {
const checkboxes = document.querySelectorAll(this.cookModeSelector + ‘ input[type=”checkbox”]’);
for (const checkbox of checkboxes) {
checkbox.checked = state;
}
},
async lock() {
try {
this.wakeLock = await this.wakeLockApi.request(“screen”);
this.wakeLock.addEventListener(“release”, () => {
this.wakeLock = false;
this.setCheckboxesState(false);
});
this.setCheckboxesState(true);
} catch (error) {
this.setCheckboxesState(false);
}
},
unlock() {
if (this.wakeLock) {
this.wakeLock.release();
this.wakeLock = false;
}
this.setCheckboxesState(false);
}
};
(function(callback) {
if (document.readyState !== “loading”) {
callback();
} else {
document.addEventListener(“DOMContentLoaded”, callback);
}
})(() => {
window.TastyRecipes.cookMode.init();
});
window.TastyRecipes = window.TastyRecipes || {};
window.TastyRecipes.staticTooltip = {
element: null,
tooltipElement: null,
deleting: false,
init( element ) {
if ( this.deleting ) {
return;
}
this.element = element;
this.buildElements();
},
destroy() {
if ( ! this.tooltipElement || this.deleting ) {
return;
}
this.deleting = true;
this.tooltipElement.classList.remove( ‘opened’ );
setTimeout( () => {
this.tooltipElement.remove();
this.deleting = false;
}, 500 );
},
buildElements() {
const tooltipElement = document.createElement( ‘div’ );
tooltipElement.classList.add( ‘tasty-recipes-static-tooltip’);
tooltipElement.setAttribute( ‘id’, ‘tasty-recipes-tooltip’ );
const currentTooltipElement = document.getElementById( ‘tasty-recipes-tooltip’ );
if ( currentTooltipElement ) {
document.body.replaceChild( tooltipElement, currentTooltipElement );
} else {
document.body.appendChild( tooltipElement );
}
this.tooltipElement = document.getElementById( ‘tasty-recipes-tooltip’ );
},
show() {
if ( ! this.tooltipElement ) {
return;
}
const tooltipTop = this.element.getBoundingClientRect().top
+ window.scrollY
– 10 // 10px offset.
– this.tooltipElement.getBoundingClientRect().height;
const tooltipLeft = this.element.getBoundingClientRect().left
– ( this.tooltipElement.getBoundingClientRect().width / 2 )
+ ( this.element.getBoundingClientRect().width / 2 ) – 1;
const posLeft = Math.max( 10, tooltipLeft );
this.maybeRemoveTail( posLeft !== tooltipLeft );
this.tooltipElement.setAttribute( ‘style’, ‘top:’ + tooltipTop + ‘px;left:’ + posLeft + ‘px;’ );
this.tooltipElement.classList.add( ‘opened’ );
},
maybeRemoveTail( removeTail ) {
if ( removeTail ) {
this.tooltipElement.classList.add( ‘tr-hide-tail’ );
} else {
this.tooltipElement.classList.remove( ‘tr-hide-tail’ );
}
},
changeMessage( message ) {
if ( ! this.tooltipElement ) {
return;
}
this.tooltipElement.innerHTML = message;
}
};
window.TastyRecipes.ajax = {
sendPostRequest( url, data, success, failure ) {
const xhr = new XMLHttpRequest();
xhr.open( ‘POST’, url, true );
xhr.send( this.preparePostData( data ) );
xhr.onreadystatechange = () => {
if ( 4 !== xhr.readyState ) {
return;
}
if ( xhr.status === 200 ) {
success( JSON.parse( xhr.responseText ) );
return;
}
failure( xhr );
};
xhr.onerror = () => {
failure( xhr );
};
},
preparePostData( data ) {
const formData = new FormData();
for ( const key in data ) {
formData.append( key, data[key] );
}
return formData;
},
};
window.TastyRecipes.ratings = {
defaultRating: 0,
currentRatingPercentage: 100,
savingRating: false,
init( minRating ) {
this.minRating = minRating;
this.formWatchRating();
this.closeTooltipWhenClickOutside();
this.addBodyClassBasedOnSelectedRating();
this.backwardCompFormRatingPosition();
},
formWatchRating() {
const ratings = document.querySelectorAll(‘.tasty-recipes-no-ratings-buttons [data-rating]’);
if ( ratings.length {
event.preventDefault();
this.defaultRating = event.target.closest( ‘.checked’ ).dataset.rating;
this.setCheckedStar( event.target );
this.maybeSendRating( this.defaultRating, event.target );
this.setRatingInForm( this.defaultRating );
} );
}
},
closeTooltipWhenClickOutside() {
window.addEventListener( ‘click’, e => {
// Bailout (don’t remove the tooltip) when the clicked element is a rating star, or it’s the tooltip itself.
if ( e.target.closest( ‘.tasty-recipes-rating’ ) || e.target.classList.contains( ‘tasty-recipes-static-tooltip’ ) ) {
return;
}
window.TastyRecipes.staticTooltip.destroy();
} );
},
setRatingInForm( rating ) {
const ratingInput = document.querySelector( ‘#respond .tasty-recipes-rating[value=”‘ + rating + ‘”]’ );
if ( ! ratingInput ) {
return;
}
ratingInput.click();
},
addBodyClassBasedOnSelectedRating() {
const ratingInputs = document.querySelectorAll( ‘input.tasty-recipes-rating’ );
if ( ! ratingInputs ) {
return;
}
for ( const ratingInput of ratingInputs ) {
ratingInput.addEventListener( ‘click’, currentEvent => {
const selectedRating = currentEvent.target.getAttribute( ‘value’ );
this.handleBodyClassByRating( selectedRating );
this.toggleCommentTextareaRequired( selectedRating );
} );
}
},
handleBodyClassByRating( rating ) {
if ( rating < this.minRating ) {
document.body.classList.remove( 'tasty-recipes-selected-minimum-rating' );
return;
}
document.body.classList.add( 'tasty-recipes-selected-minimum-rating' );
},
toggleCommentTextareaRequired( rating ) {
const commentTextarea = document.getElementById( 'comment' );
if ( ! commentTextarea ) {
return;
}
if ( rating {
window.TastyRecipes.staticTooltip.changeMessage( response.data.message );
window.TastyRecipes.staticTooltip.show();
this.updateAverageText( response.data, recipeCardElement );
this.maybeFillCommentForm( response.data );
// Hide the tooltip after 5 seconds.
setTimeout( () => {
this.maybeResetTooltip( recipeCardElement, response.data, rating );
}, 5000 );
},
() => {
this.resetTooltip( recipeCardElement );
}
);
},
updateAverageText( data, recipeCardElement ) {
if ( ! data.average ) {
return;
}
this.setRatingPercent( data );
if ( ! data.count ) {
return;
}
const quickLink = document.querySelector( ‘.tasty-recipes-rating-link’ );
if ( quickLink ) {
this.setTextInContainer( quickLink, data );
this.setPartialStar( quickLink );
}
const cardStars = recipeCardElement.querySelector( ‘.tasty-recipes-ratings-buttons’ );
cardStars.dataset.trDefaultRating = data.average;
this.setTextInContainer( recipeCardElement.querySelector( ‘.tasty-recipes-rating’ ), data );
},
setTextInContainer( container, data ) {
if ( ! container ) {
return;
}
if ( data.label ) {
const ratingLabelElement = container.querySelector( ‘.rating-label’ );
if ( ratingLabelElement ) {
ratingLabelElement.innerHTML = data.label;
}
return;
}
const averageElement = container.querySelector( ‘.average’ );
if ( averageElement ) {
averageElement.textContent = data.average;
}
const countElement = container.querySelector( ‘.count’ );
if ( countElement ) {
countElement.textContent = data.count;
}
},
setPartialStar( container ) {
const highestStar = container.querySelector( ‘[data-rating=”‘ + Math.ceil( this.defaultRating ) + ‘”]’ );
if ( highestStar ) {
highestStar.dataset.trClip = this.currentRatingPercentage;
}
},
setRatingPercent( data ) {
this.defaultRating = data.average.toFixed( 1 );
const parts = data.average.toFixed( 2 ).toString().split( ‘.’ );
this.currentRatingPercentage = parts[1] ? parts[1] : 100;
if ( this.currentRatingPercentage === ’00’ ) {
this.currentRatingPercentage = 100;
}
},
setCheckedStar( target ) {
const cardRatingContainer = target.closest( ‘.tasty-recipes-ratings-buttons’ );
const selectedRatingElement = cardRatingContainer.querySelector( ‘[data-tr-checked]’ );
if ( selectedRatingElement ) {
delete selectedRatingElement.dataset.trChecked;
}
const thisStar = target.closest( ‘.tasty-recipes-rating’ );
thisStar.dataset.trChecked = 1;
thisStar.querySelector( ‘[data-tr-clip]’ ).dataset.trClip = 100;
},
maybeFillCommentForm( data ) {
if ( ! data.comment || ! data.comment.content ) {
return;
}
const commentForm = document.querySelector( ‘#commentform’ );
if ( ! commentForm ) {
return;
}
const commentBox = commentForm.querySelector( ‘[name=comment]’ );
if ( ! commentBox || commentBox.value ) {
return;
}
// Add comment details for editing.
commentBox.innerHTML = data.comment.content;
if ( data.comment.name ) {
commentForm.querySelector( ‘[name=author]’ ).value = data.comment.name;
commentForm.querySelector( ‘[name=email]’ ).value = data.comment.email;
}
},
maybeResetTooltip( recipeCardElement, data, rating ) {
if ( this.savingRating === rating ) {
this.resetTooltip( recipeCardElement, data );
}
},
resetTooltip( recipeCardElement, data ) {
window.TastyRecipes.staticTooltip.destroy();
this.savingRating = false;
// Reset the default rating.
const cardRatingContainer = recipeCardElement.querySelector( ‘.tasty-recipes-ratings-buttons’ );
if ( cardRatingContainer ) {
this.defaultRating = ( data && data.average ) ? data.average.toFixed(1) : cardRatingContainer.dataset.trDefaultRating;
cardRatingContainer.dataset.trDefaultRating = this.defaultRating;
this.resetSelectedStar( cardRatingContainer, data );
}
},
resetSelectedStar( cardRatingContainer ) {
const selectedRatingElement = cardRatingContainer.querySelector( ‘[data-rating=”‘ + Math.ceil( this.defaultRating ) + ‘”]’ );
if ( selectedRatingElement ) {
selectedRatingElement.querySelector( ‘[data-tr-clip]’ ).dataset.trClip = this.currentRatingPercentage;
selectedRatingElement.parentNode.dataset.trChecked = 1;
}
const previousSelectedElement= cardRatingContainer.querySelector( ‘[data-tr-checked]’ );
if ( previousSelectedElement ) {
const currentSelectedRating = previousSelectedElement.querySelector(‘[data-rating]’);
if ( currentSelectedRating !== selectedRatingElement ) {
delete previousSelectedElement.dataset.trChecked;
}
}
},
backwardCompFormRatingPosition() {
const ratingsButtons = document.querySelector( ‘#respond .tasty-recipes-ratings-buttons, #tasty-recipes-comment-rating .tasty-recipes-ratings-buttons’ );
if ( ! ratingsButtons ) {
return;
}
const ratingsButtonsStyles = window.getComputedStyle(ratingsButtons);
if ( ! ratingsButtonsStyles.display.includes( ‘flex’ ) ) {
ratingsButtons.style.direction = ‘rtl’;
}
if ( typeof tastyRecipesRating !== ‘undefined’ ) {
// Select the rating that was previously selected in admin.
ratingsButtons.querySelector( ‘.tasty-recipes-rating[value=”‘ + tastyRecipesRating + ‘”]’ ).checked = true;
}
const ratingSpans = ratingsButtons.querySelectorAll( ‘.tasty-recipes-rating’ );
for (const ratingSpan of ratingSpans) {
ratingSpan.addEventListener( ‘click’, event => {
if ( ratingSpan === event.target ) {
return;
}
ratingSpan.previousElementSibling.click();
} );
}
}
};
(function(callback) {
if (document.readyState !== “loading”) {
callback();
} else {
window.addEventListener( ‘load’, callback );
}
})(() => {
window.TastyRecipes.ratings.init( window.trCommon ? window.trCommon.minRating : 4 );
});