Plugin Directory

Changeset 698968


Ignore:
Timestamp:
04/17/2013 08:16:31 AM (13 years ago)
Author:
Trendwerk
Message:

Added support for one-liners (thanks to fabrikagency)

Location:
multiple-content-blocks/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • multiple-content-blocks/trunk/README.md

    r628734 r698968  
    2424    get_the_block($name)
    2525This will get $name content block's content, for you to process
     26
     27Additional options
     28--------------
     29    the_block($name,'one-liner')
     30    get_the_block($name,'one-liner')
     31Won'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  
    55        background: #fff;
    66    }
     7   
     8    #multiple-content-blocks-box input[type=text] {
     9      width:100%;
     10    }
  • multiple-content-blocks/trunk/assets/inc/class.MCB.php

    r684285 r698968  
    4545        $blocks = $this->get_blocks($post->ID);
    4646        if(is_wp_error($blocks)) :
    47             echo '<p>'.$blocks->get_error_message().'<p>';
     47            echo '<p>'.$blocks->get_error_message().'</p>';
    4848            $blocks = $this->get_blocks($post->ID,false);
    4949        endif;
    5050       
    5151        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;
    5361                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;
    5567            endforeach;
    5668        endif;
  • multiple-content-blocks/trunk/assets/inc/functions.template-tags.php

    r684285 r698968  
    88 *
    99 * @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')
    1011 */
    11 function the_block($name) {
    12     echo get_the_block($name);
     12function the_block($name,$type='editor') {
     13    echo get_the_block($name,$type);
    1314}
    1415
     
    1718 *
    1819 * @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')
    1921 */
    20 function get_the_block($name) {
     22function get_the_block($name,$type='editor') {
    2123    if(!empty($name)) :
    2224        global $post;
    23         mcb_register_block($post->ID,$name);
     25        mcb_register_block($post->ID,$name,$type);
    2426       
    2527        return apply_filters('the_content',get_post_meta($post->ID,'mcb-'.sanitize_title($name),true));
     
    3234 * @param int $post_id
    3335 * @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')
    3437 */
    35 function mcb_register_block($post_id,$name) {
    36     if(!mcb_block_exists($post_id,$name)) {
     38function mcb_register_block($post_id,$name,$type='editor') {
     39    if(!mcb_block_exists($post_id,$name,$type)) {
    3740        $blocks = get_post_meta($post_id,'mcb-blocks',true);
    3841        if(!is_array($blocks)) $blocks = array();
    3942       
    40         $blocks[sanitize_title($name)] = $name;
     43        $blocks[sanitize_title($name)] = array('name' => $name, 'type' => $type);
    4144       
    4245        update_post_meta($post_id,'mcb-blocks',$blocks);
     
    4952 * @param int $post_id
    5053 * @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')
    5155 * @return bool
    5256 */
    53 function mcb_block_exists($post_id,$name) {
     57function mcb_block_exists($post_id,$name,$type='editor') {
    5458    $blocks = get_post_meta($post_id,'mcb-blocks',true);
    5559    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;
    5869        endif;
    5970    endif;
  • multiple-content-blocks/trunk/multiple-content-blocks.php

    r684285 r698968  
    44Plugin URI: https://github.com/trendwerk/multiple-content-blocks/
    55Description: Allow for more content blocks in WordPress than just the one.
    6 Version: 3.0.2
     6Version: 3.0.3
    77Author: Ontwerpstudio Trendwerk
    88Author URI: https://github.com/trendwerk/
  • multiple-content-blocks/trunk/readme.txt

    r684285 r698968  
    55Requires at least: 3.0
    66Tested up to: 3.5.1
    7 Stable tag: 3.0.2
     7Stable tag: 3.0.3
    88
    99Allow for more content blocks in WordPress than just the one.
Note: See TracChangeset for help on using the changeset viewer.