Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //create custom admin menu's
- // add the main menu
- add_action('admin_menu', 'my_theme_menu');
- function my_theme_menu(){
- // the settings
- $page_title = "My Themes Admin";
- $menu_title = "Theme Settings";
- /*
- * Please not that this changed in the latest wordpress
- * versions from a number to words for user capabilities.
- * This would of been 7 but now you should use 'administrator'.
- */
- $capability = 'administrator';
- $menu_slug = "theme-settings";
- $function = "main_theme_menu_plugin";
- $icon_url = ""; // could be anything jpg, png, gif
- $position = '5';
- add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); // create the menu
- }
- wp_enqueue_script( 'jquery' ); //this code here enables jquery
- // Here we add the jQuery UI script to our theme header
- wp_register_script( 'jquery-ui-script', plugins_url('/js/jquery-ui-1.8.16.custom.min.js', __FILE__)); //this part registers the new script
- wp_enqueue_script( 'jquery-ui-script' ); //this part puts the script in to our page header
- // Here we add the jQuery UI theme Css to our header
- $myThemeStyleUrl = plugins_url('/css/ui-lightness/jquery-ui-1.8.16.custom.css', __FILE__); //set the path to our css
- wp_enqueue_style('jquery-ui-style', $myThemeStyleUrl,'1.0','screen'); // this puts the css in the header
- // Here we add the code that enables the tabbed menu
- add_action('admin_head', 'enableTabMenu_plugin');
- function enableTabMenu_plugin(){
- ?>
- <script type="text/javascript">
- jQuery(function() {
- jQuery( '#tabs' ).tabs();
- });
- </script>
- <?php
- }
- function main_theme_menu_plugin() {
- ?>
- <?php
- // Social Settings Page
- function socialSettings(){
- $social = '
- <div id="social-settings">' . settings_fields( 'ty-option-group' ) . '
- <h2>Social Settings</h2>
- <div id="social-wrapper"><form action="" method="post" name="socialform"><label for="facebook">Facebook: </label><input id="facebook" type="text" name="facebook" value="' . get_option('ty-facebook') . '" /><a href="' . get_option('ty-facebook') .'"><img src="' .get_bloginfo('template_url') .'/images/social/facebook.png" alt="facebook" /></a>
- <label for="twitter">Twitter: </label><input id="twitter" type="text" name="twitter" value="'. get_option('ty-twitter') .'" /><a href="' . get_option('ty-twitter') .'"><img src="'. get_bloginfo('template_url') .'/images/social/twitter.png" alt="twitter" /></a>
- <label for="linkedin">LinkedIn: </label><input id="linkedin" type="text" name="linkedin" value="' . get_option('ty-linkedin') .'" /><a href="' . get_option('ty-linkedin') .'"><img src="'. get_bloginfo('template_url') .'/images/social/linkedin.png" alt="linkedin" /></a>
- <label for="flickr">Flickr: </label><input id="flickr" type="text" name="flickr" value="'. get_option('ty-flickr') .'" /><a href="'. get_option('ty-flickr') .'"><img src="'. get_bloginfo('template_url') .'/images/social/flickr.png" alt="flickr" /></a>
- <label for="skype">Skype: </label><input id="skype" type="text" name="skype" value="'. get_option('ty-skype') .'" /><a href="'. get_option('ty-skype') .'"><img src="'. get_bloginfo('template_url') .'/images/social/skype.png" alt="skype" /></a>
- <input id="social-button" class="button-primary" style="margin-top: 10px;" type="button" value="Save Social" />
- </form></div>
- </div>
- ';
- return $social;
- }
- // Save Social Settings Data
- add_action('wp_ajax_slider_my_action', 'saveSocialSettings'); //ajax callback
- function saveSocialSettings() {
- // set default values
- if(get_option('ty-facebook') == ""){
- update_option( 'ty-facebook', 'Facebook URL...');
- }
- if(get_option('ty-twitter') == ""){
- update_option('ty-twitter', 'Twitter URL...');
- }
- if(get_option('ty-linkedin') == ''){
- update_option('ty-linkedin', 'Linkedin URL...');
- }
- if(get_option('ty-flickr') == ''){
- update_option('ty-flickr', 'Flickr URL...');
- }
- if(get_option('ty-skype') == ''){
- update_option('ty-skype', 'Skype URL...');
- }
- // Save data to option fields
- if(! empty($_POST)){
- $facebook = $_POST['ty_facebook'];
- $twitter = $_POST['ty_twitter'];
- $linkedin = $_POST['ty_linkedin'];
- $flickr = $_POST['ty_flickr'];
- $skype = $_POST['ty_skype'];
- // save the form values to the option fields
- update_option( 'ty-facebook', $facebook);
- update_option( 'ty-twitter', $twitter);
- update_option( 'ty-linkedin', $linkedin);
- update_option( 'ty-flickr', $flickr);
- update_option( 'ty-skype', $skype);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement