wordpress-starter 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/CHANGELOG.md +4 -1
  2. data/README.md +12 -0
  3. data/lib/wordpress-starter.rb +2 -1
  4. data/templates/bootstrap/404.php +24 -0
  5. data/templates/bootstrap/admin/README.txt +25 -0
  6. data/templates/bootstrap/admin/assets/css/admin-style.css +838 -0
  7. data/templates/bootstrap/admin/assets/css/colorpicker.css +177 -0
  8. data/templates/bootstrap/admin/assets/images/1col.png +0 -0
  9. data/templates/bootstrap/admin/assets/images/2-col-portfolio.png +0 -0
  10. data/templates/bootstrap/admin/assets/images/2cl.png +0 -0
  11. data/templates/bootstrap/admin/assets/images/2cr.png +0 -0
  12. data/templates/bootstrap/admin/assets/images/3-col-portfolio.png +0 -0
  13. data/templates/bootstrap/admin/assets/images/3cm.png +0 -0
  14. data/templates/bootstrap/admin/assets/images/3cr.png +0 -0
  15. data/templates/bootstrap/admin/assets/images/4-col-portfolio.png +0 -0
  16. data/templates/bootstrap/admin/assets/images/accept.png +0 -0
  17. data/templates/bootstrap/admin/assets/images/button_check.png +0 -0
  18. data/templates/bootstrap/admin/assets/images/colorpicker/blank.gif +0 -0
  19. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_background.png +0 -0
  20. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_hex.png +0 -0
  21. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_hsb_b.png +0 -0
  22. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_hsb_h.png +0 -0
  23. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_hsb_s.png +0 -0
  24. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_indic.gif +0 -0
  25. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_overlay.png +0 -0
  26. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_rgb_b.png +0 -0
  27. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_rgb_g.png +0 -0
  28. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_rgb_r.png +0 -0
  29. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_select.gif +0 -0
  30. data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_submit.png +0 -0
  31. data/templates/bootstrap/admin/assets/images/colorpicker/select.png +0 -0
  32. data/templates/bootstrap/admin/assets/images/dropdown-arrow.png +0 -0
  33. data/templates/bootstrap/admin/assets/images/favicon.ico +0 -0
  34. data/templates/bootstrap/admin/assets/images/icon-add.png +0 -0
  35. data/templates/bootstrap/admin/assets/images/icon-backup.png +0 -0
  36. data/templates/bootstrap/admin/assets/images/icon-delete.png +0 -0
  37. data/templates/bootstrap/admin/assets/images/icon-docs.png +0 -0
  38. data/templates/bootstrap/admin/assets/images/icon-edit.png +0 -0
  39. data/templates/bootstrap/admin/assets/images/icon-home.png +0 -0
  40. data/templates/bootstrap/admin/assets/images/icon-info.png +0 -0
  41. data/templates/bootstrap/admin/assets/images/icon-notice.png +0 -0
  42. data/templates/bootstrap/admin/assets/images/icon-paint.png +0 -0
  43. data/templates/bootstrap/admin/assets/images/icon-settings.png +0 -0
  44. data/templates/bootstrap/admin/assets/images/icon-slider.png +0 -0
  45. data/templates/bootstrap/admin/assets/images/icon-warn.png +0 -0
  46. data/templates/bootstrap/admin/assets/images/icon_option.png +0 -0
  47. data/templates/bootstrap/admin/assets/images/loading-bottom.gif +0 -0
  48. data/templates/bootstrap/admin/assets/images/select.png +0 -0
  49. data/templates/bootstrap/admin/assets/images/sign_warning.png +0 -0
  50. data/templates/bootstrap/admin/assets/images/stop.png +0 -0
  51. data/templates/bootstrap/admin/assets/images/toggle_tabs.png +0 -0
  52. data/templates/bootstrap/admin/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  53. data/templates/bootstrap/admin/assets/images/warning.png +0 -0
  54. data/templates/bootstrap/admin/assets/images/wrench.png +0 -0
  55. data/templates/bootstrap/admin/assets/images/wrench16.png +0 -0
  56. data/templates/bootstrap/admin/assets/js/ajaxupload.js +606 -0
  57. data/templates/bootstrap/admin/assets/js/colorpicker.js +455 -0
  58. data/templates/bootstrap/admin/assets/js/cookie.js +1 -0
  59. data/templates/bootstrap/admin/assets/js/jquery.maskedinput-1.2.2.js +252 -0
  60. data/templates/bootstrap/admin/assets/js/jquery.tipsy.js +241 -0
  61. data/templates/bootstrap/admin/assets/js/of-medialibrary-uploader.js +168 -0
  62. data/templates/bootstrap/admin/assets/js/smof.js +623 -0
  63. data/templates/bootstrap/admin/classes/class.options-machine.php +627 -0
  64. data/templates/bootstrap/admin/front-end/options.php +77 -0
  65. data/templates/bootstrap/admin/functions/functions.admin.php +76 -0
  66. data/templates/bootstrap/admin/functions/functions.interface.php +232 -0
  67. data/templates/bootstrap/admin/functions/functions.load.php +14 -0
  68. data/templates/bootstrap/admin/functions/functions.mediauploader.php +194 -0
  69. data/templates/bootstrap/admin/functions/functions.options.php +508 -0
  70. data/templates/bootstrap/admin/functions/functions.php +0 -0
  71. data/templates/bootstrap/admin/index.php +87 -0
  72. data/templates/bootstrap/admin/layouts/default.css +0 -0
  73. data/templates/bootstrap/admin/layouts/placebo.css +0 -0
  74. data/templates/bootstrap/archive.php +57 -0
  75. data/templates/bootstrap/category.php +40 -0
  76. data/templates/bootstrap/comments.php +65 -0
  77. data/templates/bootstrap/content-aside.php +26 -0
  78. data/templates/bootstrap/content-image.php +29 -0
  79. data/templates/bootstrap/content-link.php +27 -0
  80. data/templates/bootstrap/content-none.php +21 -0
  81. data/templates/bootstrap/content-page.php +24 -0
  82. data/templates/bootstrap/content-quote.php +26 -0
  83. data/templates/bootstrap/content-status.php +33 -0
  84. data/templates/bootstrap/content.php +67 -0
  85. data/templates/bootstrap/editor-style.scss +72 -0
  86. data/templates/bootstrap/footer.php +29 -0
  87. data/templates/bootstrap/functions.php +1528 -0
  88. data/templates/bootstrap/header.php +74 -0
  89. data/templates/bootstrap/ie.scss +1 -0
  90. data/templates/bootstrap/images/bg/bg0.png +0 -0
  91. data/templates/bootstrap/images/bg/bg1.png +0 -0
  92. data/templates/bootstrap/images/bg/bg10.png +0 -0
  93. data/templates/bootstrap/images/bg/bg11.png +0 -0
  94. data/templates/bootstrap/images/bg/bg2.png +0 -0
  95. data/templates/bootstrap/images/bg/bg3.png +0 -0
  96. data/templates/bootstrap/images/bg/bg4.png +0 -0
  97. data/templates/bootstrap/images/bg/bg5.png +0 -0
  98. data/templates/bootstrap/images/bg/bg6.jpg +0 -0
  99. data/templates/bootstrap/images/bg/bg7.jpg +0 -0
  100. data/templates/bootstrap/images/bg/bg8.png +0 -0
  101. data/templates/bootstrap/images/bg/bg9.png +0 -0
  102. data/templates/bootstrap/images/glyphicons-halflings-white.png +0 -0
  103. data/templates/bootstrap/images/glyphicons-halflings.png +0 -0
  104. data/templates/bootstrap/index.php +19 -0
  105. data/templates/bootstrap/javascripts/app.js +6 -0
  106. data/templates/bootstrap/javascripts/bootstrap.js +2159 -0
  107. data/templates/bootstrap/javascripts/bootstrap.min.js +6 -0
  108. data/templates/{project/javascripts/moderninzr.min.js → bootstrap/javascripts/modernizr.min.js} +0 -0
  109. data/templates/bootstrap/languages/readme.txt +6 -0
  110. data/templates/bootstrap/license.txt +281 -0
  111. data/templates/bootstrap/loop.php +30 -0
  112. data/templates/bootstrap/manifest.rb +156 -0
  113. data/templates/bootstrap/options.php +42 -0
  114. data/templates/bootstrap/page.php +29 -0
  115. data/templates/bootstrap/print.scss +104 -0
  116. data/templates/bootstrap/readme.txt +6 -0
  117. data/templates/bootstrap/sass/_app.scss +10 -0
  118. data/templates/bootstrap/sass/_settings.scss +301 -0
  119. data/templates/bootstrap/screen.scss +1 -0
  120. data/templates/bootstrap/screenshot.png +0 -0
  121. data/templates/bootstrap/search.php +31 -0
  122. data/templates/bootstrap/searchform.php +31 -0
  123. data/templates/bootstrap/sidebar.php +15 -0
  124. data/templates/bootstrap/single.php +31 -0
  125. data/templates/bootstrap/style.css +18 -0
  126. data/templates/bootstrap/tag.php +41 -0
  127. data/templates/foundation/functions.php +8 -9
  128. data/templates/foundation/sass/_app.scss +2 -0
  129. data/templates/project/functions.php +1 -1
  130. data/templates/project/javascripts/app.js +2 -5
  131. data/templates/project/javascripts/modernizr.min.js +4 -0
  132. data/templates/project/manifest.rb +1 -1
  133. metadata +141 -2
