Skip to content

Instantly share code, notes, and snippets.

View nicolabavaro's full-sized avatar

Nicola Bavaro nicolabavaro

View GitHub Profile
@nicolabavaro
nicolabavaro / gist:59e9a638b58a539aa2e477117fe0d78a
Created September 7, 2018 08:46
Wordpress: Get attachment ID from attachment url
/**
* Ottengo l'ID di un attachment attraverso il suo URL
*
* @param $url
* @return int
*/
public function get_attachment_id( $url )
{
$attachment_id = 0;
$dir = wp_upload_dir();
@nicolabavaro
nicolabavaro / web.config
Created March 22, 2018 16:50
Laravel & Plesk 17
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="True" />
</security>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
@nicolabavaro
nicolabavaro / functions.php
Created February 20, 2017 10:05 — forked from thecodepoetry/functions.php
remove meta info in search results
add_action( 'get_header', 'dt_archive_layout', 10 );
function dt_archive_layout() {
$config = Presscore_Config::get_instance();
if(is_search() ){
$config->set( 'post.meta.fields.date', '0' );
$config->set( 'post.meta.fields.categories', '0' );
$config->set( 'post.meta.fields.comments', '0' );
add_action( 'get_header', 'dt_media_sidebar', 10 );
function dt_media_sidebar() {
$config = Presscore_Config::get_instance();
if(is_singular( 'post' )){
$config->set( 'sidebar_position', 'left' ); //to change sidebar postion
$config->set( 'sidebar_widgetarea_id', 'sidebar_1' ); //repalce with sidebar widget area id
}
@nicolabavaro
nicolabavaro / add-vc-grid-element.php
Created February 16, 2017 17:05
Create a custom element fo visual Composer Grid Builder
// _dt_fancy_header_bg_image
add_filter( 'vc_gitem_template_attribute_fancy_image', 'vc_gitem_template_attribute_fancy_image', 10, 2 );
function vc_gitem_template_attribute_fancy_image( $value, $data ) {
/**
* @var Wp_Post $post
* @var string $data
*/
global $post;
@nicolabavaro
nicolabavaro / gist:307981365280702cb9ec7e00c608a9af
Created April 4, 2016 08:36
Remove Content Editor on Product Editor Page
function remove_product_editor() {
remove_post_type_support( 'product', 'editor' );
}
add_action( 'init', 'remove_product_editor' );
@nicolabavaro
nicolabavaro / wp.sh
Created October 9, 2015 07:50 — forked from bgallagh3r/wp.sh
Wordpress: Bash Install Script -- Downloads latest WP version, updates wp-config with user supplied DB name, username and password, creates and CHMOD's uploads dir, copies all the files into the root dir you run the script from, then deletes itself!
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Database Name: "
read -e dbname
echo "Database User: "
read -e dbuser
echo "Database Password: "
@nicolabavaro
nicolabavaro / wp-shell-install.sh
Created October 9, 2015 07:46 — forked from dongilbert/wp-shell-install.sh
Auto Install Latest WordPress from Shell
#!/bin/bash
# Install script for Latest WordPress by Johnathan Williamson - extended by Don Gilbert
# Disclaimer: It might not bloody work
# Disclaimer 2: I'm not responsible for any screwups ... :)
# DB Variables
echo "MySQL Host:"
read mysqlhost
export mysqlhost
<?php
/* --------------------------------------------------------------------
:: Auto-Includer
Loads PHP files from the /includes/ directory. For WordPress sites,
this code would go in your functions.php file.
-------------------------------------------------------------------- */
foreach (glob(__DIR__ . '/includes/*.php') as $my_theme_filename) {
@nicolabavaro
nicolabavaro / gist:d62b3b7f5dcd1d2dbebb
Created July 13, 2015 12:43
Query MySQL per cambio dominio Wordpress
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');