Skip to content
This repository has been archived by the owner on Mar 17, 2018. It is now read-only.

Commit

Permalink
WP 3.8 compatibility
Browse files Browse the repository at this point in the history
Even if SMOF development was discontinued, I decided to update it and
make compatible with WordPress 3.8
  • Loading branch information
awps committed Feb 19, 2014
1 parent e203b70 commit 168a769
Show file tree
Hide file tree
Showing 23 changed files with 1,614 additions and 642 deletions.
14 changes: 7 additions & 7 deletions admin/assets/css/admin-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ border-radius: 2px;
}

#of_container #content .section-multicheck .controls input.checkbox {
margin-right: 5px;
}

#of_container #content .section-checkbox .explain {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -723,7 +724,6 @@ z-index: 2;
padding-left: 6px;
position:absolute;
left:0;
overflow: hidden;
}

#of_container .select_wrapper .select {
Expand Down
Binary file added admin/assets/images/blog1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/blog2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/blog3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/blog4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/blog5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/pf2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/pf22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/pf3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/pf32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/pf4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/pf42.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/pfg3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/pfg32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/assets/images/pfg4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 2 additions & 23 deletions admin/assets/js/smof.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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' ) {
Expand All @@ -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();

}

Expand Down Expand Up @@ -734,4 +713,4 @@ jQuery(document).ready(function($){



}); //end doc ready
}); //end doc ready
81 changes: 22 additions & 59 deletions admin/classes/class.options_machine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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" => "",
Expand Down Expand Up @@ -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 = '';
Expand All @@ -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" )
{
Expand All @@ -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'] ) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 .' />';

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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') {
Expand All @@ -713,10 +686,6 @@ public static function optionsframework_machine($options) {
} /* condition empty end */

}

if ($update_data == true) {
of_save_options($smof_data);
}

$output .= '</div>';

Expand All @@ -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);

Expand All @@ -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';}
Expand Down Expand Up @@ -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;}

Expand Down
24 changes: 4 additions & 20 deletions admin/functions/functions.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
));
Expand Down Expand Up @@ -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;
}
}
}
}
}
Expand All @@ -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;
6 changes: 2 additions & 4 deletions admin/functions/functions.filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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]',
Expand Down
Loading

0 comments on commit 168a769

Please sign in to comment.