function createCalcFunction(n) {
return function() {
console.log(n++);
};
}
const calc = createCalcFunction(10);
calc();
calc();
calc();
const calc2 = createCalcFunction(20);
calc2();
calc2();
calc2();
function makeSizer(size) {
return function() {
document.querySelector('h1').style.fontSize = size + 'px';
};
};
var size12 = makeSizer(12);
var size14 = makeSizer(14);
var size16 = makeSizer(16);
document.getElementById('size-12').onclick = size12;
document.getElementById('size-14').onclick = size14;
document.getElementById('size-16').onclick = size16;
add_action( 'pre_get_posts', 'action_view_index' );
function action_view_index( $query ) {
if( $query->is_front_page() ){
$query->set('cat',5);
return $query;
}
}