Advertisement
Guest User

Untitled

a guest
May 7th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. <?php
  2.  
  3. function init() {
  4. // Adds Thumbnails for supported
  5. add_theme_support( 'post-thumbnails' );
  6. // Customizes Tumbnail Size
  7. set_post_thumbnail_size( 150, 150 );
  8. add_image_size('Custom Imagesize', 0, 200, false);
  9.  
  10. // Only in frontend
  11. if (!is_admin()) {
  12. // Include Wordpress predefinded scripts
  13. wp_enqueue_script('jquery');
  14. wp_enqueue_script('jquery-ui');
  15. wp_enqueue_script('jquery-effects-core');
  16.  
  17. // Include custom defined Script
  18. wp_enqueue_script('html5shiv', '//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js');
  19.  
  20.  
  21. // Include custom defined style
  22. wp_enqueue_style('fontawsome', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
  23. // Include local style
  24. wp_enqueue_style('style', get_template_directory_uri() . '/style.css');
  25. }
  26.  
  27. // Register custom menu
  28. register_nav_menu('mymenu', 'Hauptmen&uuml;');
  29.  
  30. // Register custom post_type
  31. register_post_type('book', array(
  32. 'labels' => array(
  33. 'name' => __('B&uuml;cher'),
  34. 'singular_name' => __('Buch')
  35. ),
  36. 'public' => true,
  37. 'has_archive' => true,
  38. 'supports' => array('title', 'author', 'thumbnail', 'excerpt', 'isbn')
  39. ));
  40.  
  41. register_taxonomy(
  42. 'author', 'book', array(
  43. 'label' => __('Autor'),
  44. 'rewrite' => array('slug' => 'author'),
  45. 'hierarchical' => false,
  46. )
  47. );
  48.  
  49. // Register custom taxonomy
  50. register_taxonomy(
  51. 'genre', 'book', array(
  52. 'label' => __('Genre'),
  53. 'rewrite' => array('slug' => 'genre'),
  54. 'hierarchical' => true,
  55. )
  56. );
  57. }
  58. add_action('init', init);
  59.  
  60. function widgets_init() {
  61. register_sidebar(array(
  62. 'name' => 'Widget Area',
  63. 'id' => 'w_a',
  64. 'before_widget' => '<div class="widget">',
  65. 'after_widget' => '</div>',
  66. 'before_title' => '<h2 class="rounded">',
  67. 'after_title' => '</h2>',
  68. ));
  69. }
  70. add_action('widgets_init', 'widgets_init');
  71.  
  72. /**
  73. * Adds a box to the main column on the Post and Page edit screens.
  74. */
  75. function myplugin_add_meta_box() {
  76. add_meta_box('isbn','ISBN','myplugin_meta_box_callback');
  77. }
  78. add_action( 'add_meta_boxes', 'myplugin_add_meta_box' );
  79.  
  80. /**
  81. * Prints the box content.
  82. *
  83. * @param WP_Post $post The object for the current post/page.
  84. */
  85. function myplugin_meta_box_callback( $post ) {
  86.  
  87. // Add a nonce field so we can check for it later.
  88. wp_nonce_field( 'myplugin_meta_box', 'myplugin_meta_box_nonce' );
  89.  
  90. /*
  91. * Use get_post_meta() to retrieve an existing value
  92. * from the database and use the value for the form.
  93. */
  94. $value = get_post_meta( $post->ID, 'book_isbn', true );
  95.  
  96. echo '<label for="myplugin_new_field">';
  97. _e( 'ISBN', 'myplugin_textdomain' );
  98. echo '</label> ';
  99. echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field" value="' . esc_attr( $value ) . '" size="25" />';
  100. }
  101.  
  102. /**
  103. * When the post is saved, saves our custom data.
  104. *
  105. * @param int $post_id The ID of the post being saved.
  106. */
  107. function myplugin_save_meta_box_data( $post_id ) {
  108.  
  109. /*
  110. * We need to verify this came from our screen and with proper authorization,
  111. * because the save_post action can be triggered at other times.
  112. */
  113.  
  114. // Check if our nonce is set.
  115. if ( ! isset( $_POST['myplugin_meta_box_nonce'] ) ) {
  116. return;
  117. }
  118.  
  119. // Verify that the nonce is valid.
  120. if ( ! wp_verify_nonce( $_POST['myplugin_meta_box_nonce'], 'myplugin_meta_box' ) ) {
  121. return;
  122. }
  123.  
  124. // If this is an autosave, our form has not been submitted, so we don't want to do anything.
  125. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
  126. return;
  127. }
  128.  
  129. // Check the user's permissions.
  130. if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
  131.  
  132. if ( ! current_user_can( 'edit_page', $post_id ) ) {
  133. return;
  134. }
  135.  
  136. } else {
  137.  
  138. if ( ! current_user_can( 'edit_post', $post_id ) ) {
  139. return;
  140. }
  141. }
  142.  
  143. /* OK, it's safe for us to save the data now. */
  144.  
  145. // Make sure that it is set.
  146. if ( ! isset( $_POST['myplugin_new_field'] ) ) {
  147. return;
  148. }
  149.  
  150. // Sanitize user input.
  151. $my_data = sanitize_text_field( $_POST['myplugin_new_field'] );
  152.  
  153. // Update the meta field in the database.
  154. update_post_meta( $post_id, 'book_isbn', $my_data );
  155. }
  156. add_action( 'save_post', 'myplugin_save_meta_box_data' );
  157.  
  158. function wpFrame($title) {
  159. return '<i class="fa fa-wordpress"></i>' . $title . '<i class="fa fa-wordpress"></i>';
  160. }
  161. //add_filter('the_title', wpFrame);
  162. //add_filter('the_content', wpFrame);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement