' . get_seo_title() . ''; if (!empty(get_seo_description())) echo ''; if (is_single() && !empty(get_post_meta(get_the_ID(), "_keywords_meta", true))) echo ''; } function get_my_avatar_url($author_id) { return get_user_meta($author_id, "custom_avatar_url", true) ?: get_avatar_url($author_id); } function custom_additional_styles() { wp_dequeue_style('wp-block-library'); $post_type = ""; if (is_single()) { $post_type = "single"; echo ''; } elseif (is_category()) { $post_type = "category"; } elseif (is_author()) { $post_type = "author"; } elseif (is_home()) { $post_type = "index"; } elseif (is_search()) { $post_type = "search"; } elseif (is_404()) { $post_type = "404"; } elseif (is_page()) { echo ''; if (is_page_template('contact.php')) { $post_type = "contact"; } else if (is_page_template('sitemap.php')) { $post_type = "sitemap"; } else { $post_type = "page"; } } wp_enqueue_style("single", get_template_directory_uri() . '/assets/css/' . $post_type . '.min.css'); } function custom_additional_scripts() { if (is_single()) { echo ''; } elseif (is_page_template('contact.php')) { echo ''; echo ''; } echo ''; } function dom_xpath() { $content = get_the_content(); $dom = new DOMDocument(); $dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'), LIBXML_NOERROR); return new DOMXpath($dom); } function get_my_dom() { $content = get_the_content(); $dom = new DOMDocument(); return $dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'), LIBXML_NOERROR); } function get_elem_value($xpath, $elem_path, $doc_context) { $elem = $xpath->query($elem_path, $doc_context)[0]; if (empty($elem)) { return ""; } else { return $elem->nodeValue; } } function get_elem_attribute($xpath, $elem_path, $doc_context, $attribute) { $elem = $xpath->query($elem_path, $doc_context)[0]; if (empty($elem)) { return ""; } else { return $elem->getAttribute($attribute); } } function the_custom_excerpt() { global $post; echo wp_trim_words($post->post_content, 12, '...'); } function get_the_updated_time($format = '') { $_format = (!empty($format) ? $format : get_option('date_format')); return get_the_modified_date($_format); } function hasToc($tiers, $content) { $pattern = '/]*)>(.*?)<\/h([2-' . $tiers . '])>/'; $return = array(); if (empty($content)) return null; if (!preg_match_all($pattern, $content, $return)) { return false; } return $return; } function auto_id_headings($content) { if (is_single() || is_page()) { $content = preg_replace_callback('/(\(.*)(<\/h[2-3]>)/i', function ($matches) { if (!stripos($matches[0], 'id=')) : $matches[0] = $matches[1] . $matches[2] . ' id="' . sanitize_title($matches[3]) . '">' . $matches[3] . $matches[4]; endif; return $matches[0]; }, $content); } $content = str_replace("[related_box_img]", get_theme_mod("setting_related_box", ""), $content); return $content; } function the_svg($name) { echo get_the_svg($name); } function get_the_svg($name) { switch ($name): case "chevron_right": return ' '; break; case 'twitter': return ' '; break; case "facebook": return ' '; break; case "youtube": return ' '; break; case 'pinterest': return ' '; break; case 'download': return ' '; break; case 'calender': return ' '; break; case 'comments': return ' '; break; case 'expand_more': return ' '; break; case 'more_horiz': return ' '; break; case 'cancel': return ' '; break; case 'tick': return ' '; break; case 'product': return ' '; break; case 'faqs': return ' '; break; case 'conclusion': return ' '; break; case 'summary': return ' '; break; case "tumblr": return ' '; break; case "linkedin": return ' '; break; case 'arrow_right': return ' '; break; endswitch; } function wpb_set_post_views($postID) { $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, true); if ($count == '') { $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); } else { $count++; update_post_meta($postID, $count_key, $count); } } function wps_deregister_styles() { wp_dequeue_style('wp-block-library'); } function add_menu_atts($atts, $item, $args) { $atts['property'] = 'url'; return $atts; } function faq_schema() { $index = 1; $faqs_schema = ""; $xpath = dom_xpath(); $faqs = []; $elem_faqs = $xpath->query('//div[contains(@class,"faqs")]//div[contains(@class,"faq")]'); foreach ($elem_faqs as $elem_faq) { $question = get_elem_value($xpath, './/p[contains(@class,"faq__question")]', $elem_faq); $answer = get_elem_value($xpath, './/p[contains(@class,"faq__answer")]', $elem_faq); $faq = (object) array( "index" => $index, "question" => $question, "answer" => $answer ); $faqs[] = $faq; $index++; } foreach ($faqs as $faq) { $faqs_schema .= '{ "@type": "Question", "name": "' . $faq->question . '", "acceptedAnswer": { "@type": "Answer", "text": "' . $faq->answer . '" } }' . ($faq->index != count($faqs) ? "," : ""); } if (!empty($faqs)) { return ',{ "@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [ ' . $faqs_schema . ' ] }'; } else { return ""; } } function add_schema() { $site_name = get_bloginfo("name"); $home_url = home_url("/"); $image = get_my_custom_logo(); if (is_home()) { ?> '; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if (!empty($twitter_handle)) echo ''; // Fix this add this option to theme settings echo ''; echo ''; if (is_single()) { $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); if (has_post_thumbnail()) { echo ''; echo ''; echo ''; echo ''; } echo ''; echo ''; } else if (is_author()) { echo ''; echo ''; echo ''; echo ''; } else { $custom_logo = get_my_custom_logo(); if ($custom_logo) { echo ''; echo ''; echo ''; echo ''; } } } function my_custom_customizer_settings($wp_customize) { $wp_customize->add_panel('panel_post_settings', array( 'title' => __('Post Settings', 'affiliatepress'), 'description' => "", 'priority' => 159, )); $wp_customize->add_section('section_footer', array( 'title' => __('Footer', 'affiliatepress'), 'priority' => 160, )); $wp_customize->add_section('section_post_default_settings', array( 'title' => __("Post Defaults", 'affiliatepress'), 'panel' => 'panel_post_settings', 'priority' => 1, )); $wp_customize->add_section('section_post_other_settings', array( 'title' => __("Other Settings", 'affiliatepress'), 'panel' => 'panel_post_settings', 'priority' => 2, )); $wp_customize->add_section('section_site_settings', array( 'title' => __('Site Settings', 'affiliatepress'), 'priority' => 158, )); $wp_customize->add_setting('setting_footer_logo', array( 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_company_text', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_copyright_text', array( 'default' => sprintf('%%site_title%% © %%current_year%%. All rights reserved. Designed By %2$s.', get_theme_mod('theme_author_uri'), get_theme_mod('theme_author')), 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting("setting_disqus_shortname", array( 'default' => '#', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting("setting_social_youtube", array( 'default' => '#', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting("setting_social_facebook", array( 'default' => '#', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting("setting_social_twitter", array( 'default' => '#', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting("setting_social_tumblr", array( 'default' => '#', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting("setting_social_linkedin", array( 'default' => '#', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_related_box', array( 'transport' => 'refresh', 'height' => 40, 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_dmca_link', array( 'default' => '#', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_twitter_handle', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_visibility_comments', array( 'default' => true, 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_visibility_featured_image', array( 'default' => true, 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_visibility_title', array( 'default' => true, 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_visibility_sidebar_popular_posts', array( 'default' => true, 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_affiliate_disclosure', array( 'default' => true, 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_cookie_consent', array( 'default' => false, 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_cookie_consent_text', array( 'default' => "This website uses cookies in order to offer you the most relavant information.", 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_page_sidebar', array( 'default' => false, 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_setting('setting_latest_posts_section', array( 'default' => false, 'sanitize_callback' => 'sanitize_text_field' )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'control_footer_logo', array( 'label' => __('Footer Logo', 'affiliatepress'), 'section' => 'section_footer', 'settings' => 'setting_footer_logo', ))); $wp_customize->add_control("control_company_text", array( 'label' => __('Footer Company Text', 'affiliatepress'), 'type' => 'textarea', 'section' => 'section_footer', 'settings' => "setting_company_text" )); $wp_customize->add_control("control_copyright_text", array( 'label' => __('Footer Copyright Text', 'affiliatepress'), 'type' => 'textarea', 'section' => 'section_footer', 'settings' => "setting_copyright_text" )); $wp_customize->add_control("control_social_youtube", array( 'label' => __('Youtube Social Link', 'affiliatepress'), 'type' => 'url', 'section' => 'section_footer', 'settings' => "setting_social_youtube" )); $wp_customize->add_control("control_social_facebook", array( 'label' => __('Facebook Social Link', 'affiliatepress'), 'type' => 'url', 'section' => 'section_footer', 'settings' => "setting_social_facebook" )); $wp_customize->add_control("control_social_twitter", array( 'label' => __('Twitter Social Link', 'affiliatepress'), 'type' => 'url', 'section' => 'section_footer', 'settings' => "setting_social_twitter" )); $wp_customize->add_control("control_social_tumblr", array( 'label' => __('Tumblr Social Link', 'affiliatepress'), 'type' => 'url', 'section' => 'section_footer', 'settings' => "setting_social_tumblr" )); $wp_customize->add_control("control_social_linkedin", array( 'label' => __('LinkedIn Social Link', 'affiliatepress'), 'type' => 'url', 'section' => 'section_footer', 'settings' => "setting_social_linkedin" )); $wp_customize->add_control("control_dmca_link", array( 'label' => __('DMCA Link', 'affiliatepress'), 'type' => 'url', 'section' => 'section_footer', 'settings' => "setting_dmca_link" )); $wp_customize->add_control("control_disqus_shortname", array( 'label' => __('Disqus Shortname', 'affiliatepress'), 'type' => 'url', 'section' => 'section_post_other_settings', 'settings' => "setting_disqus_shortname" )); $wp_customize->add_control("control_twitter_handle", array( 'label' => __('Twitter Handle', 'affiliatepress'), 'description' => 'Used to add "twitter:site" meta tag in head. e.g. "@abc"', 'type' => 'text', 'section' => 'section_post_other_settings', 'settings' => "setting_twitter_handle" )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'control_related_box', array( 'label' => __('Related Article Icon', 'affiliatepress'), 'section' => 'section_post_other_settings', 'settings' => 'setting_related_box', ))); $wp_customize->add_control("control_visibility_comments", array( 'label' => __('Show Comments', 'affiliatepress'), 'type' => 'checkbox', 'section' => 'section_post_default_settings', 'settings' => "setting_visibility_comments" )); $wp_customize->add_control("control_visibility_featured_image", array( 'label' => __('Show Featured Image', 'affiliatepress'), 'type' => 'checkbox', 'section' => 'section_post_default_settings', 'settings' => "setting_visibility_featured_image" )); $wp_customize->add_control("control_visibility_title", array( 'label' => __('Show Post Title', 'affiliatepress'), 'type' => 'checkbox', 'section' => 'section_post_default_settings', 'settings' => "setting_visibility_title" )); $wp_customize->add_control("control_visibility_sidebar_popular_posts", array( 'label' => __('Show Sidebar Popular Posts', 'affiliatepress'), 'type' => 'checkbox', 'section' => 'section_post_default_settings', 'settings' => "setting_visibility_sidebar_popular_posts" )); $wp_customize->add_control("control_affiliate_disclosure", array( 'label' => __('Show Affiliate Closure', 'affiliatepress'), 'type' => 'checkbox', 'section' => 'section_post_other_settings', 'settings' => "setting_affiliate_disclosure" )); $wp_customize->add_control("control_cookie_consent", array( 'label' => __('Show Cookies Consent', 'affiliatepress'), 'type' => 'checkbox', 'section' => 'section_site_settings', 'settings' => "setting_cookie_consent" )); $wp_customize->add_control("control_cookie_consent_text", array( 'label' => __('Cookies Consent Text', 'affiliatepress'), 'type' => 'textarea', 'section' => 'section_site_settings', 'settings' => "setting_cookie_consent_text" )); } function wp_head_data() { social_meta(); add_seo(); add_schema(); } function my_register_sidebars() { register_sidebar(array( 'id' => 'primary', 'name' => __('Post Sidebar', 'affiliatepress'), 'description' => __('A short description of the sidebar.', 'affiliatepress'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); } function get_post_meta_default($postID, $key) { return get_post_meta($postID, $key, true) ?: "default"; } function before_page_layout() { $page_sidebar = get_theme_mod("setting_page_sidebar", false); if ($page_sidebar != false && is_page()) { echo '
'; echo '
'; } } function after_page_layout() { $page_sidebar = get_theme_mod("setting_page_sidebar", false); if ($page_sidebar != false && is_page()) { echo '
'; get_sidebar(); echo '
'; } }; add_action('before_page', 'before_page_layout', 0, 0); add_action('after_page', 'after_page_layout', 0, 0); add_action('widgets_init', 'my_register_sidebars'); add_action("wp_head", "wp_head_data"); add_action('customize_register', 'my_custom_customizer_settings'); add_filter('nav_menu_link_attributes', 'add_menu_atts', 10, 3); add_filter('the_content', 'auto_id_headings'); add_action("wp_enqueue_scripts", "custom_additional_styles"); add_action('after_setup_theme', 'basic_support'); add_action("init", "add_menu_locations"); add_action('wp_footer', 'custom_additional_scripts'); add_theme_support( 'automatic-feed-links' ); add_theme_support( "title-tag" ); add_theme_support( "wp-block-styles" ); add_theme_support( "responsive-embeds" ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script' ) ); add_theme_support( 'custom-background' ); add_theme_support( "align-wide" ); add_action('wp_enqueue_scripts', function() { if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } }); include_once(get_template_directory() . "/assets/options/post-options.php"); include_once(get_template_directory() . "/assets/options/seo.php"); include_once(get_template_directory() . "/gutenberg-blocks/blocks.php"); include_once(get_template_directory() . "/assets/options/category-options.php"); include_once(get_template_directory() . "/assets/options/user-options.php");