Permalink
Browse files

Added Some Chapter 7 Code

  • Loading branch information...
jcasabona committed Mar 24, 2014
1 parent 04c7f93 commit 40365fd59c4cb341cc7637715764f8636c636536
@@ -0,0 +1,82 @@
.wpcf7 form{
text-align: left;
font-size: 1.25em;
max-width: 95%;
}
.wpcf7 form div{
margin: 15px 0;
text-align: left;
}
.wpcf7 form div label{
text-align: left;
max-width: 98%;
display: block;
font-size: 1.4em;
font-weight: bold;
}
.wpcf7 form div input, .wpcf7 form div select, .wpcf7 form div textarea{
padding: 5px;
width: 95%;
}
.wpcf7 form div input[type='checkbox'], .wpcf7 form div input[type='radio']{
width: auto;
}
.wpcf7 form div textarea{
height: 150px;
}
.wpcf7 form div input[type="submit"]{
width: 100%;
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
background: -webkit-linear-gradient(#b5b5b5 0%, #eeeded 100%);
background: -webkit-linear-gradient(#b5b5b5, #eeeded);
background: linear-gradient(#b5b5b5, #eeeded);
border: 1px solid #999999;
}
.wpcf7 form div input[type="submit"]:hover{
border: 1px solid #CFCFCF;
}
@media screen and (min-width: 40.688em){
.wpcf7 form{
margin: 10px auto;
width: 80%;
}
.wpcf7 form div{
padding: 10px 0;
clear: left;
}
.wpcf7 form .wpcf7-list-item{
width: 48%;
float: left;
margin: 10px 0;
}
.wpcf7 form div label{
font-size: 1em;
font-weight: normal;
}
.wpcf7 form div input, .wpcf7 form div select, .wpcf7 form div textarea{
width: 55%;
margin-left: 2%;
}
.wpcf7 form div input[type='checkbox'], .wpcf7 form div input[type='radio']{
width: auto;
}
.wpcf7 form div input[type="submit"]{
width: 50%;
margin: 0 2%;
}
}
@@ -0,0 +1,12 @@
<?php
function mf_gallery_style($css){
return preg_replace("#<style type=\'text/css\'>(.*?)</style>#s", "", $css);
}
add_filter( 'gallery_style', 'mf_gallery_style');
function mf_remove_br_gallery($output) {
return preg_replace('/<br style=(.*)>/mi','',$output);
}
add_filter( 'the_content', 'mf_remove_br_gallery', 11, 2);
@@ -0,0 +1,33 @@
.gallery{
margin: 0 auto;
text-align: center;
}
.gallery img{
max-width: 100%;
}
.gallery-icon img{
border: 1px solid #CCCCCC;
background: #FFFFFF;
padding: 5px;
}
@media screen and (min-width: 25.313em){
.gallery-icon{
float: left;
margin: 10px 2%;
width: 45%;
}
}
@media screen and (min-width: 51.5em){
.gallery-icon{
width: 30%;
margin: 10px 1%;
}
}
@media screen and (min-width: 76.625em){
.gallery-icon{
width: 22%;
}
}
@@ -0,0 +1,14 @@
<?php
add_shortcode('mf_gmap', 'mf_google_maps');
function mf_google_maps($atts, $content=null){
//Argumente aus dem Shortcode extrahieren
extract(shortcode_atts(array('address' => '132 Hawthorne Street San Francisco, CA 94107', 'width' => 800, 'height' => 600), $atts));
$map= '<div class="mf-responsive-map"><iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.google.com/maps?q='.$address.'&output=embed"></iframe>';
if($content != null){
$map.= '<br/>'.$content;
}
$map.= "</div>";
return $map;
}
@@ -0,0 +1,17 @@
.mf-responsive-map {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.mf-responsive-map iframe,
.mf-responsive-map object,
.mf-responsive-map embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
@@ -0,0 +1,98 @@
<?php
/*
Plugin Name: Millennium Flüge – Produktseite
Plugin URI: http://millenniumflights.com
Description: Ein einfaches Plugin, das in WordPress unter Verwendung von Cus-tom Post Types Produkte erzeugt und anzeigt!
Author: Joe Casabona
Version: 1.0
Author URI: http://www.casabona.org
*/
/*Set-up*/
define('MFP_PATH', WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/' );
define('MFP_NAME', "Millenium Flüge - Produkte");
/*Dateien einbinden*/
require_once('mf-products-cpt.php');
function mfp_get_products(){
$products= '<div class="mf-catalog">';
$args= "post_type=products";
$catalog= new WP_Query($args);
while($catalog->have_posts()) : $catalog->the_post();
$img= mfp_get_image();
$price= mfp_get_the_price($post->ID);
print_r($post);
$products.='<div class="mf-product">'.$img.'
<p><strong>'. get_the_title() .'</strong>: '. get_the_excerpt() .'</p>
<p class="price">'. $price .'</p>
</div>';
endwhile;
wp_reset_postdata();
$products.= '</div>';
return $products;
}
/**Shortcode**/
function mfp_shortcode($atts, $content=null){
$products= mfp_get_products();
return $products;
}
add_shortcode('mf_products', 'mfp_shortcode');
/**Template-Tag**/
function mfp_products_tag(){
print mfp_get_products();
}
add_action("admin_init", "mfp_meta_box");
function mfp_meta_box(){
add_meta_box("mf-products", "Product Price", "mfp_meta_options", "products", "side", "low");
}
function mfp_meta_options(){
global $post;
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
$custom = get_post_custom($post->ID);
$mfp_price = $custom["mfp_price"][0];
?>
<label>Price:</label><input name="mfp_price" value="<?php echo $mfp_price; ?>" />
<?php
}
add_action('save_post', 'mfp_save_custom_data');
function mfp_save_custom_data(){
global $post;
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){
return $post_id;
}else{
update_post_meta($post->ID, "mfp_price", $_POST["mfp_price"]);
}
}
function mfp_get_the_price($pid){
$custom = get_post_custom($pid);
return $custom["mfp_price"][0];
}
//fm korrigiert - >mfp_get_images - ursprünglich muss natürlich mfp_get_image() sein
function mfp_get_image($pid=NULL, $size='thumbnail'){
$url= wp_get_attachment_image_src( get_post_thumbnail_id($pid), $size);
return '<img src="'.$url[0] .'" alt="'. esc_attr(get_the_title($pid)) .'" />';
}
@@ -0,0 +1,25 @@
<?php
define('MFP_CPT_NAME', "Produkte");
define('MFP_CPT_SINGLE', "Produkt");
define('MFP_CPT_TYPE', "products");
add_theme_support('post-thumbnails', array('products'));
function mfp_register() {
$args = array(
'label' => __(MFP_CPT_NAME),
'singular_label' => __(MFP_CPT_SINGLE),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type(MFP_CPT_TYPE , $args );
register_taxonomy("product-category", array("products"), array("hierarchical" => true, "label" => "Produkt-Kategorien", "singular_label" => "Produktkategorie", "rewrite" => true));
}
add_action('init', 'mfp_register');
@@ -0,0 +1,25 @@
<?php
define('MFS_CPT_NAME', "Slider Images");
define('MFS_CPT_SINGLE', "Slider Image");
define('MFS_CPT_TYPE', "slider-image");
add_theme_support('post-thumbnails', array('slider-image'));
function mfs_register() {
$args = array(
'label' => __(MFS_CPT_NAME),
'singular_label' => __(MFS_CPT_SINGLE),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type(MFS_CPT_TYPE , $args );
}
add_action('init', 'mfs_register');
?>
@@ -0,0 +1,77 @@
<?php
/*
Plugin Name: Responsive Image Slider
Plugin URI: http://millenniumflights.com
Description: Ein einfaches Plugin, das den FlexSlider (http://flex.madebymufffin.com/) in WordPress integriert und dabei auf Custom Post Types setzt!
Author: Joe Casabona
Version: 1.0
Author URI: http://www.casabona.org
*/
/*Set-up*/
define('MFS_PATH', WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/' );
define('MFS_NAME', "Responsive Image Slider");
/*Dateien einbinden */
require_once('mf-image-slider-cpt.php');
function mfs_enqueue_scripts(){
wp_enqueue_script('mf-image-slider', MFS_PATH.'jquery.flexslider-min.js', array('jquery'));
wp_enqueue_style('mf-image-slider-css', MFS_PATH.'flexslider.css');
}
add_action('wp_enqueue_scripts', 'mfs_enqueue_scripts');
function mfs_script(){
print '<script type="text/javascript" charset="utf-8">
jQuery(window).load(function() {
jQuery(".flexslider").flexslider();
});
</script>';
}
add_action('wp_head', 'mfs_script');
function mfs_get_slider(){
$slider= '<div class="flexslider">
<ul class="slides">';
$args= "post_type=slider-image";
$slides= new WP_Query($args);
while($slides->have_posts()) : $slides->the_post();
$img= get_the_post_thumbnail( $post->ID, 'large' );
$slider.='<li>'.$img.'
<p class="flex-caption"><strong>'. get_the_title() .'</strong><br/>'. get_the_content() .'</p>
</li>';
endwhile;
wp_reset_postdata();
$slider.= '</ul>
</div>';
return $slider;
}
/**Shortcode**/
function mfs_shortcode($atts, $content=null){
$slider= mfs_get_slider();
return $slider;
}
add_shortcode('mf_slider', 'mfs_shortcode');
/**Template-Tag**/
function mfs_slider_tag(){
print mfs_get_slider();
}

0 comments on commit 40365fd

Please sign in to comment.