WordPress.org

Plugin Directory

Changeset 684626


Ignore:
Timestamp:
03/20/13 05:21:51 (13 months ago)
Author:
joedolson
Message:

Significant update: move my-glossary-filter to external plugin.

Location:
my-content-management/trunk
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • my-content-management/trunk/mcm-custom-posts.php

    r671945 r684626  
    150150            return mcm_text_area( $args ); 
    151151        case 'select': 
    152             return mcm_select( $args );      
     152            return mcm_select( $args );  
     153        case 'upload': 
     154            return mcm_upload_field( $args ); 
    153155        default: 
    154156            return mcm_text_field( $args, $args[3] ); 
     
    172174add_action( 'save_post', 'mcm_save_postdata', 1, 2 ); 
    173175// this is the default text field meta box 
     176 
     177function mcm_upload_field( $args ) { 
     178    global $post; 
     179    $description = $args[2]; 
     180    // adjust data 
     181    $args[2] = get_post_meta($post->ID, $args[0], true); 
     182    $args[1] = __($args[1], 'sp' ); 
     183    if(!empty($args[2]) && $args[2] != '0') { 
     184        $download = '<p><a href="'.$args[2].'">View '.$args[1].'</a></p>'; 
     185    } 
     186    $max_upload = (int)(ini_get('upload_max_filesize')); 
     187    $max_post = (int)(ini_get('post_max_size')); 
     188    $memory_limit = (int)(ini_get('memory_limit')); 
     189    $upload_mb = min($max_upload, $max_post, $memory_limit); 
     190    $label_format = 
     191        '<p class="mcm_text_field mcm_field"><label for="%1$s"><strong>%2$s</strong></label><br />'. 
     192        '<input style="width: 80%%;" type="file" name="%1$s" value="%3$s" id="%1$s" /><br />'. 
     193        sprintf( __( "Upload limit: %s MB",'my-content-management' ),$upload_mb ); 
     194        if ( $description != '' ) { $label_format .= '<br /><em>'.$description.'</em></p>'; } else { $label_format .= '</p>'; } 
     195        if ( $download != '' ) { $label_format .= $download; } 
     196        return vsprintf( $label_format, $args ); 
     197} 
     198 
    174199function mcm_text_field( $args, $type='text' ) { 
    175200    $types = array( 'color','date','number','tel','time','url' ); 
     
    177202    global $post; 
    178203    $description = $args[2]; 
     204    $args[4] = $type; 
    179205    // adjust data 
    180206    $args[2] = get_post_meta($post->ID, $args[0], true); 
     
    182208    $label_format = 
    183209        '<p class="mcm_text_field mcm_field"><label for="%1$s"><strong>%2$s</strong></label><br />'. 
    184         '<input style="width: 80%%;" type="text" name="%1$s" value="%3$s" id="%1$s" />'; 
     210        '<input style="width: 80%%;" type="%4$s" name="%1$s" value="%3$s" id="%1$s" />'; 
    185211        if ( $description != '' ) { $label_format .= '<br /><em>'.$description.'</em></p>'; } else { $label_format .= '</p>'; } 
    186212        return vsprintf( $label_format, $args ); 
     
    240266                    $my_data[$value[0]] = $_POST[$value[0]]; 
    241267                } 
     268                if(!empty($_FILES[$value[0]])) { 
     269                    $file   = $_FILES[$value[0]]; 
     270                    $upload = wp_handle_upload($file, array('test_form' => false)); 
     271                    if(!isset($upload['error']) && isset($upload['file'])) { 
     272                        $filetype   = wp_check_filetype(basename($upload['file']), null); 
     273                        $title      = $file['name']; 
     274                        $ext        = strrchr($title, '.'); 
     275                        $title      = ($ext !== false) ? substr($title, 0, -strlen($ext)) : $title; 
     276                        $attachment = array( 
     277                            'post_mime_type'    => $wp_filetype['type'], 
     278                            'post_title'        => addslashes($title), 
     279                            'post_content'      => '', 
     280                            'post_status'       => 'inherit', 
     281                            'post_parent'       => $post->ID 
     282                        ); 
     283                        $attach_id = wp_insert_attachment($attachment, $upload['file']); 
     284                        $my_data[$value[0]] = wp_get_attachment_url( $attach_id ); 
     285                    } 
     286                }                
    242287            } 
    243288        } 
     
    259304            } 
    260305            if (!$value) { 
    261                 // delete blanks 
    262                 delete_post_meta($post->ID, $key); 
     306                // have empty values for blanks (so templating works) 
     307                update_post_meta($post->ID, $key,''); 
    263308            } 
    264309        } 
  • my-content-management/trunk/mcm-view-custom-posts.php

    r671945 r684626  
    256256 
    257257// A simple function to get data stored in a custom field 
    258 if ( !function_exists('mcm_custom_field') ) { 
    259     function mcm_get_custom_field($field,$id='') { 
    260         global $post; 
    261         $id = ($id != '')?$id:$post->ID; 
    262         $custom_field = get_post_meta($id, $field, true); 
    263         return $custom_field; 
    264     } 
    265 } 
     258function mcm_get_custom_field($field,$id='') { 
     259    global $post; 
     260    $id = ($id != '')?$id:$post->ID; 
     261    $custom_field = get_post_meta($id, $field, true); 
     262    return $custom_field; 
     263} 
     264 
    266265function mcm_custom_field( $field,$before='',$after='',$id='' ) { 
    267266    $value = mcm_get_custom_field($field, $id); 
  • my-content-management/trunk/mcm-widgets.php

    r657057 r684626  
    2424        global $mcm_enabled; 
    2525        $enabled = $mcm_enabled; 
    26         $post_type = esc_attr($instance['mcm_widget_post_type']); 
    27         $title = esc_attr($instance['title']); 
     26        $post_type = isset( $instance['mcm_widget_post_type'] ) ? esc_attr($instance['mcm_widget_post_type']) : ''; 
     27        $title = isset( $instance['title'] ) ? esc_attr($instance['title']) : ''; 
    2828    ?> 
    2929        <p> 
     
    3232        </p>     
    3333        <p> 
    34         <label for="<?php echo $this->get_field_id('mcm_widget_post_type'); ?>"><?php _e('Post type to search','my-content-management'); ?></label> <select<?php echo $disabled; ?> id="<?php echo $this->get_field_id('mcm_widget_post_type'); ?>" name="<?php echo $this->get_field_name('mcm_widget_post_type'); ?>"> 
     34        <label for="<?php echo $this->get_field_id('mcm_widget_post_type'); ?>"><?php _e('Post type to search','my-content-management'); ?></label> <select<?php echo $enabled; ?> id="<?php echo $this->get_field_id('mcm_widget_post_type'); ?>" name="<?php echo $this->get_field_name('mcm_widget_post_type'); ?>"> 
    3535    <?php 
    3636        foreach( $enabled as $v ) { 
  • my-content-management/trunk/my-content-management.php

    r671945 r684626  
    66Author: Joseph C Dolson 
    77Author URI: http://www.joedolson.com 
    8 Version: 1.3.2 
     8Version: 1.3.3 
    99*/ 
    1010/*  Copyright 2011-2012  Joe Dolson (email : joe@joedolson.com) 
     
    2424    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
    2525*/ 
    26 $mcm_version = '1.3.2'; 
     26$mcm_version = '1.3.3'; 
    2727// Enable internationalisation 
    2828load_plugin_textdomain( 'my-content-management',false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );  
     
    3434if ( !get_option( 'mcm_version' ) ) {  mcm_install_plugin(); } 
    3535if ( version_compare( get_option('mcm_version'), $mcm_version, '<' ) ) { mcm_upgrade_plugin(); } 
     36 
     37function mcm_is_plugin_installed($plugin_dir) { 
     38    require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 
     39    $plugins = get_plugins($plugin_dir); 
     40    if ($plugins) return true; 
     41    return false; 
     42} 
     43if ( isset($_GET['ignore']) && $_GET['ignore'] == 'glossary' ) { 
     44    update_option( 'mcm_glossary_ignore', 'true' ); 
     45} 
     46if ( ! ( mcm_is_plugin_installed('/my-content-glossary') ) && get_option( 'mcm_glossary_ignore' ) != 'true' ) { 
     47    function mcm_glossary_notice() { 
     48        if ( current_user_can( 'install_plugins' ) ) { 
     49            $install = admin_url('plugin-install.php?tab=search&s=my+content+glossary'); 
     50            $ignore = admin_url('options-general.php?page=my-content-management/my-content-management.php&ignore=glossary'); 
     51            echo "<div class='error'><p>The My Content Management Glossary Filter is now an independent plug-in and must be installed separately. <a href='$install'>Install My Content Glossary</a>. <a href='$ignore'>Ignore</a></p></div>"; 
     52        } 
     53    } 
     54    add_action('admin_notices', 'mcm_glossary_notice' ); 
     55} 
    3656 
    3757// eventually, options. For now, not. 
     
    6787            ), $atts)); 
    6888    return mcm_get_show_posts( $type, $display, $taxonomy, $term, $count, $order, $direction, $meta_key, $template, $cache, $offset, $id, $custom_wrapper, $custom, $operator, $year, $month, $week, $day ); 
     89} 
     90 
     91add_action('post_edit_form_tag', 'mcm_post_edit_form_tag'); 
     92function mcm_post_edit_form_tag() { 
     93    echo ' enctype="multipart/form-data"'; 
    6994} 
    7095 
     
    215240        break; 
    216241        case '1.2.0': 
    217         default: 
    218242    $options = get_option('mcm_options'); 
    219243    $options['types'][]=$default_mcm_types; 
     
    221245    $options['extras']=$default_mcm_extras; 
    222246    update_option( 'mcm_options', $options ); 
     247        default: 
    223248        break; 
    224249    } 
     
    242267 
    243268function mcm_get_support_form() { 
    244  
    245 echo "<pre>"; 
    246 print_r( $GLOBALS['wp_post_types']['mcm_people'] ); 
    247 echo "</pre>"; 
    248  
    249269global $current_user, $mcm_version; 
    250270$textdomain = 'my-content-management'; 
     
    552572                    'show_ui' => ( isset($ns['show_ui']) && $ns['show_ui'] == 1 )?true:false,  
    553573                    'hierarchical' => ( isset($ns['hierarchical']) && $ns['hierarchical'] == 1 )?true:false, 
    554                     'menu_icon' => ($ns['menu_icon']=='')?null:$ns['menu_icon'], 
     574                    'menu_icon' => ( !isset($ns['menu_icon']) || $ns['menu_icon']=='')?null:$ns['menu_icon'], 
    555575                    'supports' => $ns['supports'], 
    556576                    'slug' => $ns['slug'] ) ); 
     
    568588                    'show_ui' => ( isset($ns['show_ui']) && $ns['show_ui'] == 1 )?true:false, 
    569589                    'hierarchical' => ( isset($ns['hierarchical']) && $ns['hierarchical'] == 1 )?true:false,                     
    570                     'menu_icon' => $ns['menu_icon'], 
     590                    'menu_icon' => ( !isset($ns['menu_icon']) || $ns['menu_icon']=='')?null:$ns['menu_icon'], 
    571591                    'supports' => $ns['supports'], 
    572592                    'slug' => $ns['slug'] ) ); 
     
    10391059            'textarea'=>__('Multiple lines of text','my-content-management'), 
    10401060            'select'=>__('Select dropdown','my-content-management'), 
     1061            'upload'=>__('File upload','my-content-management'), 
    10411062            'color'=>__('Color input / HTML5','my-content-management'), 
    10421063            'date'=>__('Date input / HTML5','my-content-management'), 
  • my-content-management/trunk/readme.txt

    r671945 r684626  
    99 
    1010Creates common custom post types for advanced content management: FAQ, Testimonials, people (staff, contributors, etc.), and others! 
    11   
     11 
    1212== Description == 
    13  
    1413My Content Management creates a suite of custom post types, each with an appropriate custom taxonomy and a set of commonly needed custom fields. The purpose of the plug-in is to provide a single common interface to create commonly needed extra content tools.  
    1514 
     
    6968== Changelog == 
    7069 
     70= 1.3.3 = 
     71 
     72* New feature: Added file uploads option to custom field options. 
     73* Bug fix: function mcm_custom_field() did not exist. 
     74* Assorted bug fixes, [courtesy Juliette](http://wordpress.org/support/topic/few-small-bugsfixes-undefined-variables-and-such) 
     75* Bug fix: Upgrade bug that could wipe out custom fieldsets. Yikes!  
     76* Bug fix: Empty custom fields returned template tags instead of blank fields. 
     77* Removed Glossary Filter plug-in so that plug-in can be maintained independently.  
     78 
    7179= 1.3.2 = 
    7280 
     
    244252Well, there really isn't just one way to use this plug-in. There are many, many different ways to use it. I'd recommend buying the [User's Guide](http://www.joedolson.com/articles/my-content-management/guide/), which will walk you through many of the ways you can use this plug-in. Also, your purchase will help support me! Bonus! 
    245253 
     254= OMG! What happened to my Glossary page! = 
     255 
     256I removed the Glossary Filter plug-in from the My Content Management package in version 1.3.3. It can now be downloaded separately at <a href="http://wordpress.org/extend/plugins/my-content-glossary/">My Content Glossary</a>.  
     257 
    246258== Screenshots == 
    247259 
     
    252264== Upgrade Notice == 
    253265 
    254  * 1.3.0 Adds support for customizing custom field groups. 
     266 * 1.3.3 Important! Glossary Filter is no longer packaged with this plug-in. It must be downloaded separately. 
  • my-content-management/trunk/uninstall.php

    r459131 r684626  
    55    delete_option( 'mcm_options' ); 
    66    delete_option( 'mcm_version' ); 
     7    delete_option( 'mcm_glossary_ignore' ); 
    78} 
Note: See TracChangeset for help on using the changeset viewer.