Skip to content

Instantly share code, notes, and snippets.

@huiralb
huiralb / composer_view.js
Created October 2, 2016 16:35
Fix Visual Composer 4.8 Uncaught TypeError: Cannot read property 'attributes' of undefined
html2element: function(html) {
var $template, attributes = {},
template = html;
$template = $(template(this.model.toJSON()).trim());
if($template.get(0))
{
_.each($template.get(0).attributes, function(attr) {
attributes[attr.name] = attr.value
})};
@butlerblog
butlerblog / wp_config.php
Last active February 1, 2024 09:00
Configure WordPress #wp_mail function to send through #SMTP server https://b.utler.co/Y3
<?php
/*
* Set the following constants in wp-config.php.
* These should be added somewhere BEFORE the constant ABSPATH is defined.
*
* Author: Chad Butler
* Author URI: https://butlerblog.com
*
* For more information and instructions, see: https://b.utler.co/Y3
@nroca
nroca / gist:511ef1d287ba7121f596
Created October 9, 2014 05:39
ACF Options Page (Icon/Position)
// http://support.advancedcustomfields.com/forums/topic/change-menu-position-of-options-page/
acf_add_options_page( array(
'page_title' => 'Home Page Sliders',
'menu_title' => 'Sliders',
'menu_slug' => 'home-page-sliders',
'capability' => 'edit_posts',
'icon_url' => 'dashicons-images-alt2',
'position' => 7
@vindia
vindia / russian_transliteration.php
Created December 14, 2011 14:36
Russian (cyrillic) transliteration function
<?php
function transliterate($string) {
$roman = array("Sch","sch",'Yo','Zh','Kh','Ts','Ch','Sh','Yu','ya','yo','zh','kh','ts','ch','sh','yu','ya','A','B','V','G','D','E','Z','I','Y','K','L','M','N','O','P','R','S','T','U','F','','Y','','E','a','b','v','g','d','e','z','i','y','k','l','m','n','o','p','r','s','t','u','f','','y','','e');
$cyrillic = array("Щ","щ",'Ё','Ж','Х','Ц','Ч','Ш','Ю','я','ё','ж','х','ц','ч','ш','ю','я','А','Б','В','Г','Д','Е','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Ь','Ы','Ъ','Э','а','б','в','г','д','е','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','ь','ы','ъ','э');
return str_replace($cyrillic, $roman, $string);
}
var_dump(transliterate('андрей шевченко')); # andrey shevchenko
?>
@alexdunae
alexdunae / wordpress_custom_post_gallery.php
Created March 31, 2011 23:55
Display a custom post type's media library inline on the WordPress edit page screen
<?php
define('MY_POST_TYPE', 'my');
define('MY_POST_SLUG', 'gallery');
function my_register_post_type () {
$args = array (
'label' => 'Gallery',
'supports' => array( 'title', 'excerpt' ),
'register_meta_box_cb' => 'my_meta_box_cb',