define('HOWTOHUB_VERSION','3.0.0'); function howtohub_setup(){ register_nav_menus(array('primary'=>__('Primary','howtohub'),'footer'=>__('Footer','howtohub'))); add_theme_support('post-thumbnails'); add_theme_support('title-tag'); add_theme_support('html5',array('search-form','comment-form','comment-list','gallery','caption')); set_post_thumbnail_size(800,450,true); } add_action('after_setup_theme','howtohub_setup'); // Enqueue - single CSS file, single JS file function howtohub_scripts(){ wp_enqueue_style('howtohub',get_template_directory_uri().'/assets/css/main.css',array(),HOWTOHUB_VERSION); wp_enqueue_script('howtohub',get_template_directory_uri().'/assets/js/app.js',array(),HOWTOHUB_VERSION,true); } add_action('wp_enqueue_scripts','howtohub_scripts'); // Nuke all block styles add_action('wp_enqueue_scripts',function(){ foreach(['wp-block-library','wp-block-library-theme','global-styles','classic-theme-styles','wp-img-auto-sizes-contain-inline-css'] as $s) wp_dequeue_style($s); remove_action('wp_head','print_emoji_detection_script',7); remove_action('wp_print_styles','print_emoji_styles'); },100); // Clean head remove_action('wp_head','wp_generator'); remove_action('wp_head','wlwmanifest_link'); remove_action('wp_head','rsd_link'); remove_action('wp_head','wp_shortlink_wp_head'); // JSON-LD Schema function howtohub_json_ld(){ if(!is_single())return; $schema=array('@context'=>'https://schema.org','@type'=>'Article', 'headline'=>get_the_title(),'datePublished'=>get_the_date('c'),'dateModified'=>get_the_modified_date('c'), 'author'=>array('@type'=>'Person','name'=>get_the_author()), 'publisher'=>array('@type'=>'Organization','name'=>'HowToHub','logo'=>array('@type'=>'ImageObject','url'=>get_template_directory_uri().'/screenshot.png'))); echo ''; } add_action('wp_head','howtohub_json_ld'); // OG function howtohub_og(){if(is_single()){echo '';if(has_post_thumbnail())echo '';}} add_action('wp_head','howtohub_og'); // Category helpers function howtohub_cat_icon($tid){$i=get_term_meta($tid,'howtohub_icon',true);return $i?:'đ';} function howtohub_cat_color($tid){$c=get_term_meta($tid,'howtohub_color',true);return $c?:'#6366f1';} // Default cat meta on activation function howtohub_default_cats(){ $d=array('āϞāĻŋāύāĻžāĻā§āϏ'=>array('đ§','#f59e0b'),'āϏāĻžāϰā§āĻāĻžāϰ'=>array('đĨī¸','#3b82f6'),'āĻāϝāĻŧā§āĻŦ āĻĄā§āĻā§āϞāĻĒāĻŽā§āύā§āĻ'=>array('đ','#10b981'),'āĻĒā§āϰā§āĻā§āϰāĻžāĻŽāĻŋāĻ'=>array('đģ','#8b5cf6'),'āĻĄā§āĻāĻ āĻĒāϏ'=>array('âī¸','#ef4444'),'āύā§āĻāĻāϝāĻŧāĻžāϰā§āĻāĻŋāĻ'=>array('đ','#06b6d4'),'āϏāĻŋāĻāĻŋāĻāϰāĻŋāĻāĻŋ'=>array('đ','#ec4899'),'āĻŽā§āĻŦāĻžāĻāϞ'=>array('đą','#14b8a6'),'āϏāĻžāϧāĻžāϰāĻŖ'=>array('đ','#64748b')); foreach($d as $n=>$v){$t=get_term_by('name',$n,'category');if($t){update_term_meta($t->term_id,'howtohub_icon',$v[0]);update_term_meta($t->term_id,'howtohub_color',$v[1]);}} } add_action('after_switch_theme','howtohub_default_cats'); // Reading time function howtohub_reading_time(){ob_start();the_content();$c=str_word_count(strip_tags(ob_get_clean()));return max(1,ceil($c/200));} // Ad Spot Shortcodes function howtohub_ad_spot($atts){$a=shortcode_atts(array('size'=>'default'),$atts);ob_start(); echo '
'.esc_html__('āĻāĻĄāĻŽāĻŋāύ â āĻāĻāĻžāύ⧠āĻāĻĄ āĻā§āĻĄ āĻŦāϏāĻžāύ','howtohub').'
';} echo 'āĻŽāϤāĻžāĻŽāϤ āĻĻāĻŋāϤ⧠āϞāĻāĻāύ āĻāϰā§āύāĨ¤
'; return $d; }); add_filter('comment_form_fields',function($f){ $comment=$f['comment'];unset($f['comment']); $f['author']=''; $f['email']=''; $f['comment']=$comment; return $f; });