Version Description
- Fixed a bug that can not get the correct data when the posts use post id filtering.
- Changed that original the_content filter does not apply to wisywig field.
- Add post_id attribute to smart-cf-register-fields.
Download this release
Release Info
Developer | inc2734 |
Plugin | Smart Custom Fields |
Version | 1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.2.2
- classes/class.scf.php +171 -59
- classes/controller/class.editor.php +4 -4
- classes/models/class.revisions.php +6 -6
- readme.txt +6 -1
- smart-custom-fields.php +9 -3
classes/class.scf.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* SCF
|
4 |
-
* Version : 1.1.
|
5 |
* Author : Takashi Kitajima
|
6 |
* Created : September 23, 2014
|
7 |
-
* Modified : March
|
8 |
* License : GPLv2
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -56,10 +56,14 @@ class SCF {
|
|
56 |
}
|
57 |
$post_id = self::get_real_post_id( $post_id );
|
58 |
|
|
|
|
|
|
|
|
|
59 |
// 設定画面で未設定のメタデータは投稿が保持していても出力しないようにしないといけないので
|
60 |
// 設定データを取得して出力して良いか判別する
|
61 |
$post_type = self::get_public_post_type( $post_id );
|
62 |
-
$settings = self::get_settings( $post_type );
|
63 |
$post_meta = array();
|
64 |
foreach ( $settings as $Setting ) {
|
65 |
$groups = $Setting->get_groups();
|
@@ -94,14 +98,21 @@ class SCF {
|
|
94 |
}
|
95 |
$post_id = self::get_real_post_id( $post_id );
|
96 |
|
|
|
|
|
|
|
|
|
97 |
if ( self::get_cache( $post_id, $name ) ) {
|
|
|
98 |
return self::get_cache( $post_id, $name );
|
|
|
|
|
99 |
}
|
100 |
|
101 |
// 設定画面で未設定のメタデータは投稿が保持していても出力しないようにしないといけないので
|
102 |
// 設定データを取得して出力して良いか判別する
|
103 |
$post_type = self::get_public_post_type( $post_id );
|
104 |
-
$settings = self::get_settings( $post_type );
|
105 |
foreach ( $settings as $Setting ) {
|
106 |
$groups = $Setting->get_groups();
|
107 |
foreach ( $groups as $Group ) {
|
@@ -222,7 +233,7 @@ class SCF {
|
|
222 |
foreach ( $_post_meta as $_post_meta_key => $value ) {
|
223 |
// wysiwyg の場合はフィルタを通す
|
224 |
if ( $field_type === 'wysiwyg' ) {
|
225 |
-
$value =
|
226 |
}
|
227 |
// relation のときは $value = Post ID。公開済みでない場合は取得しない
|
228 |
elseif ( $field_type === 'relation' ) {
|
@@ -262,18 +273,19 @@ class SCF {
|
|
262 |
if ( is_array( $post_meta ) ) {
|
263 |
$_post_meta = array();
|
264 |
foreach ( $post_meta as $key => $value ) {
|
265 |
-
$_post_meta[$key] =
|
266 |
}
|
267 |
$post_meta = $_post_meta;
|
268 |
} else {
|
269 |
-
$post_meta =
|
270 |
}
|
271 |
} elseif ( $field_type === 'relation' ) {
|
272 |
$_post_meta = array();
|
273 |
if ( is_array( $post_meta ) ) {
|
274 |
foreach ( $post_meta as $post_id ) {
|
275 |
-
if ( get_post_status( $post_id ) !== 'publish' )
|
276 |
continue;
|
|
|
277 |
$_post_meta[] = $post_id;
|
278 |
}
|
279 |
}
|
@@ -286,24 +298,39 @@ class SCF {
|
|
286 |
/**
|
287 |
* その投稿タイプで有効になっている SCF をキャッシュに保存
|
288 |
*
|
289 |
-
* @param
|
290 |
-
* @param array $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
*/
|
292 |
-
|
293 |
-
self::$settings_posts_cache[$post_type]
|
|
|
|
|
|
|
294 |
}
|
295 |
|
296 |
/**
|
297 |
* その投稿タイプで有効になっている SCF を取得
|
298 |
*
|
299 |
* @param string $post_type
|
300 |
-
* @param bool $do_caching
|
301 |
* @return array $settings
|
302 |
*/
|
303 |
-
public static function get_settings_posts( $post_type
|
304 |
$posts = array();
|
305 |
-
if (
|
306 |
-
|
|
|
|
|
|
|
307 |
}
|
308 |
$settings_posts = get_posts( array(
|
309 |
'post_type' => SCF_Config::NAME,
|
@@ -318,68 +345,93 @@ class SCF {
|
|
318 |
),
|
319 |
),
|
320 |
) );
|
|
|
|
|
|
|
321 |
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
);
|
333 |
-
if ( $_condition_post_ids ) {
|
334 |
-
$_condition_post_ids = explode( ',', $_condition_post_ids );
|
335 |
-
foreach ( $_condition_post_ids as $condition_post_id ) {
|
336 |
-
$condition_post_ids[] = trim( $condition_post_id );
|
337 |
-
}
|
338 |
-
if ( $condition_post_ids && !in_array( $post_id, $condition_post_ids ) ) {
|
339 |
-
continue;
|
340 |
-
}
|
341 |
-
}
|
342 |
-
$posts[] = $settings_post;
|
343 |
-
}
|
344 |
} else {
|
345 |
-
$
|
346 |
-
}
|
347 |
-
if ( $do_caching === true ) {
|
348 |
-
self::save_settings_posts_cache( $post_type, $posts );
|
349 |
}
|
350 |
-
return $posts;
|
351 |
}
|
352 |
|
353 |
/**
|
354 |
-
* Setting
|
355 |
*
|
356 |
-
* @param
|
357 |
-
* @param
|
|
|
358 |
*/
|
359 |
-
|
360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
}
|
362 |
|
363 |
/**
|
364 |
* Setting オブジェクトの配列を取得
|
365 |
*
|
366 |
* @param string $post_type
|
367 |
-
* @param
|
368 |
* @return array $settings
|
369 |
*/
|
370 |
-
public static function get_settings( $post_type, $
|
371 |
-
if (
|
372 |
-
|
373 |
}
|
374 |
-
$
|
375 |
-
|
376 |
-
|
377 |
-
|
|
|
378 |
}
|
379 |
-
$settings =
|
380 |
-
|
381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
}
|
|
|
383 |
return $settings;
|
384 |
}
|
385 |
|
@@ -466,6 +518,29 @@ class SCF {
|
|
466 |
}
|
467 |
return $fields;
|
468 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
|
470 |
/**
|
471 |
* 改行区切りの $choices を配列に変換
|
@@ -490,4 +565,41 @@ class SCF {
|
|
490 |
public static function add_setting( $id, $title ) {
|
491 |
return new Smart_Custom_Fields_Setting( $id, $title );
|
492 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* SCF
|
4 |
+
* Version : 1.1.2
|
5 |
* Author : Takashi Kitajima
|
6 |
* Created : September 23, 2014
|
7 |
+
* Modified : March 13, 2015
|
8 |
* License : GPLv2
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
56 |
}
|
57 |
$post_id = self::get_real_post_id( $post_id );
|
58 |
|
59 |
+
if ( empty( $post_id ) ) {
|
60 |
+
return array();
|
61 |
+
}
|
62 |
+
|
63 |
// 設定画面で未設定のメタデータは投稿が保持していても出力しないようにしないといけないので
|
64 |
// 設定データを取得して出力して良いか判別する
|
65 |
$post_type = self::get_public_post_type( $post_id );
|
66 |
+
$settings = self::get_settings( $post_type, $post_id );
|
67 |
$post_meta = array();
|
68 |
foreach ( $settings as $Setting ) {
|
69 |
$groups = $Setting->get_groups();
|
98 |
}
|
99 |
$post_id = self::get_real_post_id( $post_id );
|
100 |
|
101 |
+
if ( empty( $post_id ) ) {
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
|
105 |
if ( self::get_cache( $post_id, $name ) ) {
|
106 |
+
self::debug_cache_message( "use get cache. {$post_id} {$name}" );
|
107 |
return self::get_cache( $post_id, $name );
|
108 |
+
} else {
|
109 |
+
self::debug_cache_message( "dont use get cache... {$post_id} {$name}" );
|
110 |
}
|
111 |
|
112 |
// 設定画面で未設定のメタデータは投稿が保持していても出力しないようにしないといけないので
|
113 |
// 設定データを取得して出力して良いか判別する
|
114 |
$post_type = self::get_public_post_type( $post_id );
|
115 |
+
$settings = self::get_settings( $post_type, $post_id );
|
116 |
foreach ( $settings as $Setting ) {
|
117 |
$groups = $Setting->get_groups();
|
118 |
foreach ( $groups as $Group ) {
|
233 |
foreach ( $_post_meta as $_post_meta_key => $value ) {
|
234 |
// wysiwyg の場合はフィルタを通す
|
235 |
if ( $field_type === 'wysiwyg' ) {
|
236 |
+
$value = self::add_the_content_filter( $value );
|
237 |
}
|
238 |
// relation のときは $value = Post ID。公開済みでない場合は取得しない
|
239 |
elseif ( $field_type === 'relation' ) {
|
273 |
if ( is_array( $post_meta ) ) {
|
274 |
$_post_meta = array();
|
275 |
foreach ( $post_meta as $key => $value ) {
|
276 |
+
$_post_meta[$key] = self::add_the_content_filter( $value );
|
277 |
}
|
278 |
$post_meta = $_post_meta;
|
279 |
} else {
|
280 |
+
$post_meta = self::add_the_content_filter( $post_meta );
|
281 |
}
|
282 |
} elseif ( $field_type === 'relation' ) {
|
283 |
$_post_meta = array();
|
284 |
if ( is_array( $post_meta ) ) {
|
285 |
foreach ( $post_meta as $post_id ) {
|
286 |
+
if ( get_post_status( $post_id ) !== 'publish' ) {
|
287 |
continue;
|
288 |
+
}
|
289 |
$_post_meta[] = $post_id;
|
290 |
}
|
291 |
}
|
298 |
/**
|
299 |
* その投稿タイプで有効になっている SCF をキャッシュに保存
|
300 |
*
|
301 |
+
* @param string $post_type
|
302 |
+
* @param array $settings_posts
|
303 |
+
*/
|
304 |
+
protected static function save_settings_posts_cache( $post_type, $settings_posts ) {
|
305 |
+
self::$settings_posts_cache[$post_type] = $settings_posts;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* その投稿タイプで有効になっている SCF のキャッシュを取得
|
310 |
+
*
|
311 |
+
* @param string $post_type
|
312 |
+
* @return array
|
313 |
*/
|
314 |
+
public static function get_settings_posts_cache( $post_type ) {
|
315 |
+
if ( isset( self::$settings_posts_cache[$post_type] ) ) {
|
316 |
+
return self::$settings_posts_cache[$post_type];
|
317 |
+
}
|
318 |
+
return array();
|
319 |
}
|
320 |
|
321 |
/**
|
322 |
* その投稿タイプで有効になっている SCF を取得
|
323 |
*
|
324 |
* @param string $post_type
|
|
|
325 |
* @return array $settings
|
326 |
*/
|
327 |
+
public static function get_settings_posts( $post_type ) {
|
328 |
$posts = array();
|
329 |
+
if ( self::get_settings_posts_cache( $post_type ) ) {
|
330 |
+
self::debug_cache_message( "use settings posts cache. {$post_type}" );
|
331 |
+
return self::get_settings_posts_cache( $post_type );
|
332 |
+
} else {
|
333 |
+
self::debug_cache_message( "dont use settings posts cache... {$post_type}" );
|
334 |
}
|
335 |
$settings_posts = get_posts( array(
|
336 |
'post_type' => SCF_Config::NAME,
|
345 |
),
|
346 |
),
|
347 |
) );
|
348 |
+
self::save_settings_posts_cache( $post_type, $settings_posts );
|
349 |
+
return $settings_posts;
|
350 |
+
}
|
351 |
|
352 |
+
/**
|
353 |
+
* Setting オブジェクトをキャッシュに保存
|
354 |
+
*
|
355 |
+
* @param string $post_type
|
356 |
+
* @param int|false $post_id
|
357 |
+
* @param Smart_Custom_Fields_Setting $Setting
|
358 |
+
*/
|
359 |
+
protected static function save_settings_cache( $post_type, $post_id, $Setting ) {
|
360 |
+
if ( empty( $post_id ) ) {
|
361 |
+
self::$settings_cache[$post_type][0][] = $Setting;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
} else {
|
363 |
+
self::$settings_cache[$post_type][$post_id][] = $Setting;
|
|
|
|
|
|
|
364 |
}
|
|
|
365 |
}
|
366 |
|
367 |
/**
|
368 |
+
* Setting オブジェクトキャッシュを取得
|
369 |
*
|
370 |
+
* @param string $post_type
|
371 |
+
* @param int|false $post_id
|
372 |
+
* @return array
|
373 |
*/
|
374 |
+
public static function get_settings_cache( $post_type, $post_id ) {
|
375 |
+
$settings = array();
|
376 |
+
if ( empty( $post_id ) ) {
|
377 |
+
return $settings;
|
378 |
+
}
|
379 |
+
if ( !isset( self::$settings_cache[$post_type] ) ) {
|
380 |
+
return $settings;
|
381 |
+
}
|
382 |
+
if ( isset( self::$settings_cache[$post_type][0] ) ) {
|
383 |
+
$settings = self::$settings_cache[$post_type][0];
|
384 |
+
}
|
385 |
+
if ( !empty( $post_id ) ) {
|
386 |
+
if ( isset( self::$settings_cache[$post_type][$post_id] ) ) {
|
387 |
+
$settings = array_merge( $settings, self::$settings_cache[$post_type][$post_id] );
|
388 |
+
}
|
389 |
+
}
|
390 |
+
return $settings;
|
391 |
}
|
392 |
|
393 |
/**
|
394 |
* Setting オブジェクトの配列を取得
|
395 |
*
|
396 |
* @param string $post_type
|
397 |
+
* @param int|false $post_id
|
398 |
* @return array $settings
|
399 |
*/
|
400 |
+
public static function get_settings( $post_type, $post_id ) {
|
401 |
+
if ( empty( $post_id ) ) {
|
402 |
+
$post_id = get_the_ID();
|
403 |
}
|
404 |
+
if ( self::get_settings_cache( $post_type, $post_id ) ) {
|
405 |
+
self::debug_cache_message( "use settings cache. {$post_type} {$post_id}" );
|
406 |
+
return self::get_settings_cache( $post_type, $post_id );
|
407 |
+
} else {
|
408 |
+
self::debug_cache_message( "dont use settings cache... {$post_type} {$post_id}" );
|
409 |
}
|
410 |
+
$settings = array();
|
411 |
+
$settings_posts = self::get_settings_posts( $post_type );
|
412 |
+
foreach ( $settings_posts as $settings_post ) {
|
413 |
+
$condition_post_ids_raw = get_post_meta(
|
414 |
+
$settings_post->ID,
|
415 |
+
SCF_Config::PREFIX . 'condition-post-ids',
|
416 |
+
true
|
417 |
+
);
|
418 |
+
if ( $condition_post_ids_raw ) {
|
419 |
+
$condition_post_ids_raw = explode( ',', $condition_post_ids_raw );
|
420 |
+
foreach ( $condition_post_ids_raw as $condition_post_id ) {
|
421 |
+
$condition_post_id = trim( $condition_post_id );
|
422 |
+
$Setting = SCF::add_setting( $settings_post->ID, $settings_post->post_title );
|
423 |
+
if ( $post_id == $condition_post_id ) {
|
424 |
+
$settings[] = $Setting;
|
425 |
+
}
|
426 |
+
self::save_settings_cache( $post_type, $condition_post_id, $Setting );
|
427 |
+
}
|
428 |
+
} else {
|
429 |
+
$Setting = SCF::add_setting( $settings_post->ID, $settings_post->post_title );
|
430 |
+
$settings[] = $Setting;
|
431 |
+
self::save_settings_cache( $post_type, false, $Setting );
|
432 |
+
}
|
433 |
}
|
434 |
+
$settings = apply_filters( SCF_Config::PREFIX . 'register-fields', $settings, $post_type, $post_id );
|
435 |
return $settings;
|
436 |
}
|
437 |
|
518 |
}
|
519 |
return $fields;
|
520 |
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* 管理画面で保存されたフィールドを取得
|
524 |
+
* 同じ投稿タイプで、同名のフィールド名を持つフィールドを複数定義しても一つしか返らないので注意
|
525 |
+
*
|
526 |
+
* @param string $post_type
|
527 |
+
* @param string $field_name
|
528 |
+
* @return Smart_Custom_Fields_Field_Base
|
529 |
+
*/
|
530 |
+
public static function get_field( $post_type, $field_name ) {
|
531 |
+
$settings = self::get_settings( $post_type, get_the_ID() );
|
532 |
+
foreach ( $settings as $Setting ) {
|
533 |
+
$groups = $Setting->get_groups();
|
534 |
+
foreach ( $groups as $Group ) {
|
535 |
+
$fields = $Group->get_fields();
|
536 |
+
foreach ( $fields as $Field ) {
|
537 |
+
if ( !is_null( $Field ) && $Field->get( 'name' ) === $field_name ) {
|
538 |
+
return $Field;
|
539 |
+
}
|
540 |
+
}
|
541 |
+
}
|
542 |
+
}
|
543 |
+
}
|
544 |
|
545 |
/**
|
546 |
* 改行区切りの $choices を配列に変換
|
565 |
public static function add_setting( $id, $title ) {
|
566 |
return new Smart_Custom_Fields_Setting( $id, $title );
|
567 |
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* デフォルトで the_content に適用される関数を適用
|
571 |
+
*
|
572 |
+
* @param string $value
|
573 |
+
* @return string
|
574 |
+
*/
|
575 |
+
protected static function add_the_content_filter( $value ) {
|
576 |
+
if ( has_filter( 'the_content', 'wptexturize' ) ) {
|
577 |
+
$value = wptexturize( $value );
|
578 |
+
}
|
579 |
+
if ( has_filter( 'the_content', 'convert_smilies' ) ) {
|
580 |
+
$value = convert_smilies( $value );
|
581 |
+
}
|
582 |
+
if ( has_filter( 'the_content', 'convert_chars' ) ) {
|
583 |
+
$value = convert_chars( $value );
|
584 |
+
}
|
585 |
+
if ( has_filter( 'the_content', 'wpautop' ) ) {
|
586 |
+
$value = wpautop( $value );
|
587 |
+
}
|
588 |
+
if ( has_filter( 'the_content', 'shortcode_unautop' ) ) {
|
589 |
+
$value = shortcode_unautop( $value );
|
590 |
+
}
|
591 |
+
if ( has_filter( 'the_content', 'prepend_attachment' ) ) {
|
592 |
+
$value = prepend_attachment( $value );
|
593 |
+
}
|
594 |
+
return $value;
|
595 |
+
}
|
596 |
+
|
597 |
+
/**
|
598 |
+
* キャッシュの使用状況を画面に表示
|
599 |
+
*/
|
600 |
+
protected static function debug_cache_message( $message ) {
|
601 |
+
if ( defined( 'SCF_DEBUG_CACHE' ) && SCF_DEBUG_CACHE === true ) {
|
602 |
+
echo $message . '<br />';
|
603 |
+
}
|
604 |
+
}
|
605 |
}
|
classes/controller/class.editor.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Smart_Custom_Fields_Controller_Editor
|
4 |
-
* Version : 1.0.
|
5 |
* Author : Takashi Kitajima
|
6 |
* Created : September 23, 2014
|
7 |
-
* Modified :
|
8 |
* License : GPLv2
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -65,7 +65,7 @@ class Smart_Custom_Fields_Controller_Editor {
|
|
65 |
*/
|
66 |
public function add_meta_boxes( $post_type, $post ) {
|
67 |
$_post = $post;
|
68 |
-
$settings = SCF::get_settings( $post_type );
|
69 |
foreach ( $settings as $Setting ) {
|
70 |
add_meta_box(
|
71 |
SCF_Config::PREFIX . 'custom-field-' . $Setting->get_id(),
|
@@ -148,7 +148,7 @@ class Smart_Custom_Fields_Controller_Editor {
|
|
148 |
$multiple_data_fields = array();
|
149 |
|
150 |
$post_type = get_post_type();
|
151 |
-
$settings = SCF::get_settings( $post_type );
|
152 |
foreach ( $settings as $Setting ) {
|
153 |
$groups = $Setting->get_groups();
|
154 |
foreach ( $groups as $Group ) {
|
1 |
<?php
|
2 |
/**
|
3 |
* Smart_Custom_Fields_Controller_Editor
|
4 |
+
* Version : 1.0.1
|
5 |
* Author : Takashi Kitajima
|
6 |
* Created : September 23, 2014
|
7 |
+
* Modified : March 13, 2015
|
8 |
* License : GPLv2
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
65 |
*/
|
66 |
public function add_meta_boxes( $post_type, $post ) {
|
67 |
$_post = $post;
|
68 |
+
$settings = SCF::get_settings( $post_type, $post->ID );
|
69 |
foreach ( $settings as $Setting ) {
|
70 |
add_meta_box(
|
71 |
SCF_Config::PREFIX . 'custom-field-' . $Setting->get_id(),
|
148 |
$multiple_data_fields = array();
|
149 |
|
150 |
$post_type = get_post_type();
|
151 |
+
$settings = SCF::get_settings( $post_type, $post_id );
|
152 |
foreach ( $settings as $Setting ) {
|
153 |
$groups = $Setting->get_groups();
|
154 |
foreach ( $groups as $Group ) {
|
classes/models/class.revisions.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Smart_Custom_Fields_Revisions
|
4 |
-
* Version : 1.1.
|
5 |
* Author : Takashi Kitajima
|
6 |
* Created : September 23, 2014
|
7 |
-
* Modified :
|
8 |
* License : GPLv2
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -44,7 +44,7 @@ class Smart_Custom_Fields_Revisions {
|
|
44 |
$revision = get_post( $revision_id );
|
45 |
$post_type = get_post_type();
|
46 |
|
47 |
-
$settings = SCF::get_settings( $post_type );
|
48 |
foreach ( $settings as $Setting ) {
|
49 |
$groups = $Setting->get_groups();
|
50 |
foreach ( $groups as $Group ) {
|
@@ -83,7 +83,7 @@ class Smart_Custom_Fields_Revisions {
|
|
83 |
if ( !wp_is_post_revision( $post_id ) ) {
|
84 |
return;
|
85 |
}
|
86 |
-
$settings = SCF::get_settings( get_post_type() );
|
87 |
if ( !$settings ) {
|
88 |
return;
|
89 |
}
|
@@ -100,8 +100,8 @@ class Smart_Custom_Fields_Revisions {
|
|
100 |
// チェックボックスが未入力のときは "" がくるので、それは保存しないように判別
|
101 |
$multiple_data_fields = array();
|
102 |
|
103 |
-
$post_type = get_post_type();
|
104 |
-
$settings = SCF::get_settings( $post_type );
|
105 |
foreach ( $settings as $Setting ) {
|
106 |
$groups = $Setting->get_groups();
|
107 |
foreach ( $groups as $Group ) {
|
1 |
<?php
|
2 |
/**
|
3 |
* Smart_Custom_Fields_Revisions
|
4 |
+
* Version : 1.1.1
|
5 |
* Author : Takashi Kitajima
|
6 |
* Created : September 23, 2014
|
7 |
+
* Modified : March 13, 2015
|
8 |
* License : GPLv2
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
44 |
$revision = get_post( $revision_id );
|
45 |
$post_type = get_post_type();
|
46 |
|
47 |
+
$settings = SCF::get_settings( $post_type, $post_id );
|
48 |
foreach ( $settings as $Setting ) {
|
49 |
$groups = $Setting->get_groups();
|
50 |
foreach ( $groups as $Group ) {
|
83 |
if ( !wp_is_post_revision( $post_id ) ) {
|
84 |
return;
|
85 |
}
|
86 |
+
$settings = SCF::get_settings( get_post_type( $post_id ), $post_id );
|
87 |
if ( !$settings ) {
|
88 |
return;
|
89 |
}
|
100 |
// チェックボックスが未入力のときは "" がくるので、それは保存しないように判別
|
101 |
$multiple_data_fields = array();
|
102 |
|
103 |
+
$post_type = get_post_type( $post_id );
|
104 |
+
$settings = SCF::get_settings( $post_type, $post_id );
|
105 |
foreach ( $settings as $Setting ) {
|
106 |
$groups = $Setting->get_groups();
|
107 |
foreach ( $groups as $Group ) {
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
|
|
4 |
Tags: plugin, custom field, custom, field, meta, meta field, repeat, repeatable
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.1.1
|
7 |
-
Stable tag: 1.2.
|
8 |
License: GPLv2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -72,6 +72,11 @@ You can send your own language pack to me.
|
|
72 |
|
73 |
== Changelog ==
|
74 |
|
|
|
|
|
|
|
|
|
|
|
75 |
= 1.2.1 =
|
76 |
* Fixed a bug that post id filtering incorrect.
|
77 |
|
4 |
Tags: plugin, custom field, custom, field, meta, meta field, repeat, repeatable
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.1.1
|
7 |
+
Stable tag: 1.2.2
|
8 |
License: GPLv2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
72 |
|
73 |
== Changelog ==
|
74 |
|
75 |
+
= 1.2.2 =
|
76 |
+
* Fixed a bug that can not get the correct data when the posts use post id filtering.
|
77 |
+
* Changed that original the_content filter does not apply to wisywig field.
|
78 |
+
* Add post_id attribute to smart-cf-register-fields.
|
79 |
+
|
80 |
= 1.2.1 =
|
81 |
* Fixed a bug that post id filtering incorrect.
|
82 |
|
smart-custom-fields.php
CHANGED
@@ -3,11 +3,11 @@
|
|
3 |
* Plugin name: Smart Custom Fields
|
4 |
* Plugin URI: https://github.com/inc2734/smart-custom-fields/
|
5 |
* Description: Smart Custom Fields is a simple plugin that management custom fields.
|
6 |
-
* Version: 1.2.
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: October 9, 2014
|
10 |
-
* Modified: March
|
11 |
* Text Domain: smart-custom-fields
|
12 |
* Domain Path: /languages
|
13 |
* License: GPLv2
|
@@ -78,6 +78,12 @@ class Smart_Custom_Fields {
|
|
78 |
* @param WP_Screen $screen
|
79 |
*/
|
80 |
public function current_screen( $screen ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
// 一覧画面
|
82 |
if ( $screen->id === 'edit-' . SCF_Config::NAME ) {
|
83 |
}
|
@@ -87,7 +93,7 @@ class Smart_Custom_Fields {
|
|
87 |
new Smart_Custom_Fields_Controller_Settings();
|
88 |
}
|
89 |
// その他の新規作成・編集画面
|
90 |
-
elseif ( SCF::get_settings( $screen->id,
|
91 |
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.editor.php';
|
92 |
new Smart_Custom_Fields_Controller_Editor();
|
93 |
}
|
3 |
* Plugin name: Smart Custom Fields
|
4 |
* Plugin URI: https://github.com/inc2734/smart-custom-fields/
|
5 |
* Description: Smart Custom Fields is a simple plugin that management custom fields.
|
6 |
+
* Version: 1.2.2
|
7 |
* Author: Takashi Kitajima
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: October 9, 2014
|
10 |
+
* Modified: March 14, 2015
|
11 |
* Text Domain: smart-custom-fields
|
12 |
* Domain Path: /languages
|
13 |
* License: GPLv2
|
78 |
* @param WP_Screen $screen
|
79 |
*/
|
80 |
public function current_screen( $screen ) {
|
81 |
+
$post_id = false;
|
82 |
+
if ( !empty( $_GET['post'] ) ) {
|
83 |
+
$post_id = $_GET['post'];
|
84 |
+
} elseif ( !empty( $_POST['post_ID'] ) ) {
|
85 |
+
$post_id = $_POST['post_ID'];
|
86 |
+
}
|
87 |
// 一覧画面
|
88 |
if ( $screen->id === 'edit-' . SCF_Config::NAME ) {
|
89 |
}
|
93 |
new Smart_Custom_Fields_Controller_Settings();
|
94 |
}
|
95 |
// その他の新規作成・編集画面
|
96 |
+
elseif ( SCF::get_settings( $screen->id, $post_id ) ) {
|
97 |
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.editor.php';
|
98 |
new Smart_Custom_Fields_Controller_Editor();
|
99 |
}
|