wordpress-starter 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +1 -0
- data/LICENSE +20 -0
- data/README.md +34 -0
- data/lib/wordpress-starter.rb +29 -0
- data/stylesheets/_wordpress.scss +9 -0
- data/stylesheets/wordpress/_base.scss +74 -0
- data/stylesheets/wordpress/_defaults.scss +28 -0
- data/stylesheets/wordpress/_layout.scss +56 -0
- data/stylesheets/wordpress/_mixins.scss +57 -0
- data/stylesheets/wordpress/_page.scss +364 -0
- data/stylesheets/wordpress/_responsive.scss +231 -0
- data/stylesheets/wordpress/_theme.scss +83 -0
- data/stylesheets/wordpress/_typography.scss +135 -0
- data/stylesheets/wordpress/_utils.scss +64 -0
- data/templates/project/ie.scss +1 -0
- data/templates/project/manifest.rb +21 -0
- data/templates/project/print.css +4 -0
- data/templates/project/print.scss +104 -0
- data/templates/project/readme.txt +1 -0
- data/templates/project/screen.scss +1 -0
- data/templates/project/style.css +13 -0
- data/templates/starter/404.php +24 -0
- data/templates/starter/admin/README.txt +25 -0
- data/templates/starter/admin/assets/css/admin-style.css +838 -0
- data/templates/starter/admin/assets/css/colorpicker.css +177 -0
- data/templates/starter/admin/assets/images/1col.png +0 -0
- data/templates/starter/admin/assets/images/2-col-portfolio.png +0 -0
- data/templates/starter/admin/assets/images/2cl.png +0 -0
- data/templates/starter/admin/assets/images/2cr.png +0 -0
- data/templates/starter/admin/assets/images/3-col-portfolio.png +0 -0
- data/templates/starter/admin/assets/images/3cm.png +0 -0
- data/templates/starter/admin/assets/images/3cr.png +0 -0
- data/templates/starter/admin/assets/images/4-col-portfolio.png +0 -0
- data/templates/starter/admin/assets/images/accept.png +0 -0
- data/templates/starter/admin/assets/images/button_check.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/blank.gif +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_background.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_hex.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_hsb_b.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_hsb_h.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_hsb_s.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_indic.gif +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_overlay.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_rgb_b.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_rgb_g.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_rgb_r.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_select.gif +0 -0
- data/templates/starter/admin/assets/images/colorpicker/colorpicker_submit.png +0 -0
- data/templates/starter/admin/assets/images/colorpicker/select.png +0 -0
- data/templates/starter/admin/assets/images/dropdown-arrow.png +0 -0
- data/templates/starter/admin/assets/images/favicon.ico +0 -0
- data/templates/starter/admin/assets/images/icon-add.png +0 -0
- data/templates/starter/admin/assets/images/icon-backup.png +0 -0
- data/templates/starter/admin/assets/images/icon-delete.png +0 -0
- data/templates/starter/admin/assets/images/icon-docs.png +0 -0
- data/templates/starter/admin/assets/images/icon-edit.png +0 -0
- data/templates/starter/admin/assets/images/icon-home.png +0 -0
- data/templates/starter/admin/assets/images/icon-info.png +0 -0
- data/templates/starter/admin/assets/images/icon-notice.png +0 -0
- data/templates/starter/admin/assets/images/icon-paint.png +0 -0
- data/templates/starter/admin/assets/images/icon-settings.png +0 -0
- data/templates/starter/admin/assets/images/icon-slider.png +0 -0
- data/templates/starter/admin/assets/images/icon-warn.png +0 -0
- data/templates/starter/admin/assets/images/icon_option.png +0 -0
- data/templates/starter/admin/assets/images/loading-bottom.gif +0 -0
- data/templates/starter/admin/assets/images/select.png +0 -0
- data/templates/starter/admin/assets/images/sign_warning.png +0 -0
- data/templates/starter/admin/assets/images/stop.png +0 -0
- data/templates/starter/admin/assets/images/toggle_tabs.png +0 -0
- data/templates/starter/admin/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/templates/starter/admin/assets/images/warning.png +0 -0
- data/templates/starter/admin/assets/images/wrench.png +0 -0
- data/templates/starter/admin/assets/images/wrench16.png +0 -0
- data/templates/starter/admin/assets/js/ajaxupload.js +606 -0
- data/templates/starter/admin/assets/js/colorpicker.js +455 -0
- data/templates/starter/admin/assets/js/cookie.js +1 -0
- data/templates/starter/admin/assets/js/jquery.maskedinput-1.2.2.js +252 -0
- data/templates/starter/admin/assets/js/jquery.tipsy.js +241 -0
- data/templates/starter/admin/assets/js/of-medialibrary-uploader.js +168 -0
- data/templates/starter/admin/assets/js/smof.js +623 -0
- data/templates/starter/admin/classes/class.options-machine.php +627 -0
- data/templates/starter/admin/front-end/options.php +77 -0
- data/templates/starter/admin/functions/functions.admin.php +76 -0
- data/templates/starter/admin/functions/functions.interface.php +232 -0
- data/templates/starter/admin/functions/functions.load.php +14 -0
- data/templates/starter/admin/functions/functions.mediauploader.php +194 -0
- data/templates/starter/admin/functions/functions.options.php +507 -0
- data/templates/starter/admin/functions/functions.php +0 -0
- data/templates/starter/admin/index.php +86 -0
- data/templates/starter/admin/layouts/default.css +0 -0
- data/templates/starter/admin/layouts/placebo.css +0 -0
- data/templates/starter/app.js +97 -0
- data/templates/starter/archive.php +57 -0
- data/templates/starter/category.php +40 -0
- data/templates/starter/comments.php +65 -0
- data/templates/starter/content-aside.php +26 -0
- data/templates/starter/content-image.php +29 -0
- data/templates/starter/content-link.php +27 -0
- data/templates/starter/content-none.php +21 -0
- data/templates/starter/content-page.php +24 -0
- data/templates/starter/content-quote.php +26 -0
- data/templates/starter/content-status.php +33 -0
- data/templates/starter/content.php +67 -0
- data/templates/starter/editor-style.scss +359 -0
- data/templates/starter/footer.php +29 -0
- data/templates/starter/functions.php +1211 -0
- data/templates/starter/header.php +63 -0
- data/templates/starter/ie.scss +1 -0
- data/templates/starter/images/bg/bg0.png +0 -0
- data/templates/starter/images/bg/bg1.png +0 -0
- data/templates/starter/images/bg/bg10.png +0 -0
- data/templates/starter/images/bg/bg11.png +0 -0
- data/templates/starter/images/bg/bg2.png +0 -0
- data/templates/starter/images/bg/bg3.png +0 -0
- data/templates/starter/images/bg/bg4.png +0 -0
- data/templates/starter/images/bg/bg5.png +0 -0
- data/templates/starter/images/bg/bg6.jpg +0 -0
- data/templates/starter/images/bg/bg7.jpg +0 -0
- data/templates/starter/images/bg/bg8.png +0 -0
- data/templates/starter/images/bg/bg9.png +0 -0
- data/templates/starter/index.php +19 -0
- data/templates/starter/loop.php +30 -0
- data/templates/starter/manifest.rb +149 -0
- data/templates/starter/moderninzr.min.js +4 -0
- data/templates/starter/options.php +407 -0
- data/templates/starter/page.php +29 -0
- data/templates/starter/print.scss +104 -0
- data/templates/starter/readme.txt +1 -0
- data/templates/starter/screen.scss +1 -0
- data/templates/starter/search.php +31 -0
- data/templates/starter/search.png +0 -0
- data/templates/starter/searchform.php +14 -0
- data/templates/starter/sidebar.php +15 -0
- data/templates/starter/single.php +31 -0
- data/templates/starter/style.css +13 -0
- data/templates/starter/tag.php +41 -0
- metadata +230 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* The default template for displaying footer
|
|
4
|
+
*
|
|
5
|
+
* @category Theme
|
|
6
|
+
* @package [starter]
|
|
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( 'starter_footer' ); ?>
|
|
17
|
+
<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'starter' ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'starter' ); ?>"><?php printf( __( 'Proudly powered by %s', 'starter' ), '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,1211 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* [starter] 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 [starter]
|
|
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 starter_setup() in a child theme, add your own starter_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 [starter] 1.0
|
|
42
|
+
*/
|
|
43
|
+
function starter_setup() {
|
|
44
|
+
// SET THEME LANGUAGES DIRECTORY
|
|
45
|
+
// Theme translations can be filed in the my_theme/languages/ directory
|
|
46
|
+
load_theme_textdomain( 'starter', 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', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) );
|
|
57
|
+
|
|
58
|
+
// Add post thumbnails (http://codex.wordpress.org/Post_Thumbnails)
|
|
59
|
+
add_theme_support( 'post-thumbnails' );
|
|
60
|
+
set_post_thumbnail_size( 670, 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', 'starter' ) );
|
|
64
|
+
|
|
65
|
+
/*------------------------------------------*/
|
|
66
|
+
/* Options Framework
|
|
67
|
+
/*------------------------------------------*/
|
|
68
|
+
locate_template( 'options.php', true );
|
|
69
|
+
locate_template( 'admin/index.php', true );
|
|
70
|
+
|
|
71
|
+
do_action( 'starter_setup' );
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
add_action( 'after_setup_theme', 'starter_setup' );
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Some cleanup
|
|
78
|
+
*
|
|
79
|
+
* @since [starter] 1.0
|
|
80
|
+
* @return void
|
|
81
|
+
*/
|
|
82
|
+
function starter_init() {
|
|
83
|
+
// autolinks in comments
|
|
84
|
+
remove_filter( 'comment_text', 'make_clickable', 9 );
|
|
85
|
+
|
|
86
|
+
// Display the links to the general feeds: Post and Comment Feed
|
|
87
|
+
remove_action( 'wp_head', 'feed_links', 2 );
|
|
88
|
+
|
|
89
|
+
// Display the links to the extra feeds such as category feeds
|
|
90
|
+
remove_action( 'wp_head', 'feed_links_extra', 3 );
|
|
91
|
+
|
|
92
|
+
// Display the link to the Really Simple Discovery service endpoint, EditURI link
|
|
93
|
+
remove_action( 'wp_head', 'rsd_link' );
|
|
94
|
+
|
|
95
|
+
// Display the link to the Windows Live Writer manifest file.
|
|
96
|
+
remove_action( 'wp_head', 'wlwmanifest_link' );
|
|
97
|
+
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
|
|
98
|
+
|
|
99
|
+
// index link
|
|
100
|
+
remove_action( 'wp_head', 'index_rel_link' );
|
|
101
|
+
|
|
102
|
+
// prev link
|
|
103
|
+
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
|
|
104
|
+
|
|
105
|
+
// start link
|
|
106
|
+
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
|
|
107
|
+
|
|
108
|
+
// Display relational links for the posts adjacent to the current post.
|
|
109
|
+
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
|
|
110
|
+
|
|
111
|
+
// Display the XHTML generator that is generated on the wp_head hook, WP version
|
|
112
|
+
remove_action( 'wp_head', 'wp_generator' );
|
|
113
|
+
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
|
|
114
|
+
|
|
115
|
+
// remove jetpack open graph tags
|
|
116
|
+
remove_action( 'wp_head', 'jetpack_og_tags' );
|
|
117
|
+
|
|
118
|
+
add_filter( 'use_default_gallery_style', '__return_null' );
|
|
119
|
+
|
|
120
|
+
/* Custom oEmbed Providers */
|
|
121
|
+
|
|
122
|
+
// Add Soundcloud oEmbed
|
|
123
|
+
wp_oembed_add_provider( '#http://(www\.)?soundcloud\.com/.*#i', 'http://soundcloud.com/oembed', true );
|
|
124
|
+
|
|
125
|
+
// Add Kickstarter oEmbed
|
|
126
|
+
wp_oembed_add_provider( '#http://(www\.)?kickstarter\.com/projects/.*#i', 'http://www.kickstarter.com/services/oembed', true );
|
|
127
|
+
|
|
128
|
+
// Add Instagram oEmbed
|
|
129
|
+
wp_oembed_add_provider( '#http://(www\.)?instagr(am)?\.(am|com)/.*#i', 'http://api.instagram.com/oembed', true );
|
|
130
|
+
|
|
131
|
+
// Add Slideshare oEmbed
|
|
132
|
+
wp_oembed_add_provider( '#http://(www\.)?slideshare\.net/.*#i', 'http://api.embed.ly/v1/api/oembed', true );
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
add_action( 'init', 'starter_init' );
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Remove the WordPress version from RSS feeds
|
|
139
|
+
*/
|
|
140
|
+
add_filter( 'the_generator', '__return_false' );
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Adds custom scripts to theme header
|
|
144
|
+
*
|
|
145
|
+
* @since [starter] 1.0
|
|
146
|
+
* @return void
|
|
147
|
+
*/
|
|
148
|
+
function starter_enqueue_scripts() {
|
|
149
|
+
$theme = wp_get_theme();
|
|
150
|
+
$version = $theme['Version'];
|
|
151
|
+
|
|
152
|
+
wp_deregister_script( 'jquery' );
|
|
153
|
+
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3' );
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* We add some JavaScript to pages with the comment form
|
|
157
|
+
* to support sites with threaded comments (when in use).
|
|
158
|
+
*/
|
|
159
|
+
if ( is_singular() and comments_open() and get_option( 'thread_comments' ) ) {
|
|
160
|
+
wp_enqueue_script( 'comment-reply' );
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/javascripts/modernizr.min.js', false, '2.6.2' );
|
|
164
|
+
wp_enqueue_script( 'app', get_template_directory_uri() . '/javascripts/app.js', array( 'jquery' ), $version, true );
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
add_action( 'wp_enqueue_scripts', 'starter_enqueue_scripts' );
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Adds custom styles to theme header
|
|
171
|
+
*
|
|
172
|
+
* @since [starter] 1.0
|
|
173
|
+
* @return void
|
|
174
|
+
*/
|
|
175
|
+
function starter_enqueue_styles() {
|
|
176
|
+
$theme = wp_get_theme();
|
|
177
|
+
$version = $theme['Version'];
|
|
178
|
+
|
|
179
|
+
wp_enqueue_style( 'app', get_stylesheet_uri(), false, $version, 'all' );
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
add_action( 'wp_enqueue_scripts', 'starter_enqueue_styles' );
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Makes some changes to the <title> tag, by filtering the output of wp_title().
|
|
186
|
+
*
|
|
187
|
+
* If we have a site description and we're viewing the home page or a blog posts
|
|
188
|
+
* page (when using a static front page), then we will add the site description.
|
|
189
|
+
*
|
|
190
|
+
* If we're viewing a search result, then we're going to recreate the title entirely.
|
|
191
|
+
* We're going to add page numbers to all titles as well, to the middle of a search
|
|
192
|
+
* result title and the end of all other titles.
|
|
193
|
+
*
|
|
194
|
+
* The site title also gets added to all titles.
|
|
195
|
+
*
|
|
196
|
+
* @since [starter] 1.0
|
|
197
|
+
*
|
|
198
|
+
* @param string $title Title generated by wp_title()
|
|
199
|
+
* @param string $separator The separator passed to wp_title(). Base theme uses a vertical bar, "|", as a separator in header.php.
|
|
200
|
+
* @return string The new title, ready for the <title> tag.
|
|
201
|
+
*/
|
|
202
|
+
function starter_filter_wp_title( $title, $separator ) {
|
|
203
|
+
// Don't affect wp_title() calls in feeds.
|
|
204
|
+
if ( is_feed() or function_exists( 'get_wpseo_options' ) )
|
|
205
|
+
return $title;
|
|
206
|
+
|
|
207
|
+
// The $paged global variable contains the page number of a listing of posts.
|
|
208
|
+
// The $page global variable contains the page number of a single post that is paged.
|
|
209
|
+
// We'll display whichever one applies, if we're not looking at the first page.
|
|
210
|
+
global $paged, $page, $post;
|
|
211
|
+
|
|
212
|
+
if ( is_search() ) {
|
|
213
|
+
// If we're a search, let's start over:
|
|
214
|
+
$title = sprintf( __( 'Search results for %s', 'starter' ), '"' . get_search_query() . '"' );
|
|
215
|
+
// Add a page number if we're on page 2 or more:
|
|
216
|
+
if ( $paged >= 2 ) {
|
|
217
|
+
$title .= " $separator " . sprintf( __( 'Page %s', 'starter' ), $paged );
|
|
218
|
+
}
|
|
219
|
+
// Add the site name to the end:
|
|
220
|
+
$title .= " $separator " . get_bloginfo( 'name', 'display' );
|
|
221
|
+
// We're done. Let's send the new title back to wp_title():
|
|
222
|
+
return $title;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
$return = array();
|
|
226
|
+
|
|
227
|
+
if ( $title != '' ) {
|
|
228
|
+
$return[] = str_replace( " $separator ", '', apply_filters( 'the_category', $title ) );
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if ( is_single() ) {
|
|
232
|
+
if ( get_post_meta( $post->ID, 'title', true ) ) {
|
|
233
|
+
$return[] = stripslashes( get_post_meta( $post->ID, 'seo_title', true ) );
|
|
234
|
+
}
|
|
235
|
+
elseif ( ! in_array( $post->post_type, array( 'post', 'page', 'attachment' ) ) ) {
|
|
236
|
+
$post_type_obj = get_post_type_object( $post->post_type );
|
|
237
|
+
$return[] = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name );
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Add a page number if necessary:
|
|
242
|
+
if ( $paged >= 2 or $page >= 2 ) {
|
|
243
|
+
$return[] = sprintf( __( 'Page %s', 'starter' ), max( $paged, $page ) );
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Add the site name to the end:
|
|
247
|
+
$return[] = get_bloginfo( 'name', 'display' );
|
|
248
|
+
|
|
249
|
+
// If we have a site description and we're on the home/front page, add the description:
|
|
250
|
+
$site_description = get_bloginfo( 'description', 'display' );
|
|
251
|
+
if ( $site_description and ( is_home() or is_front_page() ) ) {
|
|
252
|
+
$return[] = $site_description;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Return the new title to wp_title():
|
|
256
|
+
return implode( " $separator ", $return );
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
add_filter( 'wp_title', 'starter_filter_wp_title', 10, 3 );
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Adds code to header
|
|
263
|
+
*
|
|
264
|
+
* @since [starter] 1.0
|
|
265
|
+
* @return string misc
|
|
266
|
+
*/
|
|
267
|
+
function starter_header() {
|
|
268
|
+
?>
|
|
269
|
+
<!-- For third-generation iPad with high-resolution Retina display: -->
|
|
270
|
+
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="apple-touch-icon-144x144-precomposed.png?1333401433">
|
|
271
|
+
<!-- For iPhone with high-resolution Retina display: -->
|
|
272
|
+
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114-precomposed.png?1333401433">
|
|
273
|
+
<!-- For first- and second-generation iPad: -->
|
|
274
|
+
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72-precomposed.png?1333401433">
|
|
275
|
+
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
|
|
276
|
+
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png?1333401433">
|
|
277
|
+
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
|
|
278
|
+
<link rel="shortcut icon" href="favicon.ico?1333401433" type="image/x-icon" />
|
|
279
|
+
<?php
|
|
280
|
+
do_action( 'starter_header' );
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
add_action( 'wp_head', 'starter_header', 10 );
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Adds code to footer
|
|
287
|
+
*
|
|
288
|
+
* @since [starter] 1.0
|
|
289
|
+
* @return string misc
|
|
290
|
+
*/
|
|
291
|
+
function starter_footer() {}
|
|
292
|
+
|
|
293
|
+
add_action( 'wp_footer', 'starter_footer', 10 );
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Defines widget areas
|
|
297
|
+
*
|
|
298
|
+
* @since [starter] 1.0
|
|
299
|
+
* @return void
|
|
300
|
+
*/
|
|
301
|
+
function starter_widgets_init() {
|
|
302
|
+
register_sidebar(
|
|
303
|
+
array(
|
|
304
|
+
'name' => __( 'Primary widget area', 'starter' ),
|
|
305
|
+
'id' => 'primary-widget-area',
|
|
306
|
+
'description' => __( '', 'starter' ),
|
|
307
|
+
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
|
|
308
|
+
'after_widget' => '</li>',
|
|
309
|
+
'before_title' => '<h3 class="widget-title">',
|
|
310
|
+
'after_title' => '</h3>',
|
|
311
|
+
)
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
add_action( 'widgets_init', 'starter_widgets_init' );
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Clean up output of stylesheet <link> tags
|
|
319
|
+
*
|
|
320
|
+
* @since [starter] 1.0
|
|
321
|
+
*/
|
|
322
|
+
function starter_clean_style_tag( $input ) {
|
|
323
|
+
preg_match_all( "!<link rel='stylesheet'\s?(id='[^']+')?\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches );
|
|
324
|
+
// Only display media if it's print
|
|
325
|
+
$media = $matches[3][0] == 'print' ? ' media="print"' : '';
|
|
326
|
+
|
|
327
|
+
return '<link rel="stylesheet" href="' . $matches[ 2 ][ 0 ] . '"' . $media . '>' . "\n";
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
add_filter( 'style_loader_tag', 'starter_clean_style_tag' );
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Remove unnecessary self-closing tags
|
|
334
|
+
*
|
|
335
|
+
* @since [starter] 1.0
|
|
336
|
+
*/
|
|
337
|
+
function starter_remove_self_closing_tags( $input ) {
|
|
338
|
+
return str_replace( ' />', '>', $input );
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
add_filter( 'get_avatar', 'starter_remove_self_closing_tags' ); // <img />
|
|
342
|
+
add_filter( 'comment_id_fields', 'starter_remove_self_closing_tags' ); // <input />
|
|
343
|
+
add_filter( 'post_thumbnail_html', 'starter_remove_self_closing_tags' ); // <img />
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Wrap embedded media as suggested by Readability
|
|
347
|
+
*
|
|
348
|
+
* @link https://gist.github.com/965956
|
|
349
|
+
* @link http://www.readability.com/publishers/guidelines#publisher
|
|
350
|
+
* @since [starter] 1.0
|
|
351
|
+
*/
|
|
352
|
+
function starter_embed_wrap( $cache, $url, $attr = '', $post_ID = '' ) {
|
|
353
|
+
return '<div class="entry-content-asset">' . $cache . '</div>';
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
add_filter( 'embed_oembed_html', 'starter_embed_wrap', 10, 4 );
|
|
357
|
+
add_filter( 'embed_googlevideo', 'starter_embed_wrap', 10, 2 );
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Remove height/width attributes on images so they can be responsive
|
|
361
|
+
*
|
|
362
|
+
* @since [starter] 1.0
|
|
363
|
+
*/
|
|
364
|
+
function starter_remove_thumbnail_dimensions( $html, $id, $alt, $title ) {
|
|
365
|
+
return preg_replace(
|
|
366
|
+
array(
|
|
367
|
+
'/\s+width="\d+"/i',
|
|
368
|
+
'/\s+height="\d+"/i',
|
|
369
|
+
'/alt=""/i',
|
|
370
|
+
),
|
|
371
|
+
array(
|
|
372
|
+
'',
|
|
373
|
+
'',
|
|
374
|
+
'',
|
|
375
|
+
'alt="' . $title . '"',
|
|
376
|
+
),
|
|
377
|
+
$html
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
add_filter( 'post_thumbnail_html', 'starter_remove_thumbnail_dimensions', 10, 4 );
|
|
382
|
+
add_filter( 'image_send_to_editor', 'starter_remove_thumbnail_dimensions', 10, 4 );
|
|
383
|
+
add_filter( 'get_image_tag', 'starter_remove_thumbnail_dimensions', 10, 4 );
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Clean the output of attributes of images in editor.
|
|
387
|
+
*
|
|
388
|
+
* @link http://www.sitepoint.com/wordpress-change-img-tag-html/
|
|
389
|
+
* @since [starter] 1.0
|
|
390
|
+
*/
|
|
391
|
+
function starter_image_tag_class( $class, $id, $align, $size ) {
|
|
392
|
+
$align = 'align' . esc_attr( $align );
|
|
393
|
+
return $align;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
add_filter( 'get_image_tag_class', 'starter_image_tag_class', 0, 4 );
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Add thumbnail class to thumbnail links
|
|
400
|
+
*
|
|
401
|
+
* @since [starter] 1.0
|
|
402
|
+
*/
|
|
403
|
+
function starter_add_class_attachment_link( $html ) {
|
|
404
|
+
$postid = get_the_ID();
|
|
405
|
+
$html = str_replace( '<a', '<a class="thumbnail"', $html );
|
|
406
|
+
|
|
407
|
+
return $html;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
add_filter( 'wp_get_attachment_link', 'starter_add_class_attachment_link', 10, 1 );
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Filter in a link to a content ID attribute for the next/previous image links on image attachment pages
|
|
414
|
+
*
|
|
415
|
+
* @since [starter] 1.0
|
|
416
|
+
*/
|
|
417
|
+
function starter_enhanced_image_navigation( $url, $id ) {
|
|
418
|
+
if ( ! is_attachment() && ! wp_attachment_is_image( $id ) )
|
|
419
|
+
return $url;
|
|
420
|
+
|
|
421
|
+
$image = get_post( $id );
|
|
422
|
+
if ( ! empty( $image->post_parent ) && $image->post_parent != $id )
|
|
423
|
+
$url .= '#main';
|
|
424
|
+
|
|
425
|
+
return $url;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
add_filter( 'attachment_link', 'starter_enhanced_image_navigation', 10, 2 );
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Replace various active menu class names with "active"
|
|
432
|
+
* Remove the id="" on nav menu items
|
|
433
|
+
* Return 'menu-slug' for nav menu classes
|
|
434
|
+
*
|
|
435
|
+
* @since [starter] 1.0
|
|
436
|
+
*/
|
|
437
|
+
function starter_wp_nav_menu_class( $classes, $item ) {
|
|
438
|
+
$slug = sanitize_title( $item->title );
|
|
439
|
+
$classes = preg_replace( '/(current(-menu-|[-_]page[-_])(item|parent|ancestor))/', 'active', $classes );
|
|
440
|
+
$classes = preg_replace( '/^((menu|page)[-_\w+]+)+/', '', $classes );
|
|
441
|
+
|
|
442
|
+
$classes[] = 'menu-' . $slug;
|
|
443
|
+
|
|
444
|
+
return array_filter( array_unique( $classes ), 'is_element_empty' );
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
add_filter( 'nav_menu_css_class', 'starter_wp_nav_menu_class', 10, 2 );
|
|
448
|
+
add_filter( 'nav_menu_item_id', '__return_null' );
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Check if $element is empty
|
|
452
|
+
*
|
|
453
|
+
* @since [starter] 1.0
|
|
454
|
+
*/
|
|
455
|
+
function is_element_empty( $element ) {
|
|
456
|
+
$element = trim( $element );
|
|
457
|
+
|
|
458
|
+
return ( bool ) ! empty( $element );
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Create a graceful fallback to wp_page_menu
|
|
463
|
+
*
|
|
464
|
+
* @since [starter] 1.0
|
|
465
|
+
*/
|
|
466
|
+
function starter_page_menu() {
|
|
467
|
+
|
|
468
|
+
$args = array(
|
|
469
|
+
'sort_column' => 'menu_order, post_title',
|
|
470
|
+
'menu_class' => 'nav-menu',
|
|
471
|
+
'include' => '',
|
|
472
|
+
'exclude' => '',
|
|
473
|
+
'echo' => true,
|
|
474
|
+
'show_home' => false,
|
|
475
|
+
'link_before' => '',
|
|
476
|
+
'link_after' => '',
|
|
477
|
+
);
|
|
478
|
+
|
|
479
|
+
wp_page_menu( $args );
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Adds extra info to language attributes string
|
|
484
|
+
*
|
|
485
|
+
* @since [starter] 1.0
|
|
486
|
+
*/
|
|
487
|
+
function starter_language_attributes() {
|
|
488
|
+
$attr = array();
|
|
489
|
+
$output = '';
|
|
490
|
+
|
|
491
|
+
if ( function_exists( 'is_rtl' ) ) {
|
|
492
|
+
if ( is_rtl() == 'rtl' ) {
|
|
493
|
+
$attr[] = 'dir="rtl"';
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
$lang = get_bloginfo( 'language' );
|
|
498
|
+
|
|
499
|
+
if ( $lang and $lang !== 'en-US' ) {
|
|
500
|
+
$attr[] = "lang=\"$lang\"";
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
$attr[] = 'lang="en"';
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
return implode( ' ', $attr );
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
add_filter( 'language_attributes', 'starter_language_attributes' );
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* remove the p from around imgs
|
|
513
|
+
*
|
|
514
|
+
* @link https://gist.github.com/975026
|
|
515
|
+
* @since [starter] 1.0
|
|
516
|
+
*/
|
|
517
|
+
function starter_filter_ptags_on_images( $content ) {
|
|
518
|
+
// Replace br tags inside figures
|
|
519
|
+
$content = preg_replace( '/(<figure .*>)?<br\s?\/?>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*/iU', '\1\2\3\4', $content );
|
|
520
|
+
// do a regular expression replace...
|
|
521
|
+
// find all p tags that have just
|
|
522
|
+
// <p>maybe some white space<img all stuff up to /> then maybe whitespace </p>
|
|
523
|
+
// replace it with just the image tag...
|
|
524
|
+
$content = preg_replace( '/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content );
|
|
525
|
+
// now pass that through and do the same for iframes...
|
|
526
|
+
return preg_replace( '/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content );
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
add_filter( 'the_content', 'starter_filter_ptags_on_images' );
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Adds browser detection body class
|
|
533
|
+
* Adds extra classes to body tag on custom taxonomies
|
|
534
|
+
*
|
|
535
|
+
* @since [starter] 1.0
|
|
536
|
+
*/
|
|
537
|
+
function starter_body_classes( $classes ) {
|
|
538
|
+
global $wp_query, $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
|
|
539
|
+
|
|
540
|
+
if ( isset( $wp_query->query_vars['taxonomy'] ) or isset( $wp_query->query_vars['term'] ) ) {
|
|
541
|
+
array_push( $classes, 'custom-taxonomy-archive', 'custom-taxonomy-' . ( isset( $wp_query->query_vars[ 'taxonomy' ] ) ? get_query_var( 'taxonomy' ) : get_query_var( 'term' ) ) . '-archive' );
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if ( $is_lynx ) $classes[] = 'lynx';
|
|
545
|
+
elseif ( $is_gecko ) $classes[] = 'gecko';
|
|
546
|
+
elseif ( $is_opera ) $classes[] = 'opera';
|
|
547
|
+
elseif ( $is_NS4 ) $classes[] = 'ns4';
|
|
548
|
+
elseif ( $is_safari ) $classes[] = 'safari';
|
|
549
|
+
elseif ( $is_chrome ) $classes[] = 'chrome';
|
|
550
|
+
elseif ( $is_IE ) $classes[] = 'ie';
|
|
551
|
+
else $classes[] = 'unknown';
|
|
552
|
+
|
|
553
|
+
if ( $is_iphone ) $classes[] = 'iphone';
|
|
554
|
+
|
|
555
|
+
// Add post/page slug
|
|
556
|
+
if ( is_single() or is_page() and ! is_front_page() ) {
|
|
557
|
+
$classes[] = basename( get_permalink() );
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// Remove unnecessary classes
|
|
561
|
+
$home_id_class = 'page-id-' . get_option( 'page_on_front' );
|
|
562
|
+
$remove_classes = array(
|
|
563
|
+
'page-template-default',
|
|
564
|
+
$home_id_class,
|
|
565
|
+
);
|
|
566
|
+
|
|
567
|
+
$classes = array_diff( $classes, $remove_classes );
|
|
568
|
+
|
|
569
|
+
return $classes;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
add_filter( 'body_class', 'starter_body_classes' );
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Modifies output of custom post formats.
|
|
576
|
+
*
|
|
577
|
+
* @since [starter] 1.0
|
|
578
|
+
*/
|
|
579
|
+
function starter_custom_content( $content ) {
|
|
580
|
+
/* Check if we're displaying a 'quote' post. */
|
|
581
|
+
if ( has_post_format( 'quote' ) ) {
|
|
582
|
+
/* Match any <blockquote> elements. */
|
|
583
|
+
preg_match( '/<blockquote.*?>/', $content, $matches );
|
|
584
|
+
|
|
585
|
+
/* If no <blockquote> elements were found, wrap the entire content in one. */
|
|
586
|
+
if ( empty( $matches ) ) {
|
|
587
|
+
$content = "<blockquote>{$content}</blockquote>";
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
elseif ( has_post_format( 'aside' ) and ! is_singular() ) {
|
|
591
|
+
preg_match( '/<p>(.*?)<\/p>(?!\s*<p>)/', $content, $matches );
|
|
592
|
+
|
|
593
|
+
$content = str_replace( $matches[1], $matches[1] . ' <a href="' . get_permalink() . '">∞</a>', $content );
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
return $content;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
add_filter( 'the_content', 'starter_custom_content' );
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Remove <p> and <br /> in the shortcodes
|
|
603
|
+
*
|
|
604
|
+
* @since [starter] 1.0
|
|
605
|
+
*/
|
|
606
|
+
function starter_shortcode_empty_paragraph_fix( $content ) {
|
|
607
|
+
$array = array(
|
|
608
|
+
'<p>[' => '[',
|
|
609
|
+
']</p>' => ']',
|
|
610
|
+
']<br />' => ']',
|
|
611
|
+
);
|
|
612
|
+
|
|
613
|
+
// replace the strings in the $content
|
|
614
|
+
$content = strtr( $content, $array );
|
|
615
|
+
|
|
616
|
+
return $content;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
add_filter( 'the_content', 'starter_shortcode_empty_paragraph_fix' );
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
|
|
623
|
+
*
|
|
624
|
+
* Create your own starter_entry_meta() to override in a child theme.
|
|
625
|
+
*
|
|
626
|
+
* @since [starter] 1.0
|
|
627
|
+
*/
|
|
628
|
+
function starter_entry_meta() {
|
|
629
|
+
// Translators: used between list items, there is a space after the comma.
|
|
630
|
+
$categories_list = get_the_category_list( __( ', ', 'starter' ) );
|
|
631
|
+
|
|
632
|
+
// Translators: used between list items, there is a space after the comma.
|
|
633
|
+
$tag_list = get_the_tag_list( '', __( ', ', 'starter' ) );
|
|
634
|
+
|
|
635
|
+
$date = sprintf(
|
|
636
|
+
'<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
|
|
637
|
+
esc_url( get_permalink() ),
|
|
638
|
+
esc_attr( get_the_time() ),
|
|
639
|
+
esc_attr( get_the_date( 'c' ) ),
|
|
640
|
+
esc_html( get_the_date() )
|
|
641
|
+
);
|
|
642
|
+
|
|
643
|
+
$author = sprintf(
|
|
644
|
+
'<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
|
|
645
|
+
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
|
|
646
|
+
esc_attr( sprintf( __( 'View all posts by %s', 'starter' ), get_the_author() ) ),
|
|
647
|
+
get_the_author()
|
|
648
|
+
);
|
|
649
|
+
|
|
650
|
+
// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
|
|
651
|
+
if ( $tag_list ) {
|
|
652
|
+
$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'starter' );
|
|
653
|
+
}
|
|
654
|
+
elseif ( $categories_list ) {
|
|
655
|
+
$utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'starter' );
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
$utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'starter' );
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
printf(
|
|
662
|
+
$utility_text,
|
|
663
|
+
$categories_list,
|
|
664
|
+
$tag_list,
|
|
665
|
+
$date,
|
|
666
|
+
$author
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Returns a "Continue Reading" link for excerpts
|
|
672
|
+
*
|
|
673
|
+
* @since [starter] 1.0
|
|
674
|
+
*/
|
|
675
|
+
function starter_continue_reading_link() {
|
|
676
|
+
$read_more_link = ' <a href="' . get_permalink() . '" class="more-link">' . __( 'Continue reading', 'starter' ) . '</a>';
|
|
677
|
+
|
|
678
|
+
return $read_more_link;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Replaces "[...]" (appended to automatically generated excerpts ) with starter_continue_reading_link().
|
|
683
|
+
*
|
|
684
|
+
* To override this in a child theme, remove the filter and add your own
|
|
685
|
+
* function tied to the excerpt_more filter hook.
|
|
686
|
+
*
|
|
687
|
+
* @since [starter] 1.0
|
|
688
|
+
*/
|
|
689
|
+
function starter_auto_excerpt_more( $more ) {
|
|
690
|
+
return starter_continue_reading_link();
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
add_filter( 'excerpt_more', 'starter_auto_excerpt_more' );
|
|
694
|
+
add_filter( 'the_content_more_link', 'starter_auto_excerpt_more' );
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Adds a pretty "Continue Reading" link to custom post excerpts.
|
|
698
|
+
*
|
|
699
|
+
* To override this link in a child theme, remove the filter and add your own
|
|
700
|
+
* function tied to the get_the_excerpt filter hook.
|
|
701
|
+
*
|
|
702
|
+
* @since [starter] 1.0
|
|
703
|
+
*/
|
|
704
|
+
function starter_custom_excerpt_more( $output ) {
|
|
705
|
+
if ( has_excerpt() and ! is_attachment() ) {
|
|
706
|
+
$output .= starter_continue_reading_link();
|
|
707
|
+
}
|
|
708
|
+
return $output;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
add_filter( 'get_the_excerpt', 'starter_custom_excerpt_more' );
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Adds nofollow rel atribute to content links
|
|
715
|
+
*
|
|
716
|
+
* @since [starter] 1.0
|
|
717
|
+
*/
|
|
718
|
+
function starter_nofollow_links_in_post( $text ) {
|
|
719
|
+
global $post;
|
|
720
|
+
|
|
721
|
+
if ( get_post_meta( $post->ID, 'nofollow_links', true ) ) {
|
|
722
|
+
preg_match_all( '/<a.*? href=\"(.*? )\".*?>(.*? )<\/a>/i', $text, $links );
|
|
723
|
+
$match_count = count( $links[0] );
|
|
724
|
+
|
|
725
|
+
for ( $i = 0; $i < $match_count; ++$i ) {
|
|
726
|
+
if ( ! preg_match( '/rel=[\"\']*nofollow[\"\']*/', $links[0][$i] ) ) {
|
|
727
|
+
preg_match_all( '/<a.*? href=\"(.*? )\"(.*? )>(.*? )<\/a>/i', $links[0][$i], $link_text );
|
|
728
|
+
|
|
729
|
+
$search = '>'.$link_text[3][0].'</a>';
|
|
730
|
+
$replace = ' rel="nofollow">'.$link_text[3][0].'</a>';
|
|
731
|
+
|
|
732
|
+
$text = str_replace( $search, $replace, $text );
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
return $text;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
add_action( 'the_content', 'starter_nofollow_links_in_post' );
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Custom tag clould args
|
|
744
|
+
*
|
|
745
|
+
* @since [starter] 1.0
|
|
746
|
+
*/
|
|
747
|
+
function starter_widget_tag_cloud_args( $args ) {
|
|
748
|
+
$args['number'] = 20; // show less tags
|
|
749
|
+
$args['largest'] = 13; // make largest and smallest the same
|
|
750
|
+
$args['smallest'] = 13;
|
|
751
|
+
$args['unit'] = 'px';
|
|
752
|
+
$args['format'] = 'list'; // ul with a class of wp-tag-cloud
|
|
753
|
+
// $args['exclude'] = array(20, 80, 92); // exclude tags by ID
|
|
754
|
+
// $args['taxonomy'] = array('post_tag', 'ingredients'); // add post tags and ingredients taxonomy
|
|
755
|
+
|
|
756
|
+
return $args;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
add_filter( 'widget_tag_cloud_args', 'starter_widget_tag_cloud_args' );
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Filter tag clould output so that it can be styled by CSS
|
|
763
|
+
*
|
|
764
|
+
* @since [starter] 1.0
|
|
765
|
+
*/
|
|
766
|
+
function starter_add_tag_class( $taglinks ) {
|
|
767
|
+
$tags = explode( '</a>', $taglinks );
|
|
768
|
+
$regex = "#(.*tag-link[-])(.*)(' title.*)#e";
|
|
769
|
+
foreach ( $tags as $tag ) {
|
|
770
|
+
$tagn[] = preg_replace( $regex, "('$1$2 label tag-'.get_tag($2)->slug.'$3')", $tag );
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
return implode( '</a>', $tagn );
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
add_filter( 'wp_tag_cloud', 'starter_add_tag_class' );
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Outputs WP Pagenavi pagination or wordpress navigation
|
|
780
|
+
*
|
|
781
|
+
* @since [starter] 1.0
|
|
782
|
+
*/
|
|
783
|
+
function pagination( $query = false ) {
|
|
784
|
+
global $wp_query;
|
|
785
|
+
|
|
786
|
+
if ( is_single() ) {
|
|
787
|
+
?>
|
|
788
|
+
<nav id="comment-nav-below" class="navigation" role="navigation">
|
|
789
|
+
<h1 class="assistive-text section-heading"><?php _e( 'Post Navigation', 'starter' ); ?></h1>
|
|
790
|
+
<?php
|
|
791
|
+
if ( $previous = get_previous_post() ):?>
|
|
792
|
+
<div class="nav-previous alignleft">
|
|
793
|
+
<a href="<?php echo get_permalink( $previous );?>" title="<?php printf( __( 'Permalink to %s', 'starter' ), get_the_title( $previous ) );?>"><?php _e( 'Previous', 'starter' ); ?></a>
|
|
794
|
+
</div>
|
|
795
|
+
<?php endif;?>
|
|
796
|
+
<?php
|
|
797
|
+
if ( $next = get_next_post() ):?>
|
|
798
|
+
<div class="nav-next alignright">
|
|
799
|
+
<a href="<?php echo get_permalink( $next );?>" title="<?php printf( __( 'Permalink to %s', 'starter' ), get_the_title( $next ) );?>"><?php _e( 'Next', 'starter' ); ?></a>
|
|
800
|
+
</div>
|
|
801
|
+
<?php endif;?>
|
|
802
|
+
</nav>
|
|
803
|
+
<?php
|
|
804
|
+
} else {
|
|
805
|
+
if ( $wp_query->max_num_pages > 1 ) {
|
|
806
|
+
if ( function_exists( 'wp_pagenavi' ) ) {
|
|
807
|
+
$args = array( 'options' => PageNavi_Core::$options->get_defaults() );
|
|
808
|
+
|
|
809
|
+
if ( $query ) {
|
|
810
|
+
$args[ 'query' ] = $query;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
wp_pagenavi( $args );
|
|
814
|
+
} else {
|
|
815
|
+
//get_template_part( 'templates/pager' );
|
|
816
|
+
$big = 999999999; // This needs to be an unlikely integer
|
|
817
|
+
|
|
818
|
+
// For more options and info view the docs for paginate_links()
|
|
819
|
+
// http://codex.wordpress.org/Function_Reference/paginate_links
|
|
820
|
+
$paginate_links = paginate_links(
|
|
821
|
+
array(
|
|
822
|
+
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
|
|
823
|
+
'current' => max( 1, get_query_var( 'paged' ) ),
|
|
824
|
+
'total' => $wp_query->max_num_pages,
|
|
825
|
+
'mid_size' => 5,
|
|
826
|
+
'prev_next' => True,
|
|
827
|
+
'prev_text' => __( '←' ),
|
|
828
|
+
'next_text' => __( '→' ),
|
|
829
|
+
'type' => 'list',
|
|
830
|
+
)
|
|
831
|
+
);
|
|
832
|
+
|
|
833
|
+
// Display the pagination if more than one page is found
|
|
834
|
+
if ( $paginate_links ) {
|
|
835
|
+
echo $paginate_links;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
add_action( 'pagination', 'pagination' );
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Template for comments and pingbacks.
|
|
846
|
+
* Used as a callback by wp_list_comments() for displaying the comments.
|
|
847
|
+
*
|
|
848
|
+
* @since [starter] 1.0
|
|
849
|
+
*/
|
|
850
|
+
function starter_comment( $comment, $args, $depth ) {
|
|
851
|
+
$GLOBALS['comment'] = $comment;
|
|
852
|
+
switch ( $comment->comment_type ) {
|
|
853
|
+
case 'pingback' :
|
|
854
|
+
case 'trackback' :
|
|
855
|
+
// Display trackbacks differently than normal comments.
|
|
856
|
+
?>
|
|
857
|
+
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
|
|
858
|
+
<p><?php _e( 'Pingback:', 'starter' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'starter' ), '<span class="edit-link">', '</span>' ); ?></p>
|
|
859
|
+
<?php
|
|
860
|
+
break;
|
|
861
|
+
default :
|
|
862
|
+
// Proceed with normal comments.
|
|
863
|
+
global $post;
|
|
864
|
+
?>
|
|
865
|
+
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
|
|
866
|
+
<article id="comment-<?php comment_ID(); ?>" class="comment">
|
|
867
|
+
<header class="comment-meta comment-author vcard clearfix">
|
|
868
|
+
<?php
|
|
869
|
+
echo get_avatar( $comment, 44 );
|
|
870
|
+
printf(
|
|
871
|
+
'<cite class="fn">%1$s %2$s</cite>',
|
|
872
|
+
get_comment_author_link(),
|
|
873
|
+
// If current post author is also comment author, make it known visually.
|
|
874
|
+
( $comment->user_id === $post->post_author ) ? '<span> ' . __( 'Post author', 'starter' ) . '</span>' : ''
|
|
875
|
+
);
|
|
876
|
+
printf(
|
|
877
|
+
'<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
|
|
878
|
+
esc_url( get_comment_link( $comment->comment_ID ) ),
|
|
879
|
+
get_comment_time( 'c' ),
|
|
880
|
+
/* translators: 1: date, 2: time */
|
|
881
|
+
sprintf( __( '%1$s at %2$s', 'starter' ), get_comment_date(), get_comment_time() )
|
|
882
|
+
);
|
|
883
|
+
?>
|
|
884
|
+
</header>
|
|
885
|
+
|
|
886
|
+
<?php
|
|
887
|
+
if ( '0' == $comment->comment_approved ):
|
|
888
|
+
?>
|
|
889
|
+
<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'starter' ); ?></p>
|
|
890
|
+
<?php endif; ?>
|
|
891
|
+
|
|
892
|
+
<section class="comment-content comment clearfix">
|
|
893
|
+
<?php comment_text(); ?>
|
|
894
|
+
</section>
|
|
895
|
+
|
|
896
|
+
<div class="reply">
|
|
897
|
+
<?php edit_comment_link( __( 'Edit', 'starter' ), '<span class="edit-link">', '</span> / ' ); ?>
|
|
898
|
+
<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'starter' ), 'after' => ' <span>↓</span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
|
|
899
|
+
</div>
|
|
900
|
+
</article>
|
|
901
|
+
<?php
|
|
902
|
+
break;
|
|
903
|
+
} // end comment_type check
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Redirect to post when search query returns single result
|
|
908
|
+
*
|
|
909
|
+
* @see http://wpsnipp.com/index.php/functions-php/redirect-to-post-when-search-query-returns-single-result/
|
|
910
|
+
* @since [starter] 1.0
|
|
911
|
+
*/
|
|
912
|
+
function starter_single_result() {
|
|
913
|
+
if ( is_search() ) {
|
|
914
|
+
global $wp_query;
|
|
915
|
+
if ( $wp_query->post_count == 1 ) {
|
|
916
|
+
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
add_action( 'template_redirect', 'starter_single_result' );
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Add postMessage support for site title and description for the Theme Customizer.
|
|
924
|
+
*
|
|
925
|
+
* @since [starter] 1.0
|
|
926
|
+
*
|
|
927
|
+
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
|
928
|
+
* @return void
|
|
929
|
+
*/
|
|
930
|
+
function starter_customize_register( $wp_customize ) {
|
|
931
|
+
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
|
|
932
|
+
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
|
|
933
|
+
}
|
|
934
|
+
add_action( 'customize_register', 'starter_customize_register' );
|
|
935
|
+
|
|
936
|
+
/* SHORTCODES */
|
|
937
|
+
|
|
938
|
+
// Allow shortcodes in widgets
|
|
939
|
+
add_filter( 'widget_text', 'do_shortcode' );
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* The supported attributes for the shortcode are 'id', 'align', 'width', and 'caption'.
|
|
943
|
+
*
|
|
944
|
+
* @since [starter] 1.0
|
|
945
|
+
*/
|
|
946
|
+
function starter_shortcode_caption( $atts, $content = null ) {
|
|
947
|
+
extract(
|
|
948
|
+
shortcode_atts(
|
|
949
|
+
array(
|
|
950
|
+
'id' => '',
|
|
951
|
+
'align' => 'alignnone',
|
|
952
|
+
'width' => '',
|
|
953
|
+
'caption' => '',
|
|
954
|
+
), $atts
|
|
955
|
+
)
|
|
956
|
+
);
|
|
957
|
+
|
|
958
|
+
if ( 1 > ( int ) $width )
|
|
959
|
+
return $content;
|
|
960
|
+
|
|
961
|
+
if ( empty( $caption ) ) {
|
|
962
|
+
preg_match( '/(<img[^>]+>)[ ]?(.*)/i', $content, $match );
|
|
963
|
+
$content = $match[1];
|
|
964
|
+
$caption = $match[2];
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
if ( $id ) {
|
|
968
|
+
$idtag = 'id="' . esc_attr( $id ) . '" ';
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
$out[] = '<figure ' . $idtag . 'aria-describedby="figcaption_' . $id . '" class="post-image wp-caption ' . $align . '">';
|
|
972
|
+
$out[] = do_shortcode( $content );
|
|
973
|
+
$out[] = '<figcaption id="figcaption_' . $id . '" class="caption wp-caption-text">' . wpautop( wptexturize( $caption ) ) . '</figcaption>';
|
|
974
|
+
$out[] = '</figure>';
|
|
975
|
+
|
|
976
|
+
return implode( "\n", $out );
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
add_shortcode( 'wp_caption', 'starter_shortcode_caption' );
|
|
980
|
+
add_shortcode( 'caption', 'starter_shortcode_caption' );
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
/* ADMIN STUFF */
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Remove unnecessary dashboard widgets
|
|
987
|
+
*
|
|
988
|
+
* @link http://www.deluxeblogtips.com/2011/01/remove-dashboard-widgets-in-wordpress.html
|
|
989
|
+
* @since [starter] 1.0
|
|
990
|
+
*/
|
|
991
|
+
function starter_remove_dashboard_widgets() {
|
|
992
|
+
// Incoming Links Widget
|
|
993
|
+
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
|
|
994
|
+
|
|
995
|
+
// Plugins Widget
|
|
996
|
+
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
|
|
997
|
+
|
|
998
|
+
remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
|
|
999
|
+
remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
|
|
1000
|
+
|
|
1001
|
+
// Sitepress WPML Plugin Widget
|
|
1002
|
+
remove_meta_box( 'icl_dashboard_widget', 'dashboard', 'normal' );
|
|
1003
|
+
|
|
1004
|
+
// Yoast's SEO Plugin Widget
|
|
1005
|
+
remove_meta_box( 'yoast_db_widget', 'dashboard', 'normal' );
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
add_action( 'admin_init', 'starter_remove_dashboard_widgets' );
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* Adds custom menu to admin bar
|
|
1012
|
+
*
|
|
1013
|
+
* @since [starter] 1.0
|
|
1014
|
+
*/
|
|
1015
|
+
function starter_bar_menu( $wp_admin_bar ) {
|
|
1016
|
+
if ( ! is_super_admin() or ! is_admin_bar_showing() )
|
|
1017
|
+
return;
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* Change "Howdy"
|
|
1021
|
+
*/
|
|
1022
|
+
// get the node that contains "howdy"
|
|
1023
|
+
$my_account = $wp_admin_bar->get_node( 'my-account' );
|
|
1024
|
+
// change the "howdy"
|
|
1025
|
+
$my_account->title = str_replace( 'Howdy,', __( 'Hi,', 'starter' ), $my_account->title );
|
|
1026
|
+
// remove the original node
|
|
1027
|
+
$wp_admin_bar->remove_node( 'my-account' );
|
|
1028
|
+
// add back our modified version
|
|
1029
|
+
$wp_admin_bar->add_node( $my_account );
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Removing the "W" menu
|
|
1033
|
+
* I have nothing against it, but I *never* use it
|
|
1034
|
+
*/
|
|
1035
|
+
$wp_admin_bar->remove_menu( 'wp-logo' );
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Create a "Favorites" menu
|
|
1039
|
+
* First, just create the parent menu item
|
|
1040
|
+
*/
|
|
1041
|
+
$wp_admin_bar->add_menu(
|
|
1042
|
+
array(
|
|
1043
|
+
'id' => 'favorites',
|
|
1044
|
+
'parent' => 'top-secondary', // puts it on the right-hand side
|
|
1045
|
+
'title' => __( 'Favorites', 'starter' ),
|
|
1046
|
+
)
|
|
1047
|
+
);
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Then add links to it
|
|
1051
|
+
* This link goes to the All Settings page,
|
|
1052
|
+
* so only show it to users that have appropriate privileges
|
|
1053
|
+
*/
|
|
1054
|
+
if ( current_user_can( 'manage_options' ) ) {
|
|
1055
|
+
$wp_admin_bar->add_menu(
|
|
1056
|
+
array(
|
|
1057
|
+
'id' => 'all-settings',
|
|
1058
|
+
'parent' => 'favorites',
|
|
1059
|
+
'title' => __( 'Options', 'starter' ),
|
|
1060
|
+
'href' => admin_url( 'options.php' ),
|
|
1061
|
+
)
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
// This one goes to the list of the current user's posts
|
|
1066
|
+
$wp_admin_bar->add_menu(
|
|
1067
|
+
array(
|
|
1068
|
+
'id' => 'my-posts',
|
|
1069
|
+
'parent' => 'favorites',
|
|
1070
|
+
'title' => __( 'My Posts', 'starter' ),
|
|
1071
|
+
'href' => admin_url( 'edit.php?post_type=post&author=' . get_current_user_id() ),
|
|
1072
|
+
)
|
|
1073
|
+
);
|
|
1074
|
+
|
|
1075
|
+
// MySQL query and script execution timer output
|
|
1076
|
+
$wp_admin_bar->add_menu(
|
|
1077
|
+
array(
|
|
1078
|
+
'id' => 'do_query_bar',
|
|
1079
|
+
'parent' => 'top-secondary', // puts it on the right-hand side
|
|
1080
|
+
'title' => get_num_queries() . 'Q - ' . timer_stop() . 's', // link title
|
|
1081
|
+
'href' => '#',
|
|
1082
|
+
'meta' => false,
|
|
1083
|
+
)
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
add_action( 'admin_bar_menu', 'starter_bar_menu', '1000' );
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* This simple hack will remove the AIM, Yahoo and Jabber fields and will replace them with a bunch of other social network profiles.
|
|
1091
|
+
*
|
|
1092
|
+
* @since [starter] 1.0
|
|
1093
|
+
*/
|
|
1094
|
+
function starter_user_contactmethods( $contactmethods ) {
|
|
1095
|
+
unset( $contactmethods['aim'], $contactmethods['yim'], $contactmethods['jabber'] );
|
|
1096
|
+
|
|
1097
|
+
// Add Location
|
|
1098
|
+
$contactmethods['user_location'] = __( 'Location', 'starter' );
|
|
1099
|
+
|
|
1100
|
+
// Add Facebook
|
|
1101
|
+
$contactmethods['user_fb'] = __( 'Facebook', 'starter' );
|
|
1102
|
+
|
|
1103
|
+
// Add Pinterest
|
|
1104
|
+
$contactmethods['user_pt'] = __( 'Pinterest', 'starter' );
|
|
1105
|
+
|
|
1106
|
+
// Add Twitter
|
|
1107
|
+
$contactmethods['user_tw'] = __( 'Twitter', 'starter' );
|
|
1108
|
+
|
|
1109
|
+
// Add Linkedin
|
|
1110
|
+
$contactmethods['user_lk'] = __( 'Linkedin', 'starter' );
|
|
1111
|
+
|
|
1112
|
+
// Add Github
|
|
1113
|
+
$contactmethods['user_gh'] = __( 'Github', 'starter' );
|
|
1114
|
+
|
|
1115
|
+
// Add Google+
|
|
1116
|
+
$contactmethods['google_profile'] = __( 'Google+ profile', 'starter' );
|
|
1117
|
+
|
|
1118
|
+
return $contactmethods;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
add_filter( 'user_contactmethods', 'starter_user_contactmethods' );
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* Adds previous/next links to post edition window
|
|
1125
|
+
*
|
|
1126
|
+
* @since [starter] 1.0
|
|
1127
|
+
*/
|
|
1128
|
+
function starter_add_navigation_edit_posts() {
|
|
1129
|
+
if ( isset( $_GET['post'] ) and isset( $_GET['action'] ) and $_GET['action'] == 'edit' ) {
|
|
1130
|
+
global $post;
|
|
1131
|
+
|
|
1132
|
+
$args = array(
|
|
1133
|
+
'public' => true,
|
|
1134
|
+
'_builtin' => false,
|
|
1135
|
+
);
|
|
1136
|
+
$output = 'names'; // names or objects, note names is the default
|
|
1137
|
+
$operator = 'and'; // 'and' or 'or'
|
|
1138
|
+
|
|
1139
|
+
$post_types = get_post_types( $args, $output, $operator );
|
|
1140
|
+
|
|
1141
|
+
$post_types['post'] = 'post';
|
|
1142
|
+
$post_types['page'] = 'page';
|
|
1143
|
+
|
|
1144
|
+
if ( is_object( $post ) and in_array( $post->post_type, $post_types ) ) {
|
|
1145
|
+
$wtf = array( true, false );
|
|
1146
|
+
foreach ( $wtf as $prev ) {
|
|
1147
|
+
$p = get_adjacent_post( false, '', $prev );
|
|
1148
|
+
|
|
1149
|
+
if ( ! empty( $p ) ) {
|
|
1150
|
+
echo '<script>
|
|
1151
|
+
jQuery(function($) {
|
|
1152
|
+
$(".wrap h2" )
|
|
1153
|
+
.append(\'<a class="add-new-h2" href="' . admin_url( 'post.php?action=edit&post=' . $p->ID ) . '" title="' . __( 'Editar', 'starter' ) . ' ' . apply_filters( 'the_title', $p->post_title ) . '">' . ( $prev ? '« ' : '' ) . apply_filters( 'the_title', $p->post_title ) . ( ! $prev ? ' »' : '' ) . '</a>\' );
|
|
1154
|
+
});
|
|
1155
|
+
</script>';
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
add_action( 'admin_head', 'starter_add_navigation_edit_posts' );
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* Custom Login Logo Support
|
|
1166
|
+
*
|
|
1167
|
+
* @since [starter] 1.0
|
|
1168
|
+
*/
|
|
1169
|
+
function starter_custom_login_logo() {
|
|
1170
|
+
echo '<style type="text/css">
|
|
1171
|
+
h1 a { background-image:url(' . get_template_directory_uri() . '/images/login-logo.png) !important; }
|
|
1172
|
+
</style>';
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
add_action( 'login_head', 'starter_custom_login_logo' );
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Custom Login URL
|
|
1179
|
+
*
|
|
1180
|
+
* @since [starter] 1.0
|
|
1181
|
+
*/
|
|
1182
|
+
function starter_wp_login_url() {
|
|
1183
|
+
return home_url();
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
add_filter( 'login_headerurl', 'starter_wp_login_url' );
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* Custom Login Title
|
|
1190
|
+
*
|
|
1191
|
+
* @since [starter] 1.0
|
|
1192
|
+
*/
|
|
1193
|
+
function starter_wp_login_title() {
|
|
1194
|
+
return get_option( 'blogname' );
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
add_filter( 'login_headertitle', 'starter_wp_login_title' );
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Custom Backend Footer
|
|
1201
|
+
*
|
|
1202
|
+
* @since [starter] 1.0
|
|
1203
|
+
*/
|
|
1204
|
+
function starter_custom_admin_footer() {
|
|
1205
|
+
$credits = '<span id="footer-thankyou">Crafted by <a href="//alexsancho.name" target="_blank">Alex Sancho</a></span>.';
|
|
1206
|
+
|
|
1207
|
+
echo apply_filters( 'starter_custom_admin_footer', $credits );
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// adding it to the admin area
|
|
1211
|
+
add_filter( 'admin_footer_text', 'starter_custom_admin_footer' );
|