/**
  * フック経由でカスタムフィールドを設定
  *
  * @param array $settings 管理画面で設定された Smart_Custom_Fields_Setting の配列
  * @param string $type 投稿タイプ or ロール
  * @param int $id 投稿ID or ユーザーID
  * @param string $meta_type メタデータのタイプ。post or user
  * @return array
  */
 public function _register($settings, $type, $id, $meta_type)
 {
     // SCF::add_setting( 'ユニークなID', 'メタボックスのタイトル' );
     if (type === 'category') {
         $Setting = SCF::add_setting('id-1', 'Register Test');
         // $Setting->add_group( 'ユニークなID', 繰り返し可能か, カスタムフィールドの配列 );
         $Setting->add_group(0, false, array(array('name' => 'text', 'label' => 'text field', 'type' => 'text')));
         $Setting->add_group(1, false, array(array('name' => 'checkbox', 'label' => 'checkbox field', 'type' => 'check', 'choices' => array(1, 2, 3))));
         $Setting->add_group('group-name-3', true, array(array('name' => 'text3', 'label' => 'text field 3', 'type' => 'text'), array('name' => 'checkbox3', 'label' => 'checkbox field 3', 'type' => 'check', 'choices' => array(1, 2, 3))));
         $settings['id-1'] = $Setting;
         $Setting = SCF::add_setting('id-2', 'Register Test 2');
         $Setting->add_group(0, false, array(array('name' => 'text2-1', 'label' => 'text field 2-1', 'type' => 'text')));
         $settings['id-2'] = $Setting;
     }
     return $settings;
 }
Ejemplo n.º 2
0
 /**
  * Displaying custom fields in post edit page
  *
  * @param string $post_type
  * @param WP_Post $post
  */
 public function add_meta_boxes($post_type, $post)
 {
     $settings = SCF::get_settings($post);
     foreach ($settings as $Setting) {
         add_meta_box(SCF_Config::PREFIX . 'custom-field-' . $Setting->get_id(), $Setting->get_title(), array($this, 'display_meta_box'), $post_type, 'normal', 'default', $Setting->get_groups());
     }
 }
 /**
  * 投稿画面にフィールドを表示
  *
  * @param int $index インデックス番号
  * @param mixed $value 保存されている値(check のときだけ配列)
  * @return string html
  */
 public function get_field($index, $value)
 {
     $name = $this->get_field_name_in_editor($index);
     $disabled = $this->get_disable_attribute($index);
     $choices = SCF::choices_eol_to_array($this->get('choices'));
     $form_field = '';
     foreach ($choices as $choice) {
         $choice = trim($choice);
         $form_field .= sprintf('<option value="%1$s" %2$s>%1$s</option>', esc_html($choice), selected($value, $choice, false));
     }
     return sprintf('<select name="%s" %s>%s</select>', esc_attr($name), disabled(true, $disabled, false), $form_field);
 }
 /**
  * フック経由でカスタムフィールドを設定
  *
  * @param array $settings 管理画面で設定された Smart_Custom_Fields_Setting の配列
  * @param string $type 投稿タイプ or ロール
  * @param int $id 投稿ID or ユーザーID
  * @param string $meta_type メタデータのタイプ。post or user
  * @return array
  */
 public function _register($settings, $type, $id, $meta_type)
 {
     // SCF::add_setting( 'ユニークなID', 'メタボックスのタイトル' );
     if ($type === 'post' && ($id === $this->post_id || $id === $this->revision_id) || $type === 'editor') {
         $Setting = SCF::add_setting('id-1', 'Register Test');
         // $Setting->add_group( 'ユニークなID', 繰り返し可能か, カスタムフィールドの配列 );
         $Setting->add_group(0, false, array(array('name' => 'text', 'label' => 'text field', 'type' => 'text')));
         $Setting->add_group(1, false, array(array('name' => 'checkbox', 'label' => 'checkbox field', 'type' => 'check', 'choices' => array(1, 2, 3))));
         $Setting->add_group('group-name-3', true, array(array('name' => 'text3', 'label' => 'text field 3', 'type' => 'text'), array('name' => 'checkbox3', 'label' => 'checkbox field 3', 'type' => 'check', 'choices' => array(1, 2, 3))));
         $settings['id-1'] = $Setting;
     }
     return $settings;
 }
