Custom Field Template - Version 0.7.2

Version Description

Download this release

Release Info

Developer Hiroaki Miyashita
Plugin Icon 128x128 Custom Field Template
Version 0.7.2
Comparing to
See all releases

Code changes from version 0.7.1 to 0.7.2

Files changed (2) hide show
  1. custom-field-template.php +38 -15
  2. readme.txt +1 -1
custom-field-template.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Custom Field Template
4
  Plugin URI: http://wordpressgogo.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: 0.7.1
8
  Author URI: http://wordpressgogo.com/
9
  */
10
 
@@ -280,7 +280,8 @@ mediaButton = true';
280
  <h3><?php _e('PHP CODE (Experimental Option)', 'custom-field-template'); ?></h3>
281
  <div class="inside">
282
  <form method="post" onsubmit="return confirm('<?php _e('Are you sure to save PHP codes? Please do it at your own risk.', 'custom-field-template'); ?>');">
283
- <p><?php _e('This option is available only for `radio` and `select` types. You must set $values as an array.', 'custom-field-template'); ?><br />ex. $values = array('dog', 'cat', 'monkey'); $default = 'cat';</p>
 
284
  <table class="form-table" style="margin-bottom:5px;">
285
  <tbody>
286
  <?php
@@ -463,12 +464,12 @@ jQuery(this).addClass("closed");
463
  return $out;
464
  }
465
 
