-
-
Save luislandero/3c6e66061074a29b3f032000ca754291 to your computer and use it in GitHub Desktop.
functions file ASTROMONO.COM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Opening PHP tag - nothing should be before this, not even whitespace | |
function astra_enqueue_styles() { | |
$parent_style = 'twentyfourteen-style'; | |
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); | |
wp_enqueue_style( 'child-style', | |
get_stylesheet_directory_uri() . '/style.css', | |
array( $parent_style ), | |
wp_get_theme()->get('Version') | |
); | |
} | |
add_action( 'wp_enqueue_scripts', 'astra_enqueue_styles' ); | |
// Add Webmaster Tools verification | |
function google_webmaster_tools() { | |
echo '<meta name="google-site-verification" content="qZ2MqO-e28EHS7VmtgOj8dZbPgEpvIY2iL021fNg44k" />' . "\n"; | |
} | |
add_action( 'wp_head', 'google_webmaster_tools' ); | |
// Remove Version Number | |
function mono_remove_version() { | |
return ''; | |
} | |
add_filter('the_generator', 'mono_remove_version'); | |
// Featured image size for full width | |
if ( ! isset( $content_width ) ) | |
$content_width = 474; | |
function astra_adjust_content_width() { | |
global $content_width; | |
// if ( is_page_template( 'full-width.php' ) ) | |
$content_width = 1038; | |
} | |
add_action( 'template_redirect', 'astra_adjust_content_width' ); | |
add_action( 'after_setup_theme', 'thumbnail_size_tweak', 11 ); | |
function thumbnail_size_tweak() { | |
set_post_thumbnail_size( 1038, 572, true ); | |
} | |
// Add author relationship | |
function mono_allow_rel() { | |
global $allowedtags; | |
$allowedtags['a']['rel'] = array(); | |
} | |
add_action( 'wp_loaded', 'mono_allow_rel'); | |
// Add Google Profiles | |
function mono_add_google_profile( $contactmethods) { | |
$contactmethods ['google_profile'] = 'Google Profile URL'; | |
return $contactmethods; | |
} | |
add_filter( 'user_contactmethods', 'mono_add_google_profile', 10, 1); | |
// Add Email Suscription | |
register_sidebar( array( | |
'name' => 'Subscribe in page', | |
'id' => 'subscribe-in-page', | |
// to revert back to the non-full width sidebar just take off the "-full" part | |
'before_widget' => '<div class="suscribete-full">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3>', | |
'after_title' => '</h3>' | |
) ); | |
// Add Email Suscription Full Width | |
register_sidebar( array( | |
'name' => 'Email Suscribe Full Width', | |
'id' => 'subscribe-full-width', | |
'before_widget' => '<div class="suscribete-full">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3>', | |
'after_title' => '</h3>' | |
) ); | |
// Remove html tag info after comments | |
function yourtheme_init() { | |
add_filter('comment_form_defaults','yourtheme_comments_form_defaults'); | |
} | |
add_action('after_setup_theme','yourtheme_init'); | |
function yourtheme_comments_form_defaults($default) { | |
unset($default['comment_notes_after']); | |
return $default; | |
} | |
add_action( 'init', 'create_post_type' ); | |
function create_post_type() { | |
register_post_type( 'am_extra', | |
array( | |
'labels' => array( | |
'name' => __( 'Extras' ), | |
'singular_name' => __( 'Extra' ) | |
), | |
'public' => true, | |
'has_archive' => true, | |
'rewrite' => array('slug' => 'extra'), | |
'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields', 'revisions' ), | |
) | |
); | |
} | |
// Add specific CSS class by filter | |
add_filter( 'body_class', 'my_class_names' ); | |
function my_class_names( $classes ) { | |
if ( get_post_type() == 'am_extra' ) { | |
if ( is_single() ) { | |
// add 'class-name' to the $classes array | |
$classes[] = 'full-width'; } | |
} | |
// return the $classes array | |
return $classes; | |
} | |
// Show posts of 'post', 'page' and 'extra' post types on home page | |
add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); | |
function add_my_post_types_to_query( $query ) { | |
if ( is_home() && $query->is_main_query() ) | |
$query->set( 'post_type', array( 'post', 'am_extra' ) ); | |
return $query; | |
} | |
//add full-width class with custom field | |
add_filter('body_class','am_extra_custom_field_body_class'); | |
function am_extra_custom_field_body_class( $classes ) { | |
global $post; | |
if ( is_single() && ( 'yes' == get_post_meta( $post->ID, 'fullwidth', true ) ) ) { | |
$classes[] = 'full-width'; | |
} | |
// return the $classes array | |
return $classes; | |
} | |
function astra_widgets_init() { | |
// First footer widget area, located in the footer. Empty by default. | |
register_sidebar( array( | |
'name' => __( 'First Footer Widget Area', 'astra' ), | |
'id' => 'first-footer-widget-area', | |
'description' => __( 'The first footer widget area', 'astra' ), | |
'before_widget' => '<div id="%1$s" class="widget-container %2$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 class="widget-title">', | |
'after_title' => '</h3>', | |
) ); | |
// Second Footer Widget Area, located in the footer. Empty by default. | |
register_sidebar( array( | |
'name' => __( 'Second Footer Widget Area', 'astra' ), | |
'id' => 'second-footer-widget-area', | |
'description' => __( 'The second footer widget area', 'astra' ), | |
'before_widget' => '<div id="%1$s" class="widget-container %2$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 class="widget-title">', | |
'after_title' => '</h3>', | |
) ); | |
// Third Footer Widget Area, located in the footer. Empty by default. | |
register_sidebar( array( | |
'name' => __( 'Third Footer Widget Area', 'astra' ), | |
'id' => 'third-footer-widget-area', | |
'description' => __( 'The third footer widget area', 'astra' ), | |
'before_widget' => '<div id="%1$s" class="widget-container %2$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 class="widget-title">', | |
'after_title' => '</h3>', | |
) ); | |
// Fourth Footer Widget Area, located in the footer. Empty by default. | |
register_sidebar( array( | |
'name' => __( 'Fourth Footer Widget Area', 'astra' ), | |
'id' => 'fourth-footer-widget-area', | |
'description' => __( 'The fourth footer widget area', 'astra' ), | |
'before_widget' => '<div id="%1$s" class="widget-container %2$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 class="widget-title">', | |
'after_title' => '</h3>', | |
) ); | |
} | |
// Register sidebars by running astra_widgets_init() on the widgets_init hook. | |
add_action( 'widgets_init', 'astra_widgets_init' ); | |
//Change login logo | |
function my_login_logo() { ?> | |
<style type="text/css"> | |
#login h1 a, .login h1 a { | |
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/wpamlogin.svg); | |
background-repeat: no-repeat; | |
} | |
</style> | |
<?php } | |
add_action( 'login_enqueue_scripts', 'my_login_logo' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment