Advertisement
firoze

functions.php of levigraphic

Jun 3rd, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.08 KB | None | 0 0
  1. <?php
  2. /* -----------------------------------------------------------------------------------
  3. Here we have all the custom functions for the theme
  4. Please be extremely cautious editing this file,
  5. When things go wrong, they tend to go wrong in a big way.
  6. You have been warned!
  7. ----------------------------------------------------------------------------------- */
  8. /*
  9. * When using a child theme you can override certain functions (those wrapped
  10. * in a function_exists() call) by defining them first in your child theme's
  11. * functions.php file. The child theme's functions.php file is included before
  12. * the parent theme's file, so the child theme functions would be used.
  13. *
  14. * @link http://codex.wordpress.org/Theme_Development
  15. * @link http://codex.wordpress.org/Child_Themes
  16. ----------------------------------------------------------------------------------- */
  17. define('IMIC_THEME_PATH', get_template_directory_uri());
  18. define('IMIC_FILEPATH', get_template_directory());
  19. /* -------------------------------------------------------------------------------------
  20. Load Translation Text Domain
  21. ----------------------------------------------------------------------------------- */
  22. add_action('after_setup_theme', 'imic_theme_setup');
  23. function imic_theme_setup() {
  24. load_theme_textdomain('framework', IMIC_FILEPATH . '/language');
  25. }
  26. /* -------------------------------------------------------------------------------------
  27. Menu option
  28. ----------------------------------------------------------------------------------- */
  29. function imic_register_menu() {
  30. register_nav_menu('primary-menu', __('Primary Menu', 'framework'));
  31. register_nav_menu('top-menu', __('Top Menu', 'framework'));
  32. register_nav_menu('footer-menu', __('Footer Menu', 'framework'));
  33. }
  34. add_action('init', 'imic_register_menu');
  35. /* -------------------------------------------------------------------------------------
  36. Set Max Content Width (use in conjuction with ".entry-content img" css)
  37. ----------------------------------------------------------------------------------- */
  38. if (!isset($content_width))
  39. $content_width = 680;
  40. /* -------------------------------------------------------------------------------------
  41. Configure WP2.9+ Thumbnails & gets the current post type in the WordPress Admin
  42. ----------------------------------------------------------------------------------- */
  43. if (function_exists('add_theme_support')) {
  44. $post_type_name = '';
  45. if (isset($_GET['post'])) {
  46. $post_type_name = get_post_type($_GET['post']);
  47. }
  48. if (isset($_REQUEST['post_type'])) {
  49. $post_type_name = sanitize_key($_REQUEST['post_type']);
  50. }
  51. if ($post_type_name == 'gallery') {
  52. add_theme_support('post-formats', array(
  53. 'video', 'image', 'gallery', 'link'
  54. ));
  55. }
  56. add_theme_support('post-thumbnails');
  57. add_theme_support('automatic-feed-links');
  58. set_post_thumbnail_size(958, 9999);
  59. add_image_size('80x80','80','80',true);
  60. add_image_size('1280x525','1280','525',true);
  61. add_image_size('800x534','800','534',true);
  62. add_image_size('600x400','600','400',true);
  63. add_image_size('100x100','100','100',true);
  64. add_image_size('1280x258','1280','258',true);
  65. add_image_size('1000x400','1000','400',true);
  66. add_image_size('800x600','800','600',true);
  67. add_image_size('1000x800','800','600',true);
  68. add_theme_support('woocommerce');
  69. }
  70. /* -------------------------------------------------------------------------------------
  71. Custom Gravatar Support
  72. ----------------------------------------------------------------------------------- */
  73. if (!function_exists('imic_custom_gravatar')) {
  74. function imic_custom_gravatar($avatar_defaults) {
  75. $imic_avatar = get_template_directory_uri() . '/images/img_avatar.png';
  76. $avatar_defaults[$imic_avatar] = 'Custom Gravatar (/images/img_avatar.png)';
  77. return $avatar_defaults;
  78. }
  79. add_filter('avatar_defaults', 'imic_custom_gravatar');
  80. }
  81. /* -------------------------------------------------------------------------------------
  82. Load Theme Options
  83. ----------------------------------------------------------------------------------- */
  84. require_once(IMIC_FILEPATH . '/includes/reduxcore/framework.php');
  85. require_once(IMIC_FILEPATH . '/includes/sample/sample-config.php');
  86. include_once(IMIC_FILEPATH . '/imic-framework/imic-framework.php');
  87. /* -------------------------------------------------------------------------------------
  88. For Paginate
  89. ----------------------------------------------------------------------------------- */
  90. if (!function_exists('imic_pagination')) {
  91. function imic_pagination($pages = '', $range = 4, $pagination='',$status='future') {
  92. $showitems = ($range * 2) + 1;
  93. global $paged;
  94. if (empty($paged))
  95. $paged = 1;
  96. if ($pages == '') {
  97. global $wp_query;
  98. $pages = $wp_query->max_num_pages;
  99. if (!$pages) {
  100. $pages = 1;
  101. }
  102. }
  103. $first = ($status=='past')?'<li class="pull-right"><a href="'.get_pagenum_link($paged+1).'">'.__('Newer','framework').' &rarr; </a></li>':'<li class="pull-left"><a href="'.get_pagenum_link($paged-1).'">&larr; '.__('Older','framework').'</a></li>';
  104. $second = ($status!='past')?'<li class="pull-right"><a href="'.get_pagenum_link($paged+1).'">'.__('Newer','framework').' &rarr;</a></li>':'<li class="pull-left"><a href="'.get_pagenum_link($paged-1).'">&larr; '.__('Older','framework').'</a></li>';
  105. if (1 != $pages) {
  106. if($pagination=='Default') {
  107. echo '<ul class="pager">';
  108. if(($paged!='')&&($paged!=1)) {
  109. echo $second; }
  110. if($pages!=$paged) {
  111. echo $first; }
  112. echo '</ul>';
  113. }
  114. else {
  115. echo '<ul class="pagination">';
  116. echo '<li><a href="' . get_pagenum_link(1) . '" title="'.__('First','framework').'"><i class="fa fa-chevron-left"></i></a></li>';
  117. for ($i = 1; $i <= $pages; $i++) {
  118. if (1 != $pages && (!($i >= $paged + $range + 3 || $i <= $paged - $range - 3) || $pages <= $showitems )) {
  119. echo ($paged == $i) ? "<li class=\"active\"><span>" . $i . "</span></li>" : "<li><a href='" . get_pagenum_link($i) . "' class=\"\">" . $i . "</a></li>";
  120. }
  121. }
  122. echo '<li><a href="' . get_pagenum_link($pages) . '" title="'.__('Last','framework').'"><i class="fa fa-chevron-right"></i></a></li>';
  123. echo '</ul>'; }
  124. }
  125. }
  126. }
  127. /* -------------------------------------------------------------------------------------
  128. For Remove Dimensions from thumbnail image
  129. ----------------------------------------------------------------------------------- */
  130. add_filter('post_thumbnail_html', 'imic_remove_thumbnail_dimensions', 10);
  131. add_filter('image_send_to_editor', 'imic_remove_thumbnail_dimensions', 10);
  132. function imic_remove_thumbnail_dimensions($html) {
  133. $html = preg_replace('/(width|height)=\"\d*\"\s/', "", $html);
  134. return $html;
  135. }
  136. /* -------------------------------------------------------------------------------------
  137. Excerpt More and length
  138. ----------------------------------------------------------------------------------- */
  139. if (!function_exists('imic_custom_read_more')) {
  140. function imic_custom_read_more() {
  141. return '';
  142. }
  143. }
  144. if (!function_exists('imic_excerpt')) {
  145. function imic_excerpt($limit = 50) {
  146. return '<p>' . wp_trim_words(get_the_excerpt(), $limit, imic_custom_read_more()) . '</p>';
  147. }
  148. }
  149. /* Comment Styling
  150. /*----------------------------------------------------------------------------------- */
  151. if (!function_exists('imic_comment')) {
  152. function imic_comment($comment, $args, $depth) {
  153. $isByAuthor = false;
  154. if ($comment->comment_author_email == get_the_author_meta('email')) {
  155. $isByAuthor = true;
  156. }
  157. $GLOBALS['comment'] = $comment;
  158. ?>
  159. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  160. <div class="post-comment-block">
  161. <div id="comment-<?php comment_ID(); ?>">
  162. <div class="img-thumbnail"><?php echo get_avatar($comment, $size = '40'); ?></div>
  163. <?php
  164. echo preg_replace('/comment-reply-link/', 'comment-reply-link pull-right', get_comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => '<i class="fa fa-reply"></i>'))), 1);
  165. echo '<h5>' . get_comment_author() .__(' says','framework').'</h5>';
  166. ?>
  167. <span class="meta-data">
  168. <?php
  169. echo get_comment_date();
  170. _e(' at ', 'framework');
  171. echo get_comment_time();
  172. ?>
  173. </span>
  174. <?php if ($comment->comment_approved == '0') : ?>
  175. <em class="moderation"><?php _e('Your comment is awaiting moderation.', 'framework') ?></em>
  176. <br />
  177. <?php endif; ?>
  178. <div class="comment-text"><?php comment_text() ?></div>
  179. </div>
  180. </div>
  181. <?php
  182. }
  183. }
  184. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement