Esempio n. 1
0
function save_data($post_ID)
{
    global $wpdb;
    global $box_id;
    if (!wp_is_post_revision($post_ID) && is_admin()) {
        $ct = $_POST['post_type'];
        //require 'fire.php';
        $content_type = $_POST['content_type'];
        change_post_meta($post_ID, 'content_type', $content_type);
        //check all the boxes, and save the ones that have a value
        require $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/wk_content_types/options.php';
        for ($i = 0; $i < sizeof($boxes[$ct]); $i++) {
            $box = $boxes[$ct][$i];
            $fields = $box['fields'];
            //print_r($box);
            //check if we have custom php file
            if ($box['custom'] == '') {
                //each box can have multiple inputs, run through them
                for ($j = 0; $j < sizeof($box['fields']); $j++) {
                    $temp = explode('|', $box['fields'][$j]);
                    $level = $temp[0];
                    $type = $temp[1];
                    $name = $temp[2];
                    $translation = $temp[3];
                    $default = $temp[4];
                    //check the type and add the approprite custom fields
                    if ($type == 'date') {
                        $input = $_POST[$name . '_day'];
                        change_post_meta($post_ID, $name . '_day', $input);
                        $input = $_POST[$name . '_month'];
                        change_post_meta($post_ID, $name . '_month', $input);
                        $input = $_POST[$name . '_year'];
                        change_post_meta($post_ID, $name . '_year', $input);
                        //array_push($vars, $name.'_day', $name.'_month', $name.'_year');
                    } elseif ($type == 'time') {
                        $input = $_POST[$name . '_hour'];
                        change_post_meta($post_ID, $name . '_hour', $input);
                        $input = $_POST[$name . '_minute'];
                        change_post_meta($post_ID, $name . '_minute', $input);
                        //array_push($vars, $name.'_hour', $name.'_minute');
                    } elseif ($type == 'checkbox') {
                        //save and seperate checkbox values
                        $allvalues = explode('~', $temp[5]);
                        //find var_names to add to vars
                        $k = 0;
                        foreach ($allvalues as $val) {
                            if ($k % 2 == 0) {
                                //do nothing
                            } else {
                                //var names are first (before values), so we have the value as input, and as the desired value inside the mysql key
                                $input = $_POST[$val];
                                //name = val is used to empty this cell
                                if ($input != '') {
                                    $name = $input;
                                } else {
                                    $name = $val;
                                }
                                //empty values are not deleted, just left empty
                                change_post_meta($post_ID, $name, $input);
                            }
                            $k++;
                        }
                    } else {
                        $input = $_POST[$name];
                        change_post_meta($post_ID, $name, $input);
                    }
                }
            } else {
                //save the custom codes data
                //find the single values
                $temp = $box['fields'][0];
                $singles = explode('|', $temp);
                //save all singles
                foreach ($singles as $single) {
                    $input = $_POST[$single];
                    change_post_meta($post_ID, $single, $input);
                }
                //find the values that should be saved like date0, date1, date2...
                $temp2 = $b['fields'][1];
                $bases = explode('|', $temp2);
                //run through all the values of the custom
                //the first values indicates how many values we have for each value, example: first = 2, we have date0, date1
                $num = $_POST[$singles[0]];
                //echo $num;
                for ($j = 0; $j < $num; $j++) {
                    //read all fields
                    foreach ($bases as $base) {
                        $input = $_POST[$base . $j];
                        //echo $base.$j . '=  ' . $input;
                        change_post_meta($post_ID, $base . $j, $input);
                    }
                }
                //require 'fire.php';
            }
        }
        //echo "</pre>";
        //require 'fire.php';
    }
}
Esempio n. 2
0
function save_data($post_ID)
{
    global $wpdb;
    global $content_type;
    global $sum;
    global $box_id;
    if (!wp_is_post_revision($post_ID)) {
        $content_type = $_POST['content_type'];
        change_post_meta($post_ID, 'content_type', $content_type);
        //check all the boxes, and save the ones that have a value
        require '../wp-content/plugins/wk_content_types/options.php';
        //find again the correct sum
        $sum = 0;
        //find the id of this post type (την σειρά δηλαδή με την οποία είναι στο options)
        for ($i = 0; $i < sizeof($names); $i++) {
            if ($names[$i] != $content_type) {
                $sum += $boxes[$names[$i]];
            } else {
                break;
            }
        }
        //run through all the boxes of this content type to check for input
        $t = $boxes[$content_type] + $sum;
        for ($i = $sum; $i < $t; $i++) {
            $b = $box[$i];
            //echo "sum=$sum, t=$t";
            //each box can have multiple inputs, run through them
            for ($j = 0; $j < sizeof($b['fields']); $j++) {
                $temp = explode('|', $b['fields'][$j]);
                $level = $temp[0];
                $type = $temp[1];
                $name = $temp[2];
                $translation = $temp[3];
                $default = $temp[4];
                //check the type and add the approprite custom fields
                if ($type == 'date') {
                    $input = $_POST[$name . '_day'];
                    change_post_meta($post_ID, $name . '_day', $input);
                    $input = $_POST[$name . '_month'];
                    change_post_meta($post_ID, $name . '_month', $input);
                    $input = $_POST[$name . '_year'];
                    change_post_meta($post_ID, $name . '_year', $input);
                    //array_push($vars, $name.'_day', $name.'_month', $name.'_year');
                } elseif ($type == 'time') {
                    $input = $_POST[$name . '_hour'];
                    change_post_meta($post_ID, $name . '_hour', $input);
                    $input = $_POST[$name . '_minute'];
                    change_post_meta($post_ID, $name . '_minute', $input);
                    //array_push($vars, $name.'_hour', $name.'_minute');
                } elseif ($type == 'checkbox') {
                    //save and seperate checkbox values
                    $allvalues = explode('~', $temp[5]);
                    //find var_names to add to vars
                    $i = 0;
                    foreach ($allvalues as $val) {
                        if ($i % 2 == 0) {
                            //do nothing
                        } else {
                            //var names are first (before values)
                            $input = $_POST[$name];
                            change_post_meta($post_ID, $name, $input);
                        }
                        $i++;
                    }
                } else {
                    $input = $_POST[$name];
                    change_post_meta($post_ID, $name, $input);
                }
            }
        }
    }
}
Esempio n. 3
0
function save_data($post_ID)
{
    global $wpdb;
    global $content_type;
    global $sum;
    global $box_id;
    if (!wp_is_post_revision($post_ID) && $_POST['post_type'] == 'post' && is_admin()) {
        //print_r($_POST);
        //require 'fire.php';
        $content_type = $_POST['content_type'];
        change_post_meta($post_ID, 'content_type', $content_type);
        //check all the boxes, and save the ones that have a value
        require $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/wk_content_types/options.php';
        //find again the correct sum
        $sum = 0;
        //find the id of this post type (την σειρά δηλαδή με την οποία είναι στο options)
        for ($i = 0; $i < sizeof($names); $i++) {
            if ($names[$i] != $content_type) {
                $sum += $boxes[$names[$i]];
            } else {
                break;
            }
        }
        //run through all the boxes of this content type to check for input
        $t = $boxes[$content_type] + $sum;
        for ($i = $sum; $i < $t; $i++) {
            $b = $box[$i];
            //echo "sum=$sum, t=$t";
            //check if we have custom php file
            if ($b['custom'] == '') {
                //each box can have multiple inputs, run through them
                for ($j = 0; $j < sizeof($b['fields']); $j++) {
                    $temp = explode('|', $b['fields'][$j]);
                    $level = $temp[0];
                    $type = $temp[1];
                    $name = $temp[2];
                    $translation = $temp[3];
                    $default = $temp[4];
                    //check the type and add the approprite custom fields
                    if ($type == 'date') {
                        $input = $_POST[$name . '_day'];
                        change_post_meta($post_ID, $name . '_day', $input);
                        $input = $_POST[$name . '_month'];
                        change_post_meta($post_ID, $name . '_month', $input);
                        $input = $_POST[$name . '_year'];
                        change_post_meta($post_ID, $name . '_year', $input);
                        //array_push($vars, $name.'_day', $name.'_month', $name.'_year');
                    } elseif ($type == 'time') {
                        $input = $_POST[$name . '_hour'];
                        change_post_meta($post_ID, $name . '_hour', $input);
                        $input = $_POST[$name . '_minute'];
                        change_post_meta($post_ID, $name . '_minute', $input);
                        //array_push($vars, $name.'_hour', $name.'_minute');
                    } elseif ($type == 'checkbox') {
                        //save and seperate checkbox values
                        $allvalues = explode('~', $temp[5]);
                        //find var_names to add to vars
                        $k = 0;
                        foreach ($allvalues as $val) {
                            if ($k % 2 == 0) {
                                //do nothing
                            } else {
                                //var names are first (before values), so we have the value as input, and as the desired value inside the mysql key
                                $input = $_POST[$val];
                                //name = val is used to empty this cell
                                if ($input != '') {
                                    $name = $input;
                                } else {
                                    $name = $val;
                                }
                                //empty values are not deleted, just left empty
                                change_post_meta($post_ID, $name, $input);
                            }
                            $k++;
                        }
                    } else {
                        $input = $_POST[$name];
                        change_post_meta($post_ID, $name, $input);
                    }
                }
            } else {
                $temp = $b['fields'][0];
                $singles = explode('|', $temp);
                //save all singles
                foreach ($singles as $single) {
                    $input = $_POST[$single];
                    change_post_meta($post_ID, $single, $input);
                }
                $temp2 = $b['fields'][1];
                $bases = explode('|', $temp2);
                //run through all the values of the custom
                $num = $_POST[$singles[0]];
                for ($j = 0; $j < $num; $j++) {
                    //read all fields
                    foreach ($bases as $base) {
                        $input = $_POST[$base . $j];
                        change_post_meta($post_ID, $base . $j, $input);
                    }
                }
            }
        }
    }
}