From 947617f81f23ba23839c90f24e62dc97130b2ba9 Mon Sep 17 00:00:00 2001 From: creat0r Date: Sun, 29 Dec 2013 23:07:53 +0200 Subject: [PATCH 1/4] Added theme textdomain definition --- admin/index.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/admin/index.php b/admin/index.php index 1f98ad7..0a439e1 100644 --- a/admin/index.php +++ b/admin/index.php @@ -28,25 +28,27 @@ */ $theme_version = ''; $smof_output = ''; - + if( function_exists( 'wp_get_theme' ) ) { if( is_child_theme() ) { $temp_obj = wp_get_theme(); $theme_obj = wp_get_theme( $temp_obj->get('Template') ); } else { - $theme_obj = wp_get_theme(); + $theme_obj = wp_get_theme(); } $theme_version = $theme_obj->get('Version'); $theme_name = $theme_obj->get('Name'); $theme_uri = $theme_obj->get('ThemeURI'); $author_uri = $theme_obj->get('AuthorURI'); + $theme_textdomain = $theme_obj->get('TextDomain'); } else { $theme_data = get_theme_data( get_template_directory().'/style.css' ); $theme_version = $theme_data['Version']; $theme_name = $theme_data['Name']; $theme_uri = $theme_data['ThemeURI']; $author_uri = $theme_data['AuthorURI']; + $theme_textdomain = $theme_data['TextDomain']; } @@ -60,6 +62,7 @@ define( 'LAYOUT_PATH', ADMIN_PATH . 'layouts/' ); define( 'THEMENAME', $theme_name ); +define( 'THEMETEXTDOMAIN', $theme_textdomain); /* Theme version, uri, and the author uri are not completely necessary, but may be helpful in adding functionality */ define( 'THEMEVERSION', $theme_version ); define( 'THEMEURI', $theme_uri ); @@ -83,7 +86,7 @@ * Required Files * * @since 1.0.0 - */ + */ require_once ( ADMIN_PATH . 'functions/functions.load.php' ); require_once ( ADMIN_PATH . 'classes/class.options_machine.php' ); From b98fbd8a17c7db63908d28212c330603554b5647 Mon Sep 17 00:00:00 2001 From: creat0r Date: Mon, 30 Dec 2013 00:52:39 +0200 Subject: [PATCH 2/4] More parts of Options Panel are localization-ready now because of using _e function and adding TEXTDOMAIN variable --- admin/front-end/options.php | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/admin/front-end/options.php b/admin/front-end/options.php index 88aa3a9..c350588 100644 --- a/admin/front-end/options.php +++ b/admin/front-end/options.php @@ -1,52 +1,52 @@
-
Options Updated
+
- +
-
Options Reset
+
- +
-
Error!
+
- +
- +
- + -
Expand
+
- - + + - -
- + +
+
- +
    Menu ?> @@ -56,22 +56,22 @@
    Inputs /* Settings */ ?>
    - +
    - +
