__( 'Primary Menu', 'google_s' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
) );
/*
* Enable support for Post Formats.
* See http://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside', 'image', 'video', 'quote', 'link',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'google_s_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
}
endif;
// google_s_setup
add_action( 'after_setup_theme', 'google_s_setup' );
/**
* This theme have two sidebars one on the Right and one at the top of the footer.
* Register widget area.
*
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
function google_s_widgets_init() {
register_sidebar( array(
'name' => __( 'Right Sidebar', 'google_s' ),
'id' => 'sidebar-1',
'description' => 'This is a simple rght Sidebar, if i empty the site will be full width.',
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Sidebar', 'google_s' ),
'id' => 'sidebar-2',
'description' => 'This is multi layout Footer Sidebar if empty appears the default content.',
'before_widget' => '',
'after_widget' => ' ',
'before_title' => '',
'after_title' => ' ',
) );
}
add_action( 'widgets_init', 'google_s_widgets_init' );
/**
* Add "first" and "last" CSS classes to dynamic sidebar widgets. Also adds numeric index class for each widget (widget-1, widget-2, etc.)
*/
function widget_first_last_class($params) {
global $my_widget_num; // Global a counter array
$this_id = $params[0]['id']; // Get the id for the current sidebar we're processing
$arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets
if(!$my_widget_num) {// If the counter array doesn't exist, create it
$my_widget_num = array();
}
if(!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) { // Check if the current sidebar has no widgets
return $params; // No widgets in this sidebar... bail early.
}
if(isset($my_widget_num[$this_id])) { // See if the counter array has an entry for this sidebar
$my_widget_num[$this_id] ++;
} else { // If not, create it starting with 1
$my_widget_num[$this_id] = 1;
}
$class = 'class="widget-' . $my_widget_num[$this_id] . ' '; // Add a widget number class for additional styling options
if($my_widget_num[$this_id] == 1) { // If this is the first widget
$class .= 'widget-first ';
} elseif($my_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) { // If this is the last widget
$class .= 'g-medium--last g-wide--last ';
}
$params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']); // Insert our new classes into "before widget"
return $params;
}
add_filter('dynamic_sidebar_params','widget_first_last_class');
// Add custom editor support
function google_s_add_editor_styles() {
add_editor_style( 'custom-editor-style.css' );
}
add_action( 'after_setup_theme', 'google_s_add_editor_styles' );
/**
* Enqueue scripts and styles.
*/
function google_s_scripts() {
wp_enqueue_style( 'google_s-style', get_stylesheet_uri() );
wp_enqueue_style( 'main-style', get_template_directory_uri() . '/genericons/genericons.css' );
wp_enqueue_style( 'genericons-style', get_template_directory_uri() . '/styles/main.css' );
wp_enqueue_script( 'google_s-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
wp_enqueue_script( 'google_s-main-js', get_template_directory_uri() . '/scripts/main.min.js', array(), '20120206', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'google_s_scripts' );
/**
* Implement the Custom Header feature.
*/
//require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
// Enqueue Scripts/Styles for our Lightbox
function alter_add_lightbox() {
wp_enqueue_script( 'fancybox', get_template_directory_uri() . '/scripts/jquery.fancybox.pack.js', array( 'jquery' ), false, true );
wp_enqueue_script( 'lightbox', get_template_directory_uri() . '/scripts/lightbox.js', array( 'fancybox' ), false, true );
wp_enqueue_style( 'lightbox-style', get_template_directory_uri() . '/styles/jquery.fancybox.css' );
}
add_action( 'wp_enqueue_scripts', 'alter_add_lightbox' );
// The Excerpt length
function new_excerpt_length($length) {
return 80;
}
add_filter('excerpt_length', 'new_excerpt_length');
// Replaces the excerpt "more" text by a link
function new_excerpt_more($more) {
global $post;
if ($pos=strpos($post->post_content, '')){
return ' Read the full post ';
}
else {
return ' Read the full post ';
}
}
add_filter('excerpt_more', 'new_excerpt_more');
/**
* Meta box for Pages and Posts header
*/
function prfx_custom_meta() {
add_meta_box( 'prfx_meta', __( 'Header Line', 'google_s' ), 'prfx_meta_callback', 'post', 'normal', 'high' );
add_meta_box( 'prfx_meta', __( 'Header Line', 'google_s' ), 'prfx_meta_callback', 'page', 'normal', 'high' );
}
add_action( 'add_meta_boxes', 'prfx_custom_meta' );
/**
* Outputs the content of the meta box
*/
function prfx_meta_callback( $post ) {
wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
$prfx_stored_meta = get_post_meta( $post->ID );
?>