Advertisement
Guest User

functions.php

a guest
Mar 7th, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.49 KB | None | 0 0
  1. <?php
  2. /**
  3.  * CleanTelligent functions and definitions
  4.  *
  5.  * @package WordPress
  6.  * @subpackage CleanTelligent
  7.  *
  8.  */
  9.  
  10. function imgSlider ($atts, $content = null, $code) {
  11.     extract(shortcode_atts(array(
  12.         "id" => ""
  13.     ), $atts));
  14.     $content = do_shortcode($content);
  15.     $path = get_bloginfo('stylesheet_directory');
  16.     $path .= '/images/slider-shadow.png';
  17.     $slider = <<<EOF
  18. <div class='slider' id='slider-{$id}'>{$content}</div>
  19. <div class='shadow-wrap'><img class='shadow' src='{$path}' /></div>
  20. <div id='slider-nav-{$id}'>
  21. <a href="#" id="next-{$id}"><img src='/wp-content/themes/cleantelligent/images/next.png' alt='next' /></a>
  22. <div id='slider-nav-pager-{$id}'></div>
  23. <a href="#" id="prev-{$id}"><img src='/wp-content/themes/cleantelligent/images/prev.png' alt='previous' /></a>
  24. </div>
  25. <script type='text/javascript'>
  26.     jQuery('#slider-{$id}').cycle({
  27.         next: '#next-{$id}',
  28.         prev: '#prev-{$id}',
  29.         fx: 'fade',
  30.         timeout: 30000000,
  31.         pause: 1,
  32.         pager: '#slider-nav-pager-{$id}',
  33.         height: '433px',
  34.         width: '960px'
  35.     })
  36. </script>
  37. EOF;
  38.     return $slider;
  39. }
  40. add_shortcode('img_slider', 'imgSlider');
  41.  
  42. function imgSlide ($atts, $content = null, $code) {
  43.     extract(shortcode_atts(array(
  44.         'header' => ''
  45.     ), $atts));
  46.     $content = do_shortcode($content);
  47.     return "<div class='slide'><div class='slide-header'>{$header}</div>{$content}</div>";
  48. }
  49. add_shortcode('img_slide', 'imgSlide');
  50.  
  51. function imgSlideDesc ($atts, $content = null, $code) {
  52.     $content = do_shortcode($content);
  53.     return "<div class='slide-desc'>{$content}</div>";
  54. }
  55. add_shortcode('img_slide_desc', 'imgSlideDesc');
  56.  
  57.  
  58.  
  59.  
  60.  
  61. function tabs ($atts, $content = null, $code) {
  62.     $content = do_shortcode($content);
  63.     return "<div id='tabs'><div class='tab-wrap'>{$content}</div></div>";
  64. }
  65. add_shortcode('Tabs', 'tabs');
  66.  
  67. function tabs_title_item ($atts, $content = null, $code) {
  68.     extract(shortcode_atts(array(
  69.         'class' => '',
  70.         'target' => ''
  71.     ), $atts));
  72.     $content = do_shortcode($content);
  73.     return "<li class='{$class}'><a href='{$target}'>{$content}</a></li>";
  74. }
  75. add_shortcode('Tabs_Title_Item', 'tabs_title_item');
  76.  
  77. function tabs_body ($atts, $content = null, $code) {
  78.     extract(shortcode_atts(array(
  79.         'name' => '',
  80.     ), $atts));
  81.     $content = do_shortcode($content);
  82.     return "<div id='{$name}'>{$content}</div>";
  83. }
  84. add_shortcode('Tabs_Body', 'tabs_body');
  85.  
  86.  
  87. function entry_title ($atts, $content = null, $code) {
  88.     $content = do_shortcode($content);
  89.     return "<h1 class='entry-title'>{$content}</h1>";
  90. }
  91. add_shortcode('Page_Title', 'entry_title');
  92.  
  93. function entry_second ($atts, $content = null, $code) {
  94.     $content = do_shortcode($content);
  95.     return "<h3 class='entry-second'>{$content}</h3><hr class='rh'>";
  96. }
  97. add_shortcode('Page_Secondary', 'entry_second');
  98.  
  99.  
  100.  
  101. add_action( 'init', 'webinars_post_type' );
  102. function webinars_post_type() {
  103.     register_post_type( 'webinars',
  104.         array(
  105.             'labels' => array(
  106.                 'name' => __( 'Webinars' ),
  107.                 'singular_name' => __( 'Webinar' )
  108.             ),
  109.             'public' => true,
  110.             'has_archive' => true,
  111.             'rewrite' => array('slug' => 'webinars')
  112.         )
  113.     );
  114. }
  115.  
  116.  
  117. add_action( 'init', 'webinars_archive_post_type' );
  118. function webinars_archive_post_type() {
  119.       $labels = array(
  120.         'name' => _x( 'Categories', 'taxonomy general name' ),
  121.         'singular_name' => _x( 'Category', 'taxonomy singular name' ),
  122.         'search_items' =>  __( 'Search Categories' ),
  123.         'all_items' => __( 'All Categories' ),
  124.         'parent_item' => __( 'Parent Category' ),
  125.         'parent_item_colon' => __( 'Parent Category:' ),
  126.         'edit_item' => __( 'Edit Category' ),
  127.         'update_item' => __( 'Update Category' ),
  128.         'add_new_item' => __( 'Add New Category' ),
  129.         'new_item_name' => __( 'New Category Name' ),
  130.         'menu_name' => __( 'Categories' )
  131.       );
  132.  
  133.     register_taxonomy('webinar-categories',array('web'), array(
  134.         'hierarchical' => true,
  135.         'labels' => $labels,
  136.         'show_ui' => true,
  137.         'query_var' => true,
  138.         'rewrite' => array( 'slug' => 'webinar-categories' )
  139.     ));
  140.     register_post_type( 'webinar-archives',
  141.         array(
  142.             'labels' => array(
  143.                 'name' => __( 'Webinar Archives' ),
  144.                 'singular_name' => __( 'Webinar Archive' )
  145.             ),
  146.             'public' => true,
  147.             'has_archive' => true,
  148.             'rewrite' => array('slug' => 'webinar-archives'),
  149.             'taxonomies' => array('webinar-categories'),
  150.             'supports' => array( 'title', 'editor', 'excerpt' )
  151.         )
  152.     );
  153. }
  154.  
  155.  
  156.  
  157.  
  158. function custom_excerpt_length( $length ) {
  159.     return 100;
  160. }
  161. add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
  162.  
  163.  
  164. add_action( 'add_meta_boxes', 'webinar_add_custom_box' );
  165. function webinar_add_custom_box() {
  166.     add_meta_box(
  167.         'register_link',
  168.         __( 'Register Link for GoToMeeting', 'webinar_textdomain' ),
  169.         'webinar_inner_custom_box',
  170.         'webinars',
  171.         'advanced',
  172.         'default'
  173.     );
  174. }
  175.  
  176. function webinar_inner_custom_box( $post ) {
  177.  
  178.   // Use nonce for verification
  179.   wp_nonce_field( plugin_basename( __FILE__ ), 'webinar_nonce' );
  180.   $current_value = get_post_meta($post->ID, 'register_link', true);
  181.   // The actual fields for data entry
  182.   echo '<label for="register_link">';
  183.        _e("GoToMeeting Register Link", 'webinar_textdomain' );
  184.   echo '</label> ';
  185.   echo '<input type="text" id="register_link" name="register_link" value="' . $current_value . '" size="25" />';
  186. }
  187.  
  188. add_action('save_post', 'webinar_save_postdata');
  189. function webinar_save_postdata( $post_id ) {
  190.   if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
  191.       return;
  192.   if ( !wp_verify_nonce( $_POST['webinar_nonce'], plugin_basename( __FILE__ ) ) )
  193.       return;
  194.   if ( 'page' == $_POST['webinars'] )
  195.   {
  196.     if ( !current_user_can( 'edit_page', $post_id ) )
  197.         return;
  198.   }
  199.   else
  200.   {
  201.     if ( !current_user_can( 'edit_post', $post_id ) )
  202.         return;
  203.   }
  204.   $mydata = $_POST['register_link'];
  205.   update_post_meta($post_id, 'register_link', $mydata);
  206.  
  207. }
  208.  
  209.  
  210. function sb_get_page_nav($post) {
  211.     $pages = get_pages('child_of='.$post->ID);
  212.     if($post->post_parent != 0 && !empty($pages)) {
  213.         $parent = get_page($post->post_parent);
  214.         if(wp_get_nav_menu_object($parent->post_title)) {
  215.             $nav['title'] = $parent->post_title;
  216.         } else {
  217.             $grandParent = get_page($parent->post_title);
  218.             $nav['title'] = $grandParent->post_title;
  219.         }
  220.     } else {
  221.         $parent = get_page($post->post_parent);
  222.         $grandparent = get_page($parent->post_parent);
  223.         if(wp_get_nav_menu_object($post->post_title)) {
  224.             $nav['title'] = $post->post_title;
  225.         } elseif(wp_get_nav_menu_object($parent->post_title)) {
  226.             $nav['title'] = $parent->post_title;
  227.         } elseif($parent->post_parent != 0) {
  228.             $nav['title'] = $grandparent->post_title;
  229.         } else {
  230.             $nav['title'] = $post->post_title;
  231.             $nav['no_nav'] = true;
  232.         }
  233.     }
  234.     return $nav;
  235. }
  236.  
  237. function my_admin_init() {
  238.     $pluginfolder = get_bloginfo('stylesheet_directory');
  239.     /*wp_enqueue_script('jquery');*/
  240.     wp_enqueue_script('jquery-ui-core');
  241.    
  242.     wp_enqueue_script('jquery-ui-datepicker', $pluginfolder . '/js/jquery-ui-1.8.20.custom.min.js', array('jquery', 'jquery-ui-core') );
  243.     wp_enqueue_style('jquery.ui.theme', $pluginfolder . '/js/ui-lightness/jquery-ui-1.8.20.custom.css');
  244. }
  245. add_action('admin_init', 'my_admin_init');
  246.  
  247. $prefix = 'wb_';
  248.  
  249. $meta_boxes['web-date'] = array(
  250.     'id' => 'web-date',
  251.     'title' => 'Webinar Date',
  252.     'page' => 'webinars',
  253.     'context' => 'normal',
  254.     'priority' => 'high',
  255.     'fields' => array(
  256.         array(
  257.             'name' => 'Webinar Date',
  258.             'id' => $prefix . 'web-date',
  259.             'type' => 'date'
  260.         ),
  261.         array(
  262.             'name' => 'Webinar Start Time',
  263.             'id' => $prefix . 'web-time',
  264.             'type' => 'select',
  265.             'options' => array(
  266.                 array('value' => '7', 'name' => '7:00 am'),
  267.                 array('value' => '7.5', 'name' => '7:30 am'),
  268.                 array('value' => '8', 'name' => '8:00 am'),
  269.                 array('value' => '8.5', 'name' => '8:30 am'),
  270.                 array('value' => '9', 'name' => '9:00 am'),
  271.                 array('value' => '9.5', 'name' => '9:30 am'),
  272.                 array('value' => '10', 'name' => '10:00 am'),
  273.                 array('value' => '10.5', 'name' => '10:30 am'),
  274.                 array('value' => '11', 'name' => '11:00 am'),
  275.                 array('value' => '11.5', 'name' => '11:30 am'),
  276.                 array('value' => '12', 'name' => '12:00 pm'),
  277.                 array('value' => '12.5', 'name' => '12:30 pm'),
  278.                 array('value' => '13', 'name' => '1:00 pm'),
  279.                 array('value' => '13.5', 'name' => '1:30 pm'),
  280.                 array('value' => '14', 'name' => '2:00 pm'),
  281.                 array('value' => '14.5', 'name' => '2:30 pm'),
  282.                 array('value' => '15', 'name' => '3:00 pm')
  283.             )
  284.         ),
  285.         array(
  286.             'name' => 'Webinar End Time',
  287.             'id' => $prefix . 'web-end-time',
  288.             'type' => 'select',
  289.             'options' => array(
  290.                 array('value' => '7.5', 'name' => '7:30 am'),
  291.                 array('value' => '8', 'name' => '8:00 am'),
  292.                 array('value' => '8.5', 'name' => '8:30 am'),
  293.                 array('value' => '9', 'name' => '9:00 am'),
  294.                 array('value' => '9.5', 'name' => '9:30 am'),
  295.                 array('value' => '10', 'name' => '10:00 am'),
  296.                 array('value' => '10.5', 'name' => '10:30 am'),
  297.                 array('value' => '11', 'name' => '11:00 am'),
  298.                 array('value' => '11.5', 'name' => '11:30 am'),
  299.                 array('value' => '12', 'name' => '12:00 pm'),
  300.                 array('value' => '12.5', 'name' => '12:30 pm'),
  301.                 array('value' => '13', 'name' => '1:00 pm'),
  302.                 array('value' => '13.5', 'name' => '1:30 pm'),
  303.                 array('value' => '14', 'name' => '2:00 pm'),
  304.                 array('value' => '14.5', 'name' => '2:30 pm'),
  305.                 array('value' => '15', 'name' => '3:00 pm'),
  306.                 array('value' => '15.5', 'name' => '3:30 pm'),
  307.                 array('value' => '16', 'name' => '4:00 pm'),
  308.                 array('value' => '16.5', 'name' => '4:30 pm'),
  309.                 array('value' => '17', 'name' => '5:00 pm'),
  310.             )
  311.         )
  312.     )
  313. );
  314.  
  315.  
  316. add_action('admin_menu', 'clean_add_box');
  317.  
  318. // Add meta box
  319. function clean_add_box() {
  320.     global $meta_boxes;
  321.    
  322.     foreach( $meta_boxes as $meta_box ) {
  323.         if(!is_array($meta_box['page']) ) {
  324.             add_meta_box($meta_box['id'], $meta_box['title'], 'clean_show_meta_box', $meta_box['page'], $meta_box['context'], $meta_box['priority'],$meta_box);
  325.         } else {
  326.             foreach($meta_box['page'] as $page) {
  327.                 add_meta_box($meta_box['id'], $meta_box['title'], 'clean_show_meta_box', $page, $meta_box['context'], $meta_box['priority'],$meta_box);
  328.             }
  329.         }
  330.     }
  331. }
  332. function clean_show_meta_box( $post, $meta_box ) {
  333.     // Use nonce for verification
  334.     clean_meta_boxes($meta_box['args']);
  335. }
  336.  
  337. function clean_field_types( $field, $meta ) {
  338.    
  339.     switch( $field['type'] ) {
  340.         case 'text':
  341.             echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '<br />', $field['desc'];
  342.             break;
  343.         case 'textarea':
  344.             echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>', '<br />', $field['desc'];
  345.                
  346.             break;
  347.         case 'date':
  348.             echo '<script type="text/javascript">
  349.                jQuery(function($) {
  350.                    $(function() {
  351.                        $( "#'.$field['id'].'" ).datepicker({
  352.                            "dateFormat":"MM d, yy"
  353.                        });
  354.                    });
  355.                });
  356.            </script>';
  357.             if(!$meta) {
  358.                 $meta = '';
  359.             } else {
  360.                 $meta = date('F j, Y',$meta);
  361.             }
  362.             echo '<input readonly="readonly" id="'.$field['id'].'" type="text" size="40" name="'.$field['id'].'" value="'. $meta .'" /><br />' . $field['desc'];
  363.             break;
  364.         case 'upload':
  365.             echo '<script type="text/javascript">
  366.                jQuery(function($) {
  367.  
  368.                $("#'.$field['id'].'_button").click(function() {
  369.                 formfield = jQuery("#'.$field['id'].'").attr("name");
  370.                 tb_show("","media-upload.php?type=file&amp;TB_iframe=true");
  371.                  window.send_to_editor = function(html) {
  372.                         url = jQuery(html).attr("href");
  373.                         jQuery("#'.$field['id'].'").val(url);
  374.                         tb_remove();
  375.                    }
  376.                 return false;
  377.                });
  378.                $("#'.$field['id'].'").click(function() {
  379.                 formfield = jQuery("#'.$field['id'].'").attr("name");
  380.                 tb_show("","media-upload.php?type=file&amp;TB_iframe=true");
  381.                  window.send_to_editor = function(html) {  
  382.                         url = jQuery(html).attr("href");
  383.                         jQuery("#'.$field['id'].'").val(url);
  384.                         tb_remove();
  385.                    }
  386.                 return false;
  387.                  
  388.                });
  389.                 $("#'.$field['id'].'_button_remove").click(function() {
  390.                     $(this).siblings("#'.$field['id'].'").val("");
  391.                 });
  392.                // send url back to plugin editor
  393.  
  394.                
  395.  
  396.                });
  397.            </script>';
  398.             echo '<input readonly="readonly" id="'.$field['id'].'" type="text" size="40" name="'.$field['id'].'" value="'.$meta.'" />
  399. <input id="'.$field['id'].'_button" type="button" value="Upload File" /> <input id="'.$field['id'].'_button_remove" type="button" value="Remove File" /><br />' . $field['desc'];
  400.             break;
  401.         case 'image':
  402.             echo '<script type="text/javascript">
  403.                jQuery(function($) {
  404.  
  405.                $("#'.$field['id'].'_button").click(function() {
  406.                 formfield = jQuery("#'.$field['id'].'").attr("name");
  407.                 tb_show("","media-upload.php?type=image&amp;TB_iframe=true");
  408.                  window.send_to_editor = function(html) {
  409.                 imgurl = jQuery("img",html).attr("src");
  410.                 jQuery("#'.$field['id'].'").val(imgurl);
  411.                 tb_remove();
  412.                }
  413.                 return false;
  414.                });
  415.                $("#'.$field['id'].'").click(function() {
  416.                 formfield = jQuery("#'.$field['id'].'").attr("name");
  417.                 tb_show("","media-upload.php?type=image&amp;TB_iframe=true");
  418.                  window.send_to_editor = function(html) {
  419.                      imgurl = jQuery("img",html).attr("src");
  420.                      jQuery("#'.$field['id'].'").val(imgurl);
  421.                      tb_remove();
  422.                     }
  423.                 return false;
  424.                  
  425.                });
  426.                 $("#'.$field['id'].'_button_remove").click(function() {
  427.                     $(this).siblings("#'.$field['id'].'").val("");
  428.                 });
  429.                // send url back to plugin editor
  430.  
  431.                
  432.  
  433.                });
  434.            </script>';
  435.             echo '<input readonly="readonly" id="'.$field['id'].'" type="text" size="40" name="'.$field['id'].'" value="'.$meta.'" />
  436. <input id="'.$field['id'].'_button" type="button" value="Choose Image" /> <input id="'.$field['id'].'_button_remove" type="button" value="Remove Image" /><br />' . $field['desc'];
  437.             break;
  438.         case 'select':
  439.             echo '<select name="', $field['id'], '" id="', $field['id'], '">';
  440.             foreach ($field['options'] as $option) {
  441.                 echo '<option value="'.$option['value'].'"', $meta == $option['value'] ? ' selected="selected"' : '', '>', $option['name'], '</option>';
  442.             }
  443.             echo '</select>&nbsp;&nbsp;&nbsp;'.$field['desc'];
  444.             break;
  445.         case 'radio':
  446.             foreach ($field['options'] as $option) {
  447.                 echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];
  448.             }
  449.             break;
  450.         case 'checkbox':
  451.             echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
  452.             break;
  453.     }
  454. }
  455.  
  456. function clean_meta_boxes( $meta_boxes ) {
  457.     global $post;
  458.    
  459.     echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
  460.    
  461.     echo '<table class="form-table">';
  462.    
  463.     foreach ($meta_boxes['fields'] as $field) {
  464.        
  465.         if( $field['type'] == 'repeatable' ) {
  466.             echo '<tr>',
  467.             '<th colspan="2"><h2>',$field['name'],'</h2></th>','</tr>';
  468.             foreach($field['fields'] as $new_field) {
  469.                 echo '<tr>',
  470.                 '<th style="width:20%"><label for="', $new_field['id'], '">', $new_field['name'], '</label></th>',
  471.                 '<td>';
  472.                 clean_field_types( $new_field, $meta );
  473.                 echo '<td>',
  474.                 '</tr>';
  475.             }
  476.             echo '<tr>',
  477.             '<td style="width:20%">&nbsp;</td><td>',
  478.             '<input id="btnAdd" class="button-primary" type="button" value="Add ',$field['name'],'">',
  479.             '<input id="btnDel" class="button-secondary" type="button" value="Remove ',$field['name'],'">',
  480.             '</td>';
  481.         } else {
  482.             // get current post meta data
  483.             $meta = get_post_meta( $post->ID, $field['id'], true );
  484.            
  485.             echo '<tr>',
  486.                 '<th style="width:20%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
  487.                 '<td>';
  488.                 clean_field_types( $field, $meta );
  489.             echo '<td>',
  490.                 '</tr>';
  491.         }
  492.        
  493.        
  494.     }
  495.     echo '</table>';
  496. }
  497.  
  498.  
  499.  
  500. add_action('save_post', 'clean_save_data');
  501.  
  502. // Save data from meta box
  503. function clean_save_data( $post_id ) {
  504.     global $meta_boxes;
  505.     foreach( $meta_boxes as $meta_box ) {
  506.         if( ! is_array( $meta_box['page'] ) ) {
  507.             if( get_post_type( $post_id ) == $meta_box['page'] ) {
  508.                 $meta = $meta_box;
  509.                 clean_save_function($post_id, $meta);
  510.             }
  511.         } else {
  512.            
  513.             foreach( $meta_box['page'] as $page ) {
  514.                 if( get_post_type( $post_id ) == $page ) {
  515.                     $meta = $meta_box;
  516.                     clean_save_function($post_id, $meta);
  517.                 }
  518.             }
  519.         }
  520.        
  521.     }
  522.    
  523. }
  524.  
  525. function clean_save_function( $post_id, $meta ) {
  526.     // verify nonce        
  527.     if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) {
  528.         return $post_id;
  529.     }
  530.  
  531.     // check autosave
  532.     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
  533.         return $post_id;
  534.     }
  535.  
  536.     // check permissions
  537.     if ('page' == $_POST['post_type']) {
  538.         if (!current_user_can('edit_page', $post_id)) {
  539.             return $post_id;
  540.         }
  541.     } elseif (!current_user_can('edit_post', $post_id)) {
  542.         return $post_id;
  543.     }
  544.  
  545.     foreach ($meta['fields'] as $field) {
  546.        
  547.         if($field['type'] == 'date') {
  548.             $_POST[$field['id']] = strtotime($_POST[$field['id']]);
  549.         }
  550.        
  551.         $old = get_post_meta($post_id, $field['id'], true);
  552.         $new = $_POST[$field['id']];
  553.  
  554.         if ($new && $new != $old) {
  555.             update_post_meta($post_id, $field['id'], $new);
  556.         } elseif ('' == $new && $old) {
  557.             delete_post_meta($post_id, $field['id'], $old);
  558.         }
  559.     }
  560. }
  561.  
  562. // check autosave
  563. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
  564.  return $post_id;
  565. }
  566.  
  567.  
  568. //PLANS AND PRICING SHORTCODES
  569.  
  570. function left_plan ($atts, $content = null, $code) {
  571.     extract(shortcode_atts(array(
  572.         'price' => ''
  573.     ), $atts));
  574.     $content = do_shortcode($content);
  575.     $image = get_bloginfo('stylesheet_directory') . '/images/small.png';
  576.     return "
  577.     <div class='left-wrap'>
  578.     <div class='plan-img-wrap'><img src='{$image}' /></div>
  579.     <h2>{$content}<br>Package</h2>
  580.     <p>{$price}</p>
  581.     </div>
  582.     ";
  583. }
  584. add_shortcode('left', 'left_plan');
  585.  
  586.  
  587. function middle_plan ($atts, $content = null, $code) {
  588.     extract(shortcode_atts(array(
  589.         'price' => ''
  590.     ), $atts));
  591.     $content = do_shortcode($content);
  592.     $image = get_bloginfo('stylesheet_directory') . '/images/premium.png';
  593.     return "
  594.     <div class='middle-wrap'>
  595.     <div class='plan-img-wrap'><img src='{$image}' /></div>
  596.     <h2>{$content}<br>Package</h2>
  597.     <p>{$price}</p>
  598.     </div>
  599.     ";
  600. }
  601. add_shortcode('middle', 'middle_plan');
  602.  
  603.  
  604. function right_plan ($atts, $content = null, $code) {
  605.     extract(shortcode_atts(array(
  606.         'price' => ''
  607.     ), $atts));
  608.     $content = do_shortcode($content);
  609.     $image = get_bloginfo('stylesheet_directory') . '/images/ultimate.png';
  610.     return "
  611.     <div class='right-wrap'>
  612.     <div class='plan-img-wrap'><img src='{$image}' /></div>
  613.     <h2>{$content}<br>Package</h2>
  614.     <p>{$price}</p>
  615.     </div>
  616.     ";
  617. }
  618. add_shortcode('right', 'right_plan');
  619.  
  620.  
  621. function button_plan ($atts, $content = null, $code) {
  622.     extract(shortcode_atts(array(
  623.         'link' => ''
  624.     ), $atts));
  625.     $content = do_shortcode($content);
  626.     return "
  627.     <div class='plan-button'>
  628.     <a href='{$link}'>{$content}</a>
  629.     </div>
  630.     ";
  631. }
  632. add_shortcode('button', 'button_plan');
  633.  
  634.  
  635. function logos_plan ($atts, $content = null, $code) {
  636.     $content = do_shortcode($content);
  637.  
  638.     return "
  639.     <div class='plan-logos'>
  640.     {$content}
  641.     </div>
  642.     ";
  643. }
  644. add_shortcode('logos', 'logos_plan');
  645.  
  646.  
  647. function logos_img_plan ($atts, $content = null, $code) {
  648.     $content = do_shortcode($content);
  649.  
  650.     return "
  651.  
  652.     {$content}
  653.  
  654.     ";
  655. }
  656. add_shortcode('logos_image', 'logos_img_plan');
  657.  
  658.  
  659.  
  660. function remove_wpautp_home() {
  661.     if( is_front_page() ) {
  662.         remove_filter( 'the_content', 'wpautop');
  663.     }
  664. }
  665.  
  666. add_action('wp','remove_wpautp_home');
  667.  
  668. /*
  669.  * Plugin Name: Shortcode Empty Paragraph Fix
  670.  * Plugin URI: http://www.johannheyne.de/wordpress/shortcode-empty-paragraph-fix/
  671.  * Description: Fix issues when shortcodes are embedded in a block of content that is filtered by wpautop.
  672.  * Author URI: http://www.johannheyne.de
  673.  * Version: 0.1
  674.  * Put this in /wp-content/plugins/ of your Wordpress installation
  675.  */
  676. function shortcode_paragraph_insertion_fix($content) {  
  677.     $array = array (
  678.         '<p>[' => '[',
  679.         ']</p>' => ']',
  680.         ']<br />' => ']'
  681.     );
  682.     $content = strtr($content, $array);
  683.     return $content;
  684. }
  685. add_filter('the_content', 'shortcode_paragraph_insertion_fix');
  686.  
  687.  
  688.  
  689. add_shortcode('web', 'web');
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement