-
Notifications
You must be signed in to change notification settings - Fork 5
/
functions.php
executable file
·378 lines (331 loc) · 19.7 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<?php
/**
* Memberlite [Words] Child Theme functions and definitions
*
* @package Memberlite Words
*/
// Define constants
define( 'MEMBERLITE_WORDS_DIR', get_stylesheet_directory() );
// Enqueue scripts and styles.
function memberlite_words_enqueue_styles() {
wp_enqueue_style( 'memberlite', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'memberlite_words_enqueue_styles' );
/**
* Remove unused parent theme items.
*/
function memberlite_words_setup() {
// Add logo upload support via Customizer
add_theme_support( 'custom-logo', array(
'height' => 200,
'width' => 200,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
) );
remove_image_size( 'memberlite-banner' );
remove_image_size( 'memberlite-fullwidth' );
remove_image_size( 'memberlite-masthead' );
// Remove theme support for post formats.
remove_theme_support( 'post-formats' );
remove_theme_support( 'custom-header' );
// Remove support for a custom body background.
remove_theme_support( 'custom-background' );
// Unregister unused theme menu locations.
unregister_nav_menu( 'meta' );
}
add_action( 'after_setup_theme', 'memberlite_words_setup', 20 );
/**
* Remove unused parent theme widget areas.
*/
function memberlite_words_widgets_init() {
unregister_sidebar( 'sidebar-1' ); // Pages
unregister_sidebar( 'sidebar-2' ); // Posts and Archives
unregister_sidebar( 'sidebar-3' ); // Header Right
}
add_action( 'widgets_init', 'memberlite_words_widgets_init', 20 );
/**
* Filter the theme page templates.
*
* @param array $page_templates Page templates.
* @param WP_Theme $theme_instance WP_Theme instance.
* @param WP_Post $post The post being edited, provided for context, or null.
* @return array (Maybe) modified page templates array.
*/
function memberlite_words_filter_theme_page_templates( $page_templates, $theme_instance, $post ) {
unset( $page_templates['templates/blank.php'] );
unset( $page_templates['templates/content-sidebar.php'] );
unset( $page_templates['templates/fluid-width.php'] );
unset( $page_templates['templates/full-width.php'] );
unset( $page_templates['templates/interstitial.php'] );
unset( $page_templates['templates/landing.php'] );
unset( $page_templates['templates/narrow-width.php'] );
unset( $page_templates['templates/sidebar-content.php'] );
return $page_templates;
}
add_filter( 'theme_page_templates', 'memberlite_words_filter_theme_page_templates', 20, 3 );
/**
* Remove unused parent theme customizer options.
*/
function memberlite_words_customize_register() {
global $wp_customize;
$customizer_settings = apply_filters( 'memberlite_words_remove_customizer_settings', array(
'nav_menu_search',
'sticky_nav',
'columns_ratio_header',
'columns_ratio',
'sidebar_location',
'sidebar_location_blog',
'posts_entry_meta_after',
'page_breadcrumbs',
'post_breadcrumbs',
'archive_breadcrumbs',
'attachment_breadcrumbs',
'search_breadcrumbs',
'profile_breadcrumbs',
'delimiter',
'memberlite_loop_images',
) );
foreach( $customizer_settings as $setting ) {
$wp_customize->remove_control( $setting );
$wp_customize->remove_setting( $setting );
}
}
add_action( 'customize_register', 'memberlite_words_customize_register', 99 );
function memberlite_words_memberlite_defaults( $memberlite_defaults ) {
$memberlite_defaults['memberlite_webfonts'] = 'Roboto-Slab_Roboto';
$memberlite_defaults['posts_entry_meta_before'] = '{post_categories} {post_comments} {post_date}';
$memberlite_defaults['copyright_textbox'] = '<a href="http://wordpress.org/" rel="license">' . __( 'Proudly powered by WordPress', 'memberlite' ) . '</a><span class="sep"> | </span><a href="https://memberlitetheme.com/child-themes/words/" rel="license">' . __( 'Theme: Memberlite Words', 'memberlite' ) . '</a>';
$memberlite_defaults['color_primary_background_elements'] = '#mobile-navigation, #mobile-navigation-height-col, .btn_primary, .btn_primary:link, .menu-toggle, .bg_primary, .banner_primary, .has-background.has-color-primary-background-color';
$memberlite_defaults['color_secondary_background_elements'] = '.btn_secondary, .btn_secondary:link, .memberlite_tabbable ul.memberlite_tabs li.memberlite_active a, .memberlite_tabbable ul.memberlite_tabs li.memberlite_active a:hover, .banner_secondary, #banner_bottom, .has-background.has-color-secondary-background-color';
$memberlite_defaults['memberlite_color_scheme'] = 'Default';
$memberlite_defaults['bgcolor_header'] = '#FFFFFF';
$memberlite_defaults['bgcolor_site_navigation'] = '#F2F2F2';
$memberlite_defaults['color_site_navigation'] = '#292929';
$memberlite_defaults['color_link'] = '#54C4B1';
$memberlite_defaults['color_meta_link'] = '#303030';
$memberlite_defaults['color_primary'] = '#F2F2F2';
$memberlite_defaults['color_secondary'] = '#B5B5B5';
$memberlite_defaults['color_action'] = '#51BCA7';
/* array(
'memberlite_webfonts' => 'Lato_Lato',
'columns_ratio' => '8-4',
'columns_ratio_header' => '4-8',
'sidebar_location' => 'sidebar-right',
'sidebar_location_blog' => 'sidebar-blog-right',
'content_archives' => 'content',
'memberlite_loop_images' => 'show_none',
'posts_entry_meta_before' => __( 'Posted on {post_date} by {post_author_posts_link}', 'memberlite' ),
'posts_entry_meta_after' => __( 'This entry was posted in {post_categories} and tagged {post_tags}. Bookmark the {post_permalink}.', 'memberlite' ),
'memberlite_footerwidgets' => '4',
'copyright_textbox' => '<a href="http://wordpress.org/" rel="license">' . __( 'Proudly powered by WordPress', 'memberlite' ) . '</a><span class="sep"> | </span><a href="http://memberlitetheme.com" rel="license">' . __( 'Theme: Memberlite by Kim Coleman', 'memberlite' ) . '</a>',
'memberlite_back_to_top' => true,
'memberlite_color_scheme' => 'Default',
'memberlite_darkcss' => false,
'bgcolor_header' => '',
'bgcolor_site_navigation' => '#FAFAFA',
'color_site_navigation' => '#777777',
'color_link' => '#2C3E50',
'color_meta_link' => '#2C3E50',
'color_primary' => '#2C3E50',
'color_secondary' => '#18BC9C',
'color_action' => '#F39C12',
'bgcolor_header_elements' => '#masthead',
'bgcolor_site_navigation_elements' => '#site-navigation, .main-navigation ul.sub-menu',
'color_site_navigation_elements' => '.main-navigation a',
'color_site_navigation_hover_elements' => '.main-navigation li:hover, .main-navigation li:hover > a',
'color_link_color_elements' => '.content-area a, .footer-navigation a, .site-info a',
'color_link_hover_elements' => '.content-area a:hover, .footer-navigation a:hover, .site-info a:hover',
'color_meta_link_color_elements' => '.header-right .menu a',
'color_primary_background_elements' => '#mobile-navigation, #mobile-navigation-height-col, .masthead, .footer-widgets, .btn_primary, .btn_primary:link, .menu-toggle, .bg_primary, .banner_primary, .has-background.has-color-primary-background-color',
'color_primary_background_hover_elements' => '.btn_primary:hover',
'color_primary_color_elements' => '#meta-navigation ul ul a, #pmpro_levels .post h2, .memberlite_signup h2, .pmpro_signup_form h2, .primary, .has-text-color.has-color-primary-color',
'color_primary_color_hover_elements' => '#meta-navigation ul ul a:hover',
'color_secondary_background_elements' => '#meta-member .meta-member-inner, #meta-member .member-navigation .sub-menu, .btn_secondary, .btn_secondary:link, .memberlite_tabbable ul.memberlite_tabs li.memberlite_active a, .memberlite_tabbable ul.memberlite_tabs li.memberlite_active a:hover, .banner_secondary, #banner_bottom, .has-background.has-color-secondary-background-color',
'color_secondary_background_hover_elements' => '.btn_secondary:hover',
'color_secondary_border_elements' => '#pmpro_levels .pmpro_level-highlight, #pmpro_levels.pmpro_levels-2col .pmpro_level-highlight, #pmpro_levels.pmpro_levels-3col .pmpro_level-highlight, #pmpro_levels.pmpro_levels-4col .pmpro_level-highlight, #pmpro_levels.pmpro_levels-div .pmpro_level-highlight, #pmpro_levels.pmpro_advanced_levels-compare_table thead tr:first-child th.pmpro_level-highlight, #pmpro_levels.pmpro_advanced_levels-compare_table tfoot tr:last-child td.pmpro_level-highlight, .memberlite_signup, .pmpro_signup_form, .memberlite_tabbable ul.memberlite_tabs li.memberlite_active a, .memberlite_tabbable .memberlite_tab_content',
'color_secondary_border_left_elements' => '#pmpro_levels.pmpro_advanced_levels-compare_table thead th.pmpro_level-highlight, #pmpro_levels.pmpro_advanced_levels-compare_table tbody td.pmpro_level-highlight, #pmpro_levels.pmpro_advanced_levels-compare_table tfoot td.pmpro_level-highlight, #pmpro_levels.pmpro_levels-table .pmpro_level-highlight td:first-child, .memberlite_tabbable ul.memberlite_tabs li.memberlite_active a',
'color_secondary_border_right_elements' => '#pmpro_levels.pmpro_advanced_levels-compare_table thead th.pmpro_level-highlight, #pmpro_levels.pmpro_advanced_levels-compare_table tbody td.pmpro_level-highlight, #pmpro_levels.pmpro_advanced_levels-compare_table tfoot td.pmpro_level-highlight, #pmpro_levels.pmpro_levels-table .pmpro_level-highlight td:last-child, .memberlite_tabbable ul.memberlite_tabs li.memberlite_active a',
'color_secondary_color_elements' => 'blockquote.quote:before, q:before, .testimonials-widget-testimonial .open-quote::before, .testimonials-widget-testimonial .close-quote::after, .woocommerce ul.products li.product .price, .woocommerce-page ul.products li.product .price, .woocommerce #content div.product p.price, .woocommerce #content div.product span.price, .woocommerce div.product p.price, .woocommerce div.product span.price, .woocommerce-page #content div.product p.price, .woocommerce-page #content div.product span.price, .woocommerce-page div.product p.price, .woocommerce-page div.product span.price, .secondary, .has-text-color.has-color-secondary-color',
'color_action_background_elements' => '.btn_action, .btn_action:link, .pmpro_content_message a, .pmpro_content_message a:link, .pmpro_content_message a:visited, .pmpro_btn, .pmpro_btn:link, .pmpro_btn:visited, a.pmpro_btn, a.pmpro_btn:link, a.pmpro_btn:visited, input[type=button].pmpro_btn, input[type=submit].pmpro_btn, #loginform input[type=submit].button.button-primary, .woocommerce #content input.button.alt, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce-page #content input.button.alt, .woocommerce-page #respond input#submit.alt, .woocommerce-page a.button.alt, .woocommerce-page button.button.alt, .woocommerce-page input.button.alt, .bg_action, .banner_action, .has-background.has-color-action-background-color',
'color_action_background_hover_elements' => '.btn_action:hover, .pmpro_content_message a:hover, .pmpro_btn:hover, a.pmpro_btn:hover, input[type=button].pmpro_btn:hover, input[type=submit].pmpro_btn:hover, .woocommerce #content input.button.alt:hover, .woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover, .woocommerce-page #content input.button.alt:hover, .woocommerce-page #respond input#submit.alt:hover, .woocommerce-page a.button.alt:hover, .woocommerce-page button.button.alt:hover, .woocommerce-page input.button.alt:hover',
'color_action_color_elements' => '.action, .has-text-color.has-color-action-color',
'delimiter' => ' / ',
'memberlite_darkcss' => false,
*/
return $memberlite_defaults;
}
add_filter( 'memberlite_defaults', 'memberlite_words_memberlite_defaults' );
/**
* Filter the columns ratio to always be narrow width.
*
* @param string $r The return value for the column CSS selectors.
* @param string $location Where in the theme this CSS is used.
* @return strong The column CSS selectors to output.
*/
function memberlite_words_columns_ratio( $r, $location ) {
global $memberlite_defaults;
if ( ! empty( $location ) ) {
return $r;
}
$r = '10 medium-offset-1 large-8 large-offset-2 small-12';
return $r;
}
add_filter( 'memberlite_columns_ratio', 'memberlite_words_columns_ratio', 10, 2 );
/**
* Filter to display site adminstration email Gravatar as logo if the_custom_logo is not set.
*
*/
function memberlite_words_get_custom_logo( $html, $blog_id ) {
$custom_logo_id = get_theme_mod( 'custom_logo' );
if ( ! empty( $custom_logo_id ) ) {
return $html;
} else {
$html = sprintf(
'<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
esc_url( home_url( '/' ) ),
get_avatar( get_option( 'admin_email' ), 200, false, get_bloginfo( 'name' ) )
);
}
return $html;
}
add_filter( 'get_custom_logo', 'memberlite_words_get_custom_logo', 10, 2 );
function memberlite_words_memberlite_show_header_right( $show_header_right ) {
return false;
}
add_filter( 'memberlite_show_header_right', 'memberlite_words_memberlite_show_header_right', 20 );
/*
Filter to hide the masthead banner throughout site.
*/
function memberlite_words_memberlite_banner_show() {
return false;
}
add_filter( 'memberlite_banner_show', 'memberlite_words_memberlite_banner_show', 20 );
function memberlite_words_memberlite_before_site_header() {
$meta_login = get_theme_mod( 'meta_login', false );
if ( ! empty( $meta_login ) ) {
get_template_part( 'components/header/meta', 'member' );
}
}
add_action( 'memberlite_before_site_header', 'memberlite_words_memberlite_before_site_header' );
/*
Filter to hide the sidebars throughout site.
*/
function memberlite_words_memberlite_get_sidebar( $name ) {
return false;
}
add_filter( 'memberlite_get_sidebar', 'memberlite_words_memberlite_get_sidebar', 20 );
function memberlite_words_masthead() {
if ( ! is_home() ) { ?>
<header class="masthead_words">
<?php do_action( 'memberlite_before_masthead_inner' ); ?>
<?php memberlite_page_title(); ?>
<?php do_action( 'memberlite_after_masthead_inner' ); ?>
</header><!-- .masthead_words -->
<?php }
}
add_action( 'memberlite_before_loop', 'memberlite_words_masthead' );
function memberlite_words_memberlite_page_title( $page_title_html ) {
if ( ! is_singular( 'post' ) ) {
return $page_title_html;
} else {
global $post;
// Capture output.
ob_start();
the_title( '<h1 class="entry-title">', '</h1>' );
$memberlite_get_entry_meta_before = memberlite_get_entry_meta( $post, 'before' );
if ( ! empty( $memberlite_get_entry_meta_before ) ) { ?>
<p class="entry-meta">
<?php echo Memberlite_Customize::sanitize_text_with_links( memberlite_get_entry_meta( $post, 'before' ) ); ?>
</p><!-- .entry-meta -->
<?php }
//get captured output
$page_title_html = ob_get_contents();
ob_end_clean();
}
return $page_title_html;
}
add_filter( 'memberlite_page_title', 'memberlite_words_memberlite_page_title', 20 );
/**
* Remove the post meta shown after the post for the Words theme.
*
*/
function memberlite_words_entry_meta_remove_after( $meta, $post, $location) {
if ( $location === 'after' ) {
$meta = '';
}
return $meta;
}
add_filter( 'memberlite_get_entry_meta' , 'memberlite_words_entry_meta_remove_after', 10, 3 );
function memberlite_words_memberlite_before_content_single() {
// Show the featured image
if ( has_post_thumbnail() ) { ?>
<a class="splash-image" href="<?php echo get_permalink(); ?>">
<?php the_post_thumbnail( 'full' ); ?>
</a>
<?php
}
}
add_action( 'memberlite_before_content_single', 'memberlite_words_memberlite_before_content_single' );
/**
* Add Memberlite Words theme documentation to the Memberlite Guide.
*
*/
function memberlite_words_memberlite_guide_additional() { ?>
<img style="box-shadow: 0px 0px 5px #AAA; float: right; margin: 15px 30px; max-width: 300px; padding: 3px;" src="<?php echo wp_get_theme()->get_screenshot(); ?>" />
<h1><?php _e( 'Memberlite Words', 'memberlite-words' ); ?> <span style="background: #AAA; border-radius: 10px; color: #FFF; display: inline-block; font-size: 10px; font-weight: bold; padding: 3px 8px;"><?php esc_html_e( 'ACTIVE', 'memberlite-words' ); ?></span></h1>
<p><?php esc_html_e( 'Memberlite Words is designed to be minimalistic and unobtrusive, letting your content be the hero. Perfect for writers, bloggers, and content creators, Memberlite Words makes it easy to tell the world your story.', 'memberlite-words' ); ?></p>
<p><?php esc_html_e( 'Use Memberlite Words as a platform to share your thoughts and ideas. We have also integrated Memberlite Words to work with Paid Memberships Pro, a WordPress Membership plugin. This integration opens up a lot of possibilities for you, the creator. Build a "Go Fund Me" style website, restrict content your content behind a paywall, or build a community around your personal brand.', 'memberlite-words' ); ?></p>
<h3><?php esc_html_e( 'Created for the creator, Memberlite Words gives you the power to publish content beautifully.' ); ?></h3>
<a class="button button-hero button-primary" href="https://memberlitetheme.com/themes/memberlite-words/?utm_source=memberlite-words&utm_medium=memberlite-guide&utm_campaign=documentation&utm_content=documentation" target="_blank"><?php esc_html_e( 'Documentation', 'memberlite-words' ); ?></a> <a class="button button-hero" href="https://demo.memberlitetheme.com/words/?utm_source=memberlite-words&utm_medium=memberlite-guide&utm_campaign=demo&utm_content=theme-demo">Theme Demo</a>
<?php
}
add_action( 'memberlite_guide_additional', 'memberlite_words_memberlite_guide_additional' );
/**
* Filter the recommended plugins to show on the Memberlite Guide.
*
*/
function memberlite_words_memberlite_plugins_recommended( $memberlite_plugins_recommended ) {
$memberlite_plugins_recommended = array( 'memberlite-shortcodes', 'paid-memberships-pro' );
return $memberlite_plugins_recommended;
}
add_filter( 'memberlite_plugins_recommended', 'memberlite_words_memberlite_plugins_recommended' );
/**
* Filter the integrated plugins to show on the Memberlite Guide.
*
*/
function memberlite_words_memberlite_plugins_integrated( $memberlite_plugins_integrated ) {
$memberlite_plugins_integrated = array( 'paid-memberships-pro' );
return $memberlite_plugins_integrated;
}
add_filter( 'memberlite_plugins_integrated', 'memberlite_words_memberlite_plugins_integrated' );
/**
* Filter the supported Elements in the Memberlite Elements plugin.
*
*/
function memberlite_words_memberlite_elements_supported_elements( $memberlite_elements_supported_elements ) {
$memberlite_elements_supported_elements = array();
return $memberlite_elements_supported_elements;
}
add_filter( 'memberlite_elements_supported_elements', 'memberlite_words_memberlite_elements_supported_elements' );
// Filter - Add color schemes
function memberlite_word_color_schemes() {
$word_schemes = array(
'default' => array(
'label' => __( 'Words', 'memberlite' ),
'colors' => array(
'#FFFFFF', // header text color
'#F2F2F2', // background color
'#292929', // primary navigation background color
'#292929', // primary navigation link color
'#54C4B1', // link color
'#F2F2F2', // meta link color
'#F2F2F2', // primary color
'#292929', // secondary color
'#54C4B1', // action color
),
),
);
return $word_schemes;
}
add_filter( 'memberlite_color_schemes', 'memberlite_word_color_schemes' );