Skip to content

Instantly share code, notes, and snippets.

@dimensionmedia
dimensionmedia / page.php
Created November 4, 2017 03:54
WordPress Theme Workshop: Customizer Part Two
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php if ( get_theme_mod( 'bwpy_page_comment_toggle' ) == 1 ) : // show page comments? ?>
@dimensionmedia
dimensionmedia / functions.php
Created November 4, 2017 03:53
WordPress Theme Workshop: Customizer Part One
function bwpy_customizer( $wp_customize ) {
// add "Content Options" section
$wp_customize->add_section( 'bwpy_content_options_section' , array(
'title' => __( 'Content Options', 'bwpy' ),
'priority' => 100,
) );
// add setting for page comment toggle checkbox
@dimensionmedia
dimensionmedia / gist:7c2947d8726003a23eded47f0a300e8c
Created November 4, 2017 03:15
WordPress Theme Workshop: Widget Example
<?php
/**
* Example Widget Class
*/
class example_widget extends WP_Widget {
/** constructor -- name this the same as the class above */
function example_widget() {
parent::WP_Widget(false, $name = 'Example Text Widget');
@dimensionmedia
dimensionmedia / functions.php
Created November 4, 2017 01:51
WordPress Theme Workshop: Sample Theme Setup
/**
* MyFirstTheme's functions and definitions
*
* @package MyFirstTheme
* @since MyFirstTheme 1.0
*/
/**
* First, let's set the maximum content width based on the theme's design and stylesheet.
* This will limit the width of all uploaded images and embeds.
@dimensionmedia
dimensionmedia / index_1.html
Created July 22, 2017 16:19
JavaScript Class 3
<html>
<head>
<title>Example HTML File For JS Class: Example 1</title>
<script type="text/javascript" src="script_header.js"></script> <!-- scripts can be included in the header -->
<!-- jQuery -> Uncomment this when David says! -->
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> -->
<!-- scripts can be included "inline" style in the header -->
<script type="text/javascript">
@dimensionmedia
dimensionmedia / envira_gallery_lightbox_linking.php
Created June 19, 2017 17:14
This plugin will ignore the image links if the lightbox is not enabled.
@dimensionmedia
dimensionmedia / functions.php
Created May 2, 2017 18:12
Envira Function Filter Example
function remove_envira_gallery_js_def( $javascript ) {
$javascript = '/* var envira_gallery = [], */
var envira_galleries = [],
envira_gallery_images = {},
/* envira_isotopes = [], */
envira_isotopes_config = [],
envira_playing = false';
return $javascript;
}
@dimensionmedia
dimensionmedia / loop-blog.php
Created May 2, 2017 18:10
Envira Ajax Hack
/* find the shortcode in the post and extract the envira gallery ID */
/* you might have to adjust this logic to account for things, but you get the idea */
$pattern = get_shortcode_regex();
if ( preg_match_all( '/'. $pattern .'/s', $blog_query->post->post_content, $matches ) ) {
if (preg_match('/"([^"]+)"/', $matches[3][0], $m)) {
$gallery_id = $m[1];
} else {
//preg_match returns the number of matches found,
//so if here didn't match pattern
@dimensionmedia
dimensionmedia / example-1.txt
Last active April 29, 2017 20:08
Coding Principles - 4/29/17
<html>
<head>
<title>This is a JavaScript Example</title>
<script language="JavaScript">
var word = prompt("Word To Check", "");
function pal() {
if ( word == word.split('').reverse().join('') ) {
@dimensionmedia
dimensionmedia / envira-gallery-load-lightbox-from-link.php
Created April 21, 2017 14:30
Envira Gallery - Load Lightbox from Link (Revised)