From 1c0985e5d0bef950a1c80125235354b0970bdc06 Mon Sep 17 00:00:00 2001 From: Darren Wood Date: Wed, 31 Oct 2012 14:19:36 +1300 Subject: [PATCH 1/2] added the ability to use a CSS preprocessor by defining some variables in the functions file. --- functions.php | 150 ++++++++++++++++++++++++++++++------------------ loop-single.php | 11 ++-- 2 files changed, 101 insertions(+), 60 deletions(-) diff --git a/functions.php b/functions.php index 326082f..8106a4e 100644 --- a/functions.php +++ b/functions.php @@ -1,4 +1,98 @@ ID,'html',true); + $style = get_post_meta($post->ID,STYLE_TYPE,true); + + echo '

These fields are for the HTML markup and '.STYLE_TYPE.' styles. The post body can be used for notes.

'; + echo ''; + echo '

'; + echo ' '; + echo '

'; +} + +function pears_save_post( $post_id ) { + + // Ignore if doing an autosave + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) + return; + + // verify data came from pears meta box + if ( !wp_verify_nonce( $_POST['pears_noncename'], plugin_basename( __FILE__ ) ) ) + return; + + // Check user permissions + if ( 'post' == $_POST['post_type'] ) { + if ( !current_user_can( 'edit_page', $post_id ) ) + return; + } + else{ + if ( !current_user_can( 'edit_post', $post_id ) ) + return; + } + + $html_data = $_POST['html']; + update_post_meta($post_id, 'html', $html_data); + + $style_data = $_POST['style']; + update_post_meta($post_id, STYLE_TYPE, $style_data); +} + +// call css STYLE_TYPE convertion API +function convertScss($url, $source){ + if (STYLE_TYPE != 'css') { + $postfields = array(); + $postfields["type"] = STYLE_TYPE; + $postfields["source"] = (COMPASS) ? "@import 'compass';\n\n".$source : $source; + + $the_query = http_build_query($postfields); + + $session = curl_init(); + + curl_setopt($session, CURLOPT_URL, $url); + curl_setopt($session, CURLOPT_POST, true); + curl_setopt($session, CURLOPT_RETURNTRANSFER, true); + curl_setopt($session, CURLOPT_POSTFIELDS, http_build_query($postfields)); + + $data = curl_exec($session); + curl_close($session); + + } else { + $data = $source; + } + return $data; + +} + + + /** * TwentyTen functions and definitions * @@ -506,59 +600,3 @@ function twentyten_posted_in() { ); } endif; - -add_action( 'add_meta_boxes', 'pears_add_meta_box' ); -add_action( 'save_post', 'pears_save_post' ); - -function pears_add_meta_box() { - - add_meta_box( - 'pears', - 'Pears', - 'pears_meta_box', - 'post', - 'normal', - 'high' - ); - -} - -function pears_meta_box( $post ) { - wp_nonce_field( plugin_basename( __FILE__ ), 'pears_noncename' ); - - $html = get_post_meta($post->ID,'html',true); - $css = get_post_meta($post->ID,'css',true); - - echo '

These fields are for the HTML markup and CSS styles. The post body can be used for notes.

'; - echo ''; - echo '

'; - echo ' '; - echo '

'; -} - -function pears_save_post( $post_id ) { - - // Ignore if doing an autosave - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) - return; - - // verify data came from pears meta box - if ( !wp_verify_nonce( $_POST['pears_noncename'], plugin_basename( __FILE__ ) ) ) - return; - - // Check user permissions - if ( 'post' == $_POST['post_type'] ) { - if ( !current_user_can( 'edit_page', $post_id ) ) - return; - } - else{ - if ( !current_user_can( 'edit_post', $post_id ) ) - return; - } - - $html_data = $_POST['html']; - update_post_meta($post_id, 'html', $html_data); - - $css_data = $_POST['css']; - update_post_meta($post_id, 'css', $css_data); -} diff --git a/loop-single.php b/loop-single.php index 7feca62..faccfcb 100644 --- a/loop-single.php +++ b/loop-single.php @@ -18,7 +18,10 @@
@@ -40,9 +43,9 @@
-

CSS

copy -
From 9c98e6ced949626ec3644fc9ec29582dce46fc15 Mon Sep 17 00:00:00 2001 From: Darren Wood Date: Wed, 31 Oct 2012 15:01:58 +1300 Subject: [PATCH 2/2] fixed spelling mistake --- functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 8106a4e..50880c5 100644 --- a/functions.php +++ b/functions.php @@ -3,7 +3,7 @@ * Pears functions and customizations **/ -// Setup for CSS STYLE_TYPEs +// Setup for CSS preprocessors // Possible options here: // css, sass, scss, less, stylus define("STYLE_TYPE", "scss");