Guest User

Untitled

a guest
May 22nd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.51 KB | None | 0 0
  1. <?php
  2. function remove_footer_admin () {
  3. echo "I'm in ur footer deleting the copyrights.";
  4. }
  5.  
  6. add_filter('admin_footer_text', 'remove_footer_admin');
  7. ?>
  8. <?php
  9. $themename = "Theme";
  10. $shortname = "theme";
  11. $options = array (
  12. array( "name" => "Settings",
  13. "type" => "title"),
  14. array( "type" => "open"),
  15.  
  16. array( "name" => "Header information:",
  17. "desc" => "Appears above navigation.",
  18. "id" => $shortname."_headerinfo",
  19. "std" => "",
  20. "type" => "text"),
  21. array( "name" => "Footer information:",
  22. "desc" => "Appears at the bottom of page.",
  23. "id" => $shortname."_footerinfo",
  24. "std" => "",
  25. "type" => "textarea"),
  26.  
  27. array( "name" => "Page Exclude:",
  28. "desc" => "Enter page ID# numbers to exclude from main menu.",
  29. "id" => $shortname."_page",
  30. "std" => "",
  31. "type" => "text"),
  32.  
  33. array( "name" => "Home Image 1:",
  34. "desc" => "Enter URL for image. Dimensions should be 960x425",
  35. "id" => $shortname."_image1",
  36. "std" => "",
  37. "type" => "text"),
  38. array( "name" => "Home Image 2:",
  39. "desc" => "Enter URL for image. Dimensions should be 960x425",
  40. "id" => $shortname."_image2",
  41. "std" => "",
  42. "type" => "text"),
  43. array( "name" => "Home Image 3:",
  44. "desc" => "Enter URL for image. Dimensions should be 960x425",
  45. "id" => $shortname."_image3",
  46. "std" => "",
  47. "type" => "text"),
  48. array( "name" => "Home Image 4:",
  49. "desc" => "Enter URL for image. Dimensions should be 960x425",
  50. "id" => $shortname."_image4",
  51. "std" => "",
  52. "type" => "text"),
  53. array( "name" => "Home Image 5:",
  54. "desc" => "Enter URL for image. Dimensions should be 960x425",
  55. "id" => $shortname."_image5",
  56. "std" => "",
  57. "type" => "text"),
  58.  
  59. array( "type" => "close")
  60. );
  61. function mytheme_add_admin() {
  62. global $themename, $shortname, $options;
  63. if ( $_GET['page'] == basename(__FILE__) ) {
  64. if ( 'save' == $_REQUEST['action'] ) {
  65. foreach ($options as $value) {
  66. update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  67. foreach ($options as $value) {
  68. if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
  69. header("Location: themes.php?page=functions.php&saved=true");
  70. die;
  71. } else if( 'reset' == $_REQUEST['action'] ) {
  72. foreach ($options as $value) {
  73. delete_option( $value['id'] ); }
  74. header("Location: themes.php?page=functions.php&reset=true");
  75. die;
  76. }
  77. }
  78. add_menu_page($themename." Settings", "".$themename." Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin');
  79. }
  80. function mytheme_admin() {
  81. global $themename, $shortname, $options;
  82. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  83. if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
  84. ?>
  85. <div class="wrap">
  86. <h2><?php echo $themename; ?> settings</h2>
  87. <form method="post">
  88. <?php foreach ($options as $value) {
  89. switch ( $value['type'] ) {case "open":?>
  90. <table width="100%" border="0">
  91. <br />
  92. <?php break;case "close":?>
  93. </table><br />
  94. <?php break;case "title":?>
  95. <table width="100%" border="0">
  96. <?php break;case 'text':?>
  97. <tr>
  98. <td width="20%"><?php echo $value['name']; ?></td>
  99. <td width="80%"><input style="width:200px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" /> <small><?php echo $value['desc']; ?></small></td>
  100. </tr>
  101. <tr><td colspan="2" style="margin-bottom:5px;">&nbsp;</td></tr>
  102. <?php break;case 'textarea':?>
  103. <tr>
  104. <td width="20%" rowspan="2" valign="middle"><?php echo $value['name']; ?></td>
  105. <td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:400px; height:80px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?></textarea></td>
  106. </tr>
  107. <tr>
  108. <td><small><?php echo $value['desc']; ?></small></td>
  109. </tr><tr><td colspan="2" style="margin-bottom:5px;">&nbsp;</td></tr>
  110. <?php break;case 'select':?>
  111. <tr>
  112. <td width="20%" rowspan="2" valign="middle"><?php echo $value['name']; ?></td>
  113. <td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
  114. </tr>
  115. <tr>
  116. <td><small><?php echo $value['desc']; ?></small></td>
  117. </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  118. <?php break;case "checkbox":?>
  119. <tr>
  120. <td width="20%"><?php echo $value['name']; ?></td>
  121. <td width="80%"><? if(get_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
  122. <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> /> <small><?php echo $value['desc']; ?></small></td>
  123. </tr>
  124. <tr><td colspan="2" style="margin-bottom:5px;">&nbsp;</td></tr>
  125. <?php break;} }?>
  126. <!--</table>-->
  127. <p class="submit">
  128. <input name="save" type="submit" value="Save changes" />
  129. <input type="hidden" name="action" value="save" />
  130. </p>
  131. </form>
  132. <?php } add_action('admin_menu', 'mytheme_add_admin'); ?>
  133. <?php //SIDEBAR GENERATOR (FOR SIDEBAR AND FOOTER)-----------------------------------------------
  134. if ( function_exists('register_sidebar') )
  135. register_sidebar(array('name'=>'Blog Widgets',
  136. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  137. 'after_widget' => '</li>',
  138. 'before_title' => '<h2 class="widgettitle">',
  139. 'after_title' => '</h2>',
  140. ));
  141. register_sidebar(array('name'=>'Contact Us Widgets',
  142. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  143. 'after_widget' => '</li>',
  144. 'before_title' => '<h2 class="widgettitle">',
  145. 'after_title' => '</h2>',
  146. ));
  147. ?>
  148. <?php
  149. $key = "key";
  150. $meta_boxes = array(
  151.  
  152. "custom_header" => array(
  153. "name" => "custom_header",
  154. "title" => "Post/Page Header Image URL",
  155. "description" => "Dimensions: Pages = 960x246. Portfolio = 960x460."),
  156.  
  157. "custom_option" => array(
  158. "name" => "custom_thumb",
  159. "title" => "Post/Page Image URL",
  160. "description" => "Dimensions: Pages = 399x266. Client Review posts = 370x245. Home posts = 100x100. Portfolio posts = 67x40."),
  161.  
  162. "custom_project" => array(
  163. "name" => "custom_project",
  164. "title" => "Type of project",
  165. "description" => "Example: Pool Construction"),
  166.  
  167. "custom_client" => array(
  168. "name" => "custom_client",
  169. "title" => "Client name",
  170. "description" => "Example: John Doe")
  171.  
  172. );
  173.  
  174. function create_meta_box() {
  175.  
  176. global $key;
  177.  
  178. if( function_exists( 'add_meta_box' ) ) {
  179.  
  180. add_meta_box( 'new-meta-boxes', ' Custom Post Options', 'display_meta_box', 'post', 'normal', 'high' );
  181. add_meta_box( 'new-meta-boxes', ' Custom Post Options', 'display_meta_box', 'page', 'normal', 'high' );
  182.  
  183.  
  184. }
  185.  
  186. }
  187.  
  188. function display_meta_box() {
  189.  
  190. global $post, $meta_boxes, $key;
  191. ?>
  192. <div class="form-wrap">
  193. <?php
  194.  
  195. wp_nonce_field( plugin_basename( __FILE__ ), $key . '_wpnonce', false, true );
  196.  
  197. foreach($meta_boxes as $meta_box) {
  198.  
  199. $data = get_post_meta($post->ID, $key, true);
  200. ?>
  201. <div class="form-field form-required">
  202.  
  203. <label for="<?php echo $meta_box[ 'name' ]; ?>"><?php echo $meta_box[ 'title' ]; ?></label>
  204.  
  205. <input type="text" name="<?php echo $meta_box[ 'name' ]; ?>" value="<?php echo htmlspecialchars( $data[ $meta_box[ 'name' ] ] ); ?>" />
  206.  
  207. <p><?php echo $meta_box[ 'description' ]; ?></p>
  208.  
  209. </div>
  210.  
  211. <?php } ?>
  212. </div>
  213. <?php
  214.  
  215. }
  216.  
  217. function save_meta_box( $post_id ) {
  218.  
  219. global $post, $meta_boxes, $key;
  220.  
  221. foreach( $meta_boxes as $meta_box ) {
  222.  
  223. $data[ $meta_box[ 'name' ] ] = $_POST[ $meta_box[ 'name' ] ];
  224.  
  225. }
  226.  
  227. if ( !wp_verify_nonce( $_POST[ $key . '_wpnonce' ], plugin_basename(__FILE__) ) )
  228.  
  229. return $post_id;
  230.  
  231. if ( !current_user_can( 'edit_post', $post_id ))
  232.  
  233. return $post_id;
  234.  
  235. update_post_meta( $post_id, $key, $data );
  236. }
  237.  
  238. add_action( 'admin_menu', 'create_meta_box' );
  239. add_action( 'save_post', 'save_meta_box' );
  240. ?>
Add Comment
Please, Sign In to add comment