Ejemplo n.º 5
0
 /**
  * 投稿画面にフィールドを表示
  *
  * @param int $index インデックス番号
  * @param mixed $value 保存されている値(check のときだけ配列)
  * @return string html
  */
 public function get_field($index, $value)
 {
     $name = $this->get_field_name_in_editor($index);
     $disabled = $this->get_disable_attribute($index);
     $choices = SCF::choices_eol_to_array($this->get('choices'));
     $direction = $this->get('radio_direction');
     $form_field = sprintf('<input type="hidden" name="%s" value="" %s />', esc_attr($name), disabled(true, $disabled, false));
     foreach ($choices as $choice) {
         $choice = trim($choice);
         $form_field .= sprintf('<span class="%s"><label><input type="radio" name="%s" value="%s" %s %s /> %s</label></span>', esc_attr(SCF_Config::PREFIX . 'item-' . $direction), esc_attr($name), esc_attr($choice), checked($value, $choice, false), disabled(true, $disabled, false), esc_html($choice));
     }
     return $form_field;
 }
Ejemplo n.º 6
0
 /**
  * __construct
  *
  * @param string $group_name
  * @param bool $repeat
  * @param array $_fields
  */
 public function __construct($group_name = null, $repeat = false, array $_fields = array())
 {
     $this->name = $group_name;
     $this->repeat = $repeat === true ? true : false;
     $fields = array();
     foreach ($_fields as $field_attributes) {
         $Field = SCF::get_form_field_instance($field_attributes['type']);
         if (!is_a($Field, 'Smart_Custom_Fields_Field_Base')) {
             continue;
         }
         foreach ($field_attributes as $key => $value) {
             $Field->set($key, $value);
         }
         if (!empty($Field)) {
             $fields[$Field->get('name')] = $Field;
         }
     }
     $this->fields = $fields;
 }
Ejemplo n.º 7
0
    /**
     * カスタムフィールドを表示
     *
     * @param object $term
     */
    public function edit_form_fields($term)
    {
        $settings = SCF::get_settings($term);
        foreach ($settings as $Setting) {
            $callback_args['args'] = $Setting->get_groups();
            ?>
			<table class="form-table">
				<tr>
					<th scope="row"><?php 
            echo esc_html($Setting->get_title());
            ?>
</th>
					<td><?php 
            $this->display_meta_box($term, $callback_args);
            ?>
</td>
				</tr>
			</table>
			<?php 
        }
    }
    /**
     * カスタムフィールドを表示
     *
     * @param WP_User $user
     */
    public function user_profile($user)
    {
        printf('<h3>%s</h3>', esc_html__('Custom Fields', 'smart-custom-fields'));
        $settings = SCF::get_settings($user);
        foreach ($settings as $Setting) {
            $callback_args['args'] = $Setting->get_groups();
            ?>
			<table class="form-table">
				<tr>
					<th scope="row"><?php 
            echo esc_html($Setting->get_title());
            ?>
</th>
					<td><?php 
            $this->display_meta_box($user, $callback_args);
            ?>
</td>
				</tr>
			</table>
			<?php 
        }
    }
// $vc_store_url .= "&ec_code=038p6";
// 1ページ毎の結果件数
$vc_store_url .= "&results_per_page=25";
// ソートの属性
//  “price”,“fee”, “score”
$vc_store_url .= "&sort_by=" . urlencode("score");
// 商品 を売上ランク順にソート
// rankはsort_by及びsort_orderより優勢に働きます。rankが指定された場合、商品は売上ランクの高い順から低い順にソートされ、sort_by及びsort_orderは無視されます。
// $vc_store_url .= "&rank=" . urlencode("monthly");
// 検索結果のフォーマット
$vc_store_url .= "&format=" . urlencode("json");
$vc_store_xml = json_decode(transient_remote_get($vc_store_url));
// ショップの注意事項
$vc_store_Notice = '※「ショップ etc」は、複数の通販サイトをまとめています。商品は、複数の通販サイトより厳選しています。';
$vc_store_Notice .= 'ランキングは複数の通販サイト全体で<strong class="text-danger">もっとも関連性の高い順</strong>です。';
if (SCF::get('shipOverseasFlag') == "1") {
    $vc_store_Notice .= '海外発送は、商品を取り扱っているストア(店舗)に確認してください。';
}
get_header();
?>

