Changeset 698968
- Timestamp:
- 04/17/2013 08:16:31 AM (13 years ago)
- Location:
- multiple-content-blocks/trunk
- Files:
-
- 6 edited
-
README.md (modified) (1 diff)
-
assets/css/admin.css (modified) (1 diff)
-
assets/inc/class.MCB.php (modified) (1 diff)
-
assets/inc/functions.template-tags.php (modified) (4 diffs)
-
multiple-content-blocks.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
multiple-content-blocks/trunk/README.md
r628734 r698968 24 24 get_the_block($name) 25 25 This will get $name content block's content, for you to process 26 27 Additional options 28 -------------- 29 the_block($name,'one-liner') 30 get_the_block($name,'one-liner') 31 Won't display a WYSIWYG editor, but a plain one line text field (input type="text") -
multiple-content-blocks/trunk/assets/css/admin.css
r628734 r698968 5 5 background: #fff; 6 6 } 7 8 #multiple-content-blocks-box input[type=text] { 9 width:100%; 10 } -
multiple-content-blocks/trunk/assets/inc/class.MCB.php
r684285 r698968 45 45 $blocks = $this->get_blocks($post->ID); 46 46 if(is_wp_error($blocks)) : 47 echo '<p>'.$blocks->get_error_message().'< p>';47 echo '<p>'.$blocks->get_error_message().'</p>'; 48 48 $blocks = $this->get_blocks($post->ID,false); 49 49 endif; 50 50 51 51 if($blocks) : 52 foreach($blocks as $id=>$name) : 52 foreach($blocks as $id=>$block) : 53 54 if (is_array($block)) : 55 $name = $block['name']; 56 $type = $block['type']; 57 else : 58 $name = $block; 59 $type = 'editor'; 60 endif; 53 61 echo '<p><strong>'.$name.'</strong></p>'; 54 wp_editor(get_post_meta($post->ID,'mcb-'.$id,true),$id); 62 if ($type == 'one-liner') : 63 echo '<input type="text" name="' . $id . '" value="' . htmlentities(get_post_meta($post->ID,'mcb-'.$id,true)) . '" />'; 64 else : 65 wp_editor(get_post_meta($post->ID,'mcb-'.$id,true),$id); 66 endif; 55 67 endforeach; 56 68 endif; -
multiple-content-blocks/trunk/assets/inc/functions.template-tags.php
r684285 r698968 8 8 * 9 9 * @param string $name The name of the block 10 * @param string $type optional The name of the style, either 'editor' or 'one-liner' (defaults to 'editor') 10 11 */ 11 function the_block($name ) {12 echo get_the_block($name );12 function the_block($name,$type='editor') { 13 echo get_the_block($name,$type); 13 14 } 14 15 … … 17 18 * 18 19 * @param string $name The name of the block 20 * @param string $type optional The name of the style, either 'editor' or 'one-liner' (defaults to 'editor') 19 21 */ 20 function get_the_block($name ) {22 function get_the_block($name,$type='editor') { 21 23 if(!empty($name)) : 22 24 global $post; 23 mcb_register_block($post->ID,$name );25 mcb_register_block($post->ID,$name,$type); 24 26 25 27 return apply_filters('the_content',get_post_meta($post->ID,'mcb-'.sanitize_title($name),true)); … … 32 34 * @param int $post_id 33 35 * @param string $name The name of the block 36 * @param string $type optional The name of the style, either 'editor' or 'one-liner' (defaults to 'editor') 34 37 */ 35 function mcb_register_block($post_id,$name ) {36 if(!mcb_block_exists($post_id,$name )) {38 function mcb_register_block($post_id,$name,$type='editor') { 39 if(!mcb_block_exists($post_id,$name,$type)) { 37 40 $blocks = get_post_meta($post_id,'mcb-blocks',true); 38 41 if(!is_array($blocks)) $blocks = array(); 39 42 40 $blocks[sanitize_title($name)] = $name;43 $blocks[sanitize_title($name)] = array('name' => $name, 'type' => $type); 41 44 42 45 update_post_meta($post_id,'mcb-blocks',$blocks); … … 49 52 * @param int $post_id 50 53 * @param string $name The name of the block 54 * @param string $type optional The name of the style, either 'editor' or 'one-liner' (defaults to 'editor') 51 55 * @return bool 52 56 */ 53 function mcb_block_exists($post_id,$name ) {57 function mcb_block_exists($post_id,$name,$type='editor') { 54 58 $blocks = get_post_meta($post_id,'mcb-blocks',true); 55 59 if(is_array($blocks)) : 56 if($blocks[sanitize_title($name)] == $name) : 57 return true; 60 if(is_array($blocks[sanitize_title($name)])) : 61 $comparable_name = $blocks[sanitize_title($name)]['name']; 62 $comparable_type = $blocks[sanitize_title($name)]['type']; 63 else : 64 $comparable_name = $blocks[sanitize_title($name)]; 65 $comparable_type = 'editor'; 66 endif; 67 if($comparable_name == $name && $comparable_type == $type) : 68 return true; 58 69 endif; 59 70 endif; -
multiple-content-blocks/trunk/multiple-content-blocks.php
r684285 r698968 4 4 Plugin URI: https://github.com/trendwerk/multiple-content-blocks/ 5 5 Description: Allow for more content blocks in WordPress than just the one. 6 Version: 3.0. 26 Version: 3.0.3 7 7 Author: Ontwerpstudio Trendwerk 8 8 Author URI: https://github.com/trendwerk/ -
multiple-content-blocks/trunk/readme.txt
r684285 r698968 5 5 Requires at least: 3.0 6 6 Tested up to: 3.5.1 7 Stable tag: 3.0. 27 Stable tag: 3.0.3 8 8 9 9 Allow for more content blocks in WordPress than just the one.
Note: See TracChangeset
for help on using the changeset viewer.