Basics | Working with DOM | Working with JS | Working With Functions |
---|---|---|---|
Variables | Accessing Dom Elements | Add/Remove Array Item | Add Default Arguments to Function |
Functions | Grab Children/Parent Node(s) | Add/Remove Object Properties | Throttle/Debounce Functions |
Objects | Create DOM Elements | Conditionals | |
Add Elements to the DOM | Loops |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* configure error display (production vs development) | |
*/ | |
/* ------------------configure these variables----------------- */ | |
define('DEBUG_MODE', 0); | |
define('ROOT_DIR', '' ); |
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// square cropping logic on lines 56-70 | |
// header has the authentication, DB connection and doctype! | |
require('admin-header.php'); | |
//begin upload parser | |
if($_POST['did_upload']){ | |
//the folder where uploads will be saved | |
$upload_directory = '../uploads'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debug_to_console( $data ) { | |
if ( is_array( $data ) ) | |
$output = "<script>console.log( 'Debug Objects: " . implode( ',', $data) . "' );</script>"; | |
else | |
$output = "<script>console.log( 'Debug Objects: " . $data . "' );</script>"; | |
echo $output; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$page_for_posts = get_option('page_for_posts'); | |
if( is_home() && $page_for_posts ) : | |
echo get_the_post_thumbnail($page_for_posts, 'medium'); | |
endif; | |
?> |
NewerOlder