<div id="itemsearch">

<div class="container">
<?php 
get_template_part('breadcrumb');
?>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-2">
  <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
    <div class="panel panel-default">
Ejemplo n.º 10
0
 /**
  * false ならリビジョンとして保存される
  * 
  * @param bool $check_for_changes
  * @param WP_Post $last_revision 最新のリビジョン
  * @param WP_Post $post 現在の投稿
  * @return bool
  */
 public function wp_save_post_revision_check_for_changes($check_for_changes, $last_revision, $post)
 {
     $post_meta = array();
     $p = get_post_custom($post->ID);
     foreach ($p as $key => $value) {
         $v = SCF::get($key);
         if (!is_null($v)) {
             $post_meta[$key][] = $v;
         }
     }
     if (isset($_POST[SCF_Config::NAME])) {
         $serialized_post_meta = serialize($post_meta);
         $serialized_send_data = $_POST[SCF_Config::NAME];
         if ($serialized_post_meta != $serialized_send_data) {
             return false;
         }
     }
     return true;
 }
// 1:300m、2:500m、3:1000m、4:2000m、5:3000m
$guru_url .= "&range=5";
// ソート順: 1:店名かな順、2:ジャンルコード順、3:小エリアコード順、4:おススメ順
// ※ 位置検索の場合、「4:オススメ順」以外は指定に関係なく、強制的に距離順でソートされます。
// ぐるなびは、レスポンスデータのソート順 指定なし:ぐるなびソート順 1:店舗名、2:業態
// $guru_url .= "&sort=" . SCF::get( 'order' );
// ヒット件数
$guru_url .= "&hit_per_page=20";
// フリーワード検索
$guru_url .= "&freeword=" . urlencode(SCF::get('keyword'));
// ランチ営業あり
$guru_url .= "&lunch=" . SCF::get('lunch');
// 個室あり
$guru_url .= "&private_room=" . SCF::get('private_room');
// 食べ放題
$guru_url .= "&buffet=" . SCF::get('free_food');
// WebAPI and Cache
$guru_xml = new SimpleXMLElement(transient_remote_get($guru_url));
// 補足事項
$guru_shopNotice = "※ランキングは、「ぐるなび」のおすすめ順に基づいて作成しています。";
get_header();
?>
<div id="shopsearch">
  <div class="container">
    <?php 
get_template_part('breadcrumb');
?>
    <div class="row">
      <div class="col-xs-12 col-sm-12 col-md-3">
        <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
          <div class="panel panel-default">
Ejemplo n.º 12
0
//取得したいタグ情報
$tags = get_the_tags();
//取得したいタームのID
$term_id = $tags[0]->term_id;
//取得したいタクソノミーの種類 category | post_tag | カスタムタクソノミー
$taxonomy = 'post_tag';
//取得したいカスタムフィールド
$key_image = SCF::get_term_meta($term_id, $taxonomy, 'cf-artistKeyImage');
$artist_image = SCF::get_term_meta($term_id, $taxonomy, 'cf-artistImage');
$artist_string = SCF::get_term_meta($term_id, $taxonomy, 'cf-artistString');
$instagram_url = SCF::get_term_meta($term_id, $taxonomy, 'cf-instagramUrl');
$facebook_url = SCF::get_term_meta($term_id, $taxonomy, 'cf-facebookUrl');
$twitter_url = SCF::get_term_meta($term_id, $taxonomy, 'cf-twitterUrl');
$pinterest_url = SCF::get_term_meta($term_id, $taxonomy, 'cf-pinterestUrl');
$tumblr_url = SCF::get_term_meta($term_id, $taxonomy, 'cf-tumblrUrl');
$vimeo_url = SCF::get_term_meta($term_id, $taxonomy, 'cf-vimeoUrl');
get_header();
?>
    <!-- Header -->
    <header>
    <div class="u-text-center logo">
        <a href="<?php 
home_url();
?>
"><img src="<?php 
bloginfo('template_directory');
?>
/img/logo.png" alt="vital logo"></a>
    </div>
    <nav>
        <div class="nav-wrapper">
