Skip to content

Instantly share code, notes, and snippets.

View melissacabral's full-sized avatar

Melissa Cabral melissacabral

View GitHub Profile
@melissacabral
melissacabral / about.md
Last active February 25, 2022 18:50
PHP Class Like Button Interface Starter

TODO

  • 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 Fetch() 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
melissacabral / wp-dimox-breadcrumbs.php
Last active February 17, 2022 09:13
breadcrumbs - place in functions.php and call in your theme with dimox_breadcrumbs() [Source](http://dimox.net/wordpress-breadcrumbs-without-a-plugin/)
<?php
/**
* Dimox Breadcrumbs
* http://dimox.net/wordpress-breadcrumbs-without-a-plugin/
* Since ver 1.0
* Add this to any template file by calling dimox_breadcrumbs()
* Changes: MC added taxonomy support
*/
function dimox_breadcrumbs(){
/* === OPTIONS === */
@melissacabral
melissacabral / template-archive-per-term.php
Last active April 26, 2021 16:44
Wordpress template to show one post from each category/taxonomy term
<?php
/*
Template Name: Post thumbnails by taxonomy term
*/
//edit these to match the stuff you registered in your custom post type plugin
$post_type = 'work';
$taxonomy = 'work_category'; ?>
<?php get_header(); ?>
@melissacabral
melissacabral / config.php
Created February 25, 2021 15:28
basic config file for WIP400 class
<?php
/**
* configure error display (production vs development)
*/
/* ------------------configure these variables----------------- */
define('DEBUG_MODE', 0);
define('ROOT_DIR', '' );
@melissacabral
melissacabral / image-preserve-aspect-ratio.php
Created February 12, 2018 16:18
Change the image uploader we built so that it preserves the original aspect ratio. Replaces lines in the foreach($sizes) loop. Prevents up-sampling
if($width >= $pixels){
//wider than desired size
$newwidth = $pixels;
//calculate the correct height
$newheight=($height/$width) * $newwidth;
}else{
//smaller than desired size. preserve original width and height
$newwidth=$width;
$newheight=$height;
}
@melissacabral
melissacabral / json-mysql-php.php
Created April 30, 2019 17:31
Make a JSON object from a mysql query
<?php //connect to DB
require('config.php');
include_once('includes/functions.php');
//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
ORDER BY date DESC
@melissacabral
melissacabral / comments.php
Last active February 26, 2018 17:21
step 1 of customizing comments display
<?php
//hide all of this file if the post if password protected
if( post_password_required() ){
return;
}
//get a distinct count of comments vs. pings
$comm = get_comments( array(
'status' => 'approve',
'post_id' => $id, //This post
@melissacabral
melissacabral / wordpress_css_comment.css
Created November 30, 2012 16:39 — forked from leanda/wordpress_css_comment.css
WordPress: style sheet comment block
/*
Theme Name: Twenty Ten
Theme URI: http://wordpress.org/
Description: The 2010 default theme for WordPress.
Author: wordpressdotorg
Author URI: http://wordpress.org/
Version: 1.0
Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional)
License:
@melissacabral
melissacabral / plugincomment.php
Created October 25, 2017 03:51
WordPress Plugin Comment
<?php
/*
Plugin Name: Unique Name Here
Plugin URI: http://yoursite.com/plugin
Description: Does an awesome thing
Version: 0.1
Author: Your Name Here
Author URI: http://yoursite.com
License: GPLv3
*/