예제 #1
0
 /**
  * Instantiates and returns class singleton
  * 
  * @return CAS_App 
  */
 public static function instance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
/**
 * 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);
}
예제 #3
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);
         }
     }
 }
예제 #4
0
 /**
  * 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) : "";
 }