466
- function make_checkbox( $name, $sid, $value, $checked, $hideKey, $label ) {
467
  $options = $this->get_custom_field_template_data();
468
 
469
  $title = $name;
470
  $name = $this->sanitize_name( $name );
471
-
472
  if ( !$value ) $value = "true";
473
 
474
  if( isset( $_REQUEST[ 'post' ] ) && $_REQUEST[ 'post' ] > 0 ) {
@@ -696,7 +697,7 @@ EOF;
696
  }
697
  else if( $data[$i]['type'] == 'checkbox' ) {
698
  $out .=
699
- $this->make_checkbox( $title, $i, $data[$i]['value'], $data[$i]['checked'], $data[$i]['hideKey'], $data[$i]['label'] );
700
  }
701
  else if( $data[$i]['type'] == 'radio' ) {
702
  $out .=
@@ -930,6 +931,8 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";
930
  }
931
 
932
  function parse_ini_str($Str,$ProcessSections = TRUE) {
 
 
933
  $Section = NULL;
934
  $Data = array();
935
  $Sections = array();
@@ -977,19 +980,32 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";
977
  foreach($Data as $title => $data) {
978
  foreach($data as $key => $val) {
979
  if($val["type"] == "checkbox") {
980
- $values = explode( '#', $val["value"] );
981
- $defaults = explode( '#', $val["default"] );
982
- foreach($defaults as $dkey => $dval) {
983
- $defaults[$dkey] = trim($dval);
984
- }
 
 
 
 
 
 
985
  $tmp = $key;
986
  foreach($values as $value) {
987
  $Data[$title][$key]["type"] = "checkbox";
988
  $Data[$title][$key]["value"] = trim($value);
989
- if($tmp!=$key)
990
  $Data[$title][$key]["hideKey"] = true;
991
- if(in_array(trim($value), $defaults))
992
- $Data[$title][$key]["checked"] = true;
 
 
 
 
 
 
 
993
  $key++;
994
  }
995
  }
@@ -1022,8 +1038,15 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";
1022
  if ( $val2['hideKey'] == true ) $hide = ' class="hideKey"';
1023
  if ( !empty($val2['label']) && $options['custom_field_template_replace_keys_by_labels'] )
1024
  $key = stripcslashes($val2['label']);
1025
- $output .= '<dt><span' . $hide . '>' . $key . '</span></dt>' . "\n";
1026
- $output .= '<dd>' . $value[$key2] . '</dd>' . "\n";
 
 
 
 
 
 
 
1027
  endif;
1028
  endforeach;
1029
  endforeach;
4
  Plugin URI: http://wordpressgogo.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: 0.7.2
8
  Author URI: http://wordpressgogo.com/
9
  */
10
 
280
  <h3><?php _e('PHP CODE (Experimental Option)', 'custom-field-template'); ?></h3>
281
  <div class="inside">
282
  <form method="post" onsubmit="return confirm('<?php _e('Are you sure to save PHP codes? Please do it at your own risk.', 'custom-field-template'); ?>');">
283
+ <p><?php _e('This option is available only for `radio` and `select` types. You must set $values as an array.', 'custom-field-template'); ?><br />ex. `radio` and `select`:<br />$values = array('dog', 'cat', 'monkey'); $default = 'cat';<br />
284
+ ex. `checkbox`:<br />$values = array('dog', 'cat', 'monkey'); $defaults = array('dog', 'cat');</p>
285
  <table class="form-table" style="margin-bottom:5px;">
286
  <tbody>
287
  <?php
464
  return $out;
465
  }
466
 
467
+ function make_checkbox( $name, $sid, $value, $checked, $hideKey, $label, $code ) {
468
  $options = $this->get_custom_field_template_data();
469
 
470
  $title = $name;
471
  $name = $this->sanitize_name( $name );
472
+
473
  if ( !$value ) $value = "true";
474
 
475
  if( isset( $_REQUEST[ 'post' ] ) && $_REQUEST[ 'post' ] > 0 ) {
697
  }
698
  else if( $data[$i]['type'] == 'checkbox' ) {
699
  $out .=
700
+ $this->make_checkbox( $title, $i, $data[$i]['value'], $data[$i]['checked'], $data[$i]['hideKey'], $data[$i]['label'], $data[$i]['code'] );
701
  }
702
  else if( $data[$i]['type'] == 'radio' ) {
703
  $out .=
931
  }
932
 
933
  function parse_ini_str($Str,$ProcessSections = TRUE) {
934
+ $options = $this->get_custom_field_template_data();
935
+
936
  $Section = NULL;
937
  $Data = array();
938
  $Sections = array();
980
  foreach($Data as $title => $data) {
981
  foreach($data as $key => $val) {
982
  if($val["type"] == "checkbox") {
983
+ if ( is_numeric($val["code"]) ) :
984
+ eval(stripcslashes($options['php'][$val["code"]]));
985
+ else :
986
+ $values = explode( '#', $val["value"] );
987
+ $defaults = explode( '#', $val["default"] );
988
+ endif;
989
+
990
+ if ( is_array($defaults) )
991
+ foreach($defaults as $dkey => $dval)
992
+ $defaults[$dkey] = trim($dval);
993
+
994
  $tmp = $key;
995
  foreach($values as $value) {
996
  $Data[$title][$key]["type"] = "checkbox";
997
  $Data[$title][$key]["value"] = trim($value);
998
+ if ( $tmp!=$key )
999
  $Data[$title][$key]["hideKey"] = true;
1000
+ if ( is_array($defaults) )
1001
+ if ( in_array(trim($value), $defaults) )
1002
+ $Data[$title][$key]["checked"] = true;
1003
+ if ( $val["level"] )
1004
+ $Data[$title][$key]["level"] = $val["level"];
1005
+ if ( $val["insertTag"] == true )
1006
+ $Data[$title][$key]["insertTag"] = true;
1007
+ if ( $val["output"] == true )
1008
+ $Data[$title][$key]["output"] = true;
1009
  $key++;
1010
  }
1011
  }
1038
  if ( $val2['hideKey'] == true ) $hide = ' class="hideKey"';
1039
  if ( !empty($val2['label']) && $options['custom_field_template_replace_keys_by_labels'] )
1040
  $key = stripcslashes($val2['label']);
1041
+ if ( $val2['type'] == 'checkbox' ) :
1042
+ if( in_array($val2['value'], $value) ) :
1043
+ $output .= '<dt><span' . $hide . '>' . $key . '</span></dt>' . "\n";
1044
+ $output .= '<dd>' . $val2['value'] . '</dd>' . "\n";
1045
+ endif;
1046
+ else :
1047
+ $output .= '<dt><span' . $hide . '>' . $key . '</span></dt>' . "\n";
1048
+ $output .= '<dd>' . $value[$key2] . '</dd>' . "\n";
1049
+ endif;
1050
  endif;
1051
  endforeach;
1052
  endforeach;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wordpressgogo.com/development/custom-field-template.html
4
  Tags: custom, fields, field, template, meta, custom field, custom fields, custom field template
5
  Requires at least: 2.1
6
  Tested up to: 2.7
7
- Stable tag: 0.7.1
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
4
  Tags: custom, fields, field, template, meta, custom field, custom fields, custom field template
5
  Requires at least: 2.1
6
  Tested up to: 2.7
7
+ Stable tag: 0.7.2
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10