Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*******************************
- MENUS SUPPORT
- ********************************/
- if ( function_exists( 'wp_nav_menu' ) ){
- if (function_exists('add_theme_support')) {
- add_theme_support('nav-menus');
- add_action( 'init', 'register_my_menus' );
- function register_my_menus() {
- register_nav_menus(
- array(
- 'primary-menu' => __( 'Primary Menu' ),
- 'secondary-menu' => __( 'Secondary Menu' )
- )
- );
- }
- }
- }
- /*******************************
- IF MODIFIED SINCE HTTP HEADER wp_config
- ********************************/
- add_action('template_redirect', 'cyb_add_last_modified_header');
- function cyb_add_last_modified_header($headers) {
- //Check if we are in a single post of any type (archive pages has not modified date)
- if( is_singular() ) {
- $post_id = get_queried_object_id();
- if( $post_id ) {
- header("Last-Modified: " . get_the_modified_time("D, d M Y H:i:s", $post_id) );
- }
- }
- }
- /*******************************
- DO NOT DISPLAY ADMIN BAR AT ALL
- ********************************/
- add_filter( 'show_admin_bar', '__return_false' );
- add_action( 'admin_print_scripts-profile.php', 'wpbeginner_hide_admin_bar' );
- function wpbeginner_hide_admin_bar() { ?>
- <style type="text/css">
- .show-admin-bar { display: none; }
- </style>
- <?php
- }
- /*******************************
- Remove query strings from static resources
- ********************************/
- function _remove_script_version( $src ){
- $parts = explode( '?ver', $src );
- return $parts[0];
- }
- add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
- add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
- /*******************************
- Remove Jetpack CSS and Javascript
- ********************************/
- function wsis_remove_jetpack_assets() {
- // devicepx-jetpack.js, used to optionally load retina/HiDPI versions of files (Gravatars etc) which are known to support it, for devices that run at a higher resolution.
- wp_dequeue_script( 'devicepx' );
- }
- add_action( 'wp_enqueue_scripts', 'wsis_remove_jetpack_assets', 20 );
- // Remove CSS file, from version 3.2 of Jetpack
- add_filter( 'jetpack_implode_frontend_css', '__return_false' );
- /*******************************
- DISPLAY MY OWN GRAVATAR FOR USERS
- ********************************/
- add_filter( 'avatar_defaults', 'newgravatar' );
- function newgravatar ($avatar_defaults) {
- $myavatar = get_bloginfo('template_directory') . '/images/usericon.png';
- $avatar_defaults[$myavatar] = "ZoomingJapan";
- return $avatar_defaults;
- }
- /*******************************
- FACEBOOK FANS COUNT
- ********************************/
- function diww_fb_fan_count($fb_id){
- $count = get_transient('fan_count');
- if ($count !== false) return $count;
- $count = 0;
- $data = wp_remote_get('http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id='.$fb_id.'');
- if (is_wp_error($data)) {
- return 'Error getting number';
- }else{
- $count = strip_tags($data[body]);
- }
- set_transient('fan_count', $count, 60*60*24); // 24 hour cache
- echo $count;
- }
- /*******************************
- SHOW HIDDEN BUTTONS IN TINYMCE
- ********************************/
- function ilc_mce_buttons($buttons){
- array_push($buttons, "backcolor", "hr", "fontselect", "fontsizeselect", "code", "redo", "undo");
- return $buttons;
- }
- add_filter("mce_buttons", "ilc_mce_buttons");
- /*******************************
- ADD MORE ALLOWED HTML TAGS TO COMMENTS
- ********************************/
- add_filter('comments_open','eg_allow_tags_in_comments');
- // For making it sure, we also force the tags again before comment approval
- add_filter('pre_comment_approved','eg_allow_tags_in_comments');
- function eg_allow_tags_in_comments($data) {
- // This variable is in wp-includes/kses.php file, check it out
- global $allowedtags;
- // You can add HTML tags and their properties by this way
- $allowedtags['span'] = array('style'=>array());
- $allowedtags['big'] = array();
- $allowedtags['small'] = array();
- // And we return our expanded data for comment approval
- return $data; }
- /*******************************
- REMOVE WORDPRESS VERSION NUMBER
- ********************************/
- function wpbeginner_remove_version() {
- return '';
- }
- add_filter('the_generator', 'wpbeginner_remove_version');
- /*******************************
- LIMIT SEARCH: NO PAGES
- ********************************/
- function searchfilter($query) {
- if ($query->is_search) {
- $query->set('post_type',array('post'));
- }
- return $query;
- }
- add_filter('pre_get_posts','searchfilter');
- /*******************************
- OWN TITLE LENGHT
- ********************************/
- function japanworm_get_the_title( $length = null, $id = 0 ) {
- $post = &get_post($id);
- $title = isset($post->post_title) ? $post->post_title : '';
- $id = isset($post->ID) ? $post->ID : (int) $id;
- if ( !is_admin() ) {
- if ( !empty($post->post_password) ) {
- $protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
- $title = sprintf($protected_title_format, $title);
- } else if ( isset($post->post_status) && 'private' == $post->post_status ) {
- $private_title_format = apply_filters('private_title_format', __('Private: %s'));
- $title = sprintf($private_title_format, $title);
- }
- }
- // Shorten the title
- if ( null != $length ) {
- $length = (int) $length;
- $title = substr( $title, 0, $length ); // Only take the first 20 characters
- $title .= " …";
- }
- return apply_filters( 'the_title', $title, $id );
- }
- function japanworm_the_title($before = '', $after = '', $echo = true, $length = null) {
- $title = get_the_title($length);
- if ( strlen($title) == 0 )
- return;
- $title = $before . $title . $after;
- if ( $echo )
- echo $title;
- else
- return $title;
- }
- /*******************************
- JQUERY ENQUEUE
- ********************************/
- function add_async_forscript($url)
- {
- if (strpos($url, '#asyncload')===false)
- return $url;
- else if (is_admin())
- return str_replace('#asyncload', '', $url);
- else
- return str_replace('#asyncload', '', $url)."' async='async";
- }
- add_filter('clean_url', 'add_async_forscript', 11, 1);
- function add_my_javascripts() {
- /* If this is the admin area of WordPress, don't do anything */
- if( is_admin() )
- return;
- /* Register all of our scripts */
- wp_register_script('jquerytools', 'http://zoomingjapan.com/wp-content/themes/alltuts/js/jquery.tools.min.js', array('jquery'),'1',true);
- wp_register_script('jquery-ui-perso', get_template_directory_uri() . '/js/jquery-ui-personalized-1.5.2.packed.js', array('jquery'),'1',true);
- wp_register_script('jquery.form', get_template_directory_uri() . '/js/jquery.form.js', array('jquery'),'1',true);
- wp_register_script('jquery-slides', get_template_directory_uri() . '/js/slides.min.jquery.js', array('jquery'),'1',true);
- wp_register_script('my-slider', get_template_directory_uri() . '/js/my-slider.js', array('jquery', 'jquery-slides'),'1',true);
- wp_register_script('contact-form', get_template_directory_uri() . '/js/contact-form.js', array('jquery', 'jquery.form'),'1',true);
- wp_register_script('custom', get_template_directory_uri() . '/js/custom.js', array('jquery', 'jquery-ui-perso'),'1',true);
- wp_register_style ('theme-css', 'http://zoomingjapan.com/wp-content/themes/alltuts-child/style.css', false,'1.1','all');
- /* Enqueue the ones that need to be enqueued */
- wp_enqueue_style( 'theme-css');
- wp_enqueue_script('custom');
- if ( is_front_page() ) {
- wp_enqueue_script('my-slider');
- }
- if ( is_page( 'contact' ) ) {
- wp_enqueue_script('contact-form');
- }
- }
- add_action('wp_enqueue_scripts', 'add_my_javascripts');
- /*******************************
- DEQUEUE STYLES AND SCRIPTS FROM PLUGINS
- ********************************/
- add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
- function my_deregister_styles() {
- wp_deregister_style( 'wp-polls' );
- }
- add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
- function my_deregister_javascript() {
- if ( !is_single( array( 628, 1007 ) )) {
- wp_deregister_script( 'wp-polls' );
- }
- }
- /*******************************
- BREADCRUMBS
- ********************************/
- function dimox_breadcrumbs() {
- $delimiter = '<span class="delimiter">»</span>';
- $home = 'Home'; // text for the 'Home' link
- $before = '<span class="current">'; // tag before the current crumb
- $after = '</span>'; // tag after the current crumb
- if ( !is_front_page() || is_paged() ) {
- echo '<div id="crumbs">';
- global $post;
- $divider = $delimiter;
- if (is_home()) $divider = '';
- $homeLink = get_bloginfo('url');
- echo '<a href="' . $homeLink . '" rel="nofollow">' . $home . '</a> ' . $delimiter . ' <a href="http://zoomingjapan.com/blog/" rel="nofollow">Blog</a> ' . $divider . ' ';
- if ( is_category() ) {
- global $wp_query;
- $cat_obj = $wp_query->get_queried_object();
- $thisCat = $cat_obj->term_id;
- $thisCat = get_category($thisCat);
- $parentCat = get_category($thisCat->parent);
- if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
- echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after;
- } elseif ( is_day() ) {
- echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
- echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
- echo $before . get_the_time('d') . $after;
- } elseif ( is_month() ) {
- echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
- echo $before . get_the_time('F') . $after;
- } elseif ( is_year() ) {
- echo $before . get_the_time('Y') . $after;
- } elseif ( is_single() && !is_attachment() ) {
- if ( get_post_type() != 'post' ) {
- $post_type = get_post_type_object(get_post_type());
- $slug = $post_type->rewrite;
- echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a> ' . $delimiter . ' ';
- echo $before . get_the_title() . $after;
- } else {
- $cat = get_the_category(); $cat = $cat[0];
- echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
- echo $before . get_the_title() . $after;
- }
- } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
- $post_type = get_post_type_object(get_post_type());
- echo $before . $post_type->labels->singular_name . $after;
- } elseif ( is_attachment() ) {
- $parent = get_post($post->post_parent);
- $cat = get_the_category($parent->ID); $cat = $cat[0];
- echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
- echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter . ' ';
- echo $before . get_the_title() . $after;
- } elseif ( is_page() && !$post->post_parent ) {
- echo $before . get_the_title() . $after;
- } elseif ( is_page() && $post->post_parent ) {
- $parent_id = $post->post_parent;
- $breadcrumbs = array();
- while ($parent_id) {
- $page = get_page($parent_id);
- $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
- $parent_id = $page->post_parent;
- }
- $breadcrumbs = array_reverse($breadcrumbs);
- foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
- echo $before . get_the_title() . $after;
- } elseif ( is_search() ) {
- $searchTerm = get_search_query();
- echo $before . 'Search results for "' . $searchTerm . '"' . $after;
- } elseif ( is_tag() ) {
- echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
- } elseif ( is_author() ) {
- global $author;
- $userdata = get_userdata($author);
- echo $before . 'Articles posted by ' . $userdata->display_name . $after;
- } elseif ( is_404() ) {
- echo $before . 'Error 404' . $after;
- }
- if ( get_query_var('paged') ) {
- if (is_home()) echo ' ' . $delimiter . ' ';
- if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
- echo __('Page') . ' ' . get_query_var('paged');
- if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
- }
- echo '</div>';
- }
- } // end dimox_breadcrumbs()
- /*******************************
- THUMBNAIL SUPPORT
- ********************************/
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 263, 130, true );
- add_image_size( 'homepage-thumb', 198, 132, true );
- add_image_size( 'slider-thumb', 360, 200, true );
- add_image_size( 'latestpost-thumb', 584, 197, true );
- /*******************************
- DISPLAY USER COMMENT COUNT
- ********************************/
- function commentCount() {
- global $wpdb;
- $count = $wpdb->get_var('SELECT COUNT(comment_ID) FROM ' . $wpdb->comments. ' WHERE comment_author_email = "' . get_comment_author_email() . '"');
- echo $count . ' <img src="http://zoomingjapan.com/wp-content/themes/alltuts/images/comment-cat.png" title="comments by this user" alt="comments by this user" width="12" height="11" />';}
- /*******************************
- EXCERPT LENGTH ADJUST
- ********************************/
- function excerpt($limit) {
- $excerpt = explode(' ', get_the_excerpt(), $limit);
- if (count($excerpt)>=$limit) {
- array_pop($excerpt);
- $excerpt = implode(" ",$excerpt).' (...)';
- } else {
- $excerpt = implode(" ",$excerpt);
- }
- $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
- return $excerpt;
- }
- function content($limit) {
- $content = explode(' ', get_the_content(), $limit);
- if (count($content)>=$limit) {
- array_pop($content);
- $content = implode(" ",$content).' (...)';
- } else {
- $content = implode(" ",$content);
- }
- $content = preg_replace('/\[.+\]/','', $content);
- $content = apply_filters('the_content', $content);
- $content = str_replace(']]>', ']]>', $content);
- return $content;
- }
- /*******************************
- TOP NAVIGATION MENU WALKER
- ********************************/
- class description_walker extends Walker_Nav_Menu
- {
- function start_el(&$output, $item, $depth, $args)
- {
- global $wp_query;
- $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
- $class_names = $value = '';
- $classes = empty( $item->classes ) ? array() : (array) $item->classes;
- $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
- $class_names = ' class="'. esc_attr( $class_names ) . '"';
- $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
- $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
- $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
- $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
- $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
- $prepend = '<strong>';
- $append = '</strong>';
- $description = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
- if($depth != 0)
- {
- $description = $append = $prepend = "";
- }
- $item_output = $args->before;
- $item_output .= '<a'. $attributes .'>';
- $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
- $item_output .= $description.$args->link_after;
- $item_output .= '</a>';
- $item_output .= $args->after;
- $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
- }
- }
- /*******************************
- WIDGETS AREAS
- ********************************/
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'sidebar',
- 'id' => 'sidebar-1',
- 'before_widget' => '<div class="rightBox">
- <div class="rightBoxTop"></div>
- <div class="rightBoxMid">',
- 'after_widget' => '</div>
- <div class="rightBoxBottom"></div>
- </div>',
- 'before_title' => '<h2>',
- 'after_title' => '</h2>',
- ));
- register_sidebar(array(
- 'name' => 'footer',
- 'id' => 'sidebar-2',
- 'before_widget' => '<div class="boxFooter">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2>',
- 'after_title' => '</h2>',
- ));
- /*******************************
- PAGINATION
- ********************************
- * Retrieve or display pagination code.
- *
- * The defaults for overwriting are:
- * 'page' - Default is null (int). The current page. This function will
- * automatically determine the value.
- * 'pages' - Default is null (int). The total number of pages. This function will
- * automatically determine the value.
- * 'range' - Default is 3 (int). The number of page links to show before and after
- * the current page.
- * 'gap' - Default is 3 (int). The minimum number of pages before a gap is
- * replaced with ellipses (...).
- * 'anchor' - Default is 1 (int). The number of links to always show at begining
- * and end of pagination
- * 'before' - Default is '<div class="emm-paginate">' (string). The html or text
- * to add before the pagination links.
- * 'after' - Default is '</div>' (string). The html or text to add after the
- * pagination links.
- * 'title' - Default is '__('Pages:')' (string). The text to display before the
- * pagination links.
- * 'next_page' - Default is '__('»')' (string). The text to use for the
- * next page link.
- * 'previous_page' - Default is '__('«')' (string). The text to use for the
- * previous page link.
- * 'echo' - Default is 1 (int). To return the code instead of echo'ing, set this
- * to 0 (zero).
- *
- * @author Eric Martin <eric@ericmmartin.com>
- * @copyright Copyright (c) 2009, Eric Martin
- * @version 1.0
- *
- * @param array|string $args Optional. Override default arguments.
- * @return string HTML content, if not displaying.
- */
- function emm_paginate($args = null) {
- $defaults = array(
- 'page' => null, 'pages' => null,
- 'range' => 3, 'gap' => 3, 'anchor' => 1,
- 'before' => '<div class="emm-paginate">', 'after' => '</div>',
- 'title' => __('Pages:'),
- 'nextpage' => __('»'), 'previouspage' => __('«'),
- 'echo' => 1
- );
- $r = wp_parse_args($args, $defaults);
- extract($r, EXTR_SKIP);
- if (!$page && !$pages) {
- global $wp_query;
- $page = get_query_var('paged');
- $page = !empty($page) ? intval($page) : 1;
- $posts_per_page = intval(get_query_var('posts_per_page'));
- $pages = intval(ceil($wp_query->found_posts / $posts_per_page));
- }
- $output = "";
- if ($pages > 1) {
- $output .= "$before<span class='emm-title'>$title</span>";
- $ellipsis = "<span class='emm-gap'>...</span>";
- if ($page > 1 && !empty($previouspage)) {
- $output .= "<a href='" . get_pagenum_link($page - 1) . "' class='emm-prev'>$previouspage</a>";
- }
- $min_links = $range * 2 + 1;
- $block_min = min($page - $range, $pages - $min_links);
- $block_high = max($page + $range, $min_links);
- $left_gap = (($block_min - $anchor - $gap) > 0) ? true : false;
- $right_gap = (($block_high + $anchor + $gap) < $pages) ? true : false;
- if ($left_gap && !$right_gap) {
- $output .= sprintf('%s%s%s',
- emm_paginate_loop(1, $anchor),
- $ellipsis,
- emm_paginate_loop($block_min, $pages, $page)
- );
- }
- else if ($left_gap && $right_gap) {
- $output .= sprintf('%s%s%s%s%s',
- emm_paginate_loop(1, $anchor),
- $ellipsis,
- emm_paginate_loop($block_min, $block_high, $page),
- $ellipsis,
- emm_paginate_loop(($pages - $anchor + 1), $pages)
- );
- }
- else if ($right_gap && !$left_gap) {
- $output .= sprintf('%s%s%s',
- emm_paginate_loop(1, $block_high, $page),
- $ellipsis,
- emm_paginate_loop(($pages - $anchor + 1), $pages)
- );
- }
- else {
- $output .= emm_paginate_loop(1, $pages, $page);
- }
- if ($page < $pages && !empty($nextpage)) {
- $output .= "<a href='" . get_pagenum_link($page + 1) . "' class='emm-next'>$nextpage</a>";
- }
- $output .= $after;
- }
- if ($echo) {
- echo $output;
- }
- return $output;
- }
- /**
- * Helper function for pagination which builds the page links.
- *
- * @access private
- *
- * @author Eric Martin <eric@ericmmartin.com>
- * @copyright Copyright (c) 2009, Eric Martin
- * @version 1.0
- *
- * @param int $start The first link page.
- * @param int $max The last link page.
- * @return int $page Optional, default is 0. The current page.
- */
- function emm_paginate_loop($start, $max, $page = 0) {
- $output = "";
- for ($i = $start; $i <= $max; $i++) {
- $output .= ($page === intval($i))
- ? "<span class='emm-page emm-current'>$i</span>"
- : "<a href='" . get_pagenum_link($i) . "' class='emm-page'>$i</a>";
- }
- return $output;
- }
- /*******************************
- CUSTOM COMMENTS
- ********************************/
- function mytheme_comment($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment; ?>
- <li <?php comment_class('clearfix'); ?> id="li-comment-<?php comment_ID() ?>">
- <?php echo get_avatar($comment,$size='63'); ?>
- <div id="comment-<?php comment_ID(); ?>">
- <div class="comment-meta commentmetadata clearfix">
- <?php printf(__('<strong>%s</strong>'), get_comment_author_link()) ?> <span class="comment_count"><?php
- commentCount();?></span> <?php edit_comment_link(__('<img src="http://www.zoomingjapan.com/wp-content/themes/alltuts/images/edit.gif" al="edit gif in comments" width="13" height="13" />'),' ','') ?> <span><?php printf(__('%1$s @ %2$s'), get_comment_date('Y/n/j'), get_comment_time('G:i')) ?>
- </span>
- <div class="text">
- <?php comment_text() ?>
- </div>
- </div>
- <?php if ($comment->comment_approved == '0') : ?>
- <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
- <br />
- <?php endif; ?>
- <div class="reply">
- <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> </div>
- <div class="link-to-comment"><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php echo $comment->comment_ID; ?>" rel="external nofollow" title="<?php echo $title; ?>">Link</a></div>
- </div>
- <?php }
- function list_pings($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment;
- ?>
- <li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?>
- <?php }
- function oenology_comment_count( $count ) {
- // Only filter the comments number
- // in the front-end display
- if (
- // WordPress conditional that returns true if
- // the current page is in the WP-Admin back-end
- ! is_admin()
- ) {
- global $id;
- $comments_by_type = &separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
- return count( $comments_by_type['comment'] );
- }
- // Otherwise, when in the WP-Admin
- // back end, don't filter comments
- // number
- else {
- return $count;
- }
- }
- // Hook custom comment number into 'get_comments_number'
- add_filter('get_comments_number', 'oenology_comment_count', 0);
- add_filter('get_comments_number', 'comment_count', 0);
- function comment_count( $count ) {
- if ( ! is_admin() ) {
- global $id;
- $comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
- return count($comments_by_type['comment']);
- } else {
- return $count;
- }
- }
- /*******************************
- THEME OPTIONS PAGE
- ********************************/
- add_action('admin_menu', 'alltuts_theme_page');
- function alltuts_theme_page ()
- {
- if ( count($_POST) > 0 && isset($_POST['alltuts_settings']) )
- {
- $options = array ('logo_img', 'logo_alt','ads','advertise','contact_email','contact_text','cufon','linkedin_link','twitter_user','latest_tweet','number_tweets','facebook_link','keywords','description','analytics','popular_posts', 'copyright');
- foreach ( $options as $opt )
- {
- delete_option ( 'alltuts_'.$opt, $_POST[$opt] );
- add_option ( 'alltuts_'.$opt, $_POST[$opt] );
- }
- }
- add_menu_page(__('Alltuts Options'), __('Alltuts Options'), 'edit_themes', basename(__FILE__), 'alltuts_settings');
- add_submenu_page(__('Alltuts Options'), __('Alltuts Options'), 'edit_themes', basename(__FILE__), 'alltuts_settings');
- }
- function alltuts_settings()
- {?>
- <div class="wrap">
- <h2>AllTuts Options Panel</h2>
- <form method="post" action="">
- <fieldset style="border:1px solid #ddd; padding-bottom:20px; margin-top:20px;">
- <legend style="margin-left:5px; padding:0 5px; color:#2481C6;text-transform:uppercase;"><strong>Contact Page Settings</strong></legend>
- <table class="form-table">
- <tr>
- <td colspan="2"></td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="contact_text">Contact Page Text</label></th>
- <td>
- <textarea name="contact_text" id="contact_text" rows="7" cols="70" style="font-size:11px;"><?php echo stripslashes(get_option('alltuts_contact_text')); ?></textarea>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="contact_email">Email Address for Contact Form</label></th>
- <td>
- <input name="contact_email" type="text" id="contact_email" value="<?php echo get_option('alltuts_contact_email'); ?>" class="regular-text" />
- </td>
- </tr>
- </table>
- </fieldset>
- <p class="submit">
- <input type="submit" name="Submit" class="button-primary" value="Save Changes" />
- <input type="hidden" name="alltuts_settings" value="save" style="display:none;" />
- </p>
- </form>
- </div>
- <?php }
- /*******************************
- CONTACT FORM
- ********************************/
- function hexstr($hexstr) {
- $hexstr = str_replace(' ', '', $hexstr);
- $hexstr = str_replace('\x', '', $hexstr);
- $retstr = pack('H*', $hexstr);
- return $retstr;
- }
- function strhex($string) {
- $hexstr = unpack('H*', $string);
- return array_shift($hexstr);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement