Esempio n. 1
0
 function save_site_css($response, $data)
 {
     $css = $data['store'];
     $global_settings = pl_settings();
     $global_settings['settings']['site_css'] = $css;
     pl_settings_update($global_settings);
     return $response;
 }
Esempio n. 2
0
 function current_page_data($scope = 'local')
 {
     $d = array();
     if ($scope == 'local') {
         $d = pl_settings($this->draft->mode, $this->page->id);
     } elseif ($scope == 'type') {
         $d = pl_settings($this->draft->mode, $this->page->typeid);
     } elseif ($scope == 'section') {
         global $sections_handler;
         $d = $sections_handler->get_user_section_settings();
     } elseif ($scope == 'template') {
         global $pl_custom_template;
         $d = !empty($pl_custom_template) ? $pl_custom_template['settings'] : array();
     } elseif ($scope == 'global') {
         $d = pl_get_global_settings(pl_get_mode());
     }
     return $d ? $d : array();
 }
Esempio n. 3
0
 function save_form($response, $data)
 {
     $form = $data['store'];
     $scope = $data['scope'];
     $key = isset($data['key']) ? $data['key'] : false;
     $uid = isset($data['uid']) && $data['uid'] != 'false' ? $data['uid'] : false;
     if (!empty($uid)) {
         global $sections_data_handler;
         $response['result'] = $sections_data_handler->update_or_insert(array('uid' => $uid, 'draft' => $form[$uid]));
     }
     if ($scope == 'global' || isset($form['settings']) && is_array($form['settings'])) {
         $global_settings = pl_settings();
         // First parse sub settings field
         if (isset($form['settings'])) {
             $form['settings'] = wp_parse_args($form['settings'], $global_settings['settings']);
         }
         $response['form'] = $form;
         $global_settings = wp_parse_args($form, $global_settings);
         pl_settings_update($global_settings);
     }
     if ($scope == 'type' || $scope == 'local') {
         $metaID = $scope == 'type' ? $data['typeID'] : $data['pageID'];
         $meta_settings = pl_settings('draft', $metaID);
         $meta_settings = wp_parse_args($form, $meta_settings);
         pl_settings_update($meta_settings, 'draft', $metaID);
     }
     if ($scope == 'template') {
         $handler = new PLCustomTemplates();
         $old_settings = $handler->retrieve_field($key, 'settings');
         $settings = wp_parse_args($form, $old_settings);
         $handler->update($key, array('settings' => $settings));
     }
     if ($scope == 'section') {
         $handler = new PLCustomSections();
         $old_settings = $handler->retrieve_field($key, 'settings');
         $settings = wp_parse_args($form, $old_settings);
         $handler->update($key, array('settings' => $settings));
         $response['settings'] = $settings;
         $response['new'] = $handler->retrieve($key);
     }
     $response['scope'] = $scope;
     return $response;
 }