diff --git a/ansico-cv-blocks/ansico-cv-blocks.php b/ansico-cv-blocks/ansico-cv-blocks.php new file mode 100644 index 0000000..2de3b98 --- /dev/null +++ b/ansico-cv-blocks/ansico-cv-blocks.php @@ -0,0 +1,83 @@ + 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor']); + register_block_type('cv/position', ['editor_script' => 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor']); + register_block_type('cv/education', ['editor_script' => 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor']); + register_block_type('cv/profileheader', ['editor_script' => 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor']); + register_block_type('cv/contentblock', ['editor_script' => 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor']); + register_block_type('cv/container', ['editor_script' => 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor']); + register_block_type('cv/contactform', ['editor_script' => 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor', 'view_script' => 'cv-v1-frontend']); + register_block_type('cv/toc', ['editor_script' => 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor', 'view_script' => 'cv-v1-frontend']); + register_block_type('cv/profile', ['editor_script' => 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor']); + register_block_type('cv/topnav', ['editor_script' => 'cv-v1-blocks', 'style' => 'cv-v1-style', 'editor_style' => 'cv-v1-editor']); +} +add_action('init', 'cv_v1_register_blocks'); + +add_action('init', function() { + register_post_meta('page', 'ansico_cv_hide_title', array('show_in_rest' => true, 'single' => true, 'type' => 'boolean', 'default' => false)); + register_post_meta('page', 'ansico_cv_frame_design', array('show_in_rest' => true, 'single' => true, 'type' => 'boolean', 'default' => false)); +}); + +add_filter('body_class', function($classes) { + if (is_page()) { + $hide_title = get_post_meta(get_the_ID(), 'ansico_cv_hide_title', true); + $frame_design = get_post_meta(get_the_ID(), 'ansico_cv_frame_design', true); + if ($hide_title) $classes[] = 'ansico-cv-hide-title'; + if ($frame_design) $classes[] = 'ansico-cv-frame-design'; + } + return $classes; +}); + +add_filter('the_content', function($content) { + if (is_page() && in_the_loop() && is_main_query()) { + $hide_title = get_post_meta(get_the_ID(), 'ansico_cv_hide_title', true); + $frame_design = get_post_meta(get_the_ID(), 'ansico_cv_frame_design', true); + if ($frame_design) { + $title_html = ''; + if (!$hide_title) { + $title_html = '