Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- /*
- // Place your snippets for PHP here. Each snippet is defined under a snippet name and has a prefix, body and
- // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
- // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
- // same ids are connected.
- // Example:
- "Print to console": {
- "prefix": "log",
- "body": [
- "console.log('$1');",
- "$2"
- ],
- "description": "Log output to console"
- }
- */
- "Remove Header Right Widget Area": {
- "prefix": "remove_header_right_widget_area",
- "body": [
- "// Remove header right widget area.",
- "unregister_sidebar( 'header-right' );"
- ],
- "description": "Remove Header Right Widget Area"
- },
- "Register Widget Area": {
- "prefix": "rwa",
- "body": [
- "// Register `${1:home-featured}` widget area.",
- "genesis_register_widget_area(",
- " array(",
- " 'id' => '${1:home-featured}',",
- " 'name' => __( '${2:Home Featured}', 'my-theme-text-domain' ),",
- " 'description' => __( 'This is the ${3:home featured} section.', 'my-theme-text-domain' ),",
- " )",
- ");"
- ],
- "description": "Register a widget area in Genesis."
- },
- "Register Multiple Widget Areas": {
- "prefix": "register_multiple_Widget_areas",
- "body": [
- "// Register ${1:front-page} widget areas.",
- "for ( \\$i = 1; \\$i <= 4; \\$i++ ) {",
- " genesis_register_widget_area(",
- " array(",
- " 'id' => \"${1:front-page}-{\\$i}\",",
- " 'name' => __( \"${2:Front Page} {\\$i}\", 'my-theme-text-domain' ),",
- " 'description' => __( \"This is the ${3:front page} {\\$i} section.\", 'my-theme-text-domain' ),",
- " )",
- " );",
- "}"
- ],
- "description": "Register Multiple Widget Areas"
- },
- "Display Widget Area": {
- "prefix": "dwa",
- "body": [
- "// Display `${1:home-featured}` widget area.",
- "genesis_widget_area( '${1:home-featured}', array(",
- " 'before' => '<div class=\"${1:home-featured} widget-area\"><div class=\"wrap\">',",
- " 'after' => '</div></div>',",
- ") );"
- ],
- "description": "Display a widget area in Genesis."
- },
- "Register Custom Image Size": {
- "prefix": "register_custom_image_size",
- "body": [
- "// Register custom size for images on ${1:content archives}.",
- "add_image_size( '${2:content-archive-image}', ${3:800}, ${4:500}, true );"
- ],
- "description": "Register Custom Image Size"
- },
- "Published Post Date": {
- "prefix": "date",
- "body": [
- "// date.",
- "echo do_shortcode( '[post_date]' );"
- ],
- "description": "Published Post Date in Genesis"
- },
- "Display Featured Image": {
- "prefix": "image",
- "body": [
- "if ( has_post_thumbnail() ) {",
- " // get the URL of featured image.",
- " \\$image_url = genesis_get_image( 'format=url&size=large' );",
- "} else {",
- " // a placeholder.",
- " \\$image_url = 'http://lorempixel.com/1024/1024';",
- "}",
- "",
- "// get the alt text of featured image.",
- "\\$thumb_id = get_post_thumbnail_id( get_the_ID() );",
- "\\$alt = get_post_meta( \\$thumb_id, '_wp_attachment_image_alt', true );",
- "",
- "// if no alt text is present for featured image, set it to entry title.",
- "if ( '' === \\$alt ) {",
- " \\$alt = the_title_attribute( 'echo=0' );",
- "}",
- "",
- "// display the image.",
- "printf( '<figure class=\"story-image\"><img src=\"%s\" alt=\"%s\" /></figure>', \\$image_url, \\$alt );"
- ],
- "description": "Display Featured Image in Genesis"
- },
- "URL of Featured Image": {
- "prefix": "image_url",
- "body": [
- "// get the URL of featured image.",
- "\\$image_url = genesis_get_image( 'format=url&size=large' );"
- ],
- "description": "URL of featured image in Genesis"
- },
- "Entry Title": {
- "prefix": "title",
- "body": [
- "// title.",
- "genesis_do_post_title();"
- ],
- "description": "Entry Title in Genesis"
- },
- "Remove Primary Nav": {
- "prefix": "remove_primary_nav",
- "body": [
- "// Remove the primary navigation menu.",
- "remove_action( 'genesis_after_header', 'genesis_do_nav' );"
- ],
- "description": "Remove Primary Nav in Genesis"
- },
- "Add Categories and Tags Support to CPT": {
- "prefix": "add_categories_and_tags_support_to_cpt",
- "body": [
- "// Add Categories and Tags support to `${1:portfolio}` CPT.",
- "add_action( 'init', 'sk_add_category_tag_${1:portfolio}' );",
- "function sk_add_category_tag_${1:portfolio}() {",
- " register_taxonomy_for_object_type( 'category', '${1:portfolio}' );",
- " register_taxonomy_for_object_type( 'post_tag', '${1:portfolio}' );",
- "}"
- ],
- "description": "Add Categories and Tags support to CPT in WordPress"
- },
- "Remove Footer Widgets": {
- "prefix": "remove_footer_widgets",
- "body": [
- "// Remove Footer Widgets.",
- "remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' );"
- ],
- "description": "Remove Footer Widgets in Genesis"
- },
- "Add Archive Settings Support for CPT": {
- "prefix": "add_archive_settings_support_for_cpt",
- "body": [
- "// Add Archive Settings option to `${1:portfolio}` CPT.",
- "add_post_type_support( '${1:portfolio}', 'genesis-cpt-archives-settings' );"
- ],
- "description": "Add Archive Settings support for CPT in Genesis"
- },
- "Full Width Page Template": {
- "prefix": "full_width_page_template",
- "body": [
- "<?php",
- "",
- "add_filter( 'genesis_attr_site-inner', 'be_site_inner_attr' );",
- "/**",
- " * Add the attributes from 'entry', since this replaces the main entry.",
- " *",
- " * @author Bill Erickson",
- " * @link http://www.billerickson.net/full-width-landing-pages-in-genesis/",
- " *",
- " * @param array \\$attributes Existing attributes.",
- " * @return array Amended attributes.",
- " */",
- "function be_site_inner_attr( \\$attributes ) {",
- " // Add a class of 'full' for styling this .site-inner differently.",
- " \\$attributes['class'] .= ' full';",
- "",
- " // Add an id of 'genesis-content' for accessible skip links.",
- " \\$attributes['id'] = 'genesis-content';",
- "",
- " // Add the attributes from .entry, since this replaces the main entry.",
- " \\$attributes = wp_parse_args( \\$attributes, genesis_attributes_entry( array() ) );",
- "",
- " return \\$attributes;",
- "}",
- "",
- "// Display header.",
- "get_header();",
- "",
- "// Content.",
- "echo 'Hello World';",
- "",
- "// Display Footer.",
- "get_footer();",
- "",
- "/* Front Page Template for Full Width Sections",
- "-------------------------------------------- */",
- "",
- "/*.site-inner.full {",
- " max-width: none;",
- " padding-top: 0;",
- "}*/"
- ],
- "description": "Full Width Page Template in Genesis"
- },
- "Structural Wraps": {
- "prefix": "structural_wraps",
- "body": [
- "// Remove `$1` from structural wrap.",
- "add_theme_support( 'genesis-structural-wraps', array( 'header', 'menu-primary', 'menu-secondary', 'footer-widgets', 'footer' ) );"
- ],
- "description": "Structural Wraps in Genesis"
- },
- "Search Form Input Text": {
- "prefix": "search_form_input_text",
- "body": [
- "add_filter( 'genesis_search_text', 'custom_search_text' );",
- "/**",
- " * Customize search form input box text.",
- " *",
- " * @param string \\$text Default search input text.",
- " * @return Modified search input text.",
- " */",
- "function custom_search_text( \\$text ) {",
- " return esc_attr( '${1:Search my blog...}' );",
- "}"
- ],
- "description": "Search Form Input Text"
- },
- "Customize Links to Previous and Next Entries on Singular Entries": {
- "prefix": "customize_links_to_previous_and_next_entries_on_singular_entries",
- "body": [
- "add_action( 'genesis_after_entry', 'custom_adjacent_entry_nav' );",
- "/**",
- " * Display links to previous and next entry.",
- " *",
- " * @since 2.3.0",
- " *",
- " * @return void Return early if not singular or post type doesn't support `genesis-adjacent-entry-nav`.",
- " */",
- "function custom_adjacent_entry_nav() {",
- "",
- " if ( ! is_singular() ) {",
- " return;",
- " }",
- "",
- " genesis_markup( array(",
- " 'open' => '<div %s>',",
- " 'context' => 'adjacent-entry-pagination',",
- " ) );",
- "",
- " echo '<div class=\"pagination-previous alignleft\">';",
- " previous_post_link( '%link', '< Previous' );",
- " echo '</div>';",
- "",
- " echo '<div class=\"pagination-next alignright\">';",
- " next_post_link( '%link', 'Next >' );",
- " echo '</div>';",
- "",
- " genesis_markup( array(",
- " 'close' => '</div>',",
- " 'context' => 'adjacent-entry-pagination',",
- " ) );",
- "",
- "}"
- ],
- "description": "Customize Links to Previous and Next Entries on Singular Entries"
- },
- "Unregister Primary Sidebar": {
- "prefix": "unregister_primary_sidebar",
- "body": [
- "// Unregister primary sidebar.",
- "unregister_sidebar( 'sidebar' );"
- ],
- "description": "Unregister Primary Sidebar"
- },
- "Unregister Secondary Sidebar": {
- "prefix": "unregister_secondary_sidebar",
- "body": [
- "// Unregister secondary sidebar.",
- "unregister_sidebar( 'sidebar-alt' );"
- ],
- "description": "Unregister Secondary Sidebar"
- },
- "Add Post Navigation for Single Posts": {
- "prefix": "add_post_navigation_for_single_posts",
- "body": [
- "// Add post navigation.",
- "add_action( 'genesis_after_loop', 'genesis_prev_next_post_nav' );"
- ],
- "description": "Add Post Navigation for Single Posts"
- },
- "Customize Previous Page and Next Page text in Content Archives Post Navigation": {
- "prefix": "customize_previous_page_and_next_page_text_in_content_archives_post_navigation",
- "body": [
- "add_filter ( 'genesis_prev_link_text' , 'sp_previous_page_link' );",
- "/**",
- " * Customize the previous page link.",
- " *",
- " * @param string \\$text Default text for previous page link, \"Previous Page\".",
- " * @return Modified previous page link text.",
- " */",
- "function sp_previous_page_link ( \\$text ) {",
- " return g_ent( '« ' ) . __( '${1:Previous Page}', CHILD_DOMAIN );",
- "}",
- "",
- "add_filter ( 'genesis_next_link_text' , 'sp_next_page_link' );",
- "/**",
- " * Customize the next page link.",
- " *",
- " * @param string \\$text Default text for next page link, \"Next Page\".",
- " * @return Modified next page link text.",
- " */",
- "function sp_next_page_link ( \\$text ) {",
- " return __( '${2:Next Page}', CHILD_DOMAIN ) . g_ent( ' » ' );",
- "}"
- ],
- "description": "Customize Previous Page and Next Page text in Content Archives Post Navigation"
- },
- "Split Entries into Columns": {
- "prefix": "columns",
- "body": [
- "add_filter( 'post_class', 'custom_portfolio_post_class' );",
- "/**",
- " * Display as Columns.",
- " *",
- " * @param string \\$classes Existing post classes.",
- " * @return Modified post classes.",
- " */",
- "function custom_portfolio_post_class( \\$classes ) {",
- " if ( is_main_query() ) { // conditional to ensure that column classes do not apply to Featured widgets",
- " \\$columns = ${1:3}; // Set the number of columns here",
- "",
- " \\$column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );",
- "",
- " \\$classes[] = \\$column_classes[ \\$columns ];",
- "",
- " global \\$wp_query;",
- "",
- " if ( 0 == \\$wp_query->current_post || 0 == \\$wp_query->current_post % \\$columns ) {",
- " \\$classes[] = 'first';",
- " }",
- " }",
- "",
- " return \\$classes;",
- "}"
- ],
- "description": "Split Entries into Columns"
- },
- "Remove Archive Pagination": {
- "prefix": "remove_archive_pagination",
- "body": [
- "// Remove Archive Pagination.",
- "remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' );"
- ],
- "description": "Remove Archive Pagination in Genesis"
- }
- "Remove entry header": {
- "prefix": "remove_entry_header",
- "body": [
- "// Remove entry header.",
- "remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );",
- "remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );",
- "remove_action( 'genesis_entry_header', 'genesis_do_post_title' );",
- "remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );"
- ],
- "description": "Remove Entry Header in Genesis"
- },
- "Remove post info": {
- "prefix": "remove_post_info",
- "body": [
- "// Remove post info.",
- "remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );"
- ],
- "description": "Remove Post Info in Genesis"
- },
- "Remove entry image": {
- "prefix": "remove_entry_image",
- "body": [
- "// Remove entry image (from theme settings).",
- "remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );"
- ],
- "description": "Remove entry image in Genesis"
- },
- "Remove Entry Footer": {
- "prefix": "remove_entry_footer",
- "body": [
- "// Remove entry footer.",
- "remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );",
- "remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );",
- "remove_action( 'genesis_entry_footer', 'genesis_post_meta' );"
- ],
- "description": "Remove Entry Footer in Genesis"
- },
- "Remove Entry Meta": {
- "prefix": "remove_entry_meta",
- "body": [
- "// Remove entry meta.",
- "remove_action( 'genesis_entry_footer', 'genesis_post_meta' );"
- ],
- "description": "Remove Entry Meta in Genesis"
- },
- "Modify Read More Link when using the Content Limit": {
- "prefix": "modify_read_more_link_when_using_the_content_limit",
- "body": [
- "add_filter( 'get_the_content_more_link', 'sp_read_more_link' );",
- "/**",
- " * Modify the Genesis content limit read more link.",
- " *",
- " * @return Modified read more link for the content limit.",
- " */",
- "function sp_read_more_link() {",
- " return '... <a class=\"more-link\" href=\"' . get_permalink() . '\">${1:[Continue Reading]}</a>';",
- "}"
- ],
- "description": "Modify Read More Link when using the Content Limit"
- }
- "Reposition Footer Widgets": {
- "prefix": "reposition_footer_widgets",
- "body": [
- "// Reposition footer widgets.",
- "remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' );",
- "add_action( 'genesis_after', 'genesis_footer_widget_areas' );"
- ],
- "description": "Reposition Footer Widgets"
- },
- "Reposition Footer": {
- "prefix": "reposition_footer",
- "body": [
- "// Reposition footer.",
- "remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );",
- "remove_action( 'genesis_footer', 'genesis_do_footer' );",
- "remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 );",
- "add_action( 'genesis_after', 'genesis_footer_markup_open', 11 );",
- "add_action( 'genesis_after', 'genesis_do_footer', 12 );",
- "add_action( 'genesis_after', 'genesis_footer_markup_close', 13 );"
- ],
- "description": "Reposition Footer"
- },
- "Template Redirect": {
- "prefix": "template_redirect",
- "body": [
- "add_filter( 'template_include', 'custom_template_redirect' );",
- "/**",
- " * Use ${1:archive-portfolio}.php for ${2:portfolio category and tag taxonomy archives}.",
- " *",
- " * @param string \\$template The path of the template to include.",
- " * @return The filtered path of the template to include.",
- " */",
- "function custom_template_redirect( \\$template ) {",
- " if ( ${3:is_tax( 'portfolio_category' ) || is_tax( 'portfolio_tag' )} ) {",
- " \\$template = get_query_template( '${1:archive-portfolio}' );",
- " }",
- "",
- " return \\$template;",
- "}"
- ],
- "description": "Template Redirect in WordPress"
- },
- "Customize the WordPress Query": {
- "prefix": "pre_get_posts",
- "body": [
- "add_action( 'pre_get_posts', '${1:be_exclude_category_from_blog}' );",
- "/**",
- " * ${2:Exclude Category from Blog}.",
- " *",
- " * @author Bill Erickson",
- " * @link http://www.billerickson.net/customize-the-wordpress-query/",
- " * @param object \\$query data.",
- " */",
- "function ${1:be_exclude_category_from_blog}( \\$query ) {",
- " if ( \\$query->is_main_query() && ${3:\\$query->is_home()} ) {",
- " \\$query->${4:set( 'cat', '-4' )};",
- " }",
- "}"
- ],
- "description": "Customize the WordPress Query"
- },
- "Enqueue Font Awesome": {
- "prefix": "font_awesome",
- "body": [
- "wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css' );",
- ],
- "description": "Enqueue Font Awesome"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement