Advertisement
Guest User

Untitled

a guest
Oct 28th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.66 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. /**
  6.  
  7.  
  8.  
  9. * TwentyTen functions and definitions
  10.  
  11.  
  12.  
  13. *
  14.  
  15.  
  16.  
  17. * Sets up the theme and provides some helper functions. Some helper functions
  18.  
  19.  
  20.  
  21. * are used in the theme as custom template tags. Others are attached to action and
  22.  
  23.  
  24.  
  25. * filter hooks in WordPress to change core functionality.
  26.  
  27.  
  28.  
  29. *
  30.  
  31.  
  32.  
  33. * The first function, twentyten_setup(), sets up the theme by registering support
  34.  
  35.  
  36.  
  37. * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
  38.  
  39.  
  40.  
  41. *
  42.  
  43.  
  44.  
  45. * When using a child theme (see http://codex.wordpress.org/Theme_Development and
  46.  
  47.  
  48.  
  49. * http://codex.wordpress.org/Child_Themes), you can override certain functions
  50.  
  51.  
  52.  
  53. * (those wrapped in a function_exists() call) by defining them first in your child theme's
  54.  
  55.  
  56.  
  57. * functions.php file. The child theme's functions.php file is included before the parent
  58.  
  59.  
  60.  
  61. * theme's file, so the child theme functions would be used.
  62.  
  63.  
  64.  
  65. *
  66.  
  67.  
  68.  
  69. * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  70.  
  71.  
  72.  
  73. * to a filter or action hook. The hook can be removed by using remove_action() or
  74.  
  75.  
  76.  
  77. * remove_filter() and you can attach your own function to the hook.
  78.  
  79.  
  80.  
  81. *
  82.  
  83.  
  84.  
  85. * We can remove the parent theme's hook only after it is attached, which means we need to
  86.  
  87.  
  88.  
  89. * wait until setting up the child theme:
  90.  
  91.  
  92.  
  93. *
  94.  
  95.  
  96.  
  97. * <code>
  98.  
  99.  
  100.  
  101. * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  102.  
  103.  
  104.  
  105. * function my_child_theme_setup() {
  106.  
  107.  
  108.  
  109. * // We are providing our own filter for excerpt_length (or using the unfiltered value)
  110.  
  111.  
  112.  
  113. * remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  114.  
  115.  
  116.  
  117. * ...
  118.  
  119.  
  120.  
  121. * }
  122.  
  123.  
  124.  
  125. * </code>
  126.  
  127.  
  128.  
  129. *
  130.  
  131.  
  132.  
  133. * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
  134.  
  135.  
  136.  
  137. *
  138.  
  139.  
  140.  
  141. * @package WordPress
  142.  
  143.  
  144.  
  145. * @subpackage Twenty_Ten
  146.  
  147.  
  148.  
  149. * @since Twenty Ten 1.0
  150.  
  151.  
  152.  
  153. */
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161. /**
  162.  
  163.  
  164.  
  165. * Set the content width based on the theme's design and stylesheet.
  166.  
  167.  
  168.  
  169. *
  170.  
  171.  
  172.  
  173. * Used to set the width of images and content. Should be equal to the width the theme
  174.  
  175.  
  176.  
  177. * is designed for, generally via the style.css stylesheet.
  178.  
  179.  
  180.  
  181. */
  182.  
  183.  
  184.  
  185. if ( ! isset( $content_width ) )
  186.  
  187.  
  188.  
  189. $content_width = 640;
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197. /** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
  198.  
  199.  
  200.  
  201. add_action( 'after_setup_theme', 'twentyten_setup' );
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209. if ( ! function_exists( 'twentyten_setup' ) ):
  210.  
  211.  
  212.  
  213. /**
  214.  
  215.  
  216.  
  217. * Sets up theme defaults and registers support for various WordPress features.
  218.  
  219.  
  220.  
  221. *
  222.  
  223.  
  224.  
  225. * Note that this function is hooked into the after_setup_theme hook, which runs
  226.  
  227.  
  228.  
  229. * before the init hook. The init hook is too late for some features, such as indicating
  230.  
  231.  
  232.  
  233. * support post thumbnails.
  234.  
  235.  
  236.  
  237. *
  238.  
  239.  
  240.  
  241. * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
  242.  
  243.  
  244.  
  245. * functions.php file.
  246.  
  247.  
  248.  
  249. *
  250.  
  251.  
  252.  
  253. * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
  254.  
  255.  
  256.  
  257. * @uses register_nav_menus() To add support for navigation menus.
  258.  
  259.  
  260.  
  261. * @uses add_custom_background() To add support for a custom background.
  262.  
  263.  
  264.  
  265. * @uses add_editor_style() To style the visual editor.
  266.  
  267.  
  268.  
  269. * @uses load_theme_textdomain() For translation/localization support.
  270.  
  271.  
  272.  
  273. * @uses add_custom_image_header() To add support for a custom header.
  274.  
  275.  
  276.  
  277. * @uses register_default_headers() To register the default custom header images provided with the theme.
  278.  
  279.  
  280.  
  281. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  282.  
  283.  
  284.  
  285. *
  286.  
  287.  
  288.  
  289. * @since Twenty Ten 1.0
  290.  
  291.  
  292.  
  293. */
  294.  
  295.  
  296.  
  297. function twentyten_setup() {
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305. // This theme styles the visual editor with editor-style.css to match the theme style.
  306.  
  307.  
  308.  
  309. add_editor_style();
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317. // This theme uses post thumbnails
  318.  
  319.  
  320.  
  321. add_theme_support( 'post-thumbnails' );
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329. // Add default posts and comments RSS feed links to head
  330.  
  331.  
  332.  
  333. add_theme_support( 'automatic-feed-links' );
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341. // Make theme available for translation
  342.  
  343.  
  344.  
  345. // Translations can be filed in the /languages/ directory
  346.  
  347.  
  348.  
  349. load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357. $locale = get_locale();
  358.  
  359.  
  360.  
  361. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  362.  
  363.  
  364.  
  365. if ( is_readable( $locale_file ) )
  366.  
  367.  
  368.  
  369. require_once( $locale_file );
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377. // This theme uses wp_nav_menu() in one location.
  378.  
  379.  
  380.  
  381. register_nav_menus( array(
  382.  
  383.  
  384.  
  385. 'primary' => __( 'Primary Navigation', 'twentyten' ),
  386.  
  387.  
  388.  
  389. ) );
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397. // This theme allows users to set a custom background
  398.  
  399.  
  400.  
  401. add_custom_background();
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409. // Your changeable header business starts here
  410.  
  411.  
  412.  
  413. define( 'HEADER_TEXTCOLOR', '' );
  414.  
  415.  
  416.  
  417. // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
  418.  
  419.  
  420.  
  421. define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429. // The height and width of your custom header. You can hook into the theme's own filters to change these values.
  430.  
  431.  
  432.  
  433. // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
  434.  
  435.  
  436.  
  437. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 1094 ) );
  438.  
  439.  
  440.  
  441. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 155 ) );
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449. // We'll be using post thumbnails for custom header images on posts and pages.
  450.  
  451.  
  452.  
  453. // We want them to be 1094 pixels wide by 155 pixels tall.
  454.  
  455.  
  456.  
  457. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
  458.  
  459.  
  460.  
  461. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469. // Don't support text inside the header image.
  470.  
  471.  
  472.  
  473. define( 'NO_HEADER_TEXT', true );
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481. // Add a way for the custom header to be styled in the admin panel that controls
  482.  
  483.  
  484.  
  485. // custom headers. See twentyten_admin_header_style(), below.
  486.  
  487.  
  488.  
  489. add_custom_image_header( '', 'twentyten_admin_header_style' );
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497. // ... and thus ends the changeable header business.
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  506.  
  507.  
  508.  
  509. register_default_headers( array(
  510.  
  511.  
  512.  
  513. 'berries' => array(
  514.  
  515.  
  516.  
  517. 'url' => '%s/images/headers/berries.jpg',
  518.  
  519.  
  520.  
  521. 'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
  522.  
  523.  
  524.  
  525. /* translators: header image description */
  526.  
  527.  
  528.  
  529. 'description' => __( 'Berries', 'twentyten' )
  530.  
  531.  
  532.  
  533. ),
  534.  
  535.  
  536.  
  537. 'cherryblossom' => array(
  538.  
  539.  
  540.  
  541. 'url' => '%s/images/headers/cherryblossoms.jpg',
  542.  
  543.  
  544.  
  545. 'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
  546.  
  547.  
  548.  
  549. /* translators: header image description */
  550.  
  551.  
  552.  
  553. 'description' => __( 'Cherry Blossoms', 'twentyten' )
  554.  
  555.  
  556.  
  557. ),
  558.  
  559.  
  560.  
  561. 'concave' => array(
  562.  
  563.  
  564.  
  565. 'url' => '%s/images/headers/concave.jpg',
  566.  
  567.  
  568.  
  569. 'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
  570.  
  571.  
  572.  
  573. /* translators: header image description */
  574.  
  575.  
  576.  
  577. 'description' => __( 'Concave', 'twentyten' )
  578.  
  579.  
  580.  
  581. ),
  582.  
  583.  
  584.  
  585. 'fern' => array(
  586.  
  587.  
  588.  
  589. 'url' => '%s/images/headers/fern.jpg',
  590.  
  591.  
  592.  
  593. 'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
  594.  
  595.  
  596.  
  597. /* translators: header image description */
  598.  
  599.  
  600.  
  601. 'description' => __( 'Fern', 'twentyten' )
  602.  
  603.  
  604.  
  605. ),
  606.  
  607.  
  608.  
  609. 'forestfloor' => array(
  610.  
  611.  
  612.  
  613. 'url' => '%s/images/headers/forestfloor.jpg',
  614.  
  615.  
  616.  
  617. 'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
  618.  
  619.  
  620.  
  621. /* translators: header image description */
  622.  
  623.  
  624.  
  625. 'description' => __( 'Forest Floor', 'twentyten' )
  626.  
  627.  
  628.  
  629. ),
  630.  
  631.  
  632.  
  633. 'inkwell' => array(
  634.  
  635.  
  636.  
  637. 'url' => '%s/images/headers/inkwell.jpg',
  638.  
  639.  
  640.  
  641. 'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
  642.  
  643.  
  644.  
  645. /* translators: header image description */
  646.  
  647.  
  648.  
  649. 'description' => __( 'Inkwell', 'twentyten' )
  650.  
  651.  
  652.  
  653. ),
  654.  
  655.  
  656.  
  657. 'path' => array(
  658.  
  659.  
  660.  
  661. 'url' => '%s/images/headers/path.jpg',
  662.  
  663.  
  664.  
  665. 'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
  666.  
  667.  
  668.  
  669. /* translators: header image description */
  670.  
  671.  
  672.  
  673. 'description' => __( 'Path', 'twentyten' )
  674.  
  675.  
  676.  
  677. ),
  678.  
  679.  
  680.  
  681. 'sunset' => array(
  682.  
  683.  
  684.  
  685. 'url' => '%s/images/headers/sunset.jpg',
  686.  
  687.  
  688.  
  689. 'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
  690.  
  691.  
  692.  
  693. /* translators: header image description */
  694.  
  695.  
  696.  
  697. 'description' => __( 'Sunset', 'twentyten' )
  698.  
  699.  
  700.  
  701. )
  702.  
  703.  
  704.  
  705. ) );
  706.  
  707.  
  708.  
  709. }
  710.  
  711.  
  712.  
  713. endif;
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721. if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
  722.  
  723.  
  724.  
  725. /**
  726.  
  727.  
  728.  
  729. * Styles the header image displayed on the Appearance > Header admin panel.
  730.  
  731.  
  732.  
  733. *
  734.  
  735.  
  736.  
  737. * Referenced via add_custom_image_header() in twentyten_setup().
  738.  
  739.  
  740.  
  741. *
  742.  
  743.  
  744.  
  745. * @since Twenty Ten 1.0
  746.  
  747.  
  748.  
  749. */
  750.  
  751.  
  752.  
  753. function twentyten_admin_header_style() {
  754.  
  755.  
  756.  
  757. ?>
  758.  
  759.  
  760.  
  761. <style type="text/css">
  762.  
  763.  
  764.  
  765. /* Shows the same border as on front end */
  766.  
  767.  
  768.  
  769. #headimg {
  770.  
  771.  
  772.  
  773. border-bottom: 1px solid #000;
  774.  
  775.  
  776.  
  777. border-top: 4px solid #000;
  778.  
  779.  
  780.  
  781. }
  782.  
  783.  
  784.  
  785. /* If NO_HEADER_TEXT is false, you would style the text with these selectors:
  786.  
  787.  
  788.  
  789. #headimg #name { }
  790.  
  791.  
  792.  
  793. #headimg #desc { }
  794.  
  795.  
  796.  
  797. */
  798.  
  799.  
  800.  
  801. </style>
  802.  
  803.  
  804.  
  805. <?php
  806.  
  807.  
  808.  
  809. }
  810.  
  811.  
  812.  
  813. endif;
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821. /**
  822.  
  823.  
  824.  
  825. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  826.  
  827.  
  828.  
  829. *
  830.  
  831.  
  832.  
  833. * To override this in a child theme, remove the filter and optionally add
  834.  
  835.  
  836.  
  837. * your own function tied to the wp_page_menu_args filter hook.
  838.  
  839.  
  840.  
  841. *
  842.  
  843.  
  844.  
  845. * @since Twenty Ten 1.0
  846.  
  847.  
  848.  
  849. */
  850.  
  851.  
  852.  
  853. function twentyten_page_menu_args( $args ) {
  854.  
  855.  
  856.  
  857. $args['show_home'] = false;
  858.  
  859.  
  860.  
  861. return $args;
  862.  
  863.  
  864.  
  865. }
  866.  
  867.  
  868.  
  869. add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877. /**
  878.  
  879.  
  880.  
  881. * Sets the post excerpt length to 40 characters.
  882.  
  883.  
  884.  
  885. *
  886.  
  887.  
  888.  
  889. * To override this length in a child theme, remove the filter and add your own
  890.  
  891.  
  892.  
  893. * function tied to the excerpt_length filter hook.
  894.  
  895.  
  896.  
  897. *
  898.  
  899.  
  900.  
  901. * @since Twenty Ten 1.0
  902.  
  903.  
  904.  
  905. * @return int
  906.  
  907.  
  908.  
  909. */
  910.  
  911.  
  912.  
  913. function twentyten_excerpt_length( $length ) {
  914.  
  915.  
  916.  
  917. return 40;
  918.  
  919.  
  920.  
  921. }
  922.  
  923.  
  924.  
  925. add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933. /**
  934.  
  935.  
  936.  
  937. * Returns a "Continue Reading" link for excerpts
  938.  
  939.  
  940.  
  941. *
  942.  
  943.  
  944.  
  945. * @since Twenty Ten 1.0
  946.  
  947.  
  948.  
  949. * @return string "Continue Reading" link
  950.  
  951.  
  952.  
  953. */
  954.  
  955.  
  956.  
  957. function twentyten_continue_reading_link() {
  958.  
  959.  
  960.  
  961. return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
  962.  
  963.  
  964.  
  965. }
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973. /**
  974.  
  975.  
  976.  
  977. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
  978.  
  979.  
  980.  
  981. *
  982.  
  983.  
  984.  
  985. * To override this in a child theme, remove the filter and add your own
  986.  
  987.  
  988.  
  989. * function tied to the excerpt_more filter hook.
  990.  
  991.  
  992.  
  993. *
  994.  
  995.  
  996.  
  997. * @since Twenty Ten 1.0
  998.  
  999.  
  1000.  
  1001. * @return string An ellipsis
  1002.  
  1003.  
  1004.  
  1005. */
  1006.  
  1007.  
  1008.  
  1009. function twentyten_auto_excerpt_more( $more ) {
  1010.  
  1011.  
  1012.  
  1013. return ' &hellip;' . twentyten_continue_reading_link();
  1014.  
  1015.  
  1016.  
  1017. }
  1018.  
  1019.  
  1020.  
  1021. add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029. /**
  1030.  
  1031.  
  1032.  
  1033. * Adds a pretty "Continue Reading" link to custom post excerpts.
  1034.  
  1035.  
  1036.  
  1037. *
  1038.  
  1039.  
  1040.  
  1041. * To override this link in a child theme, remove the filter and add your own
  1042.  
  1043.  
  1044.  
  1045. * function tied to the get_the_excerpt filter hook.
  1046.  
  1047.  
  1048.  
  1049. *
  1050.  
  1051.  
  1052.  
  1053. * @since Twenty Ten 1.0
  1054.  
  1055.  
  1056.  
  1057. * @return string Excerpt with a pretty "Continue Reading" link
  1058.  
  1059.  
  1060.  
  1061. */
  1062.  
  1063.  
  1064.  
  1065. function twentyten_custom_excerpt_more( $output ) {
  1066.  
  1067.  
  1068.  
  1069. if ( has_excerpt() && ! is_attachment() ) {
  1070.  
  1071.  
  1072.  
  1073. $output .= twentyten_continue_reading_link();
  1074.  
  1075.  
  1076.  
  1077. }
  1078.  
  1079.  
  1080.  
  1081. return $output;
  1082.  
  1083.  
  1084.  
  1085. }
  1086.  
  1087.  
  1088.  
  1089. add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097. /**
  1098.  
  1099.  
  1100.  
  1101. * Remove inline styles printed when the gallery shortcode is used.
  1102.  
  1103.  
  1104.  
  1105. *
  1106.  
  1107.  
  1108.  
  1109. * Galleries are styled by the theme in Twenty Ten's style.css.
  1110.  
  1111.  
  1112.  
  1113. *
  1114.  
  1115.  
  1116.  
  1117. * @since Twenty Ten 1.0
  1118.  
  1119.  
  1120.  
  1121. * @return string The gallery style filter, with the styles themselves removed.
  1122.  
  1123.  
  1124.  
  1125. */
  1126.  
  1127.  
  1128.  
  1129. function twentyten_remove_gallery_css( $css ) {
  1130.  
  1131.  
  1132.  
  1133. return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  1134.  
  1135.  
  1136.  
  1137. }
  1138.  
  1139.  
  1140.  
  1141. add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149. if ( ! function_exists( 'twentyten_comment' ) ) :
  1150.  
  1151.  
  1152.  
  1153. /**
  1154.  
  1155.  
  1156.  
  1157. * Template for comments and pingbacks.
  1158.  
  1159.  
  1160.  
  1161. *
  1162.  
  1163.  
  1164.  
  1165. * To override this walker in a child theme without modifying the comments template
  1166.  
  1167.  
  1168.  
  1169. * simply create your own twentyten_comment(), and that function will be used instead.
  1170.  
  1171.  
  1172.  
  1173. *
  1174.  
  1175.  
  1176.  
  1177. * Used as a callback by wp_list_comments() for displaying the comments.
  1178.  
  1179.  
  1180.  
  1181. *
  1182.  
  1183.  
  1184.  
  1185. * @since Twenty Ten 1.0
  1186.  
  1187.  
  1188.  
  1189. */
  1190.  
  1191.  
  1192.  
  1193. function twentyten_comment( $comment, $args, $depth ) {
  1194.  
  1195.  
  1196.  
  1197. $GLOBALS['comment'] = $comment;
  1198.  
  1199.  
  1200.  
  1201. switch ( $comment->comment_type ) :
  1202.  
  1203.  
  1204.  
  1205. case '' :
  1206.  
  1207.  
  1208.  
  1209. ?>
  1210.  
  1211.  
  1212.  
  1213. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  1214.  
  1215.  
  1216.  
  1217. <div id="comment-<?php comment_ID(); ?>">
  1218.  
  1219.  
  1220.  
  1221. <div class="comment-author vcard">
  1222.  
  1223.  
  1224.  
  1225. <?php echo get_avatar( $comment, 40 ); ?>
  1226.  
  1227.  
  1228.  
  1229. <?php printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  1230.  
  1231.  
  1232.  
  1233. </div><!-- .comment-author .vcard -->
  1234.  
  1235.  
  1236.  
  1237. <?php if ( $comment->comment_approved == '0' ) : ?>
  1238.  
  1239.  
  1240.  
  1241. <em><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
  1242.  
  1243.  
  1244.  
  1245. <br />
  1246.  
  1247.  
  1248.  
  1249. <?php endif; ?>
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257. <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  1258.  
  1259.  
  1260.  
  1261. <?php
  1262.  
  1263.  
  1264.  
  1265. /* translators: 1: date, 2: time */
  1266.  
  1267.  
  1268.  
  1269. printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
  1270.  
  1271.  
  1272.  
  1273. ?>
  1274.  
  1275.  
  1276.  
  1277. </div><!-- .comment-meta .commentmetadata -->
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285. <div class="comment-body"><?php comment_text(); ?></div>
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293. <div class="reply">
  1294.  
  1295.  
  1296.  
  1297. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  1298.  
  1299.  
  1300.  
  1301. </div><!-- .reply -->
  1302.  
  1303.  
  1304.  
  1305. </div><!-- #comment-## -->
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313. <?php
  1314.  
  1315.  
  1316.  
  1317. break;
  1318.  
  1319.  
  1320.  
  1321. case 'pingback' :
  1322.  
  1323.  
  1324.  
  1325. case 'trackback' :
  1326.  
  1327.  
  1328.  
  1329. ?>
  1330.  
  1331.  
  1332.  
  1333. <li class="post pingback">
  1334.  
  1335.  
  1336.  
  1337. <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'twentyten'), ' ' ); ?></p>
  1338.  
  1339.  
  1340.  
  1341. <?php
  1342.  
  1343.  
  1344.  
  1345. break;
  1346.  
  1347.  
  1348.  
  1349. endswitch;
  1350.  
  1351.  
  1352.  
  1353. }
  1354.  
  1355.  
  1356.  
  1357. endif;
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365. /**
  1366.  
  1367.  
  1368.  
  1369. * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  1370.  
  1371.  
  1372.  
  1373. *
  1374.  
  1375.  
  1376.  
  1377. * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
  1378.  
  1379.  
  1380.  
  1381. * function tied to the init hook.
  1382.  
  1383.  
  1384.  
  1385. *
  1386.  
  1387.  
  1388.  
  1389. * @since Twenty Ten 1.0
  1390.  
  1391.  
  1392.  
  1393. * @uses register_sidebar
  1394.  
  1395.  
  1396.  
  1397. */
  1398.  
  1399.  
  1400.  
  1401. function twentyten_widgets_init() {
  1402.  
  1403.  
  1404.  
  1405. // Area 1, located at the top of the sidebar.
  1406.  
  1407.  
  1408.  
  1409. register_sidebar( array(
  1410.  
  1411.  
  1412.  
  1413. 'name' => __( 'Primary Widget Area', 'twentyten' ),
  1414.  
  1415.  
  1416.  
  1417. 'id' => 'primary-widget-area',
  1418.  
  1419.  
  1420.  
  1421. 'description' => __( 'The primary widget area', 'twentyten' ),
  1422.  
  1423.  
  1424.  
  1425. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  1426.  
  1427.  
  1428.  
  1429. 'after_widget' => '</li>',
  1430.  
  1431.  
  1432.  
  1433. 'before_title' => '<h3 class="widget-title">',
  1434.  
  1435.  
  1436.  
  1437. 'after_title' => '</h3>',
  1438.  
  1439.  
  1440.  
  1441. ) );
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449. // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
  1450.  
  1451.  
  1452.  
  1453. register_sidebar( array(
  1454.  
  1455.  
  1456.  
  1457. 'name' => __( 'Secondary Widget Area', 'twentyten' ),
  1458.  
  1459.  
  1460.  
  1461. 'id' => 'secondary-widget-area',
  1462.  
  1463.  
  1464.  
  1465. 'description' => __( 'The secondary widget area', 'twentyten' ),
  1466.  
  1467.  
  1468.  
  1469. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  1470.  
  1471.  
  1472.  
  1473. 'after_widget' => '</li>',
  1474.  
  1475.  
  1476.  
  1477. 'before_title' => '<h3 class="widget-title">',
  1478.  
  1479.  
  1480.  
  1481. 'after_title' => '</h3>',
  1482.  
  1483.  
  1484.  
  1485. ) );
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493. // Area 3, located in the footer. Empty by default.
  1494.  
  1495.  
  1496.  
  1497. register_sidebar( array(
  1498.  
  1499.  
  1500.  
  1501. 'name' => __( 'First Footer Widget Area', 'twentyten' ),
  1502.  
  1503.  
  1504.  
  1505. 'id' => 'first-footer-widget-area',
  1506.  
  1507.  
  1508.  
  1509. 'description' => __( 'The first footer widget area', 'twentyten' ),
  1510.  
  1511.  
  1512.  
  1513. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  1514.  
  1515.  
  1516.  
  1517. 'after_widget' => '</li>',
  1518.  
  1519.  
  1520.  
  1521. 'before_title' => '<h3 class="widget-title">',
  1522.  
  1523.  
  1524.  
  1525. 'after_title' => '</h3>',
  1526.  
  1527.  
  1528.  
  1529. ) );
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537. // Area 4, located in the footer. Empty by default.
  1538.  
  1539.  
  1540.  
  1541. register_sidebar( array(
  1542.  
  1543.  
  1544.  
  1545. 'name' => __( 'Second Footer Widget Area', 'twentyten' ),
  1546.  
  1547.  
  1548.  
  1549. 'id' => 'second-footer-widget-area',
  1550.  
  1551.  
  1552.  
  1553. 'description' => __( 'The second footer widget area', 'twentyten' ),
  1554.  
  1555.  
  1556.  
  1557. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  1558.  
  1559.  
  1560.  
  1561. 'after_widget' => '</li>',
  1562.  
  1563.  
  1564.  
  1565. 'before_title' => '<h3 class="widget-title">',
  1566.  
  1567.  
  1568.  
  1569. 'after_title' => '</h3>',
  1570.  
  1571.  
  1572.  
  1573. ) );
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581. // Area 5, located in the footer. Empty by default.
  1582.  
  1583.  
  1584.  
  1585. register_sidebar( array(
  1586.  
  1587.  
  1588.  
  1589. 'name' => __( 'Third Footer Widget Area', 'twentyten' ),
  1590.  
  1591.  
  1592.  
  1593. 'id' => 'third-footer-widget-area',
  1594.  
  1595.  
  1596.  
  1597. 'description' => __( 'The third footer widget area', 'twentyten' ),
  1598.  
  1599.  
  1600.  
  1601. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  1602.  
  1603.  
  1604.  
  1605. 'after_widget' => '</li>',
  1606.  
  1607.  
  1608.  
  1609. 'before_title' => '<h3 class="widget-title">',
  1610.  
  1611.  
  1612.  
  1613. 'after_title' => '</h3>',
  1614.  
  1615.  
  1616.  
  1617. ) );
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625. // Area 6, located in the footer. Empty by default.
  1626.  
  1627.  
  1628.  
  1629. register_sidebar( array(
  1630.  
  1631.  
  1632.  
  1633. 'name' => __( 'Fourth Footer Widget Area', 'twentyten' ),
  1634.  
  1635.  
  1636.  
  1637. 'id' => 'fourth-footer-widget-area',
  1638.  
  1639.  
  1640.  
  1641. 'description' => __( 'The fourth footer widget area', 'twentyten' ),
  1642.  
  1643.  
  1644.  
  1645. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  1646.  
  1647.  
  1648.  
  1649. 'after_widget' => '</li>',
  1650.  
  1651.  
  1652.  
  1653. 'before_title' => '<h3 class="widget-title">',
  1654.  
  1655.  
  1656.  
  1657. 'after_title' => '</h3>',
  1658.  
  1659.  
  1660.  
  1661. ) );
  1662.  
  1663.  
  1664.  
  1665. }
  1666.  
  1667.  
  1668.  
  1669. /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
  1670.  
  1671.  
  1672.  
  1673. add_action( 'widgets_init', 'twentyten_widgets_init' );
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681. /**
  1682.  
  1683.  
  1684.  
  1685. * Removes the default styles that are packaged with the Recent Comments widget.
  1686.  
  1687.  
  1688.  
  1689. *
  1690.  
  1691.  
  1692.  
  1693. * To override this in a child theme, remove the filter and optionally add your own
  1694.  
  1695.  
  1696.  
  1697. * function tied to the widgets_init action hook.
  1698.  
  1699.  
  1700.  
  1701. *
  1702.  
  1703.  
  1704.  
  1705. * @since Twenty Ten 1.0
  1706.  
  1707.  
  1708.  
  1709. */
  1710.  
  1711.  
  1712.  
  1713. function twentyten_remove_recent_comments_style() {
  1714.  
  1715.  
  1716.  
  1717. global $wp_widget_factory;
  1718.  
  1719.  
  1720.  
  1721. remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
  1722.  
  1723.  
  1724.  
  1725. }
  1726.  
  1727.  
  1728.  
  1729. add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737. if ( ! function_exists( 'twentyten_posted_on' ) ) :
  1738.  
  1739.  
  1740.  
  1741. /**
  1742.  
  1743.  
  1744.  
  1745. * Prints HTML with meta information for the current post—date/time and author.
  1746.  
  1747.  
  1748.  
  1749. *
  1750.  
  1751.  
  1752.  
  1753. * @since Twenty Ten 1.0
  1754.  
  1755.  
  1756.  
  1757. */
  1758.  
  1759.  
  1760.  
  1761. function twentyten_posted_on() {
  1762.  
  1763.  
  1764.  
  1765. printf( __( '<span class="%1$s"></span> %2$s ', 'twentyten' ),
  1766.  
  1767.  
  1768.  
  1769. 'meta-prep meta-prep-author',
  1770.  
  1771.  
  1772.  
  1773. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"></a><span class="entry-date">%3$s</span>',
  1774.  
  1775.  
  1776.  
  1777. get_permalink(),
  1778.  
  1779.  
  1780.  
  1781. esc_attr( get_the_time() ),
  1782.  
  1783.  
  1784.  
  1785. get_the_date()
  1786.  
  1787.  
  1788.  
  1789. ),
  1790.  
  1791.  
  1792.  
  1793.  
  1794. sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  1795.  
  1796.  
  1797.  
  1798. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  1799.  
  1800.  
  1801.  
  1802. sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
  1803.  
  1804.  
  1805.  
  1806. get_the_author()
  1807.  
  1808.  
  1809.  
  1810. )
  1811.  
  1812.  
  1813.  
  1814. );
  1815.  
  1816.  
  1817.  
  1818. }
  1819.  
  1820.  
  1821.  
  1822. endif;
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830. if ( ! function_exists( 'twentyten_posted_in' ) ) :
  1831.  
  1832.  
  1833.  
  1834. /**
  1835.  
  1836.  
  1837.  
  1838. * Prints HTML with meta information for the current post (category, tags and permalink).
  1839.  
  1840.  
  1841.  
  1842. *
  1843.  
  1844.  
  1845.  
  1846. * @since Twenty Ten 1.0
  1847.  
  1848.  
  1849.  
  1850. */
  1851.  
  1852.  
  1853.  
  1854. function twentyten_posted_in() {
  1855.  
  1856.  
  1857.  
  1858. // Retrieves tag list of current post, separated by commas.
  1859.  
  1860.  
  1861.  
  1862. $tag_list = get_the_tag_list( '', ', ' );
  1863.  
  1864.  
  1865.  
  1866. if ( $tag_list ) {
  1867.  
  1868.  
  1869.  
  1870. $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  1871.  
  1872.  
  1873.  
  1874. } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  1875.  
  1876.  
  1877.  
  1878. $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  1879.  
  1880.  
  1881.  
  1882. } else {
  1883.  
  1884.  
  1885.  
  1886. $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  1887.  
  1888.  
  1889.  
  1890. }
  1891.  
  1892.  
  1893.  
  1894. // Prints the string, replacing the placeholders.
  1895.  
  1896.  
  1897.  
  1898. printf(
  1899.  
  1900.  
  1901.  
  1902. $posted_in,
  1903.  
  1904.  
  1905.  
  1906. get_the_category_list( ', ' ),
  1907.  
  1908.  
  1909.  
  1910. $tag_list,
  1911.  
  1912.  
  1913.  
  1914. get_permalink(),
  1915.  
  1916.  
  1917.  
  1918. the_title_attribute( 'echo=0' )
  1919.  
  1920.  
  1921.  
  1922. );
  1923.  
  1924.  
  1925.  
  1926. }
  1927.  
  1928. if (function_exists('apc_clear_cache')) {
  1929.  
  1930. // Clear cache if something is edited
  1931.  
  1932. if (!empty($_POST) && is_admin())
  1933.  
  1934. apc_clear_cache();
  1935.  
  1936. // Add Clear APC menu under Tools menu
  1937.  
  1938. add_action('admin_menu', 'php_apc_info');
  1939.  
  1940. function php_apc_info() {
  1941.  
  1942. add_submenu_page('tools.php', 'Clear APC', 'Clear APC', 'activate_plugins', 'clear_php_apc', 'php_apc_options');
  1943.  
  1944. }
  1945.  
  1946. function php_apc_options() {
  1947.  
  1948. if (apc_clear_cache() && apc_clear_cache('user'))
  1949.  
  1950. print '<p>All Clear!</p>';
  1951.  
  1952. else
  1953.  
  1954. print '<p>Clearing Failed!</p>';
  1955.  
  1956. print '<pre>'; print_r(apc_cache_info()); print '</pre>';
  1957.  
  1958. }
  1959.  
  1960. // Add Clear APC in the favorite actions dropdown
  1961.  
  1962. add_filter('favorite_actions', 'clear_apc_link');
  1963.  
  1964. function clear_apc_link($actions) {
  1965.  
  1966. $actions['tools.php?page=clear_php_apc'] = array('Clear APC', 'edit_posts');
  1967.  
  1968. return $actions;
  1969.  
  1970. }
  1971.  
  1972. }
  1973.  
  1974. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement