Plugin Directory

Changeset 222443


Ignore:
Timestamp:
03/28/2010 02:31:41 PM (16 years ago)
Author:
jswp
Message:

bugfixes

Location:
easyjscss/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • easyjscss/trunk/easyjscss.php

    r135453 r222443  
    33Plugin Name: Easy JS and CSS support.
    44Plugin URI: http://huuah.com/easyjscss
    5 Version: 1.3
     5Version: 1.4
    66Description: Adds the options to setup post/page specific javascript and css.
    77*/
     
    1616            $css     = stripcslashes(get_post_meta($post->ID, 'easyjscss_css', true));
    1717            $cssfile = stripcslashes(get_post_meta($post->ID, 'easyjscss_cssfile', true));
     18            if ($js == "") {
     19                $js     = stripcslashes(get_post_meta($post->ID, '_easyjscss_js', true));
     20            }
     21            if ($jsfile == "") {
     22                $jsfile = stripcslashes(get_post_meta($post->ID, '_easyjscss_jsfile', true));
     23            }
     24            if ($css == "") {
     25                $css    = stripcslashes(get_post_meta($post->ID, '_easyjscss_css', true));
     26            }
     27            if ($cssfile == "") {
     28                $cssfile      = stripcslashes(get_post_meta($post->ID, '_easyjscss_cssfile', true));
     29            }
    1830        }
    1931        if (trim($jsfile) != "") {
     
    4052   
    4153    function easyjscss_meta_box_add() {
    42         add_meta_box('easyjscss','Easy JS/CSS', array($this, 'easyjscss_meta'),'post');
    43         add_meta_box('easyjscss','Easy JS/CSS', array($this, 'easyjscss_meta'),'page');
     54        add_meta_box('_easyjscss','Easy JS/CSS', array($this, 'easyjscss_meta'),'post');
     55        add_meta_box('_easyjscss','Easy JS/CSS', array($this, 'easyjscss_meta'),'page');
     56    }
     57
     58    function convert_old($post_id, $name) {
     59        $_temp = get_post_meta($post_id, $name, true);
     60        delete_post_meta($post_id, $name);
     61        delete_post_meta($post_id,'_'.$name);
     62        add_post_meta($post_id, '_'.$name, $_temp);
    4463    }
    4564
    4665    function easyjscss_meta() {
    4766        global $post;
    48         $js      = stripcslashes(get_post_meta($post->ID, 'easyjscss_js', true));
    49         $jsfile  = stripcslashes(get_post_meta($post->ID, 'easyjscss_jsfile', true));
    50         $css     = stripcslashes(get_post_meta($post->ID, 'easyjscss_css', true));
    51         $cssfile = stripcslashes(get_post_meta($post->ID, 'easyjscss_cssfile', true));
     67
     68        if ( get_post_meta($post->ID, 'easyjscss_js', true) || get_post_meta($post->ID, 'easyjscss_jsfile', true) || get_post_meta($post->ID, 'easyjscss_css', true) || get_post_meta($post->ID, 'easyjscss_cssfile', true)    ) {
     69            $this->convert_old($post->ID, "easyjscss_js");
     70            $this->convert_old($post->ID, "easyjscss_jsfile");
     71            $this->convert_old($post->ID, "easyjscss_css");
     72            $this->convert_old($post->ID, "easyjscss_cssfile");
     73        }
     74
     75        $js      = stripcslashes(get_post_meta($post->ID, '_easyjscss_js', true));
     76        $jsfile  = stripcslashes(get_post_meta($post->ID, '_easyjscss_jsfile', true));
     77        $css     = stripcslashes(get_post_meta($post->ID, '_easyjscss_css', true));
     78        $cssfile = stripcslashes(get_post_meta($post->ID, '_easyjscss_cssfile', true));
    5279        echo "Javascript include. (insert 1 file pr line, that should be included in the head-tag):<br>";
    5380        echo "<textarea style=\"width: 90%; height: 50px;\" name=\"easyjscss_jsfile\">$jsfile</textarea><br>";
     
    6188
    6289    function update_tags($id) {
    63         $js      = $_POST["easyjscss_js"];
    64         $jsfile  = $_POST["easyjscss_jsfile"];
    65         $css     = $_POST["easyjscss_css"];
    66         $cssfile = $_POST["easyjscss_cssfile"];
    67         delete_post_meta($id, 'easyjscss_js');
    68         delete_post_meta($id, 'easyjscss_jsfile');
    69         delete_post_meta($id, 'easyjscss_css');
    70         delete_post_meta($id, 'easyjscss_cssfile');
    71         add_post_meta($id, 'easyjscss_js', $js);
    72         add_post_meta($id, 'easyjscss_jsfile', $jsfile);
    73         add_post_meta($id, 'easyjscss_css', $css);
    74         add_post_meta($id, 'easyjscss_cssfile', $cssfile);
     90        if (isset($_POST["easyjscss_js"])) {
     91            $js      = $_POST["easyjscss_js"];
     92            $jsfile  = $_POST["easyjscss_jsfile"];
     93            $css     = $_POST["easyjscss_css"];
     94            $cssfile = $_POST["easyjscss_cssfile"];
     95            delete_post_meta($id, '_easyjscss_js');
     96            delete_post_meta($id, '_easyjscss_jsfile');
     97            delete_post_meta($id, '_easyjscss_css');
     98            delete_post_meta($id, '_easyjscss_cssfile');
     99            add_post_meta($id, '_easyjscss_js', $js);
     100            add_post_meta($id, '_easyjscss_jsfile', $jsfile);
     101            add_post_meta($id, '_easyjscss_css', $css);
     102            add_post_meta($id, '_easyjscss_cssfile', $cssfile);
     103        }
    75104    }
    76105
     
    81110add_action('admin_menu', array($easyjscss, 'easyjscss_meta_box_add'));
    82111add_action('wp_head', array($easyjscss, 'add_content_to_header'), 15);
    83 add_action('edit_post', array($easyjscss, 'update_tags'));
     112add_action('edit_post', array($easyjscss, 'update_tags',),5);
    84113
    85114?>
  • easyjscss/trunk/readme.txt

    r175872 r222443  
    33Tags: easy, css, js, stylesheet, javascript
    44Requires at least: 2.8.0
    5 Tested up to: 2.8.6
    6 Stable tag: 1.3
     5Tested up to: 2.9.2
     6Stable tag: 1.4
    77
    88Adds the options to insert page/post specific javascript and css.
     
    3333* First stable upload
    3434
    35 
    36 
    37 
     35= 1.4 =
     36* Bugfix: fields got remove on comment update.
     37* Meta-fields are now prefixed with _ to make them hidden.
Note: See TracChangeset for help on using the changeset viewer.