Permalink
Browse files

Merge pull request #396 from syamilmj/smof-wp-3.8

Smof wp 3.8
  • Loading branch information...
2 parents e203b70 + f476052 commit c5ac7a0930b3e20f5f55ba4c38f1dd8a9eab1efe @Smartik89 Smartik89 committed Feb 19, 2014
@@ -204,6 +204,7 @@ border-radius: 2px;
}
#of_container #content .section-multicheck .controls input.checkbox {
+ margin-right: 5px;
}
#of_container #content .section-checkbox .explain {
@@ -299,14 +300,14 @@ border-radius: 2px;
height:33px;}
-#of_container textarea, #of_container input, #of_container select, #of_container button{
+#of_container textarea, #of_container input[type="text"], #of_container select, #of_container button{
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
border-style:solid;
border-width:1px;
}
-#of_container .controls input, #of_container .controls select, #of_container .controls textarea {
+#of_container .controls input[type="text"], #of_container .controls select, #of_container .controls textarea {
margin-bottom: 9px !important;
background-color: #f1f1f1;
border: 1px solid;
@@ -316,11 +317,11 @@ border-radius: 2px;
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, sans-serif;
font-size: 12px;
}
-#of_container .controls input:hover, #of_container .controls textarea:hover {
+#of_container .controls input[type="text"]:hover, #of_container .controls textarea:hover {
background-color: #f9f9f9;
}
-#of_container .controls input:focus, #of_container .controls textarea:focus {
+#of_container .controls input[type="text"]:focus, #of_container .controls textarea:focus {
background-color: #fff;
border-color: #ccc #e6e6e6 #e6e6e6 #ccc;
outline:0;
@@ -343,10 +344,10 @@ border-radius: 2px;
width: 340px;
}
#of_container input.checkbox {
- width: 30px;
+ width: auto;
}
#of_container input.of-radio {
- width: 30px;
+ width: auto;
}
label.radio, label.multicheck {
position: relative;
@@ -723,7 +724,6 @@ z-index: 2;
padding-left: 6px;
position:absolute;
left:0;
-overflow: hidden;
}
#of_container .select_wrapper .select {
@@ -26,18 +26,6 @@ jQuery(document).ready(function($){
//Tabify Options
$('.group').hide();
- // Get the URL parameter for tab
- function getURLParameter(name) {
- return decodeURI(
- (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,''])[1]
- );
- }
-
- // If the $_GET param of tab is set, use that for the tab that should be open
- if (getURLParameter('tab') != "") {
- $.cookie('of_current_opt', '#'+getURLParameter('tab'), { expires: 7, path: '/' });
- }
-
// Display last current tab
if ($.cookie("of_current_opt") === null) {
$('.group:first').fadeIn('fast');
@@ -434,12 +422,6 @@ jQuery(document).ready(function($){
//get serialized data from all our option fields
var serializedReturn = $('#of_form :input[name][name!="security"][name!="of_reset"]').serialize();
-
- $('#of_form :input[type=checkbox]').each(function() {
- if (!this.checked) {
- serializedReturn += '&'+this.name+'=0';
- }
- });
var data = {
type: 'save',
@@ -524,7 +506,7 @@ jQuery(document).ready(function($){
/** Tipsy @since v1.3 */
if (jQuery().tipsy) {
- $('.tooltip, .typography-size, .typography-height, .typography-face, .typography-style, .of-typography-color').tipsy({
+ $('.typography-size, .typography-height, .typography-face, .typography-style, .of-typography-color').tipsy({
fade: true,
gravity: 's',
opacity: 0.7,
@@ -609,8 +591,6 @@ jQuery(document).ready(function($){
var _previewer = mainID +'_ggf_previewer';
if( _selected ){ //if var exists and isset
-
- $('.'+ _previewer ).fadeIn();
//Check if selected is not equal with "Select a font" and execute the script.
if ( _selected !== 'none' && _selected !== 'Select a font' ) {
@@ -631,7 +611,6 @@ jQuery(document).ready(function($){
//if selected is not a font remove style "font-family" at preview box
$('.'+ _previewer ).css('font-family', '' );
- $('.'+ _previewer ).fadeOut();
}
@@ -734,4 +713,4 @@ jQuery(document).ready(function($){
-}); //end doc ready
+}); //end doc ready
@@ -30,12 +30,13 @@ function __construct($options) {
* Sanitize & returns default values if don't exist
*
* Notes:
- - For further uses, you can check for the $value['type'] and performs
- more speficic sanitization on the option
- - The ultimate objective of this function is to prevent the "undefined index"
- errors some authors are having due to malformed options array
+ * - For further uses, you can check for the $value['type'] and performs
+ * more speficic sanitization on the option
+ * - The ultimate objective of this function is to prevent the "undefined index"
+ * errors some authors are having due to malformed options array
*/
- static function sanitize_option( $value ) {
+ public static function sanitize_option( $value ) {
+
$defaults = array(
"name" => "",
"desc" => "",
@@ -63,35 +64,25 @@ static function sanitize_option( $value ) {
* @return array
*/
public static function optionsframework_machine($options) {
- global $smof_output, $smof_details, $smof_data;
- if (empty($options))
- return;
- if (empty($smof_data))
- $smof_data = of_get_options();
+ global $smof_output;
+ $smof_data = of_get_options();
$data = $smof_data;
$defaults = array();
$counter = 0;
$menu = '';
$output = '';
- $update_data = false;
-
+
do_action('optionsframework_machine_before', array(
'options' => $options,
'smof_data' => $smof_data,
));
- if ($smof_output != "") {
- $output .= $smof_output;
- $smof_output = "";
- }
+ $output .= $smof_output;
-
-
foreach ($options as $value) {
// sanitize option
- if ($value['type'] != "heading")
- $value = self::sanitize_option($value);
+ $value = self::sanitize_option($value);
$counter++;
$val = '';
@@ -112,18 +103,6 @@ public static function optionsframework_machine($options) {
/* condition start */
if(!empty($smof_data) || !empty($data)){
- if (array_key_exists('id', $value) && !isset($smof_data[$value['id']])) {
- $smof_data[$value['id']] = $value['std'];
- if ($value['type'] == "checkbox" && $value['std'] == 0) {
- $smof_data[$value['id']] = 0;
- } else {
- $update_data = true;
- }
- }
- if (array_key_exists('id', $value) && !isset($smof_details[$value['id']])) {
- $smof_details[$value['id']] = $smof_data[$value['id']];
- }
-
//Start Heading
if ( $value['type'] != "heading" )
{
@@ -149,8 +128,8 @@ public static function optionsframework_machine($options) {
}
//End Heading
- //if (!isset($smof_data[$value['id']]) && $value['type'] != "heading")
- // continue;
+ if (!isset($smof_data[$value['id']]) && $value['type'] != "heading")
+ continue;
//switch statement to handle various options type
switch ( $value['type'] ) {
@@ -179,7 +158,7 @@ public static function optionsframework_machine($options) {
$theValue = $option;
if (!is_numeric($select_ID))
$theValue = $select_ID;
- $output .= '<option id="' . $select_ID . '" value="'.$theValue.'" ' . selected($smof_data[$value['id']], $theValue, false) . ' />'.$option.'</option>';
+ $output .= '<option id="' . $select_ID . '" value="'.$theValue.'" ' . selected($smof_data[$value['id']], $option, false) . ' />'.$option.'</option>';
}
$output .= '</select></div>';
break;
@@ -236,7 +215,8 @@ public static function optionsframework_machine($options) {
case "color":
$default_color = '';
if ( isset($value['std']) ) {
- $default_color = ' data-default-color="' .$value['std'] . '" ';
+ if ( $smof_data[$value['id']] != $value['std'] )
+ $default_color = ' data-default-color="' .$value['std'] . '" ';
}
$output .= '<input name="' . $value['id'] . '" id="' . $value['id'] . '" class="of-color" type="text" value="' . $smof_data[$value['id']] . '"' . $default_color .' />';
@@ -408,8 +388,7 @@ public static function optionsframework_machine($options) {
}
$header_class = str_replace(' ','',strtolower($value['name']));
$jquery_click_hook = str_replace(' ', '', strtolower($value['name']) );
- $jquery_click_hook = "of-option-" . trim(preg_replace('/ +/', '', preg_replace('/[^A-Za-z0-9 ]/', '', urldecode(html_entity_decode(strip_tags($jquery_click_hook))))));
-
+ $jquery_click_hook = "of-option-" . $jquery_click_hook;
$menu .= '<li class="'. $header_class .'"><a title="'. $value['name'] .'" href="#'. $jquery_click_hook .'"'. $icon .'>'. $value['name'] .'</a></li>';
$output .= '<div class="group" id="'. $jquery_click_hook .'"><h2>'.$value['name'].'</h2>'."\n";
break;
@@ -588,11 +567,8 @@ public static function optionsframework_machine($options) {
} else {
$g_size = '';
}
- $hide = " hide";
- if ($smof_data[$value['id']] != "none" && $smof_data[$value['id']] != "")
- $hide = "";
- $output .= '<p class="'.$value['id'].'_ggf_previewer google_font_preview'.$hide.'" '. $g_size .'>'. $g_text .'</p>';
+ $output .= '<p class="'.$value['id'].'_ggf_previewer google_font_preview" '. $g_size .'>'. $g_text .'</p>';
break;
//JQuery UI Slider
@@ -696,10 +672,7 @@ public static function optionsframework_machine($options) {
'output' => $output,
'value' => $value
));
- if ($smof_output != "") {
- $output .= $smof_output;
- $smof_output = "";
- }
+ $output .= $smof_output;
//description of each option
if ( $value['type'] != 'heading') {
@@ -713,10 +686,6 @@ public static function optionsframework_machine($options) {
} /* condition empty end */
}
-
- if ($update_data == true) {
- of_save_options($smof_data);
- }
$output .= '</div>';
@@ -729,10 +698,7 @@ public static function optionsframework_machine($options) {
'output' => $output,
'value' => $value
));
- if ($smof_output != "") {
- $output .= $smof_output;
- $smof_output = "";
- }
+ $output .= $smof_output;
return array($output,$menu,$defaults);
@@ -755,9 +721,7 @@ public static function optionsframework_media_uploader_function($id,$std,$mod){
$smof_data = of_get_options();
$uploader = '';
- $upload = "";
- if (isset($smof_data[$id]))
- $upload = $smof_data[$id];
+ $upload = $smof_data[$id];
$hide = '';
if ($mod == "min") {$hide ='hide';}
@@ -813,8 +777,7 @@ public static function optionsframework_slider_function($id,$std,$oldorder,$orde
$slider = '';
$slide = array();
- if (isset($smof_data[$id]))
- $slide = $smof_data[$id];
+ $slide = $smof_data[$id];
if (isset($slide[$oldorder])) { $val = $slide[$oldorder]; } else {$val = $std;}
@@ -19,8 +19,6 @@ function of_head() { do_action( 'of_head' ); }
/**
* Add default options upon activation else DB does not exist
*
- * DEPRECATED, Class_options_machine now does this on load to ensure all values are set
- *
* @since 1.0.0
*/
function of_option_setup()
@@ -81,22 +79,17 @@ function of_get_header_classes_array()
* @return array
*/
function of_get_options($key = null, $data = null) {
- global $smof_data;
do_action('of_get_options_before', array(
'key'=>$key, 'data'=>$data
));
if ($key != null) { // Get one specific value
+
$data = get_theme_mod($key, $data);
} else { // Get all values
- $data = get_theme_mods();
+ $data = get_theme_mods();
}
$data = apply_filters('of_options_after_load', $data);
- if ($key == null) {
- $smof_data = $data;
- } else {
- $smof_data[$key] = $data;
- }
do_action('of_option_setup_before', array(
'key'=>$key, 'data'=>$data
));
@@ -131,13 +124,6 @@ function of_save_options($data, $key = null) {
foreach ( $data as $k=>$v ) {
if (!isset($smof_data[$k]) || $smof_data[$k] != $v) { // Only write to the DB when we need to
set_theme_mod($k, $v);
- } else if (is_array($v)) {
- foreach ($v as $key=>$val) {
- if ($key != $k && $v[$key] == $val) {
- set_theme_mod($k, $v);
- break;
- }
- }
}
}
}
@@ -154,8 +140,6 @@ function of_save_options($data, $key = null) {
* @since forever
*/
-
-
$data = of_get_options();
-if (!isset($smof_details))
- $smof_details = array();
+$smof_data = of_get_options();
+$data = $smof_data;
@@ -20,8 +20,6 @@
*/
function of_filter_save_media_upload($data) {
- if(!is_array($data)) return $data;
-
foreach ($data as $key => $value) {
if (is_string($value)) {
$data[$key] = str_replace(
@@ -52,10 +50,10 @@ function of_filter_save_media_upload($data) {
*/
function of_filter_load_media_upload($data) {
- if(!is_array($data)) return $data;
+ if(!is_array($data)) return;
foreach ($data as $key => $value) {
- if (is_string($value) && preg_match("/\[site_url(_url_secure)?\]/", $value)) {
+ if (is_string($value)) {
$data[$key] = str_replace(
array(
'[site_url]',
Oops, something went wrong.

3 comments on commit c5ac7a0

@igor3333

Hello!
Tell me please - how can encode up to the introduction of an activation key?

@dovy
Collaborator
dovy commented on c5ac7a0 Jul 1, 2014

Activation key for what?

@igor3333

Want to do - without a key is invisible in the admin theme options

Please sign in to comment.