@@ -0,0 +1,67 @@
1
+ <?php
2
+ /**
3
+ * The default template for displaying content. Used for both single and index/archive/search.
4
+ *
5
+ * @category Theme
6
+ * @package [bootstrap]
7
+ * @author [Your Name]
8
+ * @copyright 2012 [Your Name]
9
+ */
10
+ ?>
11
+
12
+ <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
13
+ <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
14
+ <div class="featured-post">
15
+ <?php _e( 'Featured post', 'bootstrap' ); ?>
16
+ </div>
17
+ <?php endif; ?>
18
+ <header class="entry-header">
19
+ <?php the_post_thumbnail(); ?>
20
+ <?php if ( is_single() ) : ?>
21
+ <h1 class="entry-title"><?php the_title(); ?></h1>
22
+ <?php else : ?>
23
+ <h1 class="entry-title">
24
+ <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'bootstrap' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
25
+ </h1>
26
+ <?php endif; // is_single() ?>
27
+ <?php if ( comments_open() ) : ?>
28
+ <div class="comments-link">
29
+ <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'bootstrap' ) . '</span>', __( '1 Reply', 'bootstrap' ), __( '% Replies', 'bootstrap' ) ); ?>
30
+ </div>
31
+ <?php endif; // comments_open() ?>
32
+ </header>
33
+
34
+ <?php if ( is_search() ):
35
+ // Only display Excerpts for Search ?>
36
+ <div class="entry-summary">
37
+ <?php the_excerpt(); ?>
38
+ </div>
39
+ <?php else : ?>
40
+ <div class="entry-content">
41
+ <?php the_content( __( 'Continue reading', 'bootstrap' ) ); ?>
42
+ <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'bootstrap' ), 'after' => '</div>' ) ); ?>
43
+ </div>
44
+ <?php endif; ?>
45
+
46
+ <footer class="entry-meta clearfix">
47
+ <?php bootstrap_entry_meta(); ?>
48
+ <?php edit_post_link( __( 'Edit', 'bootstrap' ), '<span class="edit-link">', '</span>' ); ?>
49
+ <?php if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ):
50
+ // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>
51
+ <div class="author-info clearfix">
52
+ <div class="author-avatar">
53
+ <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'bootstrap_author_bio_avatar_size', 68 ) ); ?>
54
+ </div>
55
+ <div class="author-description">
56
+ <h2><?php printf( __( 'About %s', 'bootstrap' ), get_the_author() ); ?></h2>
57
+ <p><?php the_author_meta( 'description' ); ?></p>
58
+ <div class="author-link">
59
+ <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
60
+ <?php printf( __( 'View all posts by %s <span class="meta-nav">&rarr;</span>', 'bootstrap' ), get_the_author() ); ?>
61
+ </a>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ <?php endif; ?>
66
+ </footer>
67
+ </article>
@@ -0,0 +1,72 @@
1
+ /*
2
+ Theme Name: [bootstrap]
3
+ Description: Used to style the TinyMCE editor.
4
+ */
5
+
6
+ p {
7
+ margin: 0 0 9px;
8
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
9
+ font-size: 13px;
10
+ line-height: 18px;
11
+ small {
12
+ font-size: 11px;
13
+ color: #999999;
14
+ }
15
+ }
16
+
17
+ h1, h2, h3, h4, h5, h6 {
18
+ margin: 0;
19
+ font-weight: bold;
20
+ color: #333333;
21
+ text-rendering: optimizelegibility;
22
+ }
23
+
24
+ h1 small, h2 small, h3 small, h4 small, h5 small, h6 small {
25
+ font-weight: normal;
26
+ color: #999999;
27
+ }
28
+
29
+ h1 {
30
+ font-size: 30px;
31
+ line-height: 36px;
32
+ small {
33
+ font-size: 18px;
34
+ }
35
+ }
36
+
37
+ h2 {
38
+ font-size: 24px;
39
+ line-height: 36px;
40
+ small {
41
+ font-size: 18px;
42
+ }
43
+ }
44
+
45
+ h3 {
46
+ line-height: 27px;
47
+ font-size: 18px;
48
+ small {
49
+ font-size: 14px;
50
+ }
51
+ }
52
+
53
+ h4, h5, h6 {
54
+ line-height: 18px;
55
+ }
56
+
57
+ h4 {
58
+ font-size: 14px;
59
+ small {
60
+ font-size: 12px;
61
+ }
62
+ }
63
+
64
+ h5 {
65
+ font-size: 12px;
66
+ }
67
+
68
+ h6 {
69
+ font-size: 11px;
70
+ color: #999999;
71
+ text-transform: uppercase;
72
+ }
@@ -0,0 +1,29 @@
1
+ <?php
2
+ /**
3
+ * The default template for displaying footer
4
+ *
5
+ * @category Theme
6
+ * @package [bootstrap]
7
+ * @author [Your Name]
8
+ * @copyright 2012 [Your Name]
9
+ */
10
+ ?>
11
+ </div>
12
+ <?php get_sidebar(); ?>
13
+ </section>
14
+ </div>
15
+ <footer class="footer" role="contentinfo">
16
+ <?php do_action( 'bootstrap_footer' ); ?>
17
+ <a href="<?php echo esc_url( __( 'http://wordpress.org/', 'bootstrap' ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'bootstrap' ); ?>"><?php printf( __( 'Proudly powered by %s', 'bootstrap' ), 'WordPress' ); ?></a>
18
+ </footer>
19
+ </div>
20
+ <?php
21
+ /* Always have wp_footer() just before the closing </body>
22
+ * tag of your theme, or you will break many plugins, which
23
+ * generally use this hook to reference JavaScript files.
24
+ */
25
+
26
+ wp_footer();
27
+ ?>
28
+ </body>
29
+ </html>
@@ -0,0 +1,1528 @@
1
+ <?php
2
+ /**
3
+ * [bootstrap] theme functions and definitions
4
+ *
5
+ * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
6
+ *
7
+ * @category Theme
8
+ * @package [bootstrap]
9
+ * @author [Your Name]
10
+ * @copyright 2012 [Your Name]
11
+ */
12
+
13
+ global $of_options, $data;
14
+
15
+ /**
16
+ * Set the content width based on the theme's design and stylesheet.
17
+ *
18
+ * Used to set the width of images and content. Should be equal to the width the theme
19
+ * is designed for, generally via the style.css stylesheet.
20
+ */
21
+ if ( ! isset( $content_width ) )
22
+ $content_width = 540;
23
+
24
+ /**
25
+ * Sets up theme defaults and registers support for various WordPress features.
26
+ *
27
+ * Note that this function is hooked into the after_setup_theme hook, which runs
28
+ * before the init hook. The init hook is too late for some features, such as indicating
29
+ * support post thumbnails.
30
+ *
31
+ * To override bootstrap_setup() in a child theme, add your own bootstrap_setup to your child theme's
32
+ * functions.php file.
33
+ *
34
+ * @uses add_theme_support() To add support for post thumbnails, automatic feed links and Post Formats.
35
+ * @uses register_nav_menus() To add support for navigation menus.
36
+ * @uses add_custom_background() To add support for a custom background.
37
+ * @uses add_editor_style() To style the visual editor.
38
+ * @uses load_theme_textdomain() For translation/localization support.
39
+ * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
40
+ *
41
+ * @since [bootstrap] 1.0
42
+ */
43
+ function bootstrap_setup() {
44
+ // SET THEME LANGUAGES DIRECTORY
45
+ // Theme translations can be filed in the my_theme/languages/ directory
46
+ load_theme_textdomain( 'bootstrap', get_template_directory() . '/languages' );
47
+
48
+ // This theme styles the visual editor with editor-style.css to match the theme style.
49
+ add_editor_style( 'stylesheets/editor-style.css' );
50
+
51
+ // Adds support for rss links
52
+ add_theme_support( 'automatic-feed-links' );
53
+
54
+ // Add support for a variety of post formats (http://codex.wordpress.org/Post_Formats)
55
+ // Child Themes inherit the post formats defined by the parent theme
56
+ add_theme_support( 'post-formats', array( 'aside', 'link', 'image', 'quote', 'status' ) );
57
+
58
+ // Add post thumbnails (http://codex.wordpress.org/Post_Thumbnails)
59
+ add_theme_support( 'post-thumbnails' );
60
+ set_post_thumbnail_size( 540, 230, true ); // Default Thumbnail Image
61
+
62
+ // Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus)
63
+ register_nav_menu( 'primary', __( 'Primary menu', 'bootstrap' ) );
64
+
65
+ /* Options Framework */
66
+ locate_template( 'options.php', true );
67
+ locate_template( 'admin/index.php', true );
68
+
69
+ do_action( 'bootstrap_setup' );
70
+ }
71
+
72
+ add_action( 'after_setup_theme', 'bootstrap_setup' );
73
+
74
+ /**
75
+ * Some cleanup
76
+ *
77
+ * @since [bootstrap] 1.0
78
+ * @return void
79
+ */
80
+ function bootstrap_init() {
81
+ // autolinks in comments
82
+ remove_filter( 'comment_text', 'make_clickable', 9 );
83
+
84
+ // Display the links to the general feeds: Post and Comment Feed
85
+ remove_action( 'wp_head', 'feed_links', 2 );
86
+
87
+ // Display the links to the extra feeds such as category feeds
88
+ remove_action( 'wp_head', 'feed_links_extra', 3 );
89
+
90
+ // Display the link to the Really Simple Discovery service endpoint, EditURI link
91
+ remove_action( 'wp_head', 'rsd_link' );
92
+
93
+ // Display the link to the Windows Live Writer manifest file.
94
+ remove_action( 'wp_head', 'wlwmanifest_link' );
95
+ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
96
+
97
+ // index link
98
+ remove_action( 'wp_head', 'index_rel_link' );
99
+
100
+ // prev link
101
+ remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
102
+
103
+ // start link
104
+ remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
105
+
106
+ // Display relational links for the posts adjacent to the current post.
107
+ remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
108
+
109
+ // Display the XHTML generator that is generated on the wp_head hook, WP version
110
+ remove_action( 'wp_head', 'wp_generator' );
111
+ remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
112
+
113
+ // remove jetpack open graph tags
114
+ remove_action( 'wp_head', 'jetpack_og_tags' );
115
+
116
+ add_filter( 'use_default_gallery_style', '__return_null' );
117
+
118
+ /* Custom oEmbed Providers */
119
+
120
+ // Add Soundcloud oEmbed
121
+ wp_oembed_add_provider( '#http://(www\.)?soundcloud\.com/.*#i', 'http://soundcloud.com/oembed', true );
122
+
123
+ // Add Kickbootstrap oEmbed
124
+ wp_oembed_add_provider( '#http://(www\.)?kickbootstrap\.com/projects/.*#i', 'http://www.kickbootstrap.com/services/oembed', true );
125
+
126
+ // Add Instagram oEmbed
127
+ wp_oembed_add_provider( '#http://(www\.)?instagr(am)?\.(am|com)/.*#i', 'http://api.instagram.com/oembed', true );
128
+
129
+ // Add Slideshare oEmbed
130
+ wp_oembed_add_provider( '#http://(www\.)?slideshare\.net/.*#i', 'http://api.embed.ly/v1/api/oembed', true );
131
+ }
132
+
133
+ add_action( 'init', 'bootstrap_init' );
134
+
135
+ /**
136
+ * Remove the WordPress version from RSS feeds
137
+ */
138
+ add_filter( 'the_generator', '__return_false' );
139
+
140
+ /**
141
+ * Adds custom scripts to theme header
142
+ *
143
+ * @since [bootstrap] 1.0
144
+ * @return void
145
+ */
146
+ function bootstrap_enqueue_scripts() {
147
+ $theme = wp_get_theme();
148
+ $version = $theme['Version'];
149
+
150
+ wp_deregister_script( 'jquery' );
151
+ wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3' );
152
+
153
+ /**
154
+ * We add some JavaScript to pages with the comment form
155
+ * to support sites with threaded comments (when in use).
156
+ */
157
+ if ( is_singular() and comments_open() and get_option( 'thread_comments' ) ) {
158
+ wp_enqueue_script( 'comment-reply' );
159
+ }
160
+
161
+ wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/javascripts/modernizr.min.js', false, '2.6.2' );
162
+
163
+ // Minified
164
+ //wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/javascripts/boostrap.min.js', array( 'jquery' ), '2.2.2', true );
165
+
166
+ // Unminified
167
+ wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/javascripts/bootstrap.js', array( 'jquery' ), '2.2.2', true );
168
+
169
+ wp_enqueue_script( 'app', get_template_directory_uri() . '/javascripts/app.js', array( 'jquery' ), $version, true );
170
+ }
171
+
172
+ add_action( 'wp_enqueue_scripts', 'bootstrap_enqueue_scripts' );
173
+
174
+ /**
175
+ * Adds custom styles to theme header
176
+ *
177
+ * @since [bootstrap] 1.0
178
+ * @return void
179
+ */
180
+ function bootstrap_enqueue_styles() {
181
+ $theme = wp_get_theme();
182
+ $version = $theme['Version'];
183
+
184
+ wp_enqueue_style( 'app', get_stylesheet_uri(), false, $version, 'all' );
185
+ }
186
+
187
+ add_action( 'wp_enqueue_scripts', 'bootstrap_enqueue_styles' );
188
+
189
+ /**
190
+ * Makes some changes to the <title> tag, by filtering the output of wp_title().
191
+ *
192
+ * If we have a site description and we're viewing the home page or a blog posts
193
+ * page (when using a static front page), then we will add the site description.
194
+ *
195
+ * If we're viewing a search result, then we're going to recreate the title entirely.
196
+ * We're going to add page numbers to all titles as well, to the middle of a search
197
+ * result title and the end of all other titles.
198
+ *
199
+ * The site title also gets added to all titles.
200
+ *
201
+ * @since [bootstrap] 1.0
202
+ *
203
+ * @param string $title Title generated by wp_title()
204
+ * @param string $separator The separator passed to wp_title(). Base theme uses a vertical bar, "|", as a separator in header.php.
205
+ * @return string The new title, ready for the <title> tag.
206
+ */
207
+ function bootstrap_filter_wp_title( $title, $separator ) {
208
+ // Don't affect wp_title() calls in feeds.
209
+ if ( is_feed() or function_exists( 'get_wpseo_options' ) )
210
+ return $title;
211
+
212
+ // The $paged global variable contains the page number of a listing of posts.
213
+ // The $page global variable contains the page number of a single post that is paged.
214
+ // We'll display whichever one applies, if we're not looking at the first page.
215
+ global $paged, $page, $post;
216
+
217
+ if ( is_search() ) {
218
+ // If we're a search, let's start over:
219
+ $title = sprintf( __( 'Search results for %s', 'bootstrap' ), '"' . get_search_query() . '"' );
220
+ // Add a page number if we're on page 2 or more:
221
+ if ( $paged >= 2 ) {
222
+ $title .= " $separator " . sprintf( __( 'Page %s', 'bootstrap' ), $paged );
223
+ }
224
+ // Add the site name to the end:
225
+ $title .= " $separator " . get_bloginfo( 'name', 'display' );
226
+ // We're done. Let's send the new title back to wp_title():
227
+ return $title;
228
+ }
229
+
230
+ $return = array();
231
+
232
+ if ( $title != '' ) {
233
+ $return[] = str_replace( " $separator ", '', apply_filters( 'the_category', $title ) );
234
+ }
235
+
236
+ if ( is_single() ) {
237
+ if ( get_post_meta( $post->ID, 'title', true ) ) {
238
+ $return[] = stripslashes( get_post_meta( $post->ID, 'seo_title', true ) );
239
+ }
240
+ elseif ( ! in_array( $post->post_type, array( 'post', 'page', 'attachment' ) ) ) {
241
+ $post_type_obj = get_post_type_object( $post->post_type );
242
+ $return[] = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name );
243
+ }
244
+ }
245
+
246
+ // Add a page number if necessary:
247
+ if ( $paged >= 2 or $page >= 2 ) {
248
+ $return[] = sprintf( __( 'Page %s', 'bootstrap' ), max( $paged, $page ) );
249
+ }
250
+
251
+ // Add the site name to the end:
252
+ $return[] = get_bloginfo( 'name', 'display' );
253
+
254
+ // If we have a site description and we're on the home/front page, add the description:
255
+ $site_description = get_bloginfo( 'description', 'display' );
256
+ if ( $site_description and ( is_home() or is_front_page() ) ) {
257
+ $return[] = $site_description;
258
+ }
259
+
260
+ // Return the new title to wp_title():
261
+ return implode( " $separator ", $return );
262
+ }
263
+
264
+ add_filter( 'wp_title', 'bootstrap_filter_wp_title', 10, 3 );
265
+
266
+ /**
267
+ * Adds code to header
268
+ *
269
+ * @since [bootstrap] 1.0
270
+ * @return string misc
271
+ */
272
+ function bootstrap_header() {
273
+ ?>
274
+ <!-- For third-generation iPad with high-resolution Retina display: -->
275
+ <link rel="apple-touch-icon-precomposed" sizes="144x144" href="apple-touch-icon-144x144-precomposed.png?1333401433">
276
+ <!-- For iPhone with high-resolution Retina display: -->
277
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114-precomposed.png?1333401433">
278
+ <!-- For first- and second-generation iPad: -->
279
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72-precomposed.png?1333401433">
280
+ <!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
281
+ <link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png?1333401433">
282
+ <!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
283
+ <link rel="shortcut icon" href="favicon.ico?1333401433" type="image/x-icon" />
284
+ <?php
285
+ do_action( 'bootstrap_header' );
286
+ }
287
+
288
+ add_action( 'wp_head', 'bootstrap_header', 10 );
289
+
290
+ /**
291
+ * Adds code to footer
292
+ *
293
+ * @since [bootstrap] 1.0
294
+ * @return string misc
295
+ */
296
+ function bootstrap_footer() {}
297
+
298
+ add_action( 'wp_footer', 'bootstrap_footer', 10 );
299
+
300
+ /**
301
+ * Defines widget areas
302
+ *
303
+ * @since [bootstrap] 1.0
304
+ * @return void
305
+ */
306
+ function bootstrap_widgets_init() {
307
+ register_sidebar(
308
+ array(
309
+ 'name' => __( 'Primary widget area', 'bootstrap' ),
310
+ 'id' => 'primary-widget-area',
311
+ 'description' => __( '', 'bootstrap' ),
312
+ 'before_widget' => '<div id="%1$s" class="nav nav-list module %2$s">',
313
+ 'after_widget' => '</div>',
314
+ 'before_title' => '<h4 class="nav-header">',
315
+ 'after_title' => '</h4>',
316
+ )
317
+ );
318
+ }
319
+
320
+ add_action( 'widgets_init', 'bootstrap_widgets_init' );
321
+
322
+ /**
323
+ * Clean up output of stylesheet <link> tags
324
+ *
325
+ * @since [bootstrap] 1.0
326
+ */
327
+ function bootstrap_clean_style_tag( $input ) {
328
+ preg_match_all( "!<link rel='stylesheet'\s?(id='[^']+')?\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches );
329
+ // Only display media if it's print
330
+ $media = $matches[3][0] == 'print' ? ' media="print"' : '';
331
+
332
+ return '<link rel="stylesheet" href="' . $matches[ 2 ][ 0 ] . '"' . $media . '>' . "\n";
333
+ }
334
+
335
+ add_filter( 'style_loader_tag', 'bootstrap_clean_style_tag' );
336
+
337
+ /**
338
+ * Remove unnecessary self-closing tags
339
+ *
340
+ * @since [bootstrap] 1.0
341
+ */
342
+ function bootstrap_remove_self_closing_tags( $input ) {
343
+ return str_replace( ' />', '>', $input );
344
+ }
345
+
346
+ add_filter( 'get_avatar', 'bootstrap_remove_self_closing_tags' ); // <img />
347
+ add_filter( 'comment_id_fields', 'bootstrap_remove_self_closing_tags' ); // <input />
348
+ add_filter( 'post_thumbnail_html', 'bootstrap_remove_self_closing_tags' ); // <img />
349
+
350
+ /**
351
+ * Wrap embedded media as suggested by Readability
352
+ *
353
+ * @link https://gist.github.com/965956
354
+ * @link http://www.readability.com/publishers/guidelines#publisher
355
+ * @since [bootstrap] 1.0
356
+ */
357
+ function bootstrap_embed_wrap( $cache, $url, $attr = '', $post_ID = '' ) {
358
+ return '<div class="entry-content-asset">' . $cache . '</div>';
359
+ }
360
+
361
+ add_filter( 'embed_oembed_html', 'bootstrap_embed_wrap', 10, 4 );
362
+ add_filter( 'embed_googlevideo', 'bootstrap_embed_wrap', 10, 2 );
363
+
364
+ /**
365
+ * Remove height/width attributes on images so they can be responsive
366
+ *
367
+ * @since [bootstrap] 1.0
368
+ */
369
+ function bootstrap_remove_thumbnail_dimensions( $html, $id, $alt, $title ) {
370
+ return preg_replace(
371
+ array(
372
+ '/\s+width="\d+"/i',
373
+ '/\s+height="\d+"/i',
374
+ '/alt=""/i',
375
+ ),
376
+ array(
377
+ '',
378
+ '',
379
+ '',
380
+ 'alt="' . $title . '"',
381
+ ),
382
+ $html
383
+ );
384
+ }
385
+
386
+ add_filter( 'post_thumbnail_html', 'bootstrap_remove_thumbnail_dimensions', 10, 4 );
387
+ add_filter( 'image_send_to_editor', 'bootstrap_remove_thumbnail_dimensions', 10, 4 );
388
+ add_filter( 'get_image_tag', 'bootstrap_remove_thumbnail_dimensions', 10, 4 );
389
+ add_filter( 'bootstrap_shortcode_caption_content', 'bootstrap_remove_thumbnail_dimensions', 10, 4 );
390
+
391
+ /**
392
+ * Clean the output of attributes of images in editor.
393
+ *
394
+ * @link http://www.sitepoint.com/wordpress-change-img-tag-html/
395
+ * @since [bootstrap] 1.0
396
+ */
397
+ function bootstrap_image_tag_class( $class, $id, $align, $size ) {
398
+ $align = 'align' . esc_attr( $align );
399
+ return $align;
400
+ }
401
+
402
+ add_filter( 'get_image_tag_class', 'bootstrap_image_tag_class', 0, 4 );
403
+
404
+ /**
405
+ * Add thumbnail class to thumbnail links
406
+ *
407
+ * @since [bootstrap] 1.0
408
+ */
409
+ function bootstrap_add_class_attachment_link( $html ) {
410
+ $postid = get_the_ID();
411
+ $html = str_replace( '<a', '<a class="thumbnail"', $html );
412
+
413
+ return $html;
414
+ }
415
+
416
+ add_filter( 'wp_get_attachment_link', 'bootstrap_add_class_attachment_link', 10, 1 );
417
+ add_filter( 'bootstrap_shortcode_caption_content', 'bootstrap_add_class_attachment_link', 10, 1 );
418
+
419
+ /**
420
+ * Filter in a link to a content ID attribute for the next/previous image links on image attachment pages
421
+ *
422
+ * @since [bootstrap] 1.0
423
+ */
424
+ function bootstrap_enhanced_image_navigation( $url, $id ) {
425
+ if ( ! is_attachment() && ! wp_attachment_is_image( $id ) )
426
+ return $url;
427
+
428
+ $image = get_post( $id );
429
+ if ( ! empty( $image->post_parent ) && $image->post_parent != $id )
430
+ $url .= '#main';
431
+
432
+ return $url;
433
+ }
434
+
435
+ add_filter( 'attachment_link', 'bootstrap_enhanced_image_navigation', 10, 2 );
436
+
437
+ /**
438
+ * Replace various active menu class names with "active"
439
+ * Remove the id="" on nav menu items
440
+ * Return 'menu-slug' for nav menu classes
441
+ *
442
+ * @since [bootstrap] 1.0
443
+ */
444
+ function bootstrap_wp_nav_menu_class( $classes, $item ) {
445
+ $slug = sanitize_title( $item->title );
446
+ $classes = preg_replace( '/(current(-menu-|[-_]page[-_])(item|parent|ancestor))/', 'active', $classes );
447
+ $classes = preg_replace( '/^((menu|page)[-_\w+]+)+/', '', $classes );
448
+
449
+ $classes[] = 'menu-' . $slug;
450
+
451
+ return array_filter( array_unique( $classes ), 'is_element_empty' );
452
+ }
453
+
454
+ add_filter( 'nav_menu_css_class', 'bootstrap_wp_nav_menu_class', 10, 2 );
455
+ add_filter( 'nav_menu_item_id', '__return_null' );
456
+
457
+ /**
458
+ * Check if $element is empty
459
+ *
460
+ * @since [bootstrap] 1.0
461
+ */
462
+ function is_element_empty( $element ) {
463
+ $element = trim( $element );
464
+
465
+ return ( bool ) ! empty( $element );
466
+ }
467
+
468
+ /**
469
+ * Create a graceful fallback to wp_page_menu
470
+ *
471
+ * @since [bootstrap] 1.0
472
+ */
473
+ function bootstrap_page_menu() {
474
+
475
+ $args = array(
476
+ 'sort_column' => 'menu_order, post_title',
477
+ 'menu_class' => 'nav nav-list',
478
+ 'include' => '',
479
+ 'exclude' => '',
480
+ 'echo' => true,
481
+ 'show_home' => false,
482
+ 'link_before' => '',
483
+ 'link_after' => '',
484
+ );
485
+
486
+ wp_page_menu( $args );
487
+ }
488
+
489
+ /**
490
+ * Adds extra info to language attributes string
491
+ *
492
+ * @since [bootstrap] 1.0
493
+ */
494
+ function bootstrap_language_attributes() {
495
+ $attr = array();
496
+ $output = '';
497
+
498
+ if ( function_exists( 'is_rtl' ) ) {
499
+ if ( is_rtl() == 'rtl' ) {
500
+ $attr[] = 'dir="rtl"';
501
+ }
502
+ }
503
+
504
+ $lang = get_bloginfo( 'language' );
505
+
506
+ if ( $lang and $lang !== 'en-US' ) {
507
+ $attr[] = "lang=\"$lang\"";
508
+ }
509
+ else {
510
+ $attr[] = 'lang="en"';
511
+ }
512
+
513
+ return implode( ' ', $attr );
514
+ }
515
+
516
+ add_filter( 'language_attributes', 'bootstrap_language_attributes' );
517
+
518
+ /**
519
+ * remove the p from around imgs
520
+ *
521
+ * @link https://gist.github.com/975026
522
+ * @since [bootstrap] 1.0
523
+ */
524
+ function bootstrap_filter_ptags_on_images( $content ) {
525
+ // Replace br tags inside figures
526
+ $content = preg_replace( '/(<figure .*>)?<br\s?\/?>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*/iU', '\1\2\3\4', $content );
527
+ // do a regular expression replace...
528
+ // find all p tags that have just
529
+ // <p>maybe some white space<img all stuff up to /> then maybe whitespace </p>
530
+ // replace it with just the image tag...
531
+ $content = preg_replace( '/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content );
532
+ // now pass that through and do the same for iframes...
533
+ return preg_replace( '/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content );
534
+ }
535
+
536
+ add_filter( 'the_content', 'bootstrap_filter_ptags_on_images' );
537
+
538
+ /**
539
+ * Adds browser detection body class
540
+ * Adds extra classes to body tag on custom taxonomies
541
+ *
542
+ * @since [bootstrap] 1.0
543
+ */
544
+ function bootstrap_body_classes( $classes ) {
545
+ global $wp_query, $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
546
+
547
+ if ( isset( $wp_query->query_vars['taxonomy'] ) or isset( $wp_query->query_vars['term'] ) ) {
548
+ array_push( $classes, 'custom-taxonomy-archive', 'custom-taxonomy-' . ( isset( $wp_query->query_vars[ 'taxonomy' ] ) ? get_query_var( 'taxonomy' ) : get_query_var( 'term' ) ) . '-archive' );
549
+ }
550
+
551
+ if ( $is_lynx ) $classes[] = 'lynx';
552
+ elseif ( $is_gecko ) $classes[] = 'gecko';
553
+ elseif ( $is_opera ) $classes[] = 'opera';
554
+ elseif ( $is_NS4 ) $classes[] = 'ns4';
555
+ elseif ( $is_safari ) $classes[] = 'safari';
556
+ elseif ( $is_chrome ) $classes[] = 'chrome';
557
+ elseif ( $is_IE ) $classes[] = 'ie';
558
+ else $classes[] = 'unknown';
559
+
560
+ if ( $is_iphone ) $classes[] = 'iphone';
561
+
562
+ // Add post/page slug
563
+ if ( is_single() or is_page() and ! is_front_page() ) {
564
+ $classes[] = basename( get_permalink() );
565
+ }
566
+
567
+ // Remove unnecessary classes
568
+ $home_id_class = 'page-id-' . get_option( 'page_on_front' );
569
+ $remove_classes = array(
570
+ 'page-template-default',
571
+ $home_id_class,
572
+ );
573
+
574
+ $classes = array_diff( $classes, $remove_classes );
575
+
576
+ return $classes;
577
+ }
578
+
579
+ add_filter( 'body_class', 'bootstrap_body_classes' );
580
+
581
+ /**
582
+ * Modifies output of custom post formats.
583
+ *
584
+ * @since [bootstrap] 1.0
585
+ */
586
+ function bootstrap_custom_content( $content ) {
587
+ /* Check if we're displaying a 'quote' post. */
588
+ if ( has_post_format( 'quote' ) ) {
589
+ /* Match any <blockquote> elements. */
590
+ preg_match( '/<blockquote.*?>/', $content, $matches );
591
+
592
+ /* If no <blockquote> elements were found, wrap the entire content in one. */
593
+ if ( empty( $matches ) ) {
594
+ $content = "<blockquote>{$content}</blockquote>";
595
+ }
596
+ }
597
+ elseif ( has_post_format( 'aside' ) and ! is_singular() ) {
598
+ preg_match( '/<p>(.*?)<\/p>(?!\s*<p>)/', $content, $matches );
599
+
600
+ $content = str_replace( $matches[1], $matches[1] . ' <a href="' . get_permalink() . '">&#8734;</a>', $content );
601
+ }
602
+
603
+ return $content;
604
+ }
605
+
606
+ add_filter( 'the_content', 'bootstrap_custom_content' );
607
+
608
+ /**
609
+ * Remove <p> and <br /> in the shortcodes
610
+ *
611
+ * @since [bootstrap] 1.0
612
+ */
613
+ function bootstrap_shortcode_empty_paragraph_fix( $content ) {
614
+ $array = array(
615
+ '<p>[' => '[',
616
+ ']</p>' => ']',
617
+ ']<br />' => ']',
618
+ );
619
+
620
+ // replace the strings in the $content
621
+ $content = strtr( $content, $array );
622
+
623
+ return $content;
624
+ }
625
+
626
+ add_filter( 'the_content', 'bootstrap_shortcode_empty_paragraph_fix' );
627
+
628
+ /**
629
+ * Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
630
+ *
631
+ * Create your own bootstrap_entry_meta() to override in a child theme.
632
+ *
633
+ * @since [bootstrap] 1.0
634
+ */
635
+ function bootstrap_entry_meta() {
636
+ // Translators: used between list items, there is a space after the comma.
637
+ $categories_list = get_the_category_list( __( ', ', 'bootstrap' ) );
638
+
639
+ // Translators: used between list items, there is a space after the comma.
640
+ $tag_list = get_the_tag_list( '', __( ', ', 'bootstrap' ) );
641
+
642
+ $date = sprintf(
643
+ '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a>',
644
+ esc_url( get_permalink() ),
645
+ esc_attr( get_the_time() ),
646
+ esc_attr( get_the_date( 'c' ) ),
647
+ esc_html( get_the_date() )
648
+ );
649
+
650
+ $author = sprintf(
651
+ '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
652
+ esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
653
+ esc_attr( sprintf( __( 'View all posts by %s', 'bootstrap' ), get_the_author() ) ),
654
+ get_the_author()
655
+ );
656
+
657
+ // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
658
+ if ( $tag_list ) {
659
+ $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'bootstrap' );
660
+ }
661
+ elseif ( $categories_list ) {
662
+ $utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'bootstrap' );
663
+ }
664
+ else {
665
+ $utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'bootstrap' );
666
+ }
667
+
668
+ printf(
669
+ $utility_text,
670
+ $categories_list,
671
+ $tag_list,
672
+ $date,
673
+ $author
674
+ );
675
+ }
676
+
677
+ /**
678
+ * Returns a "Continue Reading" link for excerpts
679
+ *
680
+ * @since [bootstrap] 1.0
681
+ */
682
+ function bootstrap_continue_reading_link() {
683
+ $read_more_link = ' <a href="' . get_permalink() . '" class="more-link">' . __( 'Continue reading', 'bootstrap' ) . '</a>';
684
+
685
+ return $read_more_link;
686
+ }
687
+
688
+ /**
689
+ * Replaces "[...]" (appended to automatically generated excerpts ) with bootstrap_continue_reading_link().
690
+ *
691
+ * To override this in a child theme, remove the filter and add your own
692
+ * function tied to the excerpt_more filter hook.
693
+ *
694
+ * @since [bootstrap] 1.0
695
+ */
696
+ function bootstrap_auto_excerpt_more( $more ) {
697
+ return bootstrap_continue_reading_link();
698
+ }
699
+
700
+ add_filter( 'excerpt_more', 'bootstrap_auto_excerpt_more' );
701
+ add_filter( 'the_content_more_link', 'bootstrap_auto_excerpt_more' );
702
+
703
+ /**
704
+ * Adds a pretty "Continue Reading" link to custom post excerpts.
705
+ *
706
+ * To override this link in a child theme, remove the filter and add your own
707
+ * function tied to the get_the_excerpt filter hook.
708
+ *
709
+ * @since [bootstrap] 1.0
710
+ */
711
+ function bootstrap_custom_excerpt_more( $output ) {
712
+ if ( has_excerpt() and ! is_attachment() ) {
713
+ $output .= bootstrap_continue_reading_link();
714
+ }
715
+ return $output;
716
+ }
717
+
718
+ add_filter( 'get_the_excerpt', 'bootstrap_custom_excerpt_more' );
719
+
720
+ /**
721
+ * Adds nofollow rel atribute to content links
722
+ *
723
+ * @since [bootstrap] 1.0
724
+ */
725
+ function bootstrap_nofollow_links_in_post( $text ) {
726
+ global $post;
727
+
728
+ if ( get_post_meta( $post->ID, 'nofollow_links', true ) ) {
729
+ preg_match_all( '/<a.*? href=\"(.*? )\".*?>(.*? )<\/a>/i', $text, $links );
730
+ $match_count = count( $links[0] );
731
+
732
+ for ( $i = 0; $i < $match_count; ++$i ) {
733
+ if ( ! preg_match( '/rel=[\"\']*nofollow[\"\']*/', $links[0][$i] ) ) {
734
+ preg_match_all( '/<a.*? href=\"(.*? )\"(.*? )>(.*? )<\/a>/i', $links[0][$i], $link_text );
735
+
736
+ $search = '>'.$link_text[3][0].'</a>';
737
+ $replace = ' rel="nofollow">'.$link_text[3][0].'</a>';
738
+
739
+ $text = str_replace( $search, $replace, $text );
740
+ }
741
+ }
742
+ }
743
+
744
+ return $text;
745
+ }
746
+
747
+ add_action( 'the_content', 'bootstrap_nofollow_links_in_post' );
748
+
749
+ /**
750
+ * Custom tag clould args
751
+ *
752
+ * @since [bootstrap] 1.0
753
+ */
754
+ function bootstrap_widget_tag_cloud_args( $args ) {
755
+ $args['number'] = 20; // show less tags
756
+ $args['largest'] = 13; // make largest and smallest the same
757
+ $args['smallest'] = 13;
758
+ $args['unit'] = 'px';
759
+ $args['format'] = 'list'; // ul with a class of wp-tag-cloud
760
+ // $args['exclude'] = array(20, 80, 92); // exclude tags by ID
761
+ // $args['taxonomy'] = array('post_tag', 'ingredients'); // add post tags and ingredients taxonomy
762
+
763
+ return $args;
764
+ }
765
+
766
+ add_filter( 'widget_tag_cloud_args', 'bootstrap_widget_tag_cloud_args' );
767
+
768
+ /**
769
+ * Filter tag clould output so that it can be styled by CSS
770
+ *
771
+ * @since [bootstrap] 1.0
772
+ */
773
+ function bootstrap_add_tag_class( $taglinks ) {
774
+ $tags = explode( '</a>', $taglinks );
775
+ $regex = "#(.*tag-link[-])(.*)(' title.*)#e";
776
+ foreach ( $tags as $tag ) {
777
+ $tagn[] = preg_replace( $regex, "('$1$2 label tag-'.get_tag($2)->slug.'$3')", $tag );
778
+ }
779
+
780
+ return implode( '</a>', $tagn );
781
+ }
782
+
783
+ add_filter( 'wp_tag_cloud', 'bootstrap_add_tag_class' );
784
+
785
+ /**
786
+ * Outputs WP Pagenavi pagination or wordpress navigation
787
+ *
788
+ * @since [bootstrap] 1.0
789
+ */
790
+ function pagination( $query = false ) {
791
+ global $wp_query;
792
+
793
+ if ( is_single() ) {
794
+ ?>
795
+ <nav id="comment-nav-below" class="navigation pager" role="navigation">
796
+ <h1 class="assistive-text section-heading"><?php _e( 'Post Navigation', 'bootstrap' ); ?></h1>
797
+ <?php
798
+ if ( $previous = get_previous_post() ):?>
799
+ <div class="nav-previous previous">
800
+ <a href="<?php echo get_permalink( $previous );?>" title="<?php printf( __( 'Permalink to %s', 'bootstrap' ), get_the_title( $previous ) );?>"><?php _e( 'Previous', 'bootstrap' ); ?></a>
801
+ </div>
802
+ <?php endif;?>
803
+ <?php
804
+ if ( $next = get_next_post() ):?>
805
+ <div class="nav-next next">
806
+ <a href="<?php echo get_permalink( $next );?>" title="<?php printf( __( 'Permalink to %s', 'bootstrap' ), get_the_title( $next ) );?>"><?php _e( 'Next', 'bootstrap' ); ?></a>
807
+ </div>
808
+ <?php endif;?>
809
+ </nav>
810
+ <?php
811
+ } else {
812
+ if ( $wp_query->max_num_pages > 1 ) {
813
+ if ( function_exists( 'wp_pagenavi' ) ) {
814
+ $args = array( 'options' => PageNavi_Core::$options->get_defaults() );
815
+ if ( $query !== false ) {
816
+ $args['query'] = $query;
817
+ }
818
+
819
+ wp_pagenavi( $args );
820
+ } else {
821
+ //get_template_part( 'templates/pager' );
822
+ $big = 999999999; // This needs to be an unlikely integer
823
+
824
+ // For more options and info view the docs for paginate_links()
825
+ // http://codex.wordpress.org/Function_Reference/paginate_links
826
+ $paginate_links = paginate_links(
827
+ array(
828
+ 'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
829
+ 'current' => max( 1, get_query_var( 'paged' ) ),
830
+ 'total' => $wp_query->max_num_pages,
831
+ 'mid_size' => 5,
832
+ 'prev_next' => True,
833
+ 'prev_text' => __( '&larr;' ),
834
+ 'next_text' => __( '&rarr;' ),
835
+ 'type' => 'list',
836
+ )
837
+ );
838
+
839
+ // Display the pagination if more than one page is found
840
+ if ( $paginate_links ) {
841
+ echo '<div class="pagination">';
842
+ echo $paginate_links;
843
+ echo '</div>';
844
+ }
845
+ }
846
+ }
847
+ }
848
+ }
849
+
850
+ add_action( 'pagination', 'pagination' );
851
+
852
+ /**
853
+ * Template for comments and pingbacks.
854
+ * Used as a callback by wp_list_comments() for displaying the comments.
855
+ *
856
+ * @since [bootstrap] 1.0
857
+ */
858
+ function bootstrap_comment( $comment, $args, $depth ) {
859
+ $GLOBALS['comment'] = $comment;
860
+ switch ( $comment->comment_type ) {
861
+ case 'pingback' :
862
+ case 'trackback' :
863
+ // Display trackbacks differently than normal comments.
864
+ ?>
865
+ <li <?php comment_class( 'media' ); ?> id="comment-<?php comment_ID(); ?>">
866
+ <p><?php _e( 'Pingback:', 'bootstrap' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'bootstrap' ), '<span class="edit-link">', '</span>' ); ?></p>
867
+ <?php
868
+ break;
869
+ default :
870
+ // Proceed with normal comments.
871
+ global $post;
872
+
873
+ $class = ( 1 == $comment->user_id ) ? 'author media' : 'media';
874
+ ?>
875
+ <li <?php comment_class( $class ); ?> id="li-comment-<?php comment_ID(); ?>">
876
+ <article id="comment-<?php comment_ID(); ?>" class="comment">
877
+ <header class="comment-meta comment-author vcard pull-left">
878
+ <?php
879
+ echo get_avatar( $comment, 60 );
880
+ ?>
881
+ </header>
882
+ <div class="media-body">
883
+ <h4 class="media-heading">
884
+ <?php
885
+ printf(
886
+ '<cite class="fn">%1$s %2$s</cite>',
887
+ get_comment_author_link(),
888
+ // If current post author is also comment author, make it known visually.
889
+ ( $comment->user_id === $post->post_author ) ? '<span> ' . __( 'Post author', 'bootstrap' ) . '</span>' : ''
890
+ );
891
+ printf(
892
+ '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
893
+ esc_url( get_comment_link( $comment->comment_ID ) ),
894
+ get_comment_time( 'c' ),
895
+ /* translators: 1: date, 2: time */
896
+ sprintf( __( '%1$s at %2$s', 'bootstrap' ), get_comment_date(), get_comment_time() )
897
+ );
898
+ ?>
899
+ </h4>
900
+ <?php
901
+ if ( '0' == $comment->comment_approved ):
902
+ ?>
903
+ <div class="alert-message success">
904
+ <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'bootstrap' ); ?></p>
905
+ </div>
906
+ <?php endif; ?>
907
+ <section class="comment-content comment">
908
+ <?php comment_text(); ?>
909
+ </section>
910
+
911
+ <div class="reply">
912
+ <?php edit_comment_link( __( 'Edit', 'bootstrap' ), '<span class="edit-link">', '</span> / ' ); ?>
913
+ <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'bootstrap' ), 'after' => ' <span>&darr;</span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
914
+ </div>
915
+ </div>
916
+ </article>
917
+ <?php
918
+ break;
919
+ } // end comment_type check
920
+ }
921
+
922
+ /**
923
+ * Template for comments form
924
+ *
925
+ * @since [bootstrap] 1.0
926
+ */
927
+ function bootstrap_comment_form( $args = array(), $post_id = null ) {
928
+ global $user_identity, $id;
929
+
930
+ $post_id = ( $post_id === null ) ? $id : $post_id;
931
+ $commenter = wp_get_current_commenter();
932
+ $req = get_option( 'require_name_email' );
933
+ $required_text = $req ? __( ' (required) ', 'bootstrap' ) : '';
934
+ $aria_req = $req ? ' aria-required="true" required="required"' : '';
935
+
936
+ $notes = array(
937
+ 'email_input_help' => '<span class="help-inline">' . __( 'Your email address will not be published.', 'bootstrap' ) . '</span>',
938
+ 'comment_input_help' => '<span class="help-block">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s', 'bootstrap' ), ' <code>' . allowed_tags() . '</code>' ) . '</span>',
939
+ );
940
+
941
+ $fields = array(
942
+ 'author' => '<div class="control-group"><label class="control-label" for="author">' . __( 'Name', 'bootstrap' ) . $required_text . '</label> ' .
943
+ '<div class="controls"><div class="input-prepend"><span class="add-on"><i class="icon-user"></i></span><input id="author" name="author" type="text" value="' . esc_attr( $commenter[ 'comment_author' ] ) . '" tabindex="1"' . $aria_req . ' placeholder="' . __( 'Name', 'bootstrap' ) . '" class="input-large"></div></div></div>',
944
+ 'email' => '<div class="control-group"><label class="control-label" for="email">' . __( 'Email', 'bootstrap' ) . $required_text . '</label> ' .
945
+ '<div class="controls"><div class="input-prepend"><span class="add-on"><i class="icon-envelope"></i></span><input id="email" name="email" type="text" value="' . esc_attr( $commenter[ 'comment_author_email' ] ) . '" tabindex="2"' . $aria_req . ' placeholder="' . __( 'Email', 'bootstrap' ) . '" class="input-large">' . apply_filters( 'email_input_help', $notes[ 'email_input_help' ] ) . '</div></div></div>',
946
+ 'url' => '<div class="control-group"><label class="control-label" for="url">' . __( 'Website', 'bootstrap' ) . '</label>' .
947
+ '<div class="controls"><div class="input-prepend"><span class="add-on"><i class="icon-home"></i></span><input id="url" name="url" type="url" value="' . esc_attr( $commenter[ 'comment_author_url' ] ) . '" tabindex="3" placeholder="' . __( 'Website', 'bootstrap' ) . '" class="input-large"></div></div></div>',
948
+ );
949
+
950
+ $defaults = array(
951
+ 'fields' => apply_filters( 'comment_form_default_fields', $fields ),
952
+ 'comment_field' => '<div class="control-group"><div class="controls"><textarea id="comment" name="comment" placeholder="' . __( 'Your comment...', 'bootstrap' ) . '" tabindex="4" aria-required="true" required="required" class="input-large"></textarea>' . apply_filters( 'comment_input_help', $notes[ 'comment_input_help' ] ) . '</div></div>',
953
+ 'must_log_in' => '<div class="alert">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.', 'bootstrap' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</div>',
954
+ 'logged_in_as' => '<span class="help-inline">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', 'bootstrap' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</span>',
955
+ 'comment_notes_before' => '',
956
+ 'comment_notes_after' => '',
957
+ 'id_form' => 'commentform',
958
+ 'id_submit' => 'submit',
959
+ 'title_reply' => __( 'Leave a Reply', 'bootstrap' ),
960
+ 'title_reply_to' => __( 'Leave a Reply to %s', 'bootstrap' ),
961
+ 'cancel_reply_link' => __( 'Cancel reply', 'bootstrap' ),
962
+ 'label_submit' => __( 'Post Comment', 'bootstrap' ),
963
+ );
964
+
965
+ $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
966
+
967
+ if ( comments_open() ) {
968
+ do_action( 'comment_form_before' );
969
+ ?>
970
+ <section id="respond" class="respond-form">
971
+ <h3 id="comment-form-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?></h3>
972
+ <div id="cancel-comment-reply">
973
+ <p class="small"><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></p>
974
+ </div>
975
+ <?php
976
+ if ( get_option( 'comment_registration' ) and ! is_user_logged_in() ) {
977
+ echo $args['must_log_in'];
978
+ do_action( 'comment_form_must_log_in_after' );
979
+ }
980
+ else {
981
+ ?>
982
+ <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" class="form-horizontal" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>">
983
+ <?php
984
+ do_action( 'comment_form_top' );
985
+ if ( is_user_logged_in() ) {
986
+ echo apply_filters( 'comment_form_logged_in', $args[ 'logged_in_as' ], $commenter, $user_identity );
987
+ do_action( 'comment_form_logged_in_after', $commenter, $user_identity );
988
+ }
989
+ else {
990
+ echo $args[ 'comment_notes_before' ];
991
+
992
+ do_action( 'comment_form_before_fields' );
993
+
994
+ foreach ( ( array ) $args['fields'] as $name => $field ) {
995
+ echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
996
+ }
997
+
998
+ do_action( 'comment_form_after_fields' );
999
+ }
1000
+
1001
+ echo apply_filters( 'comment_form_field_comment', $args[ 'comment_field' ] );
1002
+
1003
+ echo $args[ 'comment_notes_after' ];
1004
+ ?>
1005
+ <div class="form-actions">
1006
+ <input class="btn btn-primary" name="submit" type="submit" id="<?php echo esc_attr( $args[ 'id_submit' ] ); ?>" tabindex="5" value="<?php echo esc_attr( $args[ 'label_submit' ] ); ?>" />
1007
+ <?php comment_id_fields(); ?>
1008
+ </div>
1009
+ <?php do_action( 'comment_form', $post_id ); ?>
1010
+ </form>
1011
+ <?php
1012
+ }
1013
+
1014
+ echo '</section>';
1015
+ do_action( 'comment_form_after' );
1016
+ } else {
1017
+ do_action( 'comment_form_comments_closed' );
1018
+ }
1019
+ }
1020
+
1021
+ /**
1022
+ * Redirect to post when search query returns single result
1023
+ *
1024
+ * @see http://wpsnipp.com/index.php/functions-php/redirect-to-post-when-search-query-returns-single-result/
1025
+ * @since [bootstrap] 1.0
1026
+ */
1027
+ function bootstrap_single_result() {
1028
+ if ( is_search() ) {
1029
+ global $wp_query;
1030
+ if ( $wp_query->post_count == 1 ) {
1031
+ wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
1032
+ }
1033
+ }
1034
+ }
1035
+ add_action( 'template_redirect', 'bootstrap_single_result' );
1036
+
1037
+ /**
1038
+ * Add postMessage support for site title and description for the Theme Customizer.
1039
+ *
1040
+ * @since [bootstrap] 1.0
1041
+ *
1042
+ * @param WP_Customize_Manager $wp_customize Theme Customizer object.
1043
+ * @return void
1044
+ */
1045
+ function bootstrap_customize_register( $wp_customize ) {
1046
+ $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
1047
+ $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
1048
+ }
1049
+ add_action( 'customize_register', 'bootstrap_customize_register' );
1050
+
1051
+ /* SHORTCODES */
1052
+
1053
+ // Allow shortcodes in widgets
1054
+ add_filter( 'widget_text', 'do_shortcode' );
1055
+
1056
+ /**
1057
+ * The supported attributes for the shortcode are 'id', 'align', 'width', and 'caption'.
1058
+ *
1059
+ * @since [bootstrap] 1.0
1060
+ */
1061
+ function bootstrap_shortcode_caption( $atts, $content = null ) {
1062
+ extract(
1063
+ shortcode_atts(
1064
+ array(
1065
+ 'id' => '',
1066
+ 'align' => 'alignnone',
1067
+ 'width' => '',
1068
+ 'caption' => '',
1069
+ ), $atts
1070
+ )
1071
+ );
1072
+
1073
+ if ( 1 > ( int ) $width )
1074
+ return $content;
1075
+
1076
+ if ( empty( $caption ) ) {
1077
+ preg_match( '/(<img[^>]+>)[ ]?(.*)/i', $content, $match );
1078
+ $content = $match[1];
1079
+ $caption = $match[2];
1080
+ }
1081
+
1082
+ $id = $id ? $id : 'attachment_' . rand( 1, 999 );
1083
+ $idtag = 'id="' . esc_attr( $id ) . '"';
1084
+
1085
+ $out[] = '<figure ' . $idtag . 'aria-describedby="figcaption_' . $id . '" class="post-image wp-caption ' . $align . '">';
1086
+ $out[] = apply_filters( 'bootstrap_shortcode_caption_content', do_shortcode( $content ), $id, '', '' );
1087
+ $out[] = '<figcaption id="figcaption_' . $id . '" class="caption wp-caption-text">' . wpautop( wptexturize( $caption ) ) . '</figcaption>';
1088
+ $out[] = '</figure>';
1089
+
1090
+ return implode( "\n", $out );
1091
+ }
1092
+
1093
+ add_shortcode( 'wp_caption', 'bootstrap_shortcode_caption' );
1094
+ add_shortcode( 'caption', 'bootstrap_shortcode_caption' );
1095
+
1096
+ /**
1097
+ * Gallery shortcode.
1098
+ *
1099
+ * @since [bootstrap] 1.0
1100
+ */
1101
+ function gallery_shortcode_bootstrap( $attr ) {
1102
+ global $post, $wp_locale;
1103
+
1104
+ $output = array();
1105
+
1106
+ $args = array( 'post_type' => 'attachment', 'numberposts' => - 1, 'post_status' => null, 'post_parent' => $post->ID );
1107
+ $attachments = get_posts( $args );
1108
+ if ( $attachments ) {
1109
+ $i = 0;
1110
+ $output[] = '<div id="myCarousel" class="carousel slide">';
1111
+ $output[] = '<div class="carousel-inner">';
1112
+ foreach ( $attachments as $attachment ) {
1113
+ $active = ( $i == 0) ? ' active' : '';
1114
+ $output[] = '<div class="item' . $active . '">';
1115
+ $output[] = '<a href="' . get_attachment_link( $attachment->ID ) . '">';
1116
+ $output[] = wp_get_attachment_image( $attachment->ID , 'full' );
1117
+ $output[] = '</a>';
1118
+ $output[] = '<div class="carousel-caption">';
1119
+ $output[] = '<h4>' . esc_attr( trim( strip_tags( $attachment->post_title ) ) ) . '</h4>';
1120
+ $output[] = wpautop( wptexturize( esc_attr( trim( strip_tags( $attachment->post_excerpt ) ) ) ) );
1121
+ $output[] = '</div>';
1122
+ $output[] = '</div>';
1123
+ ++$i;
1124
+ }
1125
+ $output[] = '<a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>';
1126
+ $output[] = '<a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>';
1127
+ $output[] = '</div></div>';
1128
+ }
1129
+
1130
+ return implode( "\n", $output );
1131
+ }
1132
+
1133
+ // removes standard shortcode
1134
+ remove_shortcode( 'gallery', 'gallery_shortcode' );
1135
+ add_shortcode( 'gallery', 'gallery_shortcode_bootstrap' );
1136
+
1137
+
1138
+ /* ADMIN STUFF */
1139
+
1140
+ /**
1141
+ * Remove unnecessary dashboard widgets
1142
+ *
1143
+ * @link http://www.deluxeblogtips.com/2011/01/remove-dashboard-widgets-in-wordpress.html
1144
+ * @since [bootstrap] 1.0
1145
+ */
1146
+ function bootstrap_remove_dashboard_widgets() {
1147
+ // Incoming Links Widget
1148
+ remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
1149
+
1150
+ // Plugins Widget
1151
+ remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
1152
+
1153
+ remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
1154
+ remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
1155
+
1156
+ // Sitepress WPML Plugin Widget
1157
+ remove_meta_box( 'icl_dashboard_widget', 'dashboard', 'normal' );
1158
+
1159
+ // Yoast's SEO Plugin Widget
1160
+ remove_meta_box( 'yoast_db_widget', 'dashboard', 'normal' );
1161
+ }
1162
+
1163
+ add_action( 'admin_init', 'bootstrap_remove_dashboard_widgets' );
1164
+
1165
+ /**
1166
+ * Adds custom menu to admin bar
1167
+ *
1168
+ * @since [bootstrap] 1.0
1169
+ */
1170
+ function bootstrap_bar_menu( $wp_admin_bar ) {
1171
+ if ( ! is_super_admin() or ! is_admin_bar_showing() )
1172
+ return;
1173
+
1174
+ /**
1175
+ * Change "Howdy"
1176
+ */
1177
+ // get the node that contains "howdy"
1178
+ $my_account = $wp_admin_bar->get_node( 'my-account' );
1179
+ // change the "howdy"
1180
+ $my_account->title = str_replace( 'Howdy,', __( 'Hi,', 'bootstrap' ), $my_account->title );
1181
+ // remove the original node
1182
+ $wp_admin_bar->remove_node( 'my-account' );
1183
+ // add back our modified version
1184
+ $wp_admin_bar->add_node( $my_account );
1185
+
1186
+ /**
1187
+ * Removing the "W" menu
1188
+ * I have nothing against it, but I *never* use it
1189
+ */
1190
+ $wp_admin_bar->remove_menu( 'wp-logo' );
1191
+
1192
+ /**
1193
+ * Create a "Favorites" menu
1194
+ * First, just create the parent menu item
1195
+ */
1196
+ $wp_admin_bar->add_menu(
1197
+ array(
1198
+ 'id' => 'favorites',
1199
+ 'parent' => 'top-secondary', // puts it on the right-hand side
1200
+ 'title' => __( 'Favorites', 'bootstrap' ),
1201
+ )
1202
+ );
1203
+
1204
+ /**
1205
+ * Then add links to it
1206
+ * This link goes to the All Settings page,
1207
+ * so only show it to users that have appropriate privileges
1208
+ */
1209
+ if ( current_user_can( 'manage_options' ) ) {
1210
+ $wp_admin_bar->add_menu(
1211
+ array(
1212
+ 'id' => 'all-settings',
1213
+ 'parent' => 'favorites',
1214
+ 'title' => __( 'Options', 'bootstrap' ),
1215
+ 'href' => admin_url( 'options.php' ),
1216
+ )
1217
+ );
1218
+ }
1219
+
1220
+ // This one goes to the list of the current user's posts
1221
+ $wp_admin_bar->add_menu(
1222
+ array(
1223
+ 'id' => 'my-posts',
1224
+ 'parent' => 'favorites',
1225
+ 'title' => __( 'My Posts', 'bootstrap' ),
1226
+ 'href' => admin_url( 'edit.php?post_type=post&author=' . get_current_user_id() ),
1227
+ )
1228
+ );
1229
+
1230
+ // MySQL query and script execution timer output
1231
+ $wp_admin_bar->add_menu(
1232
+ array(
1233
+ 'id' => 'do_query_bar',
1234
+ 'parent' => 'top-secondary', // puts it on the right-hand side
1235
+ 'title' => get_num_queries() . 'Q - ' . timer_stop() . 's', // link title
1236
+ 'href' => '#',
1237
+ 'meta' => false,
1238
+ )
1239
+ );
1240
+ }
1241
+
1242
+ add_action( 'admin_bar_menu', 'bootstrap_bar_menu', '1000' );
1243
+
1244
+ /**
1245
+ * This simple hack will remove the AIM, Yahoo and Jabber fields and will replace them with a bunch of other social network profiles.
1246
+ *
1247
+ * @since [bootstrap] 1.0
1248
+ */
1249
+ function bootstrap_user_contactmethods( $contactmethods ) {
1250
+ unset( $contactmethods['aim'], $contactmethods['yim'], $contactmethods['jabber'] );
1251
+
1252
+ // Add Location
1253
+ $contactmethods['user_location'] = __( 'Location', 'bootstrap' );
1254
+
1255
+ // Add Facebook
1256
+ $contactmethods['user_fb'] = __( 'Facebook', 'bootstrap' );
1257
+
1258
+ // Add Pinterest
1259
+ $contactmethods['user_pt'] = __( 'Pinterest', 'bootstrap' );
1260
+
1261
+ // Add Twitter
1262
+ $contactmethods['user_tw'] = __( 'Twitter', 'bootstrap' );
1263
+
1264
+ // Add Linkedin
1265
+ $contactmethods['user_lk'] = __( 'Linkedin', 'bootstrap' );
1266
+
1267
+ // Add Github
1268
+ $contactmethods['user_gh'] = __( 'Github', 'bootstrap' );
1269
+
1270
+ // Add Google+
1271
+ $contactmethods['google_profile'] = __( 'Google+ profile', 'bootstrap' );
1272
+
1273
+ return $contactmethods;
1274
+ }
1275
+
1276
+ add_filter( 'user_contactmethods', 'bootstrap_user_contactmethods' );
1277
+
1278
+ /**
1279
+ * Allow more HTML tags in the editor
1280
+ * Add more languages to spell check
1281
+ *
1282
+ * @since [bootstrap] 1.0
1283
+ */
1284
+ function bootstrap_change_mce_options( $array ) {
1285
+ $ext = 'pre[id|name|class|style],iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]';
1286
+
1287
+ if ( isset( $array['extended_valid_elements'] ) ) {
1288
+ $array['extended_valid_elements'] .= ','.$ext;
1289
+ }
1290
+ else {
1291
+ $array['extended_valid_elements'] = $ext;
1292
+ }
1293
+
1294
+ // Add block format elements you want to show in dropdown
1295
+ $array['theme_advanced_blockformats'] = 'h1,h2,h3,h4,p,code,blockquote';
1296
+ $array['theme_advanced_disable'] = 'strikethrough,underline,forecolor,justifyfull';
1297
+ $array[ 'spellchecker_languages' ] = '+Spanish=sp, English=en';
1298
+
1299
+ return $array;
1300
+ }
1301
+
1302
+ add_filter( 'tiny_mce_before_init', 'bootstrap_change_mce_options' );
1303
+
1304
+ /**
1305
+ * Adds previous/next links to post edition window
1306
+ *
1307
+ * @since [bootstrap] 1.0
1308
+ */
1309
+ function bootstrap_add_navigation_edit_posts() {
1310
+ if ( isset( $_GET['post'] ) and isset( $_GET['action'] ) and $_GET['action'] == 'edit' ) {
1311
+ global $post;
1312
+
1313
+ $args = array(
1314
+ 'public' => true,
1315
+ '_builtin' => false,
1316
+ );
1317
+ $output = 'names'; // names or objects, note names is the default
1318
+ $operator = 'and'; // 'and' or 'or'
1319
+
1320
+ $post_types = get_post_types( $args, $output, $operator );
1321
+
1322
+ $post_types['post'] = 'post';
1323
+ $post_types['page'] = 'page';
1324
+ if ( is_object( $post ) and in_array( $post->post_type, $post_types ) ) {
1325
+ $wtf = array( true, false );
1326
+ foreach ( $wtf as $prev ) {
1327
+ $p = get_adjacent_post( false, '', $prev );
1328
+
1329
+ if ( ! empty( $p ) ) {
1330
+ echo '<script>
1331
+ jQuery(function($) {
1332
+ $(".wrap h2" )
1333
+ .append(\'<a class="add-new-h2" href="' . admin_url( 'post.php?action=edit&post=' . $p->ID ) . '" title="' . __( 'Editar', 'bootstrap' ) . ' ' . apply_filters( 'the_title', $p->post_title ) . '">' . ( $prev ? '&laquo; ' : '' ) . apply_filters( 'the_title', $p->post_title ) . ( ! $prev ? ' &raquo;' : '' ) . '</a>\' );
1334
+ });
1335
+ </script>';
1336
+ }
1337
+ }
1338
+ }
1339
+ }
1340
+ }
1341
+
1342
+ add_action( 'admin_head', 'bootstrap_add_navigation_edit_posts' );
1343
+
1344
+ /**
1345
+ * Custom Login Logo Support
1346
+ *
1347
+ * @since [bootstrap] 1.0
1348
+ */
1349
+ function bootstrap_custom_login_logo() {
1350
+ echo '<style type="text/css">
1351
+ h1 a { background-image:url(' . get_template_directory_uri() . '/images/login-logo.png) !important; }
1352
+ </style>';
1353
+ }
1354
+
1355
+ add_action( 'login_head', 'bootstrap_custom_login_logo' );
1356
+
1357
+ /**
1358
+ * Custom Login URL
1359
+ *
1360
+ * @since [bootstrap] 1.0
1361
+ */
1362
+ function bootstrap_wp_login_url() {
1363
+ return home_url();
1364
+ }
1365
+
1366
+ add_filter( 'login_headerurl', 'bootstrap_wp_login_url' );
1367
+
1368
+ /**
1369
+ * Custom Login Title
1370
+ *
1371
+ * @since [bootstrap] 1.0
1372
+ */
1373
+ function bootstrap_wp_login_title() {
1374
+ return get_option( 'blogname' );
1375
+ }
1376
+
1377
+ add_filter( 'login_headertitle', 'bootstrap_wp_login_title' );
1378
+
1379
+ /**
1380
+ * Custom Backend Footer
1381
+ *
1382
+ * @since [bootstrap] 1.0
1383
+ */
1384
+ function bootstrap_custom_admin_footer() {
1385
+ $credits = '<span id="footer-thankyou">Crafted by <a href="//alexsancho.name" target="_blank">Alex Sancho</a></span>.';
1386
+
1387
+ echo apply_filters( 'bootstrap_custom_admin_footer', $credits );
1388
+ }
1389
+
1390
+ // adding it to the admin area
1391
+ add_filter( 'admin_footer_text', 'bootstrap_custom_admin_footer' );
1392
+
1393
+ /**
1394
+ * Class Name: twitter_bootstrap_nav_walker
1395
+ * GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker
1396
+ * Description: A custom Wordpress nav walker to implement the Twitter Bootstrap 2 (https://github.com/twitter/bootstrap/) dropdown navigation using the Wordpress built in menu manager.
1397
+ * Version: 1.2
1398
+ * Author: Edward McIntyre - @twittem
1399
+ * Licence: WTFPL 2.0 (http://sam.zoy.org/wtfpl/COPYING)
1400
+ */
1401
+ class Twitter_Bootstrap_Nav_Walker extends Walker_Nav_Menu {
1402
+ /**
1403
+ * @see Walker::start_lvl()
1404
+ * @since 3.0.0
1405
+ *
1406
+ * @param string $output Passed by reference. Used to append additional content.
1407
+ * @param int $depth Depth of page. Used for padding.
1408
+ */
1409
+ function start_lvl( &$output, $depth ) {
1410
+ $indent = str_repeat( "\t", $depth );
1411
+ $output .= "\n$indent<ul class=\"dropdown-menu\">\n";
1412
+ }
1413
+
1414
+ /**
1415
+ * @see Walker::start_el()
1416
+ * @since 3.0.0
1417
+ *
1418
+ * @param string $output Passed by reference. Used to append additional content.
1419
+ * @param object $item Menu item data object.
1420
+ * @param int $depth Depth of menu item. Used for padding.
1421
+ * @param int $current_page Menu item ID.
1422
+ * @param object $args
1423
+ */
1424
+ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
1425
+ global $wp_query;
1426
+ $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
1427
+
1428
+ if ( strcasecmp( $item->title, 'divider' ) ) {
1429
+ $class_names = $value = '';
1430
+ $classes = empty( $item->classes ) ? array() : (array) $item->classes;
1431
+ $classes[] = ( $item->current ) ? 'active' : '';
1432
+ $classes[] = 'menu-item-' . $item->ID;
1433
+ $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
1434
+
1435
+ if ( $args->has_children && $depth > 0 ) {
1436
+ $class_names .= ' dropdown-submenu';
1437
+ } elseif ( $args->has_children && $depth === 0 ) {
1438
+ $class_names .= ' dropdown';
1439
+ }
1440
+
1441
+ $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
1442
+
1443
+ $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
1444
+ $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
1445
+
1446
+ $output .= $indent . '<li' . $id . $value . $class_names .'>';
1447
+
1448
+ $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
1449
+ $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
1450
+ $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
1451
+ $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
1452
+ $attributes .= ($args->has_children) ? ' data-toggle="dropdown" data-target="#" class="dropdown-toggle"' : '';
1453
+
1454
+ $item_output = $args->before;
1455
+ $item_output .= '<a'. $attributes .'>';
1456
+ $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
1457
+ $item_output .= ($args->has_children) ? ' <span class="caret"></span></a>' : '</a>';
1458
+ $item_output .= $args->after;
1459
+
1460
+ $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
1461
+ } else {
1462
+ $output .= $indent . '<li class="divider"></li>';
1463
+ }
1464
+ }
1465
+
1466
+ /**
1467
+ * Traverse elements to create list from elements.
1468
+ *
1469
+ * Display one element if the element doesn't have any children otherwise,
1470
+ * display the element and its children. Will only traverse up to the max
1471
+ * depth and no ignore elements under that depth.
1472
+ *
1473
+ * This method shouldn't be called directly, use the walk() method instead.
1474
+ *
1475
+ * @see Walker::start_el()
1476
+ * @since 2.5.0
1477
+ *
1478
+ * @param object $element Data object
1479
+ * @param array $children_elements List of elements to continue traversing.
1480
+ * @param int $max_depth Max depth to traverse.
1481
+ * @param int $depth Depth of current element.
1482
+ * @param array $args
1483
+ * @param string $output Passed by reference. Used to append additional content.
1484
+ * @return null Null on failure with no changes to parameters.
1485
+ */
1486
+ function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
1487
+
1488
+ if ( !$element ) {
1489
+ return;
1490
+ }
1491
+
1492
+ $id_field = $this->db_fields['id'];
1493
+
1494
+ //display this element
1495
+ if ( is_array( $args[0] ) )
1496
+ $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );
1497
+ else if ( is_object( $args[0] ) )
1498
+ $args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
1499
+ $cb_args = array_merge( array( &$output, $element, $depth ), $args );
1500
+ call_user_func_array( array( &$this, 'start_el' ), $cb_args );
1501
+
1502
+ $id = $element->$id_field;
1503
+
1504
+ // descend only when the depth is right and there are childrens for this element
1505
+ if ( ($max_depth == 0 || $max_depth > $depth + 1 ) && isset( $children_elements[$id] ) ) {
1506
+ foreach ( $children_elements[$id] as $child ) {
1507
+ if ( ! isset( $newlevel ) ) {
1508
+ $newlevel = true;
1509
+ //start the child delimiter
1510
+ $cb_args = array_merge( array( &$output, $depth ), $args );
1511
+ call_user_func_array( array( &$this, 'start_lvl' ), $cb_args );
1512
+ }
1513
+ $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
1514
+ }
1515
+ unset( $children_elements[ $id ] );
1516
+ }
1517
+
1518
+ if ( isset( $newlevel ) && $newlevel ) {
1519
+ //end the child delimiter
1520
+ $cb_args = array_merge( array( &$output, $depth ), $args );
1521
+ call_user_func_array( array( &$this, 'end_lvl' ), $cb_args );
1522
+ }
1523
+
1524
+ //end this element
1525
+ $cb_args = array_merge( array( &$output, $element, $depth ), $args );
1526
+ call_user_func_array( array( &$this, 'end_el' ), $cb_args );
1527
+ }
1528
+ }