Skip to content

Instantly share code, notes, and snippets.

Melissa Cabral melissacabral

Block or report user

Report or block melissacabral

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
melissacabral /
Last active May 8, 2019
PHP Class Like Button Interface Starter


  • Import the likes table (likes.sql) into our DB
  • write the HTML for the like button interface (index.php)
  • Add the CSS for the heart button (css/style.css)
  • Add the count_likes function (includes/functions.php)
  • add the likes interface function (includes/functions.php)
  • add the JS AJAX call when the user clicks the heart button (includes/footer.php)
  • add the ajax handler PHP file to update the DB behind the scenes (ajax-handlers/like-unlike.php)
melissacabral / json-mysql-php.php
Created Apr 30, 2019
Make a JSON object from a mysql query
View json-mysql-php.php
<?php //connect to DB
//get 10 of the recent published posts out of the DB
$query = "SELECT posts.title AS post_title, posts.body AS description, posts.image AS url, users.username
FROM posts, users
WHERE posts.user_id = users.user_id
AND posts.is_published = 1
melissacabral / image-preserve-aspect-ratio.php
Created Feb 12, 2018
Change the image uploader we built so that it preserves the original aspect ratio. Replaces lines in the foreach($sizes) loop. Prevents up-sampling
View image-preserve-aspect-ratio.php
if($width >= $pixels){
//wider than desired size
$newwidth = $pixels;
//calculate the correct height
$newheight=($height/$width) * $newwidth;
//smaller than desired size. preserve original width and height
melissacabral / plugincomment.php
Created Oct 25, 2017
WordPress Plugin Comment
View plugincomment.php
Plugin Name: Unique Name Here
Plugin URI:
Description: Does an awesome thing
Version: 0.1
Author: Your Name Here
Author URI:
License: GPLv3
melissacabral / comments.php
Last active Feb 26, 2018
step 1 of customizing comments display
View comments.php
//hide all of this file if the post if password protected
if( post_password_required() ){
//get a distinct count of comments vs. pings
$comm = get_comments( array(
'status' => 'approve',
'post_id' => $id, //This post
View admin-editprofile-square-crop.php
// square cropping logic on lines 56-70
// header has the authentication, DB connection and doctype!
//begin upload parser
//the folder where uploads will be saved
$upload_directory = '../uploads';
melissacabral / php-debug-to-console.php
Created Jun 24, 2016
Helper function to allow PHP to use the console for debugging.
View php-debug-to-console.php
function debug_to_console( $data ) {
if ( is_array( $data ) )
$output = "<script>console.log( 'Debug Objects: " . implode( ',', $data) . "' );</script>";
$output = "<script>console.log( 'Debug Objects: " . $data . "' );</script>";
echo $output;
View wordpress-blog-page-featured-image.php
View image-upload-widget.php
* Plugin Name: Media Upload Widget
* Plugin URI:
* Description: A widget that allows you to upload media from a widget
* Version: 1.0
* Author: Melissa Cabral
* Author URI:
* License: GPLv3
melissacabral / gist:02c89fa1bab0307dfd2e
Created Jan 6, 2016 — forked from engelen/gist:9df926bd9f3957394d89
Use WordPress dashicons in your theme on the frontend.
View gist:02c89fa1bab0307dfd2e
add_action( 'wp_enqueue_scripts', 'mytheme_scripts' );
* Enqueue Dashicons style for frontend use
function mytheme_scripts() {
wp_enqueue_style( 'dashicons' );
You can’t perform that action at this time.