register_hooks(); } /** * Registers the hooks for displaying the content of Elementor templates * in the page templates. * * @since 1.0.0 */ public function register_hooks() { add_action('abcbiz_single_post_content', array($this, 'single_post_content_elementor'), 999); add_action('abcbiz_single_page_content', array($this, 'single_page_content_elementor'), 999); add_action('abcbiz_404_page_content', array($this, 'single_404_page_content_elementor'), 999); add_action('abcbiz_search_page_content', array($this, 'search_page_content_elementor'), 999); add_action('abcbiz_archive_page_content', array($this, 'archive_page_content_elementor'), 999); } /** * Single post content hook for Elementor template. * * If an Elementor template exists for the 'single_post' type, it will be rendered. * Otherwise, the post content will be rendered using the_content(). * * @param WP_Post $post The post object. */ public function single_post_content_elementor($post) { $template_id = ABCBizThemeBuilder::get_template_id('single_post'); if (!empty($template_id)) { echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display($template_id); } else { the_content(); } } /** * Single page content hook for Elementor template. * * If an Elementor template exists for the 'single_page' type, it will be rendered. * Otherwise, the page content will be rendered using the_content(). * * @param WP_Post $page The page object. * * @since 1.0.0 */ public function single_page_content_elementor($page) { $template_id = ABCBizThemeBuilder::get_template_id('single_page'); if (!empty($template_id)) { echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display($template_id); } else { the_content(); } } /** * Hook for rendering the 404 page content for Elementor template. * * If an Elementor template exists for the '404_page' type, it will be rendered. * Otherwise, a fallback content will be rendered including the search title, search form, and a list of search results. * * @param WP_Query $error The error query object. */ public function single_404_page_content_elementor($error) { $template_id = ABCBizThemeBuilder::get_template_id('404_page'); if (!empty($template_id)) { echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display($template_id); } else { '

404

'; '

' . esc_html__('Search Results', 'abcbiz-addons') . '

'; get_search_form(); if (have_posts()) { while (have_posts()) { the_post(); echo '' . get_the_title() . ''; } } } } /** * Renders the content for archive page using Elementor template if available. * * @param array $archive Archive data. * * @since 1.0.0 */ public function archive_page_content_elementor($archive) { $template_id = ABCBizThemeBuilder::get_template_id('archive_page'); // Check if a template exists in Elementor for 'archive_page' if (!empty($template_id)) { echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display($template_id); } else { // Fallback if no Elementor template is found echo '

' . esc_html(get_the_archive_title()) . '

'; // Check if there are posts in the archive if (have_posts()) { echo '
'; while (have_posts()) { the_post(); echo '
'; echo '

' . get_the_title() . '

'; echo '
' . get_the_excerpt() . '
'; echo '
'; } echo '
'; // Add pagination echo '
'; the_posts_pagination(array( 'prev_text' => __('Previous', 'abcbiz-addons'), 'next_text' => __('Next', 'abcbiz-addons'), )); echo '
'; } else { // Message if no posts are found echo '

' . esc_html__('No posts found in this archive.', 'abcbiz-addons') . '

'; } } } }