ID) { $js = stripcslashes(get_post_meta($post->ID, 'easyjscss_js', true)); $jsfile = stripcslashes(get_post_meta($post->ID, 'easyjscss_jsfile', true)); $css = stripcslashes(get_post_meta($post->ID, 'easyjscss_css', true)); $cssfile = stripcslashes(get_post_meta($post->ID, 'easyjscss_cssfile', true)); if ($js == "") { $js = stripcslashes(get_post_meta($post->ID, '_easyjscss_js', true)); } if ($jsfile == "") { $jsfile = stripcslashes(get_post_meta($post->ID, '_easyjscss_jsfile', true)); } if ($css == "") { $css = stripcslashes(get_post_meta($post->ID, '_easyjscss_css', true)); } if ($cssfile == "") { $cssfile = stripcslashes(get_post_meta($post->ID, '_easyjscss_cssfile', true)); } } if (trim($jsfile) != "") { $lines = explode("\n", $jsfile); for ($i=0; $i"; } } if (trim($js) != "") { echo ""; } if (trim($cssfile) != "") { $lines = explode("\n", $cssfile); for ($i=0; $i"; } } if (trim($css) != "") { echo ''; } } function easyjscss_meta_box_add() { add_meta_box('_easyjscss','Easy JS/CSS', array($this, 'easyjscss_meta'),'post'); add_meta_box('_easyjscss','Easy JS/CSS', array($this, 'easyjscss_meta'),'page'); } function convert_old($post_id, $name) { $_temp = get_post_meta($post_id, $name, true); delete_post_meta($post_id, $name); delete_post_meta($post_id,'_'.$name); add_post_meta($post_id, '_'.$name, $_temp); } function easyjscss_meta() { global $post; 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) ) { $this->convert_old($post->ID, "easyjscss_js"); $this->convert_old($post->ID, "easyjscss_jsfile"); $this->convert_old($post->ID, "easyjscss_css"); $this->convert_old($post->ID, "easyjscss_cssfile"); } $js = stripcslashes(get_post_meta($post->ID, '_easyjscss_js', true)); $jsfile = stripcslashes(get_post_meta($post->ID, '_easyjscss_jsfile', true)); $css = stripcslashes(get_post_meta($post->ID, '_easyjscss_css', true)); $cssfile = stripcslashes(get_post_meta($post->ID, '_easyjscss_cssfile', true)); echo "Javascript include. (insert 1 file pr line, that should be included in the head-tag):
"; echo "
"; echo "Javascript ( insert any javascript you want here. Ie: alert(\"Hello world\"); ):
"; echo "

"; echo "CSS include. (insert 1 file pr line, that should be included in the head-tag):
"; echo "
"; echo "CSS ( insert any css codes here. Ie: body { color: #FF0000;} ):
"; echo "
"; } function update_tags($id) { if (isset($_POST["easyjscss_js"])) { $js = $_POST["easyjscss_js"]; $jsfile = $_POST["easyjscss_jsfile"]; $css = $_POST["easyjscss_css"]; $cssfile = $_POST["easyjscss_cssfile"]; delete_post_meta($id, '_easyjscss_js'); delete_post_meta($id, '_easyjscss_jsfile'); delete_post_meta($id, '_easyjscss_css'); delete_post_meta($id, '_easyjscss_cssfile'); add_post_meta($id, '_easyjscss_js', $js); add_post_meta($id, '_easyjscss_jsfile', $jsfile); add_post_meta($id, '_easyjscss_css', $css); add_post_meta($id, '_easyjscss_cssfile', $cssfile); } } } $easyjscss = new easyjscss(); add_action('admin_menu', array($easyjscss, 'easyjscss_meta_box_add')); add_action('wp_head', array($easyjscss, 'add_content_to_header'), 15); add_action('edit_post', array($easyjscss, 'update_tags',),5); ?>