Skip to content

Instantly share code, notes, and snippets.

@tacensi
tacensi / sublime-text-config
Last active November 25, 2018 19:37
My Sublime Text configuration file
// Settings in here override those in "Default/Preferences.sublime-settings", and
// are overridden in turn by file type specific settings.
{
"auto_complete_commit_on_tab": true,
"auto_indent": true,
"bold_folder_labels": true,
"caret_style": "phase",
"create_window_at_startup": false,
@tacensi
tacensi / thrpatch.c
Created November 19, 2018 23:34 — forked from MathisRosenhauer/thrpatch.c
Upload patch to thr10 guitar amplifier
/*
* Copyright 2016
* Mathis Rosenhauer
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
@tacensi
tacensi / WP Get Post by ID
Created March 12, 2018 21:00
WP Get Post by ID
echo apply_filters( 'the_content', get_post_field('post_content', $my_postid ) );
@tacensi
tacensi / WP Nav Menu
Created March 12, 2018 18:55
WP Nav Menu
$args = array(
'theme_location' => 'main',
'menu' => '',
'container' => '',
'container_class' => '',
'container_id' => '',
'menu_id' => '',
'menu_class' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
@tacensi
tacensi / WP Custom Embed
Created March 12, 2018 17:12
WP Custom Embed, to add responsive markup
// Modifica o html do video embebedado para ficar responsivo
add_filter( 'embed_oembed_html','oembed_result', 10, 3 );
function oembed_result( $html, $url, $args ) {
if( strstr( $url, 'youtu' ) ){
$video_pattern = '~(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@#?&%=+\/\$_.-]*~i';
$video_id = ( preg_replace( $video_pattern, '$1', $url ) );
$html = '<div class="video-container"><iframe src="https://www.youtube.com/embed/' . $video_id . '" frameborder="0" allowfullscreen';
foreach ( $args as $key => $value ) {
@tacensi
tacensi / Custom link shortcode
Created March 12, 2018 17:12
Custom link shortcode, for onclick functionality
@tacensi
tacensi / WP Custom MCE Buttons
Created March 12, 2018 17:11
WP Custom MCE Buttons
// Acrescentando botões de estilo no
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter( 'tiny_mce_before_init', 'my_mce_before_init' );
function my_mce_before_init( $settings ) {
@tacensi
tacensi / Change post labels
Last active March 12, 2018 17:10
Change post labels
// Modificando o nome dos Posts para Produtos
function mg_change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Produtos';
$submenu['edit.php'][5][0] = 'Produtos';
$submenu['edit.php'][10][0] = 'Adicionar produto';
}
function mg_change_post_object_label() {
@tacensi
tacensi / ACF Options Page
Created March 8, 2018 19:17
ACF Options Page
if( function_exists('acf_add_options_page') ) {
$args = array(
'page_title' => 'Opções',
/* (string) The title displayed in the wp-admin sidebar. Defaults to page_title */
'menu_title' => '',
/* (string) The slug name to refer to this menu by (should be unique for this menu).
Defaults to a url friendly version of menu_slug */
'menu_slug' => '',
@tacensi
tacensi / cf7-blank.php
Created May 25, 2015 21:05
Change CF7 select blank line
// Alterando o texto da blank line do Contact form 7
function my_wpcf7_form_elements($html) {
$text = 'Selecione o departamento';
$html = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $html);
return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');