Smart Custom Fields - Version 3.1.6

Version Description

  • Set any on related post status. #60 (by @mayukojpn)
  • Changed that file names can be known when uploading files. #58 (by @shodoi)
Download this release

Release Info

Developer inc2734
Plugin Icon wp plugin Smart Custom Fields
Version 3.1.6
Comparing to
See all releases

Code changes from version 3.1.5 to 3.1.6

classes/fields/class.field-file.php CHANGED
@@ -75,10 +75,16 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
75
  }
76
 
77
  if ( $image_src && ! is_array( $image_src ) ) {
 
 
 
 
 
78
  $image = sprintf(
79
- '<a href="%s" target="_blank"><img src="%s" alt="" /></a>%s',
80
  wp_get_attachment_url( $value ),
81
  esc_url( $image_src ),
 
82
  $btn_remove
83
  );
84
  $hide_class = '';
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 = '';
classes/fields/class.field-related-posts.php CHANGED
@@ -82,6 +82,7 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
82
  'order' => 'ASC',
83
  'orderby' => 'ID',
84
  'posts_per_page' => -1,
 
85
  );
86
 
87
  if ( isset( $_POST['click_count'] ) ) {
@@ -137,6 +138,7 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
137
  'order' => 'ASC',
138
  'orderby' => 'ID',
139
  'posts_per_page' => $posts_per_page,
 
140
  ) );
141
  $choices_li = array();
142
  foreach ( $choices_posts as $_post ) {
@@ -144,16 +146,18 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
144
  if ( empty( $post_title ) ) {
145
  $post_title = '&nbsp;';
146
  }
147
- $choices_li[] = sprintf( '<li data-id="%d">%s</li>', $_post->ID, $post_title );
 
 
 
 
 
148
  }
149
 
150
  // selected
151
  $selected_posts = array();
