PageRenderTime 43ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/themes/OneMozilla/functions.php

https://github.com/fvignals/One-Mozilla-blog
PHP | 649 lines | 592 code | 17 blank | 40 comment | 17 complexity | 0d13b3f996d2494211328e6b06fa8023 MD5 | raw file
  1. <?php
  2. if ( ! function_exists( 'onemozilla_setup' ) ):
  3. /**
  4. * Sets up theme defaults and registers support for various WordPress features.
  5. *
  6. * To override onemozilla_setup() in a child theme, add your own onemozilla_setup to your child theme's
  7. * functions.php file.
  8. *
  9. * @uses load_theme_textdomain() For translation/localization support.
  10. * @uses add_editor_style() To style the visual editor.
  11. * @uses add_theme_support() To add support for post thumbnails.
  12. * @uses register_nav_menus() To add support for navigation menus.
  13. * @uses add_custom_background() To add support for a custom background.
  14. * @uses add_custom_image_header() To add support for a custom header.
  15. * @uses register_default_headers() To register the default custom header images provided with the theme.
  16. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  17. *
  18. */
  19. function onemozilla_setup() {
  20. /* Make the theme available for translation.
  21. * Translations can be added to the /languages/ directory.
  22. */
  23. load_theme_textdomain( 'onemozilla', get_template_directory() . '/languages' );
  24. $locale = get_locale();
  25. $locale_file = get_template_directory() . "/languages/$locale.php";
  26. if ( is_readable( $locale_file ) )
  27. require_once( $locale_file );
  28. // Load up our theme options page and related code.
  29. require( get_template_directory() . '/inc/theme-options.php' );
  30. // This theme uses wp_nav_menu() in one location.
  31. register_nav_menu( 'primary', __( 'Primary Menu', 'onemozilla' ) );
  32. // This theme uses Featured Images (also known as post thumbnails)
  33. add_theme_support( 'post-thumbnails' );
  34. // Set default image sizes
  35. update_option('thumbnail_size_w', 160);
  36. update_option('thumbnail_size_h', 160);
  37. update_option('medium_size_w', 252);
  38. update_option('medium_size_h', 0);
  39. update_option('large_size_w', 600);
  40. update_option('large_size_h', 0);
  41. // The height and width of your custom header.
  42. // Add a filter to onemozilla_header_image_width and onemozilla_header_image_height to change these values.
  43. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'onemozilla_header_image_width', 340 ) );
  44. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'onemozilla_header_image_height', 240 ) );
  45. // Add a way for the custom header to be styled in the admin panel that controls
  46. // custom headers. See onemozilla_admin_header_style(), below.
  47. add_custom_image_header( 'onemozilla_header_style', 'onemozilla_admin_header_style', 'onemozilla_admin_header_image' );
  48. // Disable the header text and color options
  49. define( 'NO_HEADER_TEXT', true );
  50. // ... and thus ends the changeable header business.
  51. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  52. register_default_headers( array(
  53. 'firefox' => array(
  54. 'url' => '%s/img/headers/firefox.png',
  55. 'thumbnail_url' => '%s/img/headers/firefox-thumbnail.png',
  56. /* L10N: header image description */
  57. 'description' => __( 'Firefox Logo', 'onemozilla' )
  58. )
  59. )
  60. );
  61. }
  62. endif; // onemozilla_setup
  63. /*********
  64. * Tell WordPress to run onemozilla_setup() when the 'after_setup_theme' hook is run.
  65. */
  66. add_action( 'after_setup_theme', 'onemozilla_setup' );
  67. /*********
  68. * Adds classes to the array of post classes. We'll use these as style hooks for post headers.
  69. */
  70. function onemozilla_post_classes( $classes ) {
  71. $options = onemozilla_get_theme_options();
  72. $comment_count = get_comments_number($post->ID);
  73. if ( $options['hide_author'] != 1 ) {
  74. $classes[] = 'show-author';
  75. }
  76. elseif ( $options['hide_author'] == 1 ) {
  77. $classes[] = 'no-author';
  78. }
  79. if ( comments_open($post->ID) || pings_open($post->ID) || ($comment_count > 0) ) {
  80. $classes[] = 'show-comments';
  81. }
  82. elseif ( !comments_open($post->ID) && !pings_open($post->ID) && ($comment_count == 0) ) {
  83. $classes[] = 'no-comments';
  84. }
  85. if ( $options['share_posts'] == 1 ) {
  86. $classes[] = 'show-sharing';
  87. }
  88. return $classes;
  89. }
  90. add_filter( 'post_class', 'onemozilla_post_classes' );
  91. /*********
  92. * Use auto-excerpts for meta description if hand-crafted exerpt is missing
  93. */
  94. function fc_meta_desc() {
  95. $post_desc_length = 25; // auto-excerpt length in number of words
  96. global $cat, $cache_categories, $wp_query, $wp_version;
  97. if(is_single() || is_page()) {
  98. $post = $wp_query->post;
  99. $post_custom = get_post_custom($post->ID);
  100. if(!empty($post->post_excerpt)) {
  101. $text = $post->post_excerpt;
  102. } else {
  103. $text = $post->post_content;
  104. }
  105. $text = str_replace(array("\r\n", "\r", "\n", " "), " ", $text);
  106. $text = str_replace(array("\""), "", $text);
  107. $text = trim(strip_tags($text));
  108. $text = explode(' ', $text);
  109. if(count($text) > $post_desc_length) {
  110. $l = $post_desc_length;
  111. $ellipsis = '...';
  112. } else {
  113. $l = count($text);
  114. $ellipsis = '';
  115. }
  116. $description = '';
  117. for ($i=0; $i<$l; $i++)
  118. $description .= $text[$i] . ' ';
  119. $description .= $ellipsis;
  120. }
  121. elseif(is_category()) {
  122. $category = $wp_query->get_queried_object();
  123. if (!empty($category->category_description)) {
  124. $description = trim(strip_tags($category->category_description));
  125. } else {
  126. $description = single_cat_title('Articles posted in ');
  127. }
  128. }
  129. else {
  130. $description = trim(strip_tags(get_bloginfo('description')));
  131. }
  132. if($description) {
  133. echo $description;
  134. }
  135. }
  136. /*********
  137. * Disable the embedded styles when using [gallery] shortcode
  138. */
  139. add_filter( 'use_default_gallery_style', '__return_false' );
  140. /*********
  141. * Disable comments on Pages by default
  142. *
  143. * This is a hack. WP doesn't currently make it possible to enable comments
  144. * by default for Posts while disabling them for Pages; it's either comments on
  145. * all or comments on none. But in most cases authors will prefer to turn off
  146. * comments for Pages. This just unchecks those checkboxes automatically so authors
  147. * don't need to remember. Comments can still be enabled for Pages on an individual
  148. * basis.
  149. */
  150. function fc_page_comments_off() {
  151. if(isset($_REQUEST['post_type'])) {
  152. if ( $_REQUEST['post_type'] == "page" ) {
  153. echo '<script>
  154. if (document.post) {
  155. var opt_comment = document.post.comment_status;
  156. var opt_ping = document.post.ping_status;
  157. if (the_comment && the_ping) {
  158. the_comment.checked = false;
  159. the_ping.checked = false;
  160. }
  161. }
  162. </script>';
  163. }
  164. }
  165. }
  166. add_action ( 'admin_footer', 'fc_page_comments_off' );
  167. /*********
  168. * Prints the page number currently being browsed, with a pipe before it.
  169. * Used in header.php to add the page number to the <title>.
  170. */
  171. if ( ! function_exists( 'fc_page_number' ) ) :
  172. function fc_page_number() {
  173. global $paged; // Contains page number.
  174. if ( $paged >= 2 )
  175. echo ' | ' . sprintf( __( 'Page %s' , 'wordpress' ), $paged );
  176. }
  177. endif;
  178. /*********
  179. * Allow uploading some additional MIME types
  180. */
  181. function fc_add_mimes( $mimes=array() ) {
  182. $mimes['webm'] = 'video/webm';
  183. $mimes['ogv'] = 'video/ogg';
  184. $mimes['mp4'] = 'video/mp4';
  185. $mimes['m4v'] = 'video/mp4';
  186. $mimes['flv'] = 'video/x-flv';
  187. return $mimes;
  188. }
  189. add_filter('upload_mimes', 'fc_add_mimes');
  190. /*********
  191. * Load various JavaScripts
  192. */
  193. function onemozilla_load_scripts() {
  194. // Load the default jQuery
  195. wp_enqueue_script('jquery');
  196. // Register and load the socialsharing script
  197. wp_register_script( 'socialshare', get_template_directory_uri() . '/js/socialshare.min.js' );
  198. $options = onemozilla_get_theme_options();
  199. if ( ($options['share_posts'] === 1) && is_singular() ) {
  200. wp_enqueue_script( 'socialshare' );
  201. }
  202. // Load the threaded comment reply script
  203. if ( get_option('thread_comments') && is_singular() ) {
  204. wp_enqueue_script( 'comment-reply' );
  205. }
  206. // Check required fields on comment form
  207. wp_register_script( 'checkcomments', get_template_directory_uri() . '/js/fc-checkcomment.js' );
  208. if ( get_option('require_name_email') && is_singular() ) {
  209. wp_enqueue_script('checkcomments');
  210. }
  211. }
  212. add_action( 'wp_enqueue_scripts', 'onemozilla_load_scripts' );
  213. /*********
  214. * Remove WP version from head (helps us evade spammers/hackers)
  215. */
  216. remove_action('wp_head', 'wp_generator');
  217. /*********
  218. * Removes the default styles that are packaged with the Recent Comments widget.
  219. */
  220. function onemozilla_remove_recent_comments_style() {
  221. add_filter( 'show_recent_comments_widget_style', '__return_false' );
  222. }
  223. add_action( 'widgets_init', 'onemozilla_remove_recent_comments_style' );
  224. /*********
  225. * Customize the password protected form
  226. */
  227. function fc_password_form() {
  228. global $post;
  229. $label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
  230. $output = '<form class="pwform" action="' . get_option('siteurl') . '/wp-pass.php" method="post">
  231. <p>'.__("This post is password protected. To view it, please enter the password.", "onemozilla").'</p>
  232. <ol><li><label for="'.$label.'">'.__("Password", "onemozilla").'</label><input name="post_password" id="'.$label.'" type="password" size="20" /></li><li><button type="submit" name="Submit">'.esc_attr__("Submit").'</button></li></ol>
  233. </form>';
  234. return $output;
  235. }
  236. add_filter('the_password_form', 'fc_password_form');
  237. if ( ! function_exists( 'onemozilla_header_style' ) ) :
  238. /**
  239. * Styles the header image on the blog
  240. */
  241. function onemozilla_header_style() {
  242. if (get_header_image()) :
  243. ?>
  244. <style type="text/css">
  245. #masthead { background-image: url(<?php header_image(); ?>); }
  246. </style>
  247. <?php
  248. endif;
  249. }
  250. endif; // onemozilla_header_style
  251. if ( ! function_exists( 'onemozilla_admin_header_style' ) ) :
  252. /**
  253. * Styles the header image displayed on the Appearance > Header admin panel.
  254. * Referenced via add_custom_image_header() in onemozilla_setup().
  255. */
  256. function onemozilla_admin_header_style() {
  257. if (function_exists('onemozilla_get_theme_options')) { // fail gracefully if we can't get theme options
  258. $options = onemozilla_get_theme_options(); // get the theme options
  259. }
  260. $header_image = get_header_image();
  261. ?>
  262. <style type="text/css">
  263. @import url(<?php echo get_template_directory_uri() . '/colors/'.$options['color_scheme'].'/'.$options['color_scheme'].'-header-preview.css'; ?>);
  264. #header-preview .header {
  265. background: url("<?php echo esc_url( $header_image ); ?>") right top no-repeat;
  266. }
  267. </style>
  268. <?php
  269. }
  270. endif; // onemozilla_admin_header_style
  271. if ( ! function_exists( 'onemozilla_admin_header_image' ) ) :
  272. /**
  273. * Custom header image markup displayed on the Appearance > Header admin panel.
  274. * Referenced via add_custom_image_header() in onemozilla_setup().
  275. */
  276. function onemozilla_admin_header_image() { ?>
  277. <div id="header-preview">
  278. <div class="header">
  279. <h1 id="site-title"><?php bloginfo( 'name' ); ?></h1>
  280. <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
  281. <span id="faux-tabzilla">Mozilla</span>
  282. </div>
  283. </div>
  284. <?php }
  285. endif; // onemozilla_admin_header_image
  286. /**
  287. * Enable featured posts
  288. */
  289. function fc_featured_meta_box($post){
  290. $featured = get_post_meta($post->ID, '_fc_featuredpost', true);
  291. ?>
  292. <label class="selectit" for="fc_featuredpost">
  293. <input type="checkbox" name="_fc_featuredpost" id="fc_featuredpost" value="1" <?php if ($featured) { ?>checked<?php } ?> />
  294. <?php _e('Feature this post?', 'onemozilla'); ?></label>
  295. <?php
  296. }
  297. function register_fc_featuredpost(){
  298. add_meta_box('meta-featured-post', __('Featured Post'), 'fc_featured_meta_box', 'post', 'side', 'low');
  299. }
  300. add_action('admin_init', 'register_fc_featuredpost', 1);
  301. function save_fc_featuredpost() {
  302. global $post;
  303. update_post_meta($post->ID, "_fc_featuredpost", $_POST["_fc_featuredpost"]);
  304. }
  305. add_action('save_post', 'save_fc_featuredpost');
  306. /**
  307. * Enable a few more buttons in the visual editor
  308. */
  309. function add_more_buttons($buttons) {
  310. $buttons[] = 'hr';
  311. $buttons[] = 'del';
  312. $buttons[] = 'sub';
  313. $buttons[] = 'sup';
  314. $buttons[] = 'cleanup';
  315. return $buttons;
  316. }
  317. add_filter("mce_buttons_3", "add_more_buttons");
  318. /**
  319. * Sets the post excerpt length to 40 words.
  320. *
  321. * To override this length in a child theme, remove the filter and add your own
  322. * function tied to the excerpt_length filter hook.
  323. */
  324. function onemozilla_excerpt_length( $length ) {
  325. return 40;
  326. }
  327. add_filter( 'excerpt_length', 'onemozilla_excerpt_length' );
  328. /**
  329. * Returns a "Continue Reading" link for excerpts
  330. */
  331. function onemozilla_continue_reading_link() {
  332. return ' <a class="go" href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading', 'onemozilla' ) . '</a>';
  333. }
  334. /**
  335. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and onemozilla_continue_reading_link().
  336. *
  337. * To override this in a child theme, remove the filter and add your own
  338. * function tied to the excerpt_more filter hook.
  339. */
  340. function onemozilla_auto_excerpt_more( $more ) {
  341. return ' &hellip;' . onemozilla_continue_reading_link();
  342. }
  343. add_filter( 'excerpt_more', 'onemozilla_auto_excerpt_more' );
  344. /**
  345. * Adds a pretty "Continue Reading" link to custom post excerpts.
  346. *
  347. * To override this link in a child theme, remove the filter and add your own
  348. * function tied to the get_the_excerpt filter hook.
  349. */
  350. function onemozilla_custom_excerpt_more( $output ) {
  351. if ( has_excerpt() && ! is_attachment() ) {
  352. $output .= onemozilla_continue_reading_link();
  353. }
  354. return $output;
  355. }
  356. add_filter( 'get_the_excerpt', 'onemozilla_custom_excerpt_more' );
  357. /**
  358. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  359. */
  360. function onemozilla_page_menu_args( $args ) {
  361. $args['show_home'] = true;
  362. return $args;
  363. }
  364. add_filter( 'wp_page_menu_args', 'onemozilla_page_menu_args' );
  365. /**
  366. * Register the widgetized sidebar.
  367. */
  368. function onemozilla_widgets_init() {
  369. register_sidebar( array(
  370. 'name' => __( 'Sidebar', 'onemozilla' ),
  371. 'id' => 'sidebar',
  372. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  373. 'after_widget' => "</aside>",
  374. 'before_title' => '<h3 class="widget-title">',
  375. 'after_title' => '</h3>',
  376. ) );
  377. }
  378. add_action( 'widgets_init', 'onemozilla_widgets_init' );
  379. /**********
  380. * Determine if the page is paged and should show posts navigation
  381. */
  382. function fc_show_posts_nav() {
  383. global $wp_query;
  384. return ($wp_query->max_num_pages > 1) ? TRUE : FALSE;
  385. }
  386. /*********
  387. * Determine if a previous post exists (i.e. that this isn't the first one)
  388. *
  389. * @param bool $in_same_cat Optional. Whether link should be in same category.
  390. * @param string $excluded_categories Optional. Excluded categories IDs.
  391. */
  392. function fc_previous_post($in_same_cat = false, $excluded_categories = '') {
  393. if ( is_attachment() )
  394. $post = & get_post($GLOBALS['post']->post_parent);
  395. else
  396. $post = get_previous_post($in_same_cat, $excluded_categories);
  397. if ( !$post )
  398. return false;
  399. else
  400. return true;
  401. }
  402. /*********
  403. * Determine if a next post exists (i.e. that this isn't the last post)
  404. *
  405. * @param bool $in_same_cat Optional. Whether link should be in same category.
  406. * @param string $excluded_categories Optional. Excluded categories IDs.
  407. */
  408. function fc_next_post($in_same_cat = false, $excluded_categories = '') {
  409. if ( is_attachment() )
  410. $post = & get_post($GLOBALS['post']->post_parent);
  411. else
  412. $post = get_next_post($in_same_cat, $excluded_categories);
  413. if ( !$post )
  414. return false;
  415. else
  416. return true;
  417. }
  418. /*********
  419. * Customize the login screen
  420. */
  421. function fc_custom_login() {
  422. echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('template_directory') . '/css/login.css">';
  423. }
  424. add_action('login_head', 'fc_custom_login');
  425. /*********
  426. * Style the visual editor to match the theme styles
  427. * onemozilla_get_theme_options() is defined in /inc/theme-options.php
  428. * If you add new color schemes, remember to include an editor style sheet!
  429. * Otherwise this will return a 404 and you'll only get default styling.
  430. */
  431. function fc_editor_style($url) {
  432. if ( !empty($url) ) {
  433. $url .= ',';
  434. }
  435. if (function_exists('onemozilla_get_theme_options')) { // fail gracefully if we can't get theme options
  436. $options = onemozilla_get_theme_options(); // get the theme options
  437. }
  438. if ($options['color_scheme']) { // if we have a color scheme, use its editor stylesheet
  439. $url .= trailingslashit( get_template_directory_uri() ) . 'colors/'.$options['color_scheme'].'/'.$options['color_scheme'].'-editor-style.css';
  440. }
  441. else { // fall back to the default
  442. $url .= trailingslashit( get_template_directory_uri() ) . 'colors/stone/stone-editor-style.css';
  443. }
  444. return $url;
  445. }
  446. add_filter('mce_css', 'fc_editor_style');
  447. /*********
  448. * Comment Template
  449. */
  450. if ( ! function_exists( 'onemozilla_comment' ) ) :
  451. function onemozilla_comment($comment, $args, $depth) {
  452. $GLOBALS['comment'] = $comment;
  453. $comment_type = get_comment_type();
  454. $date_format = get_option("date_format");
  455. $time_format = get_option("time_format");
  456. ?>
  457. <li id="comment-<?php comment_ID(); ?>" <?php comment_class('hentry'); ?>>
  458. <?php if ( $comment_type == 'trackback' ) : ?>
  459. <h3 class="entry-title"><?php _e( 'Trackback from ', 'onemozilla' ); ?> <cite><?php esc_html(comment_author_link()); ?></cite>
  460. <?php /* L10N: Trackback headings read "Trackback from <Site> on <Date> at <Time>:" */ ?>
  461. <span class="comment-meta"><?php _e('on', 'onemozilla'); ?>
  462. <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" rel="bookmark" title=" <?php _e('Permanent link to this comment by ','onemozilla'); comment_author(); ?>">
  463. <time class="published" datetime="<?php comment_date('Y-m-d'); ?>" title="<?php comment_date('Y-m-d'); ?>">
  464. <?php /* L10N: Trackback headings read "Trackback from <Site> on <Date> at <Time>:" */ ?>
  465. <?php printf( __('%1$s at %2$s','onemozilla'), get_comment_date($date_format), get_comment_time($time_format) ); ?></time></a>:</span></time></a>:</span>
  466. </h3>
  467. <?php elseif ( $comment_type == 'pingback' ) : ?>
  468. <h3 class="entry-title"><?php _e( 'Pingback from ', 'onemozilla' ); ?> <cite><?php esc_html(comment_author_link()); ?></cite>
  469. <?php /* L10N: Pingback headings read "Pingback from <Site> on <Date> at <Time>:" */ ?>
  470. <span class="comment-meta"><?php _e('on', 'onemozilla'); ?>
  471. <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" rel="bookmark" title="<?php _e('Permanent link to this comment by ','onemozilla'); comment_author(); ?>">
  472. <time class="published" datetime="<?php comment_date('Y-m-d'); ?>" title="<?php comment_date('Y-m-d'); ?>">
  473. <?php /* L10N: Pingback headings read "Pingback from <Site> on <Date> at <Time>:" */ ?>
  474. <?php printf( __('%1$s at %2$s','onemozilla'), get_comment_date($date_format), get_comment_time($time_format) ); ?></time></a>:</span></time></a>:</span>
  475. </h3>
  476. <?php else : ?>
  477. <?php if ( ( $comment->comment_author_url != "http://" ) && ( $comment->comment_author_url != "" ) ) : // if author has a link ?>
  478. <h3 class="entry-title vcard">
  479. <a href="<?php comment_author_url(); ?>" class="url" rel="nofollow external" title="<?php esc_html(comment_author_url()); ?>">
  480. <cite class="author fn"><?php esc_html(comment_author()); ?></cite>
  481. <?php if (function_exists('get_avatar')) : echo ('<span class="photo">'.get_avatar( $comment, 48 ).'</span>'); endif; ?>
  482. </a>
  483. <span class="comment-meta">
  484. <?php /* L10N: Comment headings read "<Name> wrote on <Date> at <Time>:" */ ?>
  485. <?php _e('wrote on', 'onemozilla'); ?>
  486. <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" rel="bookmark" title="<?php _e('Permanent link to this comment by ','onemozilla'); comment_author(); ?>">
  487. <time class="published" datetime="<?php comment_date('Y-m-d'); ?>" title="<?php comment_date('Y-m-d'); ?>">
  488. <?php /* L10N: Comment headings read "<Name> wrote on <Date> at <Time>:" */ ?>
  489. <?php printf( __('%1$s at %2$s','onemozilla'), get_comment_date($date_format), get_comment_time($time_format) ); ?></time></a>:</span></time></a>:</span>
  490. </h3>
  491. <?php else : // author has no link ?>
  492. <h3 class="entry-title vcard">
  493. <cite class="author fn"><?php esc_html(comment_author()); ?></cite>
  494. <?php if (function_exists('get_avatar')) : echo ('<span class="photo">'.get_avatar( $comment, 48 ).'</span>'); endif; ?>
  495. <span class="comment-meta"><?php _e('wrote on', 'onemozilla'); ?>
  496. <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" rel="bookmark" title="<?php _e('Permanent link to this comment by ','onemozilla'); comment_author(); ?>">
  497. <time class="published" datetime="<?php comment_date('Y-m-d'); ?>" title="<?php comment_date('Y-m-d'); ?>">
  498. <?php /* L10N: Comment headings read "<Name> wrote on <Date> at <Time>:" */ ?>
  499. <?php printf( __('%1$s at %2$s','onemozilla'), get_comment_date($date_format), get_comment_time($time_format) ); ?></time></a>:</span>
  500. </h3>
  501. <?php endif; ?>
  502. <?php endif; ?>
  503. <?php if ($comment->comment_approved == '0') : ?>
  504. <p class="mod"><strong><?php _e('Your comment is awaiting moderation.', 'onemozilla'); ?></strong></p>
  505. <?php endif; ?>
  506. <blockquote class="entry-content">
  507. <?php esc_html(comment_text()); ?>
  508. </blockquote>
  509. <?php if ( (get_option('thread_comments') == true) || (current_user_can('edit_post', $comment->comment_post_ID)) ) : ?>
  510. <p class="comment-util"><?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> <?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) : ?><span class="edit"><?php edit_comment_link(__('Edit Comment','onemozilla'),'',''); ?></span><?php endif; ?></p>
  511. <?php endif; ?>
  512. <?php
  513. } /* end onemozilla_comment */
  514. endif;
  515. /*********
  516. * Featured posts widget for sidebar
  517. */
  518. class moz_widget_featuredPosts extends WP_Widget {
  519. function widget($args,$instance) {
  520. $args['title'] = $instance['title'];
  521. moz_featuredPosts($args);
  522. }
  523. function moz_widget_featuredPosts() {
  524. $widget_options = array(
  525. 'description'=>__('This widget shows the three most recent featured posts.')
  526. );
  527. $this->WP_Widget('moz_widget_featuredPosts','Featured Posts',$widget_options);
  528. }
  529. function update($new_instance, $old_instance) {
  530. return $new_instance;
  531. }
  532. function form($instance) {
  533. $title = esc_attr($instance['title']);
  534. ?>
  535. <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'wordpress'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
  536. <?php
  537. }
  538. }
  539. function moz_featuredPosts($args) {
  540. $title = $args['title'];
  541. if ( !is_front_page() ) :
  542. /* Set up a custom loop for the three most recent featured posts */
  543. $featured = new WP_Query( array('posts_per_page' => 3, 'meta_key' => '_fc_featuredpost', 'meta_value' => 1) );
  544. if( $featured->have_posts() ) : ?>
  545. <aside class="widget featured-posts">
  546. <?php if ($title) : ?>
  547. <h3 class="widget-title"><?php echo $title; ?></h3>
  548. <?php endif; ?>
  549. <ul class="hfeed">
  550. <?php while($featured->have_posts()): $featured->the_post(); ?>
  551. <li id="feature-<?php the_ID(); ?>" class="hentry feature">
  552. <h4 class="entry-title entry-summary">
  553. <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permanent link to “%s”', 'onemozilla' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
  554. <span class="feature-img">
  555. <?php if (has_post_thumbnail()) : ?>
  556. <?php the_post_thumbnail(array(115,115), array('alt' => "", 'title' => "")); ?>
  557. <?php else : ?>
  558. <img src="<?php echo get_stylesheet_directory_uri(); ?>/img/featured.png" alt="" width="115" height="115" class="wp-post-image">
  559. <?php endif; ?>
  560. </span>
  561. <?php the_title(); ?>
  562. </a>
  563. </h4>
  564. </li>
  565. <?php endwhile; ?>
  566. </ul>
  567. </aside>
  568. <?php else: endif;
  569. endif;
  570. }
  571. function featuredposts_widget_init() {
  572. register_widget("moz_widget_featuredPosts");
  573. }
  574. add_action("widgets_init","featuredposts_widget_init");
  575. ?>