Skip to content

Instantly share code, notes, and snippets.

View dcangulo's full-sized avatar
💻

David Angulo dcangulo

💻
View GitHub Profile
@dcangulo
dcangulo / submenu.php
Last active April 3, 2018 06:14
A WordPress plugin template with menu and submenu. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: My WordPress Plugin
Plugin URI: https://wordpress.org/plugins/
Description: Just another WordPress plugin.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
*/
@dcangulo
dcangulo / function.php
Last active April 3, 2018 06:15
A PHP function that abbreviates numbers. (Eg. 1000 to 1K+). Visit https://www.davidangulo.xyz/ for more information.
<?php
function abbreviateNumber($num) {
if ($num >= 0 && $num < 1000) {
$format = floor($num);
$suffix = '';
}
else if ($num >= 1000 && $num < 1000000) {
$format = floor($num / 1000);
$suffix = 'K+';
}
@dcangulo
dcangulo / admin.php
Last active April 3, 2018 06:16
A WordPress plugin template that has an admin menu. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: My WordPress Plugin
Plugin URI: https://wordpress.org/plugins/
Description: Just another WordPress plugin.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
*/
@dcangulo
dcangulo / upload.php
Last active April 3, 2018 06:17
A simple WordPress plugin that allows you to upload files programatically. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Upload Files Programatically
Plugin URI: https://wordpress.org/plugins/
Description: Just another file uploader plugin.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
*/
@dcangulo
dcangulo / seo-friendly-url.php
Last active April 14, 2019 07:08
A PHP function that converts string to an SEO friendly string. Visit https://www.davidangulo.xyz/ for more information.
<?php
function seoFriendlyUrl($string) {
$string = strtolower($string);
$string = preg_replace('/[^a-z0-9_\s-]/', '', $string);
$string = preg_replace('/[\s_]/', '-', $string);
return $string;
}
//Visit the tutorial for more information
//https://www.davidangulo.xyz/how-to-create-seo-friendly-url-in-php/
@dcangulo
dcangulo / index-oop.php
Last active April 3, 2018 06:20
A WordPress plugin shortcode template on both oop and procedural approach. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Example Shortcode Plugin
Plugin URI: https://wordpress.org/plugins/
Description: Just another example shortcode plugin.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
*/