Ejemplo n.º 13
0
                                        </p>
                                    </div>
                                    <div class="card-action">
                                        <div class="card-action-string">
                                            <p>
                                                下記『受け取りボタン』を選択、または、『QRコード』をtixeeboxアプリで読み込むとチケットがお受取りいただけます。
                                            </p>
                                            <span class="m-alert">
                                                ※『受け取りボタン』を選択する前にtixeeboxアプリのインストール・利用登録をお願いします。<br>
                                                ※チケット取得のためにパスワードを求められる場合がございます。各主催からご案内しているパスワード二つを入力し、チケットを取得してください。
                                            </span>
                                        </div>
                                        <section class="col-md-12 u-mb30 u-mt60">
                                            
<?php 
    $cf_tableTicket = SCF::get('cf_tableGetTicket');
    foreach ($cf_tableTicket as $field_name => $field_value) {
        $ticket_title = esc_html($field_value['cf_tableGetTicket_title']);
        $ticket_iphone = esc_html($field_value['cf_tableGetTicket_urlIphone']);
        $ticket_android = esc_html($field_value['cf_tableGetTicket_urlAndroid']);
        ?>
    <h1 class="heading-b"><?php 
        echo $ticket_title;
        ?>
</h1>
    <table class="table table-url table-bordered">
        <thead>
            <tr>
                <th>端末</th>
                <th>イベント</th>
                <th>受け取りボタン / QRコード</th>
 /**
  * tearDown
  */
 public function tearDown()
 {
     parent::tearDown();
     SCF::clear_all_cache();
 }
 /**
  * Run management screens
  *
  * @param WP_Screen $screen
  */
 public function current_screen($screen)
 {
     // 一覧画面
     if ($screen->id === 'edit-' . SCF_Config::NAME) {
     } elseif ($screen->id === SCF_Config::NAME) {
         require_once plugin_dir_path(__FILE__) . 'classes/controller/class.settings.php';
         new Smart_Custom_Fields_Controller_Settings();
     } elseif (in_array($screen->id, get_post_types())) {
         $post_id = $this->get_post_id_in_admin();
         $Post = new stdClass();
         $Post->ID = $post_id;
         $Post->post_type = $screen->id;
         if (SCF::get_settings(new WP_Post($Post))) {
             require_once plugin_dir_path(__FILE__) . 'classes/controller/class.controller-base.php';
             require_once plugin_dir_path(__FILE__) . 'classes/controller/class.editor.php';
             new Smart_Custom_Fields_Revisions();
             new Smart_Custom_Fields_Controller_Editor();
         }
     } elseif (in_array($screen->id, array('profile', 'user-edit'))) {
         $user_id = $this->get_user_id_in_admin();
         $user_data = get_userdata($user_id);
         $roles[0] = false;
         if ($user_data) {
             $roles = $user_data->roles;
         }
         if (SCF::get_settings(get_userdata($user_id))) {
             require_once plugin_dir_path(__FILE__) . 'classes/controller/class.controller-base.php';
             require_once plugin_dir_path(__FILE__) . 'classes/controller/class.profile.php';
             new Smart_Custom_Fields_Controller_Profile();
         }
     } elseif ($screen->taxonomy) {
         $term_id = $this->get_term_id_in_admin();
         if ($term_id) {
             $term = get_term($term_id, $screen->taxonomy);
             if (SCF::get_settings($term)) {
                 require_once plugin_dir_path(__FILE__) . 'classes/controller/class.controller-base.php';
                 require_once plugin_dir_path(__FILE__) . 'classes/controller/class.taxonomy.php';
                 new Smart_Custom_Fields_Controller_Taxonomy();
             }
         }
     }
 }
 /**
  * 非複数許可フィールドのメタデータを取得
  * 
  * @param WP_Post|WP_User|object $object
  * @param Smart_Custom_Fields_Field_Base $Field
  * @param int $index
  * @return string or null
  */
 public function get_single_data_field_value($object, $Field, $index)
 {
     $Meta = new Smart_Custom_Fields_Meta($object);
     $field_name = $Field->get('name');
     if (is_null($index)) {
         return SCF::get_default_value($Field, true);
     }
     if ($Meta->is_saved()) {
         $value = $Meta->get($field_name);
         if (isset($value[$index])) {
             return $value[$index];
         }
         return '';
     }
     return SCF::get_default_value($Field, true);
 }
Ejemplo n.º 17
0
 /**
  * フック経由でカスタムフィールドを設定
  *
  * @param array $settings 管理画面で設定された Smart_Custom_Fields_Setting の配列
  * @param string $type 投稿タイプ or ロール or タクソノミー
  * @param int $id 投稿ID or ユーザーID or タームID
  * @param string $meta_type メタデータのタイプ。post or user or term
  * @return array
  */
 public function _register($settings, $type, $id, $meta_type)
 {
     // SCF::add_setting( 'ユニークなID', 'メタボックスのタイトル' );
     if ($type === 'post' && $id === $this->post_id || $type === 'post' && $id === $this->new_post_id || $type === 'editor' || $type === 'category') {
         $Setting = SCF::add_setting('id-1', 'Register Test');
         // $Setting->add_group( 'ユニークなID', 繰り返し可能か, カスタムフィールドの配列 );
         $Setting->add_group(0, false, array(array('name' => 'text', 'label' => 'text field', 'type' => 'text')));
         $Setting->add_group(1, false, array(array('name' => 'checkbox', 'label' => 'checkbox field', 'type' => 'check', 'choices' => array(1, 2, 3))));
         $Setting->add_group('group-name-3', true, array(array('name' => 'text3', 'label' => 'text field 3', 'type' => 'text'), array('name' => 'checkbox3', 'label' => 'checkbox field 3', 'type' => 'check', 'choices' => array(1, 2, 3))));
         $Setting->add_group('group-name-4', false, array(array('name' => 'text-has-default', 'label' => 'text has default', 'type' => 'text', 'default' => 'text default'), array('name' => 'text-has-not-default', 'label' => 'text has not default', 'type' => 'text'), array('name' => 'checkbox-has-default', 'label' => 'checkbox has default', 'type' => 'check', 'choices' => array('A', 'B', 'C'), 'default' => "A\nB\nX"), array('name' => 'checkbox-has-not-default', 'label' => 'checkbox has not default', 'type' => 'check', 'choices' => array('A', 'B', 'C'))));
         $settings['id-1'] = $Setting;
     }
     return $settings;
 }
<?php

/*
Template Name: オークション検索
*/
get_template_part('class-yahoauc-apiurl');
get_template_part('class-iteminfo');
$appid = ".Dvbnu6xg6490.P349ol50qReUlkYnjo4pL8CRksW1yCJYgjOhR80r_kCTIDoZbTjB6KdOc-";
$api_url = new YahoAuc_ApiUrl($appid);
$api_url->setKeyWord(SCF::get('auckeyword'));
// ヤフオクのHTML生成用のクラス (sid,pid)
$yahoauc_item = new Item_Info('3201717', '883850776');
$yahoauc_item->setUrl($api_url->getUrl());
get_header();
?>

<div id="itemsearch">
  <div class="container">
<?php 
get_template_part('breadcrumb');
?>
  <div class="row">
  <div class="col-xs-12 col-sm-12 col-md-2">
  <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
    <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
        <h4 class="panel-title">
          <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">家庭用の焼き鳥</a>
        </h4>
      </div>
      <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
Ejemplo n.º 19
0
<?php

session_start();
require_once "Design_for_reuse/SCF/SCF.php";
$api = new SCF();
$api->startHTMLRender();
$api->addFolderForm();
$api->addSearchForm();
// Used to check if changes have happened in the current folder.
$api->updateCurrentFolder();
if ($api->getSearchInfo()['isMatch'] || isset($_SESSION['searchID'])) {
    echo "<br><b>You are in folder: </b>" . $api->getSearchInfo()['searchID'] . "<br>";
    $api->startFolderSession($_POST['searchID']);
    if ($api->isInChildFolder()) {
        echo $api->getBackButton();
    }
    $collectionID = $_SESSION['searchID'];
    $api->addFileForm($collectionID);
    $itemArray = $api->getFolderContent($collectionID);
    if ($itemArray != 0) {
        foreach ($itemArray as $item) {
            echo $item->Name();
            echo $item->getActionButton();
            echo $item->getDeleteButton();
        }
    }
}
$api->stopHTMLRender();
//var_dump($api->getFolders());
Ejemplo n.º 20
0
 /**
  * 繰り返しに設定された複数許可フィールドデータの区切り識別用データのキャッシュをクリア
  */
 public static function clear_repeat_multiple_data_cache()
 {
     self::$repeat_multiple_data_cache = array();
 }
Ejemplo n.º 21
0
                <li><a href="/artists/">ARTISTS</a></li>
                <li><a href="/events/">EVENTS</a></li>
                <li><a href="/music/">MUSIC</a></li>
                <li><a href="/blog/">BLOG</a></li>
                <li><a href="#">SHOP</a></li>
            </ul>
        </div>
    </nav>
</header>
    <div class="u-bg-top">
    
    <section class="container u-pt60">
        <h1 class="m-heading-sub">ARTISTS</h1>
        <div class="l-row row u-mt30">
            <?php 
$repeat_group = SCF::get('gp-artists');
foreach ($repeat_group as $field_name => $field_value) {
    ?>
                <div class="col m4 s6">
                    <section class="card m-card">
                        <a href="<?php 
    echo esc_html($field_value['cf-cateUrl']);
    ?>
">
                            <div class="m-card-image">
                                <?php 
    echo wp_get_attachment_image($field_value['cf-artistImage'], 'medium');
    ?>
                            </div>
                        </a>
                        <h1 class="m-heading-content">
    /**
     * 設定画面にフィールドを表示(共通項目)
     * 
     * @param int $group_key
     * @param int $field_key
     */
    public function display_options($group_key, $field_key)
    {
        ?>
		<tr>
			<th><?php 
        esc_html_e('Name', 'smart-custom-fields');
        ?>
<span class="<?php 
        echo esc_attr(SCF_Config::PREFIX . 'require');
        ?>
">*</span></th>
			<td>
				<input type="text"
					name="<?php 
        echo esc_attr($this->get_field_name_in_setting($group_key, $field_key, 'name'));
        ?>
"
					size="30"
					class="<?php 
        echo esc_attr(SCF_Config::PREFIX . 'field-name');
        ?>
"
					value="<?php 
        echo esc_attr($this->get('name'));
        ?>
"
				/>
			</td>
		</tr>
		<tr>
			<th><?php 
        esc_html_e('Label', 'smart-custom-fields');
        ?>
</th>
			<td>
				<input type="text"
					name="<?php 
        echo esc_attr($this->get_field_name_in_setting($group_key, $field_key, 'label'));
        ?>
"
					size="30"
					class="<?php 
        echo esc_attr(SCF_Config::PREFIX . 'field-label');
        ?>
"
					value="<?php 
        echo esc_attr($this->get('label'));
        ?>
"
				/>
			</td>
		</tr>
		<?php 
        $fields = SCF::get_form_field_instances();
        foreach ($fields as $Field) {
            if ($Field->get_attribute('type') === $this->get_attribute('type')) {
                foreach ($this->options as $key => $value) {
                    $Field->set($key, $value);
                }
            }
            $Field->_display_field_options($group_key, $field_key);
        }
    }
    /**
     * 投稿画面にカスタムフィールドを表示
     */
    public function display_meta_box()
    {
        $Setting = SCF::add_setting(get_the_ID(), get_the_title());
        $Setting->add_group_unshift();
        $groups = $Setting->get_groups();
        ?>
		<div class="<?php 
        echo esc_attr(SCF_Config::PREFIX . 'fields-wrapper');
        ?>
">
			<div class="<?php 
        echo esc_attr(SCF_Config::PREFIX . 'groups');
        ?>
">
			<?php 
        foreach ($groups as $group_key => $Group) {
            ?>
				<?php 
            $fields = $Group->get_fields();
            array_unshift($fields, SCF::get_form_field_instance('text'));
            ?>
				<div class="<?php 
            echo esc_attr(SCF_Config::PREFIX . 'group');
            ?>
 <?php 
            $this->add_hide_class($group_key);
            ?>
">
					<div class="btn-remove-group"><span class="dashicons dashicons-no-alt"></span></div>
					<?php 
            $Group->display_options($group_key);
            ?>

					<div class="<?php 
            echo esc_attr(SCF_Config::PREFIX . 'fields');
            ?>
">
						<?php 
            foreach ($fields as $field_key => $Field) {
                ?>
						<div class="<?php 
                echo esc_attr(SCF_Config::PREFIX . 'field');
                ?>
 <?php 
                $this->add_hide_class($field_key);
                ?>
">
							<?php 
                $field_label = $Field->get('label');
                if (!$field_label) {
                    $field_label = $Field->get('name');
                    if (!$field_label) {
                        $field_label = "&nbsp;";
                    }
                }
                ?>
							<div class="<?php 
                echo esc_attr(SCF_Config::PREFIX . 'icon-handle');
                ?>
"></div>
							<b class="btn-remove-field"><span class="dashicons dashicons-no-alt"></span></b>
							<div class="field-label"><?php 
                echo esc_html($field_label);
                ?>
</div>
							<table class="<?php 
                $this->add_hide_class(!$Field->get('name'));
                ?>
">
								<tr>
									<th><?php 
                esc_html_e('Type', 'smart-custom-fields');
                ?>
<span class="<?php 
                echo esc_attr(SCF_Config::PREFIX . 'require');
                ?>
">*</span></th>
									<td>
										<select
											name="<?php 
                echo esc_attr($Field->get_field_name_in_setting($group_key, $field_key, 'type'));
                ?>
"
											class="<?php 
                echo esc_attr(SCF_Config::PREFIX . 'field-select');
                ?>
" />
											<?php 
                foreach ($this->optgroups as $optgroup_name => $optgroup_values) {
                    $optgroup_fields = array();
                    $optgroup_values['options'] = apply_filters(SCF_Config::PREFIX . 'field-select-' . $optgroup_name, $optgroup_values['options']);
                    foreach ($optgroup_values['options'] as $option_key => $option) {
                        $optgroup_fields[] = sprintf('<option value="%s" %s>%s</option>', esc_attr($option_key), selected($Field->get_attribute('type'), $option_key, false), esc_html($option));
                    }
                    printf('<optgroup label="%s">%s</optgroup>', $optgroup_values['label'], implode('', $optgroup_fields));
                }
                ?>
										</select>
									</td>
								</tr>
								<?php 
                $Field->display_options($group_key, $field_key);
                ?>
							</table>
						</div>
						<?php 
            }
            ?>
					</div>
					<div class="button btn-add-field <?php 
            $this->add_hide_class($Group->is_repeatable());
            ?>
"><?php 
            esc_html_e('Add Sub field', 'smart-custom-fields');
            ?>
</div>
				</div>
			<?php 
        }
        ?>
			</div>
			<div class="button btn-add-group"><?php 
        esc_html_e('Add Field', 'smart-custom-fields');
        ?>
</div>
		</div>
		<?php 
        wp_nonce_field(SCF_Config::NAME . '-settings', SCF_Config::PREFIX . 'settings-nonce');
        ?>
		<?php 
    }
Ejemplo n.º 24
0
 /**
  * 渡されたリビジョンからデータをリストア
  *
  * @param WP_Post $revision
  */
 public function restore($revision)
 {
     switch ($this->meta_type) {
         case 'post':
             $object = get_post($this->id);
             break;
         default:
             $object = null;
     }
     if (is_null($object) || !is_a($revision, 'WP_Post')) {
         return;
     }
     $settings = SCF::get_settings($object);
     foreach ($settings as $Setting) {
         $fields = $Setting->get_fields();
         foreach ($fields as $Field) {
             $field_name = $Field->get('name');
             $this->delete($field_name);
             $value = SCF::get($field_name, $revision->ID);
             if (is_array($value)) {
                 foreach ($value as $val) {
                     if (is_array($val)) {
                         foreach ($val as $v) {
                             // ループ内複数値項目
                             $this->add($field_name, $v);
                         }
                     } else {
                         // ループ内単一項目 or ループ外複数値項目
                         $this->add($field_name, $val);
                     }
                 }
             } else {
                 // ループ外単一項目
                 $this->add($field_name, $value);
             }
         }
     }
     $repeat_multiple_data = SCF::get_repeat_multiple_data($revision);
     $repeat_multiple_data_name = SCF_Config::PREFIX . 'repeat-multiple-data';
     $this->delete($repeat_multiple_data_name);
     $this->update($repeat_multiple_data_name, $repeat_multiple_data);
 }
 /**
  * @group get_user_meta
  */
 public function test_get_user_meta()
 {
     $this->assertNull(SCF::get_user_meta($this->user_id, 'category', 'text'));
 }