Пример #1
0
 /**
  *
  * @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);
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  *
  * @TODO document
  *
  */
 function order($a, $b)
 {
     $ap = pl_um($this->args['order_field'], $a->ID) ? pl_um($this->args['order_field'], $a->ID) : 10;
     $bp = pl_um($this->args['order_field'], $b->ID) ? pl_um($this->args['order_field'], $b->ID) : 10;
     if ($ap == $bp) {
         return 0;
     }
     return $ap < $bp ? -1 : 1;
 }
 /**
  * Option generation engine
  *
  * Flag needed for post id/profile id -- settings for special handling.
  */
 function option_engine($oid, $o, $flag = null, $setting = null)
 {
     $o = wp_parse_args($o, $this->defaults);
     $o = $this->make_adjustments($o);
     if ($o['disabled']) {
         return;
     }
     $setting = isset($this->settings_field) ? $this->settings_field : PAGELINES_SETTINGS;
     $oset = array('setting' => $setting);
     if ($o['type'] == 'select_same') {
         $new = array_flip($o['selectvalues']);
         foreach ($new as $key => $val) {
             $new[$key] = array('name' => $key);
         }
         $o['selectvalues'] = $new;
     }
     if ($this->settings_field == 'meta') {
         $oset['post_id'] = $flag;
         $o['pid'] = $flag;
         $o['input_id'] = get_pagelines_option_id($oid);
         if ($o['type'] == 'check' && (bool) pldefault($oid)) {
             $o['val'] = plmeta($oid . '_reverse', $oset);
             $o['input_name'] = $oid . '_reverse';
             $o['inputlabel'] = '(Turn Off) ' . $o['inputlabel'];
         } else {
             $o['val'] = plmeta($oid, $oset);
             $o['input_name'] = $oid;
         }
         // Check is difficult w/ defaults got to compensate
         $o['placeholder'] = pldefault($oid, $oset);
         // Parse through multi-selects
         if (!empty($o['selectvalues'])) {
             foreach ($o['selectvalues'] as $sid => $s) {
                 $o['selectvalues'][$sid]['val'] = plmeta($sid, $oset);
                 $o['selectvalues'][$sid]['input_id'] = get_pagelines_option_id($oid, $sid);
                 $o['selectvalues'][$sid]['input_name'] = $sid;
                 $o['selectvalues'][$sid]['placeholder'] = pldefault($sid, $oset);
             }
         }
     } elseif ($this->settings_field == 'profile') {
         $user = $flag;
         $o['val'] = pl_um($oid, $user->ID);
         $o['input_name'] = $oid;
         $o['input_id'] = get_pagelines_option_id($oid);
         if (!empty($o['selectvalues'])) {
             foreach ($o['selectvalues'] as $sid => $s) {
                 $o['selectvalues'][$sid]['val'] = pl_um($oid, $user->ID);
                 $o['selectvalues'][$sid]['input_id'] = get_pagelines_option_id($sid);
                 $o['selectvalues'][$sid]['input_name'] = $sid;
             }
         }
     } elseif ($this->settings_field == PAGELINES_SPECIAL) {
         if ($o['special'] != 'default' && $o['type'] == 'check' && (bool) pldefault($oid)) {
             $oset['subkey'] = $oid . '_reverse';
             $o['inputlabel'] = '(Turn Off) ' . $o['inputlabel'];
         } else {
             $oset['subkey'] = $oid;
         }
         $o['val'] = ploption($o['special'], $oset);
         $o['input_name'] = plname($o['special'], $oset);
         $o['input_id'] = plid($o['special'], $oset);
         $o['placeholder'] = pldefault($oid, $oset);
         // What a hassle.
         // Allow global option for text content (no sub key)
         // If 'hidden' then option will be nuked on save, so in class.sections.php
         // there is an 'upop' that updates to global settings
         if ($o['type'] == 'text_content' || $o['type'] == 'text_content_reverse') {
             $oset['subkey'] = null;
             $o['val'] = ploption($oid, $oset);
             $o['input_name'] = plname($oid, $oset);
         }
         if (!empty($o['selectvalues'])) {
             foreach ($o['selectvalues'] as $sid => $s) {
                 $oset['subkey'] = $sid;
                 $oset['clone_id'] = $o['clone_id'];
                 $o['selectvalues'][$sid]['val'] = ploption($o['special'], $oset);
                 $o['selectvalues'][$sid]['input_id'] = plid($o['special'], $oset);
                 $o['selectvalues'][$sid]['input_name'] = plname($o['special'], $oset);
                 $o['selectvalues'][$sid]['placeholder'] = pldefault($sid, $oset);
             }
         }
     } else {
         $o['val'] = ploption($oid, $oset);
         $o['input_name'] = get_pagelines_option_name($oid, null, null, $setting);
         $o['input_id'] = get_pagelines_option_id($oid, null, null, $setting);
         if (!empty($o['selectvalues'])) {
             foreach ($o['selectvalues'] as $sid => $s) {
                 $o['selectvalues'][$sid]['val'] = ploption($sid, $oset);
                 $o['selectvalues'][$sid]['input_id'] = get_pagelines_option_id($sid);
                 $o['selectvalues'][$sid]['input_name'] = get_pagelines_option_name($sid, null, null, $setting);
             }
         }
     }
     $o['placeholder'] = pl_html($o['placeholder']);
     if ($this->_do_the_option($oid, $o)) {
         printf('<div class="optionrow fix %s">', $this->_layout_class($o));
         $this->get_option_title($oid, $o);
         printf('<div class="optin fix"><div class="oinputs"><div class="oinputs-pad">');
         $this->option_breaker($oid, $o);
         printf('</div></div>');
         echo $this->_get_explanation($oid, $o);
         echo '<div class="clear"></div></div></div>';
     }
 }