Skip to content

Instantly share code, notes, and snippets.

View alejandrogih's full-sized avatar

Alejandro Giraldo alejandrogih

View GitHub Profile
@alejandrogih
alejandrogih / duplicate-post-meta.php
Created February 13, 2020 08:02
Wordpress duplicate post meta function
function copy_post_meta($base_post,$post_id){
$new_meta = get_post_meta($base_post);
foreach ($new_meta as $key => $value) {
$new_value = maybe_unserialize($value[0]);
update_post_meta( $post_id, $key, $new_value );
}
}

Keybase proof

I hereby claim:

  • I am alejandrogih on github.
  • I am alejandrogih (https://keybase.io/alejandrogih) on keybase.
  • I have a public key ASDUCcCPBj8cm8hbI6ppYUTsLMc8q9-VrTOGBM-OLhYzLAo

To claim this, I am signing this object:

@alejandrogih
alejandrogih / LaravelGetColumnNamesAndTypes.php
Created January 13, 2017 19:03
Laravel get column names and types
$column_name = "table_name";
$columns = DB::select('show columns from ' . $column_name);
foreach ($columns as $value) {
echo "'" . $value->Field . "' => '" . $value->Type . "|" . ( $value->Null == "NO" ? 'required' : '' ) ."', <br/>" ;
}
exit;
@alejandrogih
alejandrogih / ExampleNotification.php
Last active April 26, 2020 20:56
Send email with Sendgrid (including template id and substitutions) with Laravel's notifications
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
//This example use the official's sendgrid php helper (https://github.com/sendgrid/sendgrid-php)