Skip to content

Instantly share code, notes, and snippets.

View joshapgar's full-sized avatar

Josh Apgar joshapgar

View GitHub Profile
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@joshapgar
joshapgar / functions.php
Created April 7, 2017 12:59
Link Button Shortcode with TinyMCE Button
<?php
/****************************
* Register Shortcodes
****************************/
add_action( 'init', 'register_shortcodes');
function register_shortcodes(){
add_shortcode('linkbutton', 'linkbutton_function');
}
function linkbutton_function( $atts, $content = null ) {
@joshapgar
joshapgar / functions.php
Last active April 14, 2017 12:49
Dynamically reorder side navigation based on current page
<?php
/*******************************
* SIDEBAR NAVIGATION
*******************************/
function check_for_page_tree() {
//start by checking if we're on a page
if( is_page() ) {
global $post;
@joshapgar
joshapgar / bootstrap-clearfix.css
Created April 19, 2017 13:59
Clearfix on Bootstrap 3 columns without using rows
/* Bootstrap Clearfix */
/* Tablet */
@media (min-width:767px){
/* Column clear fix */
.col-lg-1:nth-child(12n+1),
.col-lg-2:nth-child(6n+1),
.col-lg-3:nth-child(4n+1),
.col-lg-4:nth-child(3n+1),
@joshapgar
joshapgar / scrollTo.js
Last active June 14, 2017 19:42
ScrollTo With Checks
//
// --------------------------------------------------------------------------
// To Top Function
// --------------------------------------------------------------------------
//
function toTop(elementClass) {
var chapterToTop = $(elementClass).offset();
chapterToTop = Math.round(chapterToTop.top);
var windowScrollPosition = $(document).scrollTop();
@joshapgar
joshapgar / bones.php
Created August 3, 2017 15:01
Remove version from styles and scripts, and add time version to style.css
// remove WP version from css
add_filter( 'style_loader_src', 'bones_remove_wp_ver_css_js', 9999 );
// remove WP version from scripts
function bones_remove_wp_ver_css_js( $src ) {
if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
@joshapgar
joshapgar / encryption.php
Created August 7, 2017 15:49
Encrypt and Decrypt Data
//Encryption:
$textToEncrypt = "My Text to Encrypt";
$encryptionMethod = "AES-256-CBC";
$secretHash = "encryptionhash";
$iv = mcrypt_create_iv(16, MCRYPT_RAND);
$encryptedText = openssl_encrypt($textToEncrypt,$encryptionMethod,$secretHash, 0, $iv);
//Decryption:
$decryptedText = openssl_decrypt($encryptedText, $encryptionMethod, $secretHash, 0, $iv);
print "My Decrypted Text: ". $decryptedText;
@joshapgar
joshapgar / shim.js
Created October 3, 2017 21:15
Angular Google Magic
/**
* core-js 2.4.1
* https://github.com/zloirock/core-js
* License: http://rock.mit-license.org
* © 2016 Denis Pushkarev
*/
!function(a,b,c){"use strict";!function(a){function __webpack_require__(c){if(b[c])return b[c].exports;var d=b[c]={exports:{},id:c,loaded:!1};return a[c].call(d.exports,d,d.exports,__webpack_require__),d.loaded=!0,d.exports}var b={};return __webpack_require__.m=a,__webpack_require__.c=b,__webpack_require__.p="",__webpack_require__(0)}([function(a,b,c){c(1),c(50),c(51),c(52),c(54),c(55),c(58),c(59),c(60),c(61),c(62),c(63),c(64),c(65),c(66),c(68),c(70),c(72),c(74),c(77),c(78),c(79),c(83),c(86),c(87),c(88),c(89),c(91),c(92),c(93),c(94),c(95),c(97),c(99),c(100),c(101),c(103),c(104),c(105),c(107),c(108),c(109),c(111),c(112),c(113),c(114),c(115),c(116),c(117),c(118),c(119),c(120),c(121),c(122),c(123),c(124),c(126),c(130),c(131),c(132),c(133),c(137),c(139),c(140),c(141),c(142),c(143),c(144),c(145),c(146),c(147),c(148),c(149),c(150),c(151),c(152),c(158),c(159),c(161),c(162),c(163),c(167),c
@joshapgar
joshapgar / facebook-js-login.php
Created November 3, 2017 19:28
Facebook Access Token Getter
<?php
session_start();
require( '../vendor/facebook-php-sdk-v5/autoload.php' );
$facebookAppData = file_get_contents('php://input');
$facebookAppID = $_POST["app_id"];
$facebookAppSecret = $_POST["app_secret"];
$fb = new Facebook\Facebook([
@joshapgar
joshapgar / facebook-button-function.php
Created November 3, 2017 19:29
Authenticate with Facebook Button
public function authenticate_with_facebook() {
?>
<p><a href="#" onClick="logInWithFacebook()">Log In with the JavaScript SDK</a></p>
<script>
logInWithFacebook = function() {
FB.login(function(response) {
if (response.authResponse) {
//alert('You are logged in &amp; cookie set!');
// Now you can redirect the user or do an AJAX request to
// a PHP script that grabs the signed request from the cookie.