Version Description
- Code cleaning.
Download this release
Release Info
Developer | Hiroaki Miyashita |
Plugin | Custom Field Template |
Version | 2.0.8 |
Comparing to | |
See all releases |
Code changes from version 2.0.7 to 2.0.8
- custom-field-template.php +29 -28
- readme.txt +4 -1
custom-field-template.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Custom Field Template
|
|
4 |
Plugin URI: http://wpgogo.com/development/custom-field-template.html
|
5 |
Description: This plugin adds the default custom fields on the Write Post/Page.
|
6 |
Author: Hiroaki Miyashita
|
7 |
-
Version: 2.0.
|
8 |
Author URI: http://wpgogo.com/
|
9 |
*/
|
10 |
|
@@ -2558,7 +2558,7 @@ jQuery(this).addClass("closed");
|
|
2558 |
list($out_all,$out_key,$out_value) = $this->make_radio( $title, $parentSN, $data );
|
2559 |
}
|
2560 |
else if( $data['type'] == 'select' ) {
|
2561 |
-
$data['values'] = explode( '#', $data['value'] );
|
2562 |
if ( isset($data['valueLabel']) ) $data['valueLabels'] = explode( '#', $data['valueLabel'] );
|
2563 |
list($out_all,$out_key,$out_value) = $this->make_select( $title, $parentSN, $data );
|
2564 |
}
|
@@ -2680,7 +2680,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
2680 |
$categories = explode(',', $val['category']);
|
2681 |
$categories = array_filter($categories);
|
2682 |
array_walk( $categories, create_function('&$v', '$v = trim($v);') );
|
2683 |
-
$query = $wpdb->prepare("SELECT * FROM `".$wpdb->prefix."term_taxonomy` WHERE term_id IN ("
|
2684 |
$result = $wpdb->get_results($query, ARRAY_A);
|
2685 |
$category_taxonomy = array();
|
2686 |
if ( !empty($result) && is_array($result) ) :
|
@@ -3513,13 +3513,13 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
3513 |
$replace[0] = $val;
|
3514 |
|
3515 |
$search = array();
|
3516 |
-
if($val['searchType']) eval('$search["type"] =' . stripslashes($val['searchType']));
|
3517 |
-
if($val['searchValue']) eval('$search["value"] =' . stripslashes($val['searchValue']));
|
3518 |
-
if($val['searchOperator']) eval('$search["operator"] =' . stripslashes($val['searchOperator']));
|
3519 |
-
if($val['searchValueLabel']) eval('$search["valueLabel"] =' . stripslashes($val['searchValueLabel']));
|
3520 |
-
if($val['searchDefault']) eval('$search["default"] =' . stripslashes($val['searchDefault']));
|
3521 |
-
if($val['searchClass']) eval('$search["class"] =' . stripslashes($val['searchClass']));
|
3522 |
-
if($val['searchSelectLabel']) eval('$search["selectLabel"] =' . stripslashes($val['searchSelectLabel']));
|
3523 |
|
3524 |
foreach ( $search as $skey => $sval ) :
|
3525 |
$j = 1;
|
@@ -3622,13 +3622,13 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
3622 |
endif;
|
3623 |
break;
|
3624 |
case 'select':
|
3625 |
-
if ( $rval['class'] ) $class = ' class="' . $rval['class'] . '"';
|
3626 |
$values = explode( '#', $rval['value'] );
|
3627 |
-
$valueLabel = explode( '#', $rval['valueLabel'] );
|
3628 |
-
$default = explode( '#', $rval['default'] );
|
3629 |
-
$selectLabel= $rval['selectLabel'];
|
3630 |
|
3631 |
-
if ( is_numeric($rval['searchCode']) ) :
|
3632 |
eval(stripcslashes($options['php'][$rval['searchCode']]));
|
3633 |
endif;
|
3634 |
$replace_val[$rkey] .= '<select name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]"' . $class . '>';
|
@@ -3784,9 +3784,9 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
3784 |
foreach ( $field_val as $key => $val ) :
|
3785 |
$replace[$key] = $val;
|
3786 |
$search = array();
|
3787 |
-
if($val['searchType']) eval('$search["type"] =' . stripslashes($val['searchType']));
|
3788 |
-
if($val['searchValue']) eval('$search["value"] =' . stripslashes($val['searchValue']));
|
3789 |
-
if($val['searchOperator']) eval('$search["operator"] =' . stripslashes($val['searchOperator']));
|
3790 |
|
3791 |
foreach ( $search as $skey => $sval ) :
|
3792 |
$j = 1;
|
@@ -3814,6 +3814,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
3814 |
if ( $replace[$key][$key2]['type'] == 'checkbox' || !$replace[$key][$key2]['type'] ) $where .= ' OR ';
|
3815 |
else $where .= ' AND ';
|
3816 |
endif;
|
|
|
3817 |
switch( $replace[$key][$key2]['operator'] ) :
|
3818 |
case '<=' :
|
3819 |
case '>=' :
|
@@ -3823,13 +3824,13 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
3823 |
case '<>' :
|
3824 |
case '<=>':
|
3825 |
if ( is_numeric($val3) ) :
|
3826 |
-
$where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_key = %s AND `" . $wpdb->postmeta . "`.meta_value " . $replace[$key][$key2]['operator'] . " %d)
|
3827 |
else :
|
3828 |
-
$where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_key = %s AND `" . $wpdb->postmeta . "`.meta_value " . $replace[$key][$key2]['operator'] . " %s)
|
3829 |
endif;
|
3830 |
break;
|
3831 |
default :
|
3832 |
-
$where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_key = %s AND `" . $wpdb->postmeta . "`.meta_value LIKE %s)
|
3833 |
break;
|
3834 |
endswitch;
|
3835 |
$ch++;
|
@@ -3853,7 +3854,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
3853 |
foreach ( $s as $v ) :
|
3854 |
if ( !empty($v) ) :
|
3855 |
if ( $i>0 ) $where .= ' AND ';
|
3856 |
-
$where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_value LIKE %s)
|
3857 |
$i++;
|
3858 |
endif;
|
3859 |
endforeach;
|
@@ -3869,7 +3870,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
3869 |
endif;
|
3870 |
$where .= " AND `" . $wpdb->posts . "`.post_type = 'post'";
|
3871 |
endif;
|
3872 |
-
if ( is_array($_REQUEST['cftcategory_not_in']) ) :
|
3873 |
$ids = get_objects_in_term($_REQUEST['cftcategory_not_in'], 'category');
|
3874 |
if ( is_array($ids) && count($ids) > 0 ) :
|
3875 |
$in_posts = "'" . implode("', '", $ids) . "'";
|
@@ -3877,16 +3878,16 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
3877 |
endif;
|
3878 |
endif;
|
3879 |
|
3880 |
-
if ( $_REQUEST['post_type'] ) :
|
3881 |
$where .= $wpdb->prepare(" AND `" . $wpdb->posts . "`.post_type = %s", trim($_REQUEST['post_type']));
|
3882 |
endif;
|
3883 |
|
3884 |
-
if ( $_REQUEST['no_is_search'] ) :
|
3885 |
$where .= " AND `".$wpdb->posts."`.post_status = 'publish'";
|
3886 |
else :
|
3887 |
$where .= " AND `".$wpdb->posts."`.post_status = 'publish' GROUP BY `".$wpdb->posts."`.ID";
|
3888 |
endif;
|
3889 |
-
|
3890 |
return $where;
|
3891 |
}
|
3892 |
|
@@ -3907,13 +3908,13 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
3907 |
if ( empty($_REQUEST['order']) || ((strtoupper($_REQUEST['order']) != 'ASC') && (strtoupper($_REQUEST['order']) != 'DESC')) )
|
3908 |
$_REQUEST['order'] = 'DESC';
|
3909 |
|
3910 |
-
if ( $_REQUEST['orderby'] ) :
|
3911 |
if ( in_array($_REQUEST['orderby'], array('post_author', 'post_date', 'post_title', 'post_modified', 'menu_order', 'post_parent', 'ID')) ):
|
3912 |
$sql = "`" . $wpdb->posts . "`." . $_REQUEST['orderby'] . " " . $_REQUEST['order'];
|
3913 |
elseif ( $_REQUEST['orderby'] == 'rand' ):
|
3914 |
$sql = "RAND()";
|
3915 |
else:
|
3916 |
-
if ( in_array($_REQUEST['cast'], array('binary', 'char', 'date', 'datetime', 'signed', 'time', 'unsigned')) ) :
|
3917 |
$sql = " CAST(meta.meta_value AS " . $_REQUEST['cast'] . ") " . $_REQUEST['order'];
|
3918 |
else :
|
3919 |
$sql = " meta.meta_value " . $_REQUEST['order'];
|
4 |
Plugin URI: http://wpgogo.com/development/custom-field-template.html
|
5 |
Description: This plugin adds the default custom fields on the Write Post/Page.
|
6 |
Author: Hiroaki Miyashita
|
7 |
+
Version: 2.0.8
|
8 |
Author URI: http://wpgogo.com/
|
9 |
*/
|
10 |
|
2558 |
list($out_all,$out_key,$out_value) = $this->make_radio( $title, $parentSN, $data );
|
2559 |
}
|
2560 |
else if( $data['type'] == 'select' ) {
|
2561 |
+
if ( isset($data['value']) ) $data['values'] = explode( '#', $data['value'] );
|
2562 |
if ( isset($data['valueLabel']) ) $data['valueLabels'] = explode( '#', $data['valueLabel'] );
|
2563 |
list($out_all,$out_key,$out_value) = $this->make_select( $title, $parentSN, $data );
|
2564 |
}
|
2680 |
$categories = explode(',', $val['category']);
|
2681 |
$categories = array_filter($categories);
|
2682 |
array_walk( $categories, create_function('&$v', '$v = trim($v);') );
|
2683 |
+
$query = $wpdb->prepare("SELECT * FROM `".$wpdb->prefix."term_taxonomy` WHERE term_id IN (%s)", $val['category']);
|
2684 |
$result = $wpdb->get_results($query, ARRAY_A);
|
2685 |
$category_taxonomy = array();
|
2686 |
if ( !empty($result) && is_array($result) ) :
|
3513 |
$replace[0] = $val;
|
3514 |
|
3515 |
$search = array();
|
3516 |
+
if( isset($val['searchType']) ) eval('$search["type"] =' . stripslashes($val['searchType']));
|
3517 |
+
if( isset($val['searchValue']) ) eval('$search["value"] =' . stripslashes($val['searchValue']));
|
3518 |
+
if( isset($val['searchOperator']) ) eval('$search["operator"] =' . stripslashes($val['searchOperator']));
|
3519 |
+
if( isset($val['searchValueLabel']) ) eval('$search["valueLabel"] =' . stripslashes($val['searchValueLabel']));
|
3520 |
+
if( isset($val['searchDefault']) ) eval('$search["default"] =' . stripslashes($val['searchDefault']));
|
3521 |
+
if( isset($val['searchClass']) ) eval('$search["class"] =' . stripslashes($val['searchClass']));
|
3522 |
+
if( isset($val['searchSelectLabel']) ) eval('$search["selectLabel"] =' . stripslashes($val['searchSelectLabel']));
|
3523 |
|
3524 |
foreach ( $search as $skey => $sval ) :
|
3525 |
$j = 1;
|
3622 |
endif;
|
3623 |
break;
|
3624 |
case 'select':
|
3625 |
+
if ( isset($rval['class']) ) $class = ' class="' . $rval['class'] . '"';
|
3626 |
$values = explode( '#', $rval['value'] );
|
3627 |
+
$valueLabel = isset($rval['valueLabel']) ? explode( '#', $rval['valueLabel'] ) : array();
|
3628 |
+
$default = isset($rval['default']) ? explode( '#', $rval['default'] ) : array();
|
3629 |
+
$selectLabel= isset($rval['selectLabel']) ? $rval['selectLabel'] : '';
|
3630 |
|
3631 |
+
if ( isset($rval['searchCode']) && is_numeric($rval['searchCode']) ) :
|
3632 |
eval(stripcslashes($options['php'][$rval['searchCode']]));
|
3633 |
endif;
|
3634 |
$replace_val[$rkey] .= '<select name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]"' . $class . '>';
|
3784 |
foreach ( $field_val as $key => $val ) :
|
3785 |
$replace[$key] = $val;
|
3786 |
$search = array();
|
3787 |
+
if( isset($val['searchType']) ) eval('$search["type"] =' . stripslashes($val['searchType']));
|
3788 |
+
if( isset($val['searchValue']) ) eval('$search["value"] =' . stripslashes($val['searchValue']));
|
3789 |
+
if( isset($val['searchOperator']) ) eval('$search["operator"] =' . stripslashes($val['searchOperator']));
|
3790 |
|
3791 |
foreach ( $search as $skey => $sval ) :
|
3792 |
$j = 1;
|
3814 |
if ( $replace[$key][$key2]['type'] == 'checkbox' || !$replace[$key][$key2]['type'] ) $where .= ' OR ';
|
3815 |
else $where .= ' AND ';
|
3816 |
endif;
|
3817 |
+
if ( !isset($replace[$key][$key2]['operator']) ) $replace[$key][$key2]['operator'] = '';
|
3818 |
switch( $replace[$key][$key2]['operator'] ) :
|
3819 |
case '<=' :
|
3820 |
case '>=' :
|
3824 |
case '<>' :
|
3825 |
case '<=>':
|
3826 |
if ( is_numeric($val3) ) :
|
3827 |
+
$where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_key = %s AND `" . $wpdb->postmeta . "`.meta_value " . $replace[$key][$key2]['operator'] . " %d) ) ", $key, trim($val3));
|
3828 |
else :
|
3829 |
+
$where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_key = %s AND `" . $wpdb->postmeta . "`.meta_value " . $replace[$key][$key2]['operator'] . " %s) ) ", $key, trim($val3));
|
3830 |
endif;
|
3831 |
break;
|
3832 |
default :
|
3833 |
+
$where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_key = %s AND `" . $wpdb->postmeta . "`.meta_value LIKE %s) ) ", $key, '%'.trim($val3).'%');
|
3834 |
break;
|
3835 |
endswitch;
|
3836 |
$ch++;
|
3854 |
foreach ( $s as $v ) :
|
3855 |
if ( !empty($v) ) :
|
3856 |
if ( $i>0 ) $where .= ' AND ';
|
3857 |
+
$where .= $wpdb->prepare(" ID IN (SELECT `" . $wpdb->postmeta . "`.post_id FROM `" . $wpdb->postmeta . "` WHERE (`" . $wpdb->postmeta . "`.meta_value LIKE %s) ) ", '%'.trim($v).'%');
|
3858 |
$i++;
|
3859 |
endif;
|
3860 |
endforeach;
|
3870 |
endif;
|
3871 |
$where .= " AND `" . $wpdb->posts . "`.post_type = 'post'";
|
3872 |
endif;
|
3873 |
+
if ( isset($_REQUEST['cftcategory_not_in']) && is_array($_REQUEST['cftcategory_not_in']) ) :
|
3874 |
$ids = get_objects_in_term($_REQUEST['cftcategory_not_in'], 'category');
|
3875 |
if ( is_array($ids) && count($ids) > 0 ) :
|
3876 |
$in_posts = "'" . implode("', '", $ids) . "'";
|
3878 |
endif;
|
3879 |
endif;
|
3880 |
|
3881 |
+
if ( !empty($_REQUEST['post_type']) ) :
|
3882 |
$where .= $wpdb->prepare(" AND `" . $wpdb->posts . "`.post_type = %s", trim($_REQUEST['post_type']));
|
3883 |
endif;
|
3884 |
|
3885 |
+
if ( !empty($_REQUEST['no_is_search']) ) :
|
3886 |
$where .= " AND `".$wpdb->posts."`.post_status = 'publish'";
|
3887 |
else :
|
3888 |
$where .= " AND `".$wpdb->posts."`.post_status = 'publish' GROUP BY `".$wpdb->posts."`.ID";
|
3889 |
endif;
|
3890 |
+
|
3891 |
return $where;
|
3892 |
}
|
3893 |
|
3908 |
if ( empty($_REQUEST['order']) || ((strtoupper($_REQUEST['order']) != 'ASC') && (strtoupper($_REQUEST['order']) != 'DESC')) )
|
3909 |
$_REQUEST['order'] = 'DESC';
|
3910 |
|
3911 |
+
if ( !empty($_REQUEST['orderby']) ) :
|
3912 |
if ( in_array($_REQUEST['orderby'], array('post_author', 'post_date', 'post_title', 'post_modified', 'menu_order', 'post_parent', 'ID')) ):
|
3913 |
$sql = "`" . $wpdb->posts . "`." . $_REQUEST['orderby'] . " " . $_REQUEST['order'];
|
3914 |
elseif ( $_REQUEST['orderby'] == 'rand' ):
|
3915 |
$sql = "RAND()";
|
3916 |
else:
|
3917 |
+
if ( !empty($_REQUEST['cast']) && in_array($_REQUEST['cast'], array('binary', 'char', 'date', 'datetime', 'signed', 'time', 'unsigned')) ) :
|
3918 |
$sql = " CAST(meta.meta_value AS " . $_REQUEST['cast'] . ") " . $_REQUEST['order'];
|
3919 |
else :
|
3920 |
$sql = " meta.meta_value " . $_REQUEST['order'];
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wpgogo.com/development/custom-field-template.html
|
|
4 |
Tags: custom field, custom fields, custom, fields, field, template, meta, custom field template, custom post type
|
5 |
Requires at least: 2.1
|
6 |
Tested up to: 3.5
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
The Custom Field Template plugin extends the functionality of custom fields.
|
@@ -111,6 +111,9 @@ See the default template and modify it.
|
|
111 |
|
112 |
== Changelog ==
|
113 |
|
|
|
|
|
|
|
114 |
= 2.0.7 =
|
115 |
* Bugfix: media insert.
|
116 |
|
4 |
Tags: custom field, custom fields, custom, fields, field, template, meta, custom field template, custom post type
|
5 |
Requires at least: 2.1
|
6 |
Tested up to: 3.5
|
7 |
+
Stable tag: 2.0.8
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
The Custom Field Template plugin extends the functionality of custom fields.
|
111 |
|
112 |
== Changelog ==
|
113 |
|
114 |
+
= 2.0.8 =
|
115 |
+
* Code cleaning.
|
116 |
+
|
117 |
= 2.0.7 =
|
118 |
* Bugfix: media insert.
|
119 |
|