/**
  * @group gets
  */
 public function test_gets__メタデータが保存されていないときは空値()
 {
     update_post_meta($this->post_id, 'text', 'hoge');
     add_post_meta($this->post_id, 'checkbox', 1);
     add_post_meta($this->post_id, 'checkbox', 2);
     // ループ内のチェックボックス(複数値項目)は必ずこのメタデータを持つ
     update_post_meta($this->post_id, SCF_Config::PREFIX . 'repeat-multiple-data', array('checkbox3' => array(1, 2)));
     add_post_meta($this->post_id, 'checkbox3', 1);
     add_post_meta($this->post_id, 'checkbox3', 2);
     add_post_meta($this->post_id, 'checkbox3', 3);
     $this->assertEquals(array('text' => 'hoge', 'checkbox' => array(1, 2), 'group-name-3' => array(array('text3' => '', 'checkbox3' => array(1)), array('text3' => '', 'checkbox3' => array(2, 3))), 'text-has-default' => '', 'text-has-not-default' => '', 'checkbox-has-default' => array(), 'checkbox-has-not-default' => array()), SCF::gets($this->post_id));
 }
示例#2
0
 /**
  * リビジョン比較画面にメタデータを表示
  * 
  * @param $value
  * @param $column
  * @param array $post
  * @return string
  */
 public function _wp_post_revision_field_debug_preview($value, $column, $post)
 {
     $output = '';
     $values = SCF::gets($post->ID);
     foreach ($values as $field_name_or_group_name => $value) {
         $output .= sprintf("■ %s\n", $field_name_or_group_name);
         if (is_array($value)) {
             if (isset($value[0]) && is_array($value[0])) {
                 foreach ($value as $i => $repeat_data_values) {
                     $output .= sprintf("- #%s\n", $i);
                     foreach ($repeat_data_values as $field_name => $repeat_data_value) {
                         $output .= sprintf(" %s: ", $field_name);
                         if (is_array($repeat_data_value)) {
                             $output .= sprintf("[%s]\n", implode(', ', $repeat_data_value));
                         } else {
                             $output .= sprintf("%s\n", $repeat_data_value);
                         }
                     }
                 }
             } else {
                 $output .= sprintf("[%s]\n", implode(', ', $value));
             }
         } else {
             $output .= $output .= sprintf("%s\n", $value);
         }
     }
     return $output;
 }