Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dovy committed Sep 14, 2013
1 parent dcfefc7 commit 44b769e
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 30 deletions.
10 changes: 7 additions & 3 deletions framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -915,9 +915,13 @@ public function _validate_options( $plugin_options ) {
$imported_options = json_decode( htmlspecialchars_decode( $import ), true );

if( is_array( $imported_options ) && isset( $imported_options['redux-backup'] ) && $imported_options['redux-backup'] == '1' ) {
$imported_options['imported'] = 1;
$plugin_options = wp_parse_args( $imported_options, $plugin_options ); // Allows for partial import (presets)


$plugin_options['imported'] = 1;
foreach($imported_options as $key => $value) {
$plugin_options[$key] = $value;
}

// Remove the import/export tab cookie.
if( $_COOKIE['redux_current_tab'] == 'import_export_default' ) {
setcookie( 'redux_current_tab', '', 1, '/' );
}
Expand Down
2 changes: 1 addition & 1 deletion inc/fields/media/field_media.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jQuery(document).ready(function($){
selector.find('.upload-id').val(attachment.attributes.id);
selector.find('.upload-height').val(attachment.attributes.height);
selector.find('.upload-width').val(attachment.attributes.width);
if ( attachment.attributes.type === 'image' ) {
if ( attachment.attributes.type === 'image' && !selector.find('.upload').hasClass('noPreview') ) {
selector.find('.screenshot').empty().hide().append('<img class="redux-option-image" src="' + attachment.attributes.url + '">').slideDown('fast');
}
selector.find('.media_upload_button').unbind();
Expand Down
2 changes: 1 addition & 1 deletion inc/fields/media/field_media.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions inc/fields/media/field_media.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ public function __construct( $field = array(), $value ='', $parent ) {
*/
public function render() {

$hide = 'hide ';

if( !empty( $this->field['show_url'] ) && $this->field['show_url'] === true )
$hide = '';

// No errors please
$defaults = array(
'id' => '',
Expand Down Expand Up @@ -95,24 +90,37 @@ public function render() {
}
}


if( empty( $this->value['url'] ) && !empty( $this->value['id'] ) ) {
$img = wp_get_attachment_image_src( $this->value['id'], 'full' );
$this->value['url'] = $img[0];
$this->value['width'] = $img[1];
$this->value['height'] = $img[2];
}

$hide = 'hide ';

if( (isset( $this->field['preview'] ) && $this->field['preview'] === false) ) {
$this->field['class'] .= " noPreview";
}

if( ( !empty( $this->field['url'] ) && $this->field['url'] === true ) || isset( $this->field['preview'] ) && $this->field['preview'] === false ) {
$hide = '';
}

echo '<input class="' . $hide . 'upload ' . $this->field['class'] . '" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][url]" id="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][url]" value="' . $this->value['url'] . '" readonly="readonly" />';
echo '<input type="hidden" class="upload-id ' . $this->field['class'] . '" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][id]" "' . $this->args['opt_name'] . '[' . $this->field['id'] . '][id]" value="' . $this->value['id'] . '" />';
echo '<input type="hidden" class="upload-height" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][height]" "' . $this->args['opt_name'] . '[' . $this->field['id'] . '][height]" value="' . $this->value['height'] . '" />';
echo '<input type="hidden" class="upload-width" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][width]" "' . $this->args['opt_name'] . '[' . $this->field['id'] . '][width]" value="' . $this->value['width'] . '" />';

//Preview
$hide = '';
if( empty( $this->value['url'] ) )
$hide = ' hide';

echo '<div class="screenshot' . $hide . '">';
if( (isset( $this->field['preview'] ) && $this->field['preview'] === false) || empty( $this->value['url'] ) ) {
$hide = 'hide ';
}

echo '<div class="' . $hide . 'screenshot">';
echo '<a class="of-uploaded-image" href="' . $this->value['url'] . '">';
echo '<img class="redux-option-image" id="image_' . $this->field['id'] . '" src="' . $this->value['url'] . '" alt="" />';
echo '</a>';
Expand Down
2 changes: 1 addition & 1 deletion inc/fields/select/field_select.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function render(){
}//foreach
echo '</select>';
} else {
echo '<strong>'._('No items of this type were found.', 'redux-framework').'</strong>';
echo '<strong>'.__('No items of this type were found.', 'redux-framework').'</strong>';
}

echo (isset($this->field['desc']) && !empty($this->field['desc']))?'<div class="description">'.$this->field['desc'].'</div>':'';
Expand Down
2 changes: 2 additions & 0 deletions inc/fields/sorter/field_sorter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global redux_change */
/*
* Field Sorter jquery function
* Based on
Expand All @@ -19,6 +20,7 @@ jQuery(function() {
var listID = jQuery(this).parent().attr('id');
var parentID = jQuery(this).parent().parent().attr('id');
parentID = parentID.replace(id + '_', '');
redux_change(jQuery(this));
var optionID = jQuery(this).parent().parent().parent().attr('id');
jQuery(this).prop("name", optionID + '[' + optionID + '][' + parentID + '][' + listID + ']');
});
Expand Down
4 changes: 2 additions & 2 deletions inc/fields/sorter/field_sorter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion inc/fields/sorter/field_sorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function render() {
$output .= '<input class="sorter-placebo" type="hidden" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][' . $group . '][placebo]" value="placebo">';
if ($key != "placebo") {
$output .= '<li id="' . $key . '" class="sortee">';
$output .= '<input class="position" type="hidden" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][' . $group . '][' . $key . ']" value="' . $list . '">';
$output .= '<input class="position ' . $this->field['class'] . '" type="hidden" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . '][' . $group . '][' . $key . ']" value="' . $list . '">';
$output .= $list;
$output .= '</li>';
}
Expand Down
9 changes: 5 additions & 4 deletions inc/fields/textarea/field_textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ function __construct($field = array(), $value ='', $parent) {


function render() {

$name = $this->args['opt_name'] . '[' . $this->field['id'] . ']';
$id = $this->field['id'];
$placeholder = (isset($this->field['placeholder'])) ? ' placeholder="' . esc_attr($this->field['placeholder']) . '" ' : '';
$rows = (isset($this->field['placeholder'])) ? $this->field['rows'] : 6;
$this->field['placeholder'] = isset($this->field['placeholder']) ? $this->field['placeholder'] : "";
$this->field['rows'] = isset($this->field['rows']) ? $this->field['rows'] : 6;

?>

<textarea name="<?php echo $name; ?>" id="<?php echo $id; ?>" <?php echo $placeholder; ?> class="large-text <?php echo $this->field['class']; ?>" rows="<?php echo $rows; ?>"><?php echo esc_attr($this->value); ?></textarea>
<textarea name="<?php echo $name; ?>" id="<?php echo $this->field['id']; ?>" placeholder="<?php echo esc_attr($this->field['placeholder']); ?>" class="large-text <?php echo $this->field['class']; ?>" rows="<?php echo $this->field['rows']; ?>"><?php echo $this->value; ?></textarea>

<?php
echo (isset($this->field['desc']) && !empty($this->field['desc'])) ? '<br /><span class="description">' . $this->field['desc'] . '</span>' : '';
Expand Down
27 changes: 18 additions & 9 deletions sample/sample-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,21 @@ function setup_framework_options(){
),

array(
'id'=>'media-min',
'id'=>'media-nourl',
'type' => 'media',
'mode'=> 'min',
'title' => __('Media Minimalistic (min)', 'redux-framework'),
'url'=> true,
'title' => __('Media No URL', 'redux-framework'),
'desc'=> __('This represents the minimalistic view. It does not have the preview box or the display URL in an input box. ', 'redux-framework'),
'subtitle' => __('Upload any media using the Wordpress native uploader', 'redux-framework'),
),
),
array(
'id'=>'media-nopreview',
'type' => 'media',
'preview'=> false,
'title' => __('Media No Preview', 'redux-framework'),
'desc'=> __('This represents the minimalistic view. It does not have the preview box or the display URL in an input box. ', 'redux-framework'),
'subtitle' => __('Upload any media using the Wordpress native uploader', 'redux-framework'),
),
/*
array(
'id'=>'gallery',
Expand Down Expand Up @@ -414,6 +422,7 @@ function setup_framework_options(){
"type" => "sorter",
"title" => "Homepage Layout Manager",
"desc" => "Organize how you want the layout to appear on the homepage",
"compiler"=>'true',
'options' => array(
"enabled" => array(
"placebo" => "placebo", //REQUIRED!
Expand Down Expand Up @@ -694,8 +703,8 @@ function setup_framework_options(){
'validate' => 'no_html',
'default' => 'No HTML is allowed in here.'
),
"6"=>array(
'id'=>'',
array(
'id'=>'6',
'type' => 'textarea',
'title' => __('Textarea Option - HTML Validated', 'redux-framework'),
'subtitle' => __('HTML Allowed (wp_kses)', 'redux-framework'),
Expand All @@ -710,7 +719,7 @@ function setup_framework_options(){
'subtitle' => __('Custom HTML Allowed (wp_kses)', 'redux-framework'),
'desc' => __('This is the description field, again good for additional info.', 'redux-framework'),
'validate' => 'html_custom',
'default' => 'Some HTML is allowed in here.',
'default' => '<p>Some HTML is allowed in here.</p>',
'allowed_html' => array('') //see http://codex.wordpress.org/Function_Reference/wp_kses
),
array(
Expand Down Expand Up @@ -868,8 +877,8 @@ function setup_framework_options(){
'subtitle' => __('No validation can be done on this field type', 'redux-framework'),
'desc' => __('This is the description field, again good for additional info.', 'redux-framework'),
),
"select-tags"=>array(
'id'=>'',
array(
'id'=>'select-tags',
'type' => 'select',
'data' => 'tags',
'title' => __('Tags Select Option', 'redux-framework'),
Expand Down

0 comments on commit 44b769e

Please sign in to comment.