Skip to content

Instantly share code, notes, and snippets.

View dcangulo's full-sized avatar
💻

David Angulo dcangulo

💻
View GitHub Profile
@dcangulo
dcangulo / resizeimage.php
Created April 14, 2018 06:20
A PHP function that can resize an image. Visit https://www.davidangulo.xyz/ for more information.
<?php
function resize_image($filename,$newwidth,$newheight) {
list($width, $height) = getimagesize($filename);
if(pathinfo($filename,PATHINFO_EXTENSION) == "jpg" || pathinfo($filename,PATHINFO_EXTENSION) == "jpeg") {
$src = imagecreatefromjpeg($filename);
$dst = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($dst, $filename, 100);
}
if(pathinfo($filename,PATHINFO_EXTENSION) == "png") {
@dcangulo
dcangulo / timeago.php
Created April 13, 2018 11:51
A PHP function that converts timestamp/datetime to time ago format. Visit https://www.davidangulo.xyz/ for more information.
<?php
function timeago($datetime, $full = false) {
date_default_timezone_set("Asia/Manila");
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
@dcangulo
dcangulo / crud.php
Created April 8, 2018 11:58
A CRUD Operations WordPress plugin. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: CRUD Operations
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: A simple plugin that allows you to perform Create (INSERT), Read (SELECT), Update and Delete operations.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / contact.php
Created April 5, 2018 13:45
A simple contact form WordPress plugin. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Simple Contact Form
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: A very simple contact form.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / databasetable.php
Created April 5, 2018 07:02
A simple WordPress plugin the creates custom table on plugin activation. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Create database table
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: A simple WordPress plugin that creates a database table on activation.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / column.php
Created April 4, 2018 13:22
A simple WordPress plugin that shows the last modified date of a post. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Custom Column Plugin Example
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: Add a custom column on WordPress posts.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / dashboard-widget.php
Created April 4, 2018 04:38
A dashboard widget code in WordPress. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Dashboard Widget Example
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: Just another WordPress plugin with dashboard widget.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / settings.php
Created April 3, 2018 14:05
A WordPress plugin settings page template. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Wordpress plugin with settings
Plugin URI: wordpress.org/plugins
Description: Just another WordPress plugin with settings page.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / cron.php
Created April 3, 2018 07:51
A simple WordPress plugin that has a cron schedule. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: My cron WordPress plugin
Plugin URI: wordpress.org/plugins
Description: A simple WordPress plugin that executes many times in a certain interval.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / class.verifyEmail.php
Last active March 19, 2024 10:17
A PHP class file that can be used to check if an email address is valid using SMTP protocol. Visit https://www.davidangulo.xyz/ for more information.
<?php
/**
* Class to check up e-mail
*
* @author Konstantin Granin <kostya@granin.me>
* @copyright Copyright (c) 2015, Konstantin Granin
*/
class verifyEmail {