152
  if ( !empty( $value ) && is_array( $value ) ) {
153
  foreach ( $value as $post_id ) {
154
- if ( get_post_status( $post_id ) !== 'publish' ) {
155
- continue;
156
- }
157
  $post_title = get_the_title( $post_id );
158
  if ( empty( $post_title ) ) {
159
  $post_title = '&nbsp;';
@@ -165,8 +169,9 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
165
  $hidden = array();
166
  foreach ( $selected_posts as $post_id => $post_title ) {
167
  $selected_li[] = sprintf(
168
- '<li data-id="%d"><span class="%s"></span>%s<span class="relation-remove">-</li></li>',
169
  $post_id,
 
170
  esc_attr( SCF_Config::PREFIX . 'icon-handle dashicons dashicons-menu' ),
171
  $post_title
172
  );
@@ -282,9 +287,6 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
282
  if ( $field_type === $this->get_attribute( 'type' ) ) {
283
  $validated_value = array();
284
  foreach ( $value as $post_id ) {
285
- if ( get_post_status( $post_id ) !== 'publish' ) {
286
- continue;
287
- }
288
  $validated_value[] = $post_id;
289
  }
290
  $value = $validated_value;
82
  'order' => 'ASC',
83
  'orderby' => 'ID',
84
  'posts_per_page' => -1,
85
+ 'post_status' => 'any',
86
  );
87
 
88
  if ( isset( $_POST['click_count'] ) ) {
138
  'order' => 'ASC',
139
  'orderby' => 'ID',
140
  'posts_per_page' => $posts_per_page,
141
+ 'post_status' => 'any',
142
  ) );
143
  $choices_li = array();
144
  foreach ( $choices_posts as $_post ) {
146
  if ( empty( $post_title ) ) {
147
  $post_title = '&nbsp;';
148
  }
149
+ $choices_li[] = sprintf(
150
+ '<li data-id="%d" data-status="%s">%s</li>',
151
+ $_post->ID,
152
+ $_post->post_status,
153
+ $post_title
154
+ );
155
  }
156
 
157
  // selected
158
  $selected_posts = array();
159
  if ( !empty( $value ) && is_array( $value ) ) {
160
  foreach ( $value as $post_id ) {
 
 
 
161
  $post_title = get_the_title( $post_id );
162
  if ( empty( $post_title ) ) {
163
  $post_title = '&nbsp;';
169
  $hidden = array();
170
  foreach ( $selected_posts as $post_id => $post_title ) {
171
  $selected_li[] = sprintf(
172
+ '<li data-id="%d" data-status="%s"><span class="%s"></span>%s<span class="relation-remove">-</li></li>',
173
  $post_id,
174
+ get_post_status( $post_id ),
175
  esc_attr( SCF_Config::PREFIX . 'icon-handle dashicons dashicons-menu' ),
176
  $post_title
177
  );
287
  if ( $field_type === $this->get_attribute( 'type' ) ) {
288
  $validated_value = array();
289
  foreach ( $value as $post_id ) {
 
 
 
290
  $validated_value[] = $post_id;
291
  }
292
  $value = $validated_value;
css/editor.css CHANGED
@@ -108,11 +108,32 @@
108
  .smart-cf-meta-box-table .smart-cf-relation-right ul li {
109
  background: #fff;
110
  border-bottom: #eee solid 1px;
111
- color: #0074a2;
112
  margin: 0;
113
  padding: 5px 10px;
114
  position: relative;
115
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  .smart-cf-meta-box-table .smart-cf-relation-left {
117
  float: left;
118
  width: 47%;
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%;
js/editor-relation-post-types.js CHANGED
@@ -80,6 +80,7 @@ jQuery( function( $ ) {
80
  table.find( '.smart-cf-relation-children-select ul' ).append(
81
  $( '<li />' )
82
  .attr( 'data-id', this.ID )
 
83
  .text( this.post_title )
84
  );
85
  } );
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
  } );
js/editor.js CHANGED
@@ -156,9 +156,9 @@ jQuery( 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( 'img' ).remove();
160
  image_area.prepend(
161
- '<a href="' + file.toJSON().url + '" target="_blank"><img src="' + file.toJSON().icon + '" /></a>'
162
  );
163
  image_area.removeClass( 'hide' );
164
  upload_button.parent().find( 'input[type="hidden"]' ).val( file.toJSON().id );
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 );
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: inc2734, toro_unit, mimosafa, hideokamoto, hisako-isaka, kurudrive
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.8.2
7
- Stable tag: 3.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -127,8 +127,12 @@ You can translate this plugin into your language by using [GlotPress](https://tr
127
 
128
  == Changelog ==
129
 
 
 
 
 
130
  = 3.1.5 =
131
- * Fixed a bug that disappeared layout when introducing description in relation field. #56 (by [@mayukojpn ](https://github.com/mayukojpn ))
132
  * Update item delete button style in relation field.
133
  * Fix bug when using smart-cf-register-fields hook.
134
 
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.1
7
+ Stable tag: 3.1.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
127
 
128
  == Changelog ==
129
 
130
+ = 3.1.6 =
131
+ * Set any on related post status. #60 (by [@mayukojpn](https://github.com/mayukojpn))
132
+ * Changed that file names can be known when uploading files. #58 (by [@shodoi](https://github.com/shodoi))
133
+
134
  = 3.1.5 =
135
+ * Fixed a bug that disappeared layout when introducing description in relation field. #56 (by [@mayukojpn](https://github.com/mayukojpn))
136
  * Update item delete button style in relation field.
137
  * Fix bug when using smart-cf-register-fields hook.
138
 
smart-custom-fields.php CHANGED
@@ -3,11 +3,11 @@
3
  * Plugin name: Smart Custom Fields
4
  * Plugin URI: https://github.com/inc2734/smart-custom-fields/
5
  * Description: Smart Custom Fields is a simple plugin that management custom fields.
6
- * Version: 3.1.5
7
  * Author: inc2734
8
- * Author URI: http://2inc.org
9
  * Created: October 9, 2014
10
- * Modified: October 24, 2017
11
  * Text Domain: smart-custom-fields
12
  * Domain Path: /languages
13
  * License: GPLv2 or later
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: 3.1.6
7
  * Author: inc2734
8
+ * Author URI: https://2inc.org
9
  * Created: October 9, 2014
10
+ * Modified: January 9, 2018
11
  * Text Domain: smart-custom-fields
12
  * Domain Path: /languages
13
  * License: GPLv2 or later