Example: SCSS / SASS
SCSS
// SCSS
#field_2_5 {
label.gfield_label {
display: none;
}
&.here, div.ginput_container {
margin-left: 10px;
}
}
@import "compass/reset";
// variables
$colorGreen: #008000;
$colorGreenDark: darken($colorGreen, 10);
@mixin container {
max-width: 980px;
}
// mixins with parameters
@mixin button( $color:green ) {
@if ( $color == green ) {
background-color: #008000;
}
@else if ( $color == red ) {
background-color: #B22222;
}
}
button {
@include button( red );
@include border( 1px solid #999999);
}
div,
.navbar,
#header,
input[type="input"] {
font-family: "Helvetica Neue", Arial, sans-serif;
width: auto;
margin: 0 auto;
display: block;
}
.row-12 > [class*="spans"] {
border-left: 1px solid #B5C583;
}
// nested definitions
ul {
width: 100%;
padding: {
left: 5px;
right: 5px;
}
left: 15px;
right: 15px;
li {
float: left;
margin-right: 10px;
.home:last-child {
background: url(http://placehold.it/20) scroll no-repeat 0 0;
background: url('http://placehold.it/20') scroll no-repeat 0 0;
}
}
}
.banner {
@extend .container;
}
a {
color: $colorGreen;
&:hover { color: $colorGreenDark; }
&:visited { color: #c458cb; }
}
@for $i from 1 through 5 {
.span#{$i} {
width: 20px*$i;
}
}
@mixin mobile {
@media screen and (max-width : 600px) {
@content;
}
}
SASS
// SASS
// No semi-colons, no squiggly brackets, indentation matters
#field_2_5
label.gfield_label
display: none
&.here, div.ginput_container
margin-left: 10px
@import "compass/reset"
// variables
$colorGreen: #008000
$colorGreenDark: darken($colorGreen, 10)
@mixin container
max-width: 980px
// mixins with parameters
@mixin button( $color:green )
@if ( $color == green )
background-color: #008000
@else if ( $color == red )
background-color: #B22222
button
@include button( red )
@include border( 1px solid #999999)
div,
.navbar,
#header,
input[type="input"]
font-family: "Helvetica Neue", Arial, sans-serif
width: auto
margin: 0 auto
display: block
.row-12 > [class*="spans"]
border-left: 1px solid #B5C583
// nested definitions
ul
width: 100%
padding:
left: 5px
right: 5px
left: 15px
right: 15px
li
float: left
margin-right: 10px
.home:last-child
background: url(http://placehold.it/20) scroll no-repeat 0 0
background: url('http://placehold.it/20') scroll no-repeat 0 0
.banner
@extend .container
a
color: $colorGreen
&:hover {
color: $colorGreenDark
&:visited {
color: #c458cb
@for $i from 1 through 5
.span#{$i}
width: 20px*$i
@mixin mobile
@media screen and (max-width : 600px)
@content
Example: CSS
#tagged, .tag a {
color: #3B3F42;
-webkit-transition: all .1s ease-in;
-moz-transition: all .1s ease-in;
-o-transition: all .1s ease-in;
-ms-transition: all .1s ease-in;
transition: all .1s ease-in;
}
a:hover {
color: #3B3F42;
width: 100%;
text-decoration: underline;
border-bottom: 3px solid #35ab43;
font-size: 2em;
background: #444444 url(images/background.png) no-repeat top left;
background: #444444 url("images/background.png") no-repeat top left;
}
a:focus {
color: #3B3F42;
font-size: 2.5em;
border: 1px solid #aaa;
}
div:first-child {
color: #3B3F42;
}
Example: JS
// with jQuery
get_stamp = function( str ) {
var stamp = new Date( str );
stamp = stamp.getTime() / 1000;
stmp += 'this string\'s with an escaped-type character';
stmp2 = "this string's with an ... or you can change the quotes";
return stamp;
}
if ( this.variable == 4 || num != 9 || ( this.variable == 6 && num != 8 ) ) {}
if (this.variable===4||num!=9||(this.variable!==6&&num<=8)){}
var num_vr = 4 * $num / 27 + num2 - 6.3,
num_vr=4*$num/27+num2-6.3,
hey = $(this);
myfuncname = function() {
// run code
}
tp4.jPlayer({ready:function(){$(this).jPlayer('setMedia',{oga:ap+'04'+og,m4a:ap+'04'+ma,mp3:ap+'04'+m3});},swfPath:'assets',preload:'auto',supplied:'oga,m4a,mp3',wmode:'window',smoothPlayBar:true});
function init_highlight(block, flags) {
try {
if (block.className.search(/\bno\-highlight\b/) != -1)
return processBlock(block.function, true, 0x0F) + ' class=""';
} catch (e) {
/* handle exception */
var e4x = ''
+ '<div>Example'
+ '<p>1234</p></div>';
e++;
h--;
}
for (var i = 0 / 2; i < classes.length; i++) { // "0 / 2" should not be parsed as regexp
if (checkCondition(classes[i]) === undefined)
return /\d+[\s/]/g;
}
console.log(Array.every(classes, Boolean));
}
Builder: Add Classes to Modules
/**
* Add classes to Builder modules
*
* Function name calling shouldn't be 'it_builder_loaded'
* in case parent theme is using it already.
*/
if ( ! function_exists( 'oz_builder_loaded' ) ) {
function oz_builder_loaded() {
// --> module label class
builder_register_module_style( 'content', 'Blue ', 'content-blue' );
builder_register_module_style( 'widget-bar', 'Blue (full width)', 'widget-bar-blue' );
builder_register_module_style( 'navigation', 'Subnav Blue', 'subnav-blue' );
builder_register_module_style( 'html', 'Blue Background', 'html-blue' );
builder_register_module_style( 'image', 'Blue Background (full width)', 'image-blue');
builder_register_module_style( 'header', 'White Header', 'header-white');
builder_register_module_style( 'footer', 'White Footer', 'footer-white');
}
add_action( 'it_libraries_loaded', 'oz_builder_loaded' );
}
No longer using Builder. It was good while they kept it up to date. Not so much now.
Example: PHP 2
<?php
</*
* With embedded HTML
*/
function show_metabox_syntax() {
global $post;
extract( $this->metaboxes['syntax']['field'] );
$meta = get_post_meta($post->ID, $id, true);
// echo $meta;
?>
<input type="hidden" name="codesnips_syntax_metabox_nonce" value="<?php
echo wp_create_nonce(basename(__FILE__)) ?>" />
<div class="lang-syntax-wrap">
<div class="codesnips_field_type_<?php echo str_replace(' ', '_', $type) ?>">
<?php foreach ($options as $key => $option) { ?>
<span class="lang-syntax <?php echo $key ?>">
<input id="<?php echo $key ?>" type="radio" name="<?php
echo $id ?>" value="<?php echo $key ?>"<?php
echo ($meta == $key ? ' checked="checked"' : '') ?> />
<label for="<?php echo $key ?>"><?php echo $option ?></label>
</span>
<?php }// end foreach ?>
<?php echo $desc != '' ? '<br><span class="desc">' . stripslashes($desc) . '</span>' : '' ?>
<div class="clr"></div>
</div>
</div>
<?php
}
Example: WP
define( 'DS', DIRECTORY_SEPARATOR ); // DIRECTORY_SEPARATOR
define( 'OZ_CONTENT_DIR', 'assets' ); //
define( 'WP_CONTENT_DIR', ABSPATH .OZ_CONTENT_DIR ); // /svr-root/path-to/site-root/assets
define( 'WP_CONTENT_URL', WP_SITEURL.DS.OZ_CONTENT_DIR ); // http://site.dev/assets
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR.DS.'plugins' ); // /svr-root/path-to/site-root/assets/plugins
define( 'WP_PLUGIN_URL', WP_CONTENT_URL.DS.'plugins' ); // http://site.dev/assets/plugins
define( 'UPLOADS', OZ_CONTENT_DIR.DS.'files' ); // http://site.dev/assets/files
Example: PHP
define( 'THISHOMEY', 'this is a homey');
echo THISHOMEY;
require_once 'Zend/Uri/Http.php';
namespace Location\Web;
interface Factory
{
static function _factory();
}
abstract class URI extends BaseURI implements Factory
{
abstract function test();
$num_var = (4 * $num) / 27 + $num2 - 6.3;
$num_var=(4*$num)/27+$num2-6.3;
$this->object->item = 0;
$concat = 'This string get\'s to ';
$concat .= 'be added to by another line';
$morect = "Another for \"me\" and you!";
/**
* Returns a URI
*
* @return URI
*/
static public function _factory($stats = array(), $uri = 'http')
{
echo __METHOD__;
$uri = explode(':', $uri, 0b10);
$schemeSpecific = isset($uri[1]) ? $uri[1] : '';
$desc = 'Multiline
description == | = | != | === | !== | description
description';
// Security check
if (!ctype_alnum($scheme)) {
throw new Zend_Uri_Exception('Illegal scheme');
}
return [
'uri' => $uri,
'value' => null,
];
}
if ( $var == 'timed' || $var != '' ( $var === '' && $var !== '' ) ) {}
if ($var=='timed'||$var!=''($var===''&&$var!=='')){}
if ( $var < '' || $var > '' || $var <= '' || $var => '' ) {}
if ($var<''||$var>''||$var<=''||$var=>''){}
}
__halt_compiler ();
/*
datahere
datahere
datahere
datahere
*/