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 | |
/** | |
* PHP OOP sample | |
* Tutorial here: http://code.tutsplus.com/tutorials/object-oriented-php-for-beginners--net-12762 | |
*/ | |
class MyClass | |
{ | |
public $variable; | |
public static $static_variable; |
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
var Hello = function() | |
{ | |
this.a = 1; | |
} | |
Hello.prototype.dolly = function() | |
{ | |
this.b = 2; | |
this.c = this.a + this.b; |
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
<html> | |
<head> | |
<title>Sample jQuery Plugin</title> | |
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> | |
<script type="text/javascript" src="plugin.js"></script> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { |
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 | |
/** | |
* $pos = get cut position based on fixed position ($fixed), | |
* but without break last word | |
*/ | |
$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; | |
$excerpt = ''; | |
$fixed = 25; |
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 | |
// editor level | |
$editor = get_role('editor'); | |
$editor->add_cap('edit_theme_options'); | |
register_setting('opt-group', 'opt_1'); | |
register_setting('opt-group', 'opt_2'); | |
add_filter('option_page_capability_opt-group', 'opt_group_editor_save_options'); | |
function opt_group_editor_save_options($cap) { |
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 | |
add_filter('pre_get_posts', 'namespace_add_custom_types'); | |
function namespace_add_custom_types( $query ) { | |
if( !is_admin() && is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { | |
$query->set( 'post_type', array( | |
'post', 'nav_menu_item', 'your-custom-post-type-here' | |
)); | |
return $query; |
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
<link href="style.css" rel="stylesheet"> | |
<h1>Expandable Search Form</h1> | |
<h3>Demo 1</h3> | |
<form> | |
<input type="search" placeholder="Search"> | |
</form> | |
<h3>Demo 2</h3> | |
<form id="demo-2"> |
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 | |
$args = array( | |
'post_type' => 'product', | |
'posts_per_page' => -1, // -1 mean show all data | |
'post_status' => 'publish', | |
// with multiple taxonomy, if not just get rid the relation and put only one taxonomy array | |
'tax_query' => array( | |
'relation' => 'AND', | |
array( |
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 | |
add_action('init', 'generate_new_thumbnail' ); | |
function generate_new_thumbnail() | |
{ | |
add_theme_support('post-thumbnails'); | |
// the last argument is to crop or no | |
add_image_size('post-thumb', 620, 207, true); | |
add_image_size('home-thumb', 220, 180, true); |
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 | |
/* Field */ | |
add_action( 'show_user_profile', 'my_show_extra_profile_fields' ); | |
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' ); | |
function my_show_extra_profile_fields( $user ) { | |
?> | |
<h3>Extra profile information</h3> | |
<table class="form-table"> |
OlderNewer