Changeset 511162
- Timestamp:
- 02/27/2012 02:34:23 PM (14 years ago)
- Location:
- smart-wysiwyg-blocks-of-content
- Files:
-
- 25 added
- 2 edited
-
tags/0.5.1 (added)
-
tags/0.5.1/includes (added)
-
tags/0.5.1/includes/class-swboc-admin.php (added)
-
tags/0.5.1/includes/class-swboc-common.php (added)
-
tags/0.5.1/includes/class-swboc-front.php (added)
-
tags/0.5.1/includes/class-swboc-widget.php (added)
-
tags/0.5.1/readme.txt (added)
-
tags/0.5.1/screenshot-1.png (added)
-
tags/0.5.1/screenshot-2.png (added)
-
tags/0.5.1/smart-wysiwyg-blocks-of-content.php (added)
-
tags/0.5.2 (added)
-
tags/0.5.2/includes (added)
-
tags/0.5.2/includes/class-swboc-admin.php (added)
-
tags/0.5.2/includes/class-swboc-common.php (added)
-
tags/0.5.2/includes/class-swboc-front.php (added)
-
tags/0.5.2/includes/class-swboc-widget.php (added)
-
tags/0.5.2/readme.txt (added)
-
tags/0.5.2/screenshot-1.png (added)
-
tags/0.5.2/screenshot-2.png (added)
-
tags/0.5.2/smart-wysiwyg-blocks-of-content.php (added)
-
trunk/includes (added)
-
trunk/includes/class-swboc-admin.php (added)
-
trunk/includes/class-swboc-common.php (added)
-
trunk/includes/class-swboc-front.php (added)
-
trunk/includes/class-swboc-widget.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/smart-wysiwyg-blocks-of-content.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
smart-wysiwyg-blocks-of-content/trunk/readme.txt
r356646 r511162 4 4 Tags: wysiwyg, widgets 5 5 Requires at least: 3.0 6 Tested up to: 3. 17 Stable tag: 0.5 6 Tested up to: 3.3.1 7 Stable tag: 0.5.2 8 8 9 9 Adds a custom post type that can be easily inserted at multiple spots, including widgets. Easy way to create WYSIWYG widgets. … … 29 29 30 30 == Changelog == 31 32 = 0.5.2 = 33 * Get and restore $post global var to make sure the_content filters use the correct post (Thanks Danny de Haan!). 34 35 = 0.5.1 = 36 * Split classes to external files and updated to WordPress coding standards. 31 37 32 38 = 0.5 = -
smart-wysiwyg-blocks-of-content/trunk/smart-wysiwyg-blocks-of-content.php
r356650 r511162 5 5 Description: Adds a custom post type that can be easily inserted at multiple spots, including widgets. Easy way to create WYSIWYG widgets. 6 6 Author: Coen Jacobs 7 Version: 0.5 7 Version: 0.5.2 8 8 Author URI: http://cnjcbs.com 9 9 */ 10 10 11 function swboc_shortcode($atts) { 12 extract(shortcode_atts(array( 13 'id' => '', 14 ), $atts)); 15 16 $content = ""; 17 18 if($id != "") 19 { 20 $args = array( 21 'post__in' => array($id), 22 'post_type' => 'smartblock', 23 ); 24 25 $swboc_posts = get_posts($args); 26 27 foreach( $swboc_posts as $post ) : 28 $content .= apply_filters('the_content', $post->post_content); 29 endforeach; 30 } 31 32 return $content; 11 if ( is_admin() ) { 12 include( 'includes/class-swboc-admin.php' ); 13 $SWBOC_Admin = new SWBOC_Admin(); 14 } else { 15 include( 'includes/class-swboc-front.php' ); 16 $SWBOC_Front = new SWBOC_Front(); 33 17 } 34 18 35 add_shortcode('smartblock', 'swboc_shortcode');36 37 class SWBOC_Widget extends WP_Widget {38 function SWBOC_Widget() {39 $widget_ops = array( 'classname' => 'SWBOC_Widget', 'description' => 'Widget to show a Smart WYSIWYG Block of Content' );40 $this->WP_Widget( 'swboc', 'SWBOC Widget', $widget_ops );41 }42 43 function widget( $args, $instance ) {44 extract( $args, EXTR_SKIP );45 echo $before_widget;46 47 $swboc_id = esc_attr($instance['swboc_id']);48 $swboc_title = esc_attr($instance['title']);49 50 echo $before_title.$swboc_title.$after_title;51 52 $args = array(53 'post__in' => array($swboc_id),54 'post_type' => 'smartblock',55 );56 57 $swboc_posts = get_posts($args);58 59 foreach( $swboc_posts as $post ) :60 echo apply_filters('the_content', $post->post_content);61 endforeach;62 63 echo $after_widget;64 }65 66 function update( $new_instance, $old_instance ) {67 $this->title = esc_attr($instance['title']);68 $updated_instance = $new_instance;69 return $updated_instance;70 }71 72 function form( $instance ) {73 $swboc_id = esc_attr($instance['swboc_id']);74 $swboc_title = esc_attr($instance['title']); ?>75 76 <label for="<?php echo $this->get_field_id('title'); ?>">Title:77 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $swboc_title; ?>" /></label>78 79 <label for="<?php echo $this->get_field_id('swboc_id'); ?>">Smart block:80 <select class="widefat" id="<?php echo $this->get_field_id('swboc_id'); ?>" name="<?php echo $this->get_field_name('swboc_id'); ?>">81 82 <?php $args = 'post_type=smartblock&posts_per_page=-1&orderby=ID&order=ASC';83 84 $swboc_posts = get_posts($args);85 86 foreach( $swboc_posts as $post ) :87 $currentID = $post->ID;88 89 if($currentID == $swboc_id)90 $extra = 'SELECTED';91 else92 $extra = '';93 94 echo '<option value="'.$currentID.'" '.$extra.'>'.$post->post_title.'</option>';95 endforeach;96 97 ?></select></label><?php98 }99 }100 101 add_action( 'widgets_init', create_function( '', "register_widget('SWBOC_Widget');" ) );102 103 function create_swboc_type() {104 register_post_type( 'smartblock',105 array(106 'labels' => array(107 'name' => __( 'Smart Blocks' ),108 'singular_name' => __( 'Smart Block' ),109 'add_new' => __( 'Add New' ),110 'add_new_item' => __( 'Add New Smart Block' ),111 'edit' => __( 'Edit' ),112 'edit_item' => __( 'Edit Smart Block' ),113 'new_item' => __( 'New Smart Block' ),114 'view' => __( 'View Smart Block' ),115 'view_item' => __( 'View Smart Block' ),116 'search_items' => __( 'Search Smart Blocks' ),117 'not_found' => __( 'No Smart Blocks found' ),118 'not_found_in_trash' => __( 'No Smart Blocks found in Trash' ),119 'parent' => __( 'Parent Smart Block' ),120 ),121 'public' => false,122 'description' => __( 'A Smart Block is a effective way to store content that you will use more than once.'),123 'show_ui' => true,124 'publicly_queryable' => false,125 'exclude_from_search' => true,126 'menu_position' => 20,127 'hierarchical' => false,128 'query_var' => true,129 'supports' => array( 'title', 'editor'),130 'can_export' => true,131 )132 );133 }134 135 add_action( 'init', 'create_swboc_type' );136 137 function update_swboc_database()138 {139 $db_version = get_option('swboc_database_version');140 141 if($db_version != '' || $db_version < 2)142 {143 global $wpdb;144 $wpdb->update( $wpdb->posts, array( 'post_type' => 'smartblock' ), array( 'post_type' => 'Smart Block' ) );145 update_option('swboc_database_version', 2);146 }147 }148 149 add_action('admin_init', 'update_swboc_database');150 151 19 ?>
Note: See TracChangeset
for help on using the changeset viewer.