dwieyoko
8/15/2017 - 7:26 AM

This is Born Digital Snippets

This is Born Digital Snippets

	'.text.html.basic':
		'Default article list snippet':
			'prefix': 'bd_article_snippet'
			'body': '''
			<article>
				<div class="thumbnail">
					<a href="{permalink}" title="{title}">
						<img src="{image Source}" alt="{Alt text}">
					</a>
				</div>

				<div class="detail">
					<h3 class="post-title"><a href="{permalink}" title="{title}">{title}</a></h3>
					<div class="entrymeta">
						{entry meta}
					</div>

					<div class="entrycontent">
						<p>{excerpt goes here}</p>
					</div>
				</div>
			</article>
			'''

		'HTML 5':
			'prefix': 'bd_html'
			'body': '''
			<!DOCTYPE html>
			<html>
			<head>
			<meta charset="utf-8">
			<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
			<title>Born Digital Title</title>
			</head>
			<body>

			</body>
			</html>
			'''

		'Add a Favicon':
			'prefix': 'bd_favicon'
			'body': '<link href="/YOUR_PATH/favicon.ico" rel="icon" type="image/x-icon" />'

		'Create a Quick Form':
			'prefix': 'bd_form'
			'body': '''
			<form method="post" action="">
			<div>
				<h4>Text Field</h4>
				<label for="name">Name: <span class="required">*</span>
				</label>
				<input type="text" id="name" name="name" value="" placeholder="Your name" required="required" autofocus="autofocus" />
			</div>
			<div>
				<h4>Email Field</h4>
				<label for="email">Email Address: <span class="required">*</span>
				</label>
				<input type="email" id="email" name="email" value="" placeholder="your@email.com" required="required" />
			</div>
			<div>
				<h4>Password Field</h4>
				<label for="password">New Password: <span class="required">*</span>
				</label>
				<input type="password" id="password" name="password" value="" placeholder="" required="required" />
			</div>
			<div>
				<h4>Drop Down Menu</h4>
				<label for="subject">Subject:</label>
				<select id="subject" name="subject">
					<option value="hello">Subject 1</option>
					<option value="quote">Subject 2</option>
					<option value="general">Subject 3</option>
					</select>
			</div>
			<div>
				<h4>Text Area</h4>
				<label for="message">Message: <span class="required">*</span>
				</label>
				<textarea id="message" name="message" placeholder="Write your message here." required="required"></textarea>
			</div>
			<div>
				<h4>Radio Buttons</h4>
				<label for="radio-choice-1">Choice 1</label>
				<input type="radio" name="radio-choice" id="radio-choice-1" tabindex="2" value="choice-1">
				<label for="radio-choice-2">Choice 2</label>
				<input type="radio" name="radio-choice" id="radio-choice-2" tabindex="3" value="choice-2">
			</div>
			<div>
				<h4>Check Boxes</h4>
				<label for="checkbox">Choice 1:</label>
				<input type="checkbox" name="checkbox1">
				<label for="checkbox">Choice 2:</label>
				<input type="checkbox" name="checkbox2">
			</div>
			<div>
				<input type="submit" value="Submit" id="submit" />
			</div>
			</form>
			'''

		'Add Lorem Ipsum Dummy Text':
			'prefix': 'bd_loremipsum'
			'body': '''
			Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus
			'''

		'Meta Tags for General purpose':
			'prefix': 'bd_meta_tags'
			'body': '''
			<meta http-equiv="default-style"/>
			<meta http-equiv="refresh"/>
			<meta http-equiv="Cache-Control"/>
			<meta http-equiv="Content-Disposition"/>
			<meta http-equiv="Content-Type"/>
			<meta http-equiv="Expires"/>
			<meta http-equiv="X-UA-Compatible"/>
			<meta name="application-name"/>
			<meta name="author"/>
			<meta name="classification"/>
			<meta name="copyright"/>
			<meta name="formatter"/>
			<meta name="generator"/>
			<meta name="rating"/>
			'''

		'Meta Tags for Mobile / Hand held Devices':
			'prefix': 'bd_meta_tags_handheld'
			'body': '''
			<link rel="apple-touch-icon/>
			<meta name="format-detection"/>
			<meta name="HandheldFriendly"/>
			<meta name="viewport"/>
			'''

		'Meta Tags for SEO':
			'prefix': 'bd_meta_tags_seo'
			'body': '''
			<meta name="description"/>
			<meta name="google"/>
			<meta name="googlebot"/>
			<meta name="keywords"/>
			<meta name="robots"/>
			<meta name="verify"/>
			'''

		'Create a Quick Table':
			'prefix': 'bd_table'
			'body': '''
			<table>
				<thead>
					<tr>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td></td>
						<td></td>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
						<td></td>
						<td></td>
					</tr>
				</tbody>
			</table>
			'''

	'.source.css':
		'Default CSS style description':
			'prefix': 'bd_style_css_description'
			'body': '''
			/*
			Theme Name: {Name}
			Theme URI: {URL}
			Description: {Description}
			Author: BornDigital
			Author URI: {URL}
			Version: 1.0.0
			Client: {Client}
			*/
			'''

		'BD CSS Body':
			'prefix': 'bd_css_body'
			'body': '''
			body {
			font-family: sans-serif;
			font-size: 12px;
			font-weight: normal;
			padding: 10px;
			margin: 10px auto;
			}
			'''

	'.source.js':
		'Changes every letter in a given string to lowercase':
			'prefix': 'bd_string_lowercase'
			'body': '''
				function stringToLowercase(inputString)
				{
					return inputString.toLowerCase();
				}
				'''

		'Determines whether a given string is an integer':
			'prefix': 'bd_string_is_number_int'
			'body': '''
				function isNumberInt(inputString)
				{
					return (!isNaN(parseInt(inputString))) ? true : false;
				}
				'''

		'Determines whether a given string is a floating-point number':
			'prefix': 'bd_string_is_number_float'
			'body': '''
				function isNumberFloat(inputString)
				{
					return (!isNaN(parseFloat(inputString))) ? true : false;
				}
				'''

		'Determines whether a given string is or is not a number':
			'prefix': 'bd_string_is_not_a_number'
			'body': '''
				function isNotaNumber(inputString)
				{
					return isNaN(inputString);
				}
				'''

		'Performs URL unencoding on a given string, converting numeric codes into spaces and other special characters':
			'prefix': 'bd_string_html_unencode_string'
			'body': '''
				function htmlUnencodeString (inputString)
				{
					return unescape(inputString);
				}
				'''

		'Performs URL encoding on a given string, converting spaces and other special characters into numeric codes':
			'prefix': 'bd_string_html_encode_string'
			'body': '''
				function htmlEncodeString (inputString)
				{
					return escape(inputString);
				}
				'''

		'Counts the number of words in a given string':
			'prefix': 'bd_string_count_words'
			'body': '''
				function countWords(inputString)
				{
					return inputString.split(' ').length;
				}
				'''

		'Searches in a given string for the first occurrence of another string':
			'prefix': 'bd_string_check_characters'
			'body': '''
				function checkForCharacters(inputString, checkString, startingIndex)
				{
					if (!startingIndex) startingIndex = 0;
					return inputString.indexOf(checkString);
				}
				'''

		'Capitalizes the first letter of each word in a given string':
			'prefix': 'bd_string_capitalize_words'
			'body': '''
				function capitalizeWords(string)
				{
					var tmpStr, tmpChar, preString, postString, strlen;
					tmpStr = string.toLowerCase();
					stringLen = tmpStr.length;
					if (stringLen > 0)
					{
						for (i = 0; i < stringLen; i++)
						{
							if (i == 0)
							{
								tmpChar = tmpStr.substring(0,1).toUpperCase();
								postString = tmpStr.substring(1,stringLen);
								tmpStr = tmpChar + postString;
							}
							else
							{
								tmpChar = tmpStr.substring(i,i+1);
								if (tmpChar == " " && i < (stringLen-1))
								{
									tmpChar = tmpStr.substring(i+1,i+2).toUpperCase();
									preString = tmpStr.substring(0,i+1);
									postString = tmpStr.substring(i+2,stringLen);
									tmpStr = preString + tmpChar + postString;
								}
							}
						}
					}
					return tmpStr;
				}
				'''

		'Capitalizes every letter in a given string':
			'prefix': 'bd_string_capitalize_all'
			'body': '''
			function stringToUppercase(inputString)
			{
				return inputString.toUpperCase();
			}
			'''

		'jQuery anonymous function':
			'prefix': 'bd_jquery_anonymous_function'
			'body': '''
			(function($){
			})(jQuery);
			'''

		'jQuery ready snippet':
			'prefix': 'bd_jquery_ready'
			'body': '''
			jQuery(document).ready(function($){
			});
			'''

		'jQuery loadmore trigger':
			'prefix': 'bd_jquery_loadmore_trigger'
			'body': '''
			$(window).scroll(function(){
				var wScroll = $(this).scrollTop();
					if(wScroll > $('.content-loadmore button.load-more').offset().top - ($(window).height()/ 0.8)) {
						//call ajax in here
					}
			});
			'''

		'jQuery ajax upload file':
			'prefix': 'bd_jquery_ajax_upload_file'
			'body': '''
			var form_data = new FormData();
			form_data.append('file', $('input[name="fileinput"]')[0].files[0]);
			$.ajax({
				type: 'POST',
				url: ajaxurl,
				dataType: 'json',
				data: form_data,
				processData: false,
				contentType: false,
			}).done(function(response) {
			}).fail(function() {
			}).always(function() {
			});
			'''

		'jQuery ajax snippet':
			'prefix': 'bd_jquery_ajax'
			'body': '''
			$.ajax({
				url: ajaxurl,
				type: 'post',
				data: data,
				dataType: 'json',
			}).done(function(response) {
			}).fail(function() {
			}).always(function() {
			});
			'''

		'Scroll down function':
			'prefix': 'bd_scroll_function'
			'body': '''
			var scrollDistance = somethingGoesHere; // You can remove this part if you are using a pre-determined pixel.
			$(window).scroll(function() {
				if ($(this).scrollTop() > scrollDistance){
					// What happened when it scrolls down
				}
				else{
					// Scrolled up to the top
				}
			});
			'''

		'Scroll to top function':
			'prefix': 'bd_scroll_to_top'
			'body': '''
			$("elementidorclass").click(function(e) {
				$("html, body").animate({
				scrollTop: 0
				}, 600);
				e.preventDefault()
			});
			'''

		'Refresh js function on resize and first load':
			'prefix': 'bd_refresh_function'
			'body': '''
			function continousRefresh() {
				// Stuff goes here
			}

			$(window).on('load', continousRefresh);
			$(window).on('resize', continousRefresh);
			'''

		'Play youtube video button':
			'prefix': 'bd_play_youtube_video'
			'body': '''
			$('videoParentelement').each(function() {
			var theVideo = $(this).children('iframe')

			$('playbuttonelement').on('click', function(ev) {
				theVideo[0].src += "&autoplay=1";
				ev.preventDefault();
				$(this).hide();
			})

			// Please make sure you turn of the autoplay of your video
			});
			'''

		'jQuery click function snippet':
			'prefix': 'bd_jquery_click_function'
			'body': '''
			$(document).on('click', "elementidorclass", function() {

			}
			'''

		'jQuery change function snippet':
			'prefix': 'bd_jquery_change_function'
			'body': '''
			$(document).on('change', "elementidorclass", function() {

			}
			'''

		'jQuery function snippet':
			'prefix': 'bd_jquery_function'
			'body': '''
			function functionName() {

			}
			'''

		'jQuery DOM ready snippet':
			'prefix': 'bd_dom_ready_function'
			'body': '''
			$(document).ready(function() {

			}
			'''

		'Display an Alert dialog':
			'prefix': 'bd_dialog_alert'
			'body': 'alert(messageStr);'

		'Display a Confirm dialog':
			'prefix': 'bd_dialog_confirm'
			'body': 'confirm(messageStr);'

		'Display a Message Box dialog':
			'prefix': 'bd_dialog_messagebox'
			'body': '''
			// Example:
			// value1 = 3; value2 = 4;
			// messageBox("text message %s and %s", value1, value2);
			// this message box will display the text "text message 3 and 4"
			function messageBox()
			{
				var i, msg = "", argNum = 0, startPos;
				var args = messageBox.arguments;
				var numArgs = args.length;
				if(numArgs)
				{
					theStr = args[argNum++];
					startPos = 0;  endPos = theStr.indexOf("%s",startPos);
					if(endPos == -1) endPos = theStr.length;
					while(startPos < theStr.length)
					{
						msg += theStr.substring(startPos,endPos);
						if (argNum < numArgs) msg += args[argNum++];
						startPos = endPos+2;  endPos = theStr.indexOf("%s",startPos);
						if (endPos == -1) endPos = theStr.length;
					}
					if (!msg) msg = args[0];
				}
				alert(msg);
			}
			'''

		'Display a Prompt dialog':
			'prefix': 'bd_dialog_prompt'
			'body': 'prompt(messageStr, inputFieldDefaultText);'

		'BD auto testing':
			'prefix': 'bd_auto_test'
			'body': '''
			import { Selector } from 'testcafe';
			fixture 'Sprint 1 Test'
			.page 'www.example.com';
			test('Homepage', async t => {
			await t
			// type your code here
			// example
			.typeText('#user_login', 'orangevalley')
			.typeText('#user_pass','0IjpXK)VjvTsK!ARasdf')
			.click('#wp-submit')
			.expect(Selector('.forgetmenot').innerText).eql(' Onthoud mij');
			});
			'''

	'.text.html.php':
		'Display an Alert dialog':
			'prefix': 'bd_dialog_alert'
			'body': '''
			echo 'alert(messageStr)';
			'''

		'Debug List active CRON':
			'prefix': 'bd_debug_cron_list'
			'body': '''
			  $crons = get_option( 'cron' );
			  echo '<pre>';
			  print_r($crons);
			  echo '</pre>';
			'''

		'Borndigital Wordpress text domain':
		    'prefix': 'bd__'
		    'body': '__( \\\'${1:your_text}\\\', \\\'${2:your_domain}\\\' )'

		'Register Wordpress Taxonomy':
			'prefix': 'bd_register_taxonomy'
			'body': '''
				//move this hook to your constract
				add_action('init', [$this, 'register_new_taxonomy)']);
			    public function register_new_taxonomy()
			    {
					// Add new taxonomy, make it hierarchical (like categories)
					$labels = array(
						'name'              => _x( 'Genres', 'taxonomy general name', 'textdomain' ),
						'singular_name'     => _x( 'Genre', 'taxonomy singular name', 'textdomain' ),
						'search_items'      => __( 'Search Genres', 'textdomain' ),
						'all_items'         => __( 'All Genres', 'textdomain' ),
						'parent_item'       => __( 'Parent Genre', 'textdomain' ),
						'parent_item_colon' => __( 'Parent Genre:', 'textdomain' ),
						'edit_item'         => __( 'Edit Genre', 'textdomain' ),
						'update_item'       => __( 'Update Genre', 'textdomain' ),
						'add_new_item'      => __( 'Add New Genre', 'textdomain' ),
						'new_item_name'     => __( 'New Genre Name', 'textdomain' ),
						'menu_name'         => __( 'Genre', 'textdomain' ),
					);
					$args = array(
						'hierarchical'      => true,
						'labels'            => $labels,
						'show_ui'           => true,
						'show_admin_column' => true,
						'query_var'         => true,
						'rewrite'           => array( 'slug' => 'genre' ),
					);
					register_taxonomy( 'genre', array( 'book' ), $args );
			    }
			'''

		'Register Wordpress Post Type':
			'prefix': 'bd_register_post_type'
			'body': '''
				//move this hook to your constract
				add_action('init', [$this, 'register_new_post_type)']);
			    public function register_new_post_type()
			    {
		        $args = [
		            'labels'      => [
		                'name'          => __( 'Example', 'your_text_domain' ),
		                'singular_name' => __( 'Example Singular', 'your_text_domain' ),
		                'add_new_item'  => __( 'Add New Example', 'your_text_domain' )
		            ],
		            'has_archive' => false,
		            'public'      => true,
		            'supports'    => ['title','editor','author','thumbnail','excerpt','comments','post-formats'],
		            'menu_icon'   => 'dashicons-groups'
		        ];
		        register_post_type( 'post_type_name', $args );
			    }
			'''

		'Borndigital Get Users':
			'prefix': 'bd_get_users'
			'body': '''
				$users = get_users([
					'role'         => '',
					'role__in'     => array(),
					'role__not_in' => array(),
					'meta_key'     => '',
					'meta_value'   => '',
					'meta_compare' => '',
					'meta_query'   => array(),
					'date_query'   => array(),
					'include'      => array(),
					'exclude'      => array(),
					'orderby'      => 'login',
					'order'        => 'ASC',
					'offset'       => '',
					'search'       => '',
					'number'       => '',
					'count_total'  => false,
					'fields'       => 'all',
				]);
			'''

		'Borndigital Get Posts':
			'prefix': 'bd_get_posts'
			'body': '''
				$posts = get_posts([
					'posts_per_page'   => 5,
					'offset'           => 0,
					'category'         => '',
					'category_name'    => '',
					'orderby'          => 'date',
					'order'            => 'DESC',
					'include'          => '',
					'exclude'          => '',
					'meta_key'         => '',
					'meta_value'       => '',
					'post_type'        => 'post',
					'post_mime_type'   => '',
					'post_parent'      => '',
					'author'	 	   => '',
					'author_name'	   => '',
					'post_status'      => 'publish',
					'suppress_filters' => true
				]);
			'''

		'Print all registerd scripts':
			'prefix': 'bd_debug_script_list'
			'body': '''
				global $wp_scripts, $wp_styles;
				echo '<pre>';
				print_r($wp_scripts);
				echo '</pre>';
				die();
			'''

		'Remove unused scripts from wordpress head':
			'prefix': 'bd_cleanup_wp_head'
			'body': '''
			//move this hook to your constract
			add_action('init', [$this, 'cleanup_wp_head']);
			public function cleanup_wp_head()
			{
			    // REMOVE EMOJI ICONS
			    remove_action('wp_head', 'print_emoji_detection_script', 7);
			    remove_action('wp_print_styles', 'print_emoji_styles');
			    // EditURI link
			    remove_action( 'wp_head', 'rsd_link' );
			    // Category feed links
			    remove_action( 'wp_head', 'feed_links_extra', 3 );
			    // Post and comment feed links
			    remove_action( 'wp_head', 'feed_links', 2 );
			    // Windows Live Writer
			    remove_action( 'wp_head', 'wlwmanifest_link' );
			    // Index link
			    remove_action( 'wp_head', 'index_rel_link' );
			    // Previous link
			    remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
			    // Start link
			    remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
			    // Canonical
			    remove_action('wp_head', 'rel_canonical', 10, 0 );
			    // Shortlink
			    remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
			    // Links for adjacent posts
			    remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
			    // WP version
			    remove_action( 'wp_head', 'wp_generator' );
			    // Wp Oembed
			    remove_action( 'wp_head', 'wp_oembed_add_discovery_links');
			    //REST API
			    remove_action( 'wp_head', 'rest_output_link_wp_head');
			}
			'''

		'Register ACF Options sub page':
			'prefix': 'bd_acf_sub_options_page'
			'body': '''
			if( function_exists('acf_add_options_sub_page') )
			{
			    acf_add_options_sub_page([
			        'page_title'    => __( 'Your Settings', 'your_text_domain' ),
			        'menu_slug'     => 'slug-name',
			        'parent_slug'   => 'options-general.php',
			        'capability'    => 'manage_options'
			    ]);
			}
			'''

		'Borndigital Javascript Template':
			'prefix': 'db_new_js'
			'body': '''
				var Example = (function ($) {
				  var $elms        = {};
				  var events       = {};
				  var states       = {};
				  var loading      = {};
				  var ajax         = {};
				  function setup() {
				    _registerElements();
						_registerStates();
				    _registerEvents();
				  }
				  function _registerStates() {
				      states.isRequesting = false;
				  }
				  loading.start = function(e) {
				      states.isRequesting = true;
				  }
				  loading.stop = function(e) {
				      states.isRequesting = false;
				  }
				  function _registerElements() {
						//$elms.example = $('#example');
				  }
				  function _registerEvents() {
						//$elms.example.on('click', events.example);
				  }
				  events.example = function(e) {
				  }
				  ajax.example = function () {
				    if (states.isRequesting) return;
				    loading.start();
				    var data = {
				      action : your_action,
				      nonce  : your_nonce,
				    };
				    $.ajax({
				      url     : your_url,
				      type    : 'post',
				      dataType: 'json',
				      data    : data
				    }).done(function (response) {
					      loading.stop();
					      if (response.status === 'success') {
					         //when success
					      }
				    }).fail(function (jqXHR, textStatus) {
				      console.log(textStatus);
				      loading.stop();
				    });
				  };
				  return {
				    setup: setup
				  };
				})(jQuery);
				Example.setup();
			'''

		'add_filter using function':
			'prefix': 'bd_add_filter_function'
			'body': 'add_filter(\'${1:filter_hook}\', \'${2:function_name}\');'

		'add_filter using class':
			'prefix': 'bd_add_filter_class'
			'body': 'add_filter(\'${1:filter_hook}\', [$this, \'${2:method_name}\']);'

		'add_action using function':
			'prefix': 'bd_add_action_function'
			'body': 'add_action(\'${1:action_hook}\', \'${2:function_name}\');'

		'add_action using class':
			'prefix': 'bd_add_action_class'
			'body': 'add_action(\'${1:action_hook}\', [$this, \'${2:method_name}\']);'

		'INTERNAL_PLUGIN_DIR constant':
			'prefix': 'INTERNAL_PLUGIN_DIR'
			'body': 'INTERNAL_PLUGIN_DIR'

		'INTERNAL_PLUGIN_URL constant':
			'prefix': 'INTERNAL_PLUGIN_URL'
			'body': 'INTERNAL_PLUGIN_URL'

		'Create theme\'s class then init':
			'prefix': 'bd_class_theme_then_init'
			'body': '''
			namespace Theme\\\\\${1:Setting};
			defined(\'ABSPATH\') or die(\'Can\\\\\'t access directly\');

			class ${2:Class_Name}
			{
				private $_dir;
				private $_url;

				function __construct()
				{
					$this->_dir = ${3:''};
					$this->_url = ${4:''};
				}
			}

			new ${5:ClassName}();
			'''

		'Create theme\'s class':
			'prefix': 'bd_class_theme'
			'body': '''
			namespace Theme\\\\\${1:Setting};
			defined(\'ABSPATH\') or die(\'Can\\\\\'t access directly\');

			class ${2:Class_Name}
			{
				private $_dir;
				private $_url;

				function __construct()
				{
					$this->_dir = ${3:''};
					$this->_url = ${4:''};
				}
			}
			'''

		'Create component\'s class then init it':
			'prefix': 'bd_class_component_then_init'
			'body': '''
			namespace Plugin\\\\\${1:Component};
			defined(\'ABSPATH\') or die(\'Can\\\\\'t access directly\');

			class ${2:Class_Name}
			{
				private $_dir;
				private $_url;
				function __construct()
				{
					$this->_dir = ${3:''};
					$this->_url = ${4:''};
				}
			}
			new ${5:ClassName}();
			'''

		'Create component\'s class':
			'prefix': 'bd_class_component'
			'body': '''
			namespace Plugin\\\\\${1:Component};
			defined(\'ABSPATH\') or die(\'Can\\\\\'t access directly\');

			class ${2:Class_Name}
			{
				private $_dir;
				private $_url;

				function __construct()
				{
					$this->_dir = ${3:''};
					$this->_url = ${4:''};
				}
			}
			'''

		'Create namespace for theme\'s setting':
			'prefix': 'bd_namespace_theme'
			'body': 'namespace Theme\\\\\${1:Setting};'

		'Create namespace for plugin\'s component':
			'prefix': 'bd_namespace_component'
			'body': 'namespace Plugin\\\\\${1:Component};'

		'No direct .php file access':
			'prefix': 'bd_no_direct_access'
			'body': 'defined(\'ABSPATH\') or die(\'Can\\\\\'t access directly\');'

		'Prevent direct .php file access':
			'prefix': 'bd_prevent_direct_access'
			'body': 'defined(\'ABSPATH\') or die(\'Can\\\\\'t access directly\');'

		'BD Get Post Meta':
			'prefix': 'bd_get_post_meta'
			'body': '''
			get_post_meta( int $post_id, string $key = '', bool $single = false );
			'''

		'BD PHP foreach tag':
			'prefix': 'bd_php_foreach'
			'body': '''
			foreach ($arr as $key => $value) {
			// your custom code
			// custom code
			}'''

		'BD WP Customizer Adding a New Setting':
			'prefix': 'bd_wp_customizer_add_setting'
			'body': '''
			$wp_customize->add_setting('your_setting_name' , array(
			'default'   => '#000000',
			'transport' => 'refresh',
			));'''

		'BD WP Customizer Adding a New Section':
			'prefix': 'bd_wp_customizer_add_section'
			'body': '''
			$wp_customize->add_section( 'your_section_name' , array(
				'title'      => __( 'Your Section Name', 'mytheme' ),
				'priority'   => 30
			));'''

		'BD WP Customizer Adding a New Color Control':
			'prefix': 'bd_wp_customizer_add_color_control'
			'body': '''
			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
				'label'      => __( 'Header Color', 'mytheme' ),
				'section'    => 'your_section_id',
				'settings'   => 'your_setting_id',
			)));'''

		'BD WP Adding a New Role':
			'prefix': 'bd_wp_add_role'
			'body': '''
			function bd_wp_add_role() {
			add_role( 'manager', 'Manager',
			array(
				'read',
				'edit_posts',
				'delete_posts',
			));
			}
			add_action('init', 'bd_wp_add_role');
			'''

		'BD WP Remove Role':
			'prefix': 'bd_wp_remove_role'
			'body': '''
			function bd_wp_remove_role() {
				remove_role('editor');
				remove_role('author');
				remove_role('contributor');
				remove_role('subscriber');
			}
			add_action('init', 'bd_wp_remove_role');
			'''

		'BD autoload':
			'prefix': 'bd_autoload'
			'body': '''
			defined('ABSPATH') or die('Can\\\\'t access directly');
			require 'Setup.php';
			'''

		'BD debug':
			'prefix': 'bd_dbg'
			'body': '''
			echo "<pre>";
			print_r($data);
			echo "</pre>";
			'''

		'BD enqueue css':
		    'prefix': 'bd_enqueue_css'
		    'body': '''
  			namespace Theme\\\\Queue;
  			defined('ABSPATH') or die('Can\\\\'t access file directly');
  			defined('ABSPATH') or die('Can\\\\'t access directly');
  			class CSS
  			{
  				public function __construct()
  				{
  				  add_action('wp', [$this, 'check']);
  				}

  				public function check()
  				{
  				  add_action('wp_enqueue_scripts', [$this, 'enqueueGeneralStyles']);
  				  // if( is_front_page() ) add_action('wp_enqueue_scripts', [$this, 'enqueuHomeScripts']);
  				}

  				public function enqueueGeneralStyles() {
  					$css = \\\\xpress::css();
  					//this are just for example enqueue style
  					$css
  					->register('style')
  					->setUrl(THEME_URL . '/style.css')
  					->setVersion('1.0.5')
  					->enqueue();
  					$css
  					->register('responsive')
  					->setUrl(THEME_URL . '/assets/css/responsive.css')
  					->setVersion('1.0.3')
  					->enqueue();
  				}

  				public function enqueuHomeScripts()
  				{
  				  $css = \\\\xpress::css();
  				}
  			}
  			use Theme\\\\Queue\\\\CSS;
  			new CSS();
			'''

		'BD wordpress remove admin bar':
			'prefix': 'bd_remove_adm_bar'
			'body': '''
				function remove_admin_bar()
				{
					if (!current_user_can('administrator') && !is_admin()) {
						show_admin_bar(false);
					}
				}

				//move this hook to your constract
				add_action('after_setup_theme', [$this, 'remove_admin_bar']);
			'''

		'BD setup function':
			'prefix': 'bd_setup'
			'body': '''
				namespace Plugin\\\\Access;
				defined('ABSPATH') or die('Can\\\\'t access directly');

				class Setup
				{
					private $_url;
					private $_dir;

					public function __construct()
					{
						// your hook example
						add_filter('wp_nav_menu_items', [$this, 'addItem'], 100, 2);
					}

					public function addItem($items, $args)
					{
					// your function
					}
				}
				new Setup();
			'''

		'BD ACF Get Field':
    	'prefix': 'bd_acf_get_field'
    	'body': '''
        // Get a value from the current post
        $value = get_field("text_field");

        // Get a value from a specific post
        $value = get_field("text_field", 123);

        // Check if value exists
        $value = get_field("text_field");

            if($value) {
                echo $value;
            } else {
                echo 'empty';
            }

        // Get a value from different objects
        $post_id = false; // current post
        $post_id = 1; // post ID = 1
        $post_id = "user_2"; // user ID = 2
        $post_id = "category_3"; // category term ID = 3
        $post_id = "event_4"; // event (custom taxonomy) term ID = 4
        $post_id = "option"; // options page
        $post_id = "options"; // same as above

        $value = get_field( 'my_field', $post_id );
        '''

    'BD ACF The Field':
        'prefix': 'bd_acf_the_field'
        'body': '''
        // Display a value from the current post
        <h2><?php the_field('text_field'); ?></h2>

        // Display a value from a specific post
        <h2><?php the_field('text_field', 123); ?></h2>

        // Check if value exists
            <?php if( get_field('text_field') ): ?>

                <h2><?php the_field('text_field'); ?></h2>

            <?php endif; ?>

        // Display a value from other places
        $post_id = null; // current post
        $post_id = 1; // post 1
        $post_id = "option"; // options page
        $post_id = "options"; // same as above
        $post_id = "category_2"; // target a specific category
        $post_id = "event_3"; // target a specific taxonomy (this tax is called "event")
        $post_id = "user_1"; // target a specific user (user id = 1)

        the_field( "text_field", $post_id );
        '''

    'BD ACF Get Field Object':
        'prefix': 'bd_acf_get_field_object'
        'body': '''
        // Usage
        <?php
        // Get a field object and display it with it's value
        $field_name = "text_field";
        $field      = get_field_object($field_name);

        echo $field['label'] . ': ' . $field['value'];

        // Get a field object and display it with it's value (using the field key and the value fron another post)
        $field_key = "field_5039a99716d1d";
        $post_id   = 123;
        $field     = get_field_object($field_key, $post_id);

        echo $field['label'] . ': ' . $field['value'];

        // Get a field object and create a select form element
        $field_key = "field_5039a99716d1d";
        $field     = get_field_object($field_key);

        if( $field )
        {
            echo '<select name="' . $field['key'] . '">';
                foreach( $field['choices'] as $k => $v )
                {
                    echo '<option value="' . $k . '">' . $v . '</option>';
                }
            echo '</select>';
        }

        ?>
        '''

    'BD ACF Get Fields':
        'prefix': 'bd_acf_get_fields'
        'body': '''
        // Output all fields
        <?php

        $fields = get_fields();

        if( $fields ): ?>
            <ul>
                <?php foreach( $fields as $name => $value ): ?>
                    <li><b><?php echo $name; ?></b> <?php echo $value; ?></li>
                <?php endforeach; ?>
            </ul>
        <?php endif; ?>

        // Debug
        <?php
        echo '<pre>';
            print_r( get_fields(123) );
        echo '</pre>';
        ?>
        '''

    'BD ACF Get Field Objects':
        'prefix': 'bd_acf_get_field_objects'
        'body': '''
        // Usage
        <?php
        // get all custom fields and dump for testing
        $fields = get_field_objects();
        var_dump( $fields );

        // get all custom fields, loop through them and create a label => value markup
        $fields = get_field_objects();

        if( $fields )
        {
            foreach( $fields as $field_name => $field )
            {
                echo '<div>';
                    echo '<h3>' . $field['label'] . '</h3>';
                    echo $field['value'];
                echo '</div>';
            }
        }

        ?>
        '''

    'BD ACF Repeater Looping':
        'prefix': 'bd_acf_repeater'
        'body': '''
        <?php
        // Basic Loop
        // check if the repeater field has rows of data
        if( have_rows('repeater_field_name') ):

         	// loop through the rows of data
            while ( have_rows('repeater_field_name') ) : the_row();

                // display a sub field value
                the_sub_field('sub_field_name');

            endwhile;

        else :
            // no rows found
        endif;

        ?>

        // Advanced Loop
        <?php if( have_rows('repeater_field_name') ): ?>

    	<ul class="slides">

    	<?php while( have_rows('repeater_field_name') ): the_row();

    		// vars
    		$image   = get_sub_field('image');
    		$content = get_sub_field('content');
    		$link    = get_sub_field('link');

    		?>

    		<li class="slide">

    			<?php if( $link ): ?>
    				<a href="<?php echo $link; ?>">
    			<?php endif; ?>

    				<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />

    			<?php if( $link ): ?>
    				</a>
    			<?php endif; ?>

    		    <?php echo $content; ?>

    		</li>

    	<?php endwhile; ?>

    	</ul>

        <?php endif; ?>

        // Get the first row from a repeater
        <?php

        $rows            = get_field('repeater_field_name' ); // get all the rows
        $first_row       = $rows[0]; // get the first row
        $first_row_image = $first_row['sub_field_name' ]; // get the sub field value

        // Note
        // $first_row_image = 123 (image ID)

        $image = wp_get_attachment_image_src( $first_row_image, 'full' );
        // url    = $image[0];
        // width  = $image[1];
        // height = $image[2];
        ?>
        <img src="<?php echo $image[0]; ?>" />

        // Get a random row from a repeater
        <?php

        $rows           = get_field('repeater_field_name' ); // get all the rows
        $rand_row       = $rows[ array_rand( $rows ) ]; // get a random row
        $rand_row_image = $rand_row['sub_field_name' ]; // get the sub field value

        // Note
        // $first_row_image = 123 (image ID)

        $image = wp_get_attachment_image_src( $rand_row_image, 'full' );
        // url = $image[0];
        // width = $image[1];
        // height = $image[2];
        ?>
        <img src="<?php echo $image[0]; ?>" />
        '''

    'BD ACF Flexible Content Looping':
        'prefix': 'bd_acf_flexible_content'
        'body': '''
        <?php
        // Basic Loop
        // check if the flexible content field has rows of data
        if( have_rows('flexible_content_field_name') ):

             // loop through the rows of data
            while ( have_rows('flexible_content_field_name') ) : the_row();

                if( get_row_layout() == 'paragraph' ):

                	the_sub_field('text');

                elseif( get_row_layout() == 'download' ):

                	$file = get_sub_field('file');

                endif;

            endwhile;

        else :

            // no layouts found

        endif;

        ?>

        // Nested Loop
        <?php

        // check if the flexible content field has rows of data
        if( have_rows('flexible_content_field_name') ):

         	// loop through the rows of data
            while ( have_rows('flexible_content_field_name') ) : the_row();

        		// check current row layout
                if( get_row_layout() == 'gallery' ):

                	// check if the nested repeater field has rows of data
                	if( have_rows('images') ):

        			 	echo '<ul>';

        			 	// loop through the rows of data
        			    while ( have_rows('images') ) : the_row();

        					$image = get_sub_field('image');

        					echo '<li><img src="' . $image['url'] . '" alt="' . $image['alt'] . '" /></li>';

        				endwhile;

        				echo '</ul>';

        			endif;

                endif;

            endwhile;

        else :

            // no layouts found

        endif;

        ?>
        '''

    'BD ACF Get Sub Field Object':
        'prefix': 'bd_acf_get_sub_field_object'
        'body': '''
        <?php
        // This function will return a sub field object (within a has_sub_field loop). The returned array will look something like this:
        /*
        Array
        (
            [key] => field_4fea85f5320da
            [label] => Text Field
            [name] => text_field
            [type] => text
            [instructions] =>
            [required] => 0
            [default_value] =>
            [formatting] => html
            [order_no] => 0
        )
        */
        ?>

        // Usage
        <?php if( get_field('repeater') ): ?>

        	<?php while( has_sub_field('repeater') ): ?>

        	<?php

        		// vars
        		$select = get_sub_field_object('select');
        		$value  = get_sub_field('select');

        		?>
        		<ul>
        			<?php foreach( $select['choices'] as $k => $v ): ?>
        				<li>
        					<?php if( $k == $value ): ?>
        						<span class="selected">Selected!</span>
        					<?php endif; ?>
        					<?php echo $v; ?>
        				</li>
        			<?php endforeach; ?>
        		</ul>

        	<?php endwhile; ?>

        <?php endif; ?>
        '''

    'BD ACF Get Row':
        'prefix': 'bd_acf_get_row'
        'body': '''
        // This function will return an array containing all sub field values for the current row within a have_rows() loop.

        // Usage
        <?php if( have_rows('slides') ): ?>

        	<?php while( have_rows('slides') ): the_row();

        		// vars
        		$row = get_row();


        		if( $row['image'] ): ?>

        			<img src="<?php echo $row['image']; ?>" />
        			<p><?php echo $row['caption']; ?></p>

        		<?php endif; ?>

        	<?php endwhile; ?>

        <?php endif; ?>
        '''

    'BD ACF Get Row Index':
        'prefix': 'bd_acf_get_row_index'
        'body': '''
        // This function will return the current loop count within a have_rows() loop.

        // Usage
        <?php if( have_rows('slides') ): ?>

        	<?php while( have_rows('slides') ): the_row(); ?>

        		<div class="accordion" id="accordion-<?php echo get_row_index(); ?>">

        			<h3><?php the_sub_field('title'); ?></h3>

        			<?php the_sub_field('text'); ?>

        		</div>

        	<?php endwhile; ?>

        <?php endif; ?>
        '''

    'BD Change ‘Enter Title Here’ Text For Custom Post Type':
    	'prefix': 'bd_edit_title_placeholder'
    	'body': '''
    		function change_default_title($title){
    			$screen = get_current_screen();
    			if  ('_your_custom_post_type_' == $screen->post_type) {
    			$title = 'The new title';
    			}
    			return $title;
    		}
    		add_filter('enter_title_here', 'change_default_title');
    	'''

    'BD Load Text Domain':
    	'prefix': 'bd_load_text_domain'
    	'body': '''
    		function load_textdomain()
    		{
    			load_plugin_textdomain('your-text-domain', false, dirname(plugin_basename(__FILE__) ) . '/languages/');
    		}
    		add_action('plugins_loaded', 'load_textdomain');
    	'''

    'BD Register a Plugin':
    	'prefix': 'bd_register_plugin'
    	'body': '''
    		<?php
    		/**
    		* Plugin Name: Plugin Name
    		* Plugin URI:  http://madeindonesia.nl
    		* Description: A brief description of the Plugin.
    		* Version:     1.0.0
    		* Author:      Born Digital
    		* Author URI:  http://example.com
    		* License:     MIT?
    		* License URI:
    		*/
    		?>
    	'''

    'BD Remove WordPress Version From Pages And Feeds':
    	'prefix': 'bd_remove_version'
    	'body': '''
    		function version_removal() {
    			return '';
    		}
    		add_filter('the_generator', 'version_removal');
    	'''

    'BD Replace ‘Howdy, admin’':
    	'prefix': 'bd_replace_howdy'
    	'body': '''
    		function replace_howdy($wp_admin_bar) {
    			$my_account = $wp_admin_bar->get_node('my-account');
    			$newtitle   = str_replace( 'Howdy,', 'Logged in as', $my_account->title );
    			$wp_admin_bar->add_node( array(
    			'id'    => 'my-account',
    			'title' => $newtitle,
    			) );
    		}
    		add_filter('admin_bar_menu', 'replace_howdy',25);
    	'''

    'BD Enqueue CSS':
        'prefix': 'bd_wp_enqueue_css'
        'body': '''
        wp_enqueue_style(
            string $handle,
            string $src = '',
            array $deps = array()
        );
    '''

    'BD Enqueue JS':
        'prefix': 'bd_wp_enqueue_js'
        'body': '''
        wp_enqueue_script(
            string $handle,
            string $src = '',
            array $deps = array(), string|bool|null $ver = false, bool $in_footer = false
        );
    '''

    'BD Register CSS':
        'prefix': 'bd_wp_register_css'
        'body': '''
        wp_register_style(
            string $handle,
            string $src = '',
            array $deps = array()
        );
    '''

    'BD Register JS':
        'prefix': 'bd_wp_register_js'
        'body': '''
        wp_register_script(
            string $handle,
            string $src = '',
            array $deps = array(), string|bool|null $ver = false, bool $in_footer = false
        );
    '''

    'BD Localize JS':
        'prefix': 'bd_wp_localize_js'
        'body': 'wp_localize_script( string $handle, string $object_name, array $l10n );'

	'*':
		'BD footer':
			'prefix': 'bd_footer'
			'body': '''
				<?php wp_footer(); ?>
				<script>
				</script>
				</body>
			</html>
			'''

		'BD get sidebar':
			'prefix': 'bd_get_sidebar'
			'body': '''
			<?php get_sidebar('BottleMobile'); ?>
			'''

		'BD header':
			'prefix': 'bd_header'
			'body': '''
			<!DOCTYPE html>
			<html <?php language_attributes(); ?>>
				<head>
					<?php wp_head(); ?>
				</head>
			<body style="">
			'''