/** * Renders individual field in theme options. * @since 1.6 */ function ar2_theme_options_render_field($args = array()) { global $ar2_options; extract($args, EXTR_SKIP); if (!isset($value)) { if (!is_array($ar2_options)) { ar2_flush_theme_options(); } $value = ar2_multidimensional_get($ar2_options, $_id_data['keys']); } switch ($type) { case 'thumbnail-size': ?> <div class="thumbnail-size-fields"> <label for="'ar2_theme_options[<?php echo $id; ?> ][w]"><?php _e('Width', 'ar2'); ?> </label> <?php echo ar2_form_input('ar2_theme_options[' . $id . '][w]', $width, 'class="thumb-width" style="width: 50px" maxlength="3"'); ?> <span class="thumbnail_default_width" style="display: none"><?php echo $d_width; ?> </span> <label for="'ar2_theme_options[<?php echo $id; ?> ][h]"><?php _e('Height', 'ar2'); ?> </label> <?php echo ar2_form_input('ar2_theme_options[' . $id . '][h]', $height, 'class="thumb-height" style="width: 50px" maxlength="3"'); ?> <span class="thumbnail_default_height" style="display: none"><?php echo $d_height; ?> </span> <a class="reset-thumbnail-sizes button-secondary"><?php _e('Reset to Defaults', 'ar2'); ?> </a> </div> <?php break; case 'cat-dropdown': $_taxonomy_keys = array_slice($_id_data['keys'], 0, count($_id_data['keys']) - 1); $_taxonomy_keys[] = 'taxonomy'; ?> <div class="cat-dropdown-container"> <p class="cat-dropdown-multiselect"> <?php echo ar2_form_terms_dropdown($id, $setting, ar2_multidimensional_get($ar2_options, $_taxonomy_keys), $value); ?> <?php $taxonomy = ar2_multidimensional_get($ar2_options, $_taxonomy_keys); echo ar2_form_dropdown('ar2_theme_options[' . $id . '][]', ar2_get_terms_list($taxonomy), $value, 'multiple="multiple" class="terms-multiselect"'); ?> </p> <span style="display: none" class="choosetax"><?php _e('Please choose your taxonomy before proceeding.', 'ar2'); ?> </span> </div> <?php break; case 'taxonomies-dropdown': $_posttype_keys = array_slice($_id_data['keys'], 0, count($_id_data['keys']) - 1); $_posttype_keys[] = 'post_type'; $_post_type = ar2_multidimensional_get($ar2_options, $_posttype_keys) == '' ? 'post' : ar2_multidimensional_get($ar2_options, $_posttype_keys); $taxonomy = get_taxonomy($value); echo '<span class="no-js-label">' . $taxonomy->labels->name . '</span>'; ?> <div class="tax-dropdown-container"> <?php echo ar2_form_taxonomies_dropdown('ar2_theme_options[' . $id . ']', $_post_type, $value, $extras); ?> <img class="ajax-feedback" src="<?php echo get_template_directory_uri(); ?> /images/admin/wpspin_light.gif" alt="<?php _e('Loading', 'ar2'); ?> " /> </div> <?php break; case 'posttype-dropdown': $post_type = get_post_type_object($value); echo '<span class="no-js-label">' . $post_type->labels->name . '</span>'; echo ar2_form_posttype_dropdown('ar2_theme_options[' . $id . ']', $value, $extras); break; case 'switch': echo '<input type="hidden" value="0" name="ar2_theme_options[' . $id . ']" />'; echo '<div class="switch">'; echo ar2_form_checkbox('ar2_theme_options[' . $id . ']', true, $value, 'id="ar2_theme_options[' . $id . ']"'); echo '<label for="ar2_theme_options[' . $id . ']"><div class="switch-inner">'; echo '<span class="switch-active">' . __('On', 'ar2') . '</span>'; echo '<span class="switch-inactive">' . __('Off', 'ar2') . '</span>'; echo '</div><div class="switch-node"></div></label></div>'; break; case 'color-switcher': echo '<div class="color-switch">'; foreach ($options as $color_id => $color) { if ($color_id == 'default') { echo ar2_form_radio('ar2_theme_options[' . $id . ']', 'default', $value, 'id="' . $id . '-' . $color_id . '"'); echo '<label title="' . $color['label'] . '" class="default" for="' . $id . '-' . $color_id . '"><span>' . $color['label'] . '</span></label>'; } else { echo ar2_form_radio('ar2_theme_options[' . $id . ']', $color['hex'], $value, 'id="' . $id . '-' . $color_id . '"'); echo '<label title="' . $color['label'] . '" for="' . $id . '-' . $color_id . '"><span style="background: ' . $color['hex'] . '">' . $color['label'] . '</span></label>'; } } echo '</div>'; break; case 'media-upload': echo '<div class="media-upload">'; echo '<p><img id="media-upload-img-' . $id . '" src="' . $value . '" alt="" /></p>'; echo ar2_form_input('ar2_theme_options[' . $id . ']', $value, 'id="media-upload-' . $id . '"'); echo '<input type="button" data-upload-field="' . $id . '" class="button media-upload-add" value="' . __('Add Image', 'ar2') . '" />'; echo '<a href="#" data-upload-field="' . $id . '" class="media-upload-remove">' . __('Remove', 'ar2') . '</a>'; echo '</div>'; break; case 'input': echo ar2_form_input('ar2_theme_options[' . $id . ']', $value, $extras); break; case 'textarea': echo ar2_form_textarea('ar2_theme_options[' . $id . ']', $value, $extras); break; case 'textarea_html': echo ar2_form_textarea('ar2_theme_options[' . $id . ']', $value, $extras); break; case 'dropdown': echo ar2_form_dropdown('ar2_theme_options[' . $id . ']', $options, $value, $extras); break; case 'checkbox': echo '<input type="hidden" value="0" name="ar2_theme_options[' . $id . ']" />'; echo ar2_form_checkbox('ar2_theme_options[' . $id . ']', true, $value, $extras); break; case 'custom': if ((string) $callback != '') { call_user_func($callback, array_merge($args, array('value' => $value))); } break; default: // default is static echo false != $content ? $content : ''; } if (isset($description)) { if ($type == 'checkbox') { echo ' '; } else { echo '<br />'; } echo '<span class="description">' . $description . '</span>'; } }
/** * Will attempt to check if a specific value in a multidimensional array is set. * Taken from WordPress' WP_Customize_Setting class. * * @since 2.0 * * @param $root * @param $keys * @return bool True if value is set, false if not. */ function ar2_multidimensional_isset($root, $keys) { $result = ar2_multidimensional_get($root, $keys); return isset($result); }