Hi guys,
We just got a soft reject from Theme Forest and right now on the way of fixing our themes :). I have trouble with one of the items specified by the reviewer mainly…
Scripts and styles should not be hardcoded anywhere in your theme or added any other way but with wp_enqueue_ hook and to be added from the functions file. This includes custom JS/CSS.*
Question 1
Let’s say I have this simple inline script in a page:
<?php
$name = 'John';
?>
<script>
var name = '<?php echo $name; ?>';
alert( name );
</script>
Since script should not be hardcoded anywhere in theme, except with wp_enqueue_* hook, how do I accomplish that?
Question 2
In the loop, I use CSS background-image to make post-thumbnail fixed-sized.
for example:
<div class="post-thumb" style="background-image:url(<?php echo $post_thumb_url; ?>);">
</div>
Since style also should not be hardcoded in theme, how do I solve this? It’s inside the loop, so it’s unique for each loop.
Or the use of background-image is frowned upon?