/**
  *
  * @TODO document
  *
  */
 function save_profile_admin($user_ID)
 {
     if (!isset($this->tabs) || empty($this->tabs)) {
         return;
     }
     // Loop through tabs
     foreach ($this->tabs as $tab => $t) {
         // Loop through tab options
         foreach ($t->options as $oid => $o) {
             // Note: If the value is null, then test to see if the option is already set to something
             // create and overwrite the option to null in that case (i.e. it is being set to empty)
             if (isset($o['selectvalues']) && pagelines_is_multi_option($oid, $o)) {
                 foreach ($o['selectvalues'] as $sid => $s) {
                     $option_value = isset($_POST[$sid]) ? $_POST[$sid] : null;
                     if (!empty($option_value) || pl_um($sid, $user_ID)) {
                         update_post_meta($user_ID, $sid, $option_value);
                     }
                 }
             } else {
                 $option_value = isset($_POST[$oid]) ? $_POST[$oid] : null;
                 if (!empty($option_value) || pl_um($oid, $user_ID)) {
                     update_user_meta($user_ID, $oid, $option_value);
                 }
             }
         }
     }
 }
Example #2
0
/**
 * This function registers the default values for pagelines theme settings
 */
function pagelines_settings_defaults()
{
    $default_options = array();
    foreach (get_option_array(true) as $menuitem => $options) {
        foreach ($options as $oid => $o) {
            if (isset($o['type']) && 'layout' == $o['type']) {
                $dlayout = new PageLinesLayout();
                $default_options['layout'] = $dlayout->default_layout_setup();
            } elseif (pagelines_is_multi_option($oid, $o)) {
                foreach ($o['selectvalues'] as $multi_optionid => $multi_o) {
                    if (isset($multi_o['default'])) {
                        $default_options[$multi_optionid] = $multi_o['default'];
                    }
                }
            } else {
                if (!VPRO && isset($o['version_set_default']) && $o['version_set_default'] == 'pro') {
                    $default_options[$oid] = null;
                } elseif (!VPRO && isset($o['default_free'])) {
                    $default_options[$oid] = $o['default_free'];
                } elseif (isset($o['default'])) {
                    $default_options[$oid] = $o['default'];
                }
            }
        }
    }
    return apply_filters('pagelines_settings_defaults', $default_options);
}
 /**
  * Save Meta Options
  *
  * Use tabs array to save options...
  * Need to identify if the option is being set to empty or has never been set
  * *Section Control* gets its own saving schema
  */
 function save_meta_options($postID)
 {
     // Make sure we are saving on the correct post type...
     // Current post type is passed in $_POST
     $current_post_type = isset($_POST['post_type']) ? $_POST['post_type'] : false;
     $post_type_save = in_array($current_post_type, $this->settings['posttype']) ? true : false;
     if ((isset($_POST['update']) || isset($_POST['save']) || isset($_POST['publish'])) && $post_type_save) {
         $page_template = isset($_POST['page_template']) ? $_POST['page_template'] : null;
         $save_template = $this->get_save_template_type($_POST['post_type'], $page_template);
         $template_type = new PageLinesTemplate($save_template);
         $template_type->load_section_optionator();
         // Loop through tabs
         foreach ($this->tabs as $tab => $t) {
             // Loop through tab options
             foreach ($t->options as $oid => $o) {
                 if ($oid == 'section_control') {
                     $this->save_sc($postID);
                 } elseif ($oid == 'page_background_image') {
                     $this->save_bg($oid, $postID);
                 } elseif ($o['type'] == 'text_content' || $o['type'] == 'text_content_reverse') {
                     $option_value = isset($_POST[$oid]) ? $_POST[$oid] : null;
                     plupop($oid, $option_value);
                     plupop($oid, $option_value, array('setting' => PAGELINES_SPECIAL));
                 } elseif ($o['type'] == 'check' && (bool) pldefault($oid)) {
                     $reverse = $oid . "_reverse";
                     $option_value = isset($_POST[$reverse]) ? $_POST[$reverse] : null;
                     if (!empty($option_value) || get_post_meta($postID, $reverse)) {
                         update_post_meta($postID, $reverse, $option_value);
                     }
                 } else {
                     // Note: If the value is null, then test to see if the option is already set to something
                     // create and overwrite the option to null in that case (i.e. it is being set to empty)
                     if (isset($o['selectvalues']) && pagelines_is_multi_option($oid, $o)) {
                         foreach ($o['selectvalues'] as $sid => $s) {
                             $option_value = isset($_POST[$sid]) ? $_POST[$sid] : null;
                             if (!empty($option_value) || get_post_meta($postID, $sid)) {
                                 update_post_meta($postID, $sid, $option_value);
                             }
                         }
                     } else {
                         $option_value = isset($_POST[$oid]) ? $_POST[$oid] : null;
                         if (!empty($option_value) || get_post_meta($postID, $oid)) {
                             update_post_meta($postID, $oid, $option_value);
                         }
                     }
                 }
             }
         }
     }
 }