Skip to content

Instantly share code, notes, and snippets.

@besimhu
besimhu / ACF Post Meta - Options.php
Created July 24, 2015 13:13
Get ACF options without using ACF functions.
<?php
$acf_field_one = get_option( 'options_acf_field_one' );
$acf_field_two = get_option( 'options_acf_field_two' );
@besimhu
besimhu / ACF Post Meta - Terms.php
Created July 24, 2015 13:19
Get ACF fields from taxonomy without using ACF functions.
<?php
// get taxonomy
$taxonomy = get_term_by( 'slug', get_query_var( 'taxonomy_name' ), 'my_custom_taxonomy' );
$acf_field = get_option( 'my_custom_taxonomy_' . $taxonomy->term_id . '_acf_field_slug' );
@besimhu
besimhu / ACF Post Meta - Repeater chaining.php
Last active April 30, 2016 05:14
Get ACF repeater within a repeater without using ACF functions.
<?php
// get post ID
$pid = get_the_ID();
// get our repeater
$repeater = get_post_meta( $pid, 'acf_repeater_slug', true );
if ( !empty($repeater) ) {
for( $i = 0; $i < $repeater; $i++ ) {
<?php
/*
Based on Ohad Raz - https://en.bainternet.info/custom-post-types-columns/
Some info:
-- The classes read the meta field of the CPT ID and enable the sorting
-- It's possible remove other column
-- Support 4 type of object natively: Title, Thumbnail, Custom Taxonomy, Custom Field
-- Add a filter cpt_columns_text_{column_name_id} in Title type
-- prefix/suffix values are for all the objects except post_thumb
[video src="http://www.video-url.com"][/video]
<?php
function delete_its_transients() {
global $post;
if( $post->post_type == 'cpt' ) {
delete_transient( 'transient_name' );
}
}
add_action( 'save_post', 'delete_its_transients' );
@besimhu
besimhu / .content.xml
Created August 25, 2017 18:58 — forked from rjspiker/.content.xml
AEM 6 Touch UI Show/Hide Checkbox Component Extension - Extension to the standard checkbox component. It enables hiding/unhiding of other components based on the selection made in the checkbox.
<enable
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/checkbox"
text="Enable"
id="enable"
value="true"
name="./enable"
class="cq-dialog-checkbox-showhide"
cq-dialog-checkbox-showhide-target=".button-option-enable-showhide-target"/>
<deleteEnable
@besimhu
besimhu / create_init_sql.sh
Created January 12, 2018 04:05
a script use to recover data from innodb's frm and ibd file.
#!/bin/bash
#
# File: create_init_sql.sh
#
# Author: [email protected]
# blog: www.colorfuldays.org
#
# Purpose: This script is a part of an tool to recover mysql data from .frm and .idb file.
# This script is read the db data dir's file, generate an script to create the tables.
#
@besimhu
besimhu / clean_code.md
Created August 7, 2018 17:02 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

let element = document.querySelector('#auto-complete');
let uri = 'https://example.org/search';
let choice = new Choices(element, {
removeItemButton: false,
itemSelectText: '',
shouldSort: false,
});
let timer = null;
choice.passedElement.addEventListener('search', function (event) {