WordPress theme for Friendica site at https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.4 KiB

5 years ago
  1. <?php
  2. add_action('after_setup_theme', 'friendica_setup');
  3. function friendica_setup()
  4. {
  5. load_theme_textdomain('friendica', get_template_directory() . '/languages');
  6. add_theme_support('title-tag');
  7. add_theme_support('automatic-feed-links');
  8. add_theme_support('post-thumbnails');
  9. global $content_width;
  10. if (!isset($content_width)) $content_width = 640;
  11. register_nav_menus(array(
  12. 'main-menu' => __('Main Menu', 'friendica')
  13. ));
  14. }
  15. add_action('wp_enqueue_scripts', 'friendica_load_scripts');
  16. function friendica_load_scripts()
  17. {
  18. $basedir = get_template_directory_uri() . '/assets/js/';
  19. wp_deregister_script('jquery'); //let's use our jsquery.
  20. wp_enqueue_script('jquery', $basedir.'jquery.min.js', array(), "1.11.3", true);
  21. wp_enqueue_script('skel', $basedir.'skel.min.js', array(), "3.0.1", true);
  22. wp_enqueue_script('friendica.util', $basedir.'util.js', array('jquery'), "1.0.0", true);
  23. wp_enqueue_script('friendica.main', $basedir.'main.js', array('friendica.util'), "1.0.0", true);
  24. }
  25. add_action('comment_form_before', 'friendica_enqueue_comment_reply_script');
  26. function friendica_enqueue_comment_reply_script()
  27. {
  28. if (get_option('thread_comments')) {
  29. wp_enqueue_script('comment-reply');
  30. }
  31. }
  32. add_filter('the_title', 'friendica_title');
  33. function friendica_title($title)
  34. {
  35. if ($title == '') {
  36. return '&rarr;';
  37. }
  38. else {
  39. return $title;
  40. }
  41. }
  42. add_filter('wp_title', 'friendica_filter_wp_title');
  43. function friendica_filter_wp_title($title)
  44. {
  45. return $title . esc_attr(get_bloginfo('name'));
  46. }
  47. add_action('widgets_init', 'friendica_widgets_init');
  48. function friendica_widgets_init()
  49. {
  50. register_sidebar(array(
  51. 'name' => __('Sidebar Widget Area', 'friendica') ,
  52. 'id' => 'primary-widget-area',
  53. 'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
  54. 'after_widget' => "</div>",
  55. 'before_title' => '<h3 class="widget-title">',
  56. 'after_title' => '</h3>',
  57. ));
  58. }
  59. function friendica_custom_pings($comment)
  60. {
  61. $GLOBALS['comment'] = $comment;
  62. ?>
  63. <li <?php
  64. comment_class(); ?> id="li-comment-<?php
  65. comment_ID(); ?>"><?php
  66. echo comment_author_link(); ?></li>
  67. <?php
  68. }
  69. add_filter('get_comments_number', 'friendica_comments_number');
  70. function friendica_comments_number($count)
  71. {
  72. if (!is_admin()) {
  73. global $id;
  74. $comments_by_type = & separate_comments(get_comments('status=approve&post_id=' . $id));
  75. return count($comments_by_type['comment']);
  76. }
  77. else {
  78. return $count;
  79. }
  80. }