Skip to content

Instantly share code, notes, and snippets.

View zachakbar's full-sized avatar
👻
...

{...} zachakbar

👻
...
View GitHub Profile
@zachakbar
zachakbar / acf-options-page.php
Last active March 6, 2018 21:45
Add custom options page to WordPress with ACF.
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'PAGE_TITLE',
'menu_title' => 'MENU_TITLE',
'menu_slug' => 'PAGE_SLUG',
'capability' => 'edit_posts',
'redirect' => false,
'parent_slug' => 'options-general.php'
));
}
@zachakbar
zachakbar / acf-oembed.php
Last active June 2, 2023 16:26
ACF oEmbed script w/ player parameters
<?php
/**
* ACF oEmbed script w/ player parameters
* @link https://www.advancedcustomfields.com/resources/oembed/
*/
$video = get_field('video');
// use preg_match to find iframe src
preg_match('/src="(.+?)"/', $video, $matches);
@zachakbar
zachakbar / styled-select.scss
Created February 12, 2018 23:58
Styled select box.
$grey: rgb(153,153,153);
$lightgrey: rgb(204,204,204);
$white: rgb(255,255,255);
$blue: rgb(0,188,188);
.styled-select {
background: $white url("../img/select-arrow.png") right center no-repeat;
border: $input_border;
border-radius: 5px;
width: 100%;
@zachakbar
zachakbar / menu-item-description.php
Created March 6, 2018 21:44
Add descriptions for menu items
/************************************************************************/
/* ADD DESCRIPTION TO MENU
/************************************************************************/
// Add description to navigation
function prefix_nav_description( $item_output, $item, $depth, $args ) {
if ( !empty( $item->description ) ) {
$item_output = str_replace( $args->link_after . '</a>', '<span class="menu-item-description">' . $item->description . '</span>' . $args->link_after . '</a>', $item_output );
}
return $item_output;
// init empy git repo
git init
// connect repo to project
git remote add origin PROJECT_URL
// checkout branch
git fetch && git checkout BRANCH_NAME
// check working status
<?php echo '<pre>';print_r(get_intermediate_image_sizes());echo '</pre>'; ?>
@zachakbar
zachakbar / README.md
Last active October 10, 2018 23:21
Add columns for checkboxes and radio buttons

How to use

  1. Upload the CSS.
  2. Add the following function to functions.php.
function admin_style() {
	wp_enqueue_style('admin_style', get_stylesheet_directory_uri().'PATH/TO/acf-checkbox-radio-columns.css'); 
}
add_action('admin_init', 'admin_style');
@zachakbar
zachakbar / type-style-checker.html
Last active January 15, 2019 18:33
Sample text to check type styles.
<section class="type-style-checker">
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
<p>A paragraph (from the Greek paragraphos, "to write beside" or "written beside") is a self-contained unit of a discourse in writing dealing with a particular point or idea. A paragraph consists of one or more sentences. Though not required by the syntax of any language, paragraphs are usually an expected part of formal writing, used to organize longer prose.</p>
<p><a href="#">Sample Text Link</a></p>
</section>
@zachakbar
zachakbar / multiple-slick-sliders.js
Created January 17, 2019 18:19
Function to have multiple sliders on same page.
// Needs some tweaking per project.
function initSlickSlider(clsSlider,smSlides,mdSlides,lgSlides){
// init Slick slider
$(clsSlider).each(function (idx, item) {
var s = smSlides;
var m = mdSlides;
var l = lgSlides;
var carouselId = "carousel" + idx;
this.id = carouselId;
@zachakbar
zachakbar / sanitize-acf-fields.php
Last active April 7, 2023 19:04
Helper functions to sanitize data output by the get_field() & get_sub_field() functions.
<?php
/**
* @link https://snippets.khromov.se/sanitizing-and-securing-advanced-custom-fields-output/
* @link https://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data
*/
/**
* Helper function to sanitize data output by the get_field() function also normalize values.
*
* @param $field_key