D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
vblioqus
/
safa777.info
/
wp-content
/
themes
/
infopediya
/
inc
/
Filename :
helper-methods.php
back
Copy
<?php /** * Custom helper methods for this theme * Eventually, some of the functionality here could be replaced by core features. * @package Files_Custom_Theme */ function infopediya_get_img_alt_text() { $img_url = get_the_post_thumbnail_url(); $image_id = get_post_thumbnail_id(get_the_ID()); $alt_text = get_post_meta($image_id, '_wp_attachment_image_alt', true); if (!$alt_text) : $alt_text = 'featured-image'; endif; return $alt_text; } function infopediya_menu_items($location = 'menu-1') { $menu_items = []; $menuLocations = get_nav_menu_locations(); if ($menuLocations): $menuID = $menuLocations[$location]; $menu_items = wp_get_nav_menu_items($menuID); endif; return $menu_items; } function get_custom_logo_url() { $custom_logo_id = get_theme_mod( 'custom_logo' ); $image = wp_get_attachment_image_src( $custom_logo_id , 'full' ); return $image[0]; } if (!function_exists('stcustom_posted_on')) : /** * Prints HTML with meta information for the current post-date/time and author. */ function stcustom_posted_on() { $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; if (get_the_time('U') !== get_the_modified_time('U')) { $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>'; } $time_string = sprintf( $time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()) ); $posted_on = sprintf( /* translators: %s: post date. */ esc_html_x('Posted on %s', 'post date', 'infopediya'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>' ); $byline = sprintf( /* translators: %s: post author. */ esc_html_x('by %s', 'post author', 'infopediya'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>' ); echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK. } endif; if (!function_exists('infopediya_posted_on_date')) : /** * Prints HTML with meta information for the current post-date/time and author. */ function infopediya_posted_on_date() { $time_string = '<time class="entry-date published updated" datetime="%1$s">%1$s</time>'; if (get_the_time('U') !== get_the_modified_time('U')) { $time_string = '<time class="entry-date published" datetime="%1$s">%1$s</time><time class="updated" datetime="%3$s">%4$s</time>'; } $time_string = sprintf( $time_string, esc_attr(get_the_date('F j, y')), esc_html(get_the_date()), esc_attr(get_the_modified_date('F j, y')), esc_html(get_the_modified_date()) ); $posted_on = sprintf($time_string); echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK. } endif; if (!function_exists('infopediya_entry_footer')) : /** * Prints HTML with meta information for the categories, tags and comments. */ function infopediya_entry_footer() { // Hide category and tag text for pages. if ('post' === get_post_type()) { /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list(esc_html__(', ', 'infopediya')); if ($categories_list) { /* translators: 1: list of categories. */ printf('<span class="cat-links">' . esc_html__('Posted in %1$s', 'infopediya') . '</span>', $categories_list); // WPCS: XSS OK. } /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list('', esc_html_x(', ', 'list item separator', 'infopediya')); if ($tags_list) { /* translators: 1: list of tags. */ printf('<span class="tags-links">' . esc_html__('Tagged %1$s', 'infopediya') . '</span>', $tags_list); // WPCS: XSS OK. } } if (!is_single() && !post_password_required() && (comments_open() || get_comments_number())) { echo '<span class="comments-link">'; comments_popup_link( sprintf( wp_kses( /* translators: %s: post title */ __('Leave a Comment<span class="screen-reader-text"> on %s</span>', 'infopediya'), array( 'span' => array( 'class' => array(), ), ) ), get_the_title() ) ); echo '</span>'; } edit_post_link( sprintf( wp_kses( /* translators: %s: Name of current post. Only visible to screen readers */ __('Edit <span class="screen-reader-text">%s</span>', 'infopediya'), array( 'span' => array( 'class' => array(), ), ) ), get_the_title() ), '<span class="edit-link">', '</span>' ); } endif; function cetegory_with_link() { $categories_list = get_the_category_list(esc_html__(', ', 'infopediya')); if ($categories_list) { /* translators: 1: list of categories. */ printf('<span class="cat-links">' . esc_html__('%1$s', 'infopediya') . '</span>', $categories_list); // WPCS: XSS OK. } } /********************* * PAGE NAVI *********************/ // Numeric Page Navi (built into the theme by default) function infopediya_page_navi() { global $wp_query; $bignum = 999999999; if ($wp_query->max_num_pages <= 1) { return; } echo '<nav class="pagination">'; echo paginate_links(array( 'base' => str_replace($bignum, '%#%', esc_url(get_pagenum_link($bignum))), 'format' => '', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages, 'prev_text' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16"> <path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z"/> </svg>', 'next_text' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16"> <path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8z"/> </svg>', 'type' => 'list', 'end_size' => 1, 'mid_size' => 1 )); echo '</nav>'; } /* end page navi */ function infopediya_downloads_count($id) { $current_count = get_post_meta($id, '_infopediya_download_count', true); if (isset($current_count) && $current_count != 0) { $new_value = (int)$current_count + 1; } else { $new_value = 0; } if ($new_value == 0) { update_post_meta($id, '_infopediya_download_count', 1); } else { update_post_meta($id, '_infopediya_download_count', $new_value); } } function infopediya_views_count($id) { $current_count = get_post_meta($id, '_infopediya_views_count', true); if (isset($current_count) && $current_count != 0) { $new_value = $current_count++; } else { $new_value = 0; } if ($new_value == 0) { update_post_meta($id, '_infopediya_views_count', 1); } else { update_post_meta($id, '_infopediya_views_count', $new_value); } } function infopediya_show_download_count($id) { $downloads = get_post_meta($id, '_infopediya_download_count', true); if (isset($downloads) && $downloads != 0) { $downloads = $downloads; } else { $downloads = 0; } $downloads_formatted = number_format($downloads); print_r($downloads_formatted); } function infopediya_show_views_count($id) { $views = get_post_meta($id, '_infopediya_views_count', true); if (isset($views) && $views != 0) { $views = $views; } else { $views = 0; } $views_formatted = number_format($views); print_r($views_formatted); } /** * Filter the excerpt length to 30 words. * * @param int $length Excerpt length. * @return int (Maybe) modified excerpt length. */ function infopediya_custom_excerpt_length($excerpt) { if (has_excerpt()) { $excerpt = wp_trim_words(get_the_excerpt(), apply_filters("excerpt_length", 30)); } return $excerpt; } add_filter("the_excerpt", "infopediya_custom_excerpt_length", 10);