Version Description
- Add message field. #64 (by @robssanches)
- Fix boolean field bug with
smart-cf-register-fields
filter hook. - Refactoring displaying options process of each fields.
Download this release
Release Info
Developer | inc2734 |
Plugin | Smart Custom Fields |
Version | 4.0.0 |
Comparing to | |
See all releases |
Code changes from version 3.1.7 to 4.0.0
- classes/class.config.php +2 -2
- classes/controller/class.controller-base.php +16 -8
- classes/controller/class.settings.php +9 -3
- classes/fields/class.field-boolean.php +3 -0
- classes/fields/class.field-check.php +2 -0
- classes/fields/class.field-colorpicker.php +9 -5
- classes/fields/class.field-datepicker.php +8 -3
- classes/fields/class.field-file.php +2 -0
- classes/fields/class.field-image.php +2 -0
- classes/fields/class.field-message.php +88 -0
- classes/fields/class.field-radio.php +2 -0
- classes/fields/class.field-related-posts.php +7 -3
- classes/fields/class.field-related-terms.php +7 -3
- classes/fields/class.field-select.php +2 -0
- classes/fields/class.field-text.php +2 -0
- classes/fields/class.field-textarea.php +2 -0
- classes/fields/class.field-wysiwyg.php +3 -1
- classes/models/class.abstract-field-base.php +24 -15
- languages/smart-custom-fields-ja.mo +0 -0
- languages/smart-custom-fields-ja.po +119 -125
- languages/smart-custom-fields-pt_BR.mo +0 -0
- languages/smart-custom-fields-pt_BR.po +65 -66
- languages/smart-custom-fields.pot +11 -179
- readme.txt +9 -3
- smart-custom-fields.php +1 -1
- trunk/classes/class.config.php +26 -0
- trunk/classes/class.scf.php +804 -0
- trunk/classes/controller/class.controller-base.php +340 -0
- trunk/classes/controller/class.editor.php +61 -0
- trunk/classes/controller/class.option.php +75 -0
- trunk/classes/controller/class.profile.php +73 -0
- trunk/classes/controller/class.settings.php +411 -0
- trunk/classes/controller/class.taxonomy.php +87 -0
- trunk/classes/fields/class.field-boolean.php +168 -0
- trunk/classes/fields/class.field-check.php +146 -0
- trunk/classes/fields/class.field-colorpicker.php +134 -0
- trunk/classes/fields/class.field-datepicker.php +262 -0
- trunk/classes/fields/class.field-file.php +137 -0
- trunk/classes/fields/class.field-image.php +143 -0
- trunk/classes/fields/class.field-message.php +88 -0
- trunk/classes/fields/class.field-radio.php +145 -0
- trunk/classes/fields/class.field-related-posts.php +300 -0
- trunk/classes/fields/class.field-related-terms.php +296 -0
- trunk/classes/fields/class.field-select.php +120 -0
- trunk/classes/fields/class.field-text.php +95 -0
- trunk/classes/fields/class.field-textarea.php +108 -0
- trunk/classes/fields/class.field-wysiwyg.php +216 -0
- trunk/classes/models/class.abstract-field-base.php +250 -0
- trunk/classes/models/class.ajax.php +34 -0
- trunk/classes/models/class.cache.php +249 -0
- trunk/classes/models/class.group.php +145 -0
- trunk/classes/models/class.meta.php +561 -0
- trunk/classes/models/class.options-page.php +86 -0
- trunk/classes/models/class.revisions.php +205 -0
- trunk/classes/models/class.setting.php +155 -0
- trunk/css/editor.css +253 -0
- trunk/css/option.css +9 -0
- trunk/css/profile.css +25 -0
- trunk/css/settings.css +220 -0
- trunk/css/taxonomy.css +17 -0
- trunk/css/wysiwyg.css +14 -0
- trunk/images/handle.png +0 -0
- trunk/js/editor-colorpicker.js +27 -0
- trunk/js/editor-datepicker.js +27 -0
- trunk/js/editor-relation-common.js +76 -0
- trunk/js/editor-relation-post-types.js +94 -0
- trunk/js/editor-relation-taxonomies.js +93 -0
- trunk/js/editor-wysiwyg.js +164 -0
- trunk/js/editor.js +204 -0
- trunk/js/settings-colorpicker.js +25 -0
- trunk/js/settings-datepicker.js +25 -0
- trunk/js/settings.js +221 -0
- trunk/languages/smart-custom-fields-ja.mo +0 -0
- trunk/languages/smart-custom-fields-ja.po +379 -0
- trunk/languages/smart-custom-fields-pt_BR.mo +0 -0
- trunk/languages/smart-custom-fields-pt_BR.po +387 -0
- trunk/languages/smart-custom-fields.pot +216 -0
- trunk/readme.txt +322 -0
- trunk/smart-custom-fields.php +274 -0
classes/class.config.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Version : 1.0.1
|
5 |
* Author : inc2734
|
6 |
* Created : September 23, 2014
|
7 |
-
* Modified :
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -23,4 +23,4 @@ class SCF_Config {
|
|
23 |
* プロフィール画面用の擬似投稿タイプ
|
24 |
*/
|
25 |
const PROFILE = 'smart-cf-profile';
|
26 |
-
}
|
4 |
* Version : 1.0.1
|
5 |
* Author : inc2734
|
6 |
* Created : September 23, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
23 |
* プロフィール画面用の擬似投稿タイプ
|
24 |
*/
|
25 |
const PROFILE = 'smart-cf-profile';
|
26 |
+
}
|
classes/controller/class.controller-base.php
CHANGED
@@ -267,7 +267,7 @@ class Smart_Custom_Fields_Controller_Base {
|
|
267 |
}
|
268 |
|
269 |
printf(
|
270 |
-
'<div class="%s" %s>%s
|
271 |
esc_attr( SCF_Config::PREFIX . 'meta-box-table' ),
|
272 |
$style,
|
273 |
$btn_repeat
|
@@ -275,6 +275,8 @@ class Smart_Custom_Fields_Controller_Base {
|
|
275 |
|
276 |
foreach ( $fields as $Field ) {
|
277 |
$display_name = $Field->get_attribute( 'display-name' );
|
|
|
|
|
278 |
$field_name = $Field->get( 'name' );
|
279 |
$field_label = $Field->get( 'label' );
|
280 |
if ( !$field_label ) {
|
@@ -312,21 +314,27 @@ class Smart_Custom_Fields_Controller_Base {
|
|
312 |
}
|
313 |
|
314 |
$form_field = $Field->get_field( $index, $value );
|
|
|
|
|
|
|
315 |
printf(
|
316 |
-
'<tr>
|
317 |
-
|
318 |
<td>
|
319 |
-
%2$s
|
320 |
%3$s
|
321 |
%4$s
|
|
|
322 |
</td>
|
323 |
-
</tr>',
|
324 |
-
|
|
|
325 |
$instruction,
|
326 |
$form_field,
|
327 |
-
$notes
|
|
|
|
|
328 |
);
|
329 |
}
|
330 |
-
echo '</
|
331 |
}
|
332 |
}
|
267 |
}
|
268 |
|
269 |
printf(
|
270 |
+
'<div class="%s" %s>%s',
|
271 |
esc_attr( SCF_Config::PREFIX . 'meta-box-table' ),
|
272 |
$style,
|
273 |
$btn_repeat
|
275 |
|
276 |
foreach ( $fields as $Field ) {
|
277 |
$display_name = $Field->get_attribute( 'display-name' );
|
278 |
+
$field_type = $Field->get_attribute( 'type' ); // gets the field type for use in aditional CSS classes
|
279 |
+
$layout = $Field->get_attribute( 'layout' ); // get layout type
|
280 |
$field_name = $Field->get( 'name' );
|
281 |
$field_label = $Field->get( 'label' );
|
282 |
if ( !$field_label ) {
|
314 |
}
|
315 |
|
316 |
$form_field = $Field->get_field( $index, $value );
|
317 |
+
|
318 |
+
// if the layout type is full-width, it hides the "Table Header" (th)
|
319 |
+
$table_th = $layout != 'full-width' ? '<th>'.esc_html( $field_label ).'</th>' : '';
|
320 |
printf(
|
321 |
+
'<table class="%1$sfield-type-%6$s %1$slayout-type-%7$s"><tr>
|
322 |
+
%2$s
|
323 |
<td>
|
|
|
324 |
%3$s
|
325 |
%4$s
|
326 |
+
%5$s
|
327 |
</td>
|
328 |
+
</tr></table>',
|
329 |
+
SCF_Config::PREFIX,
|
330 |
+
$table_th,
|
331 |
$instruction,
|
332 |
$form_field,
|
333 |
+
$notes,
|
334 |
+
$field_type,
|
335 |
+
$layout
|
336 |
);
|
337 |
}
|
338 |
+
echo '</div>';
|
339 |
}
|
340 |
}
|
classes/controller/class.settings.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Version : 1.3.0
|
5 |
* Author : inc2734
|
6 |
* Created : September 23, 2014
|
7 |
-
* Modified :
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -49,20 +49,26 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
49 |
*/
|
50 |
public function admin_enqueue_scripts() {
|
51 |
do_action( SCF_Config::PREFIX . 'before-settings-enqueue-scripts' );
|
|
|
52 |
wp_enqueue_style(
|
53 |
SCF_Config::PREFIX . 'settings',
|
54 |
-
plugins_url( SCF_Config::NAME ) . '/css/settings.css'
|
|
|
|
|
55 |
);
|
|
|
56 |
wp_enqueue_script(
|
57 |
SCF_Config::PREFIX . 'settings',
|
58 |
plugins_url( SCF_Config::NAME ) . '/js/settings.js',
|
59 |
array( 'jquery' ),
|
60 |
-
|
61 |
true
|
62 |
);
|
|
|
63 |
wp_localize_script( SCF_Config::PREFIX . 'settings', 'smart_cf_settings', array(
|
64 |
'duplicate_alert' => esc_html__( 'Same name exists!', 'smart-custom-fields' ),
|
65 |
) );
|
|
|
66 |
wp_enqueue_script( 'jquery-ui-sortable' );
|
67 |
do_action( SCF_Config::PREFIX . 'after-settings-enqueue-scripts' );
|
68 |
}
|
4 |
* Version : 1.3.0
|
5 |
* Author : inc2734
|
6 |
* Created : September 23, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
49 |
*/
|
50 |
public function admin_enqueue_scripts() {
|
51 |
do_action( SCF_Config::PREFIX . 'before-settings-enqueue-scripts' );
|
52 |
+
|
53 |
wp_enqueue_style(
|
54 |
SCF_Config::PREFIX . 'settings',
|
55 |
+
plugins_url( SCF_Config::NAME ) . '/css/settings.css',
|
56 |
+
array(),
|
57 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../css/settings.css' ) )
|
58 |
);
|
59 |
+
|
60 |
wp_enqueue_script(
|
61 |
SCF_Config::PREFIX . 'settings',
|
62 |
plugins_url( SCF_Config::NAME ) . '/js/settings.js',
|
63 |
array( 'jquery' ),
|
64 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/settings.js' ) ),
|
65 |
true
|
66 |
);
|
67 |
+
|
68 |
wp_localize_script( SCF_Config::PREFIX . 'settings', 'smart_cf_settings', array(
|
69 |
'duplicate_alert' => esc_html__( 'Same name exists!', 'smart-custom-fields' ),
|
70 |
) );
|
71 |
+
|
72 |
wp_enqueue_script( 'jquery-ui-sortable' );
|
73 |
do_action( SCF_Config::PREFIX . 'after-settings-enqueue-scripts' );
|
74 |
}
|
classes/fields/class.field-boolean.php
CHANGED
@@ -50,6 +50,7 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
|
50 |
public function get_field( $index, $value ) {
|
51 |
$name = $this->get_field_name_in_editor( $index );
|
52 |
$disabled = $this->get_disable_attribute( $index );
|
|
|
53 |
|
54 |
$true = sprintf(
|
55 |
'<label><input type="radio" name="%s" value="1" class="widefat" %s %s />%s ( true )</label>',
|
@@ -77,6 +78,8 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
|
77 |
* @param int $field_key
|
78 |
*/
|
79 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
80 |
?>
|
81 |
<tr>
|
82 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
50 |
public function get_field( $index, $value ) {
|
51 |
$name = $this->get_field_name_in_editor( $index );
|
52 |
$disabled = $this->get_disable_attribute( $index );
|
53 |
+
$value = ( true === $value || 1 === $value || '1' === $value ) ? 1 : 0;
|
54 |
|
55 |
$true = sprintf(
|
56 |
'<label><input type="radio" name="%s" value="1" class="widefat" %s %s />%s ( true )</label>',
|
78 |
* @param int $field_key
|
79 |
*/
|
80 |
public function display_field_options( $group_key, $field_key ) {
|
81 |
+
$this->display_name_option( $group_key, $field_key );
|
82 |
+
$this->display_label_option( $group_key, $field_key );
|
83 |
?>
|
84 |
<tr>
|
85 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-check.php
CHANGED
@@ -82,6 +82,8 @@ class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
|
|
82 |
* @param int $field_key
|
83 |
*/
|
84 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
85 |
?>
|
86 |
<tr>
|
87 |
<th><?php esc_html_e( 'Choices', 'smart-custom-fields' ); ?></th>
|
82 |
* @param int $field_key
|
83 |
*/
|
84 |
public function display_field_options( $group_key, $field_key ) {
|
85 |
+
$this->display_name_option( $group_key, $field_key );
|
86 |
+
$this->display_label_option( $group_key, $field_key );
|
87 |
?>
|
88 |
<tr>
|
89 |
<th><?php esc_html_e( 'Choices', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-colorpicker.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Version : 1.2.0
|
5 |
* Author : inc2734
|
6 |
* Created : October 21, 2014
|
7 |
-
* Modified : June
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -49,11 +49,12 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
|
|
49 |
*/
|
50 |
public function editor_enqueue_scripts() {
|
51 |
wp_enqueue_style( 'wp-color-picker' );
|
|
|
52 |
wp_enqueue_script(
|
53 |
SCF_Config::PREFIX . 'editor-colorpicker',
|
54 |
-
plugins_url( '
|
55 |
array( 'jquery', 'wp-color-picker' ),
|
56 |
-
|
57 |
true
|
58 |
);
|
59 |
}
|
@@ -63,11 +64,12 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
|
|
63 |
*/
|
64 |
public function settings_enqueue_scripts() {
|
65 |
wp_enqueue_style( 'wp-color-picker' );
|
|
|
66 |
wp_enqueue_script(
|
67 |
SCF_Config::PREFIX . 'settings-colorpicker',
|
68 |
-
plugins_url( '
|
69 |
array( 'jquery', 'wp-color-picker' ),
|
70 |
-
|
71 |
true
|
72 |
);
|
73 |
}
|
@@ -98,6 +100,8 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
|
|
98 |
* @param int $field_key
|
99 |
*/
|
100 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
101 |
?>
|
102 |
<tr>
|
103 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
4 |
* Version : 1.2.0
|
5 |
* Author : inc2734
|
6 |
* Created : October 21, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
49 |
*/
|
50 |
public function editor_enqueue_scripts() {
|
51 |
wp_enqueue_style( 'wp-color-picker' );
|
52 |
+
|
53 |
wp_enqueue_script(
|
54 |
SCF_Config::PREFIX . 'editor-colorpicker',
|
55 |
+
plugins_url( SCF_Config::NAME ) . '/js/editor-colorpicker.js',
|
56 |
array( 'jquery', 'wp-color-picker' ),
|
57 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-colorpicker.js' ) ),
|
58 |
true
|
59 |
);
|
60 |
}
|
64 |
*/
|
65 |
public function settings_enqueue_scripts() {
|
66 |
wp_enqueue_style( 'wp-color-picker' );
|
67 |
+
|
68 |
wp_enqueue_script(
|
69 |
SCF_Config::PREFIX . 'settings-colorpicker',
|
70 |
+
plugins_url( SCF_Config::NAME ) . '/js/settings-colorpicker.js',
|
71 |
array( 'jquery', 'wp-color-picker' ),
|
72 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/settings-colorpicker.js' ) ),
|
73 |
true
|
74 |
);
|
75 |
}
|
100 |
* @param int $field_key
|
101 |
*/
|
102 |
public function display_field_options( $group_key, $field_key ) {
|
103 |
+
$this->display_name_option( $group_key, $field_key );
|
104 |
+
$this->display_label_option( $group_key, $field_key );
|
105 |
?>
|
106 |
<tr>
|
107 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-datepicker.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Version : 1.2.0
|
5 |
* Author : inc2734
|
6 |
* Created : January 17, 2015
|
7 |
-
* Modified : June
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -75,18 +75,21 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
|
|
75 |
public function settings_enqueue_scripts() {
|
76 |
global $wp_scripts;
|
77 |
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
|
|
78 |
wp_enqueue_style(
|
79 |
'jquery.ui',
|
80 |
'//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css',
|
81 |
array(),
|
82 |
$ui->ver
|
83 |
);
|
|
|
84 |
wp_enqueue_script( 'jquery-ui-datepicker' );
|
|
|
85 |
wp_enqueue_script(
|
86 |
SCF_Config::PREFIX . 'settings-datepicker',
|
87 |
-
plugins_url( '
|
88 |
array( 'jquery', 'jquery-ui-datepicker' ),
|
89 |
-
|
90 |
true
|
91 |
);
|
92 |
}
|
@@ -120,6 +123,8 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
|
|
120 |
* @param int $field_key
|
121 |
*/
|
122 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
123 |
?>
|
124 |
<tr>
|
125 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
4 |
* Version : 1.2.0
|
5 |
* Author : inc2734
|
6 |
* Created : January 17, 2015
|
7 |
+
* Modified : June 04, 2018
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
75 |
public function settings_enqueue_scripts() {
|
76 |
global $wp_scripts;
|
77 |
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
78 |
+
|
79 |
wp_enqueue_style(
|
80 |
'jquery.ui',
|
81 |
'//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css',
|
82 |
array(),
|
83 |
$ui->ver
|
84 |
);
|
85 |
+
|
86 |
wp_enqueue_script( 'jquery-ui-datepicker' );
|
87 |
+
|
88 |
wp_enqueue_script(
|
89 |
SCF_Config::PREFIX . 'settings-datepicker',
|
90 |
+
plugins_url( SCF_Config::NAME ) . '/js/settings-datepicker.js',
|
91 |
array( 'jquery', 'jquery-ui-datepicker' ),
|
92 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/settings-datepicker.js' ) ),
|
93 |
true
|
94 |
);
|
95 |
}
|
123 |
* @param int $field_key
|
124 |
*/
|
125 |
public function display_field_options( $group_key, $field_key ) {
|
126 |
+
$this->display_name_option( $group_key, $field_key );
|
127 |
+
$this->display_label_option( $group_key, $field_key );
|
128 |
?>
|
129 |
<tr>
|
130 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-file.php
CHANGED
@@ -112,6 +112,8 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
|
|
112 |
* @param int $field_key
|
113 |
*/
|
114 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
115 |
?>
|
116 |
<tr>
|
117 |
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
112 |
* @param int $field_key
|
113 |
*/
|
114 |
public function display_field_options( $group_key, $field_key ) {
|
115 |
+
$this->display_name_option( $group_key, $field_key );
|
116 |
+
$this->display_label_option( $group_key, $field_key );
|
117 |
?>
|
118 |
<tr>
|
119 |
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-image.php
CHANGED
@@ -107,6 +107,8 @@ class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
|
|
107 |
* @param int $field_key
|
108 |
*/
|
109 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
110 |
?>
|
111 |
<tr>
|
112 |
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
107 |
* @param int $field_key
|
108 |
*/
|
109 |
public function display_field_options( $group_key, $field_key ) {
|
110 |
+
$this->display_name_option( $group_key, $field_key );
|
111 |
+
$this->display_label_option( $group_key, $field_key );
|
112 |
?>
|
113 |
<tr>
|
114 |
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-message.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Message
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : robssanches, inc2734
|
6 |
+
* Created : June 2, 2018
|
7 |
+
* Modified : June 2, 2018
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Message extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
return array(
|
20 |
+
'type' => 'message',
|
21 |
+
'display-name' => __( 'Message', 'smart-custom-fields' ),
|
22 |
+
'optgroup' => 'basic-fields',
|
23 |
+
'allow-multiple-data' => false,
|
24 |
+
'layout' => 'full-width'
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Set the non required items
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
protected function options() {
|
34 |
+
return array(
|
35 |
+
'default' => '',
|
36 |
+
'notes' => ''
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Getting the field
|
42 |
+
*
|
43 |
+
* @param int $index
|
44 |
+
* @param string $value
|
45 |
+
* @return string html
|
46 |
+
*/
|
47 |
+
public function get_field( $index, $value ) {
|
48 |
+
$name = $this->get_field_name_in_editor( $index );
|
49 |
+
$disabled = $this->get_disable_attribute( $index );
|
50 |
+
return sprintf(
|
51 |
+
'<div id="%s" class="widefat" %s>%s</div>',
|
52 |
+
esc_attr( $name ),
|
53 |
+
disabled( true, $disabled, false ),
|
54 |
+
$value
|
55 |
+
);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Displaying the option fields in custom field settings page
|
60 |
+
*
|
61 |
+
* @param int $group_key
|
62 |
+
* @param int $field_key
|
63 |
+
*/
|
64 |
+
public function display_field_options( $group_key, $field_key ) {
|
65 |
+
$this->display_name_option( $group_key, $field_key );
|
66 |
+
?>
|
67 |
+
<tr>
|
68 |
+
<th><?php esc_html_e( 'Message', 'smart-custom-fields' ); ?></th>
|
69 |
+
<td>
|
70 |
+
<textarea
|
71 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
72 |
+
class="widefat"
|
73 |
+
rows="5"><?php echo esc_textarea( "\n" . $this->get( 'default' ) ); ?></textarea>
|
74 |
+
</td>
|
75 |
+
</tr>
|
76 |
+
<tr>
|
77 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
78 |
+
<td>
|
79 |
+
<input type="text"
|
80 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
81 |
+
class="widefat"
|
82 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
83 |
+
/>
|
84 |
+
</td>
|
85 |
+
</tr>
|
86 |
+
<?php
|
87 |
+
}
|
88 |
+
}
|
classes/fields/class.field-radio.php
CHANGED
@@ -81,6 +81,8 @@ class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
|
|
81 |
* @param int $field_key
|
82 |
*/
|
83 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
84 |
?>
|
85 |
<tr>
|
86 |
<th><?php esc_html_e( 'Choices', 'smart-custom-fields' ); ?></th>
|
81 |
* @param int $field_key
|
82 |
*/
|
83 |
public function display_field_options( $group_key, $field_key ) {
|
84 |
+
$this->display_name_option( $group_key, $field_key );
|
85 |
+
$this->display_label_option( $group_key, $field_key );
|
86 |
?>
|
87 |
<tr>
|
88 |
<th><?php esc_html_e( 'Choices', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-related-posts.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Version : 1.4.1
|
5 |
* Author : inc2734
|
6 |
* Created : October 7, 2014
|
7 |
-
* Modified :
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -51,16 +51,18 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
|
|
51 |
SCF_Config::PREFIX . 'editor-relation-common',
|
52 |
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
|
53 |
array( 'jquery' ),
|
54 |
-
|
55 |
true
|
56 |
);
|
|
|
57 |
wp_enqueue_script(
|
58 |
SCF_Config::PREFIX . 'editor-relation-post-types',
|
59 |
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-post-types.js',
|
60 |
array( 'jquery' ),
|
61 |
-
|
62 |
true
|
63 |
);
|
|
|
64 |
wp_localize_script( SCF_Config::PREFIX . 'editor-relation-post-types', 'smart_cf_relation_post_types', array(
|
65 |
'endpoint' => admin_url( 'admin-ajax.php' ),
|
66 |
'action' => SCF_Config::PREFIX . 'relational-posts-search',
|
@@ -226,6 +228,8 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
|
|
226 |
* @param int $field_key
|
227 |
*/
|
228 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
229 |
?>
|
230 |
<tr>
|
231 |
<th><?php esc_html_e( 'Post Types', 'smart-custom-fields' ); ?></th>
|
4 |
* Version : 1.4.1
|
5 |
* Author : inc2734
|
6 |
* Created : October 7, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
51 |
SCF_Config::PREFIX . 'editor-relation-common',
|
52 |
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
|
53 |
array( 'jquery' ),
|
54 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-relation-common.js' ) ),
|
55 |
true
|
56 |
);
|
57 |
+
|
58 |
wp_enqueue_script(
|
59 |
SCF_Config::PREFIX . 'editor-relation-post-types',
|
60 |
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-post-types.js',
|
61 |
array( 'jquery' ),
|
62 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-relation-post-types.js' ) ),
|
63 |
true
|
64 |
);
|
65 |
+
|
66 |
wp_localize_script( SCF_Config::PREFIX . 'editor-relation-post-types', 'smart_cf_relation_post_types', array(
|
67 |
'endpoint' => admin_url( 'admin-ajax.php' ),
|
68 |
'action' => SCF_Config::PREFIX . 'relational-posts-search',
|
228 |
* @param int $field_key
|
229 |
*/
|
230 |
public function display_field_options( $group_key, $field_key ) {
|
231 |
+
$this->display_name_option( $group_key, $field_key );
|
232 |
+
$this->display_label_option( $group_key, $field_key );
|
233 |
?>
|
234 |
<tr>
|
235 |
<th><?php esc_html_e( 'Post Types', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-related-terms.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Version : 1.5.1
|
5 |
* Author : inc2734
|
6 |
* Created : October 7, 2014
|
7 |
-
* Modified :
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -51,16 +51,18 @@ class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_
|
|
51 |
SCF_Config::PREFIX . 'editor-relation-common',
|
52 |
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
|
53 |
array( 'jquery' ),
|
54 |
-
|
55 |
true
|
56 |
);
|
|
|
57 |
wp_enqueue_script(
|
58 |
SCF_Config::PREFIX . 'editor-relation-taxonomies',
|
59 |
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-taxonomies.js',
|
60 |
array( 'jquery' ),
|
61 |
-
|
62 |
true
|
63 |
);
|
|
|
64 |
wp_localize_script( SCF_Config::PREFIX . 'editor-relation-taxonomies', 'smart_cf_relation_taxonomies', array(
|
65 |
'endpoint' => admin_url( 'admin-ajax.php' ),
|
66 |
'action' => SCF_Config::PREFIX . 'relational-terms-search',
|
@@ -224,6 +226,8 @@ class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_
|
|
224 |
* @param int $field_key
|
225 |
*/
|
226 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
227 |
?>
|
228 |
<tr>
|
229 |
<th><?php esc_html_e( 'Taxonomies', 'smart-custom-fields' ); ?></th>
|
4 |
* Version : 1.5.1
|
5 |
* Author : inc2734
|
6 |
* Created : October 7, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
51 |
SCF_Config::PREFIX . 'editor-relation-common',
|
52 |
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
|
53 |
array( 'jquery' ),
|
54 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-relation-common.js' ) ),
|
55 |
true
|
56 |
);
|
57 |
+
|
58 |
wp_enqueue_script(
|
59 |
SCF_Config::PREFIX . 'editor-relation-taxonomies',
|
60 |
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-taxonomies.js',
|
61 |
array( 'jquery' ),
|
62 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-relation-taxonomies.js' ) ),
|
63 |
true
|
64 |
);
|
65 |
+
|
66 |
wp_localize_script( SCF_Config::PREFIX . 'editor-relation-taxonomies', 'smart_cf_relation_taxonomies', array(
|
67 |
'endpoint' => admin_url( 'admin-ajax.php' ),
|
68 |
'action' => SCF_Config::PREFIX . 'relational-terms-search',
|
226 |
* @param int $field_key
|
227 |
*/
|
228 |
public function display_field_options( $group_key, $field_key ) {
|
229 |
+
$this->display_name_option( $group_key, $field_key );
|
230 |
+
$this->display_label_option( $group_key, $field_key );
|
231 |
?>
|
232 |
<tr>
|
233 |
<th><?php esc_html_e( 'Taxonomies', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-select.php
CHANGED
@@ -76,6 +76,8 @@ class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
|
|
76 |
* @param int $field_key
|
77 |
*/
|
78 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
79 |
?>
|
80 |
<tr>
|
81 |
<th><?php esc_html_e( 'Choices', 'smart-custom-fields' ); ?></th>
|
76 |
* @param int $field_key
|
77 |
*/
|
78 |
public function display_field_options( $group_key, $field_key ) {
|
79 |
+
$this->display_name_option( $group_key, $field_key );
|
80 |
+
$this->display_label_option( $group_key, $field_key );
|
81 |
?>
|
82 |
<tr>
|
83 |
<th><?php esc_html_e( 'Choices', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-text.php
CHANGED
@@ -61,6 +61,8 @@ class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
|
|
61 |
* @param int $field_key
|
62 |
*/
|
63 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
64 |
?>
|
65 |
<tr>
|
66 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
61 |
* @param int $field_key
|
62 |
*/
|
63 |
public function display_field_options( $group_key, $field_key ) {
|
64 |
+
$this->display_name_option( $group_key, $field_key );
|
65 |
+
$this->display_label_option( $group_key, $field_key );
|
66 |
?>
|
67 |
<tr>
|
68 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-textarea.php
CHANGED
@@ -64,6 +64,8 @@ class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base
|
|
64 |
* @param int $field_key
|
65 |
*/
|
66 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
67 |
?>
|
68 |
<tr>
|
69 |
<th><?php esc_html_e( 'Rows', 'smart-custom-fields' ); ?></th>
|
64 |
* @param int $field_key
|
65 |
*/
|
66 |
public function display_field_options( $group_key, $field_key ) {
|
67 |
+
$this->display_name_option( $group_key, $field_key );
|
68 |
+
$this->display_label_option( $group_key, $field_key );
|
69 |
?>
|
70 |
<tr>
|
71 |
<th><?php esc_html_e( 'Rows', 'smart-custom-fields' ); ?></th>
|
classes/fields/class.field-wysiwyg.php
CHANGED
@@ -106,7 +106,7 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
|
106 |
$value,
|
107 |
esc_html__( 'Visual', 'smart-custom-fields' ),
|
108 |
esc_html__( 'Text', 'smart-custom-fields' )
|
109 |
-
|
110 |
);
|
111 |
}
|
112 |
|
@@ -117,6 +117,8 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
|
117 |
* @param int $field_key
|
118 |
*/
|
119 |
public function display_field_options( $group_key, $field_key ) {
|
|
|
|
|
120 |
?>
|
121 |
<tr>
|
122 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
106 |
$value,
|
107 |
esc_html__( 'Visual', 'smart-custom-fields' ),
|
108 |
esc_html__( 'Text', 'smart-custom-fields' )
|
109 |
+
|
110 |
);
|
111 |
}
|
112 |
|
117 |
* @param int $field_key
|
118 |
*/
|
119 |
public function display_field_options( $group_key, $field_key ) {
|
120 |
+
$this->display_name_option( $group_key, $field_key );
|
121 |
+
$this->display_label_option( $group_key, $field_key );
|
122 |
?>
|
123 |
<tr>
|
124 |
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
classes/models/class.abstract-field-base.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Version : 1.1.1
|
5 |
* Author : inc2734
|
6 |
* Created : October 7, 2014
|
7 |
-
* Modified :
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
@@ -19,6 +19,7 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
19 |
'display-name' => '', // eg. Text
|
20 |
'optgroup' => 'other-fields',
|
21 |
'allow-multiple-data' => false,
|
|
|
22 |
);
|
23 |
|
24 |
/**
|
@@ -95,11 +96,23 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
95 |
|
96 |
/**
|
97 |
* Displaying the option fields in custom field settings page ( Common )
|
98 |
-
*
|
99 |
* @param int $group_key
|
100 |
* @param int $field_key
|
101 |
*/
|
102 |
public function display_options( $group_key, $field_key ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
?>
|
104 |
<tr>
|
105 |
<th><?php esc_html_e( 'Name', 'smart-custom-fields' ); ?><span class="<?php echo esc_attr( SCF_Config::PREFIX . 'require' ); ?>">*</span></th>
|
@@ -112,6 +125,11 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
112 |
/>
|
113 |
</td>
|
114 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
115 |
<tr>
|
116 |
<th><?php esc_html_e( 'Label', 'smart-custom-fields' ); ?></th>
|
117 |
<td>
|
@@ -124,15 +142,6 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
124 |
</td>
|
125 |
</tr>
|
126 |
<?php
|
127 |
-
$fields = SCF::get_form_field_instances();
|
128 |
-
foreach ( $fields as $Field ) {
|
129 |
-
if ( $Field->get_attribute( 'type' ) === $this->get_attribute( 'type' ) ) {
|
130 |
-
foreach ( $this->options as $key => $value ) {
|
131 |
-
$Field->set( $key, $value );
|
132 |
-
}
|
133 |
-
}
|
134 |
-
$Field->_display_field_options( $group_key, $field_key );
|
135 |
-
}
|
136 |
}
|
137 |
|
138 |
/**
|
@@ -156,7 +165,7 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
156 |
|
157 |
/**
|
158 |
* Getting the name attribute in editor page
|
159 |
-
*
|
160 |
* @param string $name
|
161 |
* @param string $index
|
162 |
* @return string
|
@@ -173,7 +182,7 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
173 |
/**
|
174 |
* Whether to disabled
|
175 |
* Return true only when the null because data that all users have saved when $index is not null
|
176 |
-
*
|
177 |
* @param string $index
|
178 |
* @return bool $disabled
|
179 |
*/
|
@@ -187,7 +196,7 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
187 |
|
188 |
/**
|
189 |
* Getting the name attribute in custom field settings page
|
190 |
-
*
|
191 |
* @param int $group_key
|
192 |
* @param int $field_key
|
193 |
* @param string $name
|
@@ -217,7 +226,7 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
217 |
|
218 |
/**
|
219 |
* Set option value
|
220 |
-
*
|
221 |
* @param string $key
|
222 |
* @param mixed $value
|
223 |
*/
|
4 |
* Version : 1.1.1
|
5 |
* Author : inc2734
|
6 |
* Created : October 7, 2014
|
7 |
+
* Modified : June 2, 2018
|
8 |
* License : GPLv2 or later
|
9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
*/
|
19 |
'display-name' => '', // eg. Text
|
20 |
'optgroup' => 'other-fields',
|
21 |
'allow-multiple-data' => false,
|
22 |
+
'layout' => 'default', // or "full-width" (new attribute to choose layout type)
|
23 |
);
|
24 |
|
25 |
/**
|
96 |
|
97 |
/**
|
98 |
* Displaying the option fields in custom field settings page ( Common )
|
99 |
+
*
|
100 |
* @param int $group_key
|
101 |
* @param int $field_key
|
102 |
*/
|
103 |
public function display_options( $group_key, $field_key ) {
|
104 |
+
$fields = SCF::get_form_field_instances();
|
105 |
+
foreach ( $fields as $Field ) {
|
106 |
+
if ( $Field->get_attribute( 'type' ) === $this->get_attribute( 'type' ) ) {
|
107 |
+
foreach ( $this->options as $key => $value ) {
|
108 |
+
$Field->set( $key, $value );
|
109 |
+
}
|
110 |
+
}
|
111 |
+
$Field->_display_field_options( $group_key, $field_key );
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
protected function display_name_option( $group_key, $field_key ) {
|
116 |
?>
|
117 |
<tr>
|
118 |
<th><?php esc_html_e( 'Name', 'smart-custom-fields' ); ?><span class="<?php echo esc_attr( SCF_Config::PREFIX . 'require' ); ?>">*</span></th>
|
125 |
/>
|
126 |
</td>
|
127 |
</tr>
|
128 |
+
<?php
|
129 |
+
}
|
130 |
+
|
131 |
+
protected function display_label_option( $group_key, $field_key ) {
|
132 |
+
?>
|
133 |
<tr>
|
134 |
<th><?php esc_html_e( 'Label', 'smart-custom-fields' ); ?></th>
|
135 |
<td>
|
142 |
</td>
|
143 |
</tr>
|
144 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
|
147 |
/**
|
165 |
|
166 |
/**
|
167 |
* Getting the name attribute in editor page
|
168 |
+
*
|
169 |
* @param string $name
|
170 |
* @param string $index
|
171 |
* @return string
|
182 |
/**
|
183 |
* Whether to disabled
|
184 |
* Return true only when the null because data that all users have saved when $index is not null
|
185 |
+
*
|
186 |
* @param string $index
|
187 |
* @return bool $disabled
|
188 |
*/
|
196 |
|
197 |
/**
|
198 |
* Getting the name attribute in custom field settings page
|
199 |
+
*
|
200 |
* @param int $group_key
|
201 |
* @param int $field_key
|
202 |
* @param string $name
|
226 |
|
227 |
/**
|
228 |
* Set option value
|
229 |
+
*
|
230 |
* @param string $key
|
231 |
* @param mixed $value
|
232 |
*/
|
languages/smart-custom-fields-ja.mo
CHANGED
Binary file
|
languages/smart-custom-fields-ja.po
CHANGED
@@ -2,22 +2,23 @@
|
|
2 |
# This file is distributed under the same license as the Smart Custom Fields package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Smart Custom Fields 3.1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smart-custom-"
|
7 |
"fields\n"
|
8 |
-
"POT-Creation-Date:
|
9 |
-
"PO-Revision-Date: 2018-
|
10 |
-
"Last-Translator:
|
11 |
"Language-Team: Japanese\n"
|
12 |
"Language: ja\n"
|
13 |
"MIME-Version: 1.0\n"
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
-
"
|
|
|
17 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
18 |
"X-Poedit-KeywordsList: __;_e;esc_html__;esc_html_e;esc_attr__;esc_attr_e\n"
|
19 |
"X-Poedit-Basepath: ..\n"
|
20 |
-
"X-Poedit-SearchPath-0:
|
21 |
|
22 |
#: classes/controller/class.controller-base.php:46
|
23 |
msgid "Image setting"
|
@@ -32,7 +33,7 @@ msgid "Save settings"
|
|
32 |
msgstr "設定を保存"
|
33 |
|
34 |
#: classes/controller/class.profile.php:43
|
35 |
-
#: classes/controller/class.settings.php:
|
36 |
msgid "Custom Fields"
|
37 |
msgstr "カスタムフィールド"
|
38 |
|
@@ -52,57 +53,57 @@ msgstr "コンテンツフィールド"
|
|
52 |
msgid "Other fields"
|
53 |
msgstr "その他のフィールド"
|
54 |
|
55 |
-
#: classes/controller/class.settings.php:
|
56 |
msgid "Same name exists!"
|
57 |
msgstr "同じ名前が存在します!"
|
58 |
|
59 |
-
#: classes/controller/class.settings.php:
|
60 |
msgid "Display conditions ( Post )"
|
61 |
msgstr "表示条件(投稿)"
|
62 |
|
63 |
-
#: classes/controller/class.settings.php:
|
64 |
msgid "Display conditions ( Profile )"
|
65 |
msgstr "表示条件(プロフィール)"
|
66 |
|
67 |
-
#: classes/controller/class.settings.php:
|
68 |
msgid "Display conditions ( Taxonomy )"
|
69 |
msgstr "表示条件(タクソノミー)"
|
70 |
|
71 |
-
#: classes/controller/class.settings.php:
|
72 |
msgid "Display conditions ( Options page )"
|
73 |
msgstr "表示条件(オプションページ)"
|
74 |
|
75 |
-
#: classes/controller/class.settings.php:
|
76 |
msgid "Type"
|
77 |
msgstr "タイプ"
|
78 |
|
79 |
-
#: classes/controller/class.settings.php:
|
80 |
msgid "Add Sub field"
|
81 |
msgstr "サブフィールドを追加"
|
82 |
|
83 |
-
#: classes/controller/class.settings.php:
|
84 |
msgid "Add Field"
|
85 |
msgstr "フィールド追加"
|
86 |
|
87 |
-
#: classes/controller/class.settings.php:
|
88 |
-
#: classes/fields/class.field-
|
89 |
msgid "Post Types"
|
90 |
msgstr "投稿タイプ"
|
91 |
|
92 |
-
#: classes/controller/class.settings.php:
|
93 |
msgid "Post Ids ( Comma separated )"
|
94 |
msgstr "投稿 ID (カンマ区切り)"
|
95 |
|
96 |
-
#: classes/controller/class.settings.php:
|
97 |
msgid "Roles"
|
98 |
msgstr "権限"
|
99 |
|
100 |
-
#: classes/controller/class.settings.php:
|
101 |
-
#: classes/fields/class.field-
|
102 |
msgid "Taxonomies"
|
103 |
msgstr "タクソノミー"
|
104 |
|
105 |
-
#: classes/controller/class.settings.php:
|
106 |
msgid "Options pages"
|
107 |
msgstr "オプションページ"
|
108 |
|
@@ -118,55 +119,56 @@ msgstr "はい"
|
|
118 |
msgid "No"
|
119 |
msgstr "いいえ"
|
120 |
|
121 |
-
#: classes/fields/class.field-boolean.php:
|
122 |
-
#: classes/fields/class.field-check.php:
|
123 |
-
#: classes/fields/class.field-colorpicker.php:
|
124 |
-
#: classes/fields/class.field-datepicker.php:
|
125 |
-
#: classes/fields/class.field-radio.php:
|
126 |
-
#: classes/fields/class.field-select.php:
|
127 |
-
#: classes/fields/class.field-text.php:
|
128 |
-
#: classes/fields/class.field-textarea.php:
|
129 |
-
#: classes/fields/class.field-wysiwyg.php:
|
130 |
msgid "Default"
|
131 |
msgstr "デフォルト"
|
132 |
|
133 |
-
#: classes/fields/class.field-boolean.php:
|
134 |
msgid "TRUE Label"
|
135 |
msgstr "TRUE ラベル"
|
136 |
|
137 |
-
#: classes/fields/class.field-boolean.php:
|
138 |
msgid "FALSE Label"
|
139 |
msgstr "FALSE ラベル"
|
140 |
|
141 |
-
#: classes/fields/class.field-boolean.php:
|
142 |
-
#: classes/fields/class.field-check.php:
|
143 |
-
#: classes/fields/class.field-colorpicker.php:
|
144 |
-
#: classes/fields/class.field-datepicker.php:
|
145 |
-
#: classes/fields/class.field-file.php:
|
146 |
-
#: classes/fields/class.field-image.php:
|
147 |
-
#: classes/fields/class.field-radio.php:
|
148 |
-
#: classes/fields/class.field-
|
149 |
-
#: classes/fields/class.field-
|
150 |
-
#: classes/fields/class.field-
|
151 |
-
#: classes/fields/class.field-text.php:
|
152 |
-
#: classes/fields/class.field-textarea.php:
|
153 |
-
#: classes/fields/class.field-wysiwyg.php:
|
154 |
msgid "Instruction"
|
155 |
msgstr "説明文"
|
156 |
|
157 |
-
#: classes/fields/class.field-boolean.php:
|
158 |
-
#: classes/fields/class.field-check.php:
|
159 |
-
#: classes/fields/class.field-colorpicker.php:
|
160 |
-
#: classes/fields/class.field-datepicker.php:
|
161 |
-
#: classes/fields/class.field-file.php:
|
162 |
-
#: classes/fields/class.field-image.php:
|
163 |
-
#: classes/fields/class.field-
|
164 |
-
#: classes/fields/class.field-
|
165 |
-
#: classes/fields/class.field-
|
166 |
-
#: classes/fields/class.field-
|
167 |
-
#: classes/fields/class.field-
|
168 |
-
#: classes/fields/class.field-
|
169 |
-
#: classes/fields/class.field-
|
|
|
170 |
msgid "Notes"
|
171 |
msgstr "注記"
|
172 |
|
@@ -174,31 +176,31 @@ msgstr "注記"
|
|
174 |
msgid "Check"
|
175 |
msgstr "チェックボックス"
|
176 |
|
177 |
-
#: classes/fields/class.field-check.php:
|
178 |
-
#: classes/fields/class.field-radio.php:
|
179 |
-
#: classes/fields/class.field-select.php:
|
180 |
msgid "Choices"
|
181 |
msgstr "選択肢"
|
182 |
|
183 |
-
#: classes/fields/class.field-check.php:
|
184 |
-
#: classes/fields/class.field-radio.php:
|
185 |
-
#: classes/fields/class.field-select.php:
|
186 |
msgid ""
|
187 |
"If you want to separate the key and the value, enter as follows: key => value"
|
188 |
msgstr "もしキーと値を分けたい場合は次のように入力してください: キー => 値"
|
189 |
|
190 |
-
#: classes/fields/class.field-check.php:
|
191 |
-
#: classes/fields/class.field-radio.php:
|
192 |
msgid "Display Direction"
|
193 |
msgstr "表示方向"
|
194 |
|
195 |
-
#: classes/fields/class.field-check.php:
|
196 |
-
#: classes/fields/class.field-radio.php:
|
197 |
msgid "horizontal"
|
198 |
msgstr "水平方向"
|
199 |
|
200 |
-
#: classes/fields/class.field-check.php:
|
201 |
-
#: classes/fields/class.field-radio.php:
|
202 |
msgid "vertical"
|
203 |
msgstr "垂直方向"
|
204 |
|
@@ -210,24 +212,24 @@ msgstr "カラーピッカー"
|
|
210 |
msgid "Date picker"
|
211 |
msgstr "日付ピッカー"
|
212 |
|
213 |
-
#: classes/fields/class.field-datepicker.php:
|
214 |
msgid "Date Format"
|
215 |
msgstr "日付のフォーマット"
|
216 |
|
217 |
-
#: classes/fields/class.field-datepicker.php:
|
218 |
msgid "e.g dd/mm/yy"
|
219 |
msgstr "例: dd/mm/yy"
|
220 |
|
221 |
-
#: classes/fields/class.field-datepicker.php:
|
222 |
msgid "Max Date"
|
223 |
msgstr "最大日付"
|
224 |
|
225 |
-
#: classes/fields/class.field-datepicker.php:
|
226 |
-
#: classes/fields/class.field-datepicker.php:
|
227 |
msgid "e.g +1m +1w"
|
228 |
msgstr "例: +1m +1w"
|
229 |
|
230 |
-
#: classes/fields/class.field-datepicker.php:
|
231 |
msgid "Min Date"
|
232 |
msgstr "最小日付"
|
233 |
|
@@ -240,7 +242,7 @@ msgstr "ファイル"
|
|
240 |
msgid "Delete"
|
241 |
msgstr "削除"
|
242 |
|
243 |
-
#: classes/fields/class.field-file.php:
|
244 |
msgid "File Select"
|
245 |
msgstr "ファイル選択"
|
246 |
|
@@ -252,42 +254,48 @@ msgstr "画像"
|
|
252 |
msgid "Image Select"
|
253 |
msgstr "画像選択"
|
254 |
|
255 |
-
#: classes/fields/class.field-image.php:
|
256 |
msgid "Preview Size"
|
257 |
msgstr "プレビューサイズ"
|
258 |
|
|
|
|
|
|
|
|
|
|
|
259 |
#: classes/fields/class.field-radio.php:21
|
260 |
msgid "Radio"
|
261 |
msgstr "ラジオボタン"
|
262 |
|
263 |
-
#: classes/fields/class.field-
|
264 |
msgid "Related Posts"
|
265 |
msgstr "関連する投稿"
|
266 |
|
267 |
-
#: classes/fields/class.field-
|
268 |
-
#: classes/fields/class.field-
|
269 |
msgid "Search..."
|
270 |
msgstr "検索 …"
|
271 |
|
272 |
-
#: classes/fields/class.field-
|
273 |
-
#: classes/fields/class.field-
|
274 |
msgid "Load more"
|
275 |
msgstr "さらに読み込む"
|
276 |
|
277 |
-
#: classes/fields/class.field-
|
278 |
-
#: classes/fields/class.field-
|
279 |
msgid "Selectable number"
|
280 |
msgstr "選択できる個数"
|
281 |
|
|
|
|
|
|
|
|
|
282 |
#: classes/fields/class.field-select.php:21
|
283 |
msgid "Select"
|
284 |
msgstr "セレクトボックス"
|
285 |
|
286 |
-
#: classes/fields/class.field-taxonomy.php:24
|
287 |
-
msgid "Related Terms"
|
288 |
-
msgstr "関連するターム"
|
289 |
-
|
290 |
#: classes/fields/class.field-text.php:21
|
|
|
291 |
msgid "Text"
|
292 |
msgstr "テキスト"
|
293 |
|
@@ -295,7 +303,7 @@ msgstr "テキスト"
|
|
295 |
msgid "Textarea"
|
296 |
msgstr "テキストエリア"
|
297 |
|
298 |
-
#: classes/fields/class.field-textarea.php:
|
299 |
msgid "Rows"
|
300 |
msgstr "行数"
|
301 |
|
@@ -307,16 +315,16 @@ msgstr "WYSIWYG"
|
|
307 |
msgid "Visual"
|
308 |
msgstr "ビジュアル"
|
309 |
|
310 |
-
#: classes/fields/class.field-wysiwyg.php:
|
311 |
-
#: classes/fields/class.field-wysiwyg.php:
|
312 |
msgid "Add Media"
|
313 |
msgstr "メディアを追加"
|
314 |
|
315 |
-
#: classes/models/class.abstract-field-base.php:
|
316 |
msgid "Name"
|
317 |
msgstr "名前"
|
318 |
|
319 |
-
#: classes/models/class.abstract-field-base.php:
|
320 |
msgid "Label"
|
321 |
msgstr "ラベル"
|
322 |
|
@@ -328,58 +336,44 @@ msgstr "繰り返し"
|
|
328 |
msgid "Group name"
|
329 |
msgstr "グループ名"
|
330 |
|
331 |
-
#:
|
332 |
-
#: smart-custom-fields.php:
|
|
|
|
|
|
|
|
|
|
|
333 |
msgid "Add New"
|
334 |
msgstr "新規追加"
|
335 |
|
336 |
-
#: smart-custom-fields.php:
|
337 |
msgid "New Field"
|
338 |
msgstr "新規フィールド"
|
339 |
|
340 |
-
#: smart-custom-fields.php:
|
341 |
msgid "Edit Field"
|
342 |
msgstr "フィールド編集"
|
343 |
|
344 |
-
#: smart-custom-fields.php:
|
345 |
msgid "View Field"
|
346 |
msgstr "フィールドを表示"
|
347 |
|
348 |
-
#: smart-custom-fields.php:
|
349 |
msgid "All Fields"
|
350 |
msgstr "すべてのフィールド"
|
351 |
|
352 |
-
#: smart-custom-fields.php:
|
353 |
msgid "Search Fields"
|
354 |
msgstr "フィールドを検索"
|
355 |
|
356 |
-
#: smart-custom-fields.php:
|
357 |
msgid "Parent Fields:"
|
358 |
msgstr "親フィールド:"
|
359 |
|
360 |
-
#: smart-custom-fields.php:
|
361 |
msgid "No Fields found."
|
362 |
msgstr "フィールドは見つかりませんでした。"
|
363 |
|
364 |
-
#: smart-custom-fields.php:
|
365 |
msgid "No Fields found in Trash."
|
366 |
-
msgstr "
|
367 |
-
|
368 |
-
msgid "Smart Custom Fields"
|
369 |
-
msgstr "Smart Custom Fields"
|
370 |
-
|
371 |
-
#. Plugin URI of the plugin/theme
|
372 |
-
msgid "https://github.com/inc2734/smart-custom-fields/"
|
373 |
-
msgstr ""
|
374 |
-
|
375 |
-
#. Description of the plugin/theme
|
376 |
-
msgid "Smart Custom Fields is a simple plugin that management custom fields."
|
377 |
-
msgstr ""
|
378 |
-
|
379 |
-
#. Author of the plugin/theme
|
380 |
-
msgid "inc2734"
|
381 |
-
msgstr ""
|
382 |
-
|
383 |
-
#. Author URI of the plugin/theme
|
384 |
-
msgid "http://2inc.org"
|
385 |
-
msgstr ""
|
2 |
# This file is distributed under the same license as the Smart Custom Fields package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Smart Custom Fields 3.1.7\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smart-custom-"
|
7 |
"fields\n"
|
8 |
+
"POT-Creation-Date: 2018-06-26 09:22+0900\n"
|
9 |
+
"PO-Revision-Date: 2018-06-26 09:22+0900\n"
|
10 |
+
"Last-Translator: inc2734 <inc@2inc.org>\n"
|
11 |
"Language-Team: Japanese\n"
|
12 |
"Language: ja\n"
|
13 |
"MIME-Version: 1.0\n"
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
17 |
+
"X-Generator: Poedit 2.0.4\n"
|
18 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
19 |
"X-Poedit-KeywordsList: __;_e;esc_html__;esc_html_e;esc_attr__;esc_attr_e\n"
|
20 |
"X-Poedit-Basepath: ..\n"
|
21 |
+
"X-Poedit-SearchPath-0: .\n"
|
22 |
|
23 |
#: classes/controller/class.controller-base.php:46
|
24 |
msgid "Image setting"
|
33 |
msgstr "設定を保存"
|
34 |
|
35 |
#: classes/controller/class.profile.php:43
|
36 |
+
#: classes/controller/class.settings.php:82
|
37 |
msgid "Custom Fields"
|
38 |
msgstr "カスタムフィールド"
|
39 |
|
53 |
msgid "Other fields"
|
54 |
msgstr "その他のフィールド"
|
55 |
|
56 |
+
#: classes/controller/class.settings.php:69
|
57 |
msgid "Same name exists!"
|
58 |
msgstr "同じ名前が存在します!"
|
59 |
|
60 |
+
#: classes/controller/class.settings.php:88
|
61 |
msgid "Display conditions ( Post )"
|
62 |
msgstr "表示条件(投稿)"
|
63 |
|
64 |
+
#: classes/controller/class.settings.php:95
|
65 |
msgid "Display conditions ( Profile )"
|
66 |
msgstr "表示条件(プロフィール)"
|
67 |
|
68 |
+
#: classes/controller/class.settings.php:102
|
69 |
msgid "Display conditions ( Taxonomy )"
|
70 |
msgstr "表示条件(タクソノミー)"
|
71 |
|
72 |
+
#: classes/controller/class.settings.php:109
|
73 |
msgid "Display conditions ( Options page )"
|
74 |
msgstr "表示条件(オプションページ)"
|
75 |
|
76 |
+
#: classes/controller/class.settings.php:169
|
77 |
msgid "Type"
|
78 |
msgstr "タイプ"
|
79 |
|
80 |
+
#: classes/controller/class.settings.php:204
|
81 |
msgid "Add Sub field"
|
82 |
msgstr "サブフィールドを追加"
|
83 |
|
84 |
+
#: classes/controller/class.settings.php:208
|
85 |
msgid "Add Field"
|
86 |
msgstr "フィールド追加"
|
87 |
|
88 |
+
#: classes/controller/class.settings.php:238
|
89 |
+
#: classes/fields/class.field-related-posts.php:235
|
90 |
msgid "Post Types"
|
91 |
msgstr "投稿タイプ"
|
92 |
|
93 |
+
#: classes/controller/class.settings.php:245
|
94 |
msgid "Post Ids ( Comma separated )"
|
95 |
msgstr "投稿 ID (カンマ区切り)"
|
96 |
|
97 |
+
#: classes/controller/class.settings.php:270
|
98 |
msgid "Roles"
|
99 |
msgstr "権限"
|
100 |
|
101 |
+
#: classes/controller/class.settings.php:296
|
102 |
+
#: classes/fields/class.field-related-terms.php:233
|
103 |
msgid "Taxonomies"
|
104 |
msgstr "タクソノミー"
|
105 |
|
106 |
+
#: classes/controller/class.settings.php:320
|
107 |
msgid "Options pages"
|
108 |
msgstr "オプションページ"
|
109 |
|
119 |
msgid "No"
|
120 |
msgstr "いいえ"
|
121 |
|
122 |
+
#: classes/fields/class.field-boolean.php:85
|
123 |
+
#: classes/fields/class.field-check.php:119
|
124 |
+
#: classes/fields/class.field-colorpicker.php:107
|
125 |
+
#: classes/fields/class.field-datepicker.php:130
|
126 |
+
#: classes/fields/class.field-radio.php:118
|
127 |
+
#: classes/fields/class.field-select.php:93
|
128 |
+
#: classes/fields/class.field-text.php:68
|
129 |
+
#: classes/fields/class.field-textarea.php:81
|
130 |
+
#: classes/fields/class.field-wysiwyg.php:124
|
131 |
msgid "Default"
|
132 |
msgstr "デフォルト"
|
133 |
|
134 |
+
#: classes/fields/class.field-boolean.php:110
|
135 |
msgid "TRUE Label"
|
136 |
msgstr "TRUE ラベル"
|
137 |
|
138 |
+
#: classes/fields/class.field-boolean.php:120
|
139 |
msgid "FALSE Label"
|
140 |
msgstr "FALSE ラベル"
|
141 |
|
142 |
+
#: classes/fields/class.field-boolean.php:130
|
143 |
+
#: classes/fields/class.field-check.php:128
|
144 |
+
#: classes/fields/class.field-colorpicker.php:116
|
145 |
+
#: classes/fields/class.field-datepicker.php:194
|
146 |
+
#: classes/fields/class.field-file.php:119
|
147 |
+
#: classes/fields/class.field-image.php:114
|
148 |
+
#: classes/fields/class.field-radio.php:127
|
149 |
+
#: classes/fields/class.field-related-posts.php:264
|
150 |
+
#: classes/fields/class.field-related-terms.php:260
|
151 |
+
#: classes/fields/class.field-select.php:102
|
152 |
+
#: classes/fields/class.field-text.php:77
|
153 |
+
#: classes/fields/class.field-textarea.php:90
|
154 |
+
#: classes/fields/class.field-wysiwyg.php:133
|
155 |
msgid "Instruction"
|
156 |
msgstr "説明文"
|
157 |
|
158 |
+
#: classes/fields/class.field-boolean.php:137
|
159 |
+
#: classes/fields/class.field-check.php:135
|
160 |
+
#: classes/fields/class.field-colorpicker.php:123
|
161 |
+
#: classes/fields/class.field-datepicker.php:201
|
162 |
+
#: classes/fields/class.field-file.php:126
|
163 |
+
#: classes/fields/class.field-image.php:121
|
164 |
+
#: classes/fields/class.field-message.php:77
|
165 |
+
#: classes/fields/class.field-radio.php:134
|
166 |
+
#: classes/fields/class.field-related-posts.php:271
|
167 |
+
#: classes/fields/class.field-related-terms.php:267
|
168 |
+
#: classes/fields/class.field-select.php:109
|
169 |
+
#: classes/fields/class.field-text.php:84
|
170 |
+
#: classes/fields/class.field-textarea.php:97
|
171 |
+
#: classes/fields/class.field-wysiwyg.php:140
|
172 |
msgid "Notes"
|
173 |
msgstr "注記"
|
174 |
|
176 |
msgid "Check"
|
177 |
msgstr "チェックボックス"
|
178 |
|
179 |
+
#: classes/fields/class.field-check.php:89
|
180 |
+
#: classes/fields/class.field-radio.php:88
|
181 |
+
#: classes/fields/class.field-select.php:83
|
182 |
msgid "Choices"
|
183 |
msgstr "選択肢"
|
184 |
|
185 |
+
#: classes/fields/class.field-check.php:95
|
186 |
+
#: classes/fields/class.field-radio.php:94
|
187 |
+
#: classes/fields/class.field-select.php:89
|
188 |
msgid ""
|
189 |
"If you want to separate the key and the value, enter as follows: key => value"
|
190 |
msgstr "もしキーと値を分けたい場合は次のように入力してください: キー => 値"
|
191 |
|
192 |
+
#: classes/fields/class.field-check.php:99
|
193 |
+
#: classes/fields/class.field-radio.php:98
|
194 |
msgid "Display Direction"
|
195 |
msgstr "表示方向"
|
196 |
|
197 |
+
#: classes/fields/class.field-check.php:103
|
198 |
+
#: classes/fields/class.field-radio.php:102
|
199 |
msgid "horizontal"
|
200 |
msgstr "水平方向"
|
201 |
|
202 |
+
#: classes/fields/class.field-check.php:104
|
203 |
+
#: classes/fields/class.field-radio.php:103
|
204 |
msgid "vertical"
|
205 |
msgstr "垂直方向"
|
206 |
|
212 |
msgid "Date picker"
|
213 |
msgstr "日付ピッカー"
|
214 |
|
215 |
+
#: classes/fields/class.field-datepicker.php:140
|
216 |
msgid "Date Format"
|
217 |
msgstr "日付のフォーマット"
|
218 |
|
219 |
+
#: classes/fields/class.field-datepicker.php:148
|
220 |
msgid "e.g dd/mm/yy"
|
221 |
msgstr "例: dd/mm/yy"
|
222 |
|
223 |
+
#: classes/fields/class.field-datepicker.php:158
|
224 |
msgid "Max Date"
|
225 |
msgstr "最大日付"
|
226 |
|
227 |
+
#: classes/fields/class.field-datepicker.php:166
|
228 |
+
#: classes/fields/class.field-datepicker.php:184
|
229 |
msgid "e.g +1m +1w"
|
230 |
msgstr "例: +1m +1w"
|
231 |
|
232 |
+
#: classes/fields/class.field-datepicker.php:176
|
233 |
msgid "Min Date"
|
234 |
msgstr "最小日付"
|
235 |
|
242 |
msgid "Delete"
|
243 |
msgstr "削除"
|
244 |
|
245 |
+
#: classes/fields/class.field-file.php:98
|
246 |
msgid "File Select"
|
247 |
msgstr "ファイル選択"
|
248 |
|
254 |
msgid "Image Select"
|
255 |
msgstr "画像選択"
|
256 |
|
257 |
+
#: classes/fields/class.field-image.php:131
|
258 |
msgid "Preview Size"
|
259 |
msgstr "プレビューサイズ"
|
260 |
|
261 |
+
#: classes/fields/class.field-message.php:21
|
262 |
+
#: classes/fields/class.field-message.php:68
|
263 |
+
msgid "Message"
|
264 |
+
msgstr "メッセージ"
|
265 |
+
|
266 |
#: classes/fields/class.field-radio.php:21
|
267 |
msgid "Radio"
|
268 |
msgstr "ラジオボタン"
|
269 |
|
270 |
+
#: classes/fields/class.field-related-posts.php:24
|
271 |
msgid "Related Posts"
|
272 |
msgstr "関連する投稿"
|
273 |
|
274 |
+
#: classes/fields/class.field-related-posts.php:211
|
275 |
+
#: classes/fields/class.field-related-terms.php:209
|
276 |
msgid "Search..."
|
277 |
msgstr "検索 …"
|
278 |
|
279 |
+
#: classes/fields/class.field-related-posts.php:215
|
280 |
+
#: classes/fields/class.field-related-terms.php:213
|
281 |
msgid "Load more"
|
282 |
msgstr "さらに読み込む"
|
283 |
|
284 |
+
#: classes/fields/class.field-related-posts.php:256
|
285 |
+
#: classes/fields/class.field-related-terms.php:252
|
286 |
msgid "Selectable number"
|
287 |
msgstr "選択できる個数"
|
288 |
|
289 |
+
#: classes/fields/class.field-related-terms.php:24
|
290 |
+
msgid "Related Terms"
|
291 |
+
msgstr "関連するターム"
|
292 |
+
|
293 |
#: classes/fields/class.field-select.php:21
|
294 |
msgid "Select"
|
295 |
msgstr "セレクトボックス"
|
296 |
|
|
|
|
|
|
|
|
|
297 |
#: classes/fields/class.field-text.php:21
|
298 |
+
#: classes/fields/class.field-wysiwyg.php:108
|
299 |
msgid "Text"
|
300 |
msgstr "テキスト"
|
301 |
|
303 |
msgid "Textarea"
|
304 |
msgstr "テキストエリア"
|
305 |
|
306 |
+
#: classes/fields/class.field-textarea.php:71
|
307 |
msgid "Rows"
|
308 |
msgstr "行数"
|
309 |
|
315 |
msgid "Visual"
|
316 |
msgstr "ビジュアル"
|
317 |
|
318 |
+
#: classes/fields/class.field-wysiwyg.php:162
|
319 |
+
#: classes/fields/class.field-wysiwyg.php:163
|
320 |
msgid "Add Media"
|
321 |
msgstr "メディアを追加"
|
322 |
|
323 |
+
#: classes/models/class.abstract-field-base.php:118
|
324 |
msgid "Name"
|
325 |
msgstr "名前"
|
326 |
|
327 |
+
#: classes/models/class.abstract-field-base.php:134
|
328 |
msgid "Label"
|
329 |
msgstr "ラベル"
|
330 |
|
336 |
msgid "Group name"
|
337 |
msgstr "グループ名"
|
338 |
|
339 |
+
#: classes/models/class.revisions.php:128 smart-custom-fields.php:168
|
340 |
+
#: smart-custom-fields.php:169 smart-custom-fields.php:170
|
341 |
+
msgid "Smart Custom Fields"
|
342 |
+
msgstr "Smart Custom Fields"
|
343 |
+
|
344 |
+
#: smart-custom-fields.php:171 smart-custom-fields.php:172
|
345 |
+
#: smart-custom-fields.php:218 smart-custom-fields.php:219
|
346 |
msgid "Add New"
|
347 |
msgstr "新規追加"
|
348 |
|
349 |
+
#: smart-custom-fields.php:173
|
350 |
msgid "New Field"
|
351 |
msgstr "新規フィールド"
|
352 |
|
353 |
+
#: smart-custom-fields.php:174
|
354 |
msgid "Edit Field"
|
355 |
msgstr "フィールド編集"
|
356 |
|
357 |
+
#: smart-custom-fields.php:175
|
358 |
msgid "View Field"
|
359 |
msgstr "フィールドを表示"
|
360 |
|
361 |
+
#: smart-custom-fields.php:176
|
362 |
msgid "All Fields"
|
363 |
msgstr "すべてのフィールド"
|
364 |
|
365 |
+
#: smart-custom-fields.php:177
|
366 |
msgid "Search Fields"
|
367 |
msgstr "フィールドを検索"
|
368 |
|
369 |
+
#: smart-custom-fields.php:178
|
370 |
msgid "Parent Fields:"
|
371 |
msgstr "親フィールド:"
|
372 |
|
373 |
+
#: smart-custom-fields.php:179
|
374 |
msgid "No Fields found."
|
375 |
msgstr "フィールドは見つかりませんでした。"
|
376 |
|
377 |
+
#: smart-custom-fields.php:180
|
378 |
msgid "No Fields found in Trash."
|
379 |
+
msgstr "ゴミ箱にフィールドは見つかりませんでした。"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/smart-custom-fields-pt_BR.mo
CHANGED
Binary file
|
languages/smart-custom-fields-pt_BR.po
CHANGED
@@ -2,19 +2,23 @@
|
|
2 |
# This file is distributed under the same license as the Smart Custom Fields package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Smart Custom Fields 3.1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smart-custom-"
|
7 |
"fields\n"
|
8 |
-
"POT-Creation-Date:
|
|
|
|
|
|
|
|
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"PO-Revision-Date: 2018-05-29 19:42-0300\n"
|
13 |
-
"Last-Translator: robssanches <robssanches@hotmail.com>\n"
|
14 |
-
"Language-Team: Português do Brasil \n"
|
15 |
-
"Language: pt_BR\n"
|
16 |
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
17 |
"X-Generator: Poedit 2.0.7\n"
|
|
|
|
|
|
|
|
|
18 |
|
19 |
#: classes/controller/class.controller-base.php:46
|
20 |
msgid "Image setting"
|
@@ -82,7 +86,7 @@ msgid "Add Field"
|
|
82 |
msgstr "Adicionar Campo"
|
83 |
|
84 |
#: classes/controller/class.settings.php:232
|
85 |
-
#: classes/fields/class.field-
|
86 |
msgid "Post Types"
|
87 |
msgstr "Tipos de Post"
|
88 |
|
@@ -95,7 +99,7 @@ msgid "Roles"
|
|
95 |
msgstr "Funções"
|
96 |
|
97 |
#: classes/controller/class.settings.php:290
|
98 |
-
#: classes/fields/class.field-
|
99 |
msgid "Taxonomies"
|
100 |
msgstr "Taxonomias"
|
101 |
|
@@ -119,15 +123,14 @@ msgstr "Não"
|
|
119 |
#: classes/fields/class.field-check.php:117
|
120 |
#: classes/fields/class.field-colorpicker.php:103
|
121 |
#: classes/fields/class.field-datepicker.php:125
|
|
|
122 |
#: classes/fields/class.field-radio.php:116
|
123 |
#: classes/fields/class.field-select.php:91
|
124 |
#: classes/fields/class.field-text.php:66
|
125 |
#: classes/fields/class.field-textarea.php:79
|
126 |
-
#: classes/fields/class.field-wysiwyg.php:
|
127 |
msgid "Default"
|
128 |
-
msgstr ""
|
129 |
-
"7/5000\n"
|
130 |
-
"Padrão"
|
131 |
|
132 |
#: classes/fields/class.field-boolean.php:107
|
133 |
msgid "TRUE Label"
|
@@ -141,15 +144,15 @@ msgstr "Rótulo FALSO"
|
|
141 |
#: classes/fields/class.field-check.php:126
|
142 |
#: classes/fields/class.field-colorpicker.php:112
|
143 |
#: classes/fields/class.field-datepicker.php:189
|
144 |
-
#: classes/fields/class.field-file.php:
|
145 |
#: classes/fields/class.field-image.php:112
|
146 |
#: classes/fields/class.field-radio.php:125
|
147 |
-
#: classes/fields/class.field-
|
|
|
148 |
#: classes/fields/class.field-select.php:100
|
149 |
-
#: classes/fields/class.field-taxonomy.php:255
|
150 |
#: classes/fields/class.field-text.php:75
|
151 |
#: classes/fields/class.field-textarea.php:88
|
152 |
-
#: classes/fields/class.field-wysiwyg.php:
|
153 |
msgid "Instruction"
|
154 |
msgstr "Instrução"
|
155 |
|
@@ -157,15 +160,16 @@ msgstr "Instrução"
|
|
157 |
#: classes/fields/class.field-check.php:133
|
158 |
#: classes/fields/class.field-colorpicker.php:119
|
159 |
#: classes/fields/class.field-datepicker.php:196
|
160 |
-
#: classes/fields/class.field-file.php:
|
161 |
#: classes/fields/class.field-image.php:119
|
|
|
162 |
#: classes/fields/class.field-radio.php:132
|
163 |
-
#: classes/fields/class.field-
|
|
|
164 |
#: classes/fields/class.field-select.php:107
|
165 |
-
#: classes/fields/class.field-taxonomy.php:262
|
166 |
#: classes/fields/class.field-text.php:82
|
167 |
#: classes/fields/class.field-textarea.php:95
|
168 |
-
#: classes/fields/class.field-wysiwyg.php:
|
169 |
msgid "Notes"
|
170 |
msgstr "Notas"
|
171 |
|
@@ -241,7 +245,7 @@ msgstr "Arquivo"
|
|
241 |
msgid "Delete"
|
242 |
msgstr "Excluir"
|
243 |
|
244 |
-
#: classes/fields/class.field-file.php:
|
245 |
msgid "File Select"
|
246 |
msgstr "Seleção de Arquivo"
|
247 |
|
@@ -257,38 +261,43 @@ msgstr "Selecionar imagem"
|
|
257 |
msgid "Preview Size"
|
258 |
msgstr "Tamanho da pré-visualização"
|
259 |
|
|
|
|
|
|
|
|
|
260 |
#: classes/fields/class.field-radio.php:21
|
261 |
msgid "Radio"
|
262 |
msgstr "Radio"
|
263 |
|
264 |
-
#: classes/fields/class.field-
|
265 |
msgid "Related Posts"
|
266 |
msgstr "Posts Relacionados"
|
267 |
|
268 |
-
#: classes/fields/class.field-
|
269 |
-
#: classes/fields/class.field-
|
270 |
msgid "Search..."
|
271 |
msgstr "Pesquisa..."
|
272 |
|
273 |
-
#: classes/fields/class.field-
|
274 |
-
#: classes/fields/class.field-
|
275 |
msgid "Load more"
|
276 |
msgstr "Carregar mais"
|
277 |
|
278 |
-
#: classes/fields/class.field-
|
279 |
-
#: classes/fields/class.field-
|
280 |
msgid "Selectable number"
|
281 |
msgstr "Número selecionável"
|
282 |
|
|
|
|
|
|
|
|
|
283 |
#: classes/fields/class.field-select.php:21
|
284 |
msgid "Select"
|
285 |
msgstr "Seleção"
|
286 |
|
287 |
-
#: classes/fields/class.field-taxonomy.php:24
|
288 |
-
msgid "Related Terms"
|
289 |
-
msgstr "Termos relacionados"
|
290 |
-
|
291 |
#: classes/fields/class.field-text.php:21
|
|
|
292 |
msgid "Text"
|
293 |
msgstr "Texto"
|
294 |
|
@@ -308,16 +317,16 @@ msgstr "Wysiwyg"
|
|
308 |
msgid "Visual"
|
309 |
msgstr "Visual"
|
310 |
|
311 |
-
#: classes/fields/class.field-wysiwyg.php:
|
312 |
-
#: classes/fields/class.field-wysiwyg.php:
|
313 |
msgid "Add Media"
|
314 |
msgstr "Adicionar Mídia"
|
315 |
|
316 |
-
#: classes/models/class.abstract-field-base.php:
|
317 |
msgid "Name"
|
318 |
msgstr "Nome"
|
319 |
|
320 |
-
#: classes/models/class.abstract-field-base.php:
|
321 |
msgid "Label"
|
322 |
msgstr "Rótulo"
|
323 |
|
@@ -329,60 +338,50 @@ msgstr "Repetir"
|
|
329 |
msgid "Group name"
|
330 |
msgstr "Nome do grupo"
|
331 |
|
332 |
-
#:
|
333 |
-
#: smart-custom-fields.php:
|
|
|
|
|
|
|
|
|
|
|
334 |
msgid "Add New"
|
335 |
msgstr "Adicionar Novo"
|
336 |
|
337 |
-
#: smart-custom-fields.php:
|
338 |
msgid "New Field"
|
339 |
msgstr "Novo Campo"
|
340 |
|
341 |
-
#: smart-custom-fields.php:
|
342 |
msgid "Edit Field"
|
343 |
msgstr "Editar campo"
|
344 |
|
345 |
-
#: smart-custom-fields.php:
|
346 |
msgid "View Field"
|
347 |
msgstr "Visualizar campo"
|
348 |
|
349 |
-
#: smart-custom-fields.php:
|
350 |
msgid "All Fields"
|
351 |
msgstr "Todos os Campos"
|
352 |
|
353 |
-
#: smart-custom-fields.php:
|
354 |
msgid "Search Fields"
|
355 |
msgstr "Campos de Pesquisa"
|
356 |
|
357 |
-
#: smart-custom-fields.php:
|
358 |
msgid "Parent Fields:"
|
359 |
msgstr "Campos pai:"
|
360 |
|
361 |
-
#: smart-custom-fields.php:
|
362 |
msgid "No Fields found."
|
363 |
msgstr "Nenhum campo encontrado."
|
364 |
|
365 |
-
#: smart-custom-fields.php:
|
366 |
msgid "No Fields found in Trash."
|
367 |
msgstr "Nenhum campo encontrado na lixeira."
|
368 |
|
369 |
-
|
370 |
-
|
371 |
-
msgstr "
|
372 |
-
|
373 |
-
|
374 |
-
msgid "https://github.com/inc2734/smart-custom-fields/"
|
375 |
-
msgstr ""
|
376 |
-
|
377 |
-
#. Description of the plugin/theme
|
378 |
-
msgid "Smart Custom Fields is a simple plugin that management custom fields."
|
379 |
-
msgstr ""
|
380 |
-
"Smart Custom Fields é um plugin simples que gerencia campos personalizados."
|
381 |
-
|
382 |
-
#. Author of the plugin/theme
|
383 |
-
msgid "inc2734"
|
384 |
-
msgstr ""
|
385 |
-
|
386 |
-
#. Author URI of the plugin/theme
|
387 |
-
msgid "http://2inc.org"
|
388 |
-
msgstr ""
|
2 |
# This file is distributed under the same license as the Smart Custom Fields package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Smart Custom Fields 3.1.7\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smart-custom-"
|
7 |
"fields\n"
|
8 |
+
"POT-Creation-Date: 2018-06-02 21:30-0300\n"
|
9 |
+
"PO-Revision-Date: 2018-06-02 21:30-0300\n"
|
10 |
+
"Last-Translator: robssanches <robssanches@hotmail.com>\n"
|
11 |
+
"Language-Team: Português do Brasil\n"
|
12 |
+
"Language: pt_BR\n"
|
13 |
"MIME-Version: 1.0\n"
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
|
|
|
|
|
|
|
|
16 |
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
17 |
"X-Generator: Poedit 2.0.7\n"
|
18 |
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
19 |
+
"X-Poedit-KeywordsList: __;_e;esc_html__;esc_html_e;esc_attr__;esc_attr_e\n"
|
20 |
+
"X-Poedit-Basepath: ..\n"
|
21 |
+
"X-Poedit-SearchPath-0: .\n"
|
22 |
|
23 |
#: classes/controller/class.controller-base.php:46
|
24 |
msgid "Image setting"
|
86 |
msgstr "Adicionar Campo"
|
87 |
|
88 |
#: classes/controller/class.settings.php:232
|
89 |
+
#: classes/fields/class.field-related-posts.php:231
|
90 |
msgid "Post Types"
|
91 |
msgstr "Tipos de Post"
|
92 |
|
99 |
msgstr "Funções"
|
100 |
|
101 |
#: classes/controller/class.settings.php:290
|
102 |
+
#: classes/fields/class.field-related-terms.php:229
|
103 |
msgid "Taxonomies"
|
104 |
msgstr "Taxonomias"
|
105 |
|
123 |
#: classes/fields/class.field-check.php:117
|
124 |
#: classes/fields/class.field-colorpicker.php:103
|
125 |
#: classes/fields/class.field-datepicker.php:125
|
126 |
+
#: classes/fields/class.field-message.php:67
|
127 |
#: classes/fields/class.field-radio.php:116
|
128 |
#: classes/fields/class.field-select.php:91
|
129 |
#: classes/fields/class.field-text.php:66
|
130 |
#: classes/fields/class.field-textarea.php:79
|
131 |
+
#: classes/fields/class.field-wysiwyg.php:122
|
132 |
msgid "Default"
|
133 |
+
msgstr "Padrão"
|
|
|
|
|
134 |
|
135 |
#: classes/fields/class.field-boolean.php:107
|
136 |
msgid "TRUE Label"
|
144 |
#: classes/fields/class.field-check.php:126
|
145 |
#: classes/fields/class.field-colorpicker.php:112
|
146 |
#: classes/fields/class.field-datepicker.php:189
|
147 |
+
#: classes/fields/class.field-file.php:117
|
148 |
#: classes/fields/class.field-image.php:112
|
149 |
#: classes/fields/class.field-radio.php:125
|
150 |
+
#: classes/fields/class.field-related-posts.php:260
|
151 |
+
#: classes/fields/class.field-related-terms.php:256
|
152 |
#: classes/fields/class.field-select.php:100
|
|
|
153 |
#: classes/fields/class.field-text.php:75
|
154 |
#: classes/fields/class.field-textarea.php:88
|
155 |
+
#: classes/fields/class.field-wysiwyg.php:131
|
156 |
msgid "Instruction"
|
157 |
msgstr "Instrução"
|
158 |
|
160 |
#: classes/fields/class.field-check.php:133
|
161 |
#: classes/fields/class.field-colorpicker.php:119
|
162 |
#: classes/fields/class.field-datepicker.php:196
|
163 |
+
#: classes/fields/class.field-file.php:124
|
164 |
#: classes/fields/class.field-image.php:119
|
165 |
+
#: classes/fields/class.field-message.php:76
|
166 |
#: classes/fields/class.field-radio.php:132
|
167 |
+
#: classes/fields/class.field-related-posts.php:267
|
168 |
+
#: classes/fields/class.field-related-terms.php:263
|
169 |
#: classes/fields/class.field-select.php:107
|
|
|
170 |
#: classes/fields/class.field-text.php:82
|
171 |
#: classes/fields/class.field-textarea.php:95
|
172 |
+
#: classes/fields/class.field-wysiwyg.php:138
|
173 |
msgid "Notes"
|
174 |
msgstr "Notas"
|
175 |
|
245 |
msgid "Delete"
|
246 |
msgstr "Excluir"
|
247 |
|
248 |
+
#: classes/fields/class.field-file.php:98
|
249 |
msgid "File Select"
|
250 |
msgstr "Seleção de Arquivo"
|
251 |
|
261 |
msgid "Preview Size"
|
262 |
msgstr "Tamanho da pré-visualização"
|
263 |
|
264 |
+
#: classes/fields/class.field-message.php:21
|
265 |
+
msgid "Message"
|
266 |
+
msgstr "Mensagem"
|
267 |
+
|
268 |
#: classes/fields/class.field-radio.php:21
|
269 |
msgid "Radio"
|
270 |
msgstr "Radio"
|
271 |
|
272 |
+
#: classes/fields/class.field-related-posts.php:24
|
273 |
msgid "Related Posts"
|
274 |
msgstr "Posts Relacionados"
|
275 |
|
276 |
+
#: classes/fields/class.field-related-posts.php:209
|
277 |
+
#: classes/fields/class.field-related-terms.php:207
|
278 |
msgid "Search..."
|
279 |
msgstr "Pesquisa..."
|
280 |
|
281 |
+
#: classes/fields/class.field-related-posts.php:213
|
282 |
+
#: classes/fields/class.field-related-terms.php:211
|
283 |
msgid "Load more"
|
284 |
msgstr "Carregar mais"
|
285 |
|
286 |
+
#: classes/fields/class.field-related-posts.php:252
|
287 |
+
#: classes/fields/class.field-related-terms.php:248
|
288 |
msgid "Selectable number"
|
289 |
msgstr "Número selecionável"
|
290 |
|
291 |
+
#: classes/fields/class.field-related-terms.php:24
|
292 |
+
msgid "Related Terms"
|
293 |
+
msgstr "Termos relacionados"
|
294 |
+
|
295 |
#: classes/fields/class.field-select.php:21
|
296 |
msgid "Select"
|
297 |
msgstr "Seleção"
|
298 |
|
|
|
|
|
|
|
|
|
299 |
#: classes/fields/class.field-text.php:21
|
300 |
+
#: classes/fields/class.field-wysiwyg.php:108
|
301 |
msgid "Text"
|
302 |
msgstr "Texto"
|
303 |
|
317 |
msgid "Visual"
|
318 |
msgstr "Visual"
|
319 |
|
320 |
+
#: classes/fields/class.field-wysiwyg.php:160
|
321 |
+
#: classes/fields/class.field-wysiwyg.php:161
|
322 |
msgid "Add Media"
|
323 |
msgstr "Adicionar Mídia"
|
324 |
|
325 |
+
#: classes/models/class.abstract-field-base.php:106
|
326 |
msgid "Name"
|
327 |
msgstr "Nome"
|
328 |
|
329 |
+
#: classes/models/class.abstract-field-base.php:117
|
330 |
msgid "Label"
|
331 |
msgstr "Rótulo"
|
332 |
|
338 |
msgid "Group name"
|
339 |
msgstr "Nome do grupo"
|
340 |
|
341 |
+
#: classes/models/class.revisions.php:128 smart-custom-fields.php:168
|
342 |
+
#: smart-custom-fields.php:169 smart-custom-fields.php:170
|
343 |
+
msgid "Smart Custom Fields"
|
344 |
+
msgstr "Smart Custom Fields"
|
345 |
+
|
346 |
+
#: smart-custom-fields.php:171 smart-custom-fields.php:172
|
347 |
+
#: smart-custom-fields.php:218 smart-custom-fields.php:219
|
348 |
msgid "Add New"
|
349 |
msgstr "Adicionar Novo"
|
350 |
|
351 |
+
#: smart-custom-fields.php:173
|
352 |
msgid "New Field"
|
353 |
msgstr "Novo Campo"
|
354 |
|
355 |
+
#: smart-custom-fields.php:174
|
356 |
msgid "Edit Field"
|
357 |
msgstr "Editar campo"
|
358 |
|
359 |
+
#: smart-custom-fields.php:175
|
360 |
msgid "View Field"
|
361 |
msgstr "Visualizar campo"
|
362 |
|
363 |
+
#: smart-custom-fields.php:176
|
364 |
msgid "All Fields"
|
365 |
msgstr "Todos os Campos"
|
366 |
|
367 |
+
#: smart-custom-fields.php:177
|
368 |
msgid "Search Fields"
|
369 |
msgstr "Campos de Pesquisa"
|
370 |
|
371 |
+
#: smart-custom-fields.php:178
|
372 |
msgid "Parent Fields:"
|
373 |
msgstr "Campos pai:"
|
374 |
|
375 |
+
#: smart-custom-fields.php:179
|
376 |
msgid "No Fields found."
|
377 |
msgstr "Nenhum campo encontrado."
|
378 |
|
379 |
+
#: smart-custom-fields.php:180
|
380 |
msgid "No Fields found in Trash."
|
381 |
msgstr "Nenhum campo encontrado na lixeira."
|
382 |
|
383 |
+
#~ msgid ""
|
384 |
+
#~ "Smart Custom Fields is a simple plugin that management custom fields."
|
385 |
+
#~ msgstr ""
|
386 |
+
#~ "Smart Custom Fields é um plugin simples que gerencia campos "
|
387 |
+
#~ "personalizados."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/smart-custom-fields.pot
CHANGED
@@ -1,17 +1,23 @@
|
|
1 |
# Copyright (C) 2018 Smart Custom Fields
|
2 |
# This file is distributed under the same license as the Smart Custom Fields package.
|
|
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Smart Custom Fields 3.1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smart-custom-"
|
7 |
"fields\n"
|
8 |
-
"POT-Creation-Date: 2018-
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
-
"Language-Team:
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
#: classes/controller/class.controller-base.php:46
|
17 |
msgid "Image setting"
|
@@ -21,31 +27,11 @@ msgstr ""
|
|
21 |
msgid "File setting"
|
22 |
msgstr ""
|
23 |
|
24 |
-
#: classes/controller/class.option.php:57
|
25 |
-
msgid "Save settings"
|
26 |
-
msgstr ""
|
27 |
-
|
28 |
#: classes/controller/class.profile.php:43
|
29 |
#: classes/controller/class.settings.php:76
|
30 |
msgid "Custom Fields"
|
31 |
msgstr ""
|
32 |
|
33 |
-
#: classes/controller/class.settings.php:29
|
34 |
-
msgid "Basic fields"
|
35 |
-
msgstr ""
|
36 |
-
|
37 |
-
#: classes/controller/class.settings.php:33
|
38 |
-
msgid "Select fields"
|
39 |
-
msgstr ""
|
40 |
-
|
41 |
-
#: classes/controller/class.settings.php:37
|
42 |
-
msgid "Content fields"
|
43 |
-
msgstr ""
|
44 |
-
|
45 |
-
#: classes/controller/class.settings.php:41
|
46 |
-
msgid "Other fields"
|
47 |
-
msgstr ""
|
48 |
-
|
49 |
#: classes/controller/class.settings.php:64
|
50 |
msgid "Same name exists!"
|
51 |
msgstr ""
|
@@ -66,20 +52,7 @@ msgstr ""
|
|
66 |
msgid "Display conditions ( Options page )"
|
67 |
msgstr ""
|
68 |
|
69 |
-
#: classes/controller/class.settings.php:163
|
70 |
-
msgid "Type"
|
71 |
-
msgstr ""
|
72 |
-
|
73 |
-
#: classes/controller/class.settings.php:198
|
74 |
-
msgid "Add Sub field"
|
75 |
-
msgstr ""
|
76 |
-
|
77 |
-
#: classes/controller/class.settings.php:202
|
78 |
-
msgid "Add Field"
|
79 |
-
msgstr ""
|
80 |
-
|
81 |
#: classes/controller/class.settings.php:232
|
82 |
-
#: classes/fields/class.field-related-posts.php:231
|
83 |
msgid "Post Types"
|
84 |
msgstr ""
|
85 |
|
@@ -92,7 +65,6 @@ msgid "Roles"
|
|
92 |
msgstr ""
|
93 |
|
94 |
#: classes/controller/class.settings.php:290
|
95 |
-
#: classes/fields/class.field-related-terms.php:229
|
96 |
msgid "Taxonomies"
|
97 |
msgstr ""
|
98 |
|
@@ -112,80 +84,10 @@ msgstr ""
|
|
112 |
msgid "No"
|
113 |
msgstr ""
|
114 |
|
115 |
-
#: classes/fields/class.field-boolean.php:82
|
116 |
-
#: classes/fields/class.field-check.php:117
|
117 |
-
#: classes/fields/class.field-colorpicker.php:103
|
118 |
-
#: classes/fields/class.field-datepicker.php:125
|
119 |
-
#: classes/fields/class.field-radio.php:116
|
120 |
-
#: classes/fields/class.field-select.php:91
|
121 |
-
#: classes/fields/class.field-text.php:66
|
122 |
-
#: classes/fields/class.field-textarea.php:79
|
123 |
-
#: classes/fields/class.field-wysiwyg.php:122
|
124 |
-
msgid "Default"
|
125 |
-
msgstr ""
|
126 |
-
|
127 |
-
#: classes/fields/class.field-boolean.php:107
|
128 |
-
msgid "TRUE Label"
|
129 |
-
msgstr ""
|
130 |
-
|
131 |
-
#: classes/fields/class.field-boolean.php:117
|
132 |
-
msgid "FALSE Label"
|
133 |
-
msgstr ""
|
134 |
-
|
135 |
-
#: classes/fields/class.field-boolean.php:127
|
136 |
-
#: classes/fields/class.field-check.php:126
|
137 |
-
#: classes/fields/class.field-colorpicker.php:112
|
138 |
-
#: classes/fields/class.field-datepicker.php:189
|
139 |
-
#: classes/fields/class.field-file.php:117
|
140 |
-
#: classes/fields/class.field-image.php:112
|
141 |
-
#: classes/fields/class.field-radio.php:125
|
142 |
-
#: classes/fields/class.field-related-posts.php:260
|
143 |
-
#: classes/fields/class.field-related-terms.php:256
|
144 |
-
#: classes/fields/class.field-select.php:100
|
145 |
-
#: classes/fields/class.field-text.php:75
|
146 |
-
#: classes/fields/class.field-textarea.php:88
|
147 |
-
#: classes/fields/class.field-wysiwyg.php:131
|
148 |
-
msgid "Instruction"
|
149 |
-
msgstr ""
|
150 |
-
|
151 |
-
#: classes/fields/class.field-boolean.php:134
|
152 |
-
#: classes/fields/class.field-check.php:133
|
153 |
-
#: classes/fields/class.field-colorpicker.php:119
|
154 |
-
#: classes/fields/class.field-datepicker.php:196
|
155 |
-
#: classes/fields/class.field-file.php:124
|
156 |
-
#: classes/fields/class.field-image.php:119
|
157 |
-
#: classes/fields/class.field-radio.php:132
|
158 |
-
#: classes/fields/class.field-related-posts.php:267
|
159 |
-
#: classes/fields/class.field-related-terms.php:263
|
160 |
-
#: classes/fields/class.field-select.php:107
|
161 |
-
#: classes/fields/class.field-text.php:82
|
162 |
-
#: classes/fields/class.field-textarea.php:95
|
163 |
-
#: classes/fields/class.field-wysiwyg.php:138
|
164 |
-
msgid "Notes"
|
165 |
-
msgstr ""
|
166 |
-
|
167 |
#: classes/fields/class.field-check.php:21
|
168 |
msgid "Check"
|
169 |
msgstr ""
|
170 |
|
171 |
-
#: classes/fields/class.field-check.php:87
|
172 |
-
#: classes/fields/class.field-radio.php:86
|
173 |
-
#: classes/fields/class.field-select.php:81
|
174 |
-
msgid "Choices"
|
175 |
-
msgstr ""
|
176 |
-
|
177 |
-
#: classes/fields/class.field-check.php:93
|
178 |
-
#: classes/fields/class.field-radio.php:92
|
179 |
-
#: classes/fields/class.field-select.php:87
|
180 |
-
msgid ""
|
181 |
-
"If you want to separate the key and the value, enter as follows: key => value"
|
182 |
-
msgstr ""
|
183 |
-
|
184 |
-
#: classes/fields/class.field-check.php:97
|
185 |
-
#: classes/fields/class.field-radio.php:96
|
186 |
-
msgid "Display Direction"
|
187 |
-
msgstr ""
|
188 |
-
|
189 |
#: classes/fields/class.field-check.php:101
|
190 |
#: classes/fields/class.field-radio.php:100
|
191 |
msgid "horizontal"
|
@@ -204,27 +106,6 @@ msgstr ""
|
|
204 |
msgid "Date picker"
|
205 |
msgstr ""
|
206 |
|
207 |
-
#: classes/fields/class.field-datepicker.php:135
|
208 |
-
msgid "Date Format"
|
209 |
-
msgstr ""
|
210 |
-
|
211 |
-
#: classes/fields/class.field-datepicker.php:143
|
212 |
-
msgid "e.g dd/mm/yy"
|
213 |
-
msgstr ""
|
214 |
-
|
215 |
-
#: classes/fields/class.field-datepicker.php:153
|
216 |
-
msgid "Max Date"
|
217 |
-
msgstr ""
|
218 |
-
|
219 |
-
#: classes/fields/class.field-datepicker.php:161
|
220 |
-
#: classes/fields/class.field-datepicker.php:179
|
221 |
-
msgid "e.g +1m +1w"
|
222 |
-
msgstr ""
|
223 |
-
|
224 |
-
#: classes/fields/class.field-datepicker.php:171
|
225 |
-
msgid "Min Date"
|
226 |
-
msgstr ""
|
227 |
-
|
228 |
#: classes/fields/class.field-file.php:21
|
229 |
msgid "File"
|
230 |
msgstr ""
|
@@ -246,8 +127,8 @@ msgstr ""
|
|
246 |
msgid "Image Select"
|
247 |
msgstr ""
|
248 |
|
249 |
-
#: classes/fields/class.field-
|
250 |
-
msgid "
|
251 |
msgstr ""
|
252 |
|
253 |
#: classes/fields/class.field-radio.php:21
|
@@ -258,21 +139,11 @@ msgstr ""
|
|
258 |
msgid "Related Posts"
|
259 |
msgstr ""
|
260 |
|
261 |
-
#: classes/fields/class.field-related-posts.php:209
|
262 |
-
#: classes/fields/class.field-related-terms.php:207
|
263 |
-
msgid "Search..."
|
264 |
-
msgstr ""
|
265 |
-
|
266 |
#: classes/fields/class.field-related-posts.php:213
|
267 |
#: classes/fields/class.field-related-terms.php:211
|
268 |
msgid "Load more"
|
269 |
msgstr ""
|
270 |
|
271 |
-
#: classes/fields/class.field-related-posts.php:252
|
272 |
-
#: classes/fields/class.field-related-terms.php:248
|
273 |
-
msgid "Selectable number"
|
274 |
-
msgstr ""
|
275 |
-
|
276 |
#: classes/fields/class.field-related-terms.php:24
|
277 |
msgid "Related Terms"
|
278 |
msgstr ""
|
@@ -290,10 +161,6 @@ msgstr ""
|
|
290 |
msgid "Textarea"
|
291 |
msgstr ""
|
292 |
|
293 |
-
#: classes/fields/class.field-textarea.php:69
|
294 |
-
msgid "Rows"
|
295 |
-
msgstr ""
|
296 |
-
|
297 |
#: classes/fields/class.field-wysiwyg.php:26
|
298 |
msgid "Wysiwyg"
|
299 |
msgstr ""
|
@@ -302,29 +169,10 @@ msgstr ""
|
|
302 |
msgid "Visual"
|
303 |
msgstr ""
|
304 |
|
305 |
-
#: classes/fields/class.field-wysiwyg.php:160
|
306 |
#: classes/fields/class.field-wysiwyg.php:161
|
307 |
msgid "Add Media"
|
308 |
msgstr ""
|
309 |
|
310 |
-
#: classes/models/class.abstract-field-base.php:105
|
311 |
-
msgid "Name"
|
312 |
-
msgstr ""
|
313 |
-
|
314 |
-
#: classes/models/class.abstract-field-base.php:116
|
315 |
-
msgid "Label"
|
316 |
-
msgstr ""
|
317 |
-
|
318 |
-
#: classes/models/class.group.php:127
|
319 |
-
msgid "Repeat"
|
320 |
-
msgstr ""
|
321 |
-
|
322 |
-
#: classes/models/class.group.php:132
|
323 |
-
msgid "Group name"
|
324 |
-
msgstr ""
|
325 |
-
|
326 |
-
#. #-#-#-#-# smart-custom-fields.pot (Smart Custom Fields 3.1.6) #-#-#-#-#
|
327 |
-
#. Plugin Name of the plugin/theme
|
328 |
#: classes/models/class.revisions.php:128 smart-custom-fields.php:168
|
329 |
#: smart-custom-fields.php:169 smart-custom-fields.php:170
|
330 |
msgid "Smart Custom Fields"
|
@@ -366,19 +214,3 @@ msgstr ""
|
|
366 |
#: smart-custom-fields.php:180
|
367 |
msgid "No Fields found in Trash."
|
368 |
msgstr ""
|
369 |
-
|
370 |
-
#. Plugin URI of the plugin/theme
|
371 |
-
msgid "https://github.com/inc2734/smart-custom-fields/"
|
372 |
-
msgstr ""
|
373 |
-
|
374 |
-
#. Description of the plugin/theme
|
375 |
-
msgid "Smart Custom Fields is a simple plugin that management custom fields."
|
376 |
-
msgstr ""
|
377 |
-
|
378 |
-
#. Author of the plugin/theme
|
379 |
-
msgid "inc2734"
|
380 |
-
msgstr ""
|
381 |
-
|
382 |
-
#. Author URI of the plugin/theme
|
383 |
-
msgid "https://2inc.org"
|
384 |
-
msgstr ""
|
1 |
# Copyright (C) 2018 Smart Custom Fields
|
2 |
# This file is distributed under the same license as the Smart Custom Fields package.
|
3 |
+
#, fuzzy
|
4 |
msgid ""
|
5 |
msgstr ""
|
6 |
+
"Project-Id-Version: Smart Custom Fields 3.1.7\n"
|
7 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smart-custom-"
|
8 |
"fields\n"
|
9 |
+
"POT-Creation-Date: 2018-06-02 21:26-0300\n"
|
10 |
"MIME-Version: 1.0\n"
|
11 |
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
|
14 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
15 |
+
"Language-Team: Smart Custom Fields <LL@li.org>\n"
|
16 |
+
"X-Generator: Poedit 2.0.7\n"
|
17 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
18 |
+
"X-Poedit-KeywordsList: esc_html__;__;_n;_x;_n_noop;_e\n"
|
19 |
+
"X-Poedit-Basepath: ..\n"
|
20 |
+
"X-Poedit-SearchPath-0: .\n"
|
21 |
|
22 |
#: classes/controller/class.controller-base.php:46
|
23 |
msgid "Image setting"
|
27 |
msgid "File setting"
|
28 |
msgstr ""
|
29 |
|
|
|
|
|
|
|
|
|
30 |
#: classes/controller/class.profile.php:43
|
31 |
#: classes/controller/class.settings.php:76
|
32 |
msgid "Custom Fields"
|
33 |
msgstr ""
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
#: classes/controller/class.settings.php:64
|
36 |
msgid "Same name exists!"
|
37 |
msgstr ""
|
52 |
msgid "Display conditions ( Options page )"
|
53 |
msgstr ""
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
#: classes/controller/class.settings.php:232
|
|
|
56 |
msgid "Post Types"
|
57 |
msgstr ""
|
58 |
|
65 |
msgstr ""
|
66 |
|
67 |
#: classes/controller/class.settings.php:290
|
|
|
68 |
msgid "Taxonomies"
|
69 |
msgstr ""
|
70 |
|
84 |
msgid "No"
|
85 |
msgstr ""
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
#: classes/fields/class.field-check.php:21
|
88 |
msgid "Check"
|
89 |
msgstr ""
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
#: classes/fields/class.field-check.php:101
|
92 |
#: classes/fields/class.field-radio.php:100
|
93 |
msgid "horizontal"
|
106 |
msgid "Date picker"
|
107 |
msgstr ""
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
#: classes/fields/class.field-file.php:21
|
110 |
msgid "File"
|
111 |
msgstr ""
|
127 |
msgid "Image Select"
|
128 |
msgstr ""
|
129 |
|
130 |
+
#: classes/fields/class.field-message.php:21
|
131 |
+
msgid "Message"
|
132 |
msgstr ""
|
133 |
|
134 |
#: classes/fields/class.field-radio.php:21
|
139 |
msgid "Related Posts"
|
140 |
msgstr ""
|
141 |
|
|
|
|
|
|
|
|
|
|
|
142 |
#: classes/fields/class.field-related-posts.php:213
|
143 |
#: classes/fields/class.field-related-terms.php:211
|
144 |
msgid "Load more"
|
145 |
msgstr ""
|
146 |
|
|
|
|
|
|
|
|
|
|
|
147 |
#: classes/fields/class.field-related-terms.php:24
|
148 |
msgid "Related Terms"
|
149 |
msgstr ""
|
161 |
msgid "Textarea"
|
162 |
msgstr ""
|
163 |
|
|
|
|
|
|
|
|
|
164 |
#: classes/fields/class.field-wysiwyg.php:26
|
165 |
msgid "Wysiwyg"
|
166 |
msgstr ""
|
169 |
msgid "Visual"
|
170 |
msgstr ""
|
171 |
|
|
|
172 |
#: classes/fields/class.field-wysiwyg.php:161
|
173 |
msgid "Add Media"
|
174 |
msgstr ""
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
#: classes/models/class.revisions.php:128 smart-custom-fields.php:168
|
177 |
#: smart-custom-fields.php:169 smart-custom-fields.php:170
|
178 |
msgid "Smart Custom Fields"
|
214 |
#: smart-custom-fields.php:180
|
215 |
msgid "No Fields found in Trash."
|
216 |
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Smart Custom Fields ===
|
2 |
-
Contributors: inc2734, toro_unit, mimosafa, hideokamoto, hisako-isaka, kurudrive, hanamura, justinticktock, designhehe, mayukojpn, hogetan
|
3 |
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.9.
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -37,6 +37,7 @@ https://www.youtube.com/watch?v=WxPZurn0yvI
|
|
37 |
* Color picker
|
38 |
* Date picker
|
39 |
* Boolean
|
|
|
40 |
|
41 |
= How to get meta data ? =
|
42 |
|
@@ -127,6 +128,11 @@ You can translate this plugin into your language by using [GlotPress](https://tr
|
|
127 |
|
128 |
== Changelog ==
|
129 |
|
|
|
|
|
|
|
|
|
|
|
130 |
= 3.1.7 =
|
131 |
* Fixing issues and adding support for the Brazilian Portuguese language #63 (by [@robssanches](https://github.com/robssanches))
|
132 |
* Spelling fixes in Readme #62 (by [@garrett-eclipse](https://github.com/garrett-eclipse))
|
1 |
=== Smart Custom Fields ===
|
2 |
+
Contributors: inc2734, toro_unit, mimosafa, hideokamoto, hisako-isaka, kurudrive, hanamura, justinticktock, designhehe, mayukojpn, hogetan, robssanches
|
3 |
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.9.6
|
7 |
+
Stable tag: 4.0.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
37 |
* Color picker
|
38 |
* Date picker
|
39 |
* Boolean
|
40 |
+
* Message
|
41 |
|
42 |
= How to get meta data ? =
|
43 |
|
128 |
|
129 |
== Changelog ==
|
130 |
|
131 |
+
= 4.0.0 =
|
132 |
+
* Add message field. #64 (by [@robssanches](https://github.com/robssanches))
|
133 |
+
* Fix boolean field bug with `smart-cf-register-fields` filter hook.
|
134 |
+
* Refactoring displaying options process of each fields.
|
135 |
+
|
136 |
= 3.1.7 =
|
137 |
* Fixing issues and adding support for the Brazilian Portuguese language #63 (by [@robssanches](https://github.com/robssanches))
|
138 |
* Spelling fixes in Readme #62 (by [@garrett-eclipse](https://github.com/garrett-eclipse))
|
smart-custom-fields.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Author: inc2734
|
8 |
* Author URI: https://2inc.org
|
9 |
* Created: October 9, 2014
|
10 |
-
* Modified:
|
11 |
* Text Domain: smart-custom-fields
|
12 |
* Domain Path: /languages
|
13 |
* License: GPLv2 or later
|
7 |
* Author: inc2734
|
8 |
* Author URI: https://2inc.org
|
9 |
* Created: October 9, 2014
|
10 |
+
* Modified: June 04, 2018
|
11 |
* Text Domain: smart-custom-fields
|
12 |
* Domain Path: /languages
|
13 |
* License: GPLv2 or later
|
trunk/classes/class.config.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SCF_Config
|
4 |
+
* Version : 1.0.1
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : September 23, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class SCF_Config {
|
12 |
+
/**
|
13 |
+
* name
|
14 |
+
*/
|
15 |
+
const NAME = 'smart-custom-fields';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* prefix
|
19 |
+
*/
|
20 |
+
const PREFIX = 'smart-cf-';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* プロフィール画面用の擬似投稿タイプ
|
24 |
+
*/
|
25 |
+
const PROFILE = 'smart-cf-profile';
|
26 |
+
}
|
trunk/classes/class.scf.php
ADDED
@@ -0,0 +1,804 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* SCF
|
4 |
+
* Version : 2.0.1
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : September 23, 2014
|
7 |
+
* Modified : JAnuary 16, 2017
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class SCF {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Array of the registered fields ( Smart_Custom_Fields_Field_Base )
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
protected static $fields = array();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Array of the custom options pages.
|
21 |
+
* @var array
|
22 |
+
*/
|
23 |
+
protected static $options_pages = array();
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Getting all of the post meta data to feel good
|
27 |
+
*
|
28 |
+
* @param int $post_id
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
public static function gets( $post_id = null ) {
|
32 |
+
if ( is_null( $post_id ) ) {
|
33 |
+
$post_id = get_the_ID();
|
34 |
+
}
|
35 |
+
$post_id = self::get_real_post_id( $post_id );
|
36 |
+
|
37 |
+
if ( empty( $post_id ) ) {
|
38 |
+
return null;
|
39 |
+
}
|
40 |
+
|
41 |
+
// Don't output meta data that not save in the SCF settings page
|
42 |
+
// Getting the settings data, judged to output meta data.
|
43 |
+
return self::get_all_meta( get_post( $post_id ) );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Getting the post meta data to feel good
|
48 |
+
*
|
49 |
+
* @param string $name group name or field name
|
50 |
+
* @param int $post_id
|
51 |
+
* @return mixed
|
52 |
+
*/
|
53 |
+
public static function get( $name, $post_id = null ) {
|
54 |
+
if ( is_null( $post_id ) ) {
|
55 |
+
$post_id = get_the_ID();
|
56 |
+
}
|
57 |
+
$post_id = self::get_real_post_id( $post_id );
|
58 |
+
|
59 |
+
if ( empty( $post_id ) ) {
|
60 |
+
return;
|
61 |
+
}
|
62 |
+
|
63 |
+
// Don't output meta data that not save in the SCF settings page
|
64 |
+
// Getting the settings data, judged to output meta data.
|
65 |
+
return self::get_meta( get_post( $post_id ), $name );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Getting the user meta data to feel good
|
70 |
+
*
|
71 |
+
* @param int $user_id
|
72 |
+
* @param string $name group name or field name
|
73 |
+
* @return mixed
|
74 |
+
*/
|
75 |
+
public static function get_user_meta( $user_id, $name = null ) {
|
76 |
+
if ( empty( $user_id ) ) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
// If $name is null, return the all meta data.
|
81 |
+
if ( $name === null ) {
|
82 |
+
return self::get_all_meta( get_userdata( $user_id ) );
|
83 |
+
}
|
84 |
+
|
85 |
+
// Don't output meta data that not save in the SCF settings page.
|
86 |
+
// Getting the settings data, judged to output meta data.
|
87 |
+
return self::get_meta( get_userdata( $user_id ), $name );
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Getting the term meta data to feel good
|
92 |
+
*
|
93 |
+
* @param int $term_id
|
94 |
+
* @param string $taxonomy_name
|
95 |
+
* @param string $name group name or field name
|
96 |
+
* @return mixed
|
97 |
+
*/
|
98 |
+
public static function get_term_meta( $term_id, $taxonomy_name, $name = null ) {
|
99 |
+
if ( empty( $term_id ) || empty( $taxonomy_name ) ) {
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
|
103 |
+
// If $name is null, return the all meta data.
|
104 |
+
if ( $name === null ) {
|
105 |
+
return self::get_all_meta( get_term( $term_id, $taxonomy_name ) );
|
106 |
+
}
|
107 |
+
|
108 |
+
// Don't output meta data that not save in the SCF settings page
|
109 |
+
// Getting the settings data, judged to output meta data.
|
110 |
+
return self::get_meta( get_term( $term_id, $taxonomy_name ), $name );
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Getting the custom options page meta data to feel good
|
115 |
+
*
|
116 |
+
* @param string $menu_slug custom options page slug
|
117 |
+
* @param string $name group name or field name
|
118 |
+
* @return mixed
|
119 |
+
*/
|
120 |
+
public static function get_option_meta( $menu_slug, $name = null ) {
|
121 |
+
if ( empty( $menu_slug ) ) {
|
122 |
+
return;
|
123 |
+
}
|
124 |
+
|
125 |
+
if ( !isset( self::$options_pages[$menu_slug] ) ) {
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
|
129 |
+
$Option = self::generate_option_object( $menu_slug );
|
130 |
+
|
131 |
+
// If $name is null, return the all meta data.
|
132 |
+
if ( $name === null ) {
|
133 |
+
return self::get_all_meta( $Option );
|
134 |
+
}
|
135 |
+
|
136 |
+
// Don't output meta data that not save in the SCF settings page
|
137 |
+
// Getting the settings data, judged to output meta data.
|
138 |
+
return self::get_meta( $Option, $name );
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Getting any meta data to feel good
|
143 |
+
*
|
144 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
145 |
+
* @param string $name group name or field name
|
146 |
+
* @return mixed
|
147 |
+
*/
|
148 |
+
protected static function get_meta( $object, $name ) {
|
149 |
+
$Cache = Smart_Custom_Fields_Cache::getInstance();
|
150 |
+
if ( $Cache->get_meta( $object, $name ) ) {
|
151 |
+
self::debug_cache_message( "use get cache. [name: {$name}]" );
|
152 |
+
return $Cache->get_meta( $object, $name );
|
153 |
+
} else {
|
154 |
+
self::debug_cache_message( "dont use get cache... [name: {$name}]" );
|
155 |
+
}
|
156 |
+
|
157 |
+
$settings = self::get_settings( $object );
|
158 |
+
foreach ( $settings as $Setting ) {
|
159 |
+
// If $name matches the group name, returns fields in the group as array.
|
160 |
+
$Group = $Setting->get_group( $name );
|
161 |
+
if ( $Group ) {
|
162 |
+
$values_by_group = self::get_values_by_group( $object, $Group );
|
163 |
+
$Cache->save_meta( $object, $name, $values_by_group );
|
164 |
+
return $values_by_group;
|
165 |
+
}
|
166 |
+
|
167 |
+
// If $name doesn't matche the group name, returns the field that matches.
|
168 |
+
$groups = $Setting->get_groups();
|
169 |
+
foreach ( $groups as $Group ) {
|
170 |
+
$Field = $Group->get_field( $name );
|
171 |
+
if ( $Field ) {
|
172 |
+
$is_repeatable = $Group->is_repeatable();
|
173 |
+
$value_by_field = self::get_value_by_field( $object, $Field, $is_repeatable );
|
174 |
+
$Cache->save_meta( $object, $name, $value_by_field );
|
175 |
+
return $value_by_field;
|
176 |
+
}
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Getting all of any meta data to feel good
|
183 |
+
*
|
184 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
185 |
+
* @return mixed
|
186 |
+
*/
|
187 |
+
protected static function get_all_meta( $object ) {
|
188 |
+
$Cache = Smart_Custom_Fields_Cache::getInstance();
|
189 |
+
$settings = self::get_settings( $object );
|
190 |
+
$post_meta = array();
|
191 |
+
foreach ( $settings as $Setting ) {
|
192 |
+
$groups = $Setting->get_groups();
|
193 |
+
foreach ( $groups as $Group ) {
|
194 |
+
$is_repeatable = $Group->is_repeatable();
|
195 |
+
$group_name = $Group->get_name();
|
196 |
+
if ( $is_repeatable && $group_name ) {
|
197 |
+
$values_by_group = self::get_values_by_group( $object, $Group );
|
198 |
+
$Cache->save_meta( $object, $group_name, $values_by_group );
|
199 |
+
$post_meta[$group_name] = $values_by_group;
|
200 |
+
}
|
201 |
+
else {
|
202 |
+
$fields = $Group->get_fields();
|
203 |
+
foreach ( $fields as $Field ) {
|
204 |
+
$field_name = $Field->get( 'name' );
|
205 |
+
$value_by_field = self::get_value_by_field( $object, $Field, $is_repeatable );
|
206 |
+
$Cache->save_meta( $object, $field_name, $value_by_field );
|
207 |
+
$post_meta[$field_name] = $value_by_field;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
return $post_meta;
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* If in preview, return the preview post ID
|
217 |
+
*
|
218 |
+
* @param int $post_id
|
219 |
+
* @return int
|
220 |
+
*/
|
221 |
+
protected static function get_real_post_id( $post_id ) {
|
222 |
+
if ( is_preview() ) {
|
223 |
+
$preview_post = wp_get_post_autosave( $post_id );
|
224 |
+
if ( isset( $preview_post->ID ) ) {
|
225 |
+
$post_id = $preview_post->ID;
|
226 |
+
}
|
227 |
+
}
|
228 |
+
return $post_id;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Getting the meta data of the group
|
233 |
+
* When group, Note the point that returned data are repetition
|
234 |
+
*
|
235 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
236 |
+
* @param Smart_Custom_Fields_Group $Group
|
237 |
+
* @return mixed
|
238 |
+
*/
|
239 |
+
protected static function get_values_by_group( $object, $Group ) {
|
240 |
+
$is_repeatable = $Group->is_repeatable();
|
241 |
+
$meta = array();
|
242 |
+
$fields = $Group->get_fields();
|
243 |
+
$value_by_fields = array();
|
244 |
+
foreach ( $fields as $Field ) {
|
245 |
+
if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
|
246 |
+
$meta[0][$Field->get( 'name' )] = array();
|
247 |
+
} else {
|
248 |
+
$meta[0][$Field->get( 'name' )] = '';
|
249 |
+
}
|
250 |
+
}
|
251 |
+
$default_meta = $meta[0];
|
252 |
+
foreach ( $fields as $Field ) {
|
253 |
+
$value_by_field = self::get_value_by_field( $object, $Field, $is_repeatable );
|
254 |
+
foreach ( $value_by_field as $i => $value ) {
|
255 |
+
$meta[$i][$Field->get( 'name' )] = $value;
|
256 |
+
}
|
257 |
+
}
|
258 |
+
foreach ( $meta as $i => $value ) {
|
259 |
+
$meta[$i] = array_merge( $default_meta, $value );
|
260 |
+
}
|
261 |
+
return $meta;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Getting the meta data of the field
|
266 |
+
*
|
267 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
268 |
+
* @param array $field
|
269 |
+
* @param bool $is_repeatable Whether the group that this field belongs is repetition
|
270 |
+
* @return mixed $post_meta
|
271 |
+
*/
|
272 |
+
protected static function get_value_by_field( $object, $Field, $is_repeatable ) {
|
273 |
+
$field_name = $Field->get( 'name' );
|
274 |
+
if ( !$field_name ) {
|
275 |
+
return;
|
276 |
+
}
|
277 |
+
|
278 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
279 |
+
|
280 |
+
// In the case of multi-value items in the loop
|
281 |
+
$field_type = $Field->get_attribute( 'type' );
|
282 |
+
$repeat_multiple_data = self::get_repeat_multiple_data( $object );
|
283 |
+
if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[$field_name] ) ) {
|
284 |
+
if ( $Meta->is_saved_the_key( $field_name ) ) {
|
285 |
+
$_meta = $Meta->get( $field_name );
|
286 |
+
} else {
|
287 |
+
$_meta = self::get_default_value( $Field );
|
288 |
+
}
|
289 |
+
$start = 0;
|
290 |
+
foreach ( $repeat_multiple_data[$field_name] as $repeat_multiple_key => $repeat_multiple_value ) {
|
291 |
+
if ( $repeat_multiple_value === 0 ) {
|
292 |
+
$value = array();
|
293 |
+
} else {
|
294 |
+
$value = array_slice( $_meta, $start, $repeat_multiple_value );
|
295 |
+
$start += $repeat_multiple_value;
|
296 |
+
}
|
297 |
+
$value = apply_filters( SCF_Config::PREFIX . 'validate-get-value', $value, $field_type );
|
298 |
+
$meta[$repeat_multiple_key] = $value;
|
299 |
+
}
|
300 |
+
}
|
301 |
+
// Other than that
|
302 |
+
else {
|
303 |
+
$single = true;
|
304 |
+
if ( $Field->get_attribute( 'allow-multiple-data' ) || $is_repeatable ) {
|
305 |
+
$single = false;
|
306 |
+
}
|
307 |
+
if ( $Meta->is_saved_the_key( $field_name ) ) {
|
308 |
+
$meta = $Meta->get( $field_name, $single );
|
309 |
+
} else {
|
310 |
+
$meta = self::get_default_value( $Field, $single );
|
311 |
+
}
|
312 |
+
$meta = apply_filters( SCF_Config::PREFIX . 'validate-get-value', $meta, $field_type );
|
313 |
+
}
|
314 |
+
return $meta;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Return the default value
|
319 |
+
*
|
320 |
+
* @param Smart_Custom_Fields_Field_Base $Field
|
321 |
+
* @param bool $single
|
322 |
+
* @return array|strings
|
323 |
+
*/
|
324 |
+
public static function get_default_value( $Field, $single = false ) {
|
325 |
+
if ( !is_a( $Field, 'Smart_Custom_Fields_Field_Base' ) ) {
|
326 |
+
if ( $single ) {
|
327 |
+
return '';
|
328 |
+
}
|
329 |
+
return array();
|
330 |
+
}
|
331 |
+
|
332 |
+
$choices = $Field->get( 'choices' );
|
333 |
+
$default = $Field->get( 'default' );
|
334 |
+
|
335 |
+
if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
|
336 |
+
$choices = SCF::choices_eol_to_array( $choices );
|
337 |
+
$default = SCF::choices_eol_to_array( $default );
|
338 |
+
$default_sanitized = array();
|
339 |
+
|
340 |
+
if ( SCF::is_assoc( $choices ) ) {
|
341 |
+
$_choices = array_flip( $choices );
|
342 |
+
} else {
|
343 |
+
$_choices = $choices;
|
344 |
+
}
|
345 |
+
foreach ( $default as $key => $value ) {
|
346 |
+
if ( in_array( $value, $_choices ) ) {
|
347 |
+
if ( preg_match( '/^\d+$/', $value ) ) {
|
348 |
+
$value = (int)$value;
|
349 |
+
}
|
350 |
+
$default_sanitized[$key] = $value;
|
351 |
+
}
|
352 |
+
}
|
353 |
+
return $default_sanitized;
|
354 |
+
}
|
355 |
+
|
356 |
+
// Return string
|
357 |
+
if ( $single ) {
|
358 |
+
return $default;
|
359 |
+
}
|
360 |
+
// Return array
|
361 |
+
else {
|
362 |
+
if ( is_array( $default ) ) {
|
363 |
+
return $default;
|
364 |
+
}
|
365 |
+
if ( $default === '' || $default === false || $default === null ) {
|
366 |
+
return array();
|
367 |
+
}
|
368 |
+
return ( array ) $default;
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Getting enabled custom field settings in the post type or the role or the term.
|
374 |
+
*
|
375 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
376 |
+
* @return array $settings
|
377 |
+
*/
|
378 |
+
public static function get_settings_posts( $object ) {
|
379 |
+
$Cache = Smart_Custom_Fields_Cache::getInstance();
|
380 |
+
$settings_posts = array();
|
381 |
+
if ( $Cache->get_settings_posts( $object ) !== null ) {
|
382 |
+
self::debug_cache_message( "use settings posts cache." );
|
383 |
+
return $Cache->get_settings_posts( $object );
|
384 |
+
} else {
|
385 |
+
self::debug_cache_message( "dont use settings posts cache..." );
|
386 |
+
}
|
387 |
+
|
388 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
389 |
+
$types = $Meta->get_types( false );
|
390 |
+
|
391 |
+
switch ( $Meta->get_meta_type() ) {
|
392 |
+
case 'post' :
|
393 |
+
$key = SCF_Config::PREFIX . 'condition';
|
394 |
+
break;
|
395 |
+
case 'user' :
|
396 |
+
$key = SCF_Config::PREFIX . 'roles';
|
397 |
+
break;
|
398 |
+
case 'term' :
|
399 |
+
$key = SCF_Config::PREFIX . 'taxonomies';
|
400 |
+
break;
|
401 |
+
case 'option' :
|
402 |
+
$key = SCF_Config::PREFIX . 'options-pages';
|
403 |
+
break;
|
404 |
+
default :
|
405 |
+
$key = '';
|
406 |
+
}
|
407 |
+
|
408 |
+
if ( ! empty( $key ) && ( ! empty( $types ) ) ) {
|
409 |
+
$meta_query = array();
|
410 |
+
foreach ( $types as $type ) {
|
411 |
+
$meta_query[] = array(
|
412 |
+
'key' => $key,
|
413 |
+
'value' => sprintf( '"%s"', $type ),
|
414 |
+
'compare' => 'LIKE',
|
415 |
+
);
|
416 |
+
}
|
417 |
+
if ( $meta_query ) {
|
418 |
+
$meta_query[ 'relation' ] = 'OR';
|
419 |
+
}
|
420 |
+
|
421 |
+
$args = array(
|
422 |
+
'post_type' => SCF_Config::NAME,
|
423 |
+
'posts_per_page' => -1,
|
424 |
+
'order' => 'ASC',
|
425 |
+
'order_by' => 'menu_order',
|
426 |
+
'meta_query' => $meta_query,
|
427 |
+
);
|
428 |
+
|
429 |
+
$settings_posts = get_posts( $args );
|
430 |
+
}
|
431 |
+
|
432 |
+
$Cache = Smart_Custom_Fields_Cache::getInstance();
|
433 |
+
$Cache->save_settings_posts( $object, $settings_posts );
|
434 |
+
return $settings_posts;
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Getting array of the Setting object
|
439 |
+
*
|
440 |
+
* @param WP_Post|WP_User|WP_Term|Smart_Custom_Fields_Options_Mock $object
|
441 |
+
* @return array $settings
|
442 |
+
*/
|
443 |
+
public static function get_settings( $object ) {
|
444 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
445 |
+
$id = $Meta->get_id();
|
446 |
+
$type = $Meta->get_type( false );
|
447 |
+
$types = $Meta->get_types( false );
|
448 |
+
$meta_type = $Meta->get_meta_type();
|
449 |
+
|
450 |
+
// IF the post that has custom field settings according to post ID,
|
451 |
+
// don't display because the post ID would change in preview.
|
452 |
+
// So if in preview, re-getting post ID from original post (parent of the preview).
|
453 |
+
if ( $meta_type === 'post' && $object->post_type === 'revision' ) {
|
454 |
+
$object = get_post( $object->post_parent );
|
455 |
+
}
|
456 |
+
|
457 |
+
$settings = array();
|
458 |
+
|
459 |
+
if ( ! empty( $types ) ) {
|
460 |
+
$settings_posts = self::get_settings_posts( $object );
|
461 |
+
if ( $meta_type === 'post' ) {
|
462 |
+
$settings = self::get_settings_for_post( $object, $settings_posts );
|
463 |
+
}
|
464 |
+
elseif ( $meta_type === 'user' ) {
|
465 |
+
$settings = self::get_settings_for_profile( $object, $settings_posts );
|
466 |
+
}
|
467 |
+
elseif ( $meta_type === 'term' ) {
|
468 |
+
$settings = self::get_settings_for_term( $object, $settings_posts );
|
469 |
+
}
|
470 |
+
elseif ( $meta_type === 'option' ) {
|
471 |
+
$settings = self::get_settings_for_option( $object, $settings_posts );
|
472 |
+
}
|
473 |
+
}
|
474 |
+
$settings = apply_filters(
|
475 |
+
SCF_Config::PREFIX . 'register-fields',
|
476 |
+
$settings,
|
477 |
+
$type,
|
478 |
+
$id,
|
479 |
+
$meta_type,
|
480 |
+
$types
|
481 |
+
);
|
482 |
+
if ( !is_array( $settings ) ) {
|
483 |
+
$settings = array();
|
484 |
+
}
|
485 |
+
return $settings;
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Getting the Setting object for post
|
490 |
+
*
|
491 |
+
* @param WP_Post $object
|
492 |
+
* @param array $settings_posts
|
493 |
+
* @return array
|
494 |
+
*/
|
495 |
+
protected static function get_settings_for_post( $object, $settings_posts ) {
|
496 |
+
$Cache = Smart_Custom_Fields_Cache::getInstance();
|
497 |
+
$settings = array();
|
498 |
+
foreach ( $settings_posts as $settings_post ) {
|
499 |
+
if ( $Cache->get_settings( $settings_post->ID ) !== null ) {
|
500 |
+
self::debug_cache_message( "use settings cache. [id: {$settings_post->ID}]" );
|
501 |
+
$Setting = $Cache->get_settings( $settings_post->ID, $object );
|
502 |
+
if ( $Setting ) {
|
503 |
+
$settings[$settings_post->ID] = $Setting;
|
504 |
+
}
|
505 |
+
continue;
|
506 |
+
}
|
507 |
+
self::debug_cache_message( "dont use settings cache... [SCF ID: {$settings_post->ID}] [post_type: {$object->post_type}] [Post ID: {$object->ID}]" );
|
508 |
+
$condition_post_ids_raw = get_post_meta(
|
509 |
+
$settings_post->ID,
|
510 |
+
SCF_Config::PREFIX . 'condition-post-ids',
|
511 |
+
true
|
512 |
+
);
|
513 |
+
if ( $condition_post_ids_raw ) {
|
514 |
+
$condition_post_ids_raw = explode( ',', $condition_post_ids_raw );
|
515 |
+
foreach ( $condition_post_ids_raw as $condition_post_id ) {
|
516 |
+
$condition_post_id = trim( $condition_post_id );
|
517 |
+
$Setting = SCF::add_setting( $settings_post->ID, $settings_post->post_title );
|
518 |
+
if ( $object->ID == $condition_post_id ) {
|
519 |
+
$settings[$settings_post->ID] = $Setting;
|
520 |
+
}
|
521 |
+
$Post = get_post( $condition_post_id );
|
522 |
+
if ( empty( $Post ) ) {
|
523 |
+
$Post = self::generate_post_object( $condition_post_id );
|
524 |
+
}
|
525 |
+
$Cache->save_settings( $settings_post->ID, $Setting, $Post );
|
526 |
+
}
|
527 |
+
} else {
|
528 |
+
$Setting = SCF::add_setting( $settings_post->ID, $settings_post->post_title );
|
529 |
+
$settings[$settings_post->ID] = $Setting;
|
530 |
+
$Cache->save_settings( $settings_post->ID, $Setting );
|
531 |
+
}
|
532 |
+
}
|
533 |
+
return $settings;
|
534 |
+
}
|
535 |
+
|
536 |
+
/**
|
537 |
+
* Getting the Setting object for user
|
538 |
+
*
|
539 |
+
* @param WP_User $object
|
540 |
+
* @param array $settings_posts
|
541 |
+
* @return array
|
542 |
+
*/
|
543 |
+
protected static function get_settings_for_profile( $object, $settings_posts ) {
|
544 |
+
$Cache = Smart_Custom_Fields_Cache::getInstance();
|
545 |
+
$settings = array();
|
546 |
+
foreach ( $settings_posts as $settings_post ) {
|
547 |
+
if ( $Cache->get_settings( $settings_post->ID ) !== null ) {
|
548 |
+
self::debug_cache_message( "use settings cache. [id: {$settings_post->ID}]" );
|
549 |
+
$settings[] = $Cache->get_settings( $settings_post->ID );
|
550 |
+
continue;
|
551 |
+
}
|
552 |
+
self::debug_cache_message( "dont use settings cache... [id: {$settings_post->ID}]" );
|
553 |
+
$Setting = SCF::add_setting( $settings_post->ID, $settings_post->post_title );
|
554 |
+
$settings[] = $Setting;
|
555 |
+
$Cache->save_settings( $settings_post->ID, $Setting );
|
556 |
+
}
|
557 |
+
return $settings;
|
558 |
+
}
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Getting the Setting object for term
|
562 |
+
*
|
563 |
+
* @param WP_Term $object
|
564 |
+
* @param array $settings_posts
|
565 |
+
* @return array
|
566 |
+
*/
|
567 |
+
protected static function get_settings_for_term( $object, $settings_posts ) {
|
568 |
+
return self::get_settings_for_profile( $object, $settings_posts );
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Getting the Setting object for option
|
573 |
+
*
|
574 |
+
* @param WP_Term $object
|
575 |
+
* @param array $settings_posts
|
576 |
+
* @return array
|
577 |
+
*/
|
578 |
+
protected static function get_settings_for_option( $object, $settings_posts ) {
|
579 |
+
return self::get_settings_for_profile( $object, $settings_posts );
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* Getting delimited identification data of the repeated multi-value items
|
584 |
+
*
|
585 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
586 |
+
* @return array
|
587 |
+
*/
|
588 |
+
public static function get_repeat_multiple_data( $object ) {
|
589 |
+
$Cache = Smart_Custom_Fields_Cache::getInstance();
|
590 |
+
$repeat_multiple_data = array();
|
591 |
+
if ( $Cache->get_repeat_multiple_data( $object ) ) {
|
592 |
+
return $Cache->get_repeat_multiple_data( $object );
|
593 |
+
}
|
594 |
+
|
595 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
596 |
+
$_repeat_multiple_data = $Meta->get( SCF_Config::PREFIX . 'repeat-multiple-data', true );
|
597 |
+
if ( !empty( $_repeat_multiple_data ) ) {
|
598 |
+
$repeat_multiple_data = $_repeat_multiple_data;
|
599 |
+
}
|
600 |
+
|
601 |
+
$Cache->save_repeat_multiple_data( $object, $repeat_multiple_data );
|
602 |
+
return $repeat_multiple_data;
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Return true if null or empty value
|
607 |
+
*
|
608 |
+
* @param mixed $value
|
609 |
+
* @return bool
|
610 |
+
*/
|
611 |
+
public static function is_empty( &$value ) {
|
612 |
+
if ( isset( $value ) ) {
|
613 |
+
if ( is_null( $value ) || $value === '' ) {
|
614 |
+
return true;
|
615 |
+
}
|
616 |
+
return false;
|
617 |
+
}
|
618 |
+
return true;
|
619 |
+
}
|
620 |
+
|
621 |
+
/**
|
622 |
+
* Whether the associative array or not
|
623 |
+
*
|
624 |
+
* @see http://qiita.com/ka215/items/a14e53547e717d2a564f
|
625 |
+
* @param array $data This argument should be expected an array
|
626 |
+
* @param boolean $multidimensional True if a multidimensional array is inclusion into associative array, the default value is false
|
627 |
+
* @return boolean
|
628 |
+
*/
|
629 |
+
public static function is_assoc( $data, $multidimensional = false ) {
|
630 |
+
if ( !is_array( $data ) || empty( $data ) ) {
|
631 |
+
return false;
|
632 |
+
}
|
633 |
+
$has_array = false;
|
634 |
+
foreach ( $data as $key => $value ) {
|
635 |
+
if ( is_array( $value ) ) {
|
636 |
+
$has_array = true;
|
637 |
+
}
|
638 |
+
|
639 |
+
if ( !is_int( $key ) ) {
|
640 |
+
return true;
|
641 |
+
}
|
642 |
+
}
|
643 |
+
return $multidimensional && $has_array ? true : false;
|
644 |
+
}
|
645 |
+
|
646 |
+
/**
|
647 |
+
* Adding the available form field object
|
648 |
+
*
|
649 |
+
* @param Smart_Custom_Fields_Field_Base $instance
|
650 |
+
*/
|
651 |
+
public static function add_form_field_instance( Smart_Custom_Fields_Field_Base $instance ) {
|
652 |
+
$type = $instance->get_attribute( 'type' );
|
653 |
+
if ( !empty( $type ) ) {
|
654 |
+
self::$fields[$type] = $instance;
|
655 |
+
}
|
656 |
+
}
|
657 |
+
|
658 |
+
/**
|
659 |
+
* Getting the available form field object
|
660 |
+
*
|
661 |
+
* @param string $type type of the form field
|
662 |
+
* @param Smart_Custom_Fields_Field_Base
|
663 |
+
*/
|
664 |
+
public static function get_form_field_instance( $type ) {
|
665 |
+
if ( !empty( self::$fields[$type] ) ) {
|
666 |
+
return clone self::$fields[$type];
|
667 |
+
}
|
668 |
+
}
|
669 |
+
|
670 |
+
/**
|
671 |
+
* Getting all available form field object
|
672 |
+
*
|
673 |
+
* @return array
|
674 |
+
*/
|
675 |
+
public static function get_form_field_instances() {
|
676 |
+
$fields = array();
|
677 |
+
foreach ( self::$fields as $type => $instance ) {
|
678 |
+
$fields[$type] = self::get_form_field_instance( $type );
|
679 |
+
}
|
680 |
+
return $fields;
|
681 |
+
}
|
682 |
+
|
683 |
+
/**
|
684 |
+
* Getting custom fields that saved custo field settings page
|
685 |
+
* Note that not return only one even define multiple fields with the same name of the field name
|
686 |
+
*
|
687 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
688 |
+
* @param string $field_name
|
689 |
+
* @return Smart_Custom_Fields_Field_Base|null
|
690 |
+
*/
|
691 |
+
public static function get_field( $object, $field_name ) {
|
692 |
+
$settings = self::get_settings( $object );
|
693 |
+
foreach ( $settings as $Setting ) {
|
694 |
+
$fields = $Setting->get_fields();
|
695 |
+
if ( !empty( $fields[$field_name] ) ) {
|
696 |
+
return $fields[$field_name];
|
697 |
+
}
|
698 |
+
}
|
699 |
+
}
|
700 |
+
|
701 |
+
/**
|
702 |
+
* Convert to array from newline delimiter $choices
|
703 |
+
*
|
704 |
+
* @param string $choices
|
705 |
+
* @return array
|
706 |
+
*/
|
707 |
+
public static function choices_eol_to_array( $choices ) {
|
708 |
+
if ( !is_array( $choices ) ) {
|
709 |
+
if ( $choices === '' || $choices === false || $choices === null ) {
|
710 |
+
return array();
|
711 |
+
}
|
712 |
+
$_choices = str_replace( array( "\r\n", "\r", "\n" ), "\n", $choices );
|
713 |
+
$_choices = explode( "\n", $_choices );
|
714 |
+
$choices = array();
|
715 |
+
foreach ( $_choices as $_choice ) {
|
716 |
+
$_choice = array_map( 'trim', explode( '=>', $_choice ) );
|
717 |
+
if ( count( $_choice ) === 2 ) {
|
718 |
+
$choices[$_choice[0]] = $_choice[1];
|
719 |
+
} else {
|
720 |
+
$choices = array_merge( $choices, $_choice );
|
721 |
+
}
|
722 |
+
}
|
723 |
+
}
|
724 |
+
return $choices;
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
* Return generated Setting object
|
729 |
+
*
|
730 |
+
* @param string $id
|
731 |
+
* @param string $title
|
732 |
+
* @return Smart_Custom_Fields_Setting
|
733 |
+
*/
|
734 |
+
public static function add_setting( $id, $title ) {
|
735 |
+
return new Smart_Custom_Fields_Setting( $id, $title );
|
736 |
+
}
|
737 |
+
|
738 |
+
/**
|
739 |
+
* Adding custom options page
|
740 |
+
*
|
741 |
+
* @see https://developer.wordpress.org/reference/functions/add_menu_page/
|
742 |
+
* @param string $page_title
|
743 |
+
* @param string $menu_title
|
744 |
+
* @param string $capability
|
745 |
+
* @param string $menu_slug
|
746 |
+
* @param string $icon_url
|
747 |
+
* @param int $position
|
748 |
+
* @return $menu_slug
|
749 |
+
*/
|
750 |
+
public static function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $icon_url = '', $position = null ) {
|
751 |
+
self::$options_pages[$menu_slug] = $menu_title;
|
752 |
+
new Smart_Custom_Fields_Options_Page( $page_title, $menu_title, $capability, $menu_slug, $icon_url, $position );
|
753 |
+
return $menu_slug;
|
754 |
+
}
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Return array of custom options pages
|
758 |
+
*
|
759 |
+
* @return array
|
760 |
+
*/
|
761 |
+
public static function get_options_pages() {
|
762 |
+
return self::$options_pages;
|
763 |
+
}
|
764 |
+
|
765 |
+
/**
|
766 |
+
* Generate WP_Post object
|
767 |
+
*
|
768 |
+
* @param int $post_id
|
769 |
+
* @param string $post_type
|
770 |
+
* @return WP_Post
|
771 |
+
*/
|
772 |
+
public static function generate_post_object( $post_id, $post_type = null ) {
|
773 |
+
$Post = new stdClass();
|
774 |
+
$Post->ID = $post_id;
|
775 |
+
$Post->post_type = $post_type;
|
776 |
+
return new WP_Post( $Post );
|
777 |
+
}
|
778 |
+
|
779 |
+
/**
|
780 |
+
* Generate option object
|
781 |
+
*
|
782 |
+
* @param string $menu_slug
|
783 |
+
* @return stdClass
|
784 |
+
*/
|
785 |
+
public static function generate_option_object( $menu_slug ) {
|
786 |
+
$options_pages = SCF::get_options_pages();
|
787 |
+
if ( !isset( $options_pages[$menu_slug] ) ) {
|
788 |
+
return;
|
789 |
+
}
|
790 |
+
$Option = new stdClass();
|
791 |
+
$Option->menu_slug = $menu_slug;
|
792 |
+
$Option->menu_title = $options_pages[$menu_slug];
|
793 |
+
return $Option;
|
794 |
+
}
|
795 |
+
|
796 |
+
/**
|
797 |
+
* Print cache usage
|
798 |
+
*/
|
799 |
+
protected static function debug_cache_message( $message ) {
|
800 |
+
if ( defined( 'SCF_DEBUG_CACHE' ) && SCF_DEBUG_CACHE === true ) {
|
801 |
+
echo $message . '<br />';
|
802 |
+
}
|
803 |
+
}
|
804 |
+
}
|
trunk/classes/controller/class.controller-base.php
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Controller_Base
|
4 |
+
* Version : 1.4.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : April 27, 2015
|
7 |
+
* Modified : June 4, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Controller_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Array of the form field objects
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
protected $fields = array();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* __construct
|
21 |
+
*/
|
22 |
+
public function __construct() {
|
23 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Loading resources for edit page.
|
28 |
+
*
|
29 |
+
* @param string $hook
|
30 |
+
*/
|
31 |
+
public function admin_enqueue_scripts( $hook ) {
|
32 |
+
do_action( SCF_Config::PREFIX . 'before-editor-enqueue-scripts' );
|
33 |
+
wp_enqueue_style(
|
34 |
+
SCF_Config::PREFIX . 'editor',
|
35 |
+
plugins_url( SCF_Config::NAME ) . '/css/editor.css'
|
36 |
+
);
|
37 |
+
wp_enqueue_media();
|
38 |
+
wp_enqueue_script(
|
39 |
+
SCF_Config::PREFIX . 'editor',
|
40 |
+
plugins_url( SCF_Config::NAME ) . '/js/editor.js',
|
41 |
+
array( 'jquery' ),
|
42 |
+
null,
|
43 |
+
true
|
44 |
+
);
|
45 |
+
wp_localize_script( SCF_Config::PREFIX . 'editor', 'smart_cf_uploader', array(
|
46 |
+
'image_uploader_title' => esc_html__( 'Image setting', 'smart-custom-fields' ),
|
47 |
+
'file_uploader_title' => esc_html__( 'File setting', 'smart-custom-fields' ),
|
48 |
+
) );
|
49 |
+
do_action( SCF_Config::PREFIX . 'after-editor-enqueue-scripts' );
|
50 |
+
|
51 |
+
if ( !user_can_richedit() ) {
|
52 |
+
wp_enqueue_script(
|
53 |
+
'tinymce',
|
54 |
+
includes_url( '/js/tinymce/tinymce.min.js' ),
|
55 |
+
array(),
|
56 |
+
null,
|
57 |
+
true
|
58 |
+
);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Display custom fields in edit page.
|
64 |
+
*
|
65 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
66 |
+
* @param array $callback_args custom field setting information
|
67 |
+
*/
|
68 |
+
public function display_meta_box( $object, $callback_args ) {
|
69 |
+
$groups = $callback_args['args'];
|
70 |
+
$tables = $this->get_tables( $object, $groups );
|
71 |
+
|
72 |
+
printf( '<div class="%s">', esc_attr( SCF_Config::PREFIX . 'meta-box' ) );
|
73 |
+
$index = 0;
|
74 |
+
foreach ( $tables as $group_key => $Group ) {
|
75 |
+
$is_repeatable = $Group->is_repeatable();
|
76 |
+
if ( $is_repeatable && $index === 0 ) {
|
77 |
+
printf(
|
78 |
+
'<div class="%s">',
|
79 |
+
esc_attr( SCF_Config::PREFIX . 'meta-box-repeat-tables' )
|
80 |
+
);
|
81 |
+
$this->display_tr( $object, $is_repeatable, $Group->get_fields() );
|
82 |
+
}
|
83 |
+
$this->display_tr( $object, $is_repeatable, $Group->get_fields(), $index );
|
84 |
+
|
85 |
+
// If in the loop, count up the index.
|
86 |
+
// If exit the loop, reset the count.
|
87 |
+
if ( $is_repeatable &&
|
88 |
+
isset( $tables[$group_key + 1 ] ) &&
|
89 |
+
$tables[$group_key + 1 ]->get_name() === $Group->get_name() ) {
|
90 |
+
$index ++;
|
91 |
+
} else {
|
92 |
+
$index = 0;
|
93 |
+
}
|
94 |
+
if ( $is_repeatable && $index === 0 ) {
|
95 |
+
printf( '</div>' );
|
96 |
+
}
|
97 |
+
}
|
98 |
+
printf( '</div>' );
|
99 |
+
wp_nonce_field( SCF_Config::NAME . '-fields', SCF_Config::PREFIX . 'fields-nonce' );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Saving posted data
|
104 |
+
*
|
105 |
+
* @param array $data
|
106 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
107 |
+
*/
|
108 |
+
protected function save( $data, $object ) {
|
109 |
+
check_admin_referer(
|
110 |
+
SCF_Config::NAME . '-fields',
|
111 |
+
SCF_Config::PREFIX . 'fields-nonce'
|
112 |
+
);
|
113 |
+
|
114 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
115 |
+
$Meta->save( $_POST );
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Generating array for displaying the custom fields
|
120 |
+
*
|
121 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
122 |
+
* @param array $groups Settings from custom field settings page
|
123 |
+
* @return array $tables Array for displaying a table for custom fields
|
124 |
+
*/
|
125 |
+
protected function get_tables( $object, $groups ) {
|
126 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
127 |
+
|
128 |
+
$repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
|
129 |
+
$tables = array();
|
130 |
+
foreach ( $groups as $Group ) {
|
131 |
+
// If in the loop, Added groupgs by the amount of the loop.
|
132 |
+
// Added only one if setting is repetition but not loop (Ex, new registration)
|
133 |
+
if ( $Group->is_repeatable() === true ) {
|
134 |
+
$loop_count = 1;
|
135 |
+
$fields = $Group->get_fields();
|
136 |
+
foreach ( $fields as $Field ) {
|
137 |
+
$field_name = $Field->get( 'name' );
|
138 |
+
$meta = $Meta->get( $field_name );
|
139 |
+
if ( is_array( $meta ) ) {
|
140 |
+
$meta_count = count( $meta );
|
141 |
+
// When the same name of the custom field is a multiple (checbox or loop)
|
142 |
+
if ( $meta_count > 1 ) {
|
143 |
+
// checkbox
|
144 |
+
if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
|
145 |
+
if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[$field_name] ) ) {
|
146 |
+
$repeat_multiple_data_count = count( $repeat_multiple_data[$field_name] );
|
147 |
+
if ( $loop_count < $repeat_multiple_data_count ) {
|
148 |
+
$loop_count = $repeat_multiple_data_count;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
// other than checkbox
|
153 |
+
else {
|
154 |
+
if ( $loop_count < $meta_count ) {
|
155 |
+
$loop_count = $meta_count;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
if ( $loop_count >= 1 ) {
|
162 |
+
for ( $i = $loop_count; $i > 0; $i -- ) {
|
163 |
+
$tables[] = $Group;
|
164 |
+
}
|
165 |
+
continue;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
$tables[] = $Group;
|
169 |
+
}
|
170 |
+
return $tables;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Getting the multi-value field meta data.
|
175 |
+
*
|
176 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
177 |
+
* @param Smart_Custom_Fields_Field_Base $Field
|
178 |
+
* @param int $index
|
179 |
+
* @return array
|
180 |
+
*/
|
181 |
+
public function get_multiple_data_field_value( $object, $Field, $index ) {
|
182 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
183 |
+
$field_name = $Field->get( 'name' );
|
184 |
+
|
185 |
+
if ( is_null( $index ) ) {
|
186 |
+
return SCF::get_default_value( $Field );
|
187 |
+
}
|
188 |
+
|
189 |
+
if ( !$Meta->is_saved_the_key( $field_name ) ) {
|
190 |
+
return SCF::get_default_value( $Field );
|
191 |
+
}
|
192 |
+
|
193 |
+
$value = $Meta->get( $field_name );
|
194 |
+
|
195 |
+
// in the loop
|
196 |
+
$repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
|
197 |
+
if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[$field_name] ) ) {
|
198 |
+
$now_num = 0;
|
199 |
+
if ( is_array( $repeat_multiple_data[$field_name] ) && isset( $repeat_multiple_data[$field_name][$index] ) ) {
|
200 |
+
$now_num = $repeat_multiple_data[$field_name][$index];
|
201 |
+
}
|
202 |
+
|
203 |
+
// The index is starting point to refer to the total of the previous number than me ($index)
|
204 |
+
$_temp = array_slice( $repeat_multiple_data[$field_name], 0, $index );
|
205 |
+
$sum = array_sum( $_temp );
|
206 |
+
$start = $sum;
|
207 |
+
|
208 |
+
if ( $now_num ) {
|
209 |
+
$value = array_slice( $value, $start, $now_num );
|
210 |
+
} else {
|
211 |
+
$value = array();
|
212 |
+
}
|
213 |
+
}
|
214 |
+
return $value;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Getting the non multi-value field meta data.
|
219 |
+
*
|
220 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
221 |
+
* @param Smart_Custom_Fields_Field_Base $Field
|
222 |
+
* @param int $index
|
223 |
+
* @return string
|
224 |
+
*/
|
225 |
+
public function get_single_data_field_value( $object, $Field, $index ) {
|
226 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
227 |
+
$field_name = $Field->get( 'name' );
|
228 |
+
|
229 |
+
if ( is_null( $index ) ) {
|
230 |
+
return SCF::get_default_value( $Field, true );
|
231 |
+
}
|
232 |
+
|
233 |
+
if ( $Meta->is_saved_the_key( $field_name ) ) {
|
234 |
+
$value = $Meta->get( $field_name );
|
235 |
+
if ( isset( $value[$index] ) ) {
|
236 |
+
return $value[$index];
|
237 |
+
}
|
238 |
+
return '';
|
239 |
+
}
|
240 |
+
return SCF::get_default_value( $Field, true );
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Displaying tr element for table of custom fields
|
245 |
+
*
|
246 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
247 |
+
* @param bool $is_repeat
|
248 |
+
* @param array $fields
|
249 |
+
* @param int, null $index
|
250 |
+
*/
|
251 |
+
protected function display_tr( $object, $is_repeat, $fields, $index = null ) {
|
252 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
253 |
+
|
254 |
+
$btn_repeat = '';
|
255 |
+
if ( $is_repeat ) {
|
256 |
+
$btn_repeat = sprintf(
|
257 |
+
'<span class="%s"></span>',
|
258 |
+
esc_attr( SCF_Config::PREFIX . 'icon-handle dashicons dashicons-menu' )
|
259 |
+
);
|
260 |
+
$btn_repeat .= '<span class="btn-add-repeat-group dashicons dashicons-plus-alt '.SCF_Config::PREFIX.'repeat-btn"></span>';
|
261 |
+
$btn_repeat .= ' <span class="btn-remove-repeat-group dashicons dashicons-dismiss '.SCF_Config::PREFIX.'repeat-btn"></span>';
|
262 |
+
}
|
263 |
+
|
264 |
+
$style = '';
|
265 |
+
if ( is_null( $index ) ) {
|
266 |
+
$style = 'style="display: none;"';
|
267 |
+
}
|
268 |
+
|
269 |
+
printf(
|
270 |
+
'<div class="%s" %s>%s',
|
271 |
+
esc_attr( SCF_Config::PREFIX . 'meta-box-table' ),
|
272 |
+
$style,
|
273 |
+
$btn_repeat
|
274 |
+
);
|
275 |
+
|
276 |
+
foreach ( $fields as $Field ) {
|
277 |
+
$display_name = $Field->get_attribute( 'display-name' );
|
278 |
+
$field_type = $Field->get_attribute( 'type' ); // gets the field type for use in aditional CSS classes
|
279 |
+
$layout = $Field->get_attribute( 'layout' ); // get layout type
|
280 |
+
$field_name = $Field->get( 'name' );
|
281 |
+
$field_label = $Field->get( 'label' );
|
282 |
+
if ( !$field_label ) {
|
283 |
+
$field_label = $field_name;
|
284 |
+
}
|
285 |
+
|
286 |
+
// When multi-value field
|
287 |
+
if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
|
288 |
+
$value = $this->get_multiple_data_field_value( $object, $Field, $index );
|
289 |
+
}
|
290 |
+
// When non multi-value field
|
291 |
+
else {
|
292 |
+
$value = $this->get_single_data_field_value( $object, $Field, $index );
|
293 |
+
}
|
294 |
+
|
295 |
+
$instruction = $Field->get( 'instruction' );
|
296 |
+
if ( !empty( $instruction ) ) {
|
297 |
+
if ( apply_filters( SCF_Config::PREFIX . 'instruction-apply-html', false ) === true ) {
|
298 |
+
$instruction_html = $instruction;
|
299 |
+
} else {
|
300 |
+
$instruction_html = esc_html( $instruction );
|
301 |
+
}
|
302 |
+
$instruction = sprintf(
|
303 |
+
'<div class="instruction">%s</div>',
|
304 |
+
$instruction_html
|
305 |
+
);
|
306 |
+
}
|
307 |
+
|
308 |
+
$notes = $Field->get( 'notes' );
|
309 |
+
if ( !empty( $notes ) ) {
|
310 |
+
$notes = sprintf(
|
311 |
+
'<p class="description">%s</p>',
|
312 |
+
esc_html( $notes )
|
313 |
+
);
|
314 |
+
}
|
315 |
+
|
316 |
+
$form_field = $Field->get_field( $index, $value );
|
317 |
+
|
318 |
+
// if the layout type is full-width, it hides the "Table Header" (th)
|
319 |
+
$table_th = $layout != 'full-width' ? '<th>'.esc_html( $field_label ).'</th>' : '';
|
320 |
+
printf(
|
321 |
+
'<table class="%1$sfield-type-%6$s %1$slayout-type-%7$s"><tr>
|
322 |
+
%2$s
|
323 |
+
<td>
|
324 |
+
%3$s
|
325 |
+
%4$s
|
326 |
+
%5$s
|
327 |
+
</td>
|
328 |
+
</tr></table>',
|
329 |
+
SCF_Config::PREFIX,
|
330 |
+
$table_th,
|
331 |
+
$instruction,
|
332 |
+
$form_field,
|
333 |
+
$notes,
|
334 |
+
$field_type,
|
335 |
+
$layout
|
336 |
+
);
|
337 |
+
}
|
338 |
+
echo '</div>';
|
339 |
+
}
|
340 |
+
}
|
trunk/classes/controller/class.editor.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Controller_Editor
|
4 |
+
* Version : 1.1.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : September 23, 2014
|
7 |
+
* Modified : April 28, 2015
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Controller_Editor extends Smart_Custom_Fields_Controller_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* __construct
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
parent::__construct();
|
18 |
+
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 10, 2 );
|
19 |
+
add_action( 'save_post' , array( $this, 'save_post' ) );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Displaying custom fields in post edit page
|
24 |
+
*
|
25 |
+
* @param string $post_type
|
26 |
+
* @param WP_Post $post
|
27 |
+
*/
|
28 |
+
public function add_meta_boxes( $post_type, $post ) {
|
29 |
+
$settings = SCF::get_settings( $post );
|
30 |
+
foreach ( $settings as $Setting ) {
|
31 |
+
add_meta_box(
|
32 |
+
SCF_Config::PREFIX . 'custom-field-' . $Setting->get_id(),
|
33 |
+
$Setting->get_title(),
|
34 |
+
array( $this, 'display_meta_box' ),
|
35 |
+
$post_type,
|
36 |
+
'normal',
|
37 |
+
'default',
|
38 |
+
$Setting->get_groups()
|
39 |
+
);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Saving meta data from custom fields in post edit page
|
45 |
+
*
|
46 |
+
* @param int $post_id
|
47 |
+
*/
|
48 |
+
public function save_post( $post_id ) {
|
49 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
if ( wp_is_post_autosave( $post_id ) || wp_is_post_revision( $post_id ) ){
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
if ( !isset( $_POST[SCF_Config::NAME] ) ) {
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
$this->save( $_POST, get_post( $post_id ) );
|
60 |
+
}
|
61 |
+
}
|
trunk/classes/controller/class.option.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Controller_Option
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : May 29, 2014
|
7 |
+
* Modified :
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Controller_Option extends Smart_Custom_Fields_Controller_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* __construct
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
parent::__construct();
|
18 |
+
add_action( SCF_Config::PREFIX . 'custom-options-page', array( $this, 'save_option' ) );
|
19 |
+
add_action( SCF_Config::PREFIX . 'custom-options-page', array( $this, 'custom_options_page' ) );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Loading resources for term edit page
|
24 |
+
*
|
25 |
+
* @param string $hook
|
26 |
+
*/
|
27 |
+
public function admin_enqueue_scripts( $hook ) {
|
28 |
+
parent::admin_enqueue_scripts( $hook );
|
29 |
+
wp_enqueue_style(
|
30 |
+
SCF_Config::PREFIX . 'option',
|
31 |
+
plugins_url( SCF_Config::NAME ) . '/css/option.css'
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Displaying custom fields in custom options page
|
37 |
+
*
|
38 |
+
* @param stdClass $Option
|
39 |
+
*/
|
40 |
+
public function custom_options_page( $Option ) {
|
41 |
+
$settings = SCF::get_settings( $Option );
|
42 |
+
if ( !$settings ) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
?>
|
46 |
+
<form method="post" action="">
|
47 |
+
<?php foreach ( $settings as $Setting ) : ?>
|
48 |
+
<?php $callback_args['args'] = $Setting->get_groups(); ?>
|
49 |
+
<table class="form-table">
|
50 |
+
<tr>
|
51 |
+
<th scope="row"><?php echo esc_html( $Setting->get_title() ); ?></th>
|
52 |
+
<td><?php $this->display_meta_box( $Option, $callback_args ); ?></td>
|
53 |
+
</tr>
|
54 |
+
</table>
|
55 |
+
<?php endforeach; ?>
|
56 |
+
<p class="submit">
|
57 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save settings', 'smart-custom-fields' ); ?>">
|
58 |
+
</p>
|
59 |
+
</form>
|
60 |
+
<?php
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Saving meta data from custom fields in custom options page
|
65 |
+
*
|
66 |
+
* @param stdClass $Option
|
67 |
+
*/
|
68 |
+
public function save_option( $Option ) {
|
69 |
+
if ( !isset( $_POST[SCF_Config::NAME] ) ) {
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
$this->save( $_POST, $Option );
|
74 |
+
}
|
75 |
+
}
|
trunk/classes/controller/class.profile.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Controller_Profile
|
4 |
+
* Version : 1.0.1
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : March 16, 2015
|
7 |
+
* Modified : April 26, 2015
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Controller_Profile extends Smart_Custom_Fields_Controller_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* __construct
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
parent::__construct();
|
18 |
+
add_action( 'show_user_profile', array( $this, 'user_profile' ) );
|
19 |
+
add_action( 'edit_user_profile', array( $this, 'user_profile' ) );
|
20 |
+
add_action( 'personal_options_update', array( $this, 'update' ) );
|
21 |
+
add_action( 'edit_user_profile_update', array( $this, 'update' ) );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Loading resources for profile edit page
|
26 |
+
*
|
27 |
+
* @param string $hook
|
28 |
+
*/
|
29 |
+
public function admin_enqueue_scripts( $hook ) {
|
30 |
+
parent::admin_enqueue_scripts( $hook );
|
31 |
+
wp_enqueue_style(
|
32 |
+
SCF_Config::PREFIX . 'profile',
|
33 |
+
plugins_url( SCF_Config::NAME ) . '/css/profile.css'
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Displaying custom fields
|
39 |
+
*
|
40 |
+
* @param WP_User $user
|
41 |
+
*/
|
42 |
+
public function user_profile( $user ) {
|
43 |
+
printf( '<h3>%s</h3>', esc_html__( 'Custom Fields', 'smart-custom-fields' ) );
|
44 |
+
$settings = SCF::get_settings( $user );
|
45 |
+
foreach ( $settings as $Setting ) {
|
46 |
+
$callback_args['args'] = $Setting->get_groups();
|
47 |
+
?>
|
48 |
+
<table class="form-table">
|
49 |
+
<tr>
|
50 |
+
<th scope="row"><?php echo esc_html( $Setting->get_title() ); ?></th>
|
51 |
+
<td><?php $this->display_meta_box( $user, $callback_args ); ?></td>
|
52 |
+
</tr>
|
53 |
+
</table>
|
54 |
+
<?php
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Saving meta data from custom fields in profile edit page.
|
60 |
+
*
|
61 |
+
* @param int $user_id
|
62 |
+
*/
|
63 |
+
public function update( $user_id ) {
|
64 |
+
if ( !current_user_can( 'edit_user', $user_id ) ) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
if ( !isset( $_POST[SCF_Config::NAME] ) ) {
|
68 |
+
return;
|
69 |
+
}
|
70 |
+
|
71 |
+
$this->save( $_POST, get_userdata( $user_id ) );
|
72 |
+
}
|
73 |
+
}
|
trunk/classes/controller/class.settings.php
ADDED
@@ -0,0 +1,411 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Controller_Settings
|
4 |
+
* Version : 1.3.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : September 23, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Controller_Settings {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Selectbox choices of the field selection
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
private $optgroups = array();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* __construct
|
21 |
+
*/
|
22 |
+
public function __construct() {
|
23 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
24 |
+
add_action( 'save_post', array( $this, 'save_post' ) );
|
25 |
+
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
26 |
+
|
27 |
+
$this->optgroups = array(
|
28 |
+
'basic-fields' => array(
|
29 |
+
'label' => esc_attr__( 'Basic fields', 'smart-custom-fields' ),
|
30 |
+
'options' => array(),
|
31 |
+
),
|
32 |
+
'select-fields' => array(
|
33 |
+
'label' => esc_attr__( 'Select fields', 'smart-custom-fields' ),
|
34 |
+
'options' => array(),
|
35 |
+
),
|
36 |
+
'content-fields' => array(
|
37 |
+
'label' => esc_attr__( 'Content fields', 'smart-custom-fields' ),
|
38 |
+
'options' => array(),
|
39 |
+
),
|
40 |
+
'other-fields' => array(
|
41 |
+
'label' => esc_attr__( 'Other fields', 'smart-custom-fields' ),
|
42 |
+
'options' => array(),
|
43 |
+
),
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Loading resources
|
49 |
+
*/
|
50 |
+
public function admin_enqueue_scripts() {
|
51 |
+
do_action( SCF_Config::PREFIX . 'before-settings-enqueue-scripts' );
|
52 |
+
|
53 |
+
wp_enqueue_style(
|
54 |
+
SCF_Config::PREFIX . 'settings',
|
55 |
+
plugins_url( SCF_Config::NAME ) . '/css/settings.css',
|
56 |
+
array(),
|
57 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../css/settings.css' ) )
|
58 |
+
);
|
59 |
+
|
60 |
+
wp_enqueue_script(
|
61 |
+
SCF_Config::PREFIX . 'settings',
|
62 |
+
plugins_url( SCF_Config::NAME ) . '/js/settings.js',
|
63 |
+
array( 'jquery' ),
|
64 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/settings.js' ) ),
|
65 |
+
true
|
66 |
+
);
|
67 |
+
|
68 |
+
wp_localize_script( SCF_Config::PREFIX . 'settings', 'smart_cf_settings', array(
|
69 |
+
'duplicate_alert' => esc_html__( 'Same name exists!', 'smart-custom-fields' ),
|
70 |
+
) );
|
71 |
+
|
72 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
73 |
+
do_action( SCF_Config::PREFIX . 'after-settings-enqueue-scripts' );
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Adding meta boxes
|
78 |
+
*/
|
79 |
+
public function add_meta_boxes() {
|
80 |
+
add_meta_box(
|
81 |
+
SCF_Config::PREFIX . 'meta-box',
|
82 |
+
__( 'Custom Fields', 'smart-custom-fields' ),
|
83 |
+
array( $this, 'display_meta_box' ),
|
84 |
+
SCF_Config::NAME
|
85 |
+
);
|
86 |
+
add_meta_box(
|
87 |
+
SCF_Config::PREFIX . 'meta-box-condition-post',
|
88 |
+
__( 'Display conditions ( Post )', 'smart-custom-fields' ),
|
89 |
+
array( $this, 'display_meta_box_condition_post' ),
|
90 |
+
SCF_Config::NAME,
|
91 |
+
'side'
|
92 |
+
);
|
93 |
+
add_meta_box(
|
94 |
+
SCF_Config::PREFIX . 'meta-box-condition-profile',
|
95 |
+
__( 'Display conditions ( Profile )', 'smart-custom-fields' ),
|
96 |
+
array( $this, 'display_meta_box_condition_profile' ),
|
97 |
+
SCF_Config::NAME,
|
98 |
+
'side'
|
99 |
+
);
|
100 |
+
add_meta_box(
|
101 |
+
SCF_Config::PREFIX . 'meta-box-condition-taxonomy',
|
102 |
+
__( 'Display conditions ( Taxonomy )', 'smart-custom-fields' ),
|
103 |
+
array( $this, 'display_meta_box_condition_taxonomy' ),
|
104 |
+
SCF_Config::NAME,
|
105 |
+
'side'
|
106 |
+
);
|
107 |
+
add_meta_box(
|
108 |
+
SCF_Config::PREFIX . 'meta-box-condition-options-page',
|
109 |
+
__( 'Display conditions ( Options page )', 'smart-custom-fields' ),
|
110 |
+
array( $this, 'display_meta_box_condition_options_page' ),
|
111 |
+
SCF_Config::NAME,
|
112 |
+
'side'
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Displaying "hide" if $key isn't empty
|
118 |
+
*
|
119 |
+
* @param string $key
|
120 |
+
*/
|
121 |
+
private function add_hide_class( $key ) {
|
122 |
+
if ( !$key ) {
|
123 |
+
echo 'hide';
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Displaying custom fields
|
129 |
+
*/
|
130 |
+
public function display_meta_box() {
|
131 |
+
$Setting = SCF::add_setting( get_the_ID(), get_the_title() );
|
132 |
+
$Setting->add_group_unshift();
|
133 |
+
$groups = $Setting->get_groups();
|
134 |
+
?>
|
135 |
+
<div class="<?php echo esc_attr( SCF_Config::PREFIX . 'fields-wrapper' ); ?>">
|
136 |
+
<div class="<?php echo esc_attr( SCF_Config::PREFIX . 'groups' ); ?>">
|
137 |
+
<?php foreach ( $groups as $group_key => $Group ) : ?>
|
138 |
+
<?php
|
139 |
+
$fields = $Group->get_fields();
|
140 |
+
array_unshift( $fields, SCF::get_form_field_instance( 'text' ) );
|
141 |
+
?>
|
142 |
+
<div class="<?php echo esc_attr( SCF_Config::PREFIX . 'group' ); ?> <?php $this->add_hide_class( $group_key ); ?>">
|
143 |
+
<div class="btn-remove-group"><span class="dashicons dashicons-no-alt"></span></div>
|
144 |
+
<?php $Group->display_options( $group_key ); ?>
|
145 |
+
|
146 |
+
<div class="<?php echo esc_attr( SCF_Config::PREFIX . 'fields' ); ?>">
|
147 |
+
<?php foreach ( $fields as $field_key => $Field ) : ?>
|
148 |
+
<div class="<?php echo esc_attr( SCF_Config::PREFIX . 'field' ); ?> <?php $this->add_hide_class( $field_key ); ?>">
|
149 |
+
<?php
|
150 |
+
$field_name = $Field->get( 'name' );
|
151 |
+
$field_label = $Field->get( 'label' );
|
152 |
+
if ( !$field_label ) {
|
153 |
+
$field_label = $field_name;
|
154 |
+
if ( !$field_label ) {
|
155 |
+
$field_label = " ";
|
156 |
+
}
|
157 |
+
}
|
158 |
+
?>
|
159 |
+
<div class="<?php echo esc_attr( SCF_Config::PREFIX . 'icon-handle' ); ?>"></div>
|
160 |
+
<b class="btn-remove-field"><span class="dashicons dashicons-no-alt"></span></b>
|
161 |
+
<div class="field-label">
|
162 |
+
<?php echo esc_html( $field_label ); ?>
|
163 |
+
<?php if ( $field_name ) : ?>
|
164 |
+
<small>[ <?php echo esc_html( $field_name ); ?> ]</small>
|
165 |
+
<?php endif; ?>
|
166 |
+
</div>
|
167 |
+
<table class="<?php $this->add_hide_class( !$Field->get( 'name' ) ); ?>">
|
168 |
+
<tr>
|
169 |
+
<th><?php esc_html_e( 'Type', 'smart-custom-fields' ); ?><span class="<?php echo esc_attr( SCF_Config::PREFIX . 'require' ); ?>">*</span></th>
|
170 |
+
<td>
|
171 |
+
<select
|
172 |
+
name="<?php echo esc_attr( $Field->get_field_name_in_setting( $group_key, $field_key, 'type' ) ); ?>"
|
173 |
+
class="<?php echo esc_attr( SCF_Config::PREFIX . 'field-select' ); ?>" />
|
174 |
+
<?php
|
175 |
+
foreach ( $this->optgroups as $optgroup_name => $optgroup_values ) {
|
176 |
+
$optgroup_fields = array();
|
177 |
+
$optgroup_values['options'] = apply_filters(
|
178 |
+
SCF_Config::PREFIX . 'field-select-' . $optgroup_name,
|
179 |
+
$optgroup_values['options']
|
180 |
+
);
|
181 |
+
foreach ( $optgroup_values['options'] as $option_key => $option ) {
|
182 |
+
$optgroup_fields[] = sprintf(
|
183 |
+
'<option value="%s" %s>%s</option>',
|
184 |
+
esc_attr( $option_key ),
|
185 |
+
selected( $Field->get_attribute( 'type' ), $option_key, false ),
|
186 |
+
esc_html( $option )
|
187 |
+
);
|
188 |
+
}
|
189 |
+
printf(
|
190 |
+
'<optgroup label="%s">%s</optgroup>',
|
191 |
+
$optgroup_values['label'],
|
192 |
+
implode( '', $optgroup_fields )
|
193 |
+
);
|
194 |
+
}
|
195 |
+
?>
|
196 |
+
</select>
|
197 |
+
</td>
|
198 |
+
</tr>
|
199 |
+
<?php $Field->display_options( $group_key, $field_key ); ?>
|
200 |
+
</table>
|
201 |
+
</div>
|
202 |
+
<?php endforeach; ?>
|
203 |
+
</div>
|
204 |
+
<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>
|
205 |
+
</div>
|
206 |
+
<?php endforeach; ?>
|
207 |
+
</div>
|
208 |
+
<div class="button btn-add-group"><?php esc_html_e( 'Add Field', 'smart-custom-fields' ); ?></div>
|
209 |
+
</div>
|
210 |
+
<?php wp_nonce_field( SCF_Config::NAME . '-settings', SCF_Config::PREFIX . 'settings-nonce' ) ?>
|
211 |
+
<?php
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Displaying the meta box to set the display conditions for post edit page
|
216 |
+
*/
|
217 |
+
public function display_meta_box_condition_post() {
|
218 |
+
$post_types = get_post_types( array(
|
219 |
+
'show_ui' => true,
|
220 |
+
), 'objects' );
|
221 |
+
unset( $post_types['attachment'] );
|
222 |
+
unset( $post_types[SCF_Config::NAME] );
|
223 |
+
|
224 |
+
$conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'condition', true );
|
225 |
+
$post_type_field = '';
|
226 |
+
foreach ( $post_types as $post_type => $post_type_object ) {
|
227 |
+
$current = ( is_array( $conditions ) && in_array( $post_type, $conditions ) ) ? $post_type : false;
|
228 |
+
$post_type_field .= sprintf(
|
229 |
+
'<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
|
230 |
+
esc_attr( SCF_Config::PREFIX . 'condition[]' ),
|
231 |
+
esc_attr( $post_type ),
|
232 |
+
checked( $current, $post_type, false ),
|
233 |
+
esc_attr( $post_type_object->labels->singular_name )
|
234 |
+
);
|
235 |
+
}
|
236 |
+
printf(
|
237 |
+
'<p><b>%s</b>%s</p>',
|
238 |
+
esc_html__( 'Post Types', 'smart-custom-fields' ),
|
239 |
+
$post_type_field
|
240 |
+
);
|
241 |
+
|
242 |
+
$condition_post_ids = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'condition-post-ids', true );
|
243 |
+
printf(
|
244 |
+
'<p><b>%s</b><input type="text" name="%s" value="%s" class="widefat" /></p>',
|
245 |
+
esc_html__( 'Post Ids ( Comma separated )', 'smart-custom-fields' ),
|
246 |
+
esc_attr( SCF_Config::PREFIX . 'condition-post-ids' ),
|
247 |
+
$condition_post_ids
|
248 |
+
);
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Displaying the meta box to set the display conditions for profile edit page
|
253 |
+
*/
|
254 |
+
public function display_meta_box_condition_profile() {
|
255 |
+
$roles = get_editable_roles();
|
256 |
+
$conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'roles', true );
|
257 |
+
$profile_field = '';
|
258 |
+
foreach ( $roles as $name => $role ) {
|
259 |
+
$current = ( is_array( $conditions ) && in_array( $name, $conditions ) ) ? $name : false;
|
260 |
+
$profile_field .= sprintf(
|
261 |
+
'<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
|
262 |
+
esc_attr( SCF_Config::PREFIX . 'roles[]' ),
|
263 |
+
esc_attr( $name ),
|
264 |
+
checked( $current, $name, false ),
|
265 |
+
esc_html__( $role['name'], 'smart-custom-fields' )
|
266 |
+
);
|
267 |
+
}
|
268 |
+
printf(
|
269 |
+
'<p><b>%s</b>%s</p>',
|
270 |
+
esc_html__( 'Roles', 'smart-custom-fields' ),
|
271 |
+
$profile_field
|
272 |
+
);
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Displaying the meta box to set the display conditions for term edit page
|
277 |
+
*/
|
278 |
+
public function display_meta_box_condition_taxonomy() {
|
279 |
+
$taxonomies = get_taxonomies( array(
|
280 |
+
'show_ui' => true,
|
281 |
+
), 'objects' );
|
282 |
+
$conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'taxonomies', true );
|
283 |
+
$taxonomy_field = '';
|
284 |
+
foreach ( $taxonomies as $name => $taxonomy ) {
|
285 |
+
$current = ( is_array( $conditions ) && in_array( $name, $conditions ) ) ? $name : false;
|
286 |
+
$taxonomy_field .= sprintf(
|
287 |
+
'<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
|
288 |
+
esc_attr( SCF_Config::PREFIX . 'taxonomies[]' ),
|
289 |
+
esc_attr( $name ),
|
290 |
+
checked( $current, $name, false ),
|
291 |
+
esc_html__( $taxonomy->label, 'smart-custom-fields' )
|
292 |
+
);
|
293 |
+
}
|
294 |
+
printf(
|
295 |
+
'<p><b>%s</b>%s</p>',
|
296 |
+
esc_html__( 'Taxonomies', 'smart-custom-fields' ),
|
297 |
+
$taxonomy_field
|
298 |
+
);
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Displaying the meta box to set the display conditions for custom options page
|
303 |
+
*/
|
304 |
+
public function display_meta_box_condition_options_page() {
|
305 |
+
$optinos_pages = SCF::get_options_pages();
|
306 |
+
$conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'options-pages', true );
|
307 |
+
$options_page_field = '';
|
308 |
+
foreach ( $optinos_pages as $name => $optinos_page ) {
|
309 |
+
$current = ( is_array( $conditions ) && in_array( $name, $conditions ) ) ? $name : false;
|
310 |
+
$options_page_field .= sprintf(
|
311 |
+
'<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
|
312 |
+
esc_attr( SCF_Config::PREFIX . 'options-pages[]' ),
|
313 |
+
esc_attr( $name ),
|
314 |
+
checked( $current, $name, false ),
|
315 |
+
esc_html( $optinos_page )
|
316 |
+
);
|
317 |
+
}
|
318 |
+
printf(
|
319 |
+
'<p><b>%s</b>%s</p>',
|
320 |
+
esc_html__( 'Options pages', 'smart-custom-fields' ),
|
321 |
+
$options_page_field
|
322 |
+
);
|
323 |
+
}
|
324 |
+
|
325 |
+
/**
|
326 |
+
* Saving settings
|
327 |
+
*
|
328 |
+
* @param int $post_id
|
329 |
+
*/
|
330 |
+
public function save_post( $post_id ) {
|
331 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
332 |
+
return;
|
333 |
+
}
|
334 |
+
if ( !isset( $_POST[SCF_Config::NAME] ) ) {
|
335 |
+
return;
|
336 |
+
}
|
337 |
+
check_admin_referer(
|
338 |
+
SCF_Config::NAME . '-settings',
|
339 |
+
SCF_Config::PREFIX . 'settings-nonce'
|
340 |
+
);
|
341 |
+
|
342 |
+
$data = array();
|
343 |
+
foreach ( $_POST[SCF_Config::NAME] as $group_key => $group_value ) {
|
344 |
+
// $group_key = 0 is hidden field so don't save
|
345 |
+
if ( $group_key === 0 ) {
|
346 |
+
continue;
|
347 |
+
}
|
348 |
+
if ( !empty( $group_value['fields'] ) && count( $group_value['fields'] ) > 1 ) {
|
349 |
+
$fields = array();
|
350 |
+
foreach ( $group_value['fields'] as $field_key => $field_value ) {
|
351 |
+
// $field_key = 0 is hidden field so don't save
|
352 |
+
if ( $field_key === 0 ) {
|
353 |
+
continue;
|
354 |
+
}
|
355 |
+
if ( !empty( $field_value['name'] ) ) {
|
356 |
+
$fields[] = $field_value;
|
357 |
+
}
|
358 |
+
}
|
359 |
+
if ( !$fields ) {
|
360 |
+
continue;
|
361 |
+
}
|
362 |
+
|
363 |
+
if ( !empty( $group_value['repeat'] ) && $group_value['repeat'] === 'true' ) {
|
364 |
+
$group_value['repeat'] = true;
|
365 |
+
} else {
|
366 |
+
$group_value['repeat'] = false;
|
367 |
+
}
|
368 |
+
|
369 |
+
// If "repeat" isn't true, empty name
|
370 |
+
// If "repeat" is true and name is empty, assign index
|
371 |
+
if ( !( isset( $group_value['repeat'] ) && $group_value['repeat'] === true && !empty( $group_value['group-name'] ) ) ) {
|
372 |
+
$group_value['group-name'] = $group_key;
|
373 |
+
}
|
374 |
+
|
375 |
+
$group_value['fields'] = $fields;
|
376 |
+
$data[] = $group_value;
|
377 |
+
}
|
378 |
+
}
|
379 |
+
update_post_meta( $post_id, SCF_Config::PREFIX . 'setting', $data );
|
380 |
+
|
381 |
+
if ( !isset( $_POST[SCF_Config::PREFIX . 'condition'] ) ) {
|
382 |
+
delete_post_meta( $post_id, SCF_Config::PREFIX . 'condition' );
|
383 |
+
} else {
|
384 |
+
update_post_meta( $post_id, SCF_Config::PREFIX . 'condition', $_POST[SCF_Config::PREFIX . 'condition'] );
|
385 |
+
}
|
386 |
+
|
387 |
+
if ( !isset( $_POST[SCF_Config::PREFIX . 'condition-post-ids'] ) ) {
|
388 |
+
delete_post_meta( $post_id, SCF_Config::PREFIX . 'condition-post-ids' );
|
389 |
+
} else {
|
390 |
+
update_post_meta( $post_id, SCF_Config::PREFIX . 'condition-post-ids', $_POST[SCF_Config::PREFIX . 'condition-post-ids'] );
|
391 |
+
}
|
392 |
+
|
393 |
+
if ( !isset( $_POST[SCF_Config::PREFIX . 'roles'] ) ) {
|
394 |
+
delete_post_meta( $post_id, SCF_Config::PREFIX . 'roles' );
|
395 |
+
} else {
|
396 |
+
update_post_meta( $post_id, SCF_Config::PREFIX . 'roles', $_POST[SCF_Config::PREFIX . 'roles'] );
|
397 |
+
}
|
398 |
+
|
399 |
+
if ( !isset( $_POST[SCF_Config::PREFIX . 'taxonomies'] ) ) {
|
400 |
+
delete_post_meta( $post_id, SCF_Config::PREFIX . 'taxonomies' );
|
401 |
+
} else {
|
402 |
+
update_post_meta( $post_id, SCF_Config::PREFIX . 'taxonomies', $_POST[SCF_Config::PREFIX . 'taxonomies'] );
|
403 |
+
}
|
404 |
+
|
405 |
+
if ( !isset( $_POST[SCF_Config::PREFIX . 'options-pages'] ) ) {
|
406 |
+
delete_post_meta( $post_id, SCF_Config::PREFIX . 'options-pages' );
|
407 |
+
} else {
|
408 |
+
update_post_meta( $post_id, SCF_Config::PREFIX . 'options-pages', $_POST[SCF_Config::PREFIX . 'options-pages'] );
|
409 |
+
}
|
410 |
+
}
|
411 |
+
}
|
trunk/classes/controller/class.taxonomy.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Controller_Taxonomy
|
4 |
+
* Version : 1.0.1
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : April 26, 2015
|
7 |
+
* Modified : May 31, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Controller_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* __construct
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
parent::__construct();
|
18 |
+
|
19 |
+
add_action( $_REQUEST['taxonomy'] . '_edit_form_fields', array( $this, 'edit_form_fields' ) );
|
20 |
+
add_action( 'edited_terms' , array( $this, 'update' ), 10, 2 );
|
21 |
+
add_action( 'delete_term' , array( $this, 'delete' ), 10, 4 );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Loading resources for term edit page
|
26 |
+
*
|
27 |
+
* @param string $hook
|
28 |
+
*/
|
29 |
+
public function admin_enqueue_scripts( $hook ) {
|
30 |
+
parent::admin_enqueue_scripts( $hook );
|
31 |
+
wp_enqueue_style(
|
32 |
+
SCF_Config::PREFIX . 'taxonomy',
|
33 |
+
plugins_url( SCF_Config::NAME ) . '/css/taxonomy.css'
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Displaying custom fields in term edit page
|
39 |
+
*
|
40 |
+
* @param object $term
|
41 |
+
*/
|
42 |
+
public function edit_form_fields( $term ) {
|
43 |
+
$settings = SCF::get_settings( $term );
|
44 |
+
foreach ( $settings as $Setting ) {
|
45 |
+
$callback_args['args'] = $Setting->get_groups();
|
46 |
+
?>
|
47 |
+
<table class="form-table">
|
48 |
+
<tr>
|
49 |
+
<th scope="row"><?php echo esc_html( $Setting->get_title() ); ?></th>
|
50 |
+
<td><?php $this->display_meta_box( $term, $callback_args ); ?></td>
|
51 |
+
</tr>
|
52 |
+
</table>
|
53 |
+
<?php
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Saving meta data from custom fields in term edit page
|
59 |
+
*
|
60 |
+
* @param int $term_id
|
61 |
+
* @param string $taxonomy
|
62 |
+
*/
|
63 |
+
public function update( $term_id, $taxonomy ) {
|
64 |
+
if ( !current_user_can( 'manage_categories' ) ) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
if ( !isset( $_POST[SCF_Config::NAME] ) ) {
|
68 |
+
return;
|
69 |
+
}
|
70 |
+
|
71 |
+
$term = get_term( $term_id, $taxonomy );
|
72 |
+
$this->save( $_POST, $term );
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Delete meta data
|
77 |
+
*
|
78 |
+
* @param int $term_id
|
79 |
+
* @param int $term_taxonomy_id
|
80 |
+
* @param string $taxonomy
|
81 |
+
* @param object $deleted_term
|
82 |
+
*/
|
83 |
+
public function delete( $term_id, $term_taxonomy_id, $taxonomy, $deleted_term ) {
|
84 |
+
$Meta = new Smart_Custom_Fields_Meta( $deleted_term );
|
85 |
+
$Meta->delete();
|
86 |
+
}
|
87 |
+
}
|
trunk/classes/fields/class.field-boolean.php
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Boolean
|
4 |
+
* Version : 1.1.1
|
5 |
+
* Author : Toro_Unit, inc2734
|
6 |
+
* Created : April 6, 2015
|
7 |
+
* Modified : July 28, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
|
12 |
+
class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Set the required items
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
protected function init() {
|
20 |
+
add_filter( 'smart-cf-validate-get-value', array( $this, 'validate_get_value' ), 10, 2 );
|
21 |
+
return array(
|
22 |
+
'type' => 'boolean',
|
23 |
+
'display-name' => __( 'Boolean', 'smart-custom-fields' ),
|
24 |
+
'optgroup' => 'basic-fields',
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Set the non required items
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
protected function options() {
|
34 |
+
return array(
|
35 |
+
'default' => 0,
|
36 |
+
'instruction' => '',
|
37 |
+
'notes' => '',
|
38 |
+
'true_label' => __( 'Yes', 'smart-custom-fields' ),
|
39 |
+
'false_label' => __( 'No', 'smart-custom-fields' ),
|
40 |
+
);
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Getting the field
|
45 |
+
*
|
46 |
+
* @param int $index
|
47 |
+
* @param int $value
|
48 |
+
* @return string html
|
49 |
+
*/
|
50 |
+
public function get_field( $index, $value ) {
|
51 |
+
$name = $this->get_field_name_in_editor( $index );
|
52 |
+
$disabled = $this->get_disable_attribute( $index );
|
53 |
+
$value = ( true === $value || 1 === $value || '1' === $value ) ? 1 : 0;
|
54 |
+
|
55 |
+
$true = sprintf(
|
56 |
+
'<label><input type="radio" name="%s" value="1" class="widefat" %s %s />%s ( true )</label>',
|
57 |
+
esc_attr( $name ),
|
58 |
+
checked( 1, $value, false ),
|
59 |
+
disabled( true, $disabled, false ),
|
60 |
+
$this->get( 'true_label' )
|
61 |
+
);
|
62 |
+
|
63 |
+
$false = sprintf(
|
64 |
+
'<label><input type="radio" name="%s" value="0" class="widefat" %s %s />%s ( false )</label>',
|
65 |
+
esc_attr( $name ),
|
66 |
+
checked( 0, $value, false ),
|
67 |
+
disabled( true, $disabled, false ),
|
68 |
+
$this->get( 'false_label' )
|
69 |
+
);
|
70 |
+
|
71 |
+
return $true . $false;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Displaying the option fields in custom field settings page
|
76 |
+
*
|
77 |
+
* @param int $group_key
|
78 |
+
* @param int $field_key
|
79 |
+
*/
|
80 |
+
public function display_field_options( $group_key, $field_key ) {
|
81 |
+
$this->display_name_option( $group_key, $field_key );
|
82 |
+
$this->display_label_option( $group_key, $field_key );
|
83 |
+
?>
|
84 |
+
<tr>
|
85 |
+
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
86 |
+
<td>
|
87 |
+
<fieldset>
|
88 |
+
|
89 |
+
<label>
|
90 |
+
<input type="radio"
|
91 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
92 |
+
value="1"
|
93 |
+
<?php checked( 1, $this->get( 'default' ) ); ?>
|
94 |
+
/>
|
95 |
+
<span><?php echo esc_html( $this->get( 'true_label' ) ); ?> ( true )</span>
|
96 |
+
</label>
|
97 |
+
<label>
|
98 |
+
<input type="radio"
|
99 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
100 |
+
value="0"
|
101 |
+
<?php checked( 0, $this->get( 'default' ) ); ?>
|
102 |
+
/>
|
103 |
+
<span><?php echo esc_html( $this->get( 'false_label' ) ); ?> ( false )</span>
|
104 |
+
</label>
|
105 |
+
|
106 |
+
</fieldset>
|
107 |
+
</td>
|
108 |
+
</tr>
|
109 |
+
<tr>
|
110 |
+
<th><?php esc_html_e( 'TRUE Label', 'smart-custom-fields' ); ?></th>
|
111 |
+
<td>
|
112 |
+
<input type="text"
|
113 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'true_label' ) ); ?>"
|
114 |
+
class="widefat"
|
115 |
+
value="<?php echo esc_attr( $this->get( 'true_label' ) ); ?>"
|
116 |
+
/>
|
117 |
+
</td>
|
118 |
+
</tr>
|
119 |
+
<tr>
|
120 |
+
<th><?php esc_html_e( 'FALSE Label', 'smart-custom-fields' ); ?></th>
|
121 |
+
<td>
|
122 |
+
<input type="text"
|
123 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'false_label' ) ); ?>"
|
124 |
+
class="widefat"
|
125 |
+
value="<?php echo esc_attr( $this->get( 'false_label' ) ); ?>"
|
126 |
+
/>
|
127 |
+
</td>
|
128 |
+
</tr>
|
129 |
+
<tr>
|
130 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
131 |
+
<td>
|
132 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
133 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
134 |
+
</td>
|
135 |
+
</tr>
|
136 |
+
<tr>
|
137 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
138 |
+
<td>
|
139 |
+
<input type="text"
|
140 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
141 |
+
class="widefat"
|
142 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
143 |
+
/>
|
144 |
+
</td>
|
145 |
+
</tr>
|
146 |
+
<?php
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Validating when displaying meta data
|
151 |
+
*
|
152 |
+
* @param int|string $value
|
153 |
+
* @param string $field_type
|
154 |
+
* @return boolean
|
155 |
+
*/
|
156 |
+
public function validate_get_value( $value, $field_type ) {
|
157 |
+
if ( $field_type === $this->get_attribute( 'type' ) ) {
|
158 |
+
if ( is_array( $value ) ) {
|
159 |
+
foreach ( $value as $key => $val ) {
|
160 |
+
$value[$key] = !!$val;
|
161 |
+
}
|
162 |
+
} else {
|
163 |
+
$value = !!$value;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
return $value;
|
167 |
+
}
|
168 |
+
}
|
trunk/classes/fields/class.field-check.php
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Check
|
4 |
+
* Version : 1.3.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : June 4, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
return array(
|
20 |
+
'type' => 'check',
|
21 |
+
'display-name' => __( 'Check', 'smart-custom-fields' ),
|
22 |
+
'optgroup' => 'select-fields',
|
23 |
+
'allow-multiple-data' => true,
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Set the non required items
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
protected function options() {
|
33 |
+
return array(
|
34 |
+
'choices' => '',
|
35 |
+
'check_direction' => 'horizontal', // or vertical
|
36 |
+
'default' => '',
|
37 |
+
'instruction' => '',
|
38 |
+
'notes' => '',
|
39 |
+
);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Getting the field
|
44 |
+
*
|
45 |
+
* @param int $index
|
46 |
+
* @param array $value
|
47 |
+
* @return string html
|
48 |
+
*/
|
49 |
+
public function get_field( $index, $value ) {
|
50 |
+
$name = $this->get_field_name_in_editor( $index );
|
51 |
+
$disabled = $this->get_disable_attribute( $index );
|
52 |
+
$choices = SCF::choices_eol_to_array( $this->get( 'choices' ) );
|
53 |
+
$direction = $this->get( 'check_direction' );
|
54 |
+
|
55 |
+
$form_field = sprintf(
|
56 |
+
'<input type="hidden" name="%s" value="" %s />',
|
57 |
+
esc_attr( $name ),
|
58 |
+
disabled( true, $disabled, false )
|
59 |
+
);
|
60 |
+
foreach ( $choices as $key => $choice ) {
|
61 |
+
$choice = trim( $choice );
|
62 |
+
if ( !SCF::is_assoc( $choices ) ) {
|
63 |
+
$key = $choice;
|
64 |
+
}
|
65 |
+
$form_field .= sprintf(
|
66 |
+
'<span class="%1$s"><label><input type="checkbox" name="%2$s" value="%3$s" %4$s %5$s /> %6$s</label></span>',
|
67 |
+
esc_attr( SCF_Config::PREFIX . 'item-' . $direction ),
|
68 |
+
esc_attr( $name . '[]' ),
|
69 |
+
esc_attr( $key ),
|
70 |
+
checked( true, ( is_array( $value ) && in_array( $key, $value ) ), false ),
|
71 |
+
disabled( true, $disabled, false ),
|
72 |
+
esc_html( $choice )
|
73 |
+
);
|
74 |
+
}
|
75 |
+
return $form_field;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Displaying the option fields in custom field settings page
|
80 |
+
*
|
81 |
+
* @param int $group_key
|
82 |
+
* @param int $field_key
|
83 |
+
*/
|
84 |
+
public function display_field_options( $group_key, $field_key ) {
|
85 |
+
$this->display_name_option( $group_key, $field_key );
|
86 |
+
$this->display_label_option( $group_key, $field_key );
|
87 |
+
?>
|
88 |
+
<tr>
|
89 |
+
<th><?php esc_html_e( 'Choices', 'smart-custom-fields' ); ?></th>
|
90 |
+
<td>
|
91 |
+
<textarea
|
92 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'choices' ) ); ?>"
|
93 |
+
class="widefat"
|
94 |
+
rows="5" /><?php echo esc_textarea( "\n" . $this->get( 'choices' ) ); ?></textarea>
|
95 |
+
<?php esc_html_e( 'If you want to separate the key and the value, enter as follows: key => value', 'smart-custom-fields' ); ?>
|
96 |
+
</td>
|
97 |
+
</tr>
|
98 |
+
<tr>
|
99 |
+
<th><?php esc_html_e( 'Display Direction', 'smart-custom-fields' ); ?></th>
|
100 |
+
<td>
|
101 |
+
<?php
|
102 |
+
$directions = array(
|
103 |
+
'horizontal' => __( 'horizontal', 'smart-custom-fields' ),
|
104 |
+
'vertical' => __( 'vertical' , 'smart-custom-fields' ),
|
105 |
+
);
|
106 |
+
foreach ( $directions as $key => $value ) {
|
107 |
+
printf(
|
108 |
+
'<label><input type="radio" name="%s" value="%s" %s /> %s</label> ',
|
109 |
+
esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'check_direction' ) ),
|
110 |
+
esc_attr( $key ),
|
111 |
+
checked( $this->get( 'check_direction' ), $key, false ),
|
112 |
+
esc_html( $value )
|
113 |
+
);
|
114 |
+
}
|
115 |
+
?>
|
116 |
+
</td>
|
117 |
+
</tr>
|
118 |
+
<tr>
|
119 |
+
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
120 |
+
<td>
|
121 |
+
<textarea
|
122 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
123 |
+
class="widefat"
|
124 |
+
rows="5" /><?php echo esc_textarea( "\n" . $this->get( 'default' ) ); ?></textarea>
|
125 |
+
</td>
|
126 |
+
</tr>
|
127 |
+
<tr>
|
128 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
129 |
+
<td>
|
130 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
131 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
132 |
+
</td>
|
133 |
+
</tr>
|
134 |
+
<tr>
|
135 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
136 |
+
<td>
|
137 |
+
<input type="text"
|
138 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
139 |
+
class="widefat"
|
140 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
141 |
+
/>
|
142 |
+
</td>
|
143 |
+
</tr>
|
144 |
+
<?php
|
145 |
+
}
|
146 |
+
}
|
trunk/classes/fields/class.field-colorpicker.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Colorpicker
|
4 |
+
* Version : 1.2.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 21, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
add_action(
|
20 |
+
SCF_Config::PREFIX . 'before-editor-enqueue-scripts',
|
21 |
+
array( $this, 'editor_enqueue_scripts' )
|
22 |
+
);
|
23 |
+
add_action(
|
24 |
+
SCF_Config::PREFIX . 'before-settings-enqueue-scripts',
|
25 |
+
array( $this, 'settings_enqueue_scripts' )
|
26 |
+
);
|
27 |
+
return array(
|
28 |
+
'type' => 'colorpicker',
|
29 |
+
'display-name' => __( 'Color picker', 'smart-custom-fields' ),
|
30 |
+
'optgroup' => 'other-fields',
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Set the non required items
|
36 |
+
*
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
protected function options() {
|
40 |
+
return array(
|
41 |
+
'default' => '',
|
42 |
+
'instruction' => '',
|
43 |
+
'notes' => '',
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Loading resources for editor
|
49 |
+
*/
|
50 |
+
public function editor_enqueue_scripts() {
|
51 |
+
wp_enqueue_style( 'wp-color-picker' );
|
52 |
+
|
53 |
+
wp_enqueue_script(
|
54 |
+
SCF_Config::PREFIX . 'editor-colorpicker',
|
55 |
+
plugins_url( SCF_Config::NAME ) . '/js/editor-colorpicker.js',
|
56 |
+
array( 'jquery', 'wp-color-picker' ),
|
57 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-colorpicker.js' ) ),
|
58 |
+
true
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Loading resources for editor for custom field settings page
|
64 |
+
*/
|
65 |
+
public function settings_enqueue_scripts() {
|
66 |
+
wp_enqueue_style( 'wp-color-picker' );
|
67 |
+
|
68 |
+
wp_enqueue_script(
|
69 |
+
SCF_Config::PREFIX . 'settings-colorpicker',
|
70 |
+
plugins_url( SCF_Config::NAME ) . '/js/settings-colorpicker.js',
|
71 |
+
array( 'jquery', 'wp-color-picker' ),
|
72 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/settings-colorpicker.js' ) ),
|
73 |
+
true
|
74 |
+
);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Getting the field
|
79 |
+
*
|
80 |
+
* @param int $index
|
81 |
+
* @param string $value
|
82 |
+
* @return string html
|
83 |
+
*/
|
84 |
+
public function get_field( $index, $value ) {
|
85 |
+
$name = $this->get_field_name_in_editor( $index );
|
86 |
+
$disabled = $this->get_disable_attribute( $index );
|
87 |
+
return sprintf(
|
88 |
+
'<input type="text" name="%s" value="%s" class="%s" %s />',
|
89 |
+
esc_attr( $name ),
|
90 |
+
esc_attr( $value ),
|
91 |
+
esc_attr( SCF_Config::PREFIX . 'colorpicker' ),
|
92 |
+
disabled( true, $disabled, false )
|
93 |
+
);
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Displaying the option fields in custom field settings page
|
98 |
+
*
|
99 |
+
* @param int $group_key
|
100 |
+
* @param int $field_key
|
101 |
+
*/
|
102 |
+
public function display_field_options( $group_key, $field_key ) {
|
103 |
+
$this->display_name_option( $group_key, $field_key );
|
104 |
+
$this->display_label_option( $group_key, $field_key );
|
105 |
+
?>
|
106 |
+
<tr>
|
107 |
+
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
108 |
+
<td>
|
109 |
+
<input type="text"
|
110 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
111 |
+
class="widefat default-option"
|
112 |
+
value="<?php echo esc_attr( $this->get( 'default' ) ); ?>" />
|
113 |
+
</td>
|
114 |
+
</tr>
|
115 |
+
<tr>
|
116 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
117 |
+
<td>
|
118 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
119 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
120 |
+
</td>
|
121 |
+
</tr>
|
122 |
+
<tr>
|
123 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
124 |
+
<td>
|
125 |
+
<input type="text"
|
126 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
127 |
+
class="widefat"
|
128 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
129 |
+
/>
|
130 |
+
</td>
|
131 |
+
</tr>
|
132 |
+
<?php
|
133 |
+
}
|
134 |
+
}
|
trunk/classes/fields/class.field-datepicker.php
ADDED
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Datepicker
|
4 |
+
* Version : 1.2.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : January 17, 2015
|
7 |
+
* Modified : June 04, 2018
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
add_action(
|
20 |
+
SCF_Config::PREFIX . 'before-editor-enqueue-scripts',
|
21 |
+
array( $this, 'editor_enqueue_scripts' )
|
22 |
+
);
|
23 |
+
add_action(
|
24 |
+
SCF_Config::PREFIX . 'before-settings-enqueue-scripts',
|
25 |
+
array( $this, 'settings_enqueue_scripts' )
|
26 |
+
);
|
27 |
+
return array(
|
28 |
+
'type' => 'datepicker',
|
29 |
+
'display-name' => __( 'Date picker', 'smart-custom-fields' ),
|
30 |
+
'optgroup' => 'other-fields',
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Set the non required items
|
36 |
+
*
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
protected function options() {
|
40 |
+
return array(
|
41 |
+
'date_format' => '',
|
42 |
+
'max_date' => '',
|
43 |
+
'min_date' => '',
|
44 |
+
'default' => '',
|
45 |
+
'instruction' => '',
|
46 |
+
'notes' => '',
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Loading resources for editor
|
52 |
+
*/
|
53 |
+
public function editor_enqueue_scripts() {
|
54 |
+
global $wp_scripts;
|
55 |
+
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
56 |
+
wp_enqueue_style(
|
57 |
+
'jquery.ui',
|
58 |
+
'//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css',
|
59 |
+
array(),
|
60 |
+
$ui->ver
|
61 |
+
);
|
62 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
63 |
+
wp_enqueue_script(
|
64 |
+
SCF_Config::PREFIX . 'editor-datepicker',
|
65 |
+
plugins_url( '../../js/editor-datepicker.js', __FILE__ ),
|
66 |
+
array( 'jquery', 'jquery-ui-datepicker' ),
|
67 |
+
false,
|
68 |
+
true
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Loading resources for editor for custom field settings page
|
74 |
+
*/
|
75 |
+
public function settings_enqueue_scripts() {
|
76 |
+
global $wp_scripts;
|
77 |
+
$ui = $wp_scripts->query( 'jquery-ui-core' );
|
78 |
+
|
79 |
+
wp_enqueue_style(
|
80 |
+
'jquery.ui',
|
81 |
+
'//ajax.googleapis.com/ajax/libs/jqueryui/' . $ui->ver . '/themes/smoothness/jquery-ui.min.css',
|
82 |
+
array(),
|
83 |
+
$ui->ver
|
84 |
+
);
|
85 |
+
|
86 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
87 |
+
|
88 |
+
wp_enqueue_script(
|
89 |
+
SCF_Config::PREFIX . 'settings-datepicker',
|
90 |
+
plugins_url( SCF_Config::NAME ) . '/js/settings-datepicker.js',
|
91 |
+
array( 'jquery', 'jquery-ui-datepicker' ),
|
92 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/settings-datepicker.js' ) ),
|
93 |
+
true
|
94 |
+
);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Getting the field
|
99 |
+
*
|
100 |
+
* @param int $index
|
101 |
+
* @param string $value
|
102 |
+
* @return string html
|
103 |
+
*/
|
104 |
+
public function get_field( $index, $value ) {
|
105 |
+
$name = $this->get_field_name_in_editor( $index );
|
106 |
+
$disabled = $this->get_disable_attribute( $index );
|
107 |
+
$data_js = $this->get_data_js();
|
108 |
+
|
109 |
+
return sprintf(
|
110 |
+
'<input type="text" name="%s" value="%s" class="%s" %s data-js=\'%s\' />',
|
111 |
+
esc_attr( $name ),
|
112 |
+
esc_attr( $value ),
|
113 |
+
esc_attr( SCF_Config::PREFIX . 'datepicker' ),
|
114 |
+
disabled( true, $disabled, false ),
|
115 |
+
$data_js
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Displaying the option fields in custom field settings page
|
121 |
+
*
|
122 |
+
* @param int $group_key
|
123 |
+
* @param int $field_key
|
124 |
+
*/
|
125 |
+
public function display_field_options( $group_key, $field_key ) {
|
126 |
+
$this->display_name_option( $group_key, $field_key );
|
127 |
+
$this->display_label_option( $group_key, $field_key );
|
128 |
+
?>
|
129 |
+
<tr>
|
130 |
+
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
131 |
+
<td>
|
132 |
+
<input type="text"
|
133 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
134 |
+
class="widefat default-option"
|
135 |
+
value="<?php echo esc_attr( $this->get( 'default' ) ); ?>"
|
136 |
+
data-js='<?php echo $this->get_data_js(); ?>' />
|
137 |
+
</td>
|
138 |
+
</tr>
|
139 |
+
<tr>
|
140 |
+
<th><?php esc_html_e( 'Date Format', 'smart-custom-fields' ); ?></th>
|
141 |
+
<td>
|
142 |
+
<input type="text"
|
143 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'date_format' ) ); ?>"
|
144 |
+
class="widefat"
|
145 |
+
value="<?php echo esc_attr( $this->get( 'date_format' ) ); ?>"
|
146 |
+
/><br />
|
147 |
+
<span class="<?php echo esc_attr( SCF_Config::PREFIX ); ?>notes">
|
148 |
+
<?php esc_html_e( 'e.g dd/mm/yy', 'smart-custom-fields' ); ?>
|
149 |
+
<?php printf(
|
150 |
+
esc_html( 'Prease see %sdateFormat%s', 'smart-custom-fields' ),
|
151 |
+
'<a href="http://api.jqueryui.com/datepicker/#option-dateFormat" target="_blank">',
|
152 |
+
'</a>'
|
153 |
+
); ?>
|
154 |
+
</span>
|
155 |
+
</td>
|
156 |
+
</tr>
|
157 |
+
<tr>
|
158 |
+
<th><?php esc_html_e( 'Max Date', 'smart-custom-fields' ); ?></th>
|
159 |
+
<td>
|
160 |
+
<input type="text"
|
161 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'max_date' ) ); ?>"
|
162 |
+
class="widefat"
|
163 |
+
value="<?php echo esc_attr( $this->get( 'max_date' ) ); ?>"
|
164 |
+
/><br />
|
165 |
+
<span class="<?php echo esc_attr( SCF_Config::PREFIX ); ?>notes">
|
166 |
+
<?php esc_html_e( 'e.g +1m +1w', 'smart-custom-fields' ); ?>
|
167 |
+
<?php printf(
|
168 |
+
esc_html( 'Prease see %smaxData%s', 'smart-custom-fields' ),
|
169 |
+
'<a href="http://api.jqueryui.com/datepicker/#option-maxDate" target="_blank">',
|
170 |
+
'</a>'
|
171 |
+
); ?>
|
172 |
+
</span>
|
173 |
+
</td>
|
174 |
+
</tr>
|
175 |
+
<tr>
|
176 |
+
<th><?php esc_html_e( 'Min Date', 'smart-custom-fields' ); ?></th>
|
177 |
+
<td>
|
178 |
+
<input type="text"
|
179 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'min_date' ) ); ?>"
|
180 |
+
class="widefat"
|
181 |
+
value="<?php echo esc_attr( $this->get( 'min_date' ) ); ?>"
|
182 |
+
/><br />
|
183 |
+
<span class="<?php echo esc_attr( SCF_Config::PREFIX ); ?>notes">
|
184 |
+
<?php esc_html_e( 'e.g +1m +1w', 'smart-custom-fields' ); ?>
|
185 |
+
<?php printf(
|
186 |
+
esc_html( 'Prease see %sminData%s', 'smart-custom-fields' ),
|
187 |
+
'<a href="http://api.jqueryui.com/datepicker/#option-minDate" target="_blank">',
|
188 |
+
'</a>'
|
189 |
+
); ?>
|
190 |
+
</span>
|
191 |
+
</td>
|
192 |
+
</tr>
|
193 |
+
<tr>
|
194 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
195 |
+
<td>
|
196 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
197 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
198 |
+
</td>
|
199 |
+
</tr>
|
200 |
+
<tr>
|
201 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
202 |
+
<td>
|
203 |
+
<input type="text"
|
204 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
205 |
+
class="widefat"
|
206 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
207 |
+
/>
|
208 |
+
</td>
|
209 |
+
</tr>
|
210 |
+
<?php
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Return datepicker option with json_encode
|
215 |
+
*
|
216 |
+
* @return string option with json_encode
|
217 |
+
*/
|
218 |
+
protected function get_data_js() {
|
219 |
+
$js = array(
|
220 |
+
'showMonthAfterYear' => true,
|
221 |
+
'changeYear' => true,
|
222 |
+
'changeMonth' => true,
|
223 |
+
);
|
224 |
+
|
225 |
+
// If locale is Japanese, change in Japanese notation
|
226 |
+
if ( get_locale() === 'ja' ) {
|
227 |
+
$js = array_merge( $js, array(
|
228 |
+
'yearSuffix' => '年',
|
229 |
+
'dateFormat' => 'yy-mm-dd',
|
230 |
+
'dayNames' => array(
|
231 |
+
'日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日',
|
232 |
+
),
|
233 |
+
'dayNamesMin' => array(
|
234 |
+
'日', '月', '火', '水', '木', '金', '土',
|
235 |
+
),
|
236 |
+
'dayNamesShort' => array(
|
237 |
+
'日曜', '月曜', '火曜', '水曜', '木曜', '金曜', '土曜',
|
238 |
+
),
|
239 |
+
'monthNames' => array(
|
240 |
+
'1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月',
|
241 |
+
),
|
242 |
+
'monthNamesShort' => array(
|
243 |
+
'1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月',
|
244 |
+
)
|
245 |
+
) );
|
246 |
+
}
|
247 |
+
|
248 |
+
if ( $this->get( 'date_format' ) ) {
|
249 |
+
$js['dateFormat'] = $this->get( 'date_format' );
|
250 |
+
}
|
251 |
+
|
252 |
+
if ( $this->get( 'max_date' ) ) {
|
253 |
+
$js['maxDate'] = $this->get( 'max_date' );
|
254 |
+
}
|
255 |
+
|
256 |
+
if ( $this->get( 'min_date' ) ) {
|
257 |
+
$js['minDate'] = $this->get( 'min_date' );
|
258 |
+
}
|
259 |
+
|
260 |
+
return json_encode( $js );
|
261 |
+
}
|
262 |
+
}
|
trunk/classes/fields/class.field-file.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_File
|
4 |
+
* Version : 1.3.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : September 6, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
return array(
|
20 |
+
'type' => 'file',
|
21 |
+
'display-name' => __( 'File', 'smart-custom-fields' ),
|
22 |
+
'optgroup' => 'content-fields',
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Set the non required items
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
protected function options() {
|
32 |
+
return array(
|
33 |
+
'instruction' => '',
|
34 |
+
'notes' => '',
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Getting the field
|
40 |
+
*
|
41 |
+
* @param int $index
|
42 |
+
* @param string $value
|
43 |
+
* @return string html
|
44 |
+
*/
|
45 |
+
public function get_field( $index, $value ) {
|
46 |
+
$name = $this->get_field_name_in_editor( $index );
|
47 |
+
$disabled = $this->get_disable_attribute( $index );
|
48 |
+
|
49 |
+
$btn_remove = sprintf(
|
50 |
+
'<span class="btn-remove-file hide">%s</span>',
|
51 |
+
esc_html__( 'Delete', 'smart-custom-fields' )
|
52 |
+
);
|
53 |
+
|
54 |
+
$hide_class = 'hide';
|
55 |
+
$image = $btn_remove;
|
56 |
+
if ( $value ) {
|
57 |
+
// Usually, $value is attachment ID.
|
58 |
+
// If a customized, for example, $value is not an ID,
|
59 |
+
// Regarded the $value is file URL.
|
60 |
+
if ( preg_match( '/^\d+$/', $value ) ) {
|
61 |
+
$image_src = wp_get_attachment_image_src( $value, 'thumbnail', true );
|
62 |
+
if ( is_array( $image_src ) && isset( $image_src[0] ) ) {
|
63 |
+
$image_src = $image_src[0];
|
64 |
+
}
|
65 |
+
} else {
|
66 |
+
$imag_url = $value;
|
67 |
+
$path = str_replace( home_url(), '', $value );
|
68 |
+
$image_path = ABSPATH . untrailingslashit( $path );
|
69 |
+
if ( file_exists( $image_path ) ) {
|
70 |
+
$wp_check_filetype = wp_check_filetype( $image_path );
|
71 |
+
if ( ! empty( $wp_check_filetype['type'] ) ) {
|
72 |
+
$image_src = $image_url;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( $image_src && ! is_array( $image_src ) ) {
|
78 |
+
$attachment = get_post( $value );
|
79 |
+
$attachment_name = $attachment->post_name;
|
80 |
+
$attachment_url = get_attached_file( $attachment->ID );
|
81 |
+
$filetype = wp_check_filetype( $attachment_url );
|
82 |
+
$filename = $attachment_name . '.' . $filetype['ext'];
|
83 |
+
$image = sprintf(
|
84 |
+
'<a href="%s" target="_blank"><img src="%s" alt="" />%s</a>%s',
|
85 |
+
wp_get_attachment_url( $value ),
|
86 |
+
esc_url( $image_src ),
|
87 |
+
esc_attr( $filename ),
|
88 |
+
$btn_remove
|
89 |
+
);
|
90 |
+
$hide_class = '';
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
return sprintf(
|
95 |
+
'<span class="button btn-add-file">%s</span><br />
|
96 |
+
<span class="%s %s">%s</span>
|
97 |
+
<input type="hidden" name="%s" value="%s" %s />',
|
98 |
+
esc_html__( 'File Select', 'smart-custom-fields' ),
|
99 |
+
esc_attr( SCF_Config::PREFIX . 'upload-file' ),
|
100 |
+
esc_attr( $hide_class ),
|
101 |
+
$image,
|
102 |
+
esc_attr( $name ),
|
103 |
+
esc_attr( $value ),
|
104 |
+
disabled( true, $disabled, false )
|
105 |
+
);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Displaying the option fields in custom field settings page
|
110 |
+
*
|
111 |
+
* @param int $group_key
|
112 |
+
* @param int $field_key
|
113 |
+
*/
|
114 |
+
public function display_field_options( $group_key, $field_key ) {
|
115 |
+
$this->display_name_option( $group_key, $field_key );
|
116 |
+
$this->display_label_option( $group_key, $field_key );
|
117 |
+
?>
|
118 |
+
<tr>
|
119 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
120 |
+
<td>
|
121 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
122 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
123 |
+
</td>
|
124 |
+
</tr>
|
125 |
+
<tr>
|
126 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
127 |
+
<td>
|
128 |
+
<input type="text"
|
129 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
130 |
+
class="widefat"
|
131 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
132 |
+
/>
|
133 |
+
</td>
|
134 |
+
</tr>
|
135 |
+
<?php
|
136 |
+
}
|
137 |
+
}
|
trunk/classes/fields/class.field-image.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Image
|
4 |
+
* Version : 1.3.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : September 6, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
return array(
|
20 |
+
'type' => 'image',
|
21 |
+
'display-name' => __( 'Image', 'smart-custom-fields' ),
|
22 |
+
'optgroup' => 'content-fields',
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Set the non required items
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
protected function options() {
|
32 |
+
return array(
|
33 |
+
'instruction' => '',
|
34 |
+
'notes' => '',
|
35 |
+
'size' => 'full',
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Getting the field
|
41 |
+
*
|
42 |
+
* @param int $index
|
43 |
+
* @param string $value
|
44 |
+
* @return string html
|
45 |
+
*/
|
46 |
+
public function get_field( $index, $value ) {
|
47 |
+
$name = $this->get_field_name_in_editor( $index );
|
48 |
+
$disabled = $this->get_disable_attribute( $index );
|
49 |
+
|
50 |
+
$btn_remove = sprintf(
|
51 |
+
'<span class="btn-remove-image hide">%s</span>',
|
52 |
+
esc_html__( 'Delete', 'smart-custom-fields' )
|
53 |
+
);
|
54 |
+
|
55 |
+
$hide_class = 'hide';
|
56 |
+
$image = $btn_remove;
|
57 |
+
if ( $value ) {
|
58 |
+
// Usually, $value is attachment ID.
|
59 |
+
// If a customized, for example, $value is not an ID,
|
60 |
+
// Regarded the $value is file URL.
|
61 |
+
if ( preg_match( '/^\d+$/', $value ) ) {
|
62 |
+
$image_src = wp_get_attachment_image_src( $value, $this->get( 'size' ) );
|
63 |
+
if ( is_array( $image_src ) && isset( $image_src[0] ) ) {
|
64 |
+
$image_src = $image_src[0];
|
65 |
+
}
|
66 |
+
} else {
|
67 |
+
$image_url = $value;
|
68 |
+
$path = str_replace( home_url(), '', $value );
|
69 |
+
$image_path = ABSPATH . untrailingslashit( $path );
|
70 |
+
if ( file_exists( $image_path ) ) {
|
71 |
+
$wp_check_filetype = wp_check_filetype( $image_path );
|
72 |
+
if ( ! empty( $wp_check_filetype['type'] ) ) {
|
73 |
+
$image_src = $image_url;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
if ( $image_src && ! is_array( $image_src ) ) {
|
79 |
+
$image = sprintf(
|
80 |
+
'<img src="%s" alt="" />%s',
|
81 |
+
esc_url( $image_src ),
|
82 |
+
$btn_remove
|
83 |
+
);
|
84 |
+
$hide_class = '';
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
return sprintf(
|
89 |
+
'<span class="button btn-add-image">%s</span><br />
|
90 |
+
<span class="%s %s" data-size="%s">%s</span>
|
91 |
+
<input type="hidden" name="%s" value="%s" %s />',
|
92 |
+
esc_html__( 'Image Select', 'smart-custom-fields' ),
|
93 |
+
esc_attr( SCF_Config::PREFIX . 'upload-image' ),
|
94 |
+
esc_attr( $hide_class ),
|
95 |
+
esc_attr( $this->get( 'size' ) ),
|
96 |
+
$image,
|
97 |
+
esc_attr( $name ),
|
98 |
+
esc_attr( $value ),
|
99 |
+
disabled( true, $disabled, false )
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Displaying the option fields in custom field settings page
|
105 |
+
*
|
106 |
+
* @param int $group_key
|
107 |
+
* @param int $field_key
|
108 |
+
*/
|
109 |
+
public function display_field_options( $group_key, $field_key ) {
|
110 |
+
$this->display_name_option( $group_key, $field_key );
|
111 |
+
$this->display_label_option( $group_key, $field_key );
|
112 |
+
?>
|
113 |
+
<tr>
|
114 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
115 |
+
<td>
|
116 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
117 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
118 |
+
</td>
|
119 |
+
</tr>
|
120 |
+
<tr>
|
121 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
122 |
+
<td>
|
123 |
+
<input type="text"
|
124 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
125 |
+
class="widefat"
|
126 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
127 |
+
/>
|
128 |
+
</td>
|
129 |
+
</tr>
|
130 |
+
<tr>
|
131 |
+
<th><?php esc_html_e( 'Preview Size', 'smart-custom-fields' ); ?></th>
|
132 |
+
<td>
|
133 |
+
<select name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'size' ) ); ?>">
|
134 |
+
<option value="full" <?php selected( $this->get( 'size' ), 'full' );?> >full</option>
|
135 |
+
<?php foreach ( get_intermediate_image_sizes() as $size ) : ?>
|
136 |
+
<option value="<?php echo esc_attr( $size );?>" <?php selected( $this->get( 'size' ), $size );?>><?php echo esc_html( $size );?></option>
|
137 |
+
<?php endforeach;?>
|
138 |
+
</select>
|
139 |
+
</td>
|
140 |
+
</tr>
|
141 |
+
<?php
|
142 |
+
}
|
143 |
+
}
|
trunk/classes/fields/class.field-message.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Message
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : robssanches, inc2734
|
6 |
+
* Created : June 2, 2018
|
7 |
+
* Modified : June 2, 2018
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Message extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
return array(
|
20 |
+
'type' => 'message',
|
21 |
+
'display-name' => __( 'Message', 'smart-custom-fields' ),
|
22 |
+
'optgroup' => 'basic-fields',
|
23 |
+
'allow-multiple-data' => false,
|
24 |
+
'layout' => 'full-width'
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Set the non required items
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
protected function options() {
|
34 |
+
return array(
|
35 |
+
'default' => '',
|
36 |
+
'notes' => ''
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Getting the field
|
42 |
+
*
|
43 |
+
* @param int $index
|
44 |
+
* @param string $value
|
45 |
+
* @return string html
|
46 |
+
*/
|
47 |
+
public function get_field( $index, $value ) {
|
48 |
+
$name = $this->get_field_name_in_editor( $index );
|
49 |
+
$disabled = $this->get_disable_attribute( $index );
|
50 |
+
return sprintf(
|
51 |
+
'<div id="%s" class="widefat" %s>%s</div>',
|
52 |
+
esc_attr( $name ),
|
53 |
+
disabled( true, $disabled, false ),
|
54 |
+
$value
|
55 |
+
);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Displaying the option fields in custom field settings page
|
60 |
+
*
|
61 |
+
* @param int $group_key
|
62 |
+
* @param int $field_key
|
63 |
+
*/
|
64 |
+
public function display_field_options( $group_key, $field_key ) {
|
65 |
+
$this->display_name_option( $group_key, $field_key );
|
66 |
+
?>
|
67 |
+
<tr>
|
68 |
+
<th><?php esc_html_e( 'Message', 'smart-custom-fields' ); ?></th>
|
69 |
+
<td>
|
70 |
+
<textarea
|
71 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
72 |
+
class="widefat"
|
73 |
+
rows="5"><?php echo esc_textarea( "\n" . $this->get( 'default' ) ); ?></textarea>
|
74 |
+
</td>
|
75 |
+
</tr>
|
76 |
+
<tr>
|
77 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
78 |
+
<td>
|
79 |
+
<input type="text"
|
80 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
81 |
+
class="widefat"
|
82 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
83 |
+
/>
|
84 |
+
</td>
|
85 |
+
</tr>
|
86 |
+
<?php
|
87 |
+
}
|
88 |
+
}
|
trunk/classes/fields/class.field-radio.php
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Radio
|
4 |
+
* Version : 1.3.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : June 4, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
return array(
|
20 |
+
'type' => 'radio',
|
21 |
+
'display-name' => __( 'Radio', 'smart-custom-fields' ),
|
22 |
+
'optgroup' => 'select-fields',
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Set the non required items
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
protected function options() {
|
32 |
+
return array(
|
33 |
+
'choices' => '',
|
34 |
+
'radio_direction' => 'horizontal', // or vertical
|
35 |
+
'default' => '',
|
36 |
+
'instruction' => '',
|
37 |
+
'notes' => '',
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Getting the field
|
43 |
+
*
|
44 |
+
* @param int $index
|
45 |
+
* @param string $value
|
46 |
+
* @return string html
|
47 |
+
*/
|
48 |
+
public function get_field( $index, $value ) {
|
49 |
+
$name = $this->get_field_name_in_editor( $index );
|
50 |
+
$disabled = $this->get_disable_attribute( $index );
|
51 |
+
$choices = SCF::choices_eol_to_array( $this->get( 'choices' ) );
|
52 |
+
$direction = $this->get( 'radio_direction' );
|
53 |
+
|
54 |
+
$form_field = sprintf(
|
55 |
+
'<input type="hidden" name="%s" value="" %s />',
|
56 |
+
esc_attr( $name ),
|
57 |
+
disabled( true, $disabled, false )
|
58 |
+
);
|
59 |
+
foreach ( $choices as $key => $choice ) {
|
60 |
+
$choice = trim( $choice );
|
61 |
+
if ( !SCF::is_assoc( $choices ) ) {
|
62 |
+
$key = $choice;
|
63 |
+
}
|
64 |
+
$form_field .= sprintf(
|
65 |
+
'<span class="%1$s"><label><input type="radio" name="%2$s" value="%3$s" %4$s %5$s /> %6$s</label></span>',
|
66 |
+
esc_attr( SCF_Config::PREFIX . 'item-' . $direction ),
|
67 |
+
esc_attr( $name ),
|
68 |
+
esc_attr( $key ),
|
69 |
+
checked( $value, $key, false ),
|
70 |
+
disabled( true, $disabled, false ),
|
71 |
+
esc_html( $choice )
|
72 |
+
);
|
73 |
+
}
|
74 |
+
return $form_field;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Displaying the option fields in custom field settings page
|
79 |
+
*
|
80 |
+
* @param int $group_key
|
81 |
+
* @param int $field_key
|
82 |
+
*/
|
83 |
+
public function display_field_options( $group_key, $field_key ) {
|
84 |
+
$this->display_name_option( $group_key, $field_key );
|
85 |
+
$this->display_label_option( $group_key, $field_key );
|
86 |
+
?>
|
87 |
+
<tr>
|
88 |
+
<th><?php esc_html_e( 'Choices', 'smart-custom-fields' ); ?></th>
|
89 |
+
<td>
|
90 |
+
<textarea
|
91 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'choices' ) ); ?>"
|
92 |
+
class="widefat"
|
93 |
+
rows="5" /><?php echo esc_textarea( "\n" . $this->get( 'choices' ) ); ?></textarea>
|
94 |
+
<?php esc_html_e( 'If you want to separate the key and the value, enter as follows: key => value', 'smart-custom-fields' ); ?>
|
95 |
+
</td>
|
96 |
+
</tr>
|
97 |
+
<tr>
|
98 |
+
<th><?php esc_html_e( 'Display Direction', 'smart-custom-fields' ); ?></th>
|
99 |
+
<td>
|
100 |
+
<?php
|
101 |
+
$directions = array(
|
102 |
+
'horizontal' => __( 'horizontal', 'smart-custom-fields' ),
|
103 |
+
'vertical' => __( 'vertical' , 'smart-custom-fields' ),
|
104 |
+
);
|
105 |
+
foreach ( $directions as $key => $value ) {
|
106 |
+
printf(
|
107 |
+
'<label><input type="radio" name="%s" value="%s" %s /> %s</label> ',
|
108 |
+
esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'radio_direction' ) ),
|
109 |
+
esc_attr( $key ),
|
110 |
+
checked( $this->get( 'radio_direction' ), $key, false ),
|
111 |
+
esc_html( $value )
|
112 |
+
);
|
113 |
+
}
|
114 |
+
?>
|
115 |
+
</td>
|
116 |
+
</tr>
|
117 |
+
<tr>
|
118 |
+
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
119 |
+
<td>
|
120 |
+
<input type="text"
|
121 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
122 |
+
class="widefat"
|
123 |
+
value="<?php echo esc_attr( $this->get( 'default' ) ); ?>" />
|
124 |
+
</td>
|
125 |
+
</tr>
|
126 |
+
<tr>
|
127 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
128 |
+
<td>
|
129 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
130 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
131 |
+
</td>
|
132 |
+
</tr>
|
133 |
+
<tr>
|
134 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
135 |
+
<td>
|
136 |
+
<input type="text"
|
137 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
138 |
+
class="widefat"
|
139 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
140 |
+
/>
|
141 |
+
</td>
|
142 |
+
</tr>
|
143 |
+
<?php
|
144 |
+
}
|
145 |
+
}
|
trunk/classes/fields/class.field-related-posts.php
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Related_Posts
|
4 |
+
* Version : 1.4.1
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
20 |
+
add_action( 'wp_ajax_smart-cf-relational-posts-search', array( $this, 'relational_posts_search' ) );
|
21 |
+
add_filter( 'smart-cf-validate-get-value', array( $this, 'validate_get_value' ), 10, 2 );
|
22 |
+
return array(
|
23 |
+
'type' => 'relation',
|
24 |
+
'display-name' => __( 'Related Posts', 'smart-custom-fields' ),
|
25 |
+
'optgroup' => 'other-fields',
|
26 |
+
'allow-multiple-data' => true,
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Set the non required items
|
32 |
+
*
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
protected function options() {
|
36 |
+
return array(
|
37 |
+
'post-type' => '',
|
38 |
+
'limit' => 0,
|
39 |
+
'instruction' => '',
|
40 |
+
'notes' => '',
|
41 |
+
);
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Loading resources
|
46 |
+
*
|
47 |
+
* @param string $hook
|
48 |
+
*/
|
49 |
+
public function admin_enqueue_scripts( $hook ) {
|
50 |
+
wp_enqueue_script(
|
51 |
+
SCF_Config::PREFIX . 'editor-relation-common',
|
52 |
+
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
|
53 |
+
array( 'jquery' ),
|
54 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-relation-common.js' ) ),
|
55 |
+
true
|
56 |
+
);
|
57 |
+
|
58 |
+
wp_enqueue_script(
|
59 |
+
SCF_Config::PREFIX . 'editor-relation-post-types',
|
60 |
+
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-post-types.js',
|
61 |
+
array( 'jquery' ),
|
62 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-relation-post-types.js' ) ),
|
63 |
+
true
|
64 |
+
);
|
65 |
+
|
66 |
+
wp_localize_script( SCF_Config::PREFIX . 'editor-relation-post-types', 'smart_cf_relation_post_types', array(
|
67 |
+
'endpoint' => admin_url( 'admin-ajax.php' ),
|
68 |
+
'action' => SCF_Config::PREFIX . 'relational-posts-search',
|
69 |
+
'nonce' => wp_create_nonce( SCF_Config::NAME . '-relation-post-types' )
|
70 |
+
) );
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Process that loading post when clicking post load button
|
75 |
+
*/
|
76 |
+
public function relational_posts_search() {
|
77 |
+
check_ajax_referer( SCF_Config::NAME . '-relation-post-types', 'nonce' );
|
78 |
+
$_posts = array();
|
79 |
+
$args = array();
|
80 |
+
if ( isset( $_POST['post_types'] ) ) {
|
81 |
+
$post_type = explode( ',', $_POST['post_types'] );
|
82 |
+
$args = array(
|
83 |
+
'post_type' => $post_type,
|
84 |
+
'order' => 'ASC',
|
85 |
+
'orderby' => 'ID',
|
86 |
+
'posts_per_page' => -1,
|
87 |
+
'post_status' => 'any',
|
88 |
+
);
|
89 |
+
|
90 |
+
if ( isset( $_POST['click_count'] ) ) {
|
91 |
+
$posts_per_page = get_option( 'posts_per_page' );
|
92 |
+
$offset = $_POST['click_count'] * $posts_per_page;
|
93 |
+
$args = array_merge(
|
94 |
+
$args,
|
95 |
+
array(
|
96 |
+
'offset' => $offset,
|
97 |
+
'posts_per_page' => $posts_per_page,
|
98 |
+
)
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( isset( $_POST['s'] ) ) {
|
103 |
+
$args = array_merge(
|
104 |
+
$args,
|
105 |
+
array(
|
106 |
+
's' => $_POST['s'],
|
107 |
+
)
|
108 |
+
);
|
109 |
+
}
|
110 |
+
$_posts = get_posts( $args );
|
111 |
+
}
|
112 |
+
header( 'Content-Type: application/json; charset=utf-8' );
|
113 |
+
echo json_encode( $_posts );
|
114 |
+
die();
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Getting the field
|
119 |
+
*
|
120 |
+
* @param int $index
|
121 |
+
* @param array $value
|
122 |
+
* @return string html
|
123 |
+
*/
|
124 |
+
public function get_field( $index, $value ) {
|
125 |
+
$name = $this->get_field_name_in_editor( $index );
|
126 |
+
$disabled = $this->get_disable_attribute( $index );
|
127 |
+
$post_type = $this->get( 'post-type' );
|
128 |
+
$limit = $this->get( 'limit' );
|
129 |
+
if ( ! $post_type ) {
|
130 |
+
$post_type = array( 'post' );
|
131 |
+
}
|
132 |
+
if ( ! preg_match( '/^\d+$/', $limit ) ) {
|
133 |
+
$limit = '';
|
134 |
+
}
|
135 |
+
$posts_per_page = get_option( 'posts_per_page' );
|
136 |
+
|
137 |
+
// choicse
|
138 |
+
$choices_posts = get_posts( array(
|
139 |
+
'post_type' => $post_type,
|
140 |
+
'order' => 'ASC',
|
141 |
+
'orderby' => 'ID',
|
142 |
+
'posts_per_page' => $posts_per_page,
|
143 |
+
'post_status' => 'any',
|
144 |
+
) );
|
145 |
+
$choices_li = array();
|
146 |
+
foreach ( $choices_posts as $_post ) {
|
147 |
+
$post_title = get_the_title( $_post->ID );
|
148 |
+
if ( empty( $post_title ) ) {
|
149 |
+
$post_title = ' ';
|
150 |
+
}
|
151 |
+
$choices_li[] = sprintf(
|
152 |
+
'<li data-id="%d" data-status="%s">%s</li>',
|
153 |
+
$_post->ID,
|
154 |
+
$_post->post_status,
|
155 |
+
$post_title
|
156 |
+
);
|
157 |
+
}
|
158 |
+
|
159 |
+
// selected
|
160 |
+
$selected_posts = array();
|
161 |
+
if ( !empty( $value ) && is_array( $value ) ) {
|
162 |
+
foreach ( $value as $post_id ) {
|
163 |
+
$post_title = get_the_title( $post_id );
|
164 |
+
if ( empty( $post_title ) ) {
|
165 |
+
$post_title = ' ';
|
166 |
+
}
|
167 |
+
$selected_posts[$post_id] = $post_title;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
$selected_li = array();
|
171 |
+
$hidden = array();
|
172 |
+
foreach ( $selected_posts as $post_id => $post_title ) {
|
173 |
+
$selected_li[] = sprintf(
|
174 |
+
'<li data-id="%d" data-status="%s"><span class="%s"></span>%s<span class="relation-remove">-</li></li>',
|
175 |
+
$post_id,
|
176 |
+
get_post_status( $post_id ),
|
177 |
+
esc_attr( SCF_Config::PREFIX . 'icon-handle dashicons dashicons-menu' ),
|
178 |
+
$post_title
|
179 |
+
);
|
180 |
+
$hidden[] = sprintf(
|
181 |
+
'<input type="hidden" name="%s" value="%d" %s />',
|
182 |
+
esc_attr( $name . '[]' ),
|
183 |
+
$post_id,
|
184 |
+
disabled( true, $disabled, false )
|
185 |
+
);
|
186 |
+
}
|
187 |
+
|
188 |
+
$hide_class = '';
|
189 |
+
if ( count( $choices_li ) < $posts_per_page ) {
|
190 |
+
$hide_class = 'hide';
|
191 |
+
}
|
192 |
+
|
193 |
+
return sprintf(
|
194 |
+
'<div class="%s" data-post-types="%s" data-limit="%d">
|
195 |
+
<div class="%s">
|
196 |
+
<input type="text" class="widefat search-input search-input-post-types" name="search-input" placeholder="%s" />
|
197 |
+
</div>
|
198 |
+
<div class="%s">
|
199 |
+
<ul>%s</ul>
|
200 |
+
<p class="load-relation-items load-relation-post-types %s">%s</p>
|
201 |
+
<input type="hidden" name="%s" %s />
|
202 |
+
%s
|
203 |
+
</div>
|
204 |
+
</div>
|
205 |
+
<div class="%s"><ul>%s</ul></div>
|
206 |
+
<div class="clear"></div>',
|
207 |
+
SCF_Config::PREFIX . 'relation-left',
|
208 |
+
implode( ',', $post_type ),
|
209 |
+
$limit,
|
210 |
+
SCF_Config::PREFIX . 'search',
|
211 |
+
esc_attr__( 'Search...', 'smart-custom-fields' ),
|
212 |
+
SCF_Config::PREFIX . 'relation-children-select',
|
213 |
+
implode( '', $choices_li ),
|
214 |
+
$hide_class,
|
215 |
+
esc_html__( 'Load more', 'smart-custom-fields' ),
|
216 |
+
esc_attr( $name ),
|
217 |
+
disabled( true, $disabled, false ),
|
218 |
+
implode( '', $hidden ),
|
219 |
+
SCF_Config::PREFIX . 'relation-right',
|
220 |
+
implode( '', $selected_li )
|
221 |
+
);
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Displaying the option fields in custom field settings page
|
226 |
+
*
|
227 |
+
* @param int $group_key
|
228 |
+
* @param int $field_key
|
229 |
+
*/
|
230 |
+
public function display_field_options( $group_key, $field_key ) {
|
231 |
+
$this->display_name_option( $group_key, $field_key );
|
232 |
+
$this->display_label_option( $group_key, $field_key );
|
233 |
+
?>
|
234 |
+
<tr>
|
235 |
+
<th><?php esc_html_e( 'Post Types', 'smart-custom-fields' ); ?></th>
|
236 |
+
<td>
|
237 |
+
<?php
|
238 |
+
$post_types = get_post_types( array(
|
239 |
+
'show_ui' => true,
|
240 |
+
), 'objects' );
|
241 |
+
unset( $post_types['attachment'] );
|
242 |
+
unset( $post_types[SCF_Config::NAME] );
|
243 |
+
?>
|
244 |
+
<?php foreach ( $post_types as $post_type => $post_type_object ) : ?>
|
245 |
+
<?php
|
246 |
+
$save_post_types = $this->get( 'post-type' );
|
247 |
+
$checked = ( is_array( $save_post_types ) && in_array( $post_type, $save_post_types ) ) ? 'checked="checked"' : ''; ?>
|
248 |
+
<input type="checkbox"
|
249 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'post-type' ) ); ?>[]"
|
250 |
+
value="<?php echo esc_attr( $post_type ); ?>"
|
251 |
+
<?php echo $checked; ?> /><?php echo esc_html( $post_type_object->labels->singular_name ); ?>
|
252 |
+
<?php endforeach; ?>
|
253 |
+
</td>
|
254 |
+
</tr>
|
255 |
+
<tr>
|
256 |
+
<th><?php esc_html_e( 'Selectable number', 'smart-custom-fields' ); ?></th>
|
257 |
+
<td>
|
258 |
+
<input type="number"
|
259 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'limit' ) ); ?>"
|
260 |
+
value="<?php echo esc_attr( $this->get( 'limit' ) ); ?>" min="1" step="1" />
|
261 |
+
</td>
|
262 |
+
</tr>
|
263 |
+
<tr>
|
264 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
265 |
+
<td>
|
266 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
267 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
268 |
+
</td>
|
269 |
+
</tr>
|
270 |
+
<tr>
|
271 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
272 |
+
<td>
|
273 |
+
<input type="text"
|
274 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
275 |
+
class="widefat"
|
276 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
277 |
+
/>
|
278 |
+
</td>
|
279 |
+
</tr>
|
280 |
+
<?php
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Validating when displaying meta data
|
285 |
+
*
|
286 |
+
* @param array $value
|
287 |
+
* @param string $field_type
|
288 |
+
* @return array
|
289 |
+
*/
|
290 |
+
public function validate_get_value( $value, $field_type ) {
|
291 |
+
if ( $field_type === $this->get_attribute( 'type' ) ) {
|
292 |
+
$validated_value = array();
|
293 |
+
foreach ( $value as $post_id ) {
|
294 |
+
$validated_value[] = $post_id;
|
295 |
+
}
|
296 |
+
$value = $validated_value;
|
297 |
+
}
|
298 |
+
return $value;
|
299 |
+
}
|
300 |
+
}
|
trunk/classes/fields/class.field-related-terms.php
ADDED
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Related_Terms
|
4 |
+
* Version : 1.5.1
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : June 04, 2018
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
20 |
+
add_action( 'wp_ajax_smart-cf-relational-terms-search', array( $this, 'relational_terms_search' ) );
|
21 |
+
add_filter( 'smart-cf-validate-get-value', array( $this, 'validate_get_value' ), 10, 2 );
|
22 |
+
return array(
|
23 |
+
'type' => 'taxonomy',
|
24 |
+
'display-name' => __( 'Related Terms', 'smart-custom-fields' ),
|
25 |
+
'optgroup' => 'other-fields',
|
26 |
+
'allow-multiple-data' => true,
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Set the non required items
|
32 |
+
*
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
protected function options() {
|
36 |
+
return array(
|
37 |
+
'taxonomy' => '',
|
38 |
+
'limit' => 0,
|
39 |
+
'instruction' => '',
|
40 |
+
'notes' => '',
|
41 |
+
);
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Loading resources
|
46 |
+
*
|
47 |
+
* @param string $hook
|
48 |
+
*/
|
49 |
+
public function admin_enqueue_scripts( $hook ) {
|
50 |
+
wp_enqueue_script(
|
51 |
+
SCF_Config::PREFIX . 'editor-relation-common',
|
52 |
+
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
|
53 |
+
array( 'jquery' ),
|
54 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-relation-common.js' ) ),
|
55 |
+
true
|
56 |
+
);
|
57 |
+
|
58 |
+
wp_enqueue_script(
|
59 |
+
SCF_Config::PREFIX . 'editor-relation-taxonomies',
|
60 |
+
plugins_url( SCF_Config::NAME ) . '/js/editor-relation-taxonomies.js',
|
61 |
+
array( 'jquery' ),
|
62 |
+
filemtime( plugin_dir_path( dirname( __FILE__ ) . '/../../js/editor-relation-taxonomies.js' ) ),
|
63 |
+
true
|
64 |
+
);
|
65 |
+
|
66 |
+
wp_localize_script( SCF_Config::PREFIX . 'editor-relation-taxonomies', 'smart_cf_relation_taxonomies', array(
|
67 |
+
'endpoint' => admin_url( 'admin-ajax.php' ),
|
68 |
+
'action' => SCF_Config::PREFIX . 'relational-terms-search',
|
69 |
+
'nonce' => wp_create_nonce( SCF_Config::NAME . '-relation-taxonomies' )
|
70 |
+
) );
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Process that loading post when clicking post load button
|
75 |
+
*/
|
76 |
+
public function relational_terms_search() {
|
77 |
+
check_ajax_referer( SCF_Config::NAME . '-relation-taxonomies', 'nonce' );
|
78 |
+
$_terms = array();
|
79 |
+
$args = array();
|
80 |
+
if ( isset( $_POST['taxonomies'] ) ) {
|
81 |
+
$taxonomies = explode( ',', $_POST['taxonomies'] );
|
82 |
+
$args = array(
|
83 |
+
'order' => 'ASC',
|
84 |
+
'orderby' => 'ID',
|
85 |
+
'number' => '',
|
86 |
+
'hide_empty' => false,
|
87 |
+
'hierarchical' => false,
|
88 |
+
);
|
89 |
+
|
90 |
+
if ( isset( $_POST['click_count'] ) ) {
|
91 |
+
$number = get_option( 'posts_per_page' );
|
92 |
+
$offset = $_POST['click_count'] * $number;
|
93 |
+
$args = array_merge(
|
94 |
+
$args,
|
95 |
+
array(
|
96 |
+
'offset' => $offset,
|
97 |
+
'number' => $number,
|
98 |
+
)
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( isset( $_POST['search'] ) ) {
|
103 |
+
$args = array_merge(
|
104 |
+
$args,
|
105 |
+
array(
|
106 |
+
'search' => $_POST['search'],
|
107 |
+
)
|
108 |
+
);
|
109 |
+
}
|
110 |
+
$_terms = get_terms( $taxonomies, $args );
|
111 |
+
}
|
112 |
+
header( 'Content-Type: application/json; charset=utf-8' );
|
113 |
+
echo json_encode( $_terms );
|
114 |
+
die();
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Getting the field
|
119 |
+
*
|
120 |
+
* @param int $index
|
121 |
+
* @param array $value
|
122 |
+
* @return string html
|
123 |
+
*/
|
124 |
+
public function get_field( $index, $value ) {
|
125 |
+
$name = $this->get_field_name_in_editor( $index );
|
126 |
+
$disabled = $this->get_disable_attribute( $index );
|
127 |
+
$taxonomies = $this->get( 'taxonomy' );
|
128 |
+
$limit = $this->get( 'limit' );
|
129 |
+
if ( ! $taxonomies ) {
|
130 |
+
$taxonomies = array( 'category' );
|
131 |
+
}
|
132 |
+
if ( ! preg_match( '/^\d+$/', $limit ) ) {
|
133 |
+
$limit = '';
|
134 |
+
}
|
135 |
+
$number = get_option( 'posts_per_page' );
|
136 |
+
|
137 |
+
// choicse
|
138 |
+
$choices_terms = get_terms( $taxonomies, array(
|
139 |
+
'order' => 'ASC',
|
140 |
+
'orderby' => 'ID',
|
141 |
+
'hide_empty' => false,
|
142 |
+
'hierarchical' => false,
|
143 |
+
'number' => $number,
|
144 |
+
) );
|
145 |
+
$choices_li = array();
|
146 |
+
foreach ( $choices_terms as $_term ) {
|
147 |
+
$term_name = $_term->name;
|
148 |
+
if ( empty( $term_name ) ) {
|
149 |
+
$term_name = ' ';
|
150 |
+
}
|
151 |
+
$choices_li[] = sprintf(
|
152 |
+
'<li data-id="%d">%s</li>',
|
153 |
+
$_term->term_id,
|
154 |
+
$term_name
|
155 |
+
);
|
156 |
+
}
|
157 |
+
|
158 |
+
// selected
|
159 |
+
$selected_terms = array();
|
160 |
+
if ( !empty( $value ) && is_array( $value ) ) {
|
161 |
+
foreach ( $value as $term_id ) {
|
162 |
+
$term_name = get_term( $term_id )->name;
|
163 |
+
if ( empty( $term_name ) ) {
|
164 |
+
$term_name = ' ';
|
165 |
+
}
|
166 |
+
$selected_terms[$term_id] = $term_name;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
$selected_li = array();
|
170 |
+
$hidden = array();
|
171 |
+
foreach ( $selected_terms as $term_id => $term_name ) {
|
172 |
+
$selected_li[] = sprintf(
|
173 |
+
'<li data-id="%d"><span class="%s"></span>%s<span class="relation-remove">-</li></li>',
|
174 |
+
$term_id,
|
175 |
+
esc_attr( SCF_Config::PREFIX . 'icon-handle dashicons dashicons-menu' ),
|
176 |
+
$term_name
|
177 |
+
);
|
178 |
+
$hidden[] = sprintf(
|
179 |
+
'<input type="hidden" name="%s" value="%d" %s />',
|
180 |
+
esc_attr( $name . '[]' ),
|
181 |
+
$term_id,
|
182 |
+
disabled( true, $disabled, false )
|
183 |
+
);
|
184 |
+
}
|
185 |
+
|
186 |
+
$hide_class = '';
|
187 |
+
if ( count( $choices_li ) < $number ) {
|
188 |
+
$hide_class = 'hide';
|
189 |
+
}
|
190 |
+
|
191 |
+
return sprintf(
|
192 |
+
'<div class="%s" data-taxonomies="%s" data-limit="%d">
|
193 |
+
<div class="%s">
|
194 |
+
<input type="text" class="widefat search-input search-input-terms" name="search-input" placeholder="%s" />
|
195 |
+
</div>
|
196 |
+
<div class="%s">
|
197 |
+
<ul>%s</ul>
|
198 |
+
<p class="load-relation-items load-relation-terms %s">%s</p>
|
199 |
+
<input type="hidden" name="%s" %s />
|
200 |
+
%s
|
201 |
+
</div>
|
202 |
+
</div>
|
203 |
+
<div class="%s"><ul>%s</ul></div>
|
204 |
+
<div class="clear"></div>',
|
205 |
+
SCF_Config::PREFIX . 'relation-left',
|
206 |
+
implode( ',', $taxonomies ),
|
207 |
+
$limit,
|
208 |
+
SCF_Config::PREFIX . 'search',
|
209 |
+
esc_attr__( 'Search...', 'smart-custom-fields' ),
|
210 |
+
SCF_Config::PREFIX . 'relation-children-select',
|
211 |
+
implode( '', $choices_li ),
|
212 |
+
$hide_class,
|
213 |
+
esc_html__( 'Load more', 'smart-custom-fields' ),
|
214 |
+
esc_attr( $name ),
|
215 |
+
disabled( true, $disabled, false ),
|
216 |
+
implode( '', $hidden ),
|
217 |
+
SCF_Config::PREFIX . 'relation-right',
|
218 |
+
implode( '', $selected_li )
|
219 |
+
);
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Displaying the option fields in custom field settings page
|
224 |
+
*
|
225 |
+
* @param int $group_key
|
226 |
+
* @param int $field_key
|
227 |
+
*/
|
228 |
+
public function display_field_options( $group_key, $field_key ) {
|
229 |
+
$this->display_name_option( $group_key, $field_key );
|
230 |
+
$this->display_label_option( $group_key, $field_key );
|
231 |
+
?>
|
232 |
+
<tr>
|
233 |
+
<th><?php esc_html_e( 'Taxonomies', 'smart-custom-fields' ); ?></th>
|
234 |
+
<td>
|
235 |
+
<?php
|
236 |
+
$tasonomies = get_taxonomies( array(
|
237 |
+
'show_ui' => true,
|
238 |
+
), 'objects' );
|
239 |
+
?>
|
240 |
+
<?php foreach ( $tasonomies as $taxonomy => $taxonomy_object ) : ?>
|
241 |
+
<?php
|
242 |
+
$save_taxonomies = $this->get( 'taxonomy' );
|
243 |
+
$checked = ( is_array( $save_taxonomies ) && in_array( $taxonomy, $save_taxonomies ) ) ? 'checked="checked"' : ''; ?>
|
244 |
+
<input type="checkbox"
|
245 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'taxonomy' ) ); ?>[]"
|
246 |
+
value="<?php echo esc_attr( $taxonomy ); ?>"
|
247 |
+
<?php echo $checked; ?> /><?php echo esc_html( $taxonomy_object->labels->singular_name ); ?>
|
248 |
+
<?php endforeach; ?>
|
249 |
+
</td>
|
250 |
+
</tr>
|
251 |
+
<tr>
|
252 |
+
<th><?php esc_html_e( 'Selectable number', 'smart-custom-fields' ); ?></th>
|
253 |
+
<td>
|
254 |
+
<input type="number"
|
255 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'limit' ) ); ?>"
|
256 |
+
value="<?php echo esc_attr( $this->get( 'limit' ) ); ?>" min="1" step="1" />
|
257 |
+
</td>
|
258 |
+
</tr>
|
259 |
+
<tr>
|
260 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
261 |
+
<td>
|
262 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
263 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
264 |
+
</td>
|
265 |
+
</tr>
|
266 |
+
<tr>
|
267 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
268 |
+
<td>
|
269 |
+
<input type="text"
|
270 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
271 |
+
class="widefat"
|
272 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
273 |
+
/>
|
274 |
+
</td>
|
275 |
+
</tr>
|
276 |
+
<?php
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Validating when displaying meta data
|
281 |
+
*
|
282 |
+
* @param array $value
|
283 |
+
* @param string $field_type
|
284 |
+
* @return array
|
285 |
+
*/
|
286 |
+
public function validate_get_value( $value, $field_type ) {
|
287 |
+
if ( $field_type === $this->get_attribute( 'type' ) ) {
|
288 |
+
$validated_value = array();
|
289 |
+
foreach ( $value as $term ) {
|
290 |
+
$validated_value[] = $term;
|
291 |
+
}
|
292 |
+
$value = $validated_value;
|
293 |
+
}
|
294 |
+
return $value;
|
295 |
+
}
|
296 |
+
}
|
trunk/classes/fields/class.field-select.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Select
|
4 |
+
* Version : 1.3.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : June 4, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
return array(
|
20 |
+
'type' => 'select',
|
21 |
+
'display-name' => __( 'Select', 'smart-custom-fields' ),
|
22 |
+
'optgroup' => 'select-fields',
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Set the non required items
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
protected function options() {
|
32 |
+
return array(
|
33 |
+
'choices' => '',
|
34 |
+
'default' => '',
|
35 |
+
'instruction' => '',
|
36 |
+
'notes' => '',
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Getting the field
|
42 |
+
*
|
43 |
+
* @param int $index
|
44 |
+
* @param string $value
|
45 |
+
* @return string html
|
46 |
+
*/
|
47 |
+
public function get_field( $index, $value ) {
|
48 |
+
$name = $this->get_field_name_in_editor( $index );
|
49 |
+
$disabled = $this->get_disable_attribute( $index );
|
50 |
+
$choices = SCF::choices_eol_to_array( $this->get( 'choices' ) );
|
51 |
+
|
52 |
+
$form_field = '';
|
53 |
+
foreach ( $choices as $key => $choice ) {
|
54 |
+
$choice = trim( $choice );
|
55 |
+
if ( !SCF::is_assoc( $choices ) ) {
|
56 |
+
$key = $choice;
|
57 |
+
}
|
58 |
+
$form_field .= sprintf( '<option value="%1$s" %2$s>%3$s</option>',
|
59 |
+
esc_attr( $key ),
|
60 |
+
selected( $value, $key, false ),
|
61 |
+
esc_html( $choice )
|
62 |
+
);
|
63 |
+
}
|
64 |
+
return sprintf(
|
65 |
+
'<select name="%s" %s>%s</select>',
|
66 |
+
esc_attr( $name ),
|
67 |
+
disabled( true, $disabled, false ),
|
68 |
+
$form_field
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Displaying the option fields in custom field settings page
|
74 |
+
*
|
75 |
+
* @param int $group_key
|
76 |
+
* @param int $field_key
|
77 |
+
*/
|
78 |
+
public function display_field_options( $group_key, $field_key ) {
|
79 |
+
$this->display_name_option( $group_key, $field_key );
|
80 |
+
$this->display_label_option( $group_key, $field_key );
|
81 |
+
?>
|
82 |
+
<tr>
|
83 |
+
<th><?php esc_html_e( 'Choices', 'smart-custom-fields' ); ?></th>
|
84 |
+
<td>
|
85 |
+
<textarea
|
86 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'choices' ) ); ?>"
|
87 |
+
class="widefat"
|
88 |
+
rows="5" /><?php echo esc_textarea( "\n" . $this->get( 'choices' ) ); ?></textarea>
|
89 |
+
<?php esc_html_e( 'If you want to separate the key and the value, enter as follows: key => value', 'smart-custom-fields' ); ?>
|
90 |
+
</td>
|
91 |
+
</tr>
|
92 |
+
<tr>
|
93 |
+
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
94 |
+
<td>
|
95 |
+
<input type="text"
|
96 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
97 |
+
class="widefat"
|
98 |
+
value="<?php echo esc_attr( $this->get( 'default' ) ); ?>" />
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
+
<tr>
|
102 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
103 |
+
<td>
|
104 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
105 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
106 |
+
</td>
|
107 |
+
</tr>
|
108 |
+
<tr>
|
109 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
110 |
+
<td>
|
111 |
+
<input type="text"
|
112 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
113 |
+
class="widefat"
|
114 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
115 |
+
/>
|
116 |
+
</td>
|
117 |
+
</tr>
|
118 |
+
<?php
|
119 |
+
}
|
120 |
+
}
|
trunk/classes/fields/class.field-text.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Text
|
4 |
+
* Version : 1.2.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : June 4, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
return array(
|
20 |
+
'type' => 'text',
|
21 |
+
'display-name' => __( 'Text', 'smart-custom-fields' ),
|
22 |
+
'optgroup' => 'basic-fields',
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Set the non required items
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
protected function options() {
|
32 |
+
return array(
|
33 |
+
'default' => '',
|
34 |
+
'instruction' => '',
|
35 |
+
'notes' => '',
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Getting the field
|
41 |
+
*
|
42 |
+
* @param int $index
|
43 |
+
* @param string $value
|
44 |
+
* @return string html
|
45 |
+
*/
|
46 |
+
public function get_field( $index, $value ) {
|
47 |
+
$name = $this->get_field_name_in_editor( $index );
|
48 |
+
$disabled = $this->get_disable_attribute( $index );
|
49 |
+
return sprintf(
|
50 |
+
'<input type="text" name="%s" value="%s" class="widefat" %s />',
|
51 |
+
esc_attr( $name ),
|
52 |
+
esc_attr( $value ),
|
53 |
+
disabled( true, $disabled, false )
|
54 |
+
);
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Displaying the option fields in custom field settings page
|
59 |
+
*
|
60 |
+
* @param int $group_key
|
61 |
+
* @param int $field_key
|
62 |
+
*/
|
63 |
+
public function display_field_options( $group_key, $field_key ) {
|
64 |
+
$this->display_name_option( $group_key, $field_key );
|
65 |
+
$this->display_label_option( $group_key, $field_key );
|
66 |
+
?>
|
67 |
+
<tr>
|
68 |
+
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
69 |
+
<td>
|
70 |
+
<input type="text"
|
71 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
72 |
+
class="widefat"
|
73 |
+
value="<?php echo esc_attr( $this->get( 'default' ) ); ?>" />
|
74 |
+
</td>
|
75 |
+
</tr>
|
76 |
+
<tr>
|
77 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
78 |
+
<td>
|
79 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
80 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
81 |
+
</td>
|
82 |
+
</tr>
|
83 |
+
<tr>
|
84 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
85 |
+
<td>
|
86 |
+
<input type="text"
|
87 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
88 |
+
class="widefat"
|
89 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
90 |
+
/>
|
91 |
+
</td>
|
92 |
+
</tr>
|
93 |
+
<?php
|
94 |
+
}
|
95 |
+
}
|
trunk/classes/fields/class.field-textarea.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Textarea
|
4 |
+
* Version : 1.3.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : June 4, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
return array(
|
20 |
+
'type' => 'textarea',
|
21 |
+
'display-name' => __( 'Textarea', 'smart-custom-fields' ),
|
22 |
+
'optgroup' => 'basic-fields',
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Set the non required items
|
28 |
+
*
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
protected function options() {
|
32 |
+
return array(
|
33 |
+
'rows' => 5,
|
34 |
+
'default' => '',
|
35 |
+
'instruction' => '',
|
36 |
+
'notes' => '',
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Getting the field
|
42 |
+
*
|
43 |
+
* @param int $index
|
44 |
+
* @param string $value
|
45 |
+
* @return string html
|
46 |
+
*/
|
47 |
+
public function get_field( $index, $value ) {
|
48 |
+
$name = $this->get_field_name_in_editor( $index );
|
49 |
+
$disabled = $this->get_disable_attribute( $index );
|
50 |
+
$rows = $this->get( 'rows' );
|
51 |
+
return sprintf(
|
52 |
+
'<textarea name="%s" rows="%d" class="widefat" %s>%s</textarea>',
|
53 |
+
esc_attr( $name ),
|
54 |
+
esc_attr( $rows ),
|
55 |
+
disabled( true, $disabled, false ),
|
56 |
+
$value
|
57 |
+
);
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Displaying the option fields in custom field settings page
|
62 |
+
*
|
63 |
+
* @param int $group_key
|
64 |
+
* @param int $field_key
|
65 |
+
*/
|
66 |
+
public function display_field_options( $group_key, $field_key ) {
|
67 |
+
$this->display_name_option( $group_key, $field_key );
|
68 |
+
$this->display_label_option( $group_key, $field_key );
|
69 |
+
?>
|
70 |
+
<tr>
|
71 |
+
<th><?php esc_html_e( 'Rows', 'smart-custom-fields' ); ?></th>
|
72 |
+
<td>
|
73 |
+
<input type="number"
|
74 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'rows' ) ); ?>"
|
75 |
+
min="3"
|
76 |
+
value="<?php echo esc_attr( $this->get( 'rows' ) ); ?>"
|
77 |
+
/>
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
+
<tr>
|
81 |
+
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
82 |
+
<td>
|
83 |
+
<textarea
|
84 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
85 |
+
class="widefat"
|
86 |
+
rows="5"><?php echo esc_textarea( "\n" . $this->get( 'default' ) ); ?></textarea>
|
87 |
+
</td>
|
88 |
+
</tr>
|
89 |
+
<tr>
|
90 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
91 |
+
<td>
|
92 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
93 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
94 |
+
</td>
|
95 |
+
</tr>
|
96 |
+
<tr>
|
97 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
98 |
+
<td>
|
99 |
+
<input type="text"
|
100 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
101 |
+
class="widefat"
|
102 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
103 |
+
/>
|
104 |
+
</td>
|
105 |
+
</tr>
|
106 |
+
<?php
|
107 |
+
}
|
108 |
+
}
|
trunk/classes/fields/class.field-wysiwyg.php
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Wysiwyg
|
4 |
+
* Version : 1.2.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : June 4, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set the required items
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
protected function init() {
|
19 |
+
add_action(
|
20 |
+
SCF_Config::PREFIX . 'before-editor-enqueue-scripts',
|
21 |
+
array( $this, 'editor_enqueue_scripts' )
|
22 |
+
);
|
23 |
+
add_filter( 'smart-cf-validate-get-value', array( $this, 'validate_get_value' ), 10, 2 );
|
24 |
+
return array(
|
25 |
+
'type' => 'wysiwyg',
|
26 |
+
'display-name' => __( 'Wysiwyg', 'smart-custom-fields' ),
|
27 |
+
'optgroup' => 'content-fields',
|
28 |
+
);
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Set the non required items
|
33 |
+
*
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
protected function options() {
|
37 |
+
return array(
|
38 |
+
'default' => '',
|
39 |
+
'instruction' => '',
|
40 |
+
'notes' => '',
|
41 |
+
);
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Loading js after loading TinyMCE in editor page
|
46 |
+
*/
|
47 |
+
public function editor_enqueue_scripts() {
|
48 |
+
add_action( 'after_wp_tiny_mce', array( $this, 'after_wp_tiny_mce' ) );
|
49 |
+
}
|
50 |
+
public function after_wp_tiny_mce() {
|
51 |
+
printf(
|
52 |
+
'<script type="text/javascript" src="%s"></script>',
|
53 |
+
plugins_url( SCF_Config::NAME ) . '/js/editor-wysiwyg.js'
|
54 |
+
);
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Processing to be executed immediately after the field initialization
|
59 |
+
* If not exec this, taxonomy and profile wysiwyg has js error.
|
60 |
+
*/
|
61 |
+
protected function after_loaded() {
|
62 |
+
add_action( 'admin_footer', array( $this, 'admin_footer' ) );
|
63 |
+
}
|
64 |
+
public function admin_footer() {
|
65 |
+
?>
|
66 |
+
<div style="display:none;">
|
67 |
+
<?php wp_editor( '', SCF_Config::PREFIX . 'wysiwyg-base' ); ?>
|
68 |
+
</div>
|
69 |
+
<?php
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Getting the field
|
74 |
+
*
|
75 |
+
* @param int $index
|
76 |
+
* @param string $value
|
77 |
+
* @return string html
|
78 |
+
*/
|
79 |
+
public function get_field( $index, $value ) {
|
80 |
+
$name = $this->get_field_name_in_editor( $index );
|
81 |
+
$wysiwyg_id = str_replace( array( '[', ']', '-' ), '_', $name );
|
82 |
+
$disabled = $this->get_disable_attribute( $index );
|
83 |
+
if ( function_exists( 'format_for_editor' ) ) {
|
84 |
+
$value = format_for_editor( $value );
|
85 |
+
} else {
|
86 |
+
$value = wp_richedit_pre( $value );
|
87 |
+
}
|
88 |
+
return sprintf(
|
89 |
+
'<div class="wp-core-ui wp-editor-wrap tmce-active">
|
90 |
+
<div class="wp-editor-tools hide-if-no-js">
|
91 |
+
<div class="wp-media-buttons">%1$s</div>
|
92 |
+
<div class="wp-editor-tabs">
|
93 |
+
<button type="button" id="%2$s-tmce" class="smart-cf-switch-editor wp-switch-editor switch-tmce" data-wp-editor-id="%2$s">%6$s</button>
|
94 |
+
<button type="button" id="%2$s-html" class="smart-cf-switch-editor wp-switch-editor switch-html" data-wp-editor-id="%2$s">%7$s</button>
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
<div class="wp-editor-container">
|
98 |
+
<div id="qt_%2$s_toolbar" class="quicktags-toolbar"></div>
|
99 |
+
<textarea name="%3$s" rows="8" class="widefat wp-editor-area smart-cf-wp-editor" %4$s>%5$s</textarea>
|
100 |
+
</div>
|
101 |
+
</div>',
|
102 |
+
$this->media_buttons( $wysiwyg_id ),
|
103 |
+
esc_attr( $wysiwyg_id ),
|
104 |
+
esc_attr( $name ),
|
105 |
+
disabled( true, $disabled, false ),
|
106 |
+
$value,
|
107 |
+
esc_html__( 'Visual', 'smart-custom-fields' ),
|
108 |
+
esc_html__( 'Text', 'smart-custom-fields' )
|
109 |
+
|
110 |
+
);
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Displaying the option fields in custom field settings page
|
115 |
+
*
|
116 |
+
* @param int $group_key
|
117 |
+
* @param int $field_key
|
118 |
+
*/
|
119 |
+
public function display_field_options( $group_key, $field_key ) {
|
120 |
+
$this->display_name_option( $group_key, $field_key );
|
121 |
+
$this->display_label_option( $group_key, $field_key );
|
122 |
+
?>
|
123 |
+
<tr>
|
124 |
+
<th><?php esc_html_e( 'Default', 'smart-custom-fields' ); ?></th>
|
125 |
+
<td>
|
126 |
+
<textarea
|
127 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
128 |
+
class="widefat"
|
129 |
+
rows="5"><?php echo esc_textarea( "\n" . $this->get( 'default' ) ); ?></textarea>
|
130 |
+
</td>
|
131 |
+
</tr>
|
132 |
+
<tr>
|
133 |
+
<th><?php esc_html_e( 'Instruction', 'smart-custom-fields' ); ?></th>
|
134 |
+
<td>
|
135 |
+
<textarea name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'instruction' ) ); ?>"
|
136 |
+
class="widefat" rows="5"><?php echo esc_attr( $this->get( 'instruction' ) ); ?></textarea>
|
137 |
+
</td>
|
138 |
+
</tr>
|
139 |
+
<tr>
|
140 |
+
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
141 |
+
<td>
|
142 |
+
<input type="text"
|
143 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
144 |
+
class="widefat"
|
145 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
146 |
+
/>
|
147 |
+
</td>
|
148 |
+
</tr>
|
149 |
+
<?php
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Return the media button
|
154 |
+
*
|
155 |
+
* @param string $editor_id
|
156 |
+
* @return string
|
157 |
+
*/
|
158 |
+
protected function media_buttons( $editor_id = 'content' ) {
|
159 |
+
$img = '<span class="wp-media-buttons-icon"></span> ';
|
160 |
+
return sprintf( '<a href="#" class="button insert-media add_media" data-editor="%s" title="%s">%s</a>',
|
161 |
+
esc_attr( $editor_id ),
|
162 |
+
esc_attr__( 'Add Media' ),
|
163 |
+
$img . __( 'Add Media' )
|
164 |
+
);
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Validating when displaying meta data
|
169 |
+
*
|
170 |
+
* @param mixed $value
|
171 |
+
* @param string $field_type
|
172 |
+
* @return string|array
|
173 |
+
*/
|
174 |
+
public function validate_get_value( $value, $field_type ) {
|
175 |
+
if ( $field_type === $this->get_attribute( 'type' ) ) {
|
176 |
+
if ( is_array( $value ) ) {
|
177 |
+
$validated_value = array();
|
178 |
+
foreach ( $value as $k => $v ) {
|
179 |
+
$validated_value[$k] = $this->add_the_content_filter( $v );
|
180 |
+
}
|
181 |
+
$value = $validated_value;
|
182 |
+
} else {
|
183 |
+
$value = $this->add_the_content_filter( $value );
|
184 |
+
}
|
185 |
+
}
|
186 |
+
return $value;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Hooking functions that is hooked to the_content
|
191 |
+
*
|
192 |
+
* @param string $value
|
193 |
+
* @return string
|
194 |
+
*/
|
195 |
+
protected function add_the_content_filter( $value ) {
|
196 |
+
if ( has_filter( 'the_content', 'wptexturize' ) ) {
|
197 |
+
$value = wptexturize( $value );
|
198 |
+
}
|
199 |
+
if ( has_filter( 'the_content', 'convert_smilies' ) ) {
|
200 |
+
$value = convert_smilies( $value );
|
201 |
+
}
|
202 |
+
if ( has_filter( 'the_content', 'convert_chars' ) ) {
|
203 |
+
$value = convert_chars( $value );
|
204 |
+
}
|
205 |
+
if ( has_filter( 'the_content', 'wpautop' ) ) {
|
206 |
+
$value = wpautop( $value );
|
207 |
+
}
|
208 |
+
if ( has_filter( 'the_content', 'shortcode_unautop' ) ) {
|
209 |
+
$value = shortcode_unautop( $value );
|
210 |
+
}
|
211 |
+
if ( has_filter( 'the_content', 'prepend_attachment' ) ) {
|
212 |
+
$value = prepend_attachment( $value );
|
213 |
+
}
|
214 |
+
return $value;
|
215 |
+
}
|
216 |
+
}
|
trunk/classes/models/class.abstract-field-base.php
ADDED
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Field_Base
|
4 |
+
* Version : 1.1.1
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : October 7, 2014
|
7 |
+
* Modified : June 2, 2018
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
abstract class Smart_Custom_Fields_Field_Base {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Internal attribute value of this field
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
protected $attributes = array(
|
18 |
+
'type' => '', // eg. text
|
19 |
+
'display-name' => '', // eg. Text
|
20 |
+
'optgroup' => 'other-fields',
|
21 |
+
'allow-multiple-data' => false,
|
22 |
+
'layout' => 'default', // or "full-width" (new attribute to choose layout type)
|
23 |
+
);
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Options of this field
|
27 |
+
* @var array
|
28 |
+
*/
|
29 |
+
protected $options = array(
|
30 |
+
'name' => '',
|
31 |
+
'label' => '',
|
32 |
+
);
|
33 |
+
|
34 |
+
/**
|
35 |
+
* __construct
|
36 |
+
*/
|
37 |
+
public function __construct() {
|
38 |
+
$attributes = array_merge( $this->attributes, $this->init() );
|
39 |
+
$options = array_merge( $this->options, $this->options() );
|
40 |
+
if ( empty( $attributes['type'] ) || empty( $attributes['display-name'] ) ) {
|
41 |
+
exit( 'This field object is invalid. Field object must have type and display-name attributes.' );
|
42 |
+
}
|
43 |
+
if ( empty( $attributes['optgroup'] ) ) {
|
44 |
+
$attributes['optgroup'] = 'basic-fields';
|
45 |
+
}
|
46 |
+
$this->attributes = $attributes;
|
47 |
+
$this->options = $options;
|
48 |
+
add_filter(
|
49 |
+
SCF_Config::PREFIX . 'field-select-' . $attributes['optgroup'],
|
50 |
+
array( $this, 'field_select' )
|
51 |
+
);
|
52 |
+
$this->after_loaded();
|
53 |
+
|
54 |
+
SCF::add_form_field_instance( $this );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Set the required items
|
59 |
+
*
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
+
abstract protected function init();
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Set the non required items
|
66 |
+
*
|
67 |
+
* @return array
|
68 |
+
*/
|
69 |
+
abstract protected function options();
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Processing to be executed immediately after the field initialization
|
73 |
+
*/
|
74 |
+
protected function after_loaded() {
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Getting the field
|
79 |
+
*
|
80 |
+
* @param int $index
|
81 |
+
* @param mixed $value
|
82 |
+
* @return string html
|
83 |
+
*/
|
84 |
+
abstract public function get_field( $index, $value );
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Adding the type of this field to fields selection in custom field settings page
|
88 |
+
*
|
89 |
+
* @param array $attributes List of fields that belong to the optgroup
|
90 |
+
* @return array
|
91 |
+
*/
|
92 |
+
public function field_select( $attributes ) {
|
93 |
+
$attributes[$this->get_attribute( 'type' )] = $this->get_attribute( 'display-name' );
|
94 |
+
return $attributes;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Displaying the option fields in custom field settings page ( Common )
|
99 |
+
*
|
100 |
+
* @param int $group_key
|
101 |
+
* @param int $field_key
|
102 |
+
*/
|
103 |
+
public function display_options( $group_key, $field_key ) {
|
104 |
+
$fields = SCF::get_form_field_instances();
|
105 |
+
foreach ( $fields as $Field ) {
|
106 |
+
if ( $Field->get_attribute( 'type' ) === $this->get_attribute( 'type' ) ) {
|
107 |
+
foreach ( $this->options as $key => $value ) {
|
108 |
+
$Field->set( $key, $value );
|
109 |
+
}
|
110 |
+
}
|
111 |
+
$Field->_display_field_options( $group_key, $field_key );
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
protected function display_name_option( $group_key, $field_key ) {
|
116 |
+
?>
|
117 |
+
<tr>
|
118 |
+
<th><?php esc_html_e( 'Name', 'smart-custom-fields' ); ?><span class="<?php echo esc_attr( SCF_Config::PREFIX . 'require' ); ?>">*</span></th>
|
119 |
+
<td>
|
120 |
+
<input type="text"
|
121 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'name' ) ); ?>"
|
122 |
+
size="30"
|
123 |
+
class="<?php echo esc_attr( SCF_Config::PREFIX . 'field-name' ); ?>"
|
124 |
+
value="<?php echo esc_attr( $this->get( 'name' ) ); ?>"
|
125 |
+
/>
|
126 |
+
</td>
|
127 |
+
</tr>
|
128 |
+
<?php
|
129 |
+
}
|
130 |
+
|
131 |
+
protected function display_label_option( $group_key, $field_key ) {
|
132 |
+
?>
|
133 |
+
<tr>
|
134 |
+
<th><?php esc_html_e( 'Label', 'smart-custom-fields' ); ?></th>
|
135 |
+
<td>
|
136 |
+
<input type="text"
|
137 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'label' ) ); ?>"
|
138 |
+
size="30"
|
139 |
+
class="<?php echo esc_attr( SCF_Config::PREFIX . 'field-label' ); ?>"
|
140 |
+
value="<?php echo esc_attr( $this->get( 'label' ) ); ?>"
|
141 |
+
/>
|
142 |
+
</td>
|
143 |
+
</tr>
|
144 |
+
<?php
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Displaying the option fields in custom field settings page ( original )
|
149 |
+
*
|
150 |
+
* @param int $group_key
|
151 |
+
* @param int $field_key
|
152 |
+
*/
|
153 |
+
abstract protected function display_field_options( $group_key, $field_key );
|
154 |
+
public function _display_field_options( $group_key, $field_key ) {
|
155 |
+
?>
|
156 |
+
<tr class="<?php echo esc_attr( SCF_Config::PREFIX . 'field-options' ); ?> <?php echo esc_attr( SCF_Config::PREFIX . 'field-options-' . $this->get_attribute( 'type' ) ); ?> hide">
|
157 |
+
<td colspan="2">
|
158 |
+
<table>
|
159 |
+
<?php $this->display_field_options( $group_key, $field_key ); ?>
|
160 |
+
</table>
|
161 |
+
</td>
|
162 |
+
</tr>
|
163 |
+
<?php
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Getting the name attribute in editor page
|
168 |
+
*
|
169 |
+
* @param string $name
|
170 |
+
* @param string $index
|
171 |
+
* @return string
|
172 |
+
*/
|
173 |
+
protected function get_field_name_in_editor( $index ) {
|
174 |
+
return sprintf(
|
175 |
+
'%s[%s][%s]',
|
176 |
+
SCF_Config::NAME,
|
177 |
+
$this->get( 'name' ),
|
178 |
+
$index
|
179 |
+
);
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Whether to disabled
|
184 |
+
* Return true only when the null because data that all users have saved when $index is not null
|
185 |
+
*
|
186 |
+
* @param string $index
|
187 |
+
* @return bool $disabled
|
188 |
+
*/
|
189 |
+
protected function get_disable_attribute( $index ) {
|
190 |
+
$disabled = false;
|
191 |
+
if ( is_null( $index ) ) {
|
192 |
+
$disabled = true;
|
193 |
+
}
|
194 |
+
return $disabled;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Getting the name attribute in custom field settings page
|
199 |
+
*
|
200 |
+
* @param int $group_key
|
201 |
+
* @param int $field_key
|
202 |
+
* @param string $name
|
203 |
+
* @return string
|
204 |
+
*/
|
205 |
+
public function get_field_name_in_setting( $group_key, $field_key, $name ) {
|
206 |
+
return sprintf(
|
207 |
+
'%s[%s][fields][%s][%s]',
|
208 |
+
SCF_Config::NAME,
|
209 |
+
$group_key,
|
210 |
+
$field_key,
|
211 |
+
$name
|
212 |
+
);
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Getting saved option value
|
217 |
+
*
|
218 |
+
* @param string $key key of the data
|
219 |
+
* @return mixed
|
220 |
+
*/
|
221 |
+
public function get( $key ) {
|
222 |
+
if ( array_key_exists( $key, $this->options ) ) {
|
223 |
+
return $this->options[$key];
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Set option value
|
229 |
+
*
|
230 |
+
* @param string $key
|
231 |
+
* @param mixed $value
|
232 |
+
*/
|
233 |
+
public function set( $key, $value ) {
|
234 |
+
if ( array_key_exists( $key, $this->options ) ) {
|
235 |
+
$this->options[$key] = $value;
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Getting the attribute value
|
241 |
+
*
|
242 |
+
* @param string $key
|
243 |
+
* @return mixed
|
244 |
+
*/
|
245 |
+
public function get_attribute( $key ) {
|
246 |
+
if ( array_key_exists( $key, $this->attributes ) ) {
|
247 |
+
return $this->attributes[$key];
|
248 |
+
}
|
249 |
+
}
|
250 |
+
}
|
trunk/classes/models/class.ajax.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Ajax
|
4 |
+
* Version : 1.2.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : April 27, 2015
|
7 |
+
* Modified : December 12, 2015
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Ajax {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Hooking the process that it want to fire when the ajax request.
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
18 |
+
add_action( 'delete_term', array( $this, 'delete_term' ), 10, 4 );
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Deleting term meta
|
24 |
+
*
|
25 |
+
* @param int $term_id
|
26 |
+
* @param int $term_taxonomy_id
|
27 |
+
* @param string $taxonomy
|
28 |
+
* @param object $deleted_term
|
29 |
+
*/
|
30 |
+
public function delete_term( $term_id, $term_taxonomy_id, $taxonomy, $deleted_term ) {
|
31 |
+
$Meta = new Smart_Custom_Fields_Meta( $deleted_term );
|
32 |
+
$Meta->delete_term_meta_for_wp43();
|
33 |
+
}
|
34 |
+
}
|
trunk/classes/models/class.cache.php
ADDED
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Cache
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : Mau 31, 2016
|
7 |
+
* Modified :
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Cache {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Singleton instance
|
15 |
+
* @var Smart_Custom_Fields_Cache
|
16 |
+
*/
|
17 |
+
private static $instance;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Getting data proccesses is heavy. So saved getted data to $meta.
|
21 |
+
* Using post_id as key.
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
protected $meta = array();
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Getting data proccesses is heavy. So saved getted data to $settings_posts.
|
28 |
+
* Using post_type as key.
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
protected $settings_posts = array();
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Getting data proccesses is heavy. So saved getted data to $settings.
|
35 |
+
* Using post_type as key.
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
protected $settings = array();
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Getting data proccesses is heavy. So saved getted data to $repeat_multiple_data.
|
42 |
+
* Using post_id as key.
|
43 |
+
* @var array
|
44 |
+
*/
|
45 |
+
protected $repeat_multiple_data = array();
|
46 |
+
|
47 |
+
private function __construct() {}
|
48 |
+
|
49 |
+
public static function getInstance() {
|
50 |
+
if ( !self::$instance ) {
|
51 |
+
self::$instance = new Smart_Custom_Fields_Cache();
|
52 |
+
}
|
53 |
+
return self::$instance;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Clear all caches.
|
58 |
+
*/
|
59 |
+
public function flush() {
|
60 |
+
$this->clear_meta();
|
61 |
+
$this->clear_settings_posts();
|
62 |
+
$this->clear_settings();
|
63 |
+
$this->clear_repeat_multiple_data();
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Saving to cache
|
68 |
+
*
|
69 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
70 |
+
* @param string $name
|
71 |
+
* @param mixed $data
|
72 |
+
*/
|
73 |
+
public function save_meta( $object, $name, $data ) {
|
74 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
75 |
+
$id = $Meta->get_id();
|
76 |
+
$type = $Meta->get_type();
|
77 |
+
$meta_type = $Meta->get_meta_type();
|
78 |
+
if ( !empty( $id ) && !empty( $type ) && !empty( $meta_type ) ) {
|
79 |
+
$this->meta[$meta_type . '_' . $type . '_' . $id][$name] = $data;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Getting the cache
|
85 |
+
*
|
86 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
87 |
+
* @param string $name
|
88 |
+
* @return mixed
|
89 |
+
*/
|
90 |
+
public function get_meta( $object, $name = null ) {
|
91 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
92 |
+
$id = $Meta->get_id();
|
93 |
+
$type = $Meta->get_type();
|
94 |
+
$meta_type = $Meta->get_meta_type();
|
95 |
+
if ( !empty( $id ) && !empty( $type ) && !empty( $meta_type ) ) {
|
96 |
+
if ( is_null( $name ) ) {
|
97 |
+
if ( isset( $this->meta[$meta_type . '_' . $type . '_' . $id] ) ) {
|
98 |
+
return $this->meta[$meta_type . '_' . $type . '_' . $id];
|
99 |
+
}
|
100 |
+
} else {
|
101 |
+
if ( isset( $this->meta[$meta_type . '_' . $type . '_' . $id][$name] ) ) {
|
102 |
+
return $this->meta[$meta_type . '_' . $type . '_' . $id][$name];
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Clear caches
|
110 |
+
*/
|
111 |
+
public function clear_meta() {
|
112 |
+
$this->meta = array();
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Saving to cache that enabled custom field settings in the post type or the role or the term.
|
117 |
+
*
|
118 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
119 |
+
* @param array $settings_posts
|
120 |
+
*/
|
121 |
+
public function save_settings_posts( $object, $settings_posts ) {
|
122 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
123 |
+
$type = $Meta->get_type( false );
|
124 |
+
$meta_type = $Meta->get_meta_type();
|
125 |
+
$this->settings_posts[$meta_type . '_' . $type] = $settings_posts;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Getting cache that enabled custom field settings in the post type or the role or the term.
|
130 |
+
*
|
131 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
132 |
+
* @return array|null
|
133 |
+
*/
|
134 |
+
public function get_settings_posts( $object ) {
|
135 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
136 |
+
$type = $Meta->get_type( false );
|
137 |
+
$meta_type = $Meta->get_meta_type();
|
138 |
+
if ( isset( $this->settings_posts[$meta_type . '_' . $type] ) ) {
|
139 |
+
return $this->settings_posts[$meta_type . '_' . $type];
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Clear the $settings_posts
|
145 |
+
*/
|
146 |
+
public function clear_settings_posts() {
|
147 |
+
$this->settings_posts = array();
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Saving the Setting object to cache
|
152 |
+
*
|
153 |
+
* @param int $settings_post_id
|
154 |
+
* @param Smart_Custom_Fields_Setting $Setting
|
155 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
156 |
+
*/
|
157 |
+
public function save_settings( $settings_post_id, $Setting, $object = null ) {
|
158 |
+
if ( !is_null( $object ) ) {
|
159 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
160 |
+
$id = $Meta->get_id();
|
161 |
+
$meta_type = $Meta->get_meta_type();
|
162 |
+
}
|
163 |
+
if ( !empty( $meta_type ) && !empty( $id ) ) {
|
164 |
+
$this->settings[$settings_post_id][$meta_type . '_' . $id] = $Setting;
|
165 |
+
} else {
|
166 |
+
$this->settings[$settings_post_id][0] = $Setting;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Getting the Setting object cache
|
172 |
+
* If there isn't the custom field settings ... null
|
173 |
+
* If there is custom field settings
|
174 |
+
* If there is no data for the specified $meta_type + $id
|
175 |
+
* There is a thing of the General ... Smart_Custom_Fields_Setting
|
176 |
+
* There isn't a thing of the General ... false
|
177 |
+
* If there the data for the specified $meta_type + $id ... Smart_Custom_Fields_Setting
|
178 |
+
*
|
179 |
+
* @param int $settings_post_id
|
180 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
181 |
+
* @return Smart_Custom_Fields_Setting|false|null
|
182 |
+
*/
|
183 |
+
public function get_settings( $settings_post_id, $object = null ) {
|
184 |
+
if ( !is_null( $object ) ) {
|
185 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
186 |
+
$id = $Meta->get_id();
|
187 |
+
$meta_type = $Meta->get_meta_type();
|
188 |
+
}
|
189 |
+
|
190 |
+
if ( isset( $this->settings[$settings_post_id] ) ) {
|
191 |
+
$settings = $this->settings[$settings_post_id];
|
192 |
+
if ( !empty( $id ) && !empty( $meta_type ) && isset( $settings[$meta_type . '_' . $id] ) ) {
|
193 |
+
return $settings[$meta_type . '_' . $id];
|
194 |
+
}
|
195 |
+
if ( isset( $settings[0] ) ) {
|
196 |
+
return $settings[0];
|
197 |
+
}
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Clear the $settings
|
204 |
+
*/
|
205 |
+
public function clear_settings() {
|
206 |
+
$this->settings = array();
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Saving the delimited identification data of the repeated multi-value items to cache
|
211 |
+
*
|
212 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
213 |
+
* @param mixed $repeat_multiple_data
|
214 |
+
*/
|
215 |
+
public function save_repeat_multiple_data( $object, $repeat_multiple_data ) {
|
216 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
217 |
+
$id = $Meta->get_id();
|
218 |
+
$type = $Meta->get_type();
|
219 |
+
$meta_type = $Meta->get_meta_type();
|
220 |
+
if ( !empty( $id ) && !empty( $type ) && !empty( $meta_type ) ) {
|
221 |
+
$this->repeat_multiple_data[$meta_type . '_' . $type . '_' . $id] = $repeat_multiple_data;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Getting delimited identification data of the repeated multi-value items from cache
|
227 |
+
*
|
228 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
229 |
+
* @return mixed
|
230 |
+
*/
|
231 |
+
public function get_repeat_multiple_data( $object ) {
|
232 |
+
$Meta = new Smart_Custom_Fields_Meta( $object );
|
233 |
+
$id = $Meta->get_id();
|
234 |
+
$type = $Meta->get_type();
|
235 |
+
$meta_type = $Meta->get_meta_type();
|
236 |
+
if ( !empty( $id ) && !empty( $type ) ) {
|
237 |
+
if ( isset( $this->repeat_multiple_data[$meta_type . '_' . $type . '_' . $id] ) ) {
|
238 |
+
return $this->repeat_multiple_data[$meta_type . '_' . $type . '_' . $id];
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Clear delimited identification data of the repeated multi-value items cache
|
245 |
+
*/
|
246 |
+
public function clear_repeat_multiple_data() {
|
247 |
+
$this->repeat_multiple_data = array();
|
248 |
+
}
|
249 |
+
}
|
trunk/classes/models/class.group.php
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Group
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : September 23, 2014
|
7 |
+
* Modified : February 27, 2015
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Group {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Group name
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $name = null;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Array of field objects
|
21 |
+
* @var array
|
22 |
+
*/
|
23 |
+
protected $fields = array();
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Whether repeating group
|
27 |
+
* @var bool
|
28 |
+
*/
|
29 |
+
protected $repeat = false;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* __construct
|
33 |
+
*
|
34 |
+
* @param string $group_name
|
35 |
+
* @param bool $repeat
|
36 |
+
* @param array $_fields
|
37 |
+
*/
|
38 |
+
public function __construct( $group_name = null, $repeat = false, array $_fields = array() ) {
|
39 |
+
$this->name = $group_name;
|
40 |
+
$this->repeat = ( $repeat === true ) ? true : false;
|
41 |
+
$fields = array();
|
42 |
+
foreach ( $_fields as $field_attributes ) {
|
43 |
+
$Field = SCF::get_form_field_instance( $field_attributes['type'] );
|
44 |
+
if ( !is_a( $Field, 'Smart_Custom_Fields_Field_Base' ) ) {
|
45 |
+
continue;
|
46 |
+
}
|
47 |
+
foreach ( $field_attributes as $key => $value ) {
|
48 |
+
$Field->set( $key, $value );
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( !empty( $Field ) ) {
|
52 |
+
$fields[$Field->get( 'name' )] = $Field;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
$this->fields = $fields;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Getting group name
|
60 |
+
*
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function get_name() {
|
64 |
+
if ( is_numeric( $this->name ) ) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
return $this->name;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Getting fields that saved in this settings page
|
72 |
+
*
|
73 |
+
* @return array
|
74 |
+
*/
|
75 |
+
public function get_fields() {
|
76 |
+
return $this->fields;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Getting the field
|
81 |
+
*
|
82 |
+
* @param string $field_name
|
83 |
+
* @return Smart_Custom_Fields_Field_Base|null
|
84 |
+
*/
|
85 |
+
public function get_field( $field_name ) {
|
86 |
+
$fields = $this->get_fields();
|
87 |
+
if ( isset( $fields[$field_name] ) ) {
|
88 |
+
return $fields[$field_name];
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Whether repeating group
|
94 |
+
*
|
95 |
+
* @return bool
|
96 |
+
*/
|
97 |
+
public function is_repeatable() {
|
98 |
+
return $this->repeat;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Displaying "hide" if $key isn't empty
|
103 |
+
*
|
104 |
+
* @param string $key
|
105 |
+
*/
|
106 |
+
private function add_hide_class( $key ) {
|
107 |
+
if ( !$key ) {
|
108 |
+
echo 'hide';
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Displaying the option fields in custom field settings page ( Common )
|
114 |
+
*
|
115 |
+
* @param int $group_key
|
116 |
+
*/
|
117 |
+
public function display_options( $group_key ) {
|
118 |
+
?>
|
119 |
+
<div class="<?php echo esc_attr( SCF_Config::PREFIX . 'group-repeat' ); ?>">
|
120 |
+
<div class="<?php echo esc_attr( SCF_Config::PREFIX . 'icon-handle' ); ?>"></div>
|
121 |
+
<label>
|
122 |
+
<input type="checkbox"
|
123 |
+
name="<?php echo esc_attr( SCF_Config::NAME . '[' . $group_key . '][repeat]' ); ?>"
|
124 |
+
value="true"
|
125 |
+
<?php checked( $this->is_repeatable(), true ); ?>
|
126 |
+
/>
|
127 |
+
<?php esc_html_e( 'Repeat', 'smart-custom-fields' ); ?>
|
128 |
+
</label>
|
129 |
+
</div>
|
130 |
+
<table class="<?php echo esc_attr( SCF_Config::PREFIX . 'group-names' ); ?> <?php $this->add_hide_class( $this->is_repeatable() ); ?>">
|
131 |
+
<tr>
|
132 |
+
<th><?php esc_html_e( 'Group name', 'smart-custom-fields' ); ?><span class="<?php echo esc_attr( SCF_Config::PREFIX . 'require' ); ?>">*</span></th>
|
133 |
+
<td>
|
134 |
+
<input type="text"
|
135 |
+
name="<?php echo esc_attr( SCF_Config::NAME . '[' . $group_key . '][group-name]' ); ?>"
|
136 |
+
size="30"
|
137 |
+
class="<?php echo esc_attr( SCF_Config::PREFIX . 'group-name' ); ?>"
|
138 |
+
value="<?php echo esc_attr( $this->get_name() ); ?>"
|
139 |
+
/>
|
140 |
+
</td>
|
141 |
+
</tr>
|
142 |
+
</table>
|
143 |
+
<?php
|
144 |
+
}
|
145 |
+
}
|
trunk/classes/models/class.meta.php
ADDED
@@ -0,0 +1,561 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Meta
|
4 |
+
* Version : 2.1.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : March 17, 2015
|
7 |
+
* Modified : September 30, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Meta {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var WP_Post|WP_User|WP_Term|stdClass
|
15 |
+
*/
|
16 |
+
protected $object;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* What meta data
|
20 |
+
* @var string post or user or term or option
|
21 |
+
*/
|
22 |
+
protected $meta_type = 'post';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Post ID or User ID or Term ID or Menu slug
|
26 |
+
* @var int
|
27 |
+
*/
|
28 |
+
protected $id;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Post Type or Role or Taxonomy or Menu slug
|
32 |
+
* @var string
|
33 |
+
* @deprecated
|
34 |
+
*/
|
35 |
+
protected $type;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Post Type or Roles or Taxonomy or Menu slug
|
39 |
+
* @var array
|
40 |
+
*/
|
41 |
+
protected $types = array();
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param WP_Post|WP_User|WP_Term|stdClass $object
|
45 |
+
*/
|
46 |
+
public function __construct( $object ) {
|
47 |
+
$this->object = $object;
|
48 |
+
if ( is_a( $object, 'WP_Post' ) ) {
|
49 |
+
$this->id = $object->ID;
|
50 |
+
$this->type = $object->post_type;
|
51 |
+
$this->types = array( $object->post_type );
|
52 |
+
$this->meta_type = 'post';
|
53 |
+
}
|
54 |
+
elseif ( is_a( $object, 'WP_User' ) ) {
|
55 |
+
$this->id = $object->ID;
|
56 |
+
$this->type = $object->roles[0];
|
57 |
+
$this->types = array_unique( array_merge( $object->roles, array_keys( $object->caps ) ) );
|
58 |
+
$this->meta_type = 'user';
|
59 |
+
}
|
60 |
+
elseif ( isset( $object->term_id ) ) {
|
61 |
+
$this->id = $object->term_id;
|
62 |
+
$this->type = $object->taxonomy;
|
63 |
+
$this->types = array( $object->taxonomy );
|
64 |
+
$this->meta_type = 'term';
|
65 |
+
}
|
66 |
+
elseif ( isset( $object->menu_slug ) ) {
|
67 |
+
$this->id = $object->menu_slug;
|
68 |
+
$this->type = $object->menu_slug;
|
69 |
+
$this->types = array( $object->menu_slug );
|
70 |
+
$this->meta_type = 'option';
|
71 |
+
}
|
72 |
+
elseif( empty( $object ) || is_wp_error( $object ) ) {
|
73 |
+
$this->id = null;
|
74 |
+
$this->type = null;
|
75 |
+
$this->types = null;
|
76 |
+
$this->meta_type = null;
|
77 |
+
}
|
78 |
+
else {
|
79 |
+
throw new Exception( sprintf( 'Invalid $object type error. $object is "%s".', get_class( $object ) ) );
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Getting the meta type
|
85 |
+
*
|
86 |
+
* @return string post or user or term or option
|
87 |
+
*/
|
88 |
+
public function get_meta_type() {
|
89 |
+
return $this->meta_type;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Getting object ID. When option, this is menu slug.
|
94 |
+
*
|
95 |
+
* @return int|string
|
96 |
+
*/
|
97 |
+
public function get_id() {
|
98 |
+
return $this->id;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Getting type ( Post type or Role or Taxonomy or Menu slug )
|
103 |
+
*
|
104 |
+
* @deprecated
|
105 |
+
* @param bool $accept_revision If post type, whether allow revision post type
|
106 |
+
* @return string
|
107 |
+
*/
|
108 |
+
public function get_type( $accept_revision = true ) {
|
109 |
+
if ( $this->meta_type === 'post' && !$accept_revision ) {
|
110 |
+
$public_post_type = $this->get_public_post_type( $this->id );
|
111 |
+
return $public_post_type[0];
|
112 |
+
}
|
113 |
+
return $this->type;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Getting type ( Post type or Role or Taxonomy or Menu slug )
|
118 |
+
*
|
119 |
+
* @param bool $accept_revision If post type, whether allow revision post type
|
120 |
+
* @return array
|
121 |
+
*/
|
122 |
+
public function get_types( $accept_revision = true ) {
|
123 |
+
if ( $this->meta_type === 'post' && ! $accept_revision ) {
|
124 |
+
return $this->get_public_post_type( $this->id );
|
125 |
+
}
|
126 |
+
return $this->types;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Getting post type
|
131 |
+
* To feel good also Post ID of the revision
|
132 |
+
*
|
133 |
+
* @param int $post_id
|
134 |
+
* @return array
|
135 |
+
*/
|
136 |
+
protected function get_public_post_type( $post_id ) {
|
137 |
+
if ( $public_post_id = wp_is_post_revision( $post_id ) ) {
|
138 |
+
$post = get_post( $public_post_id );
|
139 |
+
} else {
|
140 |
+
$post = get_post( $post_id );
|
141 |
+
}
|
142 |
+
if ( !empty( $post->post_type ) ) {
|
143 |
+
return array( $post->post_type );
|
144 |
+
}
|
145 |
+
return $this->types;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Object with this meta data is whether saved
|
150 |
+
* Post ... If auto-draft, not saved (new posts in)
|
151 |
+
* Profile or Taxonomy or option ... Since not display only after saving.
|
152 |
+
* So if all of meta data is empty,
|
153 |
+
* It is determined that not saved
|
154 |
+
*
|
155 |
+
* @return bool
|
156 |
+
*/
|
157 |
+
public function is_saved( $key = null ) {
|
158 |
+
if ( $this->meta_type === 'post' && get_post_status( $this->get_id() ) === 'auto-draft' ) {
|
159 |
+
return false;
|
160 |
+
}
|
161 |
+
if ( !$this->get() ) {
|
162 |
+
return false;
|
163 |
+
}
|
164 |
+
return true;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* The metadata is wheter saved.
|
169 |
+
*
|
170 |
+
* @param string $key
|
171 |
+
* @return bool
|
172 |
+
*/
|
173 |
+
public function is_saved_the_key( $key ) {
|
174 |
+
if ( $this->meta_type === 'post' && get_post_status( $this->get_id() ) === 'auto-draft' ) {
|
175 |
+
return false;
|
176 |
+
}
|
177 |
+
|
178 |
+
if ( _get_meta_table( $this->meta_type ) && !$this->maybe_4_3_term_meta() ) {
|
179 |
+
return metadata_exists( $this->meta_type, $this->id, $key );
|
180 |
+
}
|
181 |
+
|
182 |
+
$option = get_option( $this->get_option_name() );
|
183 |
+
if ( is_array( $option ) ) {
|
184 |
+
return array_key_exists( $key, $option );
|
185 |
+
}
|
186 |
+
return false;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Less than WordPress 4.4 compatibility for term meta
|
191 |
+
* More than 4.4 are saved in meta. So if that use the meta data.
|
192 |
+
*
|
193 |
+
* @return bool
|
194 |
+
*/
|
195 |
+
public function maybe_4_3_term_meta() {
|
196 |
+
if ( $this->meta_type == 'term' ) {
|
197 |
+
if ( !get_metadata( $this->meta_type, $this->id ) && get_option( $this->get_option_name() ) ) {
|
198 |
+
return true;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
return false;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Getting the meta data
|
206 |
+
*
|
207 |
+
* @param string|null $key
|
208 |
+
* @param bool $single false ... return array, true ... return string
|
209 |
+
* @return string|array
|
210 |
+
*/
|
211 |
+
public function get( $key = '', $single = false ) {
|
212 |
+
if ( _get_meta_table( $this->meta_type ) && !$this->maybe_4_3_term_meta() ) {
|
213 |
+
$meta = get_metadata( $this->meta_type, $this->id, $key, $single );
|
214 |
+
} else {
|
215 |
+
$meta = $this->get_option_metadata( $key, $single );
|
216 |
+
}
|
217 |
+
|
218 |
+
if ( $key === SCF_Config::PREFIX . 'repeat-multiple-data' ) {
|
219 |
+
return $meta;
|
220 |
+
}
|
221 |
+
|
222 |
+
$settings = SCF::get_settings( $this->object );
|
223 |
+
if ( $key ) {
|
224 |
+
foreach ( $settings as $Setting ) {
|
225 |
+
$fields = $Setting->get_fields();
|
226 |
+
if ( !empty( $fields[$key] ) ) {
|
227 |
+
return $meta;
|
228 |
+
}
|
229 |
+
}
|
230 |
+
} else {
|
231 |
+
if ( is_array( $meta ) ) {
|
232 |
+
foreach ( $settings as $Setting ) {
|
233 |
+
$fields = $Setting->get_fields();
|
234 |
+
foreach ( $meta as $meta_key => $meta_value ) {
|
235 |
+
if ( isset( $fields[$meta_key] ) ) {
|
236 |
+
$metas[$meta_key] = $meta[$meta_key];
|
237 |
+
}
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
if ( isset( $metas ) ) {
|
243 |
+
return $metas;
|
244 |
+
}
|
245 |
+
if ( $single ) {
|
246 |
+
return '';
|
247 |
+
}
|
248 |
+
return array();
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Getting option like meta data.
|
253 |
+
*
|
254 |
+
* @param string|null $key
|
255 |
+
* @param bool $single false ... return array, true ... return string
|
256 |
+
* @return string|array
|
257 |
+
*/
|
258 |
+
protected function get_option_metadata( $key, $single ) {
|
259 |
+
$option = get_option( $this->get_option_name() );
|
260 |
+
|
261 |
+
if ( !$key ) {
|
262 |
+
return $option;
|
263 |
+
}
|
264 |
+
|
265 |
+
if ( isset( $option[$key] ) ) {
|
266 |
+
if ( $single && is_array( $option[$key] ) ) {
|
267 |
+
if ( isset( $option[$key][0] ) ) {
|
268 |
+
return $option[$key][0];
|
269 |
+
}
|
270 |
+
} else {
|
271 |
+
return $option[$key];
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
if ( $single ) {
|
276 |
+
return '';
|
277 |
+
}
|
278 |
+
return array();
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Updating meta data. If the meta data not exist, adding it.
|
283 |
+
*
|
284 |
+
* @param string $key
|
285 |
+
* @param mixed $value
|
286 |
+
* @param mixed $prev_value If specified, it overwrites the only ones of this value
|
287 |
+
* @return int|false Meta ID
|
288 |
+
*/
|
289 |
+
public function update( $key, $value, $prev_value = '' ) {
|
290 |
+
$return = false;
|
291 |
+
do_action( SCF_Config::PREFIX . '-before-save-' . $this->meta_type, $this->id, $key, $value );
|
292 |
+
$is_valid = apply_filters( SCF_Config::PREFIX . '-validate-save-' . $this->meta_type, $this->id, $key, $value );
|
293 |
+
if ( $is_valid ) {
|
294 |
+
if ( _get_meta_table( $this->meta_type ) ) {
|
295 |
+
$return = update_metadata( $this->meta_type, $this->id, $key, $value, $prev_value );
|
296 |
+
} else {
|
297 |
+
$return = $this->update_option_metadata( $key, $value, $prev_value );
|
298 |
+
}
|
299 |
+
}
|
300 |
+
do_action( SCF_Config::PREFIX . '-after-save-' . $this->meta_type, $this->id, $key, $value );
|
301 |
+
return $return;
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Updating the option like meta data. If the meta data not exist, adding it.
|
306 |
+
*
|
307 |
+
* @param string $key
|
308 |
+
* @param mixed $value
|
309 |
+
* @param mixed $prev_value If specified, it overwrites the only ones of this value
|
310 |
+
* @return bool
|
311 |
+
*/
|
312 |
+
protected function update_option_metadata( $key, $value, $prev_value ) {
|
313 |
+
$option_name = $this->get_option_name();
|
314 |
+
$option = get_option( $option_name );
|
315 |
+
if ( isset( $option[$key] ) ) {
|
316 |
+
if ( $prev_value !== '' ) {
|
317 |
+
foreach( $option[$key] as $option_key => $option_value ) {
|
318 |
+
if ( $prev_value === $option_value ) {
|
319 |
+
$option[$key][$option_key] = $value;
|
320 |
+
break;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
} else {
|
324 |
+
foreach( $option[$key] as $option_key => $option_value ) {
|
325 |
+
$option[$key][$option_key] = $value;
|
326 |
+
}
|
327 |
+
}
|
328 |
+
} else {
|
329 |
+
$option[$key][] = $value;
|
330 |
+
}
|
331 |
+
$option = stripslashes_deep( $option );
|
332 |
+
return update_option( $option_name, $option, false );
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Adding the meta data
|
337 |
+
*
|
338 |
+
* @param string $key
|
339 |
+
* @param mixed $value
|
340 |
+
* @param bool $unique Whether the key to the unique
|
341 |
+
* @return int|false Meta ID
|
342 |
+
*/
|
343 |
+
public function add( $key, $value, $unique = false ) {
|
344 |
+
$return = false;
|
345 |
+
do_action( SCF_Config::PREFIX . '-before-save-' . $this->meta_type, $this->id, $key, $value );
|
346 |
+
$is_valid = apply_filters( SCF_Config::PREFIX . '-validate-save-' . $this->meta_type, $this->id, $key, $value );
|
347 |
+
if ( $is_valid ) {
|
348 |
+
if ( _get_meta_table( $this->meta_type ) ) {
|
349 |
+
$return = add_metadata( $this->meta_type, $this->id, $key, $value, $unique );
|
350 |
+
} else {
|
351 |
+
$return = $this->add_option_metadata( $key, $value, $unique );
|
352 |
+
}
|
353 |
+
}
|
354 |
+
do_action( SCF_Config::PREFIX . '-after-save-' . $this->meta_type, $this->id, $key, $value );
|
355 |
+
return $return;
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Adding the option like meta data
|
360 |
+
*
|
361 |
+
* @param string $key
|
362 |
+
* @param mixed $value
|
363 |
+
* @param bool $unique Whether the key to the unique
|
364 |
+
* @return bool
|
365 |
+
*/
|
366 |
+
protected function add_option_metadata( $key, $value, $unique ) {
|
367 |
+
$option_name = $this->get_option_name();
|
368 |
+
$option = get_option( $option_name );
|
369 |
+
if ( !$unique || !isset( $option[$key] ) ) {
|
370 |
+
$option[$key][] = $value;
|
371 |
+
$option = stripslashes_deep( $option );
|
372 |
+
$return = update_option( $option_name, $option, false );
|
373 |
+
}
|
374 |
+
return false;
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Deleting the meta data
|
379 |
+
*
|
380 |
+
* @param string $key
|
381 |
+
* @param mixed $value If specified, it deletes the only ones of this value
|
382 |
+
* @return bool
|
383 |
+
*/
|
384 |
+
public function delete( $key = '', $value = '' ) {
|
385 |
+
if ( _get_meta_table( $this->meta_type ) ) {
|
386 |
+
if ( $key ) {
|
387 |
+
return delete_metadata( $this->meta_type, $this->id, $key, $value );
|
388 |
+
}
|
389 |
+
} else {
|
390 |
+
if ( $key ) {
|
391 |
+
return $this->delete_option_metadata( $key, $value );
|
392 |
+
}
|
393 |
+
}
|
394 |
+
return false;
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Deleting the option like meta data
|
399 |
+
*
|
400 |
+
* @param string $key
|
401 |
+
* @param mixed $value If specified, it deletes the only ones of this value
|
402 |
+
* @return bool
|
403 |
+
*/
|
404 |
+
protected function delete_option_metadata( $key, $value ) {
|
405 |
+
$option_name = $this->get_option_name();
|
406 |
+
$option = get_option( $option_name );
|
407 |
+
|
408 |
+
if ( isset( $option[$key] ) && $value === '' ) {
|
409 |
+
unset( $option[$key] );
|
410 |
+
return update_option( $option_name, $option );
|
411 |
+
}
|
412 |
+
|
413 |
+
if ( isset( $option[$key] ) && $value !== '' ) {
|
414 |
+
foreach ( $option[$key] as $option_key => $option_value ) {
|
415 |
+
if ( $option_value === $value ) {
|
416 |
+
unset( $option[$key][$option_key] );
|
417 |
+
}
|
418 |
+
}
|
419 |
+
return update_option( $option_name, $option );
|
420 |
+
}
|
421 |
+
return false;
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Delete all term meta for less than WordPress 4.3
|
426 |
+
*/
|
427 |
+
public function delete_term_meta_for_wp43() {
|
428 |
+
$option_name = $this->get_option_name();
|
429 |
+
return delete_option( $option_name );
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* Saving the meta data based on the posted data
|
434 |
+
*
|
435 |
+
* @param array $POST
|
436 |
+
*/
|
437 |
+
public function save( array $POST ) {
|
438 |
+
// For repeated multi-value items identification
|
439 |
+
$repeat_multiple_data = array();
|
440 |
+
|
441 |
+
// Retruning empty value when multi-value is empty, it doesn't save
|
442 |
+
$multiple_data_fields = array();
|
443 |
+
|
444 |
+
if ( is_null( $this->object ) ) {
|
445 |
+
return;
|
446 |
+
}
|
447 |
+
|
448 |
+
$this->delete( SCF_Config::PREFIX . 'repeat-multiple-data' );
|
449 |
+
|
450 |
+
if ( !isset( $POST[SCF_Config::NAME] ) ) {
|
451 |
+
return;
|
452 |
+
}
|
453 |
+
|
454 |
+
$settings = SCF::get_settings( $this->object );
|
455 |
+
$saved_data = array();
|
456 |
+
|
457 |
+
foreach ( $settings as $Setting ) {
|
458 |
+
$groups = $Setting->get_groups();
|
459 |
+
foreach ( $groups as $Group ) {
|
460 |
+
$fields = $Group->get_fields();
|
461 |
+
foreach ( $fields as $Field ) {
|
462 |
+
$field_name = $Field->get( 'name' );
|
463 |
+
if ( !isset( $POST[SCF_Config::NAME][$field_name] ) ) {
|
464 |
+
continue;
|
465 |
+
}
|
466 |
+
$saved_data[$field_name] = $POST[SCF_Config::NAME][$field_name];
|
467 |
+
|
468 |
+
$this->delete( $field_name );
|
469 |
+
if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
|
470 |
+
$multiple_data_fields[] = $field_name;
|
471 |
+
}
|
472 |
+
|
473 |
+
if ( $Group->is_repeatable() && $Field->get_attribute( 'allow-multiple-data' ) ) {
|
474 |
+
$repeat_multiple_data_fields = $saved_data[$field_name];
|
475 |
+
foreach ( $repeat_multiple_data_fields as $values ) {
|
476 |
+
if ( is_array( $values ) ) {
|
477 |
+
$repeat_multiple_data[$field_name][] = count( $values );
|
478 |
+
} else {
|
479 |
+
$repeat_multiple_data[$field_name][] = 0;
|
480 |
+
}
|
481 |
+
}
|
482 |
+
}
|
483 |
+
}
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
if ( $repeat_multiple_data ) {
|
488 |
+
$this->update( SCF_Config::PREFIX . 'repeat-multiple-data', $repeat_multiple_data );
|
489 |
+
}
|
490 |
+
|
491 |
+
foreach ( $saved_data as $name => $values ) {
|
492 |
+
foreach ( $values as $value ) {
|
493 |
+
if ( in_array( $name, $multiple_data_fields ) && $value === '' ) {
|
494 |
+
continue;
|
495 |
+
}
|
496 |
+
if ( !is_array( $value ) ) {
|
497 |
+
$this->add( $name, $value );
|
498 |
+
} else {
|
499 |
+
foreach ( $value as $val ) {
|
500 |
+
$this->add( $name, $val );
|
501 |
+
}
|
502 |
+
}
|
503 |
+
}
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
* Restore the data from the revision
|
509 |
+
*
|
510 |
+
* @param WP_Post $revision
|
511 |
+
*/
|
512 |
+
public function restore( $revision ) {
|
513 |
+
if ( $this->meta_type !== 'post' || is_null( $this->object ) || !is_a( $revision, 'WP_Post' ) ) {
|
514 |
+
return;
|
515 |
+
}
|
516 |
+
|
517 |
+
$settings = SCF::get_settings( $this->object );
|
518 |
+
foreach ( $settings as $Setting ) {
|
519 |
+
$fields = $Setting->get_fields();
|
520 |
+
foreach ( $fields as $Field ) {
|
521 |
+
$field_name = $Field->get( 'name' );
|
522 |
+
$this->delete( $field_name );
|
523 |
+
$value = SCF::get( $field_name, $revision->ID );
|
524 |
+
if ( is_array( $value ) ) {
|
525 |
+
foreach ( $value as $val ) {
|
526 |
+
if ( is_array( $val ) ) {
|
527 |
+
foreach ( $val as $v ) {
|
528 |
+
// Repeated multi-value items
|
529 |
+
$this->add( $field_name, $v );
|
530 |
+
}
|
531 |
+
} else {
|
532 |
+
// Repeated single-value items or Non repeated multi-value items
|
533 |
+
$this->add( $field_name, $val );
|
534 |
+
}
|
535 |
+
}
|
536 |
+
} else {
|
537 |
+
// Non repeated single-value item
|
538 |
+
$this->add( $field_name, $value );
|
539 |
+
}
|
540 |
+
}
|
541 |
+
}
|
542 |
+
|
543 |
+
$repeat_multiple_data = SCF::get_repeat_multiple_data( $revision );
|
544 |
+
$repeat_multiple_data_name = SCF_Config::PREFIX . 'repeat-multiple-data';
|
545 |
+
$this->delete( $repeat_multiple_data_name );
|
546 |
+
$this->update( $repeat_multiple_data_name, $repeat_multiple_data );
|
547 |
+
}
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Getting option name for saved options table
|
551 |
+
*/
|
552 |
+
public function get_option_name() {
|
553 |
+
return sprintf(
|
554 |
+
'%s%s-%s-%d',
|
555 |
+
SCF_Config::PREFIX,
|
556 |
+
$this->meta_type,
|
557 |
+
$this->type,
|
558 |
+
$this->id
|
559 |
+
);
|
560 |
+
}
|
561 |
+
}
|
trunk/classes/models/class.options-page.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Options_Page
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : May 29, 2014
|
7 |
+
* Modified :
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Options_Page {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $page_title;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
protected $menu_title;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
protected $capability;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var string
|
30 |
+
*/
|
31 |
+
protected $menu_slug;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
protected $icon_url;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @var int
|
40 |
+
*/
|
41 |
+
protected $position;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @see https://developer.wordpress.org/reference/functions/add_menu_page/
|
45 |
+
* @param string $page_title
|
46 |
+
* @param string $menu_title
|
47 |
+
* @param string $capability
|
48 |
+
* @param string $menu_slug
|
49 |
+
* @param string $icon_url
|
50 |
+
* @param int $position
|
51 |
+
*/
|
52 |
+
public function __construct( $page_title, $menu_title, $capability, $menu_slug, $icon_url = '', $position = null ) {
|
53 |
+
$this->page_title = $page_title;
|
54 |
+
$this->menu_title = $menu_title;
|
55 |
+
$this->capability = $capability;
|
56 |
+
$this->menu_slug = $menu_slug;
|
57 |
+
$this->icon_url = $icon_url;
|
58 |
+
$this->position = $position;
|
59 |
+
add_action( 'admin_menu', array( $this, 'add_options_page_menu' ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
public function add_options_page_menu() {
|
63 |
+
return add_menu_page(
|
64 |
+
$this->page_title,
|
65 |
+
$this->menu_title,
|
66 |
+
$this->capability,
|
67 |
+
$this->menu_slug,
|
68 |
+
array( $this, 'display' ),
|
69 |
+
$this->icon_url,
|
70 |
+
$this->position
|
71 |
+
);
|
72 |
+
}
|
73 |
+
|
74 |
+
public function display() {
|
75 |
+
$Option = SCF::generate_option_object( $_GET['page'] );
|
76 |
+
if ( !$Option ) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
?>
|
80 |
+
<div class="wrap">
|
81 |
+
<h3><?php echo esc_html( $Option->menu_title ); ?></h3>
|
82 |
+
<?php do_action( SCF_Config::PREFIX . 'custom-options-page', $Option ); ?>
|
83 |
+
</div>
|
84 |
+
<?php
|
85 |
+
}
|
86 |
+
}
|
trunk/classes/models/class.revisions.php
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Revisions
|
4 |
+
* Version : 1.1.6
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : September 23, 2014
|
7 |
+
* Modified : August 24, 2016
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Revisions {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* __construct
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
add_filter(
|
18 |
+
'_wp_post_revision_field_' . SCF_Config::PREFIX . 'debug-preview',
|
19 |
+
array( $this, '_wp_post_revision_field_debug_preview' ),
|
20 |
+
10,
|
21 |
+
3
|
22 |
+
);
|
23 |
+
add_filter(
|
24 |
+
'wp_save_post_revision_check_for_changes',
|
25 |
+
array( $this, 'wp_save_post_revision_check_for_changes' ),
|
26 |
+
10,
|
27 |
+
3
|
28 |
+
);
|
29 |
+
add_filter( '_wp_post_revision_fields', array( $this, '_wp_post_revision_fields' ) );
|
30 |
+
add_filter( 'get_post_metadata' , array( $this, 'get_post_metadata' ), 10, 4 );
|
31 |
+
add_action( 'edit_form_after_title' , array( $this, 'edit_form_after_title' ) );
|
32 |
+
add_action( 'wp_restore_post_revision', array( $this, 'wp_restore_post_revision' ), 10, 2 );
|
33 |
+
add_action( 'wp_insert_post' , array( $this, 'wp_insert_post' ) );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* リビジョンから復元するときに呼び出される
|
38 |
+
*
|
39 |
+
* @param int $post_id
|
40 |
+
* @param int $revision_id
|
41 |
+
*/
|
42 |
+
public function wp_restore_post_revision( $post_id, $revision_id ) {
|
43 |
+
$post = get_post( $post_id );
|
44 |
+
$revision = get_post( $revision_id );
|
45 |
+
|
46 |
+
$Meta = new Smart_Custom_Fields_Meta( $post );
|
47 |
+
$Meta->restore( $revision );
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* リビジョンデータを保存
|
52 |
+
* *_post_meta はリビジョンIDのときに自動的に本物IDに変換して処理してしまうので、*_metadata を使うこと
|
53 |
+
*
|
54 |
+
* @param int $post_id リビジョンの投稿ID
|
55 |
+
*/
|
56 |
+
public function wp_insert_post( $post_id ) {
|
57 |
+
if ( !isset( $_POST[SCF_Config::NAME] ) ) {
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
if ( !wp_is_post_revision( $post_id ) ) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
$settings = SCF::get_settings( get_post( $post_id ) );
|
64 |
+
if ( !$settings ) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
check_admin_referer(
|
69 |
+
SCF_Config::NAME . '-fields',
|
70 |
+
SCF_Config::PREFIX . 'fields-nonce'
|
71 |
+
);
|
72 |
+
|
73 |
+
$Meta = new Smart_Custom_Fields_Meta( get_post( $post_id ) );
|
74 |
+
$Meta->save( $_POST );
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* プレビューのときはプレビューのメタデータを返す。ただし、アイキャッチはリビジョンが無いので除外する
|
79 |
+
*
|
80 |
+
* @param mixed $value
|
81 |
+
* @param int $post_id
|
82 |
+
* @param string $meta_key
|
83 |
+
* @param bool $single
|
84 |
+
* @return mixed $value
|
85 |
+
*/
|
86 |
+
public function get_post_metadata( $value, $post_id, $meta_key, $single ) {
|
87 |
+
if ( ! is_preview() ) {
|
88 |
+
return $value;
|
89 |
+
}
|
90 |
+
|
91 |
+
if ( is_null( SCF::get_field( get_post( $post_id ), $meta_key ) ) ) {
|
92 |
+
return $value;
|
93 |
+
}
|
94 |
+
|
95 |
+
$preview_id = $this->get_preview_id( $post_id );
|
96 |
+
if ( $preview_id && $meta_key !== '_thumbnail_id' ) {
|
97 |
+
if ( $post_id !== $preview_id ) {
|
98 |
+
$value = get_post_meta( $preview_id, $meta_key, $single );
|
99 |
+
}
|
100 |
+
}
|
101 |
+
return $value;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* プレビューの Post ID を返す
|
106 |
+
*
|
107 |
+
* @param int $post_id
|
108 |
+
* @return int $preview_id
|
109 |
+
*/
|
110 |
+
protected function get_preview_id( $post_id ) {
|
111 |
+
global $post;
|
112 |
+
$preview_id = 0;
|
113 |
+
if ( isset( $post->ID ) && intval( $post->ID ) === intval( $post_id ) ) {
|
114 |
+
if ( is_preview() && $preview = wp_get_post_autosave( $post_id ) ) {
|
115 |
+
$preview_id = $preview->ID;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
return $preview_id;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* リビジョン比較画面でメタデータを表示させるためにキーを追加する
|
123 |
+
*
|
124 |
+
* @param array $fields
|
125 |
+
* @return array $fields
|
126 |
+
*/
|
127 |
+
public function _wp_post_revision_fields( $fields ){
|
128 |
+
$fields[SCF_Config::PREFIX . 'debug-preview'] = esc_html__( 'Smart Custom Fields', 'smart-custom-fields' );
|
129 |
+
return $fields;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* プレビュー時にメタデータを保存するためにキーとなる項目を出力する
|
134 |
+
*/
|
135 |
+
public function edit_form_after_title() {
|
136 |
+
printf(
|
137 |
+
'<input type="hidden" name="%1$s" value="%1$s" />',
|
138 |
+
SCF_Config::PREFIX . 'debug-preview'
|
139 |
+
);
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* リビジョン比較画面にメタデータを表示
|
144 |
+
*
|
145 |
+
* @param $value
|
146 |
+
* @param $column
|
147 |
+
* @param array $post
|
148 |
+
* @return string
|
149 |
+
*/
|
150 |
+
public function _wp_post_revision_field_debug_preview( $value, $column, $post ) {
|
151 |
+
$output = '';
|
152 |
+
$values = SCF::gets( $post->ID );
|
153 |
+
foreach ( $values as $field_name_or_group_name => $value ) {
|
154 |
+
$output .= sprintf( "■ %s\n", $field_name_or_group_name );
|
155 |
+
if ( is_array( $value ) ) {
|
156 |
+
if ( isset( $value[0] ) && is_array( $value[0] ) ) {
|
157 |
+
foreach ( $value as $i => $repeat_data_values ) {
|
158 |
+
$output .= sprintf( "- #%s\n", $i );
|
159 |
+
foreach ( $repeat_data_values as $field_name => $repeat_data_value ) {
|
160 |
+
$output .= sprintf( " %s: ", $field_name );
|
161 |
+
if ( is_array( $repeat_data_value ) ) {
|
162 |
+
$output .= sprintf( "[%s]\n", implode( ', ', $repeat_data_value ) );
|
163 |
+
} else {
|
164 |
+
$output .= sprintf( "%s\n", $repeat_data_value );
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
} else {
|
169 |
+
$output .= sprintf( "[%s]\n", implode( ', ', $value ) );
|
170 |
+
}
|
171 |
+
} else {
|
172 |
+
$output .= sprintf( "%s\n", $value );
|
173 |
+
}
|
174 |
+
}
|
175 |
+
return $output;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* false ならリビジョンとして保存される
|
180 |
+
*
|
181 |
+
* @param bool $check_for_changes
|
182 |
+
* @param WP_Post $last_revision 最新のリビジョン
|
183 |
+
* @param WP_Post $post 現在の投稿
|
184 |
+
* @return bool
|
185 |
+
*/
|
186 |
+
public function wp_save_post_revision_check_for_changes( $check_for_changes, $last_revision, $post ) {
|
187 |
+
$post_meta = array();
|
188 |
+
$p = get_post_custom( $post->ID );
|
189 |
+
foreach ( $p as $key => $value ) {
|
190 |
+
$v = SCF::get( $key );
|
191 |
+
if ( !is_null( $v ) ) {
|
192 |
+
$post_meta[$key][] = $v;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
if ( isset( $_POST[SCF_Config::NAME] ) ) {
|
197 |
+
$serialized_post_meta = serialize( $post_meta );
|
198 |
+
$serialized_send_data = $_POST[SCF_Config::NAME];
|
199 |
+
if ( $serialized_post_meta != $serialized_send_data ) {
|
200 |
+
return false;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
return true;
|
204 |
+
}
|
205 |
+
}
|
trunk/classes/models/class.setting.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Smart_Custom_Fields_Setting
|
4 |
+
* Version : 1.0.0
|
5 |
+
* Author : inc2734
|
6 |
+
* Created : September 23, 2014
|
7 |
+
* Modified : February 27, 2015
|
8 |
+
* License : GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Smart_Custom_Fields_Setting {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Post ID of custom field settings page
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $id;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Title of custom field settings page
|
21 |
+
* @var title
|
22 |
+
*/
|
23 |
+
protected $title;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Array of the saved group objects
|
27 |
+
* @var array
|
28 |
+
*/
|
29 |
+
protected $groups = array();
|
30 |
+
|
31 |
+
/**
|
32 |
+
* __construct
|
33 |
+
*
|
34 |
+
* @param int $post_id
|
35 |
+
*/
|
36 |
+
public function __construct( $id, $title ) {
|
37 |
+
$this->id = $id;
|
38 |
+
$this->title = $title;
|
39 |
+
$post_meta = get_post_meta(
|
40 |
+
$this->get_id(),
|
41 |
+
SCF_Config::PREFIX . 'setting',
|
42 |
+
true
|
43 |
+
);
|
44 |
+
if ( is_array( $post_meta ) ) {
|
45 |
+
foreach ( $post_meta as $group ) {
|
46 |
+
$group = shortcode_atts( array(
|
47 |
+
'group-name' => '',
|
48 |
+
'repeat' => false,
|
49 |
+
'fields' => array(),
|
50 |
+
), $group );
|
51 |
+
$this->add_group(
|
52 |
+
$group['group-name'],
|
53 |
+
$group['repeat'],
|
54 |
+
$group['fields']
|
55 |
+
);
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Getting the post ID
|
62 |
+
*
|
63 |
+
* @return string
|
64 |
+
*/
|
65 |
+
public function get_id() {
|
66 |
+
return $this->id;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Getting the post title
|
71 |
+
*
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
public function get_title() {
|
75 |
+
return $this->title;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Getting the group objects
|
80 |
+
*
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function get_groups() {
|
84 |
+
return $this->groups;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Getting together the fields in each group
|
89 |
+
*
|
90 |
+
* @return array
|
91 |
+
*/
|
92 |
+
public function get_fields() {
|
93 |
+
$groups = $this->get_groups();
|
94 |
+
$fields = array();
|
95 |
+
foreach ( $groups as $Group ) {
|
96 |
+
$fields = array_merge( $fields, $Group->get_fields() );
|
97 |
+
}
|
98 |
+
return $fields;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Adding group to the tail
|
103 |
+
* If the argument is not, adding an empty group
|
104 |
+
*
|
105 |
+
* @param string $group_name
|
106 |
+
* @param bool $repeat
|
107 |
+
* @param array $_fields
|
108 |
+
*/
|
109 |
+
public function add_group( $group_name = null, $repeat = false, array $fields = array() ) {
|
110 |
+
$Group = $this->new_group( $group_name, $repeat, $fields );
|
111 |
+
$group_name = $Group->get_name();
|
112 |
+
if ( $group_name ) {
|
113 |
+
$this->groups[$group_name] = $Group;
|
114 |
+
} else {
|
115 |
+
$this->groups[] = $Group;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Getting group
|
121 |
+
*
|
122 |
+
* @param string $group_name
|
123 |
+
* @return Smart_Custom_Fields_Group|false
|
124 |
+
*/
|
125 |
+
public function get_group( $group_name ) {
|
126 |
+
$groups = $this->get_groups();
|
127 |
+
if ( isset( $groups[$group_name] ) && $groups[$group_name]->is_repeatable() ) {
|
128 |
+
return $groups[$group_name];
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Adding group to the head
|
134 |
+
* If the argument is not, adding an empty group
|
135 |
+
*
|
136 |
+
* @param string $group_name
|
137 |
+
* @param bool $repeat
|
138 |
+
* @param array $_fields
|
139 |
+
*/
|
140 |
+
public function add_group_unshift( $group_name = null, $repeat = false, array $fields = array() ) {
|
141 |
+
$Group = $this->new_group( $group_name, $repeat, $fields );
|
142 |
+
array_unshift( $this->groups, $Group );
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Getting generated new group
|
147 |
+
*
|
148 |
+
* @param string $group_name
|
149 |
+
* @param bool $repeat
|
150 |
+
* @param array $_fields
|
151 |
+
*/
|
152 |
+
protected function new_group( $group_name, $repeat, $fields ) {
|
153 |
+
return new Smart_Custom_Fields_Group( $group_name, $repeat, $fields );
|
154 |
+
}
|
155 |
+
}
|
trunk/css/editor.css
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* editor.css
|
3 |
+
* Version : 1.3.1
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : September 23, 2014
|
6 |
+
* Modified : June 4, 2016
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
|
11 |
+
/** ==================================================
|
12 |
+
* #normal-sortables
|
13 |
+
*/
|
14 |
+
.smart-cf-meta-box {
|
15 |
+
margin: 0 -12px;
|
16 |
+
}
|
17 |
+
|
18 |
+
/** ==================================================
|
19 |
+
* .smart-cf-meta-box-table
|
20 |
+
*/
|
21 |
+
.smart-cf-meta-box-table {
|
22 |
+
background: #fff;
|
23 |
+
border-bottom: #eee solid 1px;
|
24 |
+
padding: 10px 12px;
|
25 |
+
}
|
26 |
+
.smart-cf-meta-box-table table {
|
27 |
+
width: 100%;
|
28 |
+
}
|
29 |
+
.smart-cf-meta-box-table th,
|
30 |
+
.smart-cf-meta-box-table td {
|
31 |
+
font-weight: normal;
|
32 |
+
text-align: left;
|
33 |
+
padding: 7px 5px;
|
34 |
+
vertical-align: top;
|
35 |
+
}
|
36 |
+
.smart-cf-meta-box-table th {
|
37 |
+
width: 25%;
|
38 |
+
}
|
39 |
+
.smart-cf-meta-box-table td label {
|
40 |
+
margin-right: 10px;
|
41 |
+
}
|
42 |
+
.smart-cf-meta-box-table .wp-editor-tools:after {
|
43 |
+
display: block;
|
44 |
+
}
|
45 |
+
.smart-cf-meta-box-table .wp-editor-container {
|
46 |
+
clear: both;
|
47 |
+
}
|
48 |
+
.smart-cf-meta-box-table td .instruction {
|
49 |
+
font-size: 14px;
|
50 |
+
margin: 0 0 10px;
|
51 |
+
}
|
52 |
+
.smart-cf-meta-box-table td .description {
|
53 |
+
font-size: 12px;
|
54 |
+
margin: 10px 0 0;
|
55 |
+
color: #888;
|
56 |
+
}
|
57 |
+
.smart-cf-meta-box-table td .clear {
|
58 |
+
clear: both;
|
59 |
+
}
|
60 |
+
|
61 |
+
/** ==================================================
|
62 |
+
* .smart-cf-meta-box-repeat-tables
|
63 |
+
*/
|
64 |
+
.smart-cf-meta-box-repeat-tables .smart-cf-meta-box-table > .smart-cf-icon-handle,
|
65 |
+
.smart-cf-meta-box-repeat-tables .smart-cf-meta-box-table > .smart-cf-repeat-btn {
|
66 |
+
position: relative;
|
67 |
+
top: 3px;
|
68 |
+
vertical-align: middle;
|
69 |
+
}
|
70 |
+
.smart-cf-meta-box-repeat-tables .smart-cf-repeat-btn {
|
71 |
+
cursor: pointer;
|
72 |
+
width: auto;
|
73 |
+
height: auto;
|
74 |
+
font-size: 1.3em;
|
75 |
+
padding: 0;
|
76 |
+
-webkit-border-radius: 50%;
|
77 |
+
border-radius: 50%;
|
78 |
+
display: inline-block;
|
79 |
+
vertical-align: middle;
|
80 |
+
text-align: center;
|
81 |
+
color: #999;
|
82 |
+
margin-right: 3px;
|
83 |
+
}
|
84 |
+
.smart-cf-meta-box-repeat-tables .smart-cf-icon-handle:hover,
|
85 |
+
.smart-cf-meta-box-repeat-tables .smart-cf-repeat-btn:hover {
|
86 |
+
color: #333;
|
87 |
+
}
|
88 |
+
.smart-cf-meta-box-repeat-tables table {
|
89 |
+
margin-top: 7px;
|
90 |
+
}
|
91 |
+
|
92 |
+
/** ==================================================
|
93 |
+
* relation
|
94 |
+
*/
|
95 |
+
.smart-cf-meta-box-table .smart-cf-relation-left,
|
96 |
+
.smart-cf-meta-box-table .smart-cf-relation-right {
|
97 |
+
border: #ddd solid 1px;
|
98 |
+
border-radius: 3px;
|
99 |
+
height: 160px;
|
100 |
+
}
|
101 |
+
.smart-cf-meta-box-table .smart-cf-relation-left ul,
|
102 |
+
.smart-cf-meta-box-table .smart-cf-relation-right ul {
|
103 |
+
list-style: none;
|
104 |
+
margin: 0;
|
105 |
+
padding: 0;
|
106 |
+
}
|
107 |
+
.smart-cf-meta-box-table .smart-cf-relation-left ul li,
|
108 |
+
.smart-cf-meta-box-table .smart-cf-relation-right ul li {
|
109 |
+
background: #fff;
|
110 |
+
border-bottom: #eee solid 1px;
|
111 |
+
color: #999;
|
112 |
+
margin: 0;
|
113 |
+
padding: 5px 10px;
|
114 |
+
position: relative;
|
115 |
+
}
|
116 |
+
.smart-cf-meta-box-table .smart-cf-relation-left ul li[data-status="publish"],
|
117 |
+
.smart-cf-meta-box-table .smart-cf-relation-right ul li[data-status="publish"] {
|
118 |
+
color: #0074a2;
|
119 |
+
}
|
120 |
+
.smart-cf-meta-box-table .smart-cf-relation-left ul li::after,
|
121 |
+
.smart-cf-meta-box-table .smart-cf-relation-right ul li::after {
|
122 |
+
content: attr(data-status);
|
123 |
+
display: inline-block;
|
124 |
+
background-color: #999;
|
125 |
+
color: #fff;
|
126 |
+
border-radius: 4px;
|
127 |
+
padding: 0 3px;
|
128 |
+
font-size: 10px;
|
129 |
+
margin-left: .5em;
|
130 |
+
position: relative;
|
131 |
+
top: -1px;
|
132 |
+
}
|
133 |
+
.smart-cf-meta-box-table .smart-cf-relation-left ul li[data-status="publish"]::after,
|
134 |
+
.smart-cf-meta-box-table .smart-cf-relation-right ul li[data-status="publish"]::after {
|
135 |
+
display: none;
|
136 |
+
}
|
137 |
+
.smart-cf-meta-box-table .smart-cf-relation-left {
|
138 |
+
float: left;
|
139 |
+
width: 47%;
|
140 |
+
overflow: hidden;
|
141 |
+
}
|
142 |
+
.smart-cf-meta-box-table .smart-cf-relation-left .smart-cf-search {
|
143 |
+
background-color: #f5f5f5;
|
144 |
+
border-bottom: 1px solid #eee;
|
145 |
+
padding: 5px;
|
146 |
+
}
|
147 |
+
.smart-cf-meta-box-table .smart-cf-relation-left .smart-cf-relation-children-select {
|
148 |
+
overflow: auto;
|
149 |
+
height: 122px;
|
150 |
+
}
|
151 |
+
.smart-cf-meta-box-table .smart-cf-relation-left ul li {
|
152 |
+
cursor: pointer;
|
153 |
+
}
|
154 |
+
.smart-cf-meta-box-table .smart-cf-relation-left ul li:hover {
|
155 |
+
background: #e4f6fd;
|
156 |
+
}
|
157 |
+
.smart-cf-meta-box-table .smart-cf-relation-left .load-relation-items {
|
158 |
+
background: #e4f6fd;
|
159 |
+
cursor: pointer;
|
160 |
+
margin: 0;
|
161 |
+
padding: 6px 10px;
|
162 |
+
text-align: center;
|
163 |
+
}
|
164 |
+
.smart-cf-meta-box-table .smart-cf-relation-left .load-relation-items:hover {
|
165 |
+
background: #c1ebfc;
|
166 |
+
}
|
167 |
+
.smart-cf-meta-box-table .smart-cf-relation-right {
|
168 |
+
float: right;
|
169 |
+
width: 50%;
|
170 |
+
overflow: auto;
|
171 |
+
}
|
172 |
+
.smart-cf-meta-box-table .smart-cf-relation-right ul li {
|
173 |
+
padding-right: 30px;
|
174 |
+
padding-left: 30px;
|
175 |
+
}
|
176 |
+
.smart-cf-meta-box-table .smart-cf-relation-right ul li .smart-cf-icon-handle {
|
177 |
+
position: absolute;
|
178 |
+
top: 4px;
|
179 |
+
left: 5px;
|
180 |
+
margin: 0;
|
181 |
+
}
|
182 |
+
.smart-cf-meta-box-table .smart-cf-relation-right ul li .relation-remove {
|
183 |
+
cursor: pointer;
|
184 |
+
display: block;
|
185 |
+
display: flex;
|
186 |
+
align-items: center;
|
187 |
+
justify-content: center;
|
188 |
+
height: 12px;
|
189 |
+
width: 12px;
|
190 |
+
line-height: 1;
|
191 |
+
border-radius: 3px;
|
192 |
+
position: absolute;
|
193 |
+
top: 7px;
|
194 |
+
right: 6px;
|
195 |
+
color: #fff;
|
196 |
+
background-color: #32373c;
|
197 |
+
}
|
198 |
+
|
199 |
+
/** ==================================================
|
200 |
+
* .smart-cf-upload-image, .smart-cf-upload-file
|
201 |
+
*/
|
202 |
+
.smart-cf-upload-image,
|
203 |
+
.smart-cf-upload-file {
|
204 |
+
display: inline-block;
|
205 |
+
position: relative;
|
206 |
+
}
|
207 |
+
.smart-cf-upload-image img,
|
208 |
+
.smart-cf-upload-file img {
|
209 |
+
margin-top: 5px;
|
210 |
+
max-width: 100%;
|
211 |
+
vertical-align: top;
|
212 |
+
}
|
213 |
+
.smart-cf-upload-image .btn-remove-image,
|
214 |
+
.smart-cf-upload-file .btn-remove-file {
|
215 |
+
background: red;
|
216 |
+
border-radius: 3px;
|
217 |
+
color: #fff;
|
218 |
+
cursor: pointer;
|
219 |
+
display: block;
|
220 |
+
font-size: 10px;
|
221 |
+
padding: 2px 6px;
|
222 |
+
position: absolute;
|
223 |
+
left: 5px;
|
224 |
+
bottom: 5px;
|
225 |
+
}
|
226 |
+
|
227 |
+
/** ==================================================
|
228 |
+
* .hide
|
229 |
+
*/
|
230 |
+
.smart-cf-upload-image.hide,
|
231 |
+
.smart-cf-upload-file.hide,
|
232 |
+
.smart-cf-upload-image .btn-remove-image.hide,
|
233 |
+
.smart-cf-upload-file .btn-remove-file.hide,
|
234 |
+
.load-relation-items.hide {
|
235 |
+
display: none;
|
236 |
+
}
|
237 |
+
|
238 |
+
/** ==================================================
|
239 |
+
* classes
|
240 |
+
*/
|
241 |
+
.smart-cf-icon-handle {
|
242 |
+
cursor: move;
|
243 |
+
display: inline-block;
|
244 |
+
margin-right: 10px;
|
245 |
+
overflow: hidden;
|
246 |
+
position: relative;
|
247 |
+
color: #CCC;
|
248 |
+
}
|
249 |
+
|
250 |
+
.smart-cf-item-vertical {
|
251 |
+
display: block;
|
252 |
+
margin: 0 0 3px;
|
253 |
+
}
|
trunk/css/option.css
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* option.css
|
3 |
+
* Version : 1.0.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : May 30, 2016
|
6 |
+
* Modified :
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
trunk/css/profile.css
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* profile.css
|
3 |
+
* Version : 1.0.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : March 18, 2014
|
6 |
+
* Modified :
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
|
11 |
+
/** ==================================================
|
12 |
+
* .smart-cf-meta-box
|
13 |
+
*/
|
14 |
+
.smart-cf-meta-box:first-child {
|
15 |
+
border-top: #ddd solid 1px;
|
16 |
+
}
|
17 |
+
|
18 |
+
/** ==================================================
|
19 |
+
* .smart-cf-meta-box-table
|
20 |
+
*/
|
21 |
+
.smart-cf-meta-box-table {
|
22 |
+
background: transparent;
|
23 |
+
border-bottom: #ddd solid 1px;
|
24 |
+
padding: 10px 0;
|
25 |
+
}
|
trunk/css/settings.css
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* settings.css
|
3 |
+
* Version : 1.1.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : September 23, 2014
|
6 |
+
* Modified : May 31, 2016
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
|
11 |
+
/** ==================================================
|
12 |
+
* #normal-sortables
|
13 |
+
*/
|
14 |
+
#normal-sortables {
|
15 |
+
display: none;
|
16 |
+
}
|
17 |
+
|
18 |
+
/** ==================================================
|
19 |
+
* .btn-add-group
|
20 |
+
*/
|
21 |
+
.smart-cf-fields-wrapper .btn-add-group {
|
22 |
+
margin-top: 10px;
|
23 |
+
}
|
24 |
+
|
25 |
+
/** ==================================================
|
26 |
+
* .smart-cf-group
|
27 |
+
*/
|
28 |
+
.smart-cf-group {
|
29 |
+
background: #f5f5f5;
|
30 |
+
border: #ddd solid 1px;
|
31 |
+
margin: 10px 0 0;
|
32 |
+
padding: 10px;
|
33 |
+
position: relative;
|
34 |
+
}
|
35 |
+
.smart-cf-group .smart-cf-require {
|
36 |
+
color: #f60;
|
37 |
+
font-size: 90%;
|
38 |
+
margin-left: 3px;
|
39 |
+
}
|
40 |
+
.smart-cf-group .smart-cf-notes {
|
41 |
+
color: #999;
|
42 |
+
font-size: 90%;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* .btn-remove-group
|
47 |
+
*/
|
48 |
+
.smart-cf-group .btn-remove-group {
|
49 |
+
cursor: pointer;
|
50 |
+
position: absolute;
|
51 |
+
top: 10px;
|
52 |
+
right: 10px;
|
53 |
+
}
|
54 |
+
.smart-cf-group .btn-remove-group .dashicons,
|
55 |
+
.smart-cf-group .btn-remove-group .dashicons:before {
|
56 |
+
font-size: 14px;
|
57 |
+
height: 14px;
|
58 |
+
width: 14px;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* .btn-add-field
|
63 |
+
*/
|
64 |
+
.smart-cf-group .btn-add-field {
|
65 |
+
margin-top: 5px;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* .smart-cf-group-repeat
|
70 |
+
*/
|
71 |
+
.smart-cf-group .smart-cf-group-repeat {
|
72 |
+
margin: 0 0 5px;
|
73 |
+
}
|
74 |
+
.smart-cf-group .smart-cf-group-repeat label {
|
75 |
+
position: relative;
|
76 |
+
top: -2px;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* .smart-cf-group-names
|
81 |
+
*/
|
82 |
+
.smart-cf-group .smart-cf-group-names {
|
83 |
+
width: 100%;
|
84 |
+
}
|
85 |
+
.smart-cf-group .smart-cf-group-names th {
|
86 |
+
text-align: left;
|
87 |
+
width: 20%;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* .smart-cf-alert
|
92 |
+
*/
|
93 |
+
.smart-cf-alert {
|
94 |
+
color: #f60;
|
95 |
+
display: block;
|
96 |
+
font-size: 90%;
|
97 |
+
margin-top: 2px 0;
|
98 |
+
}
|
99 |
+
|
100 |
+
/** ==================================================
|
101 |
+
* .smart-cf-fields
|
102 |
+
*/
|
103 |
+
.smart-cf-group .smart-cf-fields {
|
104 |
+
margin-top: 7px;
|
105 |
+
}
|
106 |
+
|
107 |
+
/** ==================================================
|
108 |
+
* .smart-cf-field
|
109 |
+
*/
|
110 |
+
.smart-cf-group .smart-cf-field {
|
111 |
+
background: #fff;
|
112 |
+
border: #ddd solid 1px;
|
113 |
+
margin: 5px 0 0;
|
114 |
+
padding: 10px;
|
115 |
+
overflow: hidden;
|
116 |
+
*zoom: 1;
|
117 |
+
}
|
118 |
+
.smart-cf-group .smart-cf-field:first-child {
|
119 |
+
margin-top: 0;
|
120 |
+
}
|
121 |
+
.smart-cf-group .smart-cf-field table {
|
122 |
+
border-collapse: collapse;
|
123 |
+
width: 100%;
|
124 |
+
}
|
125 |
+
.smart-cf-group .smart-cf-field table th,
|
126 |
+
.smart-cf-group .smart-cf-field table td {
|
127 |
+
padding: 5px 0;
|
128 |
+
}
|
129 |
+
.smart-cf-group .smart-cf-field table th {
|
130 |
+
font-weight: normal;
|
131 |
+
padding-top: 10px;
|
132 |
+
padding-right: 15px;
|
133 |
+
text-align: left;
|
134 |
+
vertical-align: top;
|
135 |
+
width: 15%;
|
136 |
+
}
|
137 |
+
.smart-cf-group .smart-cf-field table table {
|
138 |
+
margin: -5px 0;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* .smart-cf-icon-handle
|
143 |
+
*/
|
144 |
+
.smart-cf-group .smart-cf-field .smart-cf-icon-handle {
|
145 |
+
float: left;
|
146 |
+
margin-top: 4px;
|
147 |
+
margin-right: 8px;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* .field-label
|
152 |
+
*/
|
153 |
+
.smart-cf-group .smart-cf-field .field-label {
|
154 |
+
cursor: pointer;
|
155 |
+
position: relative;
|
156 |
+
overflow: hidden;
|
157 |
+
*zoom: 1;
|
158 |
+
}
|
159 |
+
.smart-cf-group .smart-cf-field .field-label small {
|
160 |
+
color: #999;
|
161 |
+
font-size: 90%;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* .btn-remove-field
|
166 |
+
*/
|
167 |
+
.smart-cf-group .smart-cf-field .btn-remove-field {
|
168 |
+
cursor: pointer;
|
169 |
+
float: right;
|
170 |
+
}
|
171 |
+
.smart-cf-group .smart-cf-field .btn-remove-field .dashicons,
|
172 |
+
.smart-cf-group .smart-cf-field .btn-remove-field .dashicons:before {
|
173 |
+
font-size: 14px;
|
174 |
+
height: 14px;
|
175 |
+
width: 14px;
|
176 |
+
}
|
177 |
+
|
178 |
+
/** ==================================================
|
179 |
+
* #smart-cf-meta-box-condition
|
180 |
+
*/
|
181 |
+
#smart-cf-meta-box-condition-post b,
|
182 |
+
#smart-cf-meta-box-condition-profile b,
|
183 |
+
#smart-cf-meta-box-condition-taxonomy b,
|
184 |
+
#smart-cf-meta-box-condition-options-page b {
|
185 |
+
display: block;
|
186 |
+
margin: 0 0 5px;
|
187 |
+
}
|
188 |
+
#smart-cf-meta-box-condition-post label,
|
189 |
+
#smart-cf-meta-box-condition-profile label,
|
190 |
+
#smart-cf-meta-box-condition-taxonomy label,
|
191 |
+
#smart-cf-meta-box-condition-options-page label {
|
192 |
+
display: block;
|
193 |
+
margin: 0 0 5px;
|
194 |
+
}
|
195 |
+
|
196 |
+
/** ==================================================
|
197 |
+
* .hide
|
198 |
+
*/
|
199 |
+
.smart-cf-group .smart-cf-field table tr.hide,
|
200 |
+
.smart-cf-group.hide,
|
201 |
+
.smart-cf-group .btn-add-field.hide,
|
202 |
+
.smart-cf-group .smart-cf-group-names.hide,
|
203 |
+
.smart-cf-group .smart-cf-field.hide,
|
204 |
+
.smart-cf-group .smart-cf-field table.hide {
|
205 |
+
display: none;
|
206 |
+
}
|
207 |
+
|
208 |
+
/** ==================================================
|
209 |
+
* classes
|
210 |
+
*/
|
211 |
+
.smart-cf-icon-handle {
|
212 |
+
background: url( ../images/handle.png ) no-repeat;
|
213 |
+
cursor: move;
|
214 |
+
display: inline-block;
|
215 |
+
margin-right: 10px;
|
216 |
+
height: 10px;
|
217 |
+
width: 10px;
|
218 |
+
overflow: hidden;
|
219 |
+
position: relative;
|
220 |
+
}
|
trunk/css/taxonomy.css
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* taxonomy.css
|
3 |
+
* Version : 1.0.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : April 26, 2014
|
6 |
+
* Modified :
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
|
11 |
+
/** ==================================================
|
12 |
+
* .smart-cf-meta-box-table
|
13 |
+
*/
|
14 |
+
.smart-cf-meta-box-table {
|
15 |
+
background: transparent;
|
16 |
+
border-bottom-color: #ddd;
|
17 |
+
}
|
trunk/css/wysiwyg.css
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* wysiwyg.css
|
3 |
+
* Version : 1.0.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : April 11, 2015
|
6 |
+
* Modified :
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
|
11 |
+
body {
|
12 |
+
font-family: "Open Sans", Helvetica, Arial, sans-serif;
|
13 |
+
font-size: 13px;
|
14 |
+
}
|
trunk/images/handle.png
ADDED
Binary file
|
trunk/js/editor-colorpicker.js
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* editor-colorpicker.js
|
3 |
+
* Version : 1.0.1
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : October 21, 2014
|
6 |
+
* Modified : July 28, 2016
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
$( '.smart-cf-meta-box-table' ).each( function( i, e ) {
|
12 |
+
$( e ).find( '.smart-cf-colorpicker' ).each( function( i, e ) {
|
13 |
+
if ( $( e ).attr( 'disabled' ) !== 'disabled' ) {
|
14 |
+
$( e ).wpColorPicker();
|
15 |
+
}
|
16 |
+
} );
|
17 |
+
} );
|
18 |
+
|
19 |
+
$( document ).on( 'smart-cf-after-add-group', function( e, obj ) {
|
20 |
+
var parent = $( obj.button ).parents( '.smart-cf-meta-box-repeat-tables' );
|
21 |
+
parent.find( '.smart-cf-colorpicker' ).each( function( i, e ) {
|
22 |
+
if ( $( e ).attr( 'disabled' ) !== 'disabled' ) {
|
23 |
+
$( e ).wpColorPicker();
|
24 |
+
}
|
25 |
+
} );
|
26 |
+
} );
|
27 |
+
} );
|
trunk/js/editor-datepicker.js
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* editor-datepicker.js
|
3 |
+
* Version : 1.0.1
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : January 18, 2015
|
6 |
+
* Modified : July 28, 2016
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
$( '.smart-cf-meta-box-table' ).each( function( i, e ) {
|
12 |
+
$( e ).find( '.smart-cf-datepicker' ).each( function( i, e ) {
|
13 |
+
if ( $( e ).attr( 'disabled' ) !== 'disabled' ) {
|
14 |
+
$( e ).datepicker( $( e ).data( 'js' ) );
|
15 |
+
}
|
16 |
+
} );
|
17 |
+
} );
|
18 |
+
|
19 |
+
$( document ).on( 'smart-cf-after-add-group', function( e, obj ) {
|
20 |
+
var parent = $( obj.button ).parents( '.smart-cf-meta-box-repeat-tables' );
|
21 |
+
parent.find( '.smart-cf-datepicker' ).each( function( i, e ) {
|
22 |
+
if ( $( e ).attr( 'disabled' ) !== 'disabled' ) {
|
23 |
+
$( e ).datepicker( $( e ).data( 'js' ) );
|
24 |
+
}
|
25 |
+
} );
|
26 |
+
} );
|
27 |
+
} );
|
trunk/js/editor-relation-common.js
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( function( $ ) {
|
2 |
+
|
3 |
+
var table_class = 'tr';
|
4 |
+
|
5 |
+
/**
|
6 |
+
* 選択肢
|
7 |
+
*/
|
8 |
+
var choices_li = '.smart-cf-relation-children-select li';
|
9 |
+
$( '.smart-cf-meta-box' ).on( 'click', choices_li, function() {
|
10 |
+
var id = $( this ).data( 'id' );
|
11 |
+
var parent = $( this ).closest( table_class );
|
12 |
+
var limit = parent.find( '.smart-cf-relation-left' ).data( 'limit' );
|
13 |
+
|
14 |
+
if ( limit > 0 && limit <= parent.find( '.smart-cf-relation-right li' ).length ) {
|
15 |
+
return true;
|
16 |
+
}
|
17 |
+
|
18 |
+
if ( parent.find( '.smart-cf-relation-right li[data-id="' + id + '"]' ).length !== 0 ) {
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
|
22 |
+
var clone = $( this ).clone();
|
23 |
+
clone
|
24 |
+
.prepend( $( '<span class="smart-cf-icon-handle dashicons dashicons-menu"></span>' ) )
|
25 |
+
.append( $( '<span class="relation-remove">-</span>' ) );
|
26 |
+
parent.find( '.smart-cf-relation-right ul' ).append( clone );
|
27 |
+
update_relation_value( $( this ).closest( 'tr' ) );
|
28 |
+
} );
|
29 |
+
|
30 |
+
/**
|
31 |
+
* 選択済み項目の削除
|
32 |
+
*/
|
33 |
+
var relation_remove = '.smart-cf-relation-right li .relation-remove';
|
34 |
+
$( '.smart-cf-meta-box' ).on( 'click', relation_remove, function() {
|
35 |
+
var tr = $( this ).closest( 'tr' );
|
36 |
+
$( this ).parent().remove();
|
37 |
+
update_relation_value( tr );
|
38 |
+
} );
|
39 |
+
|
40 |
+
/**
|
41 |
+
* update_relation_value
|
42 |
+
* @param dom tr
|
43 |
+
*/
|
44 |
+
function update_relation_value( tr ) {
|
45 |
+
var hidden = tr.find( 'input[type="hidden"]' );
|
46 |
+
hidden.each( function( i, e ) {
|
47 |
+
if ( i !== 0 ) {
|
48 |
+
$( this ).remove();
|
49 |
+
}
|
50 |
+
} );
|
51 |
+
tr.find( '.smart-cf-relation-right li' ).each( function( i, e ) {
|
52 |
+
var hidden_box = $( this ).closest( table_class ).find( '.smart-cf-relation-children-select' );
|
53 |
+
var id = $( this ).data( 'id' );
|
54 |
+
var clone = hidden.first().clone();
|
55 |
+
var name = clone.attr( 'name' );
|
56 |
+
clone.attr( 'name', name + '[]' );
|
57 |
+
clone.val( id );
|
58 |
+
hidden_box.append( clone );
|
59 |
+
} );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* sortable
|
64 |
+
*/
|
65 |
+
$( '.smart-cf-meta-box' ).find( '.smart-cf-relation-right ul' )
|
66 |
+
.on( 'mousedown', function( event ) {
|
67 |
+
event.stopPropagation();
|
68 |
+
} )
|
69 |
+
.sortable( {
|
70 |
+
handle: '.smart-cf-icon-handle',
|
71 |
+
update: function() {
|
72 |
+
update_relation_value( $( this ).closest( 'tr' ) );
|
73 |
+
}
|
74 |
+
} );
|
75 |
+
|
76 |
+
} );
|
trunk/js/editor-relation-post-types.js
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* editor.js
|
3 |
+
* Version : 1.2.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : September 30, 2014
|
6 |
+
* Modified : January 27, 2017
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
|
12 |
+
var table_class = 'tr';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* 初期化
|
16 |
+
* click_count はロードボタンを押すごとに加算。
|
17 |
+
* 検索ボックスが変更されるたびに 0 にリセットすること。
|
18 |
+
*/
|
19 |
+
$( '.smart-cf-meta-box .load-relation-post-types' ).closest( table_class )
|
20 |
+
.data( 'click_count', 0 )
|
21 |
+
.data( 'search_timer', null )
|
22 |
+
.data( 'recent_search_query', '' );
|
23 |
+
|
24 |
+
/**
|
25 |
+
* 検索ボタン
|
26 |
+
*/
|
27 |
+
$( document ).on( 'keyup', '.smart-cf-meta-box .search-input-post-types', function() {
|
28 |
+
var parent = $( this ).closest( table_class );
|
29 |
+
var search_timer = parent.data( 'search_timer' );
|
30 |
+
clearTimeout( search_timer );
|
31 |
+
|
32 |
+
parent.data( 'click_count', 0 );
|
33 |
+
parent.find( '.smart-cf-relation-children-select ul li' ).remove();
|
34 |
+
|
35 |
+
var search_query = $( this ).val();
|
36 |
+
parent.data( 'recent_search_query', search_query );
|
37 |
+
parent.data( 'search_timer', setTimeout( function() {
|
38 |
+
get_posts( { s: search_query }, parent );
|
39 |
+
}, 2000 ) );
|
40 |
+
} );
|
41 |
+
|
42 |
+
/**
|
43 |
+
* 読み込みボタン
|
44 |
+
*/
|
45 |
+
$( document ).on( 'click', '.smart-cf-meta-box .load-relation-post-types', function() {
|
46 |
+
var parent = $( this ).closest( table_class );
|
47 |
+
var click_count = parent.data( 'click_count' );
|
48 |
+
click_count ++;
|
49 |
+
parent.data( 'click_count', click_count );
|
50 |
+
var search_query = parent.data( 'recent_search_query' );
|
51 |
+
if ( search_query ) {
|
52 |
+
get_posts( { s: search_query }, parent );
|
53 |
+
} else {
|
54 |
+
get_posts( {}, parent );
|
55 |
+
}
|
56 |
+
} );
|
57 |
+
|
58 |
+
/**
|
59 |
+
* クエリ
|
60 |
+
*/
|
61 |
+
function get_posts( args, table ) {
|
62 |
+
var click_count = table.data( 'click_count' );
|
63 |
+
var post_types = table.find( '.smart-cf-relation-left' ).data( 'post-types' );
|
64 |
+
var btn_load = table.find( '.load-relation-post-types' );
|
65 |
+
var btn_load_text = btn_load.text();
|
66 |
+
btn_load.text( 'Now loading...' );
|
67 |
+
|
68 |
+
args = $.extend( args, {
|
69 |
+
action : smart_cf_relation_post_types.action,
|
70 |
+
nonce : smart_cf_relation_post_types.nonce,
|
71 |
+
click_count: click_count,
|
72 |
+
post_types : post_types
|
73 |
+
} );
|
74 |
+
$.post(
|
75 |
+
smart_cf_relation_post_types.endpoint,
|
76 |
+
args,
|
77 |
+
function( response ) {
|
78 |
+
btn_load.addClass( 'hide' );
|
79 |
+
$( response ).each( function( i, e ) {
|
80 |
+
table.find( '.smart-cf-relation-children-select ul' ).append(
|
81 |
+
$( '<li />' )
|
82 |
+
.attr( 'data-id', this.ID )
|
83 |
+
.attr( 'data-status', this.post_status )
|
84 |
+
.text( this.post_title )
|
85 |
+
);
|
86 |
+
} );
|
87 |
+
|
88 |
+
btn_load.text( btn_load_text );
|
89 |
+
btn_load.removeClass( 'hide' );
|
90 |
+
}
|
91 |
+
);
|
92 |
+
return false;
|
93 |
+
}
|
94 |
+
} );
|
trunk/js/editor-relation-taxonomies.js
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* editor.js
|
3 |
+
* Version : 1.2.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : February 2, 2016
|
6 |
+
* Modified : January 27, 2017
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
|
12 |
+
var table_class = 'tr';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* 初期化
|
16 |
+
* click_count はロードボタンを押すごとに加算。
|
17 |
+
* 検索ボックスが変更されるたびに 0 にリセットすること。
|
18 |
+
*/
|
19 |
+
$( '.smart-cf-meta-box .load-relation-terms' ).closest( table_class )
|
20 |
+
.data( 'click_count', 0 )
|
21 |
+
.data( 'search_timer', null )
|
22 |
+
.data( 'recent_search_query', '' );
|
23 |
+
|
24 |
+
/**
|
25 |
+
* 検索ボタン
|
26 |
+
*/
|
27 |
+
$( document ).on( 'keyup', '.smart-cf-meta-box .search-input-terms', function() {
|
28 |
+
var parent = $( this ).closest( table_class );
|
29 |
+
var search_timer = parent.data( 'search_timer' );
|
30 |
+
clearTimeout( search_timer );
|
31 |
+
|
32 |
+
parent.data( 'click_count', 0 );
|
33 |
+
parent.find( '.smart-cf-relation-children-select ul li' ).remove();
|
34 |
+
|
35 |
+
var search_query = $( this ).val();
|
36 |
+
parent.data( 'recent_search_query', search_query );
|
37 |
+
parent.data( 'search_timer', setTimeout( function() {
|
38 |
+
get_terms( { search: search_query }, parent );
|
39 |
+
}, 2000 ) );
|
40 |
+
} );
|
41 |
+
|
42 |
+
/**
|
43 |
+
* 読み込みボタン
|
44 |
+
*/
|
45 |
+
$( document ).on( 'click', '.smart-cf-meta-box .load-relation-terms', function() {
|
46 |
+
var parent = $( this ).closest( table_class );
|
47 |
+
var click_count = parent.data( 'click_count' );
|
48 |
+
click_count ++;
|
49 |
+
parent.data( 'click_count', click_count );
|
50 |
+
var search_query = parent.data( 'recent_search_query' );
|
51 |
+
if ( search_query ) {
|
52 |
+
get_terms( { search: search_query }, parent );
|
53 |
+
} else {
|
54 |
+
get_terms( {}, parent );
|
55 |
+
}
|
56 |
+
} );
|
57 |
+
|
58 |
+
/**
|
59 |
+
* クエリ
|
60 |
+
*/
|
61 |
+
function get_terms( args, table ) {
|
62 |
+
var click_count = table.data( 'click_count' );
|
63 |
+
var taxonomies = table.find( '.smart-cf-relation-left' ).data( 'taxonomies' );
|
64 |
+
var btn_load = table.find( '.load-relation-terms' );
|
65 |
+
var btn_load_text = btn_load.text();
|
66 |
+
btn_load.text( 'Now loading...' );
|
67 |
+
|
68 |
+
args = $.extend( args, {
|
69 |
+
action : smart_cf_relation_taxonomies.action,
|
70 |
+
nonce : smart_cf_relation_taxonomies.nonce,
|
71 |
+
click_count: click_count,
|
72 |
+
taxonomies : taxonomies
|
73 |
+
} );
|
74 |
+
$.post(
|
75 |
+
smart_cf_relation_taxonomies.endpoint,
|
76 |
+
args,
|
77 |
+
function( response ) {
|
78 |
+
btn_load.addClass( 'hide' );
|
79 |
+
$( response ).each( function( i, e ) {
|
80 |
+
table.find( '.smart-cf-relation-children-select ul' ).append(
|
81 |
+
$( '<li />' )
|
82 |
+
.attr( 'data-id', this.term_id )
|
83 |
+
.text( this.name )
|
84 |
+
);
|
85 |
+
} );
|
86 |
+
|
87 |
+
btn_load.text( btn_load_text );
|
88 |
+
btn_load.removeClass( 'hide' );
|
89 |
+
}
|
90 |
+
);
|
91 |
+
return false;
|
92 |
+
}
|
93 |
+
} );
|
trunk/js/editor-wysiwyg.js
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* editor-wysiwyg.js
|
3 |
+
* Version : 2.0.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : September 28, 2014
|
6 |
+
* Modified : June 4, 2016
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
|
12 |
+
$( '.smart-cf-meta-box' ).each( function( i, e ) {
|
13 |
+
var wrapper = $( e );
|
14 |
+
var table_class = '.smart-cf-meta-box-table';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* ロード時に wysiwyg エディター用のテキストエリアがあったら wysiwyg 化する。
|
18 |
+
*/
|
19 |
+
wrapper.find( '.smart-cf-wp-editor' ).each( function( i, e ) {
|
20 |
+
if ( $( this ).parents( table_class ).css( 'display' ) === 'none' ) {
|
21 |
+
return true;
|
22 |
+
}
|
23 |
+
$( e ).attr( 'id', $( e ).attr( 'name' ).replace( /(\[|\]|\-)/ig, '_' ) );
|
24 |
+
var editor_id = $( e ).attr( 'id' );
|
25 |
+
var wrap = $( e ).parents( '.wp-editor-wrap' );
|
26 |
+
initialize_editor( wrap, editor_id );
|
27 |
+
|
28 |
+
var mceinit = scf_generate_mceinit( editor_id );
|
29 |
+
tinyMCEPreInit.mceInit[editor_id] = mceinit;
|
30 |
+
if ( typeof tinymce !== 'undefined' ) {
|
31 |
+
tinymce.init( mceinit );
|
32 |
+
}
|
33 |
+
|
34 |
+
var qtinit = scf_generate_qtinit( editor_id );
|
35 |
+
tinyMCEPreInit.qtInit[editor_id] = qtinit;
|
36 |
+
if ( typeof quicktags !== 'undefined' ) {
|
37 |
+
quicktags( qtinit );
|
38 |
+
QTags._buttonsInit();
|
39 |
+
}
|
40 |
+
} );
|
41 |
+
} );
|
42 |
+
|
43 |
+
/**
|
44 |
+
* グループ追加ボタンを押したときに発火。
|
45 |
+
* wysiwyg エディター用のテキストエリアがあったら wysiwyg 化する。
|
46 |
+
*/
|
47 |
+
$( document ).on( 'smart-cf-after-add-group', function( e, data ) {
|
48 |
+
var button = data.button;
|
49 |
+
var clone = data.clone;
|
50 |
+
clone.find( '.smart-cf-wp-editor' ).each( function( i, e ) {
|
51 |
+
$( e ).attr( 'id', $( e ).attr( 'name' ).replace( /(\[|\]|\-)/ig, '_' ) );
|
52 |
+
var editor_id = $( e ).attr( 'id' );
|
53 |
+
var wrap = $( e ).parents( '.wp-editor-wrap' );
|
54 |
+
initialize_editor( wrap, editor_id );
|
55 |
+
|
56 |
+
var mceinit = scf_generate_mceinit( editor_id );
|
57 |
+
tinyMCEPreInit.mceInit[editor_id] = mceinit;
|
58 |
+
if ( typeof tinymce !== 'undefined' ) {
|
59 |
+
tinymce.init( mceinit );
|
60 |
+
}
|
61 |
+
|
62 |
+
var qtinit = scf_generate_qtinit( editor_id );
|
63 |
+
tinyMCEPreInit.qtInit[editor_id] = qtinit;
|
64 |
+
if ( typeof quicktags !== 'undefined' ) {
|
65 |
+
quicktags( qtinit );
|
66 |
+
QTags._buttonsInit();
|
67 |
+
}
|
68 |
+
} );
|
69 |
+
} );
|
70 |
+
|
71 |
+
/**
|
72 |
+
* ドラッグしたときに発火。
|
73 |
+
* wysiwyg エディター用のテキストエリアをオフる。
|
74 |
+
*/
|
75 |
+
$( document ).on( 'smart-cf-repeat-table-sortable-start', function( e, ui ) {
|
76 |
+
$( ui ).find( '.smart-cf-wp-editor' ).each( function( i, e ) {
|
77 |
+
var editor_id = $( this ).attr( 'id' );
|
78 |
+
|
79 |
+
tinymce.execCommand( 'mceRemoveEditor', false, editor_id );
|
80 |
+
|
81 |
+
var mceinit = scf_generate_mceinit( editor_id );
|
82 |
+
tinyMCEPreInit.mceInit[editor_id] = mceinit;
|
83 |
+
|
84 |
+
var qtinit = scf_generate_qtinit( editor_id );
|
85 |
+
tinyMCEPreInit.qtInit[editor_id] = qtinit;
|
86 |
+
if ( typeof quicktags !== 'undefined' ) {
|
87 |
+
quicktags( qtinit );
|
88 |
+
QTags._buttonsInit();
|
89 |
+
}
|
90 |
+
} );
|
91 |
+
} );
|
92 |
+
|
93 |
+
/**
|
94 |
+
* ドロップしたときに発火。
|
95 |
+
* wysiwyg エディター用のテキストエリアを wysiwyg 化する。
|
96 |
+
*/
|
97 |
+
$( document ).on( 'smart-cf-repeat-table-sortable-stop', function( e, ui ) {
|
98 |
+
$( ui ).find( '.smart-cf-wp-editor' ).each( function( i, e ) {
|
99 |
+
var editor_id = $( this ).attr( 'id' );
|
100 |
+
|
101 |
+
var mceinit = scf_generate_mceinit( editor_id );
|
102 |
+
tinyMCEPreInit.mceInit[editor_id] = mceinit;
|
103 |
+
if ( typeof tinymce !== 'undefined' ) {
|
104 |
+
tinymce.init( mceinit );
|
105 |
+
}
|
106 |
+
|
107 |
+
var qtinit = scf_generate_qtinit( editor_id );
|
108 |
+
tinyMCEPreInit.qtInit[editor_id] = qtinit;
|
109 |
+
if ( typeof quicktags !== 'undefined' ) {
|
110 |
+
quicktags( qtinit );
|
111 |
+
QTags._buttonsInit();
|
112 |
+
}
|
113 |
+
} );
|
114 |
+
} );
|
115 |
+
|
116 |
+
function initialize_editor( wrap, editor_id ) {
|
117 |
+
wrap.attr( 'id', 'wp-' + editor_id + '-wrap' );
|
118 |
+
wrap.find( 'a.add_media' ).attr( 'data-editor', editor_id );
|
119 |
+
wrap.find( '.switch-tmce' )
|
120 |
+
.attr( 'data-wp-editor-id', editor_id )
|
121 |
+
.attr( 'id', editor_id + '-tmce' );
|
122 |
+
wrap.find( '.switch-html' )
|
123 |
+
.attr( 'data-wp-editor-id', editor_id )
|
124 |
+
.attr( 'id', editor_id + '-html' );
|
125 |
+
wrap.find( '.quicktags-toolbar' ).attr( 'id', 'qt_' + editor_id + '_toolbar' );
|
126 |
+
}
|
127 |
+
|
128 |
+
function scf_generate_mceinit( editor_id ) {
|
129 |
+
var mceinit;
|
130 |
+
if ( typeof tinyMCEPreInit.mceInit.content !== 'undefined' ) {
|
131 |
+
mceinit = $.extend( true, {}, tinyMCEPreInit.mceInit.content );
|
132 |
+
mceinit.selector = '#' + editor_id;
|
133 |
+
} else {
|
134 |
+
mceinit = {
|
135 |
+
content_css: ['../wp-includes/js/tinymce/skins/wordpress/wp-content.css', '../wp-content/plugins/smart-custom-fields/css/wysiwyg.css'],
|
136 |
+
menubar: false,
|
137 |
+
plugins: "hr,wplink,fullscreen,wordpress,textcolor,paste,charmap",
|
138 |
+
toolbar1: "bold,italic,strikethrough,bullist,numlist,blockquote,hr,alignleft,aligncenter,alignright,link,unlink,wp_more,spellchecker,wp_adv,fullscreen",
|
139 |
+
toolbar2: "formatselect,underline,alignjustify,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help,code",
|
140 |
+
convert_urls: false,
|
141 |
+
theme: "modern",
|
142 |
+
skin: "lightgray",
|
143 |
+
wp_autoresize_on: true,
|
144 |
+
wpautop: true,
|
145 |
+
selector: '#' + editor_id
|
146 |
+
};
|
147 |
+
}
|
148 |
+
return mceinit;
|
149 |
+
}
|
150 |
+
|
151 |
+
function scf_generate_qtinit( editor_id ) {
|
152 |
+
var qtinit;
|
153 |
+
if ( typeof tinyMCEPreInit.qtInit.content !== 'undefined' ) {
|
154 |
+
qtinit = $.extend( true, {}, tinyMCEPreInit.qtInit.content );
|
155 |
+
qtinit.id = editor_id;
|
156 |
+
} else {
|
157 |
+
qtinit = {
|
158 |
+
id: editor_id,
|
159 |
+
buttons: "strong,em,link,block,del,ins,img,ul,ol,li,code,more,close"
|
160 |
+
}
|
161 |
+
}
|
162 |
+
return qtinit;
|
163 |
+
}
|
164 |
+
} );
|
trunk/js/editor.js
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* editor.js
|
3 |
+
* Version : 2.0.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : September 23, 2014
|
6 |
+
* Modified : June 4, 2016
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
|
12 |
+
$( '.smart-cf-meta-box' ).each( function( i, e ) {
|
13 |
+
var wrapper = $( e );
|
14 |
+
var btn_add_repeat_group = wrapper.find( '.btn-add-repeat-group' );
|
15 |
+
var btn_remove_repeat_group = wrapper.find( '.btn-remove-repeat-group' );
|
16 |
+
var table_class = '.smart-cf-meta-box-table';
|
17 |
+
var cnt = wrapper.find( table_class ).length;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* グループ追加ボタン
|
21 |
+
*/
|
22 |
+
btn_add_repeat_group.click( function( e ) {
|
23 |
+
cnt ++;
|
24 |
+
var parent = $( this ).parents( '.smart-cf-meta-box-repeat-tables' );
|
25 |
+
add_repeat_group( $( this ) );
|
26 |
+
} );
|
27 |
+
|
28 |
+
/**
|
29 |
+
* グループ削除ボタン
|
30 |
+
*/
|
31 |
+
btn_remove_repeat_group.click( function() {
|
32 |
+
var table = $( this ).parents( table_class );
|
33 |
+
table.fadeOut( 'fast', function() {
|
34 |
+
$( this ).remove();
|
35 |
+
} );
|
36 |
+
var tables = $( this ).parents( '.smart-cf-meta-box-repeat-tables' );
|
37 |
+
if ( tables.find( table_class ).length === 2 ) {
|
38 |
+
cnt ++;
|
39 |
+
add_repeat_group( $( this ) );
|
40 |
+
}
|
41 |
+
} );
|
42 |
+
|
43 |
+
function add_repeat_group( button ) {
|
44 |
+
var tables = button.parents( '.smart-cf-meta-box-repeat-tables' );
|
45 |
+
var table = tables.find( table_class ).first();
|
46 |
+
var clone = table.clone( true, true ).hide();
|
47 |
+
|
48 |
+
clone.find( 'input, select, textarea' ).each( function( i, e ) {
|
49 |
+
var name = $( this ).attr( 'name' );
|
50 |
+
if ( name ) {
|
51 |
+
$( this ).attr( 'name',
|
52 |
+
name.replace(
|
53 |
+
/^(smart-custom-fields\[.+?\])\[\]/,
|
54 |
+
'$1[' + cnt + ']'
|
55 |
+
)
|
56 |
+
);
|
57 |
+
$( this ).removeAttr( 'disabled' );
|
58 |
+
}
|
59 |
+
} );
|
60 |
+
|
61 |
+
button.parent().after( clone.fadeIn( 'fast' ) );
|
62 |
+
button.trigger( 'smart-cf-after-add-group', { button: button, clone: clone} );
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* 画像アップローダー
|
67 |
+
*/
|
68 |
+
wrapper.find( '.btn-add-image' ).click( function( e ) {
|
69 |
+
e.preventDefault();
|
70 |
+
var custom_uploader_image;
|
71 |
+
var upload_button = $( this );
|
72 |
+
if ( custom_uploader_image ) {
|
73 |
+
custom_uploader_image.open();
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
wp.media.view.Modal.prototype.on( 'ready', function(){
|
78 |
+
$( 'select.attachment-filters' )
|
79 |
+
.find( '[value="uploaded"]' )
|
80 |
+
.attr( 'selected', true )
|
81 |
+
.parent()
|
82 |
+
.trigger( 'change' );
|
83 |
+
} );
|
84 |
+
|
85 |
+
custom_uploader_image = wp.media( {
|
86 |
+
button : {
|
87 |
+
text: smart_cf_uploader.image_uploader_title
|
88 |
+
},
|
89 |
+
states: [
|
90 |
+
new wp.media.controller.Library({
|
91 |
+
title : smart_cf_uploader.image_uploader_title,
|
92 |
+
library : wp.media.query( { type: 'image' } ),
|
93 |
+
multiple : false,
|
94 |
+
filterable: 'uploaded'
|
95 |
+
})
|
96 |
+
]
|
97 |
+
} );
|
98 |
+
|
99 |
+
custom_uploader_image.on( 'select', function() {
|
100 |
+
var images = custom_uploader_image.state().get( 'selection' );
|
101 |
+
images.each( function( file ){
|
102 |
+
var sizes = file.get('sizes');
|
103 |
+
var image_area = upload_button.parent().find( '.smart-cf-upload-image' );
|
104 |
+
var sizename = image_area.data('size');
|
105 |
+
var img = sizes[ sizename ] || sizes.full;
|
106 |
+
image_area.find( 'img' ).remove();
|
107 |
+
image_area.prepend(
|
108 |
+
'<img src="' + img.url + '" />'
|
109 |
+
);
|
110 |
+
image_area.removeClass( 'hide' );
|
111 |
+
upload_button.parent().find( 'input[type="hidden"]' ).val( file.toJSON().id );
|
112 |
+
} );
|
113 |
+
} );
|
114 |
+
|
115 |
+
custom_uploader_image.open();
|
116 |
+
} );
|
117 |
+
|
118 |
+
/**
|
119 |
+
* 画像削除ボタン
|
120 |
+
*/
|
121 |
+
wrapper.find( '.smart-cf-upload-image' ).hover( function() {
|
122 |
+
$( this ).find( '.btn-remove-image' ).fadeIn( 'fast', function() {
|
123 |
+
$( this ).removeClass( 'hide' );
|
124 |
+
} );
|
125 |
+
}, function() {
|
126 |
+
$( this ).find( '.btn-remove-image' ).fadeOut( 'fast', function() {
|
127 |
+
$( this ).addClass( 'hide' );
|
128 |
+
} );
|
129 |
+
} );
|
130 |
+
wrapper.find( '.btn-remove-image' ).click( function() {
|
131 |
+
$( this ).parent().find( 'img' ).remove();
|
132 |
+
$( this ).parent().siblings( 'input[type="hidden"]' ).val( '' );
|
133 |
+
$( this ).parent().addClass( 'hide' );
|
134 |
+
} );
|
135 |
+
|
136 |
+
/**
|
137 |
+
* ファイルアップローダー
|
138 |
+
*/
|
139 |
+
wrapper.find( '.btn-add-file' ).click( function( e ) {
|
140 |
+
e.preventDefault();
|
141 |
+
var custom_uploader_file;
|
142 |
+
var upload_button = $( this );
|
143 |
+
if ( custom_uploader_file ) {
|
144 |
+
custom_uploader_file.open();
|
145 |
+
return;
|
146 |
+
}
|
147 |
+
custom_uploader_file = wp.media( {
|
148 |
+
title : smart_cf_uploader.file_uploader_title,
|
149 |
+
button: {
|
150 |
+
text: smart_cf_uploader.file_uploader_title
|
151 |
+
},
|
152 |
+
multiple: false
|
153 |
+
} );
|
154 |
+
|
155 |
+
custom_uploader_file.on( 'select', function() {
|
156 |
+
var images = custom_uploader_file.state().get( 'selection' );
|
157 |
+
images.each( function( file ){
|
158 |
+
var image_area = upload_button.parent().find( '.smart-cf-upload-file' );
|
159 |
+
image_area.find( 'a' ).remove();
|
160 |
+
image_area.prepend(
|
161 |
+
'<a href="' + file.toJSON().url + '" target="_blank"><img src="' + file.toJSON().icon + '" /><span>' + file.toJSON().filename + '</span></a>'
|
162 |
+
);
|
163 |
+
image_area.removeClass( 'hide' );
|
164 |
+
upload_button.parent().find( 'input[type="hidden"]' ).val( file.toJSON().id );
|
165 |
+
} );
|
166 |
+
} );
|
167 |
+
|
168 |
+
custom_uploader_file.open();
|
169 |
+
} );
|
170 |
+
|
171 |
+
/**
|
172 |
+
* ファイル削除ボタン
|
173 |
+
*/
|
174 |
+
wrapper.find( '.smart-cf-upload-file' ).hover( function() {
|
175 |
+
$( this ).find( '.btn-remove-file' ).fadeIn( 'fast', function() {
|
176 |
+
$( this ).removeClass( 'hide' );
|
177 |
+
} );
|
178 |
+
}, function() {
|
179 |
+
$( this ).find( '.btn-remove-file' ).fadeOut( 'fast', function() {
|
180 |
+
$( this ).addClass( 'hide' );
|
181 |
+
} );
|
182 |
+
} );
|
183 |
+
wrapper.find( '.btn-remove-file' ).click( function() {
|
184 |
+
$( this ).parent().find( 'img' ).remove();
|
185 |
+
$( this ).parent().siblings( 'input[type="hidden"]' ).val( '' );
|
186 |
+
$( this ).parent().addClass( 'hide' );
|
187 |
+
} );
|
188 |
+
|
189 |
+
/**
|
190 |
+
* sortable
|
191 |
+
*/
|
192 |
+
wrapper.find( '.smart-cf-meta-box-repeat-tables' ).sortable( {
|
193 |
+
handle: '.smart-cf-icon-handle',
|
194 |
+
items : '> .smart-cf-meta-box-table:not( :first-child )',
|
195 |
+
start : function( e, ui ) {
|
196 |
+
$( this ).trigger( 'smart-cf-repeat-table-sortable-start', ui.item );
|
197 |
+
},
|
198 |
+
stop : function( e, ui ) {
|
199 |
+
$( this ).trigger( 'smart-cf-repeat-table-sortable-stop', ui.item );
|
200 |
+
},
|
201 |
+
} );
|
202 |
+
|
203 |
+
} );
|
204 |
+
} );
|
trunk/js/settings-colorpicker.js
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* settings-colorpicker.js
|
3 |
+
* Version : 1.0.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : March 10, 2014
|
6 |
+
* Modified :
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
$( document ).on( 'smart-cf-setting-field-open', function( e, options ) {
|
12 |
+
if ( $( options ).hasClass( 'smart-cf-field-options-colorpicker' ) ) {
|
13 |
+
$( options ).find( '.default-option' ).each( function( i, e ) {
|
14 |
+
$( e ).wpColorPicker();
|
15 |
+
} );
|
16 |
+
}
|
17 |
+
} );
|
18 |
+
$( document ).on( 'smart-cf-setting-show-options', function( e, options ) {
|
19 |
+
if ( $( options ).hasClass( 'smart-cf-field-options-colorpicker' ) ) {
|
20 |
+
$( options ).find( '.default-option' ).each( function( i, e ) {
|
21 |
+
$( e ).wpColorPicker();
|
22 |
+
} );
|
23 |
+
}
|
24 |
+
} );
|
25 |
+
} );
|
trunk/js/settings-datepicker.js
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* settings-datepicker.js
|
3 |
+
* Version : 1.0.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : March 10, 2015
|
6 |
+
* Modified :
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
$( document ).on( 'smart-cf-setting-field-open', function( e, options ) {
|
12 |
+
if ( $( options ).hasClass( 'smart-cf-field-options-datepicker' ) ) {
|
13 |
+
$( options ).find( '.default-option' ).each( function( i, e ) {
|
14 |
+
$( e ).datepicker( $( e ).data( 'js' ) );
|
15 |
+
} );
|
16 |
+
}
|
17 |
+
} );
|
18 |
+
$( document ).on( 'smart-cf-setting-show-options', function( e, options ) {
|
19 |
+
if ( $( options ).hasClass( 'smart-cf-field-options-datepicker' ) ) {
|
20 |
+
$( options ).find( '.default-option' ).each( function( i, e ) {
|
21 |
+
$( e ).datepicker( $( e ).data( 'js' ) );
|
22 |
+
} );
|
23 |
+
}
|
24 |
+
} );
|
25 |
+
} );
|
trunk/js/settings.js
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* settings.js
|
3 |
+
* Version : 1.1.0
|
4 |
+
* Author : inc2734
|
5 |
+
* Created : September 23, 2014
|
6 |
+
* Modified : March 10, 2015
|
7 |
+
* License : GPLv2 or later
|
8 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
*/
|
10 |
+
jQuery( function( $ ) {
|
11 |
+
$( '.smart-cf-fields-wrapper' ).each( function( i, e ) {
|
12 |
+
var wrapper = $( e );
|
13 |
+
var btn_add_group = wrapper.find( '.btn-add-group' );
|
14 |
+
var btn_remove_group = wrapper.find( '.btn-remove-group' );
|
15 |
+
var btn_add_field = wrapper.find( '.btn-add-field' );
|
16 |
+
var btn_remove_field = wrapper.find( '.btn-remove-field' );
|
17 |
+
var group_class = '.smart-cf-group';
|
18 |
+
var field_class = '.smart-cf-field';
|
19 |
+
var duplicate_alert_class = '.smart-cf-duplicate-alert';
|
20 |
+
var options = wrapper.find( '.smart-cf-field-options' );
|
21 |
+
var cnt = wrapper.find( field_class ).length;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* 重複エラーメッセージ表示 & 重複時の更新不可
|
25 |
+
*/
|
26 |
+
wrapper.find( 'input[class="smart-cf-group-name"], input[class="smart-cf-field-name"]' ).keyup( function() {
|
27 |
+
var val = $( this ).val();
|
28 |
+
var cnt = 0;
|
29 |
+
wrapper.find( 'input[class="smart-cf-group-name"], input[class="smart-cf-field-name"]' ).each( function( i, e ) {
|
30 |
+
if ( val === $( this ).val() && val !== '' ) {
|
31 |
+
cnt ++;
|
32 |
+
}
|
33 |
+
} );
|
34 |
+
if ( cnt > 1 ) {
|
35 |
+
if ( $( this ).siblings( duplicate_alert_class ).length < 1 ) {
|
36 |
+
$( this ).after(
|
37 |
+
$( '<div class="smart-cf-alert" />' )
|
38 |
+
.addClass( duplicate_alert_class.replace( '.', '' ) )
|
39 |
+
.text( smart_cf_settings.duplicate_alert )
|
40 |
+
);
|
41 |
+
}
|
42 |
+
cnt = 0;
|
43 |
+
} else {
|
44 |
+
$( this ).siblings( duplicate_alert_class ).remove();
|
45 |
+
}
|
46 |
+
|
47 |
+
if ( $( duplicate_alert_class ).length ) {
|
48 |
+
$( '#publish' ).attr( 'disabled', 'disabled' );
|
49 |
+
} else {
|
50 |
+
$( '#publish' ).removeAttr( 'disabled' );
|
51 |
+
}
|
52 |
+
} );
|
53 |
+
|
54 |
+
/**
|
55 |
+
* sortable
|
56 |
+
*/
|
57 |
+
$( '.smart-cf-groups' ).sortable( {
|
58 |
+
cursor: 'move',
|
59 |
+
handle: '.smart-cf-icon-handle'
|
60 |
+
} );
|
61 |
+
$( '.smart-cf-fields' ).sortable( {
|
62 |
+
cursor: 'move',
|
63 |
+
handle: '.smart-cf-icon-handle'
|
64 |
+
} );
|
65 |
+
|
66 |
+
/**
|
67 |
+
* フィールドの開閉
|
68 |
+
*/
|
69 |
+
$( '.field-label' ).click( function() {
|
70 |
+
var field_label = $( this );
|
71 |
+
var table = $( this ).parents( field_class ).find( 'table' );
|
72 |
+
if ( table.hasClass( 'hide' ) ) {
|
73 |
+
field_label.html( " " );
|
74 |
+
table.fadeIn( 'fast', function() {
|
75 |
+
$( this ).removeClass( 'hide' );
|
76 |
+
table.find( '.smart-cf-field-options' ).each( function( i, e ) {
|
77 |
+
$( this ).trigger( 'smart-cf-setting-field-open', e );
|
78 |
+
} );
|
79 |
+
} );
|
80 |
+
} else {
|
81 |
+
var label = table.find( '.smart-cf-field-label' ).val();
|
82 |
+
var name = $( '<small>' ).text( '[ ' + table.find('.smart-cf-field-name').val() + ' ]' );
|
83 |
+
|
84 |
+
if ( !label ) {
|
85 |
+
label = table.find( '.smart-cf-field-name' ).val();
|
86 |
+
}
|
87 |
+
table.fadeOut( 'fast', function() {
|
88 |
+
$( this ).addClass( 'hide' );
|
89 |
+
field_label.text( label + " " ).append( name );
|
90 |
+
} );
|
91 |
+
}
|
92 |
+
} );
|
93 |
+
|
94 |
+
/**
|
95 |
+
* グループ追加ボタン
|
96 |
+
*/
|
97 |
+
btn_add_group.click( function() {
|
98 |
+
cnt ++;
|
99 |
+
var group = wrapper.find( group_class );
|
100 |
+
var group_clone = group.first().clone( true, true );
|
101 |
+
group.last().after( group_clone.fadeIn( 'fast', function() {
|
102 |
+
$( this ).removeClass( 'hide' );
|
103 |
+
} ) );
|
104 |
+
|
105 |
+
var field = group_clone.find( field_class );
|
106 |
+
var field_clone = field.first().clone( true, true );
|
107 |
+
field.last().after( field_clone.removeClass( 'hide' ) );
|
108 |
+
|
109 |
+
group_clone.find( 'input, select, textarea' ).each( function( i, e ) {
|
110 |
+
$( this ).attr( 'name',
|
111 |
+
$( this ).attr( 'name' ).replace(
|
112 |
+
/^(smart-custom-fields)\[\d+\]/,
|
113 |
+
'$1[' + cnt + ']'
|
114 |
+
)
|
115 |
+
);
|
116 |
+
} );
|
117 |
+
|
118 |
+
field_clone.find( 'input, select, textarea' ).each( function( i, e ) {
|
119 |
+
$( this ).attr( 'name',
|
120 |
+
$( this ).attr( 'name' ).replace(
|
121 |
+
/^(smart-custom-fields)\[.+?\](\[fields\])\[\d+?\]/,
|
122 |
+
'$1[' + cnt + ']$2[' + cnt + ']'
|
123 |
+
)
|
124 |
+
);
|
125 |
+
} );
|
126 |
+
} );
|
127 |
+
|
128 |
+
/**
|
129 |
+
* グループ削除ボタン
|
130 |
+
*/
|
131 |
+
btn_remove_group.click( function() {
|
132 |
+
$( this ).parents( group_class ).fadeOut( 'fast', function() {
|
133 |
+
$( this ).remove();
|
134 |
+
} );
|
135 |
+
} );
|
136 |
+
|
137 |
+
/**
|
138 |
+
* フィールド追加ボタン
|
139 |
+
*/
|
140 |
+
btn_add_field.click( function() {
|
141 |
+
cnt ++;
|
142 |
+
var group = $( this ).parents( group_class );
|
143 |
+
var field = group.find( field_class );
|
144 |
+
var clone = field.first().clone( true, true );
|
145 |
+
field.last().after( clone.fadeIn( 'fast', function() {
|
146 |
+
$( this ).removeClass( 'hide' );
|
147 |
+
} ) );
|
148 |
+
|
149 |
+
clone.find( 'input, select, textarea' ).each( function( i, e ) {
|
150 |
+
$( this ).attr( 'name',
|
151 |
+
$( this ).attr( 'name' ).replace(
|
152 |
+
/^(smart-custom-fields\[.+?\]\[fields\])\[\d+?\]/,
|
153 |
+
'$1[' + cnt + ']'
|
154 |
+
)
|
155 |
+
);
|
156 |
+
} );
|
157 |
+
} );
|
158 |
+
|
159 |
+
/**
|
160 |
+
* フィールド削除ボタン
|
161 |
+
*/
|
162 |
+
btn_remove_field.click( function() {
|
163 |
+
$( this ).parents( field_class ).fadeOut( 'fast', function() {
|
164 |
+
$( this ).remove();
|
165 |
+
} );
|
166 |
+
} );
|
167 |
+
|
168 |
+
/**
|
169 |
+
* 選択項目オプション
|
170 |
+
*/
|
171 |
+
options.find( 'input, textarea, select' ).attr( 'disabled', 'disabled' );
|
172 |
+
wrapper.find( '.smart-cf-field-select' ).each( function( i, e ) {
|
173 |
+
var selected_type = $( this ).val();
|
174 |
+
$( this ).parents( field_class ).find( '.smart-cf-field-options-' + selected_type )
|
175 |
+
.removeClass( 'hide' )
|
176 |
+
.find( 'input, textarea, select' ).removeAttr( 'disabled' );
|
177 |
+
} );
|
178 |
+
|
179 |
+
wrapper.find( '.smart-cf-field-select' ).change( function() {
|
180 |
+
var field = $( this ).parents( field_class );
|
181 |
+
var val = $( this ).val();
|
182 |
+
|
183 |
+
var hide_options = field.find( '.smart-cf-field-options' );
|
184 |
+
hide_options.addClass( 'hide' );
|
185 |
+
hide_options.find( 'input, textarea, select' ).attr( 'disabled', 'disabled' );
|
186 |
+
|
187 |
+
var show_options = field.find( '.smart-cf-field-options-' + val );
|
188 |
+
show_options.find( 'input, textarea, select' ).removeAttr( 'disabled' );
|
189 |
+
show_options.removeClass( 'hide' );
|
190 |
+
show_options.trigger( 'smart-cf-setting-show-options', show_options );
|
191 |
+
} );
|
192 |
+
|
193 |
+
/**
|
194 |
+
* リピートボタンクリック時
|
195 |
+
*/
|
196 |
+
wrapper.find( '.smart-cf-group-repeat input' ).click( function() {
|
197 |
+
var group = $( this ).parents( group_class );
|
198 |
+
var names = group.find( '.smart-cf-group-names' );
|
199 |
+
var btn_add_field = group.find( '.btn-add-field' );
|
200 |
+
if ( $( this ).prop( 'checked' ) ) {
|
201 |
+
names.removeClass( 'hide' );
|
202 |
+
btn_add_field.removeClass( 'hide' );
|
203 |
+
} else {
|
204 |
+
names.addClass( 'hide' );
|
205 |
+
btn_add_field.addClass( 'hide' );
|
206 |
+
}
|
207 |
+
} );
|
208 |
+
|
209 |
+
/**
|
210 |
+
* フィールド名入力ボックス
|
211 |
+
*/
|
212 |
+
wrapper.find( '.smart-cf-field-label' ).focus( function() {
|
213 |
+
var field = $( this ).parents( '.smart-cf-field' );
|
214 |
+
var name_val = field.find( '.smart-cf-field-name' ).val();
|
215 |
+
var label_val = $( this ).val();
|
216 |
+
if ( name_val && !label_val ) {
|
217 |
+
$( this ).val( name_val );
|
218 |
+
}
|
219 |
+
} );
|
220 |
+
} );
|
221 |
+
} );
|
trunk/languages/smart-custom-fields-ja.mo
ADDED
Binary file
|
trunk/languages/smart-custom-fields-ja.po
ADDED
@@ -0,0 +1,379 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2015 Smart Custom Fields
|
2 |
+
# This file is distributed under the same license as the Smart Custom Fields package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Smart Custom Fields 3.1.7\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smart-custom-"
|
7 |
+
"fields\n"
|
8 |
+
"POT-Creation-Date: 2018-06-26 09:22+0900\n"
|
9 |
+
"PO-Revision-Date: 2018-06-26 09:22+0900\n"
|
10 |
+
"Last-Translator: inc2734 <inc@2inc.org>\n"
|
11 |
+
"Language-Team: Japanese\n"
|
12 |
+
"Language: ja\n"
|
13 |
+
"MIME-Version: 1.0\n"
|
14 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
+
"Content-Transfer-Encoding: 8bit\n"
|
16 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
17 |
+
"X-Generator: Poedit 2.0.4\n"
|
18 |
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
19 |
+
"X-Poedit-KeywordsList: __;_e;esc_html__;esc_html_e;esc_attr__;esc_attr_e\n"
|
20 |
+
"X-Poedit-Basepath: ..\n"
|
21 |
+
"X-Poedit-SearchPath-0: .\n"
|
22 |
+
|
23 |
+
#: classes/controller/class.controller-base.php:46
|
24 |
+
msgid "Image setting"
|
25 |
+
msgstr "画像設定"
|
26 |
+
|
27 |
+
#: classes/controller/class.controller-base.php:47
|
28 |
+
msgid "File setting"
|
29 |
+
msgstr "ファイル設定"
|
30 |
+
|
31 |
+
#: classes/controller/class.option.php:57
|
32 |
+
msgid "Save settings"
|
33 |
+
msgstr "設定を保存"
|
34 |
+
|
35 |
+
#: classes/controller/class.profile.php:43
|
36 |
+
#: classes/controller/class.settings.php:82
|
37 |
+
msgid "Custom Fields"
|
38 |
+
msgstr "カスタムフィールド"
|
39 |
+
|
40 |
+
#: classes/controller/class.settings.php:29
|
41 |
+
msgid "Basic fields"
|
42 |
+
msgstr "基本フィールド"
|
43 |
+
|
44 |
+
#: classes/controller/class.settings.php:33
|
45 |
+
msgid "Select fields"
|
46 |
+
msgstr "選択フィールド"
|
47 |
+
|
48 |
+
#: classes/controller/class.settings.php:37
|
49 |
+
msgid "Content fields"
|
50 |
+
msgstr "コンテンツフィールド"
|
51 |
+
|
52 |
+
#: classes/controller/class.settings.php:41
|
53 |
+
msgid "Other fields"
|
54 |
+
msgstr "その他のフィールド"
|
55 |
+
|
56 |
+
#: classes/controller/class.settings.php:69
|
57 |
+
msgid "Same name exists!"
|
58 |
+
msgstr "同じ名前が存在します!"
|
59 |
+
|
60 |
+
#: classes/controller/class.settings.php:88
|
61 |
+
msgid "Display conditions ( Post )"
|
62 |
+
msgstr "表示条件(投稿)"
|
63 |
+
|
64 |
+
#: classes/controller/class.settings.php:95
|
65 |
+
msgid "Display conditions ( Profile )"
|
66 |
+
msgstr "表示条件(プロフィール)"
|
67 |
+
|
68 |
+
#: classes/controller/class.settings.php:102
|
69 |
+
msgid "Display conditions ( Taxonomy )"
|
70 |
+
msgstr "表示条件(タクソノミー)"
|
71 |
+
|
72 |
+
#: classes/controller/class.settings.php:109
|
73 |
+
msgid "Display conditions ( Options page )"
|
74 |
+
msgstr "表示条件(オプションページ)"
|
75 |
+
|
76 |
+
#: classes/controller/class.settings.php:169
|
77 |
+
msgid "Type"
|
78 |
+
msgstr "タイプ"
|
79 |
+
|
80 |
+
#: classes/controller/class.settings.php:204
|
81 |
+
msgid "Add Sub field"
|
82 |
+
msgstr "サブフィールドを追加"
|
83 |
+
|
84 |
+
#: classes/controller/class.settings.php:208
|
85 |
+
msgid "Add Field"
|
86 |
+
msgstr "フィールド追加"
|
87 |
+
|
88 |
+
#: classes/controller/class.settings.php:238
|
89 |
+
#: classes/fields/class.field-related-posts.php:235
|
90 |
+
msgid "Post Types"
|
91 |
+
msgstr "投稿タイプ"
|
92 |
+
|
93 |
+
#: classes/controller/class.settings.php:245
|
94 |
+
msgid "Post Ids ( Comma separated )"
|
95 |
+
msgstr "投稿 ID (カンマ区切り)"
|
96 |
+
|
97 |
+
#: classes/controller/class.settings.php:270
|
98 |
+
msgid "Roles"
|
99 |
+
msgstr "権限"
|
100 |
+
|
101 |
+
#: classes/controller/class.settings.php:296
|
102 |
+
#: classes/fields/class.field-related-terms.php:233
|
103 |
+
msgid "Taxonomies"
|
104 |
+
msgstr "タクソノミー"
|
105 |
+
|
106 |
+
#: classes/controller/class.settings.php:320
|
107 |
+
msgid "Options pages"
|
108 |
+
msgstr "オプションページ"
|
109 |
+
|
110 |
+
#: classes/fields/class.field-boolean.php:23
|
111 |
+
msgid "Boolean"
|
112 |
+
msgstr "真偽値"
|
113 |
+
|
114 |
+
#: classes/fields/class.field-boolean.php:38
|
115 |
+
msgid "Yes"
|
116 |
+
msgstr "はい"
|
117 |
+
|
118 |
+
#: classes/fields/class.field-boolean.php:39
|
119 |
+
msgid "No"
|
120 |
+
msgstr "いいえ"
|
121 |
+
|
122 |
+
#: classes/fields/class.field-boolean.php:85
|
123 |
+
#: classes/fields/class.field-check.php:119
|
124 |
+
#: classes/fields/class.field-colorpicker.php:107
|
125 |
+
#: classes/fields/class.field-datepicker.php:130
|
126 |
+
#: classes/fields/class.field-radio.php:118
|
127 |
+
#: classes/fields/class.field-select.php:93
|
128 |
+
#: classes/fields/class.field-text.php:68
|
129 |
+
#: classes/fields/class.field-textarea.php:81
|
130 |
+
#: classes/fields/class.field-wysiwyg.php:124
|
131 |
+
msgid "Default"
|
132 |
+
msgstr "デフォルト"
|
133 |
+
|
134 |
+
#: classes/fields/class.field-boolean.php:110
|
135 |
+
msgid "TRUE Label"
|
136 |
+
msgstr "TRUE ラベル"
|
137 |
+
|
138 |
+
#: classes/fields/class.field-boolean.php:120
|
139 |
+
msgid "FALSE Label"
|
140 |
+
msgstr "FALSE ラベル"
|
141 |
+
|
142 |
+
#: classes/fields/class.field-boolean.php:130
|
143 |
+
#: classes/fields/class.field-check.php:128
|
144 |
+
#: classes/fields/class.field-colorpicker.php:116
|
145 |
+
#: classes/fields/class.field-datepicker.php:194
|
146 |
+
#: classes/fields/class.field-file.php:119
|
147 |
+
#: classes/fields/class.field-image.php:114
|
148 |
+
#: classes/fields/class.field-radio.php:127
|
149 |
+
#: classes/fields/class.field-related-posts.php:264
|
150 |
+
#: classes/fields/class.field-related-terms.php:260
|
151 |
+
#: classes/fields/class.field-select.php:102
|
152 |
+
#: classes/fields/class.field-text.php:77
|
153 |
+
#: classes/fields/class.field-textarea.php:90
|
154 |
+
#: classes/fields/class.field-wysiwyg.php:133
|
155 |
+
msgid "Instruction"
|
156 |
+
msgstr "説明文"
|
157 |
+
|
158 |
+
#: classes/fields/class.field-boolean.php:137
|
159 |
+
#: classes/fields/class.field-check.php:135
|
160 |
+
#: classes/fields/class.field-colorpicker.php:123
|
161 |
+
#: classes/fields/class.field-datepicker.php:201
|
162 |
+
#: classes/fields/class.field-file.php:126
|
163 |
+
#: classes/fields/class.field-image.php:121
|
164 |
+
#: classes/fields/class.field-message.php:77
|
165 |
+
#: classes/fields/class.field-radio.php:134
|
166 |
+
#: classes/fields/class.field-related-posts.php:271
|
167 |
+
#: classes/fields/class.field-related-terms.php:267
|
168 |
+
#: classes/fields/class.field-select.php:109
|
169 |
+
#: classes/fields/class.field-text.php:84
|
170 |
+
#: classes/fields/class.field-textarea.php:97
|
171 |
+
#: classes/fields/class.field-wysiwyg.php:140
|
172 |
+
msgid "Notes"
|
173 |
+
msgstr "注記"
|
174 |
+
|
175 |
+
#: classes/fields/class.field-check.php:21
|
176 |
+
msgid "Check"
|
177 |
+
msgstr "チェックボックス"
|
178 |
+
|
179 |
+
#: classes/fields/class.field-check.php:89
|
180 |
+
#: classes/fields/class.field-radio.php:88
|
181 |
+
#: classes/fields/class.field-select.php:83
|
182 |
+
msgid "Choices"
|
183 |
+
msgstr "選択肢"
|
184 |
+
|
185 |
+
#: classes/fields/class.field-check.php:95
|
186 |
+
#: classes/fields/class.field-radio.php:94
|
187 |
+
#: classes/fields/class.field-select.php:89
|
188 |
+
msgid ""
|
189 |
+
"If you want to separate the key and the value, enter as follows: key => value"
|
190 |
+
msgstr "もしキーと値を分けたい場合は次のように入力してください: キー => 値"
|
191 |
+
|
192 |
+
#: classes/fields/class.field-check.php:99
|
193 |
+
#: classes/fields/class.field-radio.php:98
|
194 |
+
msgid "Display Direction"
|
195 |
+
msgstr "表示方向"
|
196 |
+
|
197 |
+
#: classes/fields/class.field-check.php:103
|
198 |
+
#: classes/fields/class.field-radio.php:102
|
199 |
+
msgid "horizontal"
|
200 |
+
msgstr "水平方向"
|
201 |
+
|
202 |
+
#: classes/fields/class.field-check.php:104
|
203 |
+
#: classes/fields/class.field-radio.php:103
|
204 |
+
msgid "vertical"
|
205 |
+
msgstr "垂直方向"
|
206 |
+
|
207 |
+
#: classes/fields/class.field-colorpicker.php:29
|
208 |
+
msgid "Color picker"
|
209 |
+
msgstr "カラーピッカー"
|
210 |
+
|
211 |
+
#: classes/fields/class.field-datepicker.php:29
|
212 |
+
msgid "Date picker"
|
213 |
+
msgstr "日付ピッカー"
|
214 |
+
|
215 |
+
#: classes/fields/class.field-datepicker.php:140
|
216 |
+
msgid "Date Format"
|
217 |
+
msgstr "日付のフォーマット"
|
218 |
+
|
219 |
+
#: classes/fields/class.field-datepicker.php:148
|
220 |
+
msgid "e.g dd/mm/yy"
|
221 |
+
msgstr "例: dd/mm/yy"
|
222 |
+
|
223 |
+
#: classes/fields/class.field-datepicker.php:158
|
224 |
+
msgid "Max Date"
|
225 |
+
msgstr "最大日付"
|
226 |
+
|
227 |
+
#: classes/fields/class.field-datepicker.php:166
|
228 |
+
#: classes/fields/class.field-datepicker.php:184
|
229 |
+
msgid "e.g +1m +1w"
|
230 |
+
msgstr "例: +1m +1w"
|
231 |
+
|
232 |
+
#: classes/fields/class.field-datepicker.php:176
|
233 |
+
msgid "Min Date"
|
234 |
+
msgstr "最小日付"
|
235 |
+
|
236 |
+
#: classes/fields/class.field-file.php:21
|
237 |
+
msgid "File"
|
238 |
+
msgstr "ファイル"
|
239 |
+
|
240 |
+
#: classes/fields/class.field-file.php:51
|
241 |
+
#: classes/fields/class.field-image.php:52
|
242 |
+
msgid "Delete"
|
243 |
+
msgstr "削除"
|
244 |
+
|
245 |
+
#: classes/fields/class.field-file.php:98
|
246 |
+
msgid "File Select"
|
247 |
+
msgstr "ファイル選択"
|
248 |
+
|
249 |
+
#: classes/fields/class.field-image.php:21
|
250 |
+
msgid "Image"
|
251 |
+
msgstr "画像"
|
252 |
+
|
253 |
+
#: classes/fields/class.field-image.php:92
|
254 |
+
msgid "Image Select"
|
255 |
+
msgstr "画像選択"
|
256 |
+
|
257 |
+
#: classes/fields/class.field-image.php:131
|
258 |
+
msgid "Preview Size"
|
259 |
+
msgstr "プレビューサイズ"
|
260 |
+
|
261 |
+
#: classes/fields/class.field-message.php:21
|
262 |
+
#: classes/fields/class.field-message.php:68
|
263 |
+
msgid "Message"
|
264 |
+
msgstr "メッセージ"
|
265 |
+
|
266 |
+
#: classes/fields/class.field-radio.php:21
|
267 |
+
msgid "Radio"
|
268 |
+
msgstr "ラジオボタン"
|
269 |
+
|
270 |
+
#: classes/fields/class.field-related-posts.php:24
|
271 |
+
msgid "Related Posts"
|
272 |
+
msgstr "関連する投稿"
|
273 |
+
|
274 |
+
#: classes/fields/class.field-related-posts.php:211
|
275 |
+
#: classes/fields/class.field-related-terms.php:209
|
276 |
+
msgid "Search..."
|
277 |
+
msgstr "検索 …"
|
278 |
+
|
279 |
+
#: classes/fields/class.field-related-posts.php:215
|
280 |
+
#: classes/fields/class.field-related-terms.php:213
|
281 |
+
msgid "Load more"
|
282 |
+
msgstr "さらに読み込む"
|
283 |
+
|
284 |
+
#: classes/fields/class.field-related-posts.php:256
|
285 |
+
#: classes/fields/class.field-related-terms.php:252
|
286 |
+
msgid "Selectable number"
|
287 |
+
msgstr "選択できる個数"
|
288 |
+
|
289 |
+
#: classes/fields/class.field-related-terms.php:24
|
290 |
+
msgid "Related Terms"
|
291 |
+
msgstr "関連するターム"
|
292 |
+
|
293 |
+
#: classes/fields/class.field-select.php:21
|
294 |
+
msgid "Select"
|
295 |
+
msgstr "セレクトボックス"
|
296 |
+
|
297 |
+
#: classes/fields/class.field-text.php:21
|
298 |
+
#: classes/fields/class.field-wysiwyg.php:108
|
299 |
+
msgid "Text"
|
300 |
+
msgstr "テキスト"
|
301 |
+
|
302 |
+
#: classes/fields/class.field-textarea.php:21
|
303 |
+
msgid "Textarea"
|
304 |
+
msgstr "テキストエリア"
|
305 |
+
|
306 |
+
#: classes/fields/class.field-textarea.php:71
|
307 |
+
msgid "Rows"
|
308 |
+
msgstr "行数"
|
309 |
+
|
310 |
+
#: classes/fields/class.field-wysiwyg.php:26
|
311 |
+
msgid "Wysiwyg"
|
312 |
+
msgstr "WYSIWYG"
|
313 |
+
|
314 |
+
#: classes/fields/class.field-wysiwyg.php:107
|
315 |
+
msgid "Visual"
|
316 |
+
msgstr "ビジュアル"
|
317 |
+
|
318 |
+
#: classes/fields/class.field-wysiwyg.php:162
|
319 |
+
#: classes/fields/class.field-wysiwyg.php:163
|
320 |
+
msgid "Add Media"
|
321 |
+
msgstr "メディアを追加"
|
322 |
+
|
323 |
+
#: classes/models/class.abstract-field-base.php:118
|
324 |
+
msgid "Name"
|
325 |
+
msgstr "名前"
|
326 |
+
|
327 |
+
#: classes/models/class.abstract-field-base.php:134
|
328 |
+
msgid "Label"
|
329 |
+
msgstr "ラベル"
|
330 |
+
|
331 |
+
#: classes/models/class.group.php:127
|
332 |
+
msgid "Repeat"
|
333 |
+
msgstr "繰り返し"
|
334 |
+
|
335 |
+
#: classes/models/class.group.php:132
|
336 |
+
msgid "Group name"
|
337 |
+
msgstr "グループ名"
|
338 |
+
|
339 |
+
#: classes/models/class.revisions.php:128 smart-custom-fields.php:168
|
340 |
+
#: smart-custom-fields.php:169 smart-custom-fields.php:170
|
341 |
+
msgid "Smart Custom Fields"
|
342 |
+
msgstr "Smart Custom Fields"
|
343 |
+
|
344 |
+
#: smart-custom-fields.php:171 smart-custom-fields.php:172
|
345 |
+
#: smart-custom-fields.php:218 smart-custom-fields.php:219
|
346 |
+
msgid "Add New"
|
347 |
+
msgstr "新規追加"
|
348 |
+
|
349 |
+
#: smart-custom-fields.php:173
|
350 |
+
msgid "New Field"
|
351 |
+
msgstr "新規フィールド"
|
352 |
+
|
353 |
+
#: smart-custom-fields.php:174
|
354 |
+
msgid "Edit Field"
|
355 |
+
msgstr "フィールド編集"
|
356 |
+
|
357 |
+
#: smart-custom-fields.php:175
|
358 |
+
msgid "View Field"
|
359 |
+
msgstr "フィールドを表示"
|
360 |
+
|
361 |
+
#: smart-custom-fields.php:176
|
362 |
+
msgid "All Fields"
|
363 |
+
msgstr "すべてのフィールド"
|
364 |
+
|
365 |
+
#: smart-custom-fields.php:177
|
366 |
+
msgid "Search Fields"
|
367 |
+
msgstr "フィールドを検索"
|
368 |
+
|
369 |
+
#: smart-custom-fields.php:178
|
370 |
+
msgid "Parent Fields:"
|
371 |
+
msgstr "親フィールド:"
|
372 |
+
|
373 |
+
#: smart-custom-fields.php:179
|
374 |
+
msgid "No Fields found."
|
375 |
+
msgstr "フィールドは見つかりませんでした。"
|
376 |
+
|
377 |
+
#: smart-custom-fields.php:180
|
378 |
+
msgid "No Fields found in Trash."
|
379 |
+
msgstr "ゴミ箱にフィールドは見つかりませんでした。"
|
trunk/languages/smart-custom-fields-pt_BR.mo
ADDED
Binary file
|
trunk/languages/smart-custom-fields-pt_BR.po
ADDED
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2017 Smart Custom Fields
|
2 |
+
# This file is distributed under the same license as the Smart Custom Fields package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Smart Custom Fields 3.1.7\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smart-custom-"
|
7 |
+
"fields\n"
|
8 |
+
"POT-Creation-Date: 2018-06-02 21:30-0300\n"
|
9 |
+
"PO-Revision-Date: 2018-06-02 21:30-0300\n"
|
10 |
+
"Last-Translator: robssanches <robssanches@hotmail.com>\n"
|
11 |
+
"Language-Team: Português do Brasil\n"
|
12 |
+
"Language: pt_BR\n"
|
13 |
+
"MIME-Version: 1.0\n"
|
14 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
+
"Content-Transfer-Encoding: 8bit\n"
|
16 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
17 |
+
"X-Generator: Poedit 2.0.7\n"
|
18 |
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
19 |
+
"X-Poedit-KeywordsList: __;_e;esc_html__;esc_html_e;esc_attr__;esc_attr_e\n"
|
20 |
+
"X-Poedit-Basepath: ..\n"
|
21 |
+
"X-Poedit-SearchPath-0: .\n"
|
22 |
+
|
23 |
+
#: classes/controller/class.controller-base.php:46
|
24 |
+
msgid "Image setting"
|
25 |
+
msgstr "Configuração de imagem"
|
26 |
+
|
27 |
+
#: classes/controller/class.controller-base.php:47
|
28 |
+
msgid "File setting"
|
29 |
+
msgstr "Configuração de arquivo"
|
30 |
+
|
31 |
+
#: classes/controller/class.option.php:57
|
32 |
+
msgid "Save settings"
|
33 |
+
msgstr "Salvar configurações"
|
34 |
+
|
35 |
+
#: classes/controller/class.profile.php:43
|
36 |
+
#: classes/controller/class.settings.php:76
|
37 |
+
msgid "Custom Fields"
|
38 |
+
msgstr "Campos personalizados"
|
39 |
+
|
40 |
+
#: classes/controller/class.settings.php:29
|
41 |
+
msgid "Basic fields"
|
42 |
+
msgstr "Campos básicos"
|
43 |
+
|
44 |
+
#: classes/controller/class.settings.php:33
|
45 |
+
msgid "Select fields"
|
46 |
+
msgstr "Selecione os campos"
|
47 |
+
|
48 |
+
#: classes/controller/class.settings.php:37
|
49 |
+
msgid "Content fields"
|
50 |
+
msgstr "Campos de conteúdo"
|
51 |
+
|
52 |
+
#: classes/controller/class.settings.php:41
|
53 |
+
msgid "Other fields"
|
54 |
+
msgstr "Outros campos"
|
55 |
+
|
56 |
+
#: classes/controller/class.settings.php:64
|
57 |
+
msgid "Same name exists!"
|
58 |
+
msgstr "O mesmo nome existe!"
|
59 |
+
|
60 |
+
#: classes/controller/class.settings.php:82
|
61 |
+
msgid "Display conditions ( Post )"
|
62 |
+
msgstr "Condições de exibição (Post)"
|
63 |
+
|
64 |
+
#: classes/controller/class.settings.php:89
|
65 |
+
msgid "Display conditions ( Profile )"
|
66 |
+
msgstr "Condições de exibição (Perfil)"
|
67 |
+
|
68 |
+
#: classes/controller/class.settings.php:96
|
69 |
+
msgid "Display conditions ( Taxonomy )"
|
70 |
+
msgstr "Condições de exibição (Taxonomia)"
|
71 |
+
|
72 |
+
#: classes/controller/class.settings.php:103
|
73 |
+
msgid "Display conditions ( Options page )"
|
74 |
+
msgstr "Condições de exibição (Página de Opções)"
|
75 |
+
|
76 |
+
#: classes/controller/class.settings.php:163
|
77 |
+
msgid "Type"
|
78 |
+
msgstr "Tipo"
|
79 |
+
|
80 |
+
#: classes/controller/class.settings.php:198
|
81 |
+
msgid "Add Sub field"
|
82 |
+
msgstr "Adicionar Campo Secundário"
|
83 |
+
|
84 |
+
#: classes/controller/class.settings.php:202
|
85 |
+
msgid "Add Field"
|
86 |
+
msgstr "Adicionar Campo"
|
87 |
+
|
88 |
+
#: classes/controller/class.settings.php:232
|
89 |
+
#: classes/fields/class.field-related-posts.php:231
|
90 |
+
msgid "Post Types"
|
91 |
+
msgstr "Tipos de Post"
|
92 |
+
|
93 |
+
#: classes/controller/class.settings.php:239
|
94 |
+
msgid "Post Ids ( Comma separated )"
|
95 |
+
msgstr "IDs de postagem (separados por vírgula)"
|
96 |
+
|
97 |
+
#: classes/controller/class.settings.php:264
|
98 |
+
msgid "Roles"
|
99 |
+
msgstr "Funções"
|
100 |
+
|
101 |
+
#: classes/controller/class.settings.php:290
|
102 |
+
#: classes/fields/class.field-related-terms.php:229
|
103 |
+
msgid "Taxonomies"
|
104 |
+
msgstr "Taxonomias"
|
105 |
+
|
106 |
+
#: classes/controller/class.settings.php:314
|
107 |
+
msgid "Options pages"
|
108 |
+
msgstr "Páginas de opções"
|
109 |
+
|
110 |
+
#: classes/fields/class.field-boolean.php:23
|
111 |
+
msgid "Boolean"
|
112 |
+
msgstr "Verdadeiro ou Falso"
|
113 |
+
|
114 |
+
#: classes/fields/class.field-boolean.php:38
|
115 |
+
msgid "Yes"
|
116 |
+
msgstr "Sim"
|
117 |
+
|
118 |
+
#: classes/fields/class.field-boolean.php:39
|
119 |
+
msgid "No"
|
120 |
+
msgstr "Não"
|
121 |
+
|
122 |
+
#: classes/fields/class.field-boolean.php:82
|
123 |
+
#: classes/fields/class.field-check.php:117
|
124 |
+
#: classes/fields/class.field-colorpicker.php:103
|
125 |
+
#: classes/fields/class.field-datepicker.php:125
|
126 |
+
#: classes/fields/class.field-message.php:67
|
127 |
+
#: classes/fields/class.field-radio.php:116
|
128 |
+
#: classes/fields/class.field-select.php:91
|
129 |
+
#: classes/fields/class.field-text.php:66
|
130 |
+
#: classes/fields/class.field-textarea.php:79
|
131 |
+
#: classes/fields/class.field-wysiwyg.php:122
|
132 |
+
msgid "Default"
|
133 |
+
msgstr "Padrão"
|
134 |
+
|
135 |
+
#: classes/fields/class.field-boolean.php:107
|
136 |
+
msgid "TRUE Label"
|
137 |
+
msgstr "Rótulo VERDADEIRO"
|
138 |
+
|
139 |
+
#: classes/fields/class.field-boolean.php:117
|
140 |
+
msgid "FALSE Label"
|
141 |
+
msgstr "Rótulo FALSO"
|
142 |
+
|
143 |
+
#: classes/fields/class.field-boolean.php:127
|
144 |
+
#: classes/fields/class.field-check.php:126
|
145 |
+
#: classes/fields/class.field-colorpicker.php:112
|
146 |
+
#: classes/fields/class.field-datepicker.php:189
|
147 |
+
#: classes/fields/class.field-file.php:117
|
148 |
+
#: classes/fields/class.field-image.php:112
|
149 |
+
#: classes/fields/class.field-radio.php:125
|
150 |
+
#: classes/fields/class.field-related-posts.php:260
|
151 |
+
#: classes/fields/class.field-related-terms.php:256
|
152 |
+
#: classes/fields/class.field-select.php:100
|
153 |
+
#: classes/fields/class.field-text.php:75
|
154 |
+
#: classes/fields/class.field-textarea.php:88
|
155 |
+
#: classes/fields/class.field-wysiwyg.php:131
|
156 |
+
msgid "Instruction"
|
157 |
+
msgstr "Instrução"
|
158 |
+
|
159 |
+
#: classes/fields/class.field-boolean.php:134
|
160 |
+
#: classes/fields/class.field-check.php:133
|
161 |
+
#: classes/fields/class.field-colorpicker.php:119
|
162 |
+
#: classes/fields/class.field-datepicker.php:196
|
163 |
+
#: classes/fields/class.field-file.php:124
|
164 |
+
#: classes/fields/class.field-image.php:119
|
165 |
+
#: classes/fields/class.field-message.php:76
|
166 |
+
#: classes/fields/class.field-radio.php:132
|
167 |
+
#: classes/fields/class.field-related-posts.php:267
|
168 |
+
#: classes/fields/class.field-related-terms.php:263
|
169 |
+
#: classes/fields/class.field-select.php:107
|
170 |
+
#: classes/fields/class.field-text.php:82
|
171 |
+
#: classes/fields/class.field-textarea.php:95
|
172 |
+
#: classes/fields/class.field-wysiwyg.php:138
|
173 |
+
msgid "Notes"
|
174 |
+
msgstr "Notas"
|
175 |
+
|
176 |
+
#: classes/fields/class.field-check.php:21
|
177 |
+
msgid "Check"
|
178 |
+
msgstr "Checkbox"
|
179 |
+
|
180 |
+
#: classes/fields/class.field-check.php:87
|
181 |
+
#: classes/fields/class.field-radio.php:86
|
182 |
+
#: classes/fields/class.field-select.php:81
|
183 |
+
msgid "Choices"
|
184 |
+
msgstr "Opções"
|
185 |
+
|
186 |
+
#: classes/fields/class.field-check.php:93
|
187 |
+
#: classes/fields/class.field-radio.php:92
|
188 |
+
#: classes/fields/class.field-select.php:87
|
189 |
+
msgid ""
|
190 |
+
"If you want to separate the key and the value, enter as follows: key => value"
|
191 |
+
msgstr ""
|
192 |
+
"Se você deseja separar a chave e o valor, insira da seguinte forma: key => "
|
193 |
+
"value"
|
194 |
+
|
195 |
+
#: classes/fields/class.field-check.php:97
|
196 |
+
#: classes/fields/class.field-radio.php:96
|
197 |
+
msgid "Display Direction"
|
198 |
+
msgstr "Direção de Exibição"
|
199 |
+
|
200 |
+
#: classes/fields/class.field-check.php:101
|
201 |
+
#: classes/fields/class.field-radio.php:100
|
202 |
+
msgid "horizontal"
|
203 |
+
msgstr "horizontal"
|
204 |
+
|
205 |
+
#: classes/fields/class.field-check.php:102
|
206 |
+
#: classes/fields/class.field-radio.php:101
|
207 |
+
msgid "vertical"
|
208 |
+
msgstr "vertical"
|
209 |
+
|
210 |
+
#: classes/fields/class.field-colorpicker.php:29
|
211 |
+
msgid "Color picker"
|
212 |
+
msgstr "Seletor de cores"
|
213 |
+
|
214 |
+
#: classes/fields/class.field-datepicker.php:29
|
215 |
+
msgid "Date picker"
|
216 |
+
msgstr "Seletor de data"
|
217 |
+
|
218 |
+
#: classes/fields/class.field-datepicker.php:135
|
219 |
+
msgid "Date Format"
|
220 |
+
msgstr "Formato de data"
|
221 |
+
|
222 |
+
#: classes/fields/class.field-datepicker.php:143
|
223 |
+
msgid "e.g dd/mm/yy"
|
224 |
+
msgstr "ex. dd/mm/yy"
|
225 |
+
|
226 |
+
#: classes/fields/class.field-datepicker.php:153
|
227 |
+
msgid "Max Date"
|
228 |
+
msgstr "Data máxima"
|
229 |
+
|
230 |
+
#: classes/fields/class.field-datepicker.php:161
|
231 |
+
#: classes/fields/class.field-datepicker.php:179
|
232 |
+
msgid "e.g +1m +1w"
|
233 |
+
msgstr "ex. +1m +1w"
|
234 |
+
|
235 |
+
#: classes/fields/class.field-datepicker.php:171
|
236 |
+
msgid "Min Date"
|
237 |
+
msgstr "Data mínima"
|
238 |
+
|
239 |
+
#: classes/fields/class.field-file.php:21
|
240 |
+
msgid "File"
|
241 |
+
msgstr "Arquivo"
|
242 |
+
|
243 |
+
#: classes/fields/class.field-file.php:51
|
244 |
+
#: classes/fields/class.field-image.php:52
|
245 |
+
msgid "Delete"
|
246 |
+
msgstr "Excluir"
|
247 |
+
|
248 |
+
#: classes/fields/class.field-file.php:98
|
249 |
+
msgid "File Select"
|
250 |
+
msgstr "Seleção de Arquivo"
|
251 |
+
|
252 |
+
#: classes/fields/class.field-image.php:21
|
253 |
+
msgid "Image"
|
254 |
+
msgstr "Imagem"
|
255 |
+
|
256 |
+
#: classes/fields/class.field-image.php:92
|
257 |
+
msgid "Image Select"
|
258 |
+
msgstr "Selecionar imagem"
|
259 |
+
|
260 |
+
#: classes/fields/class.field-image.php:129
|
261 |
+
msgid "Preview Size"
|
262 |
+
msgstr "Tamanho da pré-visualização"
|
263 |
+
|
264 |
+
#: classes/fields/class.field-message.php:21
|
265 |
+
msgid "Message"
|
266 |
+
msgstr "Mensagem"
|
267 |
+
|
268 |
+
#: classes/fields/class.field-radio.php:21
|
269 |
+
msgid "Radio"
|
270 |
+
msgstr "Radio"
|
271 |
+
|
272 |
+
#: classes/fields/class.field-related-posts.php:24
|
273 |
+
msgid "Related Posts"
|
274 |
+
msgstr "Posts Relacionados"
|
275 |
+
|
276 |
+
#: classes/fields/class.field-related-posts.php:209
|
277 |
+
#: classes/fields/class.field-related-terms.php:207
|
278 |
+
msgid "Search..."
|
279 |
+
msgstr "Pesquisa..."
|
280 |
+
|
281 |
+
#: classes/fields/class.field-related-posts.php:213
|
282 |
+
#: classes/fields/class.field-related-terms.php:211
|
283 |
+
msgid "Load more"
|
284 |
+
msgstr "Carregar mais"
|
285 |
+
|
286 |
+
#: classes/fields/class.field-related-posts.php:252
|
287 |
+
#: classes/fields/class.field-related-terms.php:248
|
288 |
+
msgid "Selectable number"
|
289 |
+
msgstr "Número selecionável"
|
290 |
+
|
291 |
+
#: classes/fields/class.field-related-terms.php:24
|
292 |
+
msgid "Related Terms"
|
293 |
+
msgstr "Termos relacionados"
|
294 |
+
|
295 |
+
#: classes/fields/class.field-select.php:21
|
296 |
+
msgid "Select"
|
297 |
+
msgstr "Seleção"
|
298 |
+
|
299 |
+
#: classes/fields/class.field-text.php:21
|
300 |
+
#: classes/fields/class.field-wysiwyg.php:108
|
301 |
+
msgid "Text"
|
302 |
+
msgstr "Texto"
|
303 |
+
|
304 |
+
#: classes/fields/class.field-textarea.php:21
|
305 |
+
msgid "Textarea"
|
306 |
+
msgstr "Área de Texto"
|
307 |
+
|
308 |
+
#: classes/fields/class.field-textarea.php:69
|
309 |
+
msgid "Rows"
|
310 |
+
msgstr "Linhas"
|
311 |
+
|
312 |
+
#: classes/fields/class.field-wysiwyg.php:26
|
313 |
+
msgid "Wysiwyg"
|
314 |
+
msgstr "Wysiwyg"
|
315 |
+
|
316 |
+
#: classes/fields/class.field-wysiwyg.php:107
|
317 |
+
msgid "Visual"
|
318 |
+
msgstr "Visual"
|
319 |
+
|
320 |
+
#: classes/fields/class.field-wysiwyg.php:160
|
321 |
+
#: classes/fields/class.field-wysiwyg.php:161
|
322 |
+
msgid "Add Media"
|
323 |
+
msgstr "Adicionar Mídia"
|
324 |
+
|
325 |
+
#: classes/models/class.abstract-field-base.php:106
|
326 |
+
msgid "Name"
|
327 |
+
msgstr "Nome"
|
328 |
+
|
329 |
+
#: classes/models/class.abstract-field-base.php:117
|
330 |
+
msgid "Label"
|
331 |
+
msgstr "Rótulo"
|
332 |
+
|
333 |
+
#: classes/models/class.group.php:127
|
334 |
+
msgid "Repeat"
|
335 |
+
msgstr "Repetir"
|
336 |
+
|
337 |
+
#: classes/models/class.group.php:132
|
338 |
+
msgid "Group name"
|
339 |
+
msgstr "Nome do grupo"
|
340 |
+
|
341 |
+
#: classes/models/class.revisions.php:128 smart-custom-fields.php:168
|
342 |
+
#: smart-custom-fields.php:169 smart-custom-fields.php:170
|
343 |
+
msgid "Smart Custom Fields"
|
344 |
+
msgstr "Smart Custom Fields"
|
345 |
+
|
346 |
+
#: smart-custom-fields.php:171 smart-custom-fields.php:172
|
347 |
+
#: smart-custom-fields.php:218 smart-custom-fields.php:219
|
348 |
+
msgid "Add New"
|
349 |
+
msgstr "Adicionar Novo"
|
350 |
+
|
351 |
+
#: smart-custom-fields.php:173
|
352 |
+
msgid "New Field"
|
353 |
+
msgstr "Novo Campo"
|
354 |
+
|
355 |
+
#: smart-custom-fields.php:174
|
356 |
+
msgid "Edit Field"
|
357 |
+
msgstr "Editar campo"
|
358 |
+
|
359 |
+
#: smart-custom-fields.php:175
|
360 |
+
msgid "View Field"
|
361 |
+
msgstr "Visualizar campo"
|
362 |
+
|
363 |
+
#: smart-custom-fields.php:176
|
364 |
+
msgid "All Fields"
|
365 |
+
msgstr "Todos os Campos"
|
366 |
+
|
367 |
+
#: smart-custom-fields.php:177
|
368 |
+
msgid "Search Fields"
|
369 |
+
msgstr "Campos de Pesquisa"
|
370 |
+
|
371 |
+
#: smart-custom-fields.php:178
|
372 |
+
msgid "Parent Fields:"
|
373 |
+
msgstr "Campos pai:"
|
374 |
+
|
375 |
+
#: smart-custom-fields.php:179
|
376 |
+
msgid "No Fields found."
|
377 |
+
msgstr "Nenhum campo encontrado."
|
378 |
+
|
379 |
+
#: smart-custom-fields.php:180
|
380 |
+
msgid "No Fields found in Trash."
|
381 |
+
msgstr "Nenhum campo encontrado na lixeira."
|
382 |
+
|
383 |
+
#~ msgid ""
|
384 |
+
#~ "Smart Custom Fields is a simple plugin that management custom fields."
|
385 |
+
#~ msgstr ""
|
386 |
+
#~ "Smart Custom Fields é um plugin simples que gerencia campos "
|
387 |
+
#~ "personalizados."
|
trunk/languages/smart-custom-fields.pot
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2018 Smart Custom Fields
|
2 |
+
# This file is distributed under the same license as the Smart Custom Fields package.
|
3 |
+
#, fuzzy
|
4 |
+
msgid ""
|
5 |
+
msgstr ""
|
6 |
+
"Project-Id-Version: Smart Custom Fields 3.1.7\n"
|
7 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/smart-custom-"
|
8 |
+
"fields\n"
|
9 |
+
"POT-Creation-Date: 2018-06-02 21:26-0300\n"
|
10 |
+
"MIME-Version: 1.0\n"
|
11 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
+
"Content-Transfer-Encoding: 8bit\n"
|
13 |
+
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
|
14 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
15 |
+
"Language-Team: Smart Custom Fields <LL@li.org>\n"
|
16 |
+
"X-Generator: Poedit 2.0.7\n"
|
17 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
18 |
+
"X-Poedit-KeywordsList: esc_html__;__;_n;_x;_n_noop;_e\n"
|
19 |
+
"X-Poedit-Basepath: ..\n"
|
20 |
+
"X-Poedit-SearchPath-0: .\n"
|
21 |
+
|
22 |
+
#: classes/controller/class.controller-base.php:46
|
23 |
+
msgid "Image setting"
|
24 |
+
msgstr ""
|
25 |
+
|
26 |
+
#: classes/controller/class.controller-base.php:47
|
27 |
+
msgid "File setting"
|
28 |
+
msgstr ""
|
29 |
+
|
30 |
+
#: classes/controller/class.profile.php:43
|
31 |
+
#: classes/controller/class.settings.php:76
|
32 |
+
msgid "Custom Fields"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: classes/controller/class.settings.php:64
|
36 |
+
msgid "Same name exists!"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: classes/controller/class.settings.php:82
|
40 |
+
msgid "Display conditions ( Post )"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: classes/controller/class.settings.php:89
|
44 |
+
msgid "Display conditions ( Profile )"
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: classes/controller/class.settings.php:96
|
48 |
+
msgid "Display conditions ( Taxonomy )"
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: classes/controller/class.settings.php:103
|
52 |
+
msgid "Display conditions ( Options page )"
|
53 |
+
msgstr ""
|
54 |
+
|
55 |
+
#: classes/controller/class.settings.php:232
|
56 |
+
msgid "Post Types"
|
57 |
+
msgstr ""
|
58 |
+
|
59 |
+
#: classes/controller/class.settings.php:239
|
60 |
+
msgid "Post Ids ( Comma separated )"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: classes/controller/class.settings.php:264
|
64 |
+
msgid "Roles"
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#: classes/controller/class.settings.php:290
|
68 |
+
msgid "Taxonomies"
|
69 |
+
msgstr ""
|
70 |
+
|
71 |
+
#: classes/controller/class.settings.php:314
|
72 |
+
msgid "Options pages"
|
73 |
+
msgstr ""
|
74 |
+
|
75 |
+
#: classes/fields/class.field-boolean.php:23
|
76 |
+
msgid "Boolean"
|
77 |
+
msgstr ""
|
78 |
+
|
79 |
+
#: classes/fields/class.field-boolean.php:38
|
80 |
+
msgid "Yes"
|
81 |
+
msgstr ""
|
82 |
+
|
83 |
+
#: classes/fields/class.field-boolean.php:39
|
84 |
+
msgid "No"
|
85 |
+
msgstr ""
|
86 |
+
|
87 |
+
#: classes/fields/class.field-check.php:21
|
88 |
+
msgid "Check"
|
89 |
+
msgstr ""
|
90 |
+
|
91 |
+
#: classes/fields/class.field-check.php:101
|
92 |
+
#: classes/fields/class.field-radio.php:100
|
93 |
+
msgid "horizontal"
|
94 |
+
msgstr ""
|
95 |
+
|
96 |
+
#: classes/fields/class.field-check.php:102
|
97 |
+
#: classes/fields/class.field-radio.php:101
|
98 |
+
msgid "vertical"
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: classes/fields/class.field-colorpicker.php:29
|
102 |
+
msgid "Color picker"
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: classes/fields/class.field-datepicker.php:29
|
106 |
+
msgid "Date picker"
|
107 |
+
msgstr ""
|
108 |
+
|
109 |
+
#: classes/fields/class.field-file.php:21
|
110 |
+
msgid "File"
|
111 |
+
msgstr ""
|
112 |
+
|
113 |
+
#: classes/fields/class.field-file.php:51
|
114 |
+
#: classes/fields/class.field-image.php:52
|
115 |
+
msgid "Delete"
|
116 |
+
msgstr ""
|
117 |
+
|
118 |
+
#: classes/fields/class.field-file.php:98
|
119 |
+
msgid "File Select"
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: classes/fields/class.field-image.php:21
|
123 |
+
msgid "Image"
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: classes/fields/class.field-image.php:92
|
127 |
+
msgid "Image Select"
|
128 |
+
msgstr ""
|
129 |
+
|
130 |
+
#: classes/fields/class.field-message.php:21
|
131 |
+
msgid "Message"
|
132 |
+
msgstr ""
|
133 |
+
|
134 |
+
#: classes/fields/class.field-radio.php:21
|
135 |
+
msgid "Radio"
|
136 |
+
msgstr ""
|
137 |
+
|
138 |
+
#: classes/fields/class.field-related-posts.php:24
|
139 |
+
msgid "Related Posts"
|
140 |
+
msgstr ""
|
141 |
+
|
142 |
+
#: classes/fields/class.field-related-posts.php:213
|
143 |
+
#: classes/fields/class.field-related-terms.php:211
|
144 |
+
msgid "Load more"
|
145 |
+
msgstr ""
|
146 |
+
|
147 |
+
#: classes/fields/class.field-related-terms.php:24
|
148 |
+
msgid "Related Terms"
|
149 |
+
msgstr ""
|
150 |
+
|
151 |
+
#: classes/fields/class.field-select.php:21
|
152 |
+
msgid "Select"
|
153 |
+
msgstr ""
|
154 |
+
|
155 |
+
#: classes/fields/class.field-text.php:21
|
156 |
+
#: classes/fields/class.field-wysiwyg.php:108
|
157 |
+
msgid "Text"
|
158 |
+
msgstr ""
|
159 |
+
|
160 |
+
#: classes/fields/class.field-textarea.php:21
|
161 |
+
msgid "Textarea"
|
162 |
+
msgstr ""
|
163 |
+
|
164 |
+
#: classes/fields/class.field-wysiwyg.php:26
|
165 |
+
msgid "Wysiwyg"
|
166 |
+
msgstr ""
|
167 |
+
|
168 |
+
#: classes/fields/class.field-wysiwyg.php:107
|
169 |
+
msgid "Visual"
|
170 |
+
msgstr ""
|
171 |
+
|
172 |
+
#: classes/fields/class.field-wysiwyg.php:161
|
173 |
+
msgid "Add Media"
|
174 |
+
msgstr ""
|
175 |
+
|
176 |
+
#: classes/models/class.revisions.php:128 smart-custom-fields.php:168
|
177 |
+
#: smart-custom-fields.php:169 smart-custom-fields.php:170
|
178 |
+
msgid "Smart Custom Fields"
|
179 |
+
msgstr ""
|
180 |
+
|
181 |
+
#: smart-custom-fields.php:171 smart-custom-fields.php:172
|
182 |
+
#: smart-custom-fields.php:218 smart-custom-fields.php:219
|
183 |
+
msgid "Add New"
|
184 |
+
msgstr ""
|
185 |
+
|
186 |
+
#: smart-custom-fields.php:173
|
187 |
+
msgid "New Field"
|
188 |
+
msgstr ""
|
189 |
+
|
190 |
+
#: smart-custom-fields.php:174
|
191 |
+
msgid "Edit Field"
|
192 |
+
msgstr ""
|
193 |
+
|
194 |
+
#: smart-custom-fields.php:175
|
195 |
+
msgid "View Field"
|
196 |
+
msgstr ""
|
197 |
+
|
198 |
+
#: smart-custom-fields.php:176
|
199 |
+
msgid "All Fields"
|
200 |
+
msgstr ""
|
201 |
+
|
202 |
+
#: smart-custom-fields.php:177
|
203 |
+
msgid "Search Fields"
|
204 |
+
msgstr ""
|
205 |
+
|
206 |
+
#: smart-custom-fields.php:178
|
207 |
+
msgid "Parent Fields:"
|
208 |
+
msgstr ""
|
209 |
+
|
210 |
+
#: smart-custom-fields.php:179
|
211 |
+
msgid "No Fields found."
|
212 |
+
msgstr ""
|
213 |
+
|
214 |
+
#: smart-custom-fields.php:180
|
215 |
+
msgid "No Fields found in Trash."
|
216 |
+
msgstr ""
|
trunk/readme.txt
ADDED
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Smart Custom Fields ===
|
2 |
+
Contributors: inc2734, toro_unit, mimosafa, hideokamoto, hisako-isaka, kurudrive, hanamura, justinticktock, designhehe, mayukojpn, hogetan, robssanches
|
3 |
+
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.9.6
|
7 |
+
Stable tag: 4.0.0
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
Smart Custom Fields is a simple plugin for managing custom fields.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
Smart Custom Fields is a simple plugin for managing custom fields.
|
16 |
+
|
17 |
+
= Features =
|
18 |
+
|
19 |
+
* Field group loop support.
|
20 |
+
* Meta data revision support.
|
21 |
+
* Meta data preview support.
|
22 |
+
|
23 |
+
https://www.youtube.com/watch?v=WxPZurn0yvI
|
24 |
+
|
25 |
+
= Field Types =
|
26 |
+
|
27 |
+
* Text
|
28 |
+
* Textarea
|
29 |
+
* Radio
|
30 |
+
* Select
|
31 |
+
* Checkbox
|
32 |
+
* WYSIWYG editor
|
33 |
+
* Image
|
34 |
+
* File
|
35 |
+
* Related Posts
|
36 |
+
* Related Terms
|
37 |
+
* Color picker
|
38 |
+
* Date picker
|
39 |
+
* Boolean
|
40 |
+
* Message
|
41 |
+
|
42 |
+
= How to get meta data ? =
|
43 |
+
|
44 |
+
**Post meta data**
|
45 |
+
|
46 |
+
This method can get any meta data.
|
47 |
+
|
48 |
+
`SCF::get( 'field-name' )`
|
49 |
+
|
50 |
+
This method can get meta data of any group.
|
51 |
+
|
52 |
+
`SCF::get( 'group-name' )`
|
53 |
+
|
54 |
+
This method can get all meta data.
|
55 |
+
|
56 |
+
`SCF::gets()`
|
57 |
+
|
58 |
+
**User meta data**
|
59 |
+
|
60 |
+
This method can get any user meta data.
|
61 |
+
|
62 |
+
`SCF::get_user_meta( $user_id, 'field-name' )`
|
63 |
+
|
64 |
+
This method can get user meta data of any group.
|
65 |
+
|
66 |
+
`SCF::get_user_meta( $user_id, 'group-name' )`
|
67 |
+
|
68 |
+
This method can get all user meta data.
|
69 |
+
|
70 |
+
`SCF::get_user_meta( $user_id )`
|
71 |
+
|
72 |
+
**Term meta data**
|
73 |
+
|
74 |
+
This method can get any term meta data.
|
75 |
+
|
76 |
+
`SCF::get_term_meta( $term_id, $taxonomy 'field-name' )`
|
77 |
+
|
78 |
+
This method can get term meta data of any group.
|
79 |
+
|
80 |
+
`SCF::get_term_meta( $term_id, $taxonomy, 'group-name' )`
|
81 |
+
|
82 |
+
This method can get all term meta data.
|
83 |
+
|
84 |
+
`SCF::get_term_meta( $term_id, $taxonomy )`
|
85 |
+
|
86 |
+
**Custom options page meta data**
|
87 |
+
|
88 |
+
This method can get any custom options page meta data.
|
89 |
+
|
90 |
+
`SCF::get_option_meta( $menu_slug, 'field-name' )`
|
91 |
+
|
92 |
+
This method can get custom options page meta data of any group.
|
93 |
+
|
94 |
+
`SCF::get_option_meta( $menu_slug, 'group-name' )`
|
95 |
+
|
96 |
+
This method can get all custom options page meta data.
|
97 |
+
|
98 |
+
`SCF::get_option_meta( $menu_slug )`
|
99 |
+
|
100 |
+
= Create custom options page =
|
101 |
+
|
102 |
+
`SCF::add_options_page( $page_title, $menu_title, $capability, $menu_slug, $icon_url = '', $position = null );`
|
103 |
+
|
104 |
+
= Register custom fields by the code. =
|
105 |
+
|
106 |
+
https://gist.github.com/inc2734/9f6d65c7473d060d0fd6
|
107 |
+
|
108 |
+
= GitHub =
|
109 |
+
|
110 |
+
https://github.com/inc2734/smart-custom-fields/
|
111 |
+
|
112 |
+
= Translators =
|
113 |
+
|
114 |
+
* Japanese(ja) - [JOTAKI Taisuke](https://profiles.wordpress.org/tai/)
|
115 |
+
|
116 |
+
You can translate this plugin into your language by using [GlotPress](https://translate.wordpress.org/projects/wp-plugins/smart-custom-fields).
|
117 |
+
|
118 |
+
== Installation ==
|
119 |
+
|
120 |
+
1. Upload `Smart Custom Fields` to the `/wp-content/plugins/` directory
|
121 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
122 |
+
1. You can setting custom fields in 'Smart Custom Fields' page.
|
123 |
+
|
124 |
+
== Screenshots ==
|
125 |
+
|
126 |
+
1. Smart Custom Fields settings page.
|
127 |
+
2. Post edit page.
|
128 |
+
|
129 |
+
== Changelog ==
|
130 |
+
|
131 |
+
= 4.0.0 =
|
132 |
+
* Add message field. #64 (by [@robssanches](https://github.com/robssanches))
|
133 |
+
* Fix boolean field bug with `smart-cf-register-fields` filter hook.
|
134 |
+
* Refactoring displaying options process of each fields.
|
135 |
+
|
136 |
+
= 3.1.7 =
|
137 |
+
* Fixing issues and adding support for the Brazilian Portuguese language #63 (by [@robssanches](https://github.com/robssanches))
|
138 |
+
* Spelling fixes in Readme #62 (by [@garrett-eclipse](https://github.com/garrett-eclipse))
|
139 |
+
|
140 |
+
= 3.1.6 =
|
141 |
+
* Set any on related post status. #60 (by [@mayukojpn](https://github.com/mayukojpn))
|
142 |
+
* Changed that file names can be known when uploading files. #58 (by [@shodoi](https://github.com/shodoi))
|
143 |
+
|
144 |
+
= 3.1.5 =
|
145 |
+
* Fixed a bug that disappeared layout when introducing description in relation field. #56 (by [@mayukojpn](https://github.com/mayukojpn))
|
146 |
+
* Update item delete button style in relation field.
|
147 |
+
* Fix bug when using smart-cf-register-fields hook.
|
148 |
+
|
149 |
+
= 3.1.4 =
|
150 |
+
* Remove no used codes.
|
151 |
+
* Fixed a bug that name disappears when opening / closing a field. #51 (by [@yousan](https://github.com/yousan))
|
152 |
+
|
153 |
+
= 3.1.3 =
|
154 |
+
* Fix Selectable number bug
|
155 |
+
|
156 |
+
= 3.1.2 =
|
157 |
+
* Update readme.txt
|
158 |
+
|
159 |
+
= 3.1.1 =
|
160 |
+
* Fixed a bug of limit attribute at relation post types and taxonomies field.
|
161 |
+
|
162 |
+
= 3.1.0 =
|
163 |
+
* Added limit attribute at relation post types and taxonomies field.
|
164 |
+
|
165 |
+
= 3.0.1 =
|
166 |
+
* Fixed a bug that icon and display position of created option page are not reflected #47 (by [@designhehe](https://github.com/designhehe))
|
167 |
+
|
168 |
+
= 3.0.0 =
|
169 |
+
* Support multiple user roles.
|
170 |
+
* Update filter hook smart-cf-register-fields
|
171 |
+
|
172 |
+
= 2.3.0 =
|
173 |
+
* Support displayed thumbnail when value of file and image field is file url.
|
174 |
+
|
175 |
+
= 2.2.3 =
|
176 |
+
* Fix get_post_metadata hooked only preview #43 (by [@wireframeslayout](https://github.com/wireframeslayout))
|
177 |
+
|
178 |
+
= 2.2.2 =
|
179 |
+
* Fix #37 #38
|
180 |
+
|
181 |
+
= 2.2.1 =
|
182 |
+
* Fix bug boolean field in repeatable group #39
|
183 |
+
* Fix bug datepicker and colorpicker in repeatable group #41
|
184 |
+
|
185 |
+
= 2.2.0 =
|
186 |
+
* Refactoring tests.
|
187 |
+
* Changed behavior of the default value of new field of the already saved object. Using the default value.
|
188 |
+
|
189 |
+
= 2.1.1 =
|
190 |
+
* Fix revision lines duplication (by [@hanamura](https://github.com/hanamura))
|
191 |
+
* Fixed a bug that relation fields don't work on the options page.
|
192 |
+
|
193 |
+
= 2.1.0 =
|
194 |
+
* Support separated key and value in select, checkbox, radio.
|
195 |
+
* Added switching editor mode tab in wysiwyg field.
|
196 |
+
* Added instruction of field option.
|
197 |
+
|
198 |
+
= 2.0.0 =
|
199 |
+
* Refactoring
|
200 |
+
* Added meta data of custom options page.
|
201 |
+
|
202 |
+
= 1.7.0 =
|
203 |
+
* Added taxonomy relation field.
|
204 |
+
* Added textarea rows setting.
|
205 |
+
* Fixed a bug that tinymce js error when disabled rich editing.
|
206 |
+
|
207 |
+
= 1.6.7 =
|
208 |
+
* Removed console.log in a js file.
|
209 |
+
|
210 |
+
= 1.6.6 =
|
211 |
+
* Fixed a bug that warning is out when the array isn't returned in the smart-cf-register-fields.
|
212 |
+
|
213 |
+
= 1.6.5 =
|
214 |
+
* Fixed a bug that multi value in the loop is broken.
|
215 |
+
* In setting screen, if the field is closed, display the field name.
|
216 |
+
|
217 |
+
= 1.6.4 =
|
218 |
+
* Fixed a bug that wysiwyg fields became tinymce default format when content editor mode is text.
|
219 |
+
* Change the comment in English.
|
220 |
+
|
221 |
+
= 1.6.3 =
|
222 |
+
* Fixed a bug that metadata that isn't defined by Smart Custom Fields can't get in preview.
|
223 |
+
|
224 |
+
= 1.6.2 =
|
225 |
+
* Fixed a bug that sometimes can't get data when there are multiple Smart Custom Fields settings.
|
226 |
+
|
227 |
+
= 1.6.1 =
|
228 |
+
* Fixed a bug that custom field settings vanished when saved.
|
229 |
+
|
230 |
+
= 1.6.0 =
|
231 |
+
* Added search feature in the relation field.
|
232 |
+
* Changed when the object isn't saved, default value is active.
|
233 |
+
* Remove filter hook smart-cf-is_use_default_when_not_saved.
|
234 |
+
* Fixed a bug that isn't displayed meta data in preview when using custom fields settings with post id.
|
235 |
+
|
236 |
+
= 1.5.3 =
|
237 |
+
* Fixed a wysiwyg field bug.
|
238 |
+
|
239 |
+
= 1.5.2 =
|
240 |
+
* Fixed a wysiwyg field bug.
|
241 |
+
|
242 |
+
= 1.5.1 =
|
243 |
+
* Fixed a relation field bug.
|
244 |
+
|
245 |
+
= 1.5.0 =
|
246 |
+
* Update wysiwyg field.
|
247 |
+
|
248 |
+
= 1.4.0 =
|
249 |
+
* refactoring controllers.
|
250 |
+
* Add term custom fields.
|
251 |
+
* Add filter hook smart-cf-is_use_default_when_not_saved
|
252 |
+
* Changed to the default value is used if the value has not been saved. If you want to revert to the previous behavior, return false in smart-cf-is_use_default_when_not_saved.
|
253 |
+
|
254 |
+
= 1.3.2 =
|
255 |
+
* Add preview size setting in the image field.
|
256 |
+
* Add display direction setting in the checkbox and radio field.
|
257 |
+
* Changed the upload field that displayed uploaded to this post first.
|
258 |
+
|
259 |
+
= 1.3.1 =
|
260 |
+
* Fixed a wysiwyg field bug.
|
261 |
+
* Add boolean field.
|
262 |
+
|
263 |
+
= 1.3.0 =
|
264 |
+
* refactoring.
|
265 |
+
* Add profile custom fields.
|
266 |
+
* Add filter hook smart-cf-validate-get-value
|
267 |
+
* Add method SCF::get_user_meta( $user_id, $name = null )
|
268 |
+
* Fixed a revision bug.
|
269 |
+
* Fixed a bug that thumbnail is not displayed correctly in preview.
|
270 |
+
* Fixed a relation field bug.
|
271 |
+
* Changed return value of SCF::get with multiple data in loop.
|
272 |
+
* Changed revision screen format.
|
273 |
+
|
274 |
+
= 1.2.2 =
|
275 |
+
* Fixed a bug that can not get the correct data when the posts use post id filtering.
|
276 |
+
* Changed that original the_content filter does not apply to wysiwyg field.
|
277 |
+
* Add post_id attribute to smart-cf-register-fields.
|
278 |
+
|
279 |
+
= 1.2.1 =
|
280 |
+
* Fixed a bug that post id filtering incorrect.
|
281 |
+
|
282 |
+
= 1.2.0 =
|
283 |
+
* refactoring. A lot of changes in all.
|
284 |
+
* Renewed the Smart_Custom_Fields_Field_Base.
|
285 |
+
* Add filter hook smart-cf-register-fields. If You use this hook, you can define custom fields by the code.
|
286 |
+
* Add action hook smart-cf-before-editor-enqueue-scripts
|
287 |
+
* Add action hook smart-cf-after-editor-enqueue-scripts
|
288 |
+
* Add action hook smart-cf-before-settings-enqueue-scripts
|
289 |
+
* Add action hook smart-cf-after-settings-enqueue-scripts
|
290 |
+
|
291 |
+
= 1.1.3 =
|
292 |
+
* Change method SCF::get_field to SCF::get_value_by_field
|
293 |
+
* Change method SCF::get_sub_field to SCF::get_values_by_group
|
294 |
+
* Add method SCF::get_field
|
295 |
+
* Add method SCF::choices_eol_to_array
|
296 |
+
* remove method Smart_Custom_Fields_Field_Base::get_choices
|
297 |
+
|
298 |
+
= 1.1.2 =
|
299 |
+
* Add action hook smart-cf-fields-loaded
|
300 |
+
|
301 |
+
= 1.1.1 =
|
302 |
+
* UX Improvement of settings page.
|
303 |
+
|
304 |
+
= 1.1.0 =
|
305 |
+
* Add date picker field.
|
306 |
+
|
307 |
+
= 1.0.3 =
|
308 |
+
* Fixed a bug that can't be get the correct data when specify a $post_id attribute to SCF::get(). For example SCF::get( 'key', $post_id )
|
309 |
+
|
310 |
+
= 1.0.2 =
|
311 |
+
* Add color picker field.
|
312 |
+
* Add smart-cf-before-save-post action hook.
|
313 |
+
* Add smart-cf-after-save-post action hook.
|
314 |
+
* Add smart-cf-validate-save-post filter hook.
|
315 |
+
|
316 |
+
= 1.0.1 =
|
317 |
+
* Add display condition by post id.
|
318 |
+
* Fixed bug that is not displayed wysiwyg editor when there are not content editor.
|
319 |
+
* Textarea does not filter the_content filter in SCF::get() and SCF::gets().
|
320 |
+
|
321 |
+
= 1.0.0 =
|
322 |
+
* Initial release.
|
trunk/smart-custom-fields.php
ADDED
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
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: 4.0.0
|
7 |
+
* Author: inc2734
|
8 |
+
* Author URI: https://2inc.org
|
9 |
+
* Created: October 9, 2014
|
10 |
+
* Modified: June 26, 2018
|
11 |
+
* Text Domain: smart-custom-fields
|
12 |
+
* Domain Path: /languages
|
13 |
+
* License: GPLv2 or later
|
14 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
15 |
+
*/
|
16 |
+
class Smart_Custom_Fields {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* __construct
|
20 |
+
*/
|
21 |
+
public function __construct() {
|
22 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/class.config.php';
|
23 |
+
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
|
24 |
+
register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Loading translation files
|
29 |
+
*/
|
30 |
+
public function plugins_loaded() {
|
31 |
+
load_plugin_textdomain (
|
32 |
+
'smart-custom-fields',
|
33 |
+
false,
|
34 |
+
dirname( plugin_basename( __FILE__ ) ) . '/languages'
|
35 |
+
);
|
36 |
+
|
37 |
+
do_action( SCF_Config::PREFIX . 'load' );
|
38 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/models/class.meta.php';
|
39 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/models/class.setting.php';
|
40 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/models/class.group.php';
|
41 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/models/class.abstract-field-base.php';
|
42 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/models/class.revisions.php';
|
43 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/models/class.ajax.php';
|
44 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/models/class.options-page.php';
|
45 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/models/class.cache.php';
|
46 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/class.scf.php';
|
47 |
+
new Smart_Custom_Fields_Revisions();
|
48 |
+
|
49 |
+
foreach ( glob( plugin_dir_path( __FILE__ ) . 'classes/fields/*.php' ) as $form_item ) {
|
50 |
+
include_once $form_item;
|
51 |
+
$basename = basename( $form_item, '.php' );
|
52 |
+
$classname = preg_replace( '/^class\.field\-(.+)$/', 'Smart_Custom_Fields_Field_$1', $basename );
|
53 |
+
$classname = str_replace( '-', '_', $classname );
|
54 |
+
if ( class_exists( $classname ) ) {
|
55 |
+
new $classname();
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) );
|
60 |
+
add_action( 'init' , array( $this, 'register_post_type' ) );
|
61 |
+
add_action( 'init' , array( $this, 'ajax_request' ) );
|
62 |
+
add_action( 'admin_menu' , array( $this, 'admin_menu' ) );
|
63 |
+
add_action( 'current_screen' , array( $this, 'current_screen' ) );
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* The action hook provides in after_setup_themeto be able to add fields
|
68 |
+
* from themes not only plugins.
|
69 |
+
*/
|
70 |
+
public function after_setup_theme() {
|
71 |
+
do_action( SCF_Config::PREFIX . 'fields-loaded' );
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Uninstall proccesses
|
76 |
+
*/
|
77 |
+
public static function uninstall() {
|
78 |
+
$cf_posts = get_posts( array(
|
79 |
+
'post_type' => SCF_Config::NAME,
|
80 |
+
'posts_per_page' => -1,
|
81 |
+
'post_status' => 'any',
|
82 |
+
) );
|
83 |
+
foreach ( $cf_posts as $post ) {
|
84 |
+
wp_delete_post( $post->ID, true );
|
85 |
+
}
|
86 |
+
delete_post_meta_by_key( SCF_Config::PREFIX . 'repeat-multiple-data' );
|
87 |
+
|
88 |
+
// option の smart-cf-xxx を削除
|
89 |
+
global $wpdb;
|
90 |
+
$wpdb->query(
|
91 |
+
$wpdb->prepare(
|
92 |
+
"
|
93 |
+
DELETE FROM $wpdb->options
|
94 |
+
WHERE option_name LIKE %s
|
95 |
+
",
|
96 |
+
SCF_Config::PREFIX . '%'
|
97 |
+
)
|
98 |
+
);
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Run management screens
|
103 |
+
*
|
104 |
+
* @param WP_Screen $screen
|
105 |
+
*/
|
106 |
+
public function current_screen( $screen ) {
|
107 |
+
// 一覧画面
|
108 |
+
if ( $screen->id === 'edit-' . SCF_Config::NAME ) {
|
109 |
+
}
|
110 |
+
// 新規作成・編集画面
|
111 |
+
elseif ( $screen->id === SCF_Config::NAME ) {
|
112 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.settings.php';
|
113 |
+
new Smart_Custom_Fields_Controller_Settings();
|
114 |
+
}
|
115 |
+
// その他の新規作成・編集画面
|
116 |
+
elseif ( in_array( $screen->id, get_post_types() ) ) {
|
117 |
+
$post_id = $this->get_post_id_in_admin();
|
118 |
+
if ( SCF::get_settings( SCF::generate_post_object( $post_id, $screen->id ) ) ) {
|
119 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
|
120 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.editor.php';
|
121 |
+
new Smart_Custom_Fields_Revisions();
|
122 |
+
new Smart_Custom_Fields_Controller_Editor();
|
123 |
+
}
|
124 |
+
}
|
125 |
+
// プロフィール編集画面
|
126 |
+
elseif ( in_array( $screen->id, array( 'profile', 'user-edit' ) ) ) {
|
127 |
+
$user_id = $this->get_user_id_in_admin();
|
128 |
+
if ( SCF::get_settings( get_userdata( $user_id ) ) ) {
|
129 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
|
130 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.profile.php';
|
131 |
+
new Smart_Custom_Fields_Controller_Profile();
|
132 |
+
}
|
133 |
+
}
|
134 |
+
// タグ、カテゴリー、タクソノミー
|
135 |
+
elseif ( $screen->taxonomy ) {
|
136 |
+
$term_id = $this->get_term_id_in_admin();
|
137 |
+
if ( $term_id ) {
|
138 |
+
$term = get_term( $term_id, $screen->taxonomy );
|
139 |
+
if ( SCF::get_settings( $term ) ) {
|
140 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
|
141 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.taxonomy.php';
|
142 |
+
new Smart_Custom_Fields_Controller_Taxonomy();
|
143 |
+
}
|
144 |
+
}
|
145 |
+
}
|
146 |
+
// オプションページ
|
147 |
+
else {
|
148 |
+
$menu_slug = preg_replace( '/^toplevel_page_(.+)$/', '$1', $screen->id );
|
149 |
+
$options_pages = SCF::get_options_pages();
|
150 |
+
|
151 |
+
if ( array_key_exists( $menu_slug, $options_pages ) ) {
|
152 |
+
$Option = SCF::generate_option_object( $menu_slug );
|
153 |
+
if ( SCF::get_settings( $Option ) ) {
|
154 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
|
155 |
+
require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.option.php';
|
156 |
+
new Smart_Custom_Fields_Controller_Option();
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Registering custom post type.
|
164 |
+
* Run the menu display in a different method.
|
165 |
+
*/
|
166 |
+
public function register_post_type() {
|
167 |
+
$labels = array(
|
168 |
+
'name' => __( 'Smart Custom Fields', 'smart-custom-fields' ),
|
169 |
+
'menu_name' => __( 'Smart Custom Fields', 'smart-custom-fields' ),
|
170 |
+
'name_admin_bar' => __( 'Smart Custom Fields', 'smart-custom-fields' ),
|
171 |
+
'add_new' => __( 'Add New', 'smart-custom-fields' ),
|
172 |
+
'add_new_item' => __( 'Add New', 'smart-custom-fields' ),
|
173 |
+
'new_item' => __( 'New Field', 'smart-custom-fields' ),
|
174 |
+
'edit_item' => __( 'Edit Field', 'smart-custom-fields' ),
|
175 |
+
'view_item' => __( 'View Field', 'smart-custom-fields' ),
|
176 |
+
'all_items' => __( 'All Fields', 'smart-custom-fields' ),
|
177 |
+
'search_items' => __( 'Search Fields', 'smart-custom-fields' ),
|
178 |
+
'parent_item_colon' => __( 'Parent Fields:', 'smart-custom-fields' ),
|
179 |
+
'not_found' => __( 'No Fields found.', 'smart-custom-fields' ),
|
180 |
+
'not_found_in_trash' => __( 'No Fields found in Trash.', 'smart-custom-fields' )
|
181 |
+
);
|
182 |
+
register_post_type(
|
183 |
+
SCF_Config::NAME,
|
184 |
+
array(
|
185 |
+
'label' => 'Smart Custom Fields',
|
186 |
+
'labels' => $labels,
|
187 |
+
'public' => false,
|
188 |
+
'show_ui' => true,
|
189 |
+
'capability_type' => 'page',
|
190 |
+
'supports' => array( 'title', 'page-attributes' ),
|
191 |
+
'show_in_menu' => false,
|
192 |
+
)
|
193 |
+
);
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Hooking the process that it want to fire when the ajax request.
|
198 |
+
*/
|
199 |
+
public function ajax_request() {
|
200 |
+
$Ajax = new Smart_Custom_Fields_Ajax();
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Adding menus in management screen.
|
205 |
+
*/
|
206 |
+
public function admin_menu() {
|
207 |
+
add_menu_page(
|
208 |
+
'Smart Custom Fields',
|
209 |
+
'Smart Custom Fields',
|
210 |
+
'manage_options',
|
211 |
+
'edit.php?post_type=' . SCF_Config::NAME,
|
212 |
+
false,
|
213 |
+
false,
|
214 |
+
'80.026'
|
215 |
+
);
|
216 |
+
add_submenu_page(
|
217 |
+
'edit.php?post_type=' . SCF_Config::NAME,
|
218 |
+
__( 'Add New', 'smart-custom-fields' ),
|
219 |
+
__( 'Add New', 'smart-custom-fields' ),
|
220 |
+
'manage_options',
|
221 |
+
'post-new.php?post_type=' . SCF_Config::NAME
|
222 |
+
);
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Getting the post ID in post editing page.
|
227 |
+
*
|
228 |
+
* @return int
|
229 |
+
*/
|
230 |
+
protected function get_post_id_in_admin() {
|
231 |
+
$post_id = false;
|
232 |
+
if ( !empty( $_GET['post'] ) ) {
|
233 |
+
$post_id = $_GET['post'];
|
234 |
+
} elseif ( !empty( $_POST['post_ID'] ) ) {
|
235 |
+
$post_id = $_POST['post_ID'];
|
236 |
+
}
|
237 |
+
return $post_id;
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Getting the user ID in profile and user editing pages.
|
242 |
+
*
|
243 |
+
* @return int
|
244 |
+
*/
|
245 |
+
protected function get_user_id_in_admin() {
|
246 |
+
$screen = get_current_screen();
|
247 |
+
$user_id = false;
|
248 |
+
if ( !empty( $_GET['user_id'] ) ) {
|
249 |
+
$user_id = $_GET['user_id'];
|
250 |
+
} elseif ( !empty( $_POST['user_id'] ) ) {
|
251 |
+
$user_id = $_POST['user_id'];
|
252 |
+
} elseif ( $screen->id === 'profile' ) {
|
253 |
+
$current_user = wp_get_current_user();
|
254 |
+
$user_id = $current_user->ID;
|
255 |
+
}
|
256 |
+
return $user_id;
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Getting the term ID in term editing page.
|
261 |
+
*
|
262 |
+
* @return int
|
263 |
+
*/
|
264 |
+
protected function get_term_id_in_admin() {
|
265 |
+
$term_id = false;
|
266 |
+
if ( !empty( $_GET['tag_ID'] ) ) {
|
267 |
+
$term_id = $_GET['tag_ID'];
|
268 |
+
} elseif ( !empty( $_POST['tag_ID'] ) ) {
|
269 |
+
$term_id = $_POST['tag_ID'];
|
270 |
+
}
|
271 |
+
return $term_id;
|
272 |
+
}
|
273 |
+
}
|
274 |
+
new Smart_Custom_Fields();
|