Plugin Directory

Changeset 331831


Ignore:
Timestamp:
01/12/2011 06:10:52 PM (15 years ago)
Author:
mikelynn
Message:

Found a bug related to revisions, tagging version 1.0.10

Location:
graceful-sidebar-plugin
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • graceful-sidebar-plugin/tags/1.0.10/graceful_sidebar.php

    r328418 r331831  
    55Tags: custom sidebar, pages sidebar, custom sidebar
    66Description: Creates a custom sidebar widget to display a custom field from a page.  Create a page or post, enable the widget in your sidebar and add content. Create custom fields called graceful_title and graceful_content. <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KKFYUAMPCQHXQ">Donate</a>
    7 Version: 1.0.8
     7Version: 1.0.10
    88Author: Michael Lynn
    99Author URI: http://www.mlynn.org/
     
    1313add_action("admin_init", "gs_widget_admininit");
    1414add_action('save_post','gs_save_meta');
    15 register_activation_hook( __FILE__, 'gs_activation' );
    1615
    17 function gs_activation() {
    18 
    19 }
    20 
    21 function gs_save_meta(){
     16function gs_save_meta($post_id){
    2217    global $post;
    2318    // Clean up legacy
    24     $custom = get_post_custom($post->ID);
    25     $graceful_title_legacy = $custom["graceful_title"][0];
    26     $graceful_content_legacy = $custom["graceful_content"][0];
    27 // version 1.07 hides graceful variables from custom fields
    2819
    29     if ($graceful_title_legacy!='') {
    30         // this means we have a legacy custom field - need to move it to the new '_graceful' field to hide it from custom fields
    31         delete_post_meta($post->ID, "graceful_title");
    32     }   
     20    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
     21        return $post_id;
     22    }
    3323
    34     if ($graceful_content_legacy!='') {
    35         // this means we have a legacy custom field - need to move it to the new '_graceful' field to hide it from custom fields
    36         delete_post_meta($post->ID, "graceful_content");
    37     }   
    38     update_post_meta($post->ID, "_graceful_title", $_POST["_graceful_title"]);
    39     update_post_meta($post->ID, "_graceful_content", $_POST["_graceful_content"]);
     24    if ('page' == $_POST['post_type']) {
     25        if (!current_user_can('edit_page', $post_id)) {
     26            return $post_id;
     27        }
     28    } elseif (!current_user_can('edit_post', $post_id)) {
     29        return $post_id;
     30    }
     31
     32    $title_current= get_post_meta($post_id,'_graceful_title',true);
     33    $content_current= get_post_meta($post_id,'_graceful_content',true);
     34
     35    $title_new = $_POST['graceful_title'];
     36    $content_new = $_POST['graceful_content'];
     37    if ($title_new != $title_current) {
     38        update_post_meta($post_id, "_graceful_title", $title_new);
     39    }
     40    if ($content_new != $content_current) {
     41        update_post_meta($post_id, "_graceful_content", $content_new);
     42    }
    4043}
    4144
    4245function gs_widget_init() {
    4346
    44   register_sidebar_widget('Graceful Sidebar Widget', 'gs_widget');
    45   register_widget_control('Graceful Sidebar Widget', 'gs_widget_control', '500', '500');
     47    wp_register_sidebar_widget('graceful_sidebar','Graceful Sidebar Widget', 'gs_widget','');
     48    wp_register_widget_control('graceful_sidebar','Graceful Sidebar Widget', 'gs_widget_control', '500', '500');
    4649
    4750}
     
    5558
    5659function gs_meta() {
    57     global $post;
     60    global $post;
    5861
    59     $custom = get_post_custom($post->ID);
    60     $graceful_title_legacy = $custom["graceful_title"][0];
    61     $graceful_content_legacy = $custom["graceful_content"][0];
    62 // version 1.07 hides graceful variables from custom fields
    63     $graceful_title = $custom["_graceful_title"][0];
    64     $graceful_content = $custom["_graceful_content"][0];
     62    $title_current= get_post_meta($post->ID,'_graceful_title',true);
     63    $content_current= get_post_meta($post->ID,'_graceful_content',true);
     64
     65    $title_legacy= get_post_meta($post->ID,'graceful_title',true);
     66    $content_legacy= get_post_meta($post->ID,'graceful_content',true);
    6567
    6668// Clean up legacy
    67     if ($graceful_title_legacy!='' && $graceful_title=='') {
     69    if ($title_legacy!='' && $title_current=='') {
    6870// this means we have a legacy custom field - need to move it to the new '_graceful' field to hide it from custom fields
    69 
    70         update_post_meta($post->ID, "_graceful_title", $graceful_title_legacy);
     71        update_post_meta($post->ID, "_graceful_title", $title_legacy);
    7172        delete_post_meta($post->ID, "graceful_title");
    72         $graceful_title = $graceful_title_legacy;
     73        $title = $title_legacy;
     74    } else {
     75        $title = $title_current;
    7376    }
    74     if ($graceful_content_legacy!='' && $graceful_content=='') {
     77    if ($content_legacy!='' && $content=='') {
    7578        // this means we have a legacy custom field - need to move it to the new '_graceful' field to hide it from custom fields
    76 
    77         update_post_meta($post->ID, "_graceful_content", $graceful_content_legacy);
     79        update_post_meta($post->ID, "_graceful_content", $content_legacy);
    7880        delete_post_meta($post->ID, "graceful_content");
    79         $graceful_content = $graceful_content_legacy;
     81        $graceful_content = $content_legacy;
     82    } else {
     83        $content = $content_current;
    8084    }
    8185       
     
    8387    <p>This content will be displayed in the sidebar for this post or page - ONLY for this post or page.  Be certain that you enable the Graceful Sidebar Widget by dragging it to a sidebar area in your theme from the Appearances->Widgets administration panel.  <a href=http://www.mlynn.org/graceful-sidebar-plugin>More Information</a><p>
    8488    <table class='widefat settings post'>
    85         <thead>
    86             <tr>
    87                 <th>Graceful Sidebar Title</th>
    88                 <th>Graceful Sidebar Content</th>
    89             </tr>
    90         </thead>
    91         <tbody>
    92             <tr>
    93                 <td><input name='_graceful_title' type=text size=40 value='<?php echo $graceful_title;?>'></td>
    94                 <td><div id=editorcontainer><textarea id="content" name='_graceful_content' rows=8 cols=90><?php echo $graceful_content;?></textarea></div></td>
    95             </tr>
     89        <tr>
     90            <thead>
     91                <th valign=top><b>Graceful Sidebar Title:</b></th>
     92            </thead>
     93            <tbody>
     94                <td><input name='graceful_title' type=text size=80 value='<?php echo $title;?>'></td>
     95            </tbody>
     96        </tr>
     97        <tr>
     98            <thead>
     99                <th valign=top><b>Graceful Sidebar Content:</b></th>
     100            </thead>
     101            <tbody>
     102                <td><div id=editorcontainer><textarea id="content" name='graceful_content' rows=8 cols=90><?php echo $content;?></textarea></div></td>
     103            </tbody>
     104        </tr>
    96105        </tbody>
    97106    </table>
     
    109118
    110119    global $post;
     120
     121    $title= get_post_meta($post->ID,'_graceful_title',true);
     122    $content= get_post_meta($post->ID,'_graceful_content',true);
     123
    111124    if (is_single() || is_page()) {
    112125        extract($args);
    113126        $gs_widget_options = unserialize(get_option('gs_widget_options'));
    114127
    115         $title_legacy = get_post_meta($post->ID, 'graceful_title', true);
    116         $content_legacy = get_post_meta($post->ID, 'graceful_content', true);
    117 
    118         $title = get_post_meta($post->ID, '_graceful_title', true);
    119         $content = get_post_meta($post->ID, '_graceful_content', true);
    120 
    121 
    122         $custom = get_post_custom($post->ID);
    123 
    124         $graceful_title_legacy = $custom["graceful_title"][0];
    125         $graceful_content_legacy = $custom["graceful_content"][0];
    126         $graceful_title = $custom["_graceful_title"][0];
    127         $graceful_content = $custom["_graceful_content"][0];
    128 
    129         if ($title_legacy!='' && $title == '') {
    130             // still have legacy custom fields - move them to new fields with _'s to hide them from custom field display
    131             $title = $title_legacy;
    132         }
    133         if ($content_legacy!='' && $content == '') {
    134             // still have legacy custom fields - move them to new fields with _'s to hide them from custom field display
    135             $content = $content_legacy;
    136         }
    137128        if ( $title || $content ) {
    138129
  • graceful-sidebar-plugin/tags/1.0.10/readme.txt

    r326976 r331831  
    77Requires at least: 2.8
    88Tested up to: 3.0.3
    9 Stable tag: 1.0.8
     9Stable tag: 1.0.10
    1010
    1111Create custom sidebars for your posts or pages.
     
    3838
    3939== Changelog ==
     40
     41= Version 1.0.10 =
     42* Found a bug related to post revisions
     43
     44= Version 1.0.9 =
     45* Fixed intermittent failures in save
    4046
    4147= Version 1.0.8 =
     
    7076== Upgrade Notice ==
    7177
     78= 1.0.10 =
     79* Back up your data!  You will need to redrag the widget to your sidebar after upgrading and you may lose the sidebar content of your previous versions.
     80
     81= 1.0.9 =
     82* Fixed Intermittent failures saving
     83
    7284= 1.0.8 =
    7385* Bugfix in save routine - fixed.
  • graceful-sidebar-plugin/trunk/graceful_sidebar.php

    r328418 r331831  
    55Tags: custom sidebar, pages sidebar, custom sidebar
    66Description: Creates a custom sidebar widget to display a custom field from a page.  Create a page or post, enable the widget in your sidebar and add content. Create custom fields called graceful_title and graceful_content. <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KKFYUAMPCQHXQ">Donate</a>
    7 Version: 1.0.8
     7Version: 1.0.10
    88Author: Michael Lynn
    99Author URI: http://www.mlynn.org/
     
    1313add_action("admin_init", "gs_widget_admininit");
    1414add_action('save_post','gs_save_meta');
    15 register_activation_hook( __FILE__, 'gs_activation' );
    1615
    17 function gs_activation() {
    18 
    19 }
    20 
    21 function gs_save_meta(){
     16function gs_save_meta($post_id){
    2217    global $post;
    2318    // Clean up legacy
    24     $custom = get_post_custom($post->ID);
    25     $graceful_title_legacy = $custom["graceful_title"][0];
    26     $graceful_content_legacy = $custom["graceful_content"][0];
    27 // version 1.07 hides graceful variables from custom fields
    2819
    29     if ($graceful_title_legacy!='') {
    30         // this means we have a legacy custom field - need to move it to the new '_graceful' field to hide it from custom fields
    31         delete_post_meta($post->ID, "graceful_title");
    32     }   
     20    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
     21        return $post_id;
     22    }
    3323
    34     if ($graceful_content_legacy!='') {
    35         // this means we have a legacy custom field - need to move it to the new '_graceful' field to hide it from custom fields
    36         delete_post_meta($post->ID, "graceful_content");
    37     }   
    38     update_post_meta($post->ID, "_graceful_title", $_POST["_graceful_title"]);
    39     update_post_meta($post->ID, "_graceful_content", $_POST["_graceful_content"]);
     24    if ('page' == $_POST['post_type']) {
     25        if (!current_user_can('edit_page', $post_id)) {
     26            return $post_id;
     27        }
     28    } elseif (!current_user_can('edit_post', $post_id)) {
     29        return $post_id;
     30    }
     31
     32    $title_current= get_post_meta($post_id,'_graceful_title',true);
     33    $content_current= get_post_meta($post_id,'_graceful_content',true);
     34
     35    $title_new = $_POST['graceful_title'];
     36    $content_new = $_POST['graceful_content'];
     37    if ($title_new != $title_current) {
     38        update_post_meta($post_id, "_graceful_title", $title_new);
     39    }
     40    if ($content_new != $content_current) {
     41        update_post_meta($post_id, "_graceful_content", $content_new);
     42    }
    4043}
    4144
    4245function gs_widget_init() {
    4346
    44   register_sidebar_widget('Graceful Sidebar Widget', 'gs_widget');
    45   register_widget_control('Graceful Sidebar Widget', 'gs_widget_control', '500', '500');
     47    wp_register_sidebar_widget('graceful_sidebar','Graceful Sidebar Widget', 'gs_widget','');
     48    wp_register_widget_control('graceful_sidebar','Graceful Sidebar Widget', 'gs_widget_control', '500', '500');
    4649
    4750}
     
    5558
    5659function gs_meta() {
    57     global $post;
     60    global $post;
    5861
    59     $custom = get_post_custom($post->ID);
    60     $graceful_title_legacy = $custom["graceful_title"][0];
    61     $graceful_content_legacy = $custom["graceful_content"][0];
    62 // version 1.07 hides graceful variables from custom fields
    63     $graceful_title = $custom["_graceful_title"][0];
    64     $graceful_content = $custom["_graceful_content"][0];
     62    $title_current= get_post_meta($post->ID,'_graceful_title',true);
     63    $content_current= get_post_meta($post->ID,'_graceful_content',true);
     64
     65    $title_legacy= get_post_meta($post->ID,'graceful_title',true);
     66    $content_legacy= get_post_meta($post->ID,'graceful_content',true);
    6567
    6668// Clean up legacy
    67     if ($graceful_title_legacy!='' && $graceful_title=='') {
     69    if ($title_legacy!='' && $title_current=='') {
    6870// this means we have a legacy custom field - need to move it to the new '_graceful' field to hide it from custom fields
    69 
    70         update_post_meta($post->ID, "_graceful_title", $graceful_title_legacy);
     71        update_post_meta($post->ID, "_graceful_title", $title_legacy);
    7172        delete_post_meta($post->ID, "graceful_title");
    72         $graceful_title = $graceful_title_legacy;
     73        $title = $title_legacy;
     74    } else {
     75        $title = $title_current;
    7376    }
    74     if ($graceful_content_legacy!='' && $graceful_content=='') {
     77    if ($content_legacy!='' && $content=='') {
    7578        // this means we have a legacy custom field - need to move it to the new '_graceful' field to hide it from custom fields
    76 
    77         update_post_meta($post->ID, "_graceful_content", $graceful_content_legacy);
     79        update_post_meta($post->ID, "_graceful_content", $content_legacy);
    7880        delete_post_meta($post->ID, "graceful_content");
    79         $graceful_content = $graceful_content_legacy;
     81        $graceful_content = $content_legacy;
     82    } else {
     83        $content = $content_current;
    8084    }
    8185       
     
    8387    <p>This content will be displayed in the sidebar for this post or page - ONLY for this post or page.  Be certain that you enable the Graceful Sidebar Widget by dragging it to a sidebar area in your theme from the Appearances->Widgets administration panel.  <a href=http://www.mlynn.org/graceful-sidebar-plugin>More Information</a><p>
    8488    <table class='widefat settings post'>
    85         <thead>
    86             <tr>
    87                 <th>Graceful Sidebar Title</th>
    88                 <th>Graceful Sidebar Content</th>
    89             </tr>
    90         </thead>
    91         <tbody>
    92             <tr>
    93                 <td><input name='_graceful_title' type=text size=40 value='<?php echo $graceful_title;?>'></td>
    94                 <td><div id=editorcontainer><textarea id="content" name='_graceful_content' rows=8 cols=90><?php echo $graceful_content;?></textarea></div></td>
    95             </tr>
     89        <tr>
     90            <thead>
     91                <th valign=top><b>Graceful Sidebar Title:</b></th>
     92            </thead>
     93            <tbody>
     94                <td><input name='graceful_title' type=text size=80 value='<?php echo $title;?>'></td>
     95            </tbody>
     96        </tr>
     97        <tr>
     98            <thead>
     99                <th valign=top><b>Graceful Sidebar Content:</b></th>
     100            </thead>
     101            <tbody>
     102                <td><div id=editorcontainer><textarea id="content" name='graceful_content' rows=8 cols=90><?php echo $content;?></textarea></div></td>
     103            </tbody>
     104        </tr>
    96105        </tbody>
    97106    </table>
     
    109118
    110119    global $post;
     120
     121    $title= get_post_meta($post->ID,'_graceful_title',true);
     122    $content= get_post_meta($post->ID,'_graceful_content',true);
     123
    111124    if (is_single() || is_page()) {
    112125        extract($args);
    113126        $gs_widget_options = unserialize(get_option('gs_widget_options'));
    114127
    115         $title_legacy = get_post_meta($post->ID, 'graceful_title', true);
    116         $content_legacy = get_post_meta($post->ID, 'graceful_content', true);
    117 
    118         $title = get_post_meta($post->ID, '_graceful_title', true);
    119         $content = get_post_meta($post->ID, '_graceful_content', true);
    120 
    121 
    122         $custom = get_post_custom($post->ID);
    123 
    124         $graceful_title_legacy = $custom["graceful_title"][0];
    125         $graceful_content_legacy = $custom["graceful_content"][0];
    126         $graceful_title = $custom["_graceful_title"][0];
    127         $graceful_content = $custom["_graceful_content"][0];
    128 
    129         if ($title_legacy!='' && $title == '') {
    130             // still have legacy custom fields - move them to new fields with _'s to hide them from custom field display
    131             $title = $title_legacy;
    132         }
    133         if ($content_legacy!='' && $content == '') {
    134             // still have legacy custom fields - move them to new fields with _'s to hide them from custom field display
    135             $content = $content_legacy;
    136         }
    137128        if ( $title || $content ) {
    138129
  • graceful-sidebar-plugin/trunk/readme.txt

    r326976 r331831  
    77Requires at least: 2.8
    88Tested up to: 3.0.3
    9 Stable tag: 1.0.8
     9Stable tag: 1.0.10
    1010
    1111Create custom sidebars for your posts or pages.
     
    3838
    3939== Changelog ==
     40
     41= Version 1.0.10 =
     42* Found a bug related to post revisions
     43
     44= Version 1.0.9 =
     45* Fixed intermittent failures in save
    4046
    4147= Version 1.0.8 =
     
    7076== Upgrade Notice ==
    7177
     78= 1.0.10 =
     79* Back up your data!  You will need to redrag the widget to your sidebar after upgrading and you may lose the sidebar content of your previous versions.
     80
     81= 1.0.9 =
     82* Fixed Intermittent failures saving
     83
    7284= 1.0.8 =
    7385* Bugfix in save routine - fixed.
Note: See TracChangeset for help on using the changeset viewer.