add_theme_support( 'woocommerce', array(
'thumbnail_image_width' => 200,
'gallery_thumbnail_image_width' => 100,
'single_image_width' => 500,
) );
// Remove default WC image sizes
function remove_wc_image_sizes() {
remove_image_size( 'woocommerce_thumbnail' );
remove_image_size( 'woocommerce_single' );
remove_image_size( 'woocommerce_gallery_thumbnail' );
remove_image_size( 'shop_catalog' );
remove_image_size( 'shop_single' );
remove_image_size( 'shop_thumbnail' );
}
add_action('init', 'remove_wc_image_sizes');
$args = array( 'posts_per_page' => 3 );
$lastposts = get_posts( $args );
foreach( $lastposts as $post ){ setup_postdata($post);
?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php
the_content();
}
wp_reset_postdata();
function disable_wp_auto_p( $content ) {
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
return $content;
}
add_filter( 'the_content', 'disable_wp_auto_p', 0 );
remove_action( 'template_redirect', 'maybe_redirect_404' );
$cc = new YourSite_Category_Calendar('your-category');
echo $cc->get_calendar();
<?php
class YourSite_CategoryCalendar {
var $category;
var $initial;
var $echo;
static function on_load() {
add_shortcode('category-calendar',array(__CLASS__,'shortcode'));
add_action('init',array(__CLASS__,'init'));
global $wp_rewrite;
$wp_rewrite->add_rule('^events/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?$',
'index.php?post_type=event&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&category_name=$matches[4]',
'top');
$wp_rewrite->flush_rules(false); // Remove this after you've got it working
}
static function shortcode($attributes) {
$attributes = wp_parse_args($attributes,array(
'category' => false,
));
$cc = new YourSite_CategoryCalendar($attributes['category']);
echo $cc->get_calendar();
}
static function init() {
register_post_type('event',array(
'hierarchical' => true,
'label' => 'Events',
'public' => true,
'show_ui' => true,
'query_var' => 'event',
'rewrite' => array('slug' => 'events'),
'supports' => array('title','editor','custom-fields'),
'taxonomies' => array('category'),
));
}
function __construct($category,$initial=true,$echo=true) {
$this->category = $category;
$this->initial = $initial;
$this->echo = $echo;
}
function get_calendar() {
add_filter('query',array(&$this,'query'));
ob_start();
get_calendar($this->category,$this->initial,$this->echo);
$calendar = ob_get_clean();
remove_filter('query',array(&$this,'query'));
list($header,$body) = explode('<tbody>',$calendar);
$find = '#(href="http://[^/]+)(/[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/)#';
$replace = '$1/events$2'.$this->category.'/"';
$body = preg_replace($find,$replace,$body);
return "{$header}<tbody>{$body}";
}
function query($query) {
if ($this->category) {
global $wpdb;
$find = "FROM {$wpdb->posts}\\s+WHERE";
$add =<<<SQL
INNER JOIN {$wpdb->term_relationships} calendar_term_relationship ON calendar_term_relationship.object_id={$wpdb->posts}.ID
INNER JOIN {$wpdb->term_taxonomy} calendar_term_taxonomy ON calendar_term_taxonomy.term_taxonomy_id=calendar_term_relationship.term_taxonomy_id
INNER JOIN {$wpdb->terms} calendar_term ON calendar_term.term_id=calendar_term_taxonomy.term_id
WHERE calendar_term_taxonomy.taxonomy='category' AND calendar_term.slug='%s' AND
SQL;
$replace = "FROM {$wpdb->posts} {$add} ";
$query = preg_replace("#{$find}#Us",$replace,$query);
$query = preg_replace("#post_type\s*=\s*'post'#","post_type='event'",$query);
$query = $wpdb->prepare($query,$this->category);
}
return $query;
}
}
YourSite_CategoryCalendar::on_load();
<?php
$servicesTax = get_post_meta($post->ID, 'services_tax', true);
echo $servicesTax;
?>
<?php
$servicesTax = get_post_custom_values( 'services_tax' );
foreach ( $servicesTax as $key => $value ) {
echo $value;
}; ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; ?>
$args = shortcode_atts(
array(
'rating' => 5,
'type' => 'rating',
'number' => 0,
),
$atts
);
// **************************************************** showCamera ****************************************************
// * *
// * showCamera will display the video feed from an IP-based camera. It accepts the following parameters: *
// * url - this is the url of the camera (http://dockcam.jkshay.com, for example) *
// * port - this is the port on which the camera is listening *
// * user - this is the username used to access the camera *
// * I suggest creating a camera user with the username 'guest' *
// * password - this is the password for the user specified above *
// * I suggest creating a password 'guest' for the user specified above *
// * width - this is the width of the videostream *
// * refresh - the number of milliseconds between image refreshes for IE *
// * class - a CSS class attribute applied to the videostream to facilitate styling via CSS *
// * *
// * NOTE: The credentials necessary to view your camera WILL be available to anyone who views the page source *
// * DO NOT USE ADMINISTRATOR CREDENTIALS UNLESS YOU WANT PEOPLE TO MESS WITH YOUR CAMERA *
// * *
// ********************************************************************************************************************
function showCamera($parameters)
{
// Define accepted parameters and convert to PHP variables
extract(shortcode_atts(array('url' => 'http://dockcam.jkshay.com', 'port' => '84', 'user' => 'guest', 'password' => 'guest', 'width' => '480', 'refresh' => '1000', 'class' => 'alignleft',), $parameters));
// Build string of HTML code to be returned by the function call
$results = "";
// IE is unable to accept the videostream.cgi viewing method, so we need to deliver an alternate viewing method
// We do this by introducing a javascript that will reload static images at a predefined rate
// Check if the user is using Internet Explorer
$results = $results."
<!--[if IE]>";
// Introduce javascript function to determine when to reload static image
$results = $results."
<script language='JavaScript' type='text/javascript'>
function reload()
{
setTimeout('reloadImg(\"refresh\")',".$refresh.")
};";
// Introduce javascript function to reload the static image
$results = $results."
function reloadImg(id)
{
var obj = document.getElementById(id);
var date = new Date();
obj.src = '".$url.":".$port."/snapshot.cgi?user=".$user."&pwd=".$password."&t=' + Math.floor(date.getTime()/1000);
}
</script>";
// Insert the HTML <img> tag to load the static image
$results = $results."
<img src='".$url.":".$port."/snapshot.cgi?user=".$user."&pwd=".$password."&t=' name='refresh' id='refresh' class=".$class." onload='reload(this)' onerror='reload(this)' width='".$width."'>";
// Close the 'User is using IE IF block'
$results = $results."
<![endif]-->";
// Check if the user is NOT using IE
$results = $results."
<![if !IE]>";
// Insert the HTML <img> tag to load the videostream
$results = $results."
<img src='".$url.":".$port."/videostream.cgi?user=".$user."&pwd=".$password."' class='".$class."' width='".$width."' alt='Live Feed'/>";
// Close the 'User is NOT using IE IF block'
$results = $results."
<![endif]>
";
// Return function results
return $results;
}
// Register this function with the WordPress framework as a shortcode
add_shortcode('showCamera', 'showCamera');
// ********************************************************************************************************************