- -
- - - - - - -
- + +
+ + + + + + +
+ - +
From 5696d4befa39f4560bf9fe159ddaa0e4d9c134fd Mon Sep 17 00:00:00 2001 From: creat0r Date: Mon, 30 Dec 2013 01:06:50 +0200 Subject: [PATCH 3/4] More strings made localization-ready --- admin/classes/class.options_machine.php | 402 ++++++++++++------------ 1 file changed, 201 insertions(+), 201 deletions(-) diff --git a/admin/classes/class.options_machine.php b/admin/classes/class.options_machine.php index e257c61..dbc62d8 100644 --- a/admin/classes/class.options_machine.php +++ b/admin/classes/class.options_machine.php @@ -1,4 +1,4 @@ -optionsframework_machine($options); - + $this->Inputs = $return[0]; $this->Menu = $return[1]; $this->Defaults = $return[2]; - + } - /** + /** * Sanitize option * * 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 @@ -70,7 +70,7 @@ public static function optionsframework_machine($options) { $smof_data = of_get_options(); $data = $smof_data; - $defaults = array(); + $defaults = array(); $counter = 0; $menu = ''; $output = ''; @@ -84,19 +84,19 @@ public static function optionsframework_machine($options) { $output .= $smof_output; $smof_output = ""; } - - + + foreach ($options as $value) { - + // sanitize option if ($value['type'] != "heading") $value = self::sanitize_option($value); $counter++; $val = ''; - - //create array of defaults + + //create array of defaults if ($value['type'] == 'multicheck'){ if (is_array($value['std'])){ foreach($value['std'] as $i=>$key){ @@ -108,10 +108,10 @@ public static function optionsframework_machine($options) { } else { if (isset($value['id'])) $defaults[$value['id']] = $value['std']; } - + /* 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) { @@ -128,7 +128,7 @@ public static function optionsframework_machine($options) { if ( $value['type'] != "heading" ) { $class = ''; if(isset( $value['class'] )) { $class = $value['class']; } - + //hide items in checkbox group $fold=''; if (array_key_exists("fold",$value)) { @@ -138,35 +138,35 @@ public static function optionsframework_machine($options) { $fold="f_".$value['fold']." temphide "; } } - + $output .= '
'."\n"; - + //only show header if 'name' value exists if($value['name']) $output .= '

'. $value['name'] .'

'."\n"; - + $output .= '
'."\n" . '
'."\n"; - - } + + } //End Heading //if (!isset($smof_data[$value['id']]) && $value['type'] != "heading") // continue; - - //switch statement to handle various options type + + //switch statement to handle various options type switch ( $value['type'] ) { - + //text input case 'text': $t_value = ''; $t_value = stripslashes($smof_data[$value['id']]); - + $mini =''; if(!isset($value['mod'])) $value['mod'] = ''; if($value['mod'] == 'mini') { $mini = 'mini';} - + $output .= ''; break; - + //select option case 'select': $mini =''; @@ -179,59 +179,59 @@ public static function optionsframework_machine($options) { $theValue = $option; if (!is_numeric($select_ID)) $theValue = $select_ID; - $output .= ''; - } + $output .= ''; + } $output .= '
'; break; - + //textarea option - case 'textarea': + case 'textarea': $cols = '8'; $ta_value = ''; - + if(isset($value['options'])){ $ta_options = $value['options']; if(isset($ta_options['cols'])){ $cols = $ta_options['cols']; - } + } } - - $ta_value = stripslashes($smof_data[$value['id']]); - $output .= ''; + + $ta_value = stripslashes($smof_data[$value['id']]); + $output .= ''; break; - + //radiobox option case "radio": $checked = (isset($smof_data[$value['id']])) ? checked($smof_data[$value['id']], $option, false) : ''; foreach($value['options'] as $option=>$name) { - $output .= '
'; + $output .= '
'; } break; - + //checkbox option case 'checkbox': if (!isset($smof_data[$value['id']])) { $smof_data[$value['id']] = 0; } - + $fold = ''; if (array_key_exists("folds",$value)) $fold="fld "; - + $output .= ''; $output .= ''; break; - + //multiple checkbox option - case 'multicheck': + case 'multicheck': (isset($smof_data[$value['id']]))? $multi_stored = $smof_data[$value['id']] : $multi_stored=""; - + foreach ($value['options'] as $key => $option) { if (!isset($multi_stored[$key])) {$multi_stored[$key] = '';} $of_key_string = $value['id'] . '_' . $key; - $output .= '
'; - } + $output .= '
'; + } break; - + // Color picker case "color": $default_color = ''; @@ -239,48 +239,48 @@ public static function optionsframework_machine($options) { $default_color = ' data-default-color="' .$value['std'] . '" '; } $output .= ''; - + break; - //typography option + //typography option case 'typography': - + $typography_stored = isset($smof_data[$value['id']]) ? $smof_data[$value['id']] : $value['std']; - + /* Font Size */ - + if(isset($typography_stored['size'])) { $output .= '
'; $output .= '
'; - + } - + /* Line Height */ if(isset($typography_stored['height'])) { - + $output .= '
'; $output .= '
'; - + } - + /* Font Face */ if(isset($typography_stored['face'])) { - + $output .= '
'; $output .= '
'; - + } - + /* Font Weight */ if(isset($typography_stored['style'])) { - + $output .= '
'; $output .= '
'; - + } - + /* Font Color */ if(isset($typography_stored['color'])) { - + $output .= '
'; $output .= ''; - + } - + break; - + //border option case 'border': - + /* Border Width */ $border_stored = $smof_data[$value['id']]; - + $output .= '
'; $output .= '
'; - + /* Border Style */ $output .= '
'; $output .= '
'; - - /* Border Color */ + + /* Border Color */ $output .= '
'; $output .= ''; - + break; - + //images checkbox - use image as checkboxes case 'images': - + $i = 0; - + $select_value = (isset($smof_data[$value['id']])) ? $smof_data[$value['id']] : ''; - - foreach ($value['options'] as $key => $option) - { + + foreach ($value['options'] as $key => $option) + { $i++; - + $checked = ''; $selected = ''; if(NULL!=checked($select_value, $key, false)) { $checked = checked($select_value, $key, false); - $selected = 'of-radio-img-selected'; + $selected = 'of-radio-img-selected'; } $output .= ''; $output .= ''; $output .= '
'. $key .'
'; $output .= ''; - $output .= '
'; + $output .= ''; } - + break; - + //info (for small intro box etc) case "info": $info_text = $value['std']; $output .= '
'.$info_text.'
'; break; - + //display a single image case "image": $src = $value['std']; $output .= ''; break; - + //tab heading case 'heading': if($counter >= 2){ @@ -409,11 +409,11 @@ 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)))))); - + $menu .= '
  • '. $value['name'] .'
  • '; $output .= '

    '.$value['name'].'

    '."\n"; break; - + //drag & drop slide manager case 'slider': $output .= '
      '; @@ -431,12 +431,12 @@ public static function optionsframework_machine($options) { $order = $i; $output .= Options_Machine::optionsframework_slider_function($value['id'],$value['std'],$oldorder,$order); } - } + } $output .= '
    '; - $output .= 'Add New Slide
    '; - + $output .= ''.__("Add New Slide", THEMETEXTDOMAIN).'
    '; + break; - + //drag & drop block manager case 'sorter': @@ -512,34 +512,34 @@ public static function optionsframework_machine($options) { $output .= '
    '; break; - + //background images option case 'tiles': - + $i = 0; $select_value = isset($smof_data[$value['id']]) && !empty($smof_data[$value['id']]) ? $smof_data[$value['id']] : ''; if (is_array($value['options'])) { - foreach ($value['options'] as $key => $option) { + foreach ($value['options'] as $key => $option) { $i++; - + $checked = ''; $selected = ''; if(NULL!=checked($select_value, $option, false)) { $checked = checked($select_value, $option, false); - $selected = 'of-radio-tile-selected'; + $selected = 'of-radio-tile-selected'; } $output .= ''; $output .= ''; $output .= '
    '; - $output .= '
    '; + $output .= ''; } } - + break; - + //backup and restore options data case 'backup': - + $instructions = $value['desc']; $backup = of_get_options(BACKUPS); $init = of_get_options('smof_init'); @@ -550,34 +550,34 @@ public static function optionsframework_machine($options) { } else { $log = $backup['backup_log']; } - + $output .= '
    '; $output .= '
    '.$instructions."\n"; $output .= '

    '. __('Last Backup : ').''.$log.'

    '."\n"; $output .= 'Backup Options'; $output .= 'Restore Options'; $output .= '
    '; - + break; - + //export or import data between different installs case 'transfer': - + $instructions = $value['desc']; $output .= ''."\n"; $output .= 'Import Options'; - + break; - + // google font field case 'select_google_font': $output .= '
    '; $output .= '
    '; - + if(isset($value['preview']['text'])){ $g_text = $value['preview']['text']; } else { @@ -585,57 +585,57 @@ public static function optionsframework_machine($options) { } if(isset($value['preview']['size'])) { $g_size = 'style="font-size: '. $value['preview']['size'] .';"'; - } else { + } else { $g_size = ''; } $hide = " hide"; if ($smof_data[$value['id']] != "none" && $smof_data[$value['id']] != "") $hide = ""; - + $output .= '

    '. $g_text .'

    '; break; - + //JQuery UI Slider case 'sliderui': $s_val = $s_min = $s_max = $s_step = $s_edit = '';//no errors, please - + $s_val = stripslashes($smof_data[$value['id']]); - + if(!isset($value['min'])){ $s_min = '0'; }else{ $s_min = $value['min']; } if(!isset($value['max'])){ $s_max = $s_min + 1; }else{ $s_max = $value['max']; } if(!isset($value['step'])){ $s_step = '1'; }else{ $s_step = $value['step']; } - - if(!isset($value['edit'])){ - $s_edit = ' readonly="readonly"'; + + if(!isset($value['edit'])){ + $s_edit = ' readonly="readonly"'; } else { $s_edit = ''; } - + if ($s_val == '') $s_val = $s_min; - + //values $s_data = 'data-id="'.$value['id'].'" data-val="'.$s_val.'" data-min="'.$s_min.'" data-max="'.$s_max.'" data-step="'.$s_step.'"'; - + //html output $output .= ''; $output .= '
    '; - + break; - - + + //Switch option case 'switch': if (!isset($smof_data[$value['id']])) { $smof_data[$value['id']] = 0; } - + $fold = ''; if (array_key_exists("folds",$value)) $fold="s_fld "; - + $cb_enabled = $cb_disabled = '';//no errors, please - + //Get selected if ($smof_data[$value['id']] == 1){ $cb_enabled = ' selected'; @@ -644,30 +644,30 @@ public static function optionsframework_machine($options) { $cb_enabled = ''; $cb_disabled = ' selected'; } - + //Label ON if(!isset($value['on'])){ $on = "On"; }else{ $on = $value['on']; } - + //Label OFF if(!isset($value['off'])){ $off = "Off"; }else{ $off = $value['off']; } - + $output .= '

    '; $output .= ''; $output .= ''; - + $output .= ''; $output .= ''; - + $output .= '

    '; - + break; // Uploader 3.5 @@ -675,16 +675,16 @@ public static function optionsframework_machine($options) { case "media": if(!isset($value['mod'])) $value['mod'] = ''; - + $u_val = ''; if($smof_data[$value['id']]){ $u_val = stripslashes($smof_data[$value['id']]); } $output .= Options_Machine::optionsframework_media_uploader_function($value['id'],$u_val, $value['mod']); - + break; - + } do_action('optionsframework_machine_loop', array( @@ -700,24 +700,24 @@ public static function optionsframework_machine($options) { $output .= $smof_output; $smof_output = ""; } - + //description of each option - if ( $value['type'] != 'heading') { - if(!isset($value['desc'])){ $explain_value = ''; } else{ - $explain_value = '
    '. $value['desc'] .'
    '."\n"; - } + if ( $value['type'] != 'heading') { + if(!isset($value['desc'])){ $explain_value = ''; } else{ + $explain_value = '
    '. $value['desc'] .'
    '."\n"; + } $output .= '
    '.$explain_value."\n"; $output .= '
    '."\n"; } - + } /* condition empty end */ - + } if ($update_data == true) { of_save_options($smof_data); } - + $output .= ''; do_action('optionsframework_machine_after', array( @@ -733,9 +733,9 @@ public static function optionsframework_machine($options) { $output .= $smof_output; $smof_output = ""; } - + return array($output,$menu,$defaults); - + } @@ -753,47 +753,47 @@ public static function optionsframework_media_uploader_function($id,$std,$mod){ $data = of_get_options(); $smof_data = of_get_options(); - + $uploader = ''; $upload = ""; if (isset($smof_data[$id])) $upload = $smof_data[$id]; $hide = ''; - + if ($mod == "min") {$hide ='hide';} - + if ( $upload != "") { $val = $upload; } else {$val = $std;} - - $uploader .= ''; - + + $uploader .= ''; + //Upload controls DIV $uploader .= '
    '; //If the user has WP3.5+ show upload/remove button if ( function_exists( 'wp_enqueue_media' ) ) { - $uploader .= 'Upload'; - + $uploader .= ''.__("Upload", THEMETEXTDOMAIN).''; + if(!empty($upload)) {$hide = '';} else { $hide = 'hide';} - $uploader .= 'Remove'; + $uploader .= ''.__("Remove", THEMETEXTDOMAIN).''; } - else + else { - $output .= '

    Upgrade your version of WordPress for full media support.

    '; + $output .= '

    '.__("Upgrade your version of WordPress for full media support.", THEMETEXTDOMAIN).'

    '; } $uploader .='
    ' . "\n"; //Preview $uploader .= '
    '; - if(!empty($upload)){ + if(!empty($upload)){ $uploader .= ''; $uploader .= ''; - $uploader .= ''; + $uploader .= ''; } $uploader .= '
    '; - $uploader .= '
    ' . "\n"; - + $uploader .= '
    ' . "\n"; + return $uploader; - + } /** @@ -807,76 +807,76 @@ public static function optionsframework_media_uploader_function($id,$std,$mod){ * @return string */ public static function optionsframework_slider_function($id,$std,$oldorder,$order){ - + $data = of_get_options(); $smof_data = of_get_options(); - + $slider = ''; $slide = array(); if (isset($smof_data[$id])) $slide = $smof_data[$id]; - + if (isset($slide[$oldorder])) { $val = $slide[$oldorder]; } else {$val = $std;} - + //initialize all vars $slidevars = array('title','url','link','description'); - + foreach ($slidevars as $slidevar) { if (!isset($val[$slidevar])) { $val[$slidevar] = ''; } } - - //begin slider interface + + //begin slider interface if (!empty($val['title'])) { $slider .= '
  • '.stripslashes($val['title']).''; } else { $slider .= '
  • Slide '.$order.''; } - + $slider .= ''; - + $slider .= 'Edit
    '; - + $slider .= '
    '; - + $slider .= ''; $slider .= ''; - + $slider .= ''; $slider .= ''; - + $slider .= '
    Upload'; - + if(!empty($val['url'])) {$hide = '';} else { $hide = 'hide';} $slider .= 'Remove'; $slider .='
    ' . "\n"; $slider .= '
    '; if(!empty($val['url'])){ - + $slider .= ''; $slider .= ''; $slider .= ''; - + } - $slider .= '
    '; + $slider .= '
    '; $slider .= ''; $slider .= ''; - + $slider .= ''; $slider .= ''; - + $slider .= 'Delete'; $slider .= '
    ' . "\n"; - + $slider .= ''; $slider .= '
  • '; - + return $slider; - + } - + }//end Options Machine class ?> From f922de0d87323dc3215bb22a5d268750ed510452 Mon Sep 17 00:00:00 2001 From: creat0r Date: Mon, 30 Dec 2013 01:47:26 +0200 Subject: [PATCH 4/4] Made slider element controls localization ready --- admin/classes/class.options_machine.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/admin/classes/class.options_machine.php b/admin/classes/class.options_machine.php index dbc62d8..5b63787 100644 --- a/admin/classes/class.options_machine.php +++ b/admin/classes/class.options_machine.php @@ -831,25 +831,25 @@ public static function optionsframework_slider_function($id,$std,$oldorder,$orde if (!empty($val['title'])) { $slider .= '
  • '.stripslashes($val['title']).''; } else { - $slider .= '
  • Slide '.$order.''; + $slider .= '
  • '.__("Slide", THEMETEXTDOMAIN).' '.$order.''; } $slider .= ''; - $slider .= 'Edit
    '; + $slider .= ''.__("Edit", THEMETEXTDOMAIN).''; $slider .= '
    '; - $slider .= ''; + $slider .= ''; $slider .= ''; - $slider .= ''; + $slider .= ''; $slider .= ''; - $slider .= '
    Upload'; + $slider .= '
    '.__("Upload", THEMETEXTDOMAIN).''; if(!empty($val['url'])) {$hide = '';} else { $hide = 'hide';} - $slider .= 'Remove'; + $slider .= ''.__("Remove", THEMETEXTDOMAIN).''; $slider .='
    ' . "\n"; $slider .= '
    '; if(!empty($val['url'])){ @@ -860,13 +860,13 @@ public static function optionsframework_slider_function($id,$std,$oldorder,$orde } $slider .= '
    '; - $slider .= ''; + $slider .= ''; $slider .= ''; - $slider .= ''; + $slider .= ''; $slider .= ''; - $slider .= 'Delete'; + $slider .= ''.__("Delete", THEMETEXTDOMAIN).''; $slider .= '
    ' . "\n"; $slider .= '
    ';