Advertisement
Guest User

Untitled

a guest
Nov 28th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.40 KB | None | 0 0
  1. <?php
  2. add_action('after_setup_theme', 'startup_setup');
  3. function startup_setup(){
  4. load_theme_textdomain('startup', get_template_directory() . '/languages');
  5. add_theme_support( 'automatic-feed-links' );
  6. add_theme_support( 'post-thumbnails' );
  7. add_theme_support( 'custom-background' );
  8. global $content_width;
  9. if ( ! isset( $content_width ) ) $content_width = 640;
  10. register_nav_menus(
  11. array( 'main-menu' => __( 'Main Menu', 'startup' ) )
  12. );
  13. }
  14. require_once (get_template_directory() . '/setup/options.php');
  15. add_action('wp_enqueue_scripts','startup_load_scripts');
  16. function startup_load_scripts()
  17. {
  18. wp_enqueue_script('jquery');
  19. wp_register_script('twitter', 'https://platform.twitter.com/widgets.js');
  20. wp_enqueue_script('twitter');
  21. wp_register_script('gplus', 'https://apis.google.com/js/plusone.js');
  22. wp_enqueue_script('gplus');
  23. wp_register_script('startup-videos', get_template_directory_uri().'/scripts/videos.js');
  24. wp_enqueue_script('startup-videos');
  25. }
  26. function startup_enqueue_admin_scripts()
  27. {
  28. global $startup_theme_page;
  29. if ( $startup_theme_page != get_current_screen()->id ) { return; }
  30. wp_enqueue_script('startup-admin-script', get_template_directory_uri().'/scripts/admin.js', array('jquery','media-upload','thickbox'));
  31. wp_enqueue_script('startup-admin-color', get_template_directory_uri().'/scripts/color-picker/color.js');
  32. wp_enqueue_style('startup-admin-style', get_template_directory_uri().'/scripts/admin.css');
  33. wp_enqueue_style('thickbox');
  34. }
  35. add_action('wp_enqueue_scripts','startup_load_styles');
  36. function startup_load_styles()
  37. {
  38. wp_enqueue_style('startup-open-sans', 'https://fonts.googleapis.com/css?family=Open+Sans:300');
  39. $options = get_option('startup_options');
  40. if ( $options['gfont1'] ){ wp_enqueue_style('startup-gfont1', 'https://fonts.googleapis.com/css?family='.sanitize_text_field($options['gfont1'])); }
  41. }
  42. add_action('wp_head', 'startup_print_custom_styles');
  43. function startup_print_custom_styles()
  44. {
  45. if(!is_admin()){
  46. $options = get_option('startup_options');
  47. if ( false != $options['customstyles']) {
  48. $custom_css = '<style type="text/css">';
  49. $custom_css .= 'body{';
  50. if ( '' != $options['textcolor'] ) { $custom_css .= 'color:#'.sanitize_text_field($options['textcolor']).'}'; }
  51. if ( '' != $options['linkcolor'] ) { $custom_css .= 'a{color:#'.sanitize_text_field($options['linkcolor']).'}'; }
  52. if ( '' != $options['hovercolor'] ) { $custom_css .= 'a:hover{color:#'.sanitize_text_field($options['hovercolor']).'}'; }
  53. $custom_css .= '.entry-content p{';
  54. if ( '' != $options['pfont'] ) { $custom_css .= 'font-family:'.sanitize_text_field($options['pfont']).';'; }
  55. if ( '' != $options['psize'] ) { $custom_css .= 'font-size:'.sanitize_text_field($options['psize']).'px;'; }
  56. if ( '' != $options['pcolor'] ) { $custom_css .= 'color:#'.sanitize_text_field($options['pcolor']).''; }
  57. $custom_css .= '}';
  58. $custom_css .= '.entry-content a{';
  59. if ( '' != $options['plfont'] ) { $custom_css .= 'font-family:'.sanitize_text_field($options['plfont']).';'; }
  60. if ( '' != $options['plsize'] ) { $custom_css .= 'font-size:'.sanitize_text_field($options['plsize']).'px;'; }
  61. if ( '' != $options['plcolor'] ) { $custom_css .= 'color:#'.sanitize_text_field($options['plcolor']).''; }
  62. $custom_css .= '}';
  63. $custom_css .= 'h1, h2, h3, h4, h5, h6{';
  64. if ( '' != $options['hfont'] ) { $custom_css .= 'font-family:'.sanitize_text_field($options['hfont']).';'; }
  65. if ( '' != $options['hcolor'] ) { $custom_css .= 'color:#'.sanitize_text_field($options['hcolor']).''; }
  66. $custom_css .= '}';
  67. $custom_css .= 'h1 a, h2 a, h3 a, h4 a, h5 a, h6 a{';
  68. if ( '' != $options['hlcolor'] ) { $custom_css .= 'color:#'.sanitize_text_field($options['hlcolor']).''; }
  69. $custom_css .= '}';
  70. if ( '' != $options['navbg'] ) { $custom_css .= 'nav{background-color:#'.sanitize_text_field($options['navbg']).'}'; }
  71. if ( '' != $options['navtrans'] ) { $custom_css .= 'nav li ul{opacity:'.sanitize_text_field($options['navtrans']).'}'; }
  72. $custom_css .= '</style>';
  73. echo $custom_css; }
  74. }
  75. }
  76. add_action('wp_head', 'startup_print_custom_scripts', 99);
  77. function startup_print_custom_scripts()
  78. {
  79. if(!is_admin()){
  80. $options = get_option('startup_options');
  81. ?>
  82. <script type="text/javascript">
  83. jQuery(document).ready(function($){
  84. $("#wrapper").vids();
  85. });
  86. </script>
  87. <?php
  88. }
  89. }
  90. add_action('comment_form_before', 'startup_enqueue_comment_reply_script');
  91. function startup_enqueue_comment_reply_script()
  92. {
  93. if(get_option('thread_comments')) { wp_enqueue_script('comment-reply'); }
  94. }
  95. add_filter('the_title', 'startup_title');
  96. function startup_title($title) {
  97. if ($title == '') {
  98. return 'Untitled';
  99. } else {
  100. return $title;
  101. }
  102. }
  103. add_filter('wp_title', 'startup_filter_wp_title');
  104. function startup_filter_wp_title($title)
  105. {
  106. return $title . esc_attr(get_bloginfo('name'));
  107. }
  108. add_filter('comment_form_defaults', 'startup_comment_form_defaults');
  109. function startup_comment_form_defaults( $args )
  110. {
  111. $req = get_option( 'require_name_email' );
  112. $required_text = sprintf( ' ' . __('Required fields are marked %s', 'startup'), '<span class="required">*</span>' );
  113. $args['comment_notes_before'] = '<p class="comment-notes">' . __('Your email is kept private.', 'startup') . ( $req ? $required_text : '' ) . '</p>';
  114. $args['title_reply'] = __('Post a Comment', 'startup');
  115. $args['title_reply_to'] = __('Post a Reply to %s', 'startup');
  116. return $args;
  117. }
  118. function startup_breadcrumbs() {
  119. if (!is_home()) {
  120. echo '<div id="breadcrumbs"><a href="'.home_url().'/">' . __( 'Home', 'startup' ) . '</a> » ';
  121. if (is_category() || is_single()) {
  122. the_category(', ');
  123. if (is_single()) {
  124. echo " » ";
  125. the_title();
  126. }
  127. }
  128. elseif (is_page()) {the_title();}
  129. elseif (is_tag()) {_e('Tag Page for ', 'startup' ); single_tag_title();}
  130. elseif (is_day()) {_e('Archives for ', 'startup' ); the_time('F jS, Y');}
  131. elseif (is_month()) {_e('Archives for ', 'startup' ); the_time('F, Y');}
  132. elseif (is_year()) {_e('Archives for ', 'startup' ); the_time('Y');}
  133. elseif (is_author()) {_e('Author Archives', 'startup' );}
  134. elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {_e('Blog Archives', 'startup' );}
  135. elseif (is_search()) {_e('Search Results', 'startup' );}
  136. elseif (is_404()) {_e('Page Not Found', 'startup' );}
  137. echo '</div>';
  138. }
  139. }
  140. add_action( 'init', 'startup_set_default_widgets' );
  141. function startup_set_default_widgets() {
  142. if ( is_admin() && isset( $_GET['activated'] ) ) {
  143. update_option( 'sidebars_widgets', $preset_widgets );
  144. }
  145. }
  146. add_action( 'init', 'startup_add_shortcodes' );
  147. function startup_add_shortcodes() {
  148. add_filter('widget_text', 'do_shortcode');
  149. add_shortcode('wp_caption', 'fixed_img_caption_shortcode');
  150. add_shortcode('caption', 'fixed_img_caption_shortcode');
  151. }
  152. function fixed_img_caption_shortcode($attr, $content = null) {
  153. $output = apply_filters('img_caption_shortcode', '', $attr, $content);
  154. if ( $output != '' ) return $output;
  155. extract(shortcode_atts(array(
  156. 'id'=> '',
  157. 'align' => 'alignnone',
  158. 'width' => '',
  159. 'caption' => ''), $attr));
  160. if ( 1 > (int) $width || empty($caption) )
  161. return $content;
  162. if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
  163. return '<div ' . $id . 'class="wp-caption ' . esc_attr($align)
  164. . '">'
  165. . do_shortcode( $content ) . '<p class="wp-caption-text">'
  166. . $caption . '</p></div>';
  167. }
  168. add_action( 'widgets_init', 'startup_widgets_init' );
  169. function startup_widgets_init() {
  170. register_sidebar( array (
  171. 'name' => __('Sidebar Widget Area', 'startup'),
  172. 'id' => 'primary-widget-area',
  173. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  174. 'after_widget' => "",
  175. 'before_title' => '<h3 class="widget-title">',
  176. 'after_title' => '</h3>',
  177. ) );
  178. register_sidebar( array (
  179. 'name' => __('Left Sidebar Widget Area', 'startup'),
  180. 'id' => 'lsidebar-widget-area',
  181. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  182. 'after_widget' => "",
  183. 'before_title' => '<h3 class="widget-title">',
  184. 'after_title' => '</h3>',
  185. ) );
  186. register_sidebar( array (
  187. 'name' => __('Right Sidebar Widget Area', 'startup'),
  188. 'id' => 'rsidebar-widget-area',
  189. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  190. 'after_widget' => "",
  191. 'before_title' => '<h3 class="widget-title">',
  192. 'after_title' => '</h3>',
  193. ) );
  194. }
  195. $preset_widgets = array (
  196. 'primary-aside'  => array( 'search', 'pages', 'categories', 'archives' ),
  197. );
  198. function startup_get_page_number() {
  199. if (get_query_var('paged')) {
  200. print ' | ' . __( 'Page ' , 'startup') . get_query_var('paged');
  201. }
  202. }
  203. function startup_catz($glue) {
  204. $current_cat = single_cat_title( '', false );
  205. $separator = "\n";
  206. $cats = explode( $separator, get_the_category_list($separator) );
  207. foreach ( $cats as $i => $str ) {
  208. if ( strstr( $str, ">$current_cat<" ) ) {
  209. unset($cats[$i]);
  210. break;
  211. }
  212. }
  213. if ( empty($cats) )
  214. return false;
  215. return trim(join( $glue, $cats ));
  216. }
  217. function startup_tag_it($glue) {
  218. $current_tag = single_tag_title( '', '',  false );
  219. $separator = "\n";
  220. $tags = explode( $separator, get_the_tag_list( "", "$separator", "" ) );
  221. foreach ( $tags as $i => $str ) {
  222. if ( strstr( $str, ">$current_tag<" ) ) {
  223. unset($tags[$i]);
  224. break;
  225. }
  226. }
  227. if ( empty($tags) )
  228. return false;
  229. return trim(join( $glue, $tags ));
  230. }
  231. function startup_commenter_link() {
  232. $commenter = get_comment_author_link();
  233. if ( ereg( '<a[^>]* class=[^>]+>', $commenter ) ) {
  234. $commenter = preg_replace( '/(<a[^>]* class=[\'"]?)/', '\\1url ' , $commenter );
  235. } else {
  236. $commenter = preg_replace( '/(<a )/', '\\1class="url "' , $commenter );
  237. }
  238. $avatar_email = get_comment_author_email();
  239. $avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( $avatar_email, 80 ) );
  240. echo $avatar . ' <span class="fn n">' . $commenter . '</span>';
  241. }
  242. function startup_custom_comments($comment, $args, $depth) {
  243. $GLOBALS['comment'] = $comment;
  244. $GLOBALS['comment_depth'] = $depth;
  245. ?>
  246. <li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
  247. <div class="comment-author vcard"><?php startup_commenter_link() ?></div>
  248. <div class="comment-meta"><?php printf(__('Posted %1$s at %2$s', 'startup' ), get_comment_date(), get_comment_time() ); ?><span class="meta-sep"> | </span> <a>" title="<?php _e('Permalink to this comment', 'startup' ); ?>"><?php _e('Permalink', 'startup' ); ?></a>
  249. <?php edit_comment_link(__('Edit', 'startup'), ' <span class="meta-sep"> | </span> <span class="edit-link">', '</span>'); ?></div>
  250. <?php if ($comment->comment_approved == '0') { echo '\t\t\t\t\t<span class="unapproved">'; _e('Your comment is awaiting moderation.', 'startup'); echo '</span>\n'; } ?>
  251. <div class="comment-content">
  252. <?php comment_text() ?>
  253. </div>
  254. <?php
  255. if($args['type'] == 'all' || get_comment_type() == 'comment') :
  256. comment_reply_link(array_merge($args, array(
  257. 'reply_text' => __('Reply','startup'),
  258. 'login_text' => __('Login to reply.', 'startup'),
  259. 'depth' => $depth,
  260. 'before' => '<div class="comment-reply-link">',
  261. 'after' => '</div>'
  262. )));
  263. endif;
  264. ?>
  265. <?php }
  266. function startup_custom_pings($comment, $args, $depth) {
  267. $GLOBALS['comment'] = $comment;
  268. ?>
  269. <li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
  270. <div class="comment-author"><?php printf(__('By %1$s on %2$s at %3$s', 'startup'),
  271. get_comment_author_link(),
  272. get_comment_date(),
  273. get_comment_time() );
  274. edit_comment_link(__('Edit', 'startup'), ' <span class="meta-sep"> | </span> <span class="edit-link">', '</span>'); ?></div>
  275. <?php if ($comment->comment_approved == '0') { echo '\t\t\t\t\t<span class="unapproved">'; _e('Your trackback is awaiting moderation.', 'startup'); echo '</span>\n'; } ?>
  276. <div class="comment-content">
  277. <?php comment_text() ?>
  278. </div>
  279. <?php }
  280.  
  281. <strong>modelo da página principal (index.php)</strong>
  282.  
  283. <?php get_header(); ?>
  284. <div id="content">
  285. <?php get_template_part( 'nav', 'above' ); ?>
  286. <?php while ( have_posts() ) : the_post() ?>
  287. <?php get_template_part( 'entry' ); ?>
  288. <?php comments_template(); ?>
  289. <?php endwhile; ?>
  290. <?php get_template_part( 'nav', 'below' ); ?>
  291. </div>
  292. <?php get_sidebar(); ?>
  293. <?php get_footer(); ?>
  294.  
  295. <strong>modelo de página (page.php)</strong>
  296.  
  297. <?php get_header(); ?>
  298. <article id="content">
  299. <?php the_post(); ?>
  300. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  301. <h1 class="entry-title"><?php the_title(); ?></h1>
  302. <div class="entry-content">
  303. <?php
  304. if ( has_post_thumbnail() ) {
  305. the_post_thumbnail();
  306. }
  307. ?>
  308. <?php the_content(); ?>
  309. <?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'startup' ) . '&after=</div>') ?>
  310. <?php edit_post_link( __( 'Edit', 'startup' ), '<div class="edit-link">', '</div>' ) ?>
  311. </div>
  312. </div>
  313. <?php comments_template( '', true ); ?>
  314. </article>
  315. <?php get_sidebar(); ?>
  316. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement