ID, 'magnitude-meta-content-alignment', true); if (!empty($post_options)) { $page_layout = $post_options; } else { $page_layout = $global_alignment; } } if (is_front_page() || is_home()) { $frontpage_layout = magnitude_get_option('frontpage_content_alignment'); if (!empty($frontpage_layout)) { $page_layout = $frontpage_layout; } else { $page_layout = $global_alignment; } } if ($page_layout == 'align-content-right') { if (is_front_page()) { if (is_page_template('tmpl-front-page.php')) { if (is_active_sidebar('home-sidebar-widgets')) { $classes[] = 'align-content-right'; } else { $classes[] = 'full-width-content'; } } else { if (is_active_sidebar('sidebar-1')) { $classes[] = 'align-content-right'; } else { $classes[] = 'full-width-content'; } } } else { if (is_active_sidebar('sidebar-1')) { $classes[] = 'align-content-right'; } else { $classes[] = 'full-width-content'; } } } elseif ($page_layout == 'full-width-content') { $classes[] = 'full-width-content'; } else { if (is_front_page()) { if (is_page_template('tmpl-front-page.php')) { if (is_active_sidebar('home-sidebar-widgets')) { $classes[] = 'align-content-left'; } else { $classes[] = 'full-width-content'; } } else { if (is_active_sidebar('sidebar-1')) { $classes[] = 'align-content-left'; } else { $classes[] = 'full-width-content'; } } } else { if (is_active_sidebar('sidebar-1')) { $classes[] = 'align-content-left'; } else { $classes[] = 'full-width-content'; } } } $banner_layout = magnitude_get_option('global_site_layout_setting'); if ($banner_layout == 'boxed') { $classes[] = 'af-boxed-layout'; } elseif ($banner_layout == 'wide') { $classes[] = 'af-wide-layout'; } else { $classes[] = ''; } return $classes; } add_filter('body_class', 'magnitude_body_classes'); function magnitude_is_elementor() { global $post; return \Elementor\Plugin::$instance->db->is_built_with_elementor($post->ID); } /** * Add a pingback url auto-discovery header for singularly identifiable articles. */ function magnitude_pingback_header() { if (is_singular() && pings_open()) { echo ''; } } add_action('wp_head', 'magnitude_pingback_header'); /** * Returns posts. * * @since Magnitude 1.0.0 */ if (!function_exists('magnitude_get_posts')): function magnitude_get_posts($number_of_posts, $category = '0') { if (is_front_page()) { $paged = (get_query_var('page')) ? get_query_var('page') : 1; } else { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; } $ins_args = array( 'post_type' => 'post', 'posts_per_page' => absint($number_of_posts), // 'paged' => $paged, 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true ); $category = isset($category) ? $category : '0'; if (absint($category) > 0) { $ins_args['cat'] = absint($category); } $all_posts = new WP_Query($ins_args); return $all_posts; } endif; /** * Returns no image url. * * @since Magnitude 1.0.0 */ if (!function_exists('magnitude_post_format')): function magnitude_post_format($post_id) { $post_format = get_post_format($post_id); switch ($post_format) { case "image": $post_format = "
"; break; case "video": $post_format = "
"; break; case "gallery": $post_format = "
"; break; default: $post_format = ""; } echo $post_format; } endif; if (!function_exists('magnitude_get_block')) : /** * * @param null * * @return null * * @since Magnitude 1.0.0 * */ function magnitude_get_block($block = 'grid', $section = 'post') { get_template_part('inc/hooks/blocks/block-' . $section, $block); } endif; if (!function_exists('magnitude_archive_title')) : /** * * @param null * * @return null * * @since Magnitude 1.0.0 * */ function magnitude_archive_title($title) { if (is_category()) { $title = single_cat_title('', false); } elseif (is_tag()) { $title = single_tag_title('', false); } elseif (is_author()) { $title = '' . get_the_author() . ''; } elseif (is_post_type_archive()) { $title = post_type_archive_title('', false); } elseif (is_tax()) { $title = single_term_title('', false); } return $title; } endif; add_filter('get_the_archive_title', 'magnitude_archive_title'); /* Display Breadcrumbs */ if (!function_exists('magnitude_get_breadcrumb')) : /** * Simple breadcrumb. * * @since 1.0.0 */ function magnitude_get_breadcrumb() { $enable_breadcrumbs = magnitude_get_option('enable_breadcrumb'); if (1 != $enable_breadcrumbs) { return; } // Bail if Home Page. if (is_front_page() || is_home()) { return; } if (!function_exists('breadcrumb_trail')) { /** * Load libraries. */ require_once get_template_directory() . '/lib/breadcrumb-trail/breadcrumb-trail.php'; } $breadcrumb_args = array( 'container' => 'div', 'show_browse' => false, ); ?>
' . $global_read_more_texts . ''; if (trim($default_excerpt) !== '') { return $default_excerpt . $read_more; } $global_excerpt_length = magnitude_get_option('global_excerpt_length'); return wp_trim_words($content, $global_excerpt_length, $read_more); } endif; /* Display Pagination */ if (!function_exists('magnitude_numeric_pagination')) : /** * Simple excerpt more. * * @since 1.0.0 */ function magnitude_numeric_pagination() { $pagination_type = magnitude_get_option('archive_pagination_view'); switch ($pagination_type) { case 'archive-default': the_posts_pagination(array( 'mid_size' => 3, 'prev_text' => __('Previous', 'magnitude'), 'next_text' => __('Next', 'magnitude'), )); break; default: break; } return; } endif; /* Word read count Pagination */ if (!function_exists('magnitude_count_content_words')) : /** * @param $content * * @return string */ function magnitude_count_content_words($post_id) { $show_read_mins = magnitude_get_option('global_show_min_read'); if ($show_read_mins == 'yes') { $content = apply_filters('the_content', get_post_field('post_content', $post_id)); $read_words = magnitude_get_option('global_show_min_read_number'); $decode_content = html_entity_decode($content); $filter_shortcode = do_shortcode($decode_content); $strip_tags = wp_strip_all_tags($filter_shortcode, true); $count = str_word_count($strip_tags); $word_per_min = (absint($count) / $read_words); $word_per_min = ceil($word_per_min); if (absint($word_per_min) > 0) { $word_count_strings = sprintf(_n('%s min read', '%s min read', number_format_i18n($word_per_min), 'magnitude'), number_format_i18n($word_per_min)); if ('post' == get_post_type($post_id)): echo ''; echo esc_html($word_count_strings); echo ''; endif; } } } endif; /** * Check if given term has child terms * * @param Integer $term_id * @param String $taxonomy * * @return Boolean */ function magnitude_list_popular_taxonomies($taxonomy = 'post_tag', $title = "Popular Tags", $number = 5) { $popular_taxonomies = get_terms(array( 'taxonomy' => $taxonomy, 'number' => absint($number), 'orderby' => 'count', 'order' => 'DESC', 'hide_empty' => true, )); $html = ''; if (isset($popular_taxonomies) && !empty($popular_taxonomies)): $html .= ''; endif; echo $html; } /** * @param $post_id * @param string $size * * @return mixed|string */ function magnitude_get_freatured_image_url($post_id, $size = 'magnitude-featured') { if (has_post_thumbnail($post_id)) { $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size); $url = $thumb['0']; } else { $url = ''; } return $url; } //Get attachment alt tag if (!function_exists('magnitude_get_img_alt')): function magnitude_get_img_alt($attachment_ID) { // Get ALT $thumb_alt = get_post_meta($attachment_ID, '_wp_attachment_image_alt', true); // No ALT supplied get attachment info if (empty($thumb_alt)) $attachment = get_post($attachment_ID); // Use caption if no ALT supplied if (empty($thumb_alt)) $thumb_alt = $attachment->post_excerpt; // Use title if no caption supplied either if (empty($thumb_alt)) $thumb_alt = $attachment->post_title; // Return ALT return trim(strip_tags($thumb_alt)); } endif; // Move Jetpack from the_content / the_excerpt using shortcode function jptweak_remove_share() { remove_filter('the_content', 'sharing_display', 19); remove_filter('the_excerpt', 'sharing_display', 19); } add_action('loop_start', 'jptweak_remove_share'); /** * @param $post_id */ function magnitude_get_comments_views_share($post_id) { ?> 1): ?> get_global_options(); if (in_array('index', $global['show']) && (is_home() || is_front_page() || is_archive() || is_search() || in_array(get_post_type(), $global['show']))): ?>
'; } ?>
'; } endif; } function magnitude_single_post_commtents_view($post_id) { ?>
1): ?>
name; } //Search if (is_search()) { $args['search'] = get_search_query(); } //Author if (is_author()) { $args['author'] = get_the_author_meta('user_nicename'); } //Date archive if (is_date()) { $args['year'] = get_query_var('year'); $args['month'] = get_query_var('monthnum'); $args['day'] = get_query_var('day'); } /* * Categories and taxonomies * Get the affiliated post type for custom taxonomy */ if (is_category() || is_tag() || is_tax()) { $args['cat'] = get_queried_object()->slug; $args['taxonomy'] = get_queried_object()->taxonomy; if (is_tax()) { global $wp_taxonomies; $tax_object = isset($wp_taxonomies[$args['taxonomy']]) ? $wp_taxonomies[$args['taxonomy']]->object_type : array(); $args['post_type'] = array_pop($tax_object); } } return $args; } endif;