term_id ) . '" ' . $show_class . 'title="' . sprintf( __( "View all posts in %s", "acosmin" ), $category[0]->name ) . '" ' . '>' . $category[0]->name.' '; } if( $gpt != 'page') { echo $output_category; } } /* Output comments number /* ------------------------------------ */ function ac_comments_number() { $num_comments = get_comments_number(); $comments = ''; if ( comments_open() ) { if ( $num_comments == 0 ) { $comments = __('0 Comments', 'acosmin'); } elseif ( $num_comments > 1 ) { $comments = $num_comments . __(' Comments', 'acosmin'); } else { $comments = __('1 Comment', 'acosmin'); } } echo $comments; } /* Truncate post title & content /* ------------------------------------ */ // -- Post function ac_truncate_post($amount,$echo=true,$allowable_tags='') { global $post; $truncate = $post->post_content; if ( strlen($truncate) <= $amount ) $echo_out = ''; else $echo_out = ''; // else $echo_out = ' ...' $truncate = apply_filters('the_content', $truncate); $truncate = preg_replace('@@si', '', $truncate); $truncate = preg_replace('@@si', '', $truncate); $truncate = strip_tags($truncate, $allowable_tags); if ($echo_out == '...') $truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ' ')); else $truncate = substr($truncate, 0, $amount); if ($echo) echo $truncate,$echo_out; else return ($truncate . $echo_out); } // -- Title function ac_truncate_title($amount,$echo=true) { global $post; $truncate = $post->post_title; if ( strlen($truncate) <= $amount ) $echo_out = ''; else $echo_out = ' ...'; $truncate = apply_filters('the_title', $truncate); $truncate = preg_replace('@@si', '', $truncate); $truncate = preg_replace('@@si', '', $truncate); $truncate = strip_tags($truncate); if ($echo_out == '...') $truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ' ')); else $truncate = substr($truncate, 0, $amount); if ($echo) echo $truncate,$echo_out; else return ($truncate . $echo_out); } /* Basic template hooks /* ------------------------------------ */ function ac_after_body() { // After the
tag do_action( 'ac_after_body_hook' ); } function ac_before_body_closed() { // Before the tag do_action( 'ac_before_body_closed_hook' ); } /* Check if page is paginated /* ------------------------------------ */ function ac_check_paged() { global $wp_query, $page, $post; if( $page < 2) { return true; } else { return false; } } /* Custom feed url /* ------------------------------------ */ function ac_custom_rss_feed( $output, $feed ) { if ( strpos( $output, 'comments' ) ) return $output; $custom_feed = of_get_option( 'ac_custom_rss_url' ); return esc_url( $custom_feed ); } if ( of_get_option( 'ac_custom_rss_url' ) != '' ) { add_action( 'feed_link', 'ac_custom_rss_feed', 10, 2 ); } /* Favicon /* ------------------------------------ */ function ac_favicon() { $favicon_desktop = of_get_option( 'ac_favicon_desktop' ); $output = ''; if ( $favicon_desktop != '') { echo $output . "\n"; } else { return; } } add_action( 'wp_head', 'ac_favicon', 2); /* Google Analytics code /* ------------------------------------ */ function ac_google_analytics() { $google_analytics = of_get_option( 'ac_google_analytics_code' ); if ( $google_analytics != '') { echo $google_analytics . "\n"; } else { return; } } add_action('ac_after_body_hook', 'ac_google_analytics'); /* Output Facebook SDK /* ------------------------------------ */ function ac_fb_js_sdk() { $facebook_appId = of_get_option( 'ac_facebook_appid' ); if ( $facebook_appId != '' && of_get_option( 'ac_fb_javascript_sdk' ) ) { ?>