Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
Last active July 11, 2016 21:21
Show Gist options
  • Save jazzsequence/00fea4700d46317e888f to your computer and use it in GitHub Desktop.
Save jazzsequence/00fea4700d46317e888f to your computer and use it in GitHub Desktop.
Sublime Text snippets
<snippet>
<content><![CDATA[
->add_field( array(
'name' => __( '${1:Field Name}', '${2:textdomain}' ),
'id' => \$prefix . '${3:field_id}',
'type' => '${4:cmb2_field_type}',
'desc' => __( '${5:Description of the field.}', '${2:textdomain}' ),
${6:'options' =>} ${7:${8:array of options or callback function},}
${9:'attributes' =>} ${10:${11:array of attributes},}
${12:'default' =>} ${13:'${14:default_value}',}
)${15: }
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>->add_field(</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
<snippet>
<content><![CDATA[
\$${1:group_field_id} = \$${2:cmb}->add_field( array(
'id' => \$prefix . '${3:group_id}',
'type' => 'group',
${4:'description' => __( '${5:group description}', '${6:textdomain}' ),}
${7:'repeatable' => false, // Use false if you want a non-repeatable group}
'options' => array(
'group_title' => __( '${8:Entry }{#}', '${6:textdomain}' ),
'add_button' => __( '${9:Add another entry}', '${6:textdomain}' ),
'remove_button' => __( '${10:Remove entry}', '${6:textdomain}' ),
${11:'sortable' => true,}
${12:'closed' => true, // Close the groups by default.}
),
) );
]]></content>
<tabTrigger>cmb2_add_group</tabTrigger>
<scope>source.php</scope>
</snippet>
<snippet>
<content><![CDATA[
\$${1:cmb}->add_group_field( \$${2:group_field_id}, array(
'name' => __( '${3:Field Name}', '${4:textdomain}' ),
${5:'description' => __( '${6:Write a short description of this field}', '${4:textdomain}' ),}
'id' => '${7:field_id}',
'type' => '${8:field type}',
) );
]]></content>
<tabTrigger>add_group_field</tabTrigger>
<scope>source.php</scope>
</snippet>
<snippet>
<content><![CDATA[
\$prefix = '${1:_clientname_feature_}';
\$${2:cmb} = new_cmb2_box( array(
'id' => \$prefix . 'metabox',
'title' => __( '${3:Metabox Title}', '${4:textdomain}' ),
'object_types' => array( '${5:array_of_post_types}' ),
) );
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>new_cmb2_box</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
<snippet>
<content><![CDATA[
register_via_cpt_core( array(
__( '${1:Singular Name}', '${2:textdomain}' ), // Singular.
__( '${3:${1:Plural}s}', '${2:textdomain}' ), // Plural.
'${4:taxonomy_name}', // Registered name.
),
array(
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ),
'menu_icon' => 'dashicons-palmtree',
),
);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>register_via_cpt_core</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
<snippet>
<content><![CDATA[
p2p_register_connection_type( array(
'name' => '${1:post_type}s_to_${2:other_post_type}s',
'from' => '${1:post_type}',
'to' => '${2:other_post_type}',
'admin_box' => ${3:array( // Array of values or false.
'show' => '${4:any}', // 'any', 'from', 'to' or false.
'context' => '${5:side}', // 'side' or 'advanced'.
),}
${6:'title' => array(
'from' => __( '${7:Title on the From post type}', '${8:textdomain}' ),
'to' => __( '${9:Title on the To post type}', '${8:textdomain}' ),
),}
${10:'from_labels' => array(
'singular_name' => __( '${11:Singular ${1: } name}', '${8:textdomain}' ),
'search_items' => __( '${12:Search ${1: }s}', '${8:textdomain}' ),
'not_found' => __( '${13:No ${1: }s found.}', '${8:textdomain}' ),
'create' => __( '${14:Create ${1: } connection}', '${8:textdomain}' ),
),}
${15:'to_labels' => array(
'singular_name' => __( '${16:Singular ${2: } name}', '${8:textdomain}' ),
'search_items' => __( '${17:Search ${2: }s}', '${8:textdomain}' ),
'not_found' => __( '${18:No ${2: }s found.}', '${8:textdomain}' ),
'create' => __( '${19:Create ${2: } connection}', '${8:textdomain}' ),
),}
) );
]]></content>
<tabTrigger>p2p_register_connection_type</tabTrigger>
<scope>source.php</scope>
</snippet>
<snippet>
<content><![CDATA[
register_via_taxonomy_core( array(
__( '${1:Singular Name}', '${2:textdomain}' ), // Singular.
__( '${3:${1:Plural}s}', '${2:textdomain}' ), // Plural.
'${4:taxonomy_name}', // Registered name.
),
${5:array()}, // Array of taxonomy arguments.
array( ${6:array of post types} ), // Array of post types.
);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>register_via_taxonomy_core</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment