<?php
/* Add our function to the *_enqueue_scripts hook. */
add_action( 'wp_enqueue_scripts', 'wordcamp_vegas_scripts' );
/**
* Function that registers and enqueues our scripts & styles.
*
* @since 1.0.0
*/
function wordcamp_vegas_scripts() {
wp_enqueue_script( 'mytheme-functions', trailingslashit( get_stylesheet_directory_uri() ) . 'library/js/functions.js', array( 'jquery' ), '1.0.1', true );
wp_enqueue_style( 'mytheme', trailingslashit( get_stylesheet_directory_uri() ) . 'library/css/screen.css', null, '1.0.1', 'screen' );
}
?>
Where Does this function belong?functions.phpThis function should reside in your Theme OR Child Themes functions.php because it correlates to the design of your site.
There .
<?php
/* Register sidebars. */
add_action( 'widgets_init', 'wordcamp_vegas_register_sidebars', 12 );
/**
* Function that registers and enqueues our scripts & styles.
*
* @since 1.0.0
*/
function wordcamp_vegas_register_sidebars() {
$utility_bar = array(
'name' => __( 'Utility: Bar' ),
'id' => 'utilitybar',
'description' => __( 'Displayed at the top of the page.' ),
'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
);
register_sidebar( $utility_bar );
}
?>
Where Does this function belong?functions.phpThis function should reside in your Theme OR Child Themes functions.php because it creates widget areas for use in your current design.
This sidebar might not have any use in a future project or the next theme you may use.
<?php
/* Register sidebars. */
add_action( 'init', 'wordcamp_vegas_register_post_type' );
/**
* Function that registers our Custom Post Type.
*
* @since 1.0.0
*/
function wordcamp_vegas_register_post_type() {
/* Labels. */
$portfolio_labels = array(
'menu_name' => __( 'Portfolio' ),
'name' => __( 'Projects' ),
'singular_name' => __( 'Project' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Project' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit Project' ),
'new_item' => __( 'New Project' ),
'view' => __( 'View Project' ),
'view_item' => __( 'View Project' ),
'search_items' => __( 'Search Projects' ),
'not_found' => __( 'No Projects found' ),
'not_found_in_trash' => __( 'No Projects found in the Trash' ),
);
/* Arguments. */
$portfolio_args = array(
'has_archive' => 'portfolio',
'show_in_nav_menus' => false,
'description' => 'Here you will find a select few of my WordPress projects. Ranging from custom theme development to minor theme modification. You might also see some custom plugin development. Note, not all of my work is public.',
'labels' => $portfolio_labels,
'public' => true,
'publicly_queryable' => true,
'query_var' => 'portfolio',
'rewrite' => array( 'slug' => false, 'with_front' => true ),
'capability_type' => 'post',
'hierarchical' => false,
'taxonomies' => array( 'project_category', 'project_tag', 'project_tools' ),
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', "{$prefix}-post-settings", 'entry-views' ),
);
/* Register. */
register_post_type( 'portfolio', $portfolio_args );
}
?>
Where Does this function belong?you-site-functionallity-plugin/functions.phpThis function should be created in functionallity plugin. If you’re creating Custom Post Types chances are you will want them around when you change themes in the future.
Example: If your CPT is a portfolio, and your the type of person who changes your theme once a month you don’t want to have to copy and paste code from each theme everytime... This way it always exists as long as the plugin is Active.