Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
<?php /*-----------------------------------------------------------------------------------*/ /* Admin Interface /*-----------------------------------------------------------------------------------*/ $functions_path = THEME_ADMIN . '/'; function siteoptions_add_admin() { global $query_string; if ( isset($_REQUEST['page']) && $_REQUEST['page'] == 'siteoptions' ) { if (isset($_REQUEST['of_save']) && 'reset' == $_REQUEST['of_save']) { $options = get_option('of_template'); of_reset_options($options,'siteoptions'); header("Location: admin.php?page=siteoptions&reset=true"); die; } } $tt_page = add_theme_page('Chameleon Setting', 'Chameleon Setting', 'edit_theme_options', 'siteoptions','siteoptions_options_page'); add_action("admin_print_scripts-$tt_page", 'of_load_only'); add_action("admin_print_styles-$tt_page",'of_style_only'); } add_action('admin_menu', 'siteoptions_add_admin'); /*-----------------------------------------------------------------------------------*/ /* Reset Function /*-----------------------------------------------------------------------------------*/ function of_reset_options($options,$page = ''){ global $wpdb; $query_inner = ''; $count = 0; $excludes = array( 'blogname' , 'blogdescription' ); foreach($options as $option){ if(isset($option['id'])){ $count++; $option_id = $option['id']; $option_type = $option['type']; //Skip assigned id's if(in_array($option_id,$excludes)) { continue; } if($count > 1){ $query_inner .= ' OR '; } if($option_type == 'multicheck'){ $multicount = 0; foreach($option['options'] as $option_key => $option_option){ $multicount++; if($multicount > 1){ $query_inner .= ' OR '; } $query_inner .= "option_name = '" . $option_id . "_" . $option_key . "'"; } } else if(is_array($option_type)) { $type_array_count = 0; foreach($option_type as $inner_option){ $type_array_count++; $option_id = $inner_option['id']; if($type_array_count > 1){ $query_inner .= ' OR '; } $query_inner .= "option_name = '$option_id'"; } } else { $query_inner .= "option_name = '$option_id'"; } } } //When Theme Options page is reset - Add the of_options option if($page == 'siteoptions'){ $query_inner .= " OR option_name = 'of_options'"; } //echo $query_inner; $query = "DELETE FROM $wpdb->options WHERE $query_inner"; $wpdb->query($query); $filename = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/styledefault.css"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); // Let's make sure the file exists and is writable first. $filename = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/style.css"; if (is_writable($filename)) { if (!$handle = fopen($filename, 'w+')) { echo "Cannot open file ($filename)<br>"; exit; } // Write $contents to our opened file. if (fwrite($handle, $contents) === FALSE) { echo "Cannot write file ($filename)<br>"; exit; } } else { echo "File $filename has not write permission.<br>"; exit; } $filename = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/images/price-tagori.png"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); // Let's make sure the file exists and is writable first. $filename = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/images/price-tag.png"; if (is_writable($filename)) { if (!$handle = fopen($filename, 'w+')) { echo "Cannot open file ($filename)<br>"; exit; } // Write $contents to our opened file. if (fwrite($handle, $contents) === FALSE) { echo "Cannot write file ($filename)<br>"; exit; } } else { echo "File $filename has not write permission.<br>"; exit; } } /*-----------------------------------------------------------------------------------*/ /* Build the Options Page /*-----------------------------------------------------------------------------------*/ function siteoptions_options_page(){ $options = get_option('of_template'); $themename = get_option('of_themename'); if (get_option('ts_chameleon_license')) { $myLicense = get_option('ts_chameleon_license'); $maindomain = trim(ts_chameleon_maindomain(home_url())); $compareLicensePro = substr(md5($maindomain.'proch4m3l30nth3m35070173'.$myLicense['email']),0,32); $compareLicenseFree = substr(md5($maindomain.'070173ch4m3l30nth3m354fr33'.$myLicense['email']),0,32); if ( ($compareLicensePro==$myLicense['license']) || ($compareLicenseFree==$myLicense['license']) ) { ?> <div class="wrap" id="truethemes_container"> <div id="of-popup-save" class="of-save-popup"> <div class="of-save-save">Options Updated</div> </div> <div id="of-popup-reset" class="of-save-popup"> <div class="of-save-reset">Options Reset</div> </div> <form action="" enctype="multipart/form-data" id="ofform"> <div id="header"> <div class="logo"> <h2>Chameleon Setting</h2> </div> <div class="icon-option"> </div> <div class="clear"></div> </div> <?php // Rev up the Options Machine $return = siteoptions_machine($options); ?> <div id="main"> <div id="of-nav"> <ul> <?php echo $return[1] ?> </ul> </div> <div id="content"> <?php echo $return[0]; /* Settings */ ?> </div> <div class="clear"></div> </div> <div class="save_bar_top"> <img style="display:none;" src="<?php echo get_template_directory_uri() ?>/admin/images/wpspin_light.gif" class="ajax-loading-img ajax-loading-img-bottom" alt="Working..." /> <input type="submit" value="Save All Changes" class="button-primary" /> </form> <form action="<?php echo esc_attr( $_SERVER['REQUEST_URI'] ) ?>" method="post" style="display:inline" id="ofform-reset"> <span class="submit-footer-reset"> <input name="reset" type="submit" value="Reset Options" class="button submit-button reset-button" onclick="return confirm('CAUTION: Any and all settings will be lost! Click OK to reset.');" /> <input type="hidden" name="of_save" value="reset" /> </span> </form> </div> <?php if (!empty($update_message)) echo $update_message; ?> <div style="clear:both;"></div> </div> <!--wrap--> <?php } else { echo '<h3>Your ACTIVATION KEY is invalid.</h3><div>Please input your right ACTIVATION KEY or request one by click on <strong>Chameleon Setting</strong> under <strong>Appearance</strong> menu.</div>'; delete_option('ts_chameleon_license'); } } else { ts_chameleon_license(); } } /*-----------------------------------------------------------------------------------*/ /* Load required styles for Options Page /*-----------------------------------------------------------------------------------*/ require_once(TEMPLATEPATH . '/admin/admin-library.php'); function of_style_only() { wp_enqueue_style('admin-style', get_template_directory_uri().'/admin/admin-style.css'); wp_enqueue_style('color-picker', get_template_directory_uri().'/admin/colorpicker.css'); $color = get_user_option('admin_color'); if ($color == "fresh") { wp_enqueue_style('admin-style-grey', get_template_directory_uri().'/admin/admin-style-grey.css'); wp_enqueue_style('color-picker', get_template_directory_uri().'/admin/colorpicker.css'); } } /*-----------------------------------------------------------------------------------*/ /* Load required javascripts for Options Page /*-----------------------------------------------------------------------------------*/ function of_load_only() { add_action('admin_head', 'of_admin_head'); wp_enqueue_script('jquery-ui-core'); wp_register_script('jquery-input-mask', get_template_directory_uri().'/admin/js/jquery.maskedinput-1.2.2.js', array( 'jquery' )); wp_enqueue_script('jquery-input-mask'); wp_enqueue_script('color-picker', get_template_directory_uri().'/admin/js/colorpicker.js', array('jquery')); wp_enqueue_script('ajaxupload', get_template_directory_uri().'/admin/js/ajaxupload.js', array('jquery')); function of_admin_head() { ?> <script type="text/javascript" language="javascript"> jQuery(document).ready(function(){ // Race condition to make sure js files are loaded if (typeof AjaxUpload != 'function') { return ++counter < 6 && window.setTimeout(init, counter * 500); } //Color Picker <?php $options = get_option('of_template'); foreach($options as $option){ if($option['type'] == 'color' OR $option['type'] == 'typography' OR $option['type'] == 'border'){ if($option['type'] == 'typography' OR $option['type'] == 'border'){ $option_id = $option['id']; $temp_color = get_option($option_id); $option_id = $option['id'] . '_color'; $color = $temp_color['color']; } else { $option_id = $option['id']; $color = get_option($option_id); } ?> jQuery('#<?php echo $option_id; ?>_picker').children('div').css('backgroundColor', '<?php echo $color; ?>'); jQuery('#<?php echo $option_id; ?>_picker').ColorPicker({ color: '<?php echo $color; ?>', onShow: function (colpkr) { jQuery(colpkr).fadeIn(500); return false; }, onHide: function (colpkr) { jQuery(colpkr).fadeOut(500); return false; }, onChange: function (hsb, hex, rgb) { //jQuery(this).css('border','1px solid red'); jQuery('#<?php echo $option_id; ?>_picker').children('div').css('backgroundColor', '#' + hex); jQuery('#<?php echo $option_id; ?>_picker').next('input').attr('value','#' + hex); } }); <?php } } ?> }); </script> <?php //AJAX Upload ?> <script type="text/javascript"> jQuery(document).ready(function(){ var i = 0; jQuery('#of-nav li a').attr('id', function() { i++; return 'item'+i; }); var flip = 0; jQuery('#expand_options').click(function(){ if(flip == 0){ flip = 1; jQuery('#truethemes_container #of-nav').hide(); jQuery('#truethemes_container #content').width(755); jQuery('#truethemes_container .group').add('#truethemes_container .group h2').show(); jQuery(this).text('[-]'); } else { flip = 0; jQuery('#truethemes_container #of-nav').show(); jQuery('#truethemes_container #content').width(579); jQuery('#truethemes_container .group').add('#truethemes_container .group h2').hide(); jQuery('#truethemes_container .group:first').show(); jQuery('#truethemes_container #of-nav li').removeClass('current'); jQuery('#truethemes_container #of-nav li:first').addClass('current'); jQuery(this).text('[+]'); } }); jQuery('.group').hide(); jQuery('.group:first').fadeIn(); jQuery('.group .collapsed').each(function(){ jQuery(this).find('input:checked').parent().parent().parent().nextAll().each( function(){ if (jQuery(this).hasClass('last')) { jQuery(this).removeClass('hidden'); return false; } jQuery(this).filter('.hidden').removeClass('hidden'); }); }); jQuery('.group .collapsed input:checkbox').click(unhideHidden); function unhideHidden(){ if (jQuery(this).attr('checked')) { jQuery(this).parent().parent().parent().nextAll().removeClass('hidden'); } else { jQuery(this).parent().parent().parent().nextAll().each( function(){ if (jQuery(this).filter('.last').length) { jQuery(this).addClass('hidden'); return false; } jQuery(this).addClass('hidden'); }); } } jQuery('.of-radio-img-img').click(function(){ jQuery(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected'); jQuery(this).addClass('of-radio-img-selected'); }); jQuery('.of-radio-img-label').hide(); jQuery('.of-radio-img-img').show(); jQuery('.of-radio-img-radio').hide(); jQuery('#of-nav li:first').addClass('current'); jQuery('#of-nav li a').click(function(evt){ jQuery('#of-nav li').removeClass('current'); jQuery(this).parent().addClass('current'); var clicked_group = jQuery(this).attr('href'); jQuery('.group').hide(); jQuery(clicked_group).fadeIn(); evt.preventDefault(); }); if('<?php if(isset($_REQUEST['reset'])) { echo $_REQUEST['reset'];} else { echo 'false';} ?>' == 'true'){ var reset_popup = jQuery('#of-popup-reset'); reset_popup.fadeIn(); window.setTimeout(function(){ reset_popup.fadeOut(); }, 2000); //alert(response); } //Update Message popup jQuery.fn.center = function () { this.animate({"top":( jQuery(window).height() - this.height() - 200 ) / 2+jQuery(window).scrollTop() + "px"},100); this.css("left", 250 ); return this; } jQuery('#of-popup-save').center(); jQuery('#of-popup-reset').center(); jQuery(window).scroll(function() { jQuery('#of-popup-save').center(); jQuery('#of-popup-reset').center(); }); //AJAX Upload jQuery('.image_upload_button').each(function(){ var clickedObject = jQuery(this); var clickedID = jQuery(this).attr('id'); new AjaxUpload(clickedID, { action: '<?php echo admin_url("admin-ajax.php"); ?>', name: clickedID, // File upload name data: { // Additional data to send action: 'of_ajax_post_action', type: 'upload', data: clickedID }, autoSubmit: true, // Submit file after selection responseType: false, onChange: function(file, extension){}, onSubmit: function(file, extension){ clickedObject.text('Uploading'); // change button text, when user selects file this.disable(); // If you want to allow uploading only 1 file at time, you can disable upload button interval = window.setInterval(function(){ var text = clickedObject.text(); if (text.length < 13){ clickedObject.text(text + '.'); } else { clickedObject.text('Uploading'); } }, 200); }, onComplete: function(file, response) { window.clearInterval(interval); clickedObject.text('Upload Image'); this.enable(); // enable upload button // If there was an error if(response.search('Upload Error') > -1){ var buildReturn = '<span class="upload-error">' + response + '</span>'; jQuery(".upload-error").remove(); clickedObject.parent().after(buildReturn); } else{ var buildReturn = '<img class="hide of-option-image" id="image_'+clickedID+'" src="'+response+'" alt="" />'; jQuery(".upload-error").remove(); jQuery("#image_" + clickedID).remove(); clickedObject.parent().after(buildReturn); jQuery('img#image_'+clickedID).fadeIn(); clickedObject.next('span').fadeIn(); clickedObject.parent().prev('input').val(response); } } }); }); //AJAX Remove (clear option value) jQuery('.image_reset_button').click(function(){ var clickedObject = jQuery(this); var clickedID = jQuery(this).attr('id'); var theID = jQuery(this).attr('title'); var ajax_url = '<?php echo admin_url("admin-ajax.php"); ?>'; var data = { action: 'of_ajax_post_action', type: 'image_reset', data: theID }; jQuery.post(ajax_url, data, function(response) { var image_to_remove = jQuery('#image_' + theID); var button_to_hide = jQuery('#reset_' + theID); image_to_remove.fadeOut(500,function(){ jQuery(this).remove(); }); button_to_hide.fadeOut(); clickedObject.parent().prev('input').val(''); }); return false; }); /* Top save button jQuery(document).ready( function(){ // bind "click" event for links with title="submit" jQuery("a[title=submit]").click( function(){ // it submits the form it is contained within jQuery(this).parents("form").submit(); }); }); */ //Save everything else jQuery('#ofform').submit(function(){ function newValues() { var serializedValues = jQuery("#ofform").serialize(); return serializedValues; } jQuery(":checkbox, :radio").click(newValues); jQuery("select").change(newValues); jQuery('.ajax-loading-img').fadeIn(); var serializedReturn = newValues(); var ajax_url = '<?php echo admin_url("admin-ajax.php"); ?>'; //var data = {data : serializedReturn}; var data = { <?php if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'siteoptions'){ ?> type: 'options', <?php } ?> action: 'of_ajax_post_action', data: serializedReturn }; jQuery.post(ajax_url, data, function(response) { var success = jQuery('#of-popup-save'); var loading = jQuery('.ajax-loading-img'); loading.fadeOut(); success.fadeIn(); window.setTimeout(function(){ success.fadeOut(); }, 2000); }); return false; }); }); </script> <?php } } /*-----------------------------------------------------------------------------------*/ /* Ajax Save Action /*-----------------------------------------------------------------------------------*/ add_action('wp_ajax_of_ajax_post_action', 'of_ajax_callback'); function of_ajax_callback() { global $wpdb; // this is how you get access to the database $save_type = $_POST['type']; //Uploads if($save_type == 'upload'){ $clickedID = $_POST['data']; // Acts as the name $filename = $_FILES[$clickedID]; $filename['name'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', $filename['name']); $override['test_form'] = false; $override['action'] = 'wp_handle_upload'; $uploaded_file = wp_handle_upload($filename,$override); $upload_tracking[] = $clickedID; update_option( $clickedID , $uploaded_file['url'] ); if(!empty($uploaded_file['error'])) {echo 'Upload Error: ' . $uploaded_file['error']; } else { echo $uploaded_file['url']; } // Is the Response } elseif($save_type == 'image_reset'){ $id = $_POST['data']; // Acts as the name global $wpdb; $query = "DELETE FROM $wpdb->options WHERE option_name LIKE '$id'"; $wpdb->query($query); } elseif ($save_type == 'options' OR $save_type == 'framework') { $data = $_POST['data']; parse_str($data,$output); //print_r($output); //Pull options $options = get_option('of_template'); foreach($options as $option_array){ $id = $option_array['id']; $old_value = get_option($id); $new_value = ''; if(isset($output[$id])){ $new_value = $output[$option_array['id']]; } if(isset($option_array['id'])) { // Non - Headings... $type = $option_array['type']; if ( is_array($type)){ foreach($type as $array){ if($array['type'] == 'text'){ $id = $array['id']; $std = $array['std']; $new_value = $output[$id]; if($new_value == ''){ $new_value = $std; } update_option( $id, stripslashes($new_value)); } } } elseif($new_value == '' && $type == 'checkbox'){ // Checkbox Save update_option($id,'false'); } elseif ($new_value == 'true' && $type == 'checkbox'){ // Checkbox Save update_option($id,'true'); } elseif($type == 'multicheck'){ // Multi Check Save $option_options = $option_array['options']; foreach ($option_options as $options_id => $options_value){ $multicheck_id = $id . "_" . $options_id; if(!isset($output[$multicheck_id])){ update_option($multicheck_id,'false'); } else{ update_option($multicheck_id,'true'); } } } elseif($type != 'upload_min'){ update_option($id,stripslashes($new_value)); } } } ts_change_style_css(); } die(); } /*-----------------------------------------------------------------------------------*/ /* Cases fpr various option types /*-----------------------------------------------------------------------------------*/ function siteoptions_machine($options) { $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; //Start Heading if ( $value['type'] != "heading" ) { //========================================= PAYMENT =============================================//
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Untitled
2 hours ago | 2.28 KB
GSA NS
7 hours ago | 1.37 KB
WaterFul.m
MatLab | 9 hours ago | 0.42 KB
WaterEmpty.m
MatLab | 9 hours ago | 0.54 KB
Spinning.m
MatLab | 9 hours ago | 0.53 KB
Drying.m
MatLab | 9 hours ago | 0.48 KB
DoorCls.m
MatLab | 9 hours ago | 0.55 KB
Washing.m
MatLab | 9 hours ago | 0.45 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!