Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * CleanTelligent functions and definitions
- *
- * @package WordPress
- * @subpackage CleanTelligent
- *
- */
- function imgSlider ($atts, $content = null, $code) {
- extract(shortcode_atts(array(
- "id" => ""
- ), $atts));
- $content = do_shortcode($content);
- $path = get_bloginfo('stylesheet_directory');
- $path .= '/images/slider-shadow.png';
- $slider = <<<EOF
- <div class='slider' id='slider-{$id}'>{$content}</div>
- <div class='shadow-wrap'><img class='shadow' src='{$path}' /></div>
- <div id='slider-nav-{$id}'>
- <a href="#" id="next-{$id}"><img src='/wp-content/themes/cleantelligent/images/next.png' alt='next' /></a>
- <div id='slider-nav-pager-{$id}'></div>
- <a href="#" id="prev-{$id}"><img src='/wp-content/themes/cleantelligent/images/prev.png' alt='previous' /></a>
- </div>
- <script type='text/javascript'>
- jQuery('#slider-{$id}').cycle({
- next: '#next-{$id}',
- prev: '#prev-{$id}',
- fx: 'fade',
- timeout: 30000000,
- pause: 1,
- pager: '#slider-nav-pager-{$id}',
- height: '433px',
- width: '960px'
- })
- </script>
- EOF;
- return $slider;
- }
- add_shortcode('img_slider', 'imgSlider');
- function imgSlide ($atts, $content = null, $code) {
- extract(shortcode_atts(array(
- 'header' => ''
- ), $atts));
- $content = do_shortcode($content);
- return "<div class='slide'><div class='slide-header'>{$header}</div>{$content}</div>";
- }
- add_shortcode('img_slide', 'imgSlide');
- function imgSlideDesc ($atts, $content = null, $code) {
- $content = do_shortcode($content);
- return "<div class='slide-desc'>{$content}</div>";
- }
- add_shortcode('img_slide_desc', 'imgSlideDesc');
- function tabs ($atts, $content = null, $code) {
- $content = do_shortcode($content);
- return "<div id='tabs'><div class='tab-wrap'>{$content}</div></div>";
- }
- add_shortcode('Tabs', 'tabs');
- function tabs_title_item ($atts, $content = null, $code) {
- extract(shortcode_atts(array(
- 'class' => '',
- 'target' => ''
- ), $atts));
- $content = do_shortcode($content);
- return "<li class='{$class}'><a href='{$target}'>{$content}</a></li>";
- }
- add_shortcode('Tabs_Title_Item', 'tabs_title_item');
- function tabs_body ($atts, $content = null, $code) {
- extract(shortcode_atts(array(
- 'name' => '',
- ), $atts));
- $content = do_shortcode($content);
- return "<div id='{$name}'>{$content}</div>";
- }
- add_shortcode('Tabs_Body', 'tabs_body');
- function entry_title ($atts, $content = null, $code) {
- $content = do_shortcode($content);
- return "<h1 class='entry-title'>{$content}</h1>";
- }
- add_shortcode('Page_Title', 'entry_title');
- function entry_second ($atts, $content = null, $code) {
- $content = do_shortcode($content);
- return "<h3 class='entry-second'>{$content}</h3><hr class='rh'>";
- }
- add_shortcode('Page_Secondary', 'entry_second');
- add_action( 'init', 'webinars_post_type' );
- function webinars_post_type() {
- register_post_type( 'webinars',
- array(
- 'labels' => array(
- 'name' => __( 'Webinars' ),
- 'singular_name' => __( 'Webinar' )
- ),
- 'public' => true,
- 'has_archive' => true,
- 'rewrite' => array('slug' => 'webinars')
- )
- );
- }
- add_action( 'init', 'webinars_archive_post_type' );
- function webinars_archive_post_type() {
- $labels = array(
- 'name' => _x( 'Categories', 'taxonomy general name' ),
- 'singular_name' => _x( 'Category', 'taxonomy singular name' ),
- 'search_items' => __( 'Search Categories' ),
- 'all_items' => __( 'All Categories' ),
- 'parent_item' => __( 'Parent Category' ),
- 'parent_item_colon' => __( 'Parent Category:' ),
- 'edit_item' => __( 'Edit Category' ),
- 'update_item' => __( 'Update Category' ),
- 'add_new_item' => __( 'Add New Category' ),
- 'new_item_name' => __( 'New Category Name' ),
- 'menu_name' => __( 'Categories' )
- );
- register_taxonomy('webinar-categories',array('web'), array(
- 'hierarchical' => true,
- 'labels' => $labels,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'webinar-categories' )
- ));
- register_post_type( 'webinar-archives',
- array(
- 'labels' => array(
- 'name' => __( 'Webinar Archives' ),
- 'singular_name' => __( 'Webinar Archive' )
- ),
- 'public' => true,
- 'has_archive' => true,
- 'rewrite' => array('slug' => 'webinar-archives'),
- 'taxonomies' => array('webinar-categories'),
- 'supports' => array( 'title', 'editor', 'excerpt' )
- )
- );
- }
- function custom_excerpt_length( $length ) {
- return 100;
- }
- add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
- add_action( 'add_meta_boxes', 'webinar_add_custom_box' );
- function webinar_add_custom_box() {
- add_meta_box(
- 'register_link',
- __( 'Register Link for GoToMeeting', 'webinar_textdomain' ),
- 'webinar_inner_custom_box',
- 'webinars',
- 'advanced',
- 'default'
- );
- }
- function webinar_inner_custom_box( $post ) {
- // Use nonce for verification
- wp_nonce_field( plugin_basename( __FILE__ ), 'webinar_nonce' );
- $current_value = get_post_meta($post->ID, 'register_link', true);
- // The actual fields for data entry
- echo '<label for="register_link">';
- _e("GoToMeeting Register Link", 'webinar_textdomain' );
- echo '</label> ';
- echo '<input type="text" id="register_link" name="register_link" value="' . $current_value . '" size="25" />';
- }
- add_action('save_post', 'webinar_save_postdata');
- function webinar_save_postdata( $post_id ) {
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
- return;
- if ( !wp_verify_nonce( $_POST['webinar_nonce'], plugin_basename( __FILE__ ) ) )
- return;
- if ( 'page' == $_POST['webinars'] )
- {
- if ( !current_user_can( 'edit_page', $post_id ) )
- return;
- }
- else
- {
- if ( !current_user_can( 'edit_post', $post_id ) )
- return;
- }
- $mydata = $_POST['register_link'];
- update_post_meta($post_id, 'register_link', $mydata);
- }
- function sb_get_page_nav($post) {
- $pages = get_pages('child_of='.$post->ID);
- if($post->post_parent != 0 && !empty($pages)) {
- $parent = get_page($post->post_parent);
- if(wp_get_nav_menu_object($parent->post_title)) {
- $nav['title'] = $parent->post_title;
- } else {
- $grandParent = get_page($parent->post_title);
- $nav['title'] = $grandParent->post_title;
- }
- } else {
- $parent = get_page($post->post_parent);
- $grandparent = get_page($parent->post_parent);
- if(wp_get_nav_menu_object($post->post_title)) {
- $nav['title'] = $post->post_title;
- } elseif(wp_get_nav_menu_object($parent->post_title)) {
- $nav['title'] = $parent->post_title;
- } elseif($parent->post_parent != 0) {
- $nav['title'] = $grandparent->post_title;
- } else {
- $nav['title'] = $post->post_title;
- $nav['no_nav'] = true;
- }
- }
- return $nav;
- }
- function my_admin_init() {
- $pluginfolder = get_bloginfo('stylesheet_directory');
- /*wp_enqueue_script('jquery');*/
- wp_enqueue_script('jquery-ui-core');
- wp_enqueue_script('jquery-ui-datepicker', $pluginfolder . '/js/jquery-ui-1.8.20.custom.min.js', array('jquery', 'jquery-ui-core') );
- wp_enqueue_style('jquery.ui.theme', $pluginfolder . '/js/ui-lightness/jquery-ui-1.8.20.custom.css');
- }
- add_action('admin_init', 'my_admin_init');
- $prefix = 'wb_';
- $meta_boxes['web-date'] = array(
- 'id' => 'web-date',
- 'title' => 'Webinar Date',
- 'page' => 'webinars',
- 'context' => 'normal',
- 'priority' => 'high',
- 'fields' => array(
- array(
- 'name' => 'Webinar Date',
- 'id' => $prefix . 'web-date',
- 'type' => 'date'
- ),
- array(
- 'name' => 'Webinar Start Time',
- 'id' => $prefix . 'web-time',
- 'type' => 'select',
- 'options' => array(
- array('value' => '7', 'name' => '7:00 am'),
- array('value' => '7.5', 'name' => '7:30 am'),
- array('value' => '8', 'name' => '8:00 am'),
- array('value' => '8.5', 'name' => '8:30 am'),
- array('value' => '9', 'name' => '9:00 am'),
- array('value' => '9.5', 'name' => '9:30 am'),
- array('value' => '10', 'name' => '10:00 am'),
- array('value' => '10.5', 'name' => '10:30 am'),
- array('value' => '11', 'name' => '11:00 am'),
- array('value' => '11.5', 'name' => '11:30 am'),
- array('value' => '12', 'name' => '12:00 pm'),
- array('value' => '12.5', 'name' => '12:30 pm'),
- array('value' => '13', 'name' => '1:00 pm'),
- array('value' => '13.5', 'name' => '1:30 pm'),
- array('value' => '14', 'name' => '2:00 pm'),
- array('value' => '14.5', 'name' => '2:30 pm'),
- array('value' => '15', 'name' => '3:00 pm')
- )
- ),
- array(
- 'name' => 'Webinar End Time',
- 'id' => $prefix . 'web-end-time',
- 'type' => 'select',
- 'options' => array(
- array('value' => '7.5', 'name' => '7:30 am'),
- array('value' => '8', 'name' => '8:00 am'),
- array('value' => '8.5', 'name' => '8:30 am'),
- array('value' => '9', 'name' => '9:00 am'),
- array('value' => '9.5', 'name' => '9:30 am'),
- array('value' => '10', 'name' => '10:00 am'),
- array('value' => '10.5', 'name' => '10:30 am'),
- array('value' => '11', 'name' => '11:00 am'),
- array('value' => '11.5', 'name' => '11:30 am'),
- array('value' => '12', 'name' => '12:00 pm'),
- array('value' => '12.5', 'name' => '12:30 pm'),
- array('value' => '13', 'name' => '1:00 pm'),
- array('value' => '13.5', 'name' => '1:30 pm'),
- array('value' => '14', 'name' => '2:00 pm'),
- array('value' => '14.5', 'name' => '2:30 pm'),
- array('value' => '15', 'name' => '3:00 pm'),
- array('value' => '15.5', 'name' => '3:30 pm'),
- array('value' => '16', 'name' => '4:00 pm'),
- array('value' => '16.5', 'name' => '4:30 pm'),
- array('value' => '17', 'name' => '5:00 pm'),
- )
- )
- )
- );
- add_action('admin_menu', 'clean_add_box');
- // Add meta box
- function clean_add_box() {
- global $meta_boxes;
- foreach( $meta_boxes as $meta_box ) {
- if(!is_array($meta_box['page']) ) {
- add_meta_box($meta_box['id'], $meta_box['title'], 'clean_show_meta_box', $meta_box['page'], $meta_box['context'], $meta_box['priority'],$meta_box);
- } else {
- foreach($meta_box['page'] as $page) {
- add_meta_box($meta_box['id'], $meta_box['title'], 'clean_show_meta_box', $page, $meta_box['context'], $meta_box['priority'],$meta_box);
- }
- }
- }
- }
- function clean_show_meta_box( $post, $meta_box ) {
- // Use nonce for verification
- clean_meta_boxes($meta_box['args']);
- }
- function clean_field_types( $field, $meta ) {
- switch( $field['type'] ) {
- case 'text':
- echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '<br />', $field['desc'];
- break;
- case 'textarea':
- echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>', '<br />', $field['desc'];
- break;
- case 'date':
- echo '<script type="text/javascript">
- jQuery(function($) {
- $(function() {
- $( "#'.$field['id'].'" ).datepicker({
- "dateFormat":"MM d, yy"
- });
- });
- });
- </script>';
- if(!$meta) {
- $meta = '';
- } else {
- $meta = date('F j, Y',$meta);
- }
- echo '<input readonly="readonly" id="'.$field['id'].'" type="text" size="40" name="'.$field['id'].'" value="'. $meta .'" /><br />' . $field['desc'];
- break;
- case 'upload':
- echo '<script type="text/javascript">
- jQuery(function($) {
- $("#'.$field['id'].'_button").click(function() {
- formfield = jQuery("#'.$field['id'].'").attr("name");
- tb_show("","media-upload.php?type=file&TB_iframe=true");
- window.send_to_editor = function(html) {
- url = jQuery(html).attr("href");
- jQuery("#'.$field['id'].'").val(url);
- tb_remove();
- }
- return false;
- });
- $("#'.$field['id'].'").click(function() {
- formfield = jQuery("#'.$field['id'].'").attr("name");
- tb_show("","media-upload.php?type=file&TB_iframe=true");
- window.send_to_editor = function(html) {
- url = jQuery(html).attr("href");
- jQuery("#'.$field['id'].'").val(url);
- tb_remove();
- }
- return false;
- });
- $("#'.$field['id'].'_button_remove").click(function() {
- $(this).siblings("#'.$field['id'].'").val("");
- });
- // send url back to plugin editor
- });
- </script>';
- echo '<input readonly="readonly" id="'.$field['id'].'" type="text" size="40" name="'.$field['id'].'" value="'.$meta.'" />
- <input id="'.$field['id'].'_button" type="button" value="Upload File" /> <input id="'.$field['id'].'_button_remove" type="button" value="Remove File" /><br />' . $field['desc'];
- break;
- case 'image':
- echo '<script type="text/javascript">
- jQuery(function($) {
- $("#'.$field['id'].'_button").click(function() {
- formfield = jQuery("#'.$field['id'].'").attr("name");
- tb_show("","media-upload.php?type=image&TB_iframe=true");
- window.send_to_editor = function(html) {
- imgurl = jQuery("img",html).attr("src");
- jQuery("#'.$field['id'].'").val(imgurl);
- tb_remove();
- }
- return false;
- });
- $("#'.$field['id'].'").click(function() {
- formfield = jQuery("#'.$field['id'].'").attr("name");
- tb_show("","media-upload.php?type=image&TB_iframe=true");
- window.send_to_editor = function(html) {
- imgurl = jQuery("img",html).attr("src");
- jQuery("#'.$field['id'].'").val(imgurl);
- tb_remove();
- }
- return false;
- });
- $("#'.$field['id'].'_button_remove").click(function() {
- $(this).siblings("#'.$field['id'].'").val("");
- });
- // send url back to plugin editor
- });
- </script>';
- echo '<input readonly="readonly" id="'.$field['id'].'" type="text" size="40" name="'.$field['id'].'" value="'.$meta.'" />
- <input id="'.$field['id'].'_button" type="button" value="Choose Image" /> <input id="'.$field['id'].'_button_remove" type="button" value="Remove Image" /><br />' . $field['desc'];
- break;
- case 'select':
- echo '<select name="', $field['id'], '" id="', $field['id'], '">';
- foreach ($field['options'] as $option) {
- echo '<option value="'.$option['value'].'"', $meta == $option['value'] ? ' selected="selected"' : '', '>', $option['name'], '</option>';
- }
- echo '</select> '.$field['desc'];
- break;
- case 'radio':
- foreach ($field['options'] as $option) {
- echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];
- }
- break;
- case 'checkbox':
- echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
- break;
- }
- }
- function clean_meta_boxes( $meta_boxes ) {
- global $post;
- echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
- echo '<table class="form-table">';
- foreach ($meta_boxes['fields'] as $field) {
- if( $field['type'] == 'repeatable' ) {
- echo '<tr>',
- '<th colspan="2"><h2>',$field['name'],'</h2></th>','</tr>';
- foreach($field['fields'] as $new_field) {
- echo '<tr>',
- '<th style="width:20%"><label for="', $new_field['id'], '">', $new_field['name'], '</label></th>',
- '<td>';
- clean_field_types( $new_field, $meta );
- echo '<td>',
- '</tr>';
- }
- echo '<tr>',
- '<td style="width:20%"> </td><td>',
- '<input id="btnAdd" class="button-primary" type="button" value="Add ',$field['name'],'">',
- '<input id="btnDel" class="button-secondary" type="button" value="Remove ',$field['name'],'">',
- '</td>';
- } else {
- // get current post meta data
- $meta = get_post_meta( $post->ID, $field['id'], true );
- echo '<tr>',
- '<th style="width:20%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
- '<td>';
- clean_field_types( $field, $meta );
- echo '<td>',
- '</tr>';
- }
- }
- echo '</table>';
- }
- add_action('save_post', 'clean_save_data');
- // Save data from meta box
- function clean_save_data( $post_id ) {
- global $meta_boxes;
- foreach( $meta_boxes as $meta_box ) {
- if( ! is_array( $meta_box['page'] ) ) {
- if( get_post_type( $post_id ) == $meta_box['page'] ) {
- $meta = $meta_box;
- clean_save_function($post_id, $meta);
- }
- } else {
- foreach( $meta_box['page'] as $page ) {
- if( get_post_type( $post_id ) == $page ) {
- $meta = $meta_box;
- clean_save_function($post_id, $meta);
- }
- }
- }
- }
- }
- function clean_save_function( $post_id, $meta ) {
- // verify nonce
- if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) {
- return $post_id;
- }
- // check autosave
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
- return $post_id;
- }
- // check permissions
- if ('page' == $_POST['post_type']) {
- if (!current_user_can('edit_page', $post_id)) {
- return $post_id;
- }
- } elseif (!current_user_can('edit_post', $post_id)) {
- return $post_id;
- }
- foreach ($meta['fields'] as $field) {
- if($field['type'] == 'date') {
- $_POST[$field['id']] = strtotime($_POST[$field['id']]);
- }
- $old = get_post_meta($post_id, $field['id'], true);
- $new = $_POST[$field['id']];
- if ($new && $new != $old) {
- update_post_meta($post_id, $field['id'], $new);
- } elseif ('' == $new && $old) {
- delete_post_meta($post_id, $field['id'], $old);
- }
- }
- }
- // check autosave
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
- return $post_id;
- }
- //PLANS AND PRICING SHORTCODES
- function left_plan ($atts, $content = null, $code) {
- extract(shortcode_atts(array(
- 'price' => ''
- ), $atts));
- $content = do_shortcode($content);
- $image = get_bloginfo('stylesheet_directory') . '/images/small.png';
- return "
- <div class='left-wrap'>
- <div class='plan-img-wrap'><img src='{$image}' /></div>
- <h2>{$content}<br>Package</h2>
- <p>{$price}</p>
- </div>
- ";
- }
- add_shortcode('left', 'left_plan');
- function middle_plan ($atts, $content = null, $code) {
- extract(shortcode_atts(array(
- 'price' => ''
- ), $atts));
- $content = do_shortcode($content);
- $image = get_bloginfo('stylesheet_directory') . '/images/premium.png';
- return "
- <div class='middle-wrap'>
- <div class='plan-img-wrap'><img src='{$image}' /></div>
- <h2>{$content}<br>Package</h2>
- <p>{$price}</p>
- </div>
- ";
- }
- add_shortcode('middle', 'middle_plan');
- function right_plan ($atts, $content = null, $code) {
- extract(shortcode_atts(array(
- 'price' => ''
- ), $atts));
- $content = do_shortcode($content);
- $image = get_bloginfo('stylesheet_directory') . '/images/ultimate.png';
- return "
- <div class='right-wrap'>
- <div class='plan-img-wrap'><img src='{$image}' /></div>
- <h2>{$content}<br>Package</h2>
- <p>{$price}</p>
- </div>
- ";
- }
- add_shortcode('right', 'right_plan');
- function button_plan ($atts, $content = null, $code) {
- extract(shortcode_atts(array(
- 'link' => ''
- ), $atts));
- $content = do_shortcode($content);
- return "
- <div class='plan-button'>
- <a href='{$link}'>{$content}</a>
- </div>
- ";
- }
- add_shortcode('button', 'button_plan');
- function logos_plan ($atts, $content = null, $code) {
- $content = do_shortcode($content);
- return "
- <div class='plan-logos'>
- {$content}
- </div>
- ";
- }
- add_shortcode('logos', 'logos_plan');
- function logos_img_plan ($atts, $content = null, $code) {
- $content = do_shortcode($content);
- return "
- {$content}
- ";
- }
- add_shortcode('logos_image', 'logos_img_plan');
- function remove_wpautp_home() {
- if( is_front_page() ) {
- remove_filter( 'the_content', 'wpautop');
- }
- }
- add_action('wp','remove_wpautp_home');
- /*
- * Plugin Name: Shortcode Empty Paragraph Fix
- * Plugin URI: http://www.johannheyne.de/wordpress/shortcode-empty-paragraph-fix/
- * Description: Fix issues when shortcodes are embedded in a block of content that is filtered by wpautop.
- * Author URI: http://www.johannheyne.de
- * Version: 0.1
- * Put this in /wp-content/plugins/ of your Wordpress installation
- */
- function shortcode_paragraph_insertion_fix($content) {
- $array = array (
- '<p>[' => '[',
- ']</p>' => ']',
- ']<br />' => ']'
- );
- $content = strtr($content, $array);
- return $content;
- }
- add_filter('the_content', 'shortcode_paragraph_insertion_fix');
- add_shortcode('web', 'web');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement