/** * Enqueue premium libs: GSAP, ScrollTrigger, Three.js, Lottie */ add_action('wp_enqueue_scripts', function(){ // Theme main wp_enqueue_style('blendepic-style', get_stylesheet_uri(), [], wp_get_theme()->get('Version')); wp_enqueue_script('three', 'https://unpkg.com/three@0.160.0/build/three.min.js', [], null, true); wp_enqueue_script('gsap', 'https://unpkg.com/gsap@3/dist/gsap.min.js', [], null, true); wp_enqueue_script('gsap-scroll', 'https://unpkg.com/gsap@3/dist/ScrollTrigger.min.js', ['gsap'], null, true); wp_enqueue_script('lottie', 'https://unpkg.com/lottie-web/build/player/lottie.min.js', [], null, true); wp_enqueue_script('blendepic-runtime', get_template_directory_uri() . '/dist/js/runtime.js', ['three','gsap','gsap-scroll','lottie'], null, true); wp_enqueue_script('blendepic-main', get_template_directory_uri() . '/dist/js/main.js', ['blendepic-runtime'], null, true); wp_localize_script('blendepic-main', 'BEPRO', [ 'themeUrl' => get_template_directory_uri(), 'ajax' => admin_url('admin-ajax.php') ]); }); /** * Register CPTs: product, course */ add_action('init', function(){ $supports = ['title','editor','thumbnail','excerpt','revisions','author']; register_post_type('product',[ 'label'=>'Products','public'=>true,'has_archive'=>true,'show_in_rest'=>true, 'supports'=>$supports,'menu_icon'=>'dashicons-products','show_in_graphql'=>true,'graphql_single_name'=>'Product','graphql_plural_name'=>'Products' ]); register_post_type('course',[ 'label'=>'Courses','public'=>true,'has_archive'=>true,'show_in_rest'=>true, 'supports'=>$supports,'menu_icon'=>'dashicons-welcome-learn-more','show_in_graphql'=>true,'graphql_single_name'=>'Course','graphql_plural_name'=>'Courses' ]); }); /** * Meta fields: price, video_url */ add_action('init', function(){ register_post_meta('product','price',[ 'type'=>'string','single'=>true,'show_in_rest'=>true,'auth_callback'=>'__return_true' ]); register_post_meta('product','video_url',[ 'type'=>'string','single'=>true,'show_in_rest'=>true,'auth_callback'=>'__return_true' ]); register_post_meta('course','price',[ 'type'=>'string','single'=>true,'show_in_rest'=>true,'auth_callback'=>'__return_true' ]); register_post_meta('course','video_url',[ 'type'=>'string','single'=>true,'show_in_rest'=>true,'auth_callback'=>'__return_true' ]); }); /** * Shortcode: [enroll_button] */ add_shortcode('enroll_button', function($atts){ $atts = shortcode_atts(['label'=>'Enroll Now','url'=>'#checkout'], $atts); return ''.esc_html($atts['label']).''; }); /** * Add block pattern / hook for front-page hero */ add_action('after_setup_theme', function(){ add_theme_support('post-thumbnails'); });