Skip to content

Instantly share code, notes, and snippets.

View luiseduardobraschi's full-sized avatar
🤓
Updating knowledgebase...

Luis Braschi luiseduardobraschi

🤓
Updating knowledgebase...
View GitHub Profile
@luiseduardobraschi
luiseduardobraschi / wp_menu_items_to_links.sql
Last active August 29, 2015 14:17
Change WordPress' nav menu items into custom links
@luiseduardobraschi
luiseduardobraschi / Dummy.Csharp.example.cs
Last active November 29, 2019 06:42
Example of well formatted code
using System;
namespace FacebookGroup {
public class Example(){
public Exemple(){
Console.WriteLine("hej på dig");
}
}
}
@luiseduardobraschi
luiseduardobraschi / changing-form-fields-after-user-log-in.php
Last active August 25, 2017 06:05
Since WordPress uses difrerent templates for both logged and not logged-in users, I ended up having to use some other hooks other than the default filter.
<?php
function alter_comment_form_fields($fields){
$commenter = wp_get_current_commenter();
$fields['author'] = '<p class="comment-form-input comment-form-author"><label for="author">' . __( 'This is a fancy label', 'your-text-domain' ) . '</label><input id="author" required name="author" type="text" placeholder="Seu nome" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" /></p>';
return $fields;
}
@luiseduardobraschi
luiseduardobraschi / MyTax-meta-class.php
Created July 17, 2016 03:32
Add Google Maps meta field to taxonomy using bainternet/Tax-Meta-Class
<?php
include_once dirname(__FILE__)."/Tax-meta-class/Tax-meta-class.php";
class MyTax_Meta_Class extends Tax_Meta_Class {
public function load_scripts_styles(){
parent::load_scripts_styles();
// enqueue only in the right place
if(isset($_REQUEST['taxonomy'])) {
//script must have been registered previously (priority of at least 10)
@luiseduardobraschi
luiseduardobraschi / list.html
Last active August 25, 2017 06:05
One-liner last-child style remover.
<style>
ul {
list-style:none;
}
li {
display: inline-block;
padding: 5px;
}
</style>
@luiseduardobraschi
luiseduardobraschi / a2dissite.sh
Last active August 25, 2017 06:07
Apache 2's a2ensite and a2dissite for non-Deb based distros. Source (slightly modified): Apache virtual hosting in CentOS http://www.tecmint.com/apache-virtual-hosting-in-centos/
#!/bin/bash
avail=/etc/httpd/sites-enabled/$1.conf
enabled=/etc/httpd/sites-enabled
site=`ls /etc/httpd/sites-enabled/`
if [ "$#" != "1" ]; then
echo "Use script: a2dissite virtual_site"
echo -e "\nAvailable virtual hosts: \n$site"
exit 0
else
@luiseduardobraschi
luiseduardobraschi / ApplicationContext.cs
Created May 26, 2017 00:08
Friendship workflow using Entity Framework
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace Test.Models {
public DbSet<Friendship> Friendships { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
/* USER */
modelBuilder.Entity<User>().HasMany(u => u.Friends).WithMany();
@luiseduardobraschi
luiseduardobraschi / .bashrc
Created May 26, 2017 08:52
My .bashrc setup.
source /opt/wp-completion.bash
export DEV=/var/www/html
export EDITOR=subl
export PS1="\[$(tput bold)\]\[\033[38;5;58m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\[$(tput sgr0)\]\[\033[38;5;58m\]\H\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\] [\t] \w \\$\n> \[$(tput sgr0)\]"
# function to set terminal title
function set-title() {
if [[ -z "$ORIG" ]]; then
ORIG=$PS1
@luiseduardobraschi
luiseduardobraschi / toggle.js
Last active December 9, 2017 20:14
A bookmarklet to quickly toggle admin bar in WordPress .
javascript: (function() {
var htmlStyle = document.documentElement.style;
var adminBarStyle = document.getElementById('wpadminbar').style;
if(undefined == window.hasAdminBar){
window.hasAdminBar = true;
}
var cssText, display;
@luiseduardobraschi
luiseduardobraschi / loop.php
Created March 8, 2018 05:39
Adding taxonomy filtering to a loop
<?php
$args = array(
'post_type' => 'cardapio',
'posts_per_page' => 999,
'orderby' => 'title',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'cardapio_category',
'field' => 'term_id',