Beispiel #1
0
 /**
  * Save meta values for post
  * @param  int $post_id 
  * @return void 
  */
 public function save_post($post_id)
 {
     // Save button pressed
     if (!isset($_POST['original_publish']) && !isset($_POST['save_post'])) {
         return;
     }
     // Only sidebar type
     if (get_post_type($post_id) != CAS_App::TYPE_SIDEBAR) {
         return;
     }
     // Verify nonce
     if (!check_admin_referer(WPCACore::PREFIX . $post_id, WPCACore::NONCE)) {
         return;
     }
     // Check permissions
     if (!current_user_can(CAS_App::CAPABILITY, $post_id)) {
         return;
     }
     // Check autosave
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // Update metadata
     foreach (CAS_App::instance()->manager()->metadata()->get_all() as $field) {
         $new = isset($_POST[$field->get_id()]) ? $_POST[$field->get_id()] : '';
         $old = $field->get_data($post_id);
         if ($new != '' && $new != $old) {
             $field->update($post_id, $new);
         } elseif ($new == '' && $old != '') {
             $field->delete($post_id, $old);
         }
     }
 }
/**
 * Template wrapper to display content aware sidebars
 *
 * @since  3.0
 * @param  array|string  $args 
 * @return void 
 */
function ca_display_sidebar($args = array())
{
    CAS_App::instance()->manager()->manual_sidebar($args);
}
 /**
  * Display merge position column
  *
  * @since  3.1
  * @param  string  $column_name
  * @param  int     $post_id
  * @return string
  */
 protected function column_merge_pos($column_name, $post_id)
 {
     $metadata = CAS_App::instance()->manager()->metadata()->get($column_name);
     return $metadata ? $metadata->get_list_data($post_id) : "";
 }