Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function init() {
- // Adds Thumbnails for supported
- add_theme_support( 'post-thumbnails' );
- // Customizes Tumbnail Size
- set_post_thumbnail_size( 150, 150 );
- add_image_size('Custom Imagesize', 0, 200, false);
- // Only in frontend
- if (!is_admin()) {
- // Include Wordpress predefinded scripts
- wp_enqueue_script('jquery');
- wp_enqueue_script('jquery-ui');
- wp_enqueue_script('jquery-effects-core');
- // Include custom defined Script
- wp_enqueue_script('html5shiv', '//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js');
- // Include custom defined style
- wp_enqueue_style('fontawsome', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
- // Include local style
- wp_enqueue_style('style', get_template_directory_uri() . '/style.css');
- }
- // Register custom menu
- register_nav_menu('mymenu', 'Hauptmenü');
- // Register custom post_type
- register_post_type('book', array(
- 'labels' => array(
- 'name' => __('Bücher'),
- 'singular_name' => __('Buch')
- ),
- 'public' => true,
- 'has_archive' => true,
- 'supports' => array('title', 'author', 'thumbnail', 'excerpt', 'isbn')
- ));
- register_taxonomy(
- 'author', 'book', array(
- 'label' => __('Autor'),
- 'rewrite' => array('slug' => 'author'),
- 'hierarchical' => false,
- )
- );
- // Register custom taxonomy
- register_taxonomy(
- 'genre', 'book', array(
- 'label' => __('Genre'),
- 'rewrite' => array('slug' => 'genre'),
- 'hierarchical' => true,
- )
- );
- }
- add_action('init', init);
- function widgets_init() {
- register_sidebar(array(
- 'name' => 'Widget Area',
- 'id' => 'w_a',
- 'before_widget' => '<div class="widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="rounded">',
- 'after_title' => '</h2>',
- ));
- }
- add_action('widgets_init', 'widgets_init');
- /**
- * Adds a box to the main column on the Post and Page edit screens.
- */
- function myplugin_add_meta_box() {
- add_meta_box('isbn','ISBN','myplugin_meta_box_callback');
- }
- add_action( 'add_meta_boxes', 'myplugin_add_meta_box' );
- /**
- * Prints the box content.
- *
- * @param WP_Post $post The object for the current post/page.
- */
- function myplugin_meta_box_callback( $post ) {
- // Add a nonce field so we can check for it later.
- wp_nonce_field( 'myplugin_meta_box', 'myplugin_meta_box_nonce' );
- /*
- * Use get_post_meta() to retrieve an existing value
- * from the database and use the value for the form.
- */
- $value = get_post_meta( $post->ID, 'book_isbn', true );
- echo '<label for="myplugin_new_field">';
- _e( 'ISBN', 'myplugin_textdomain' );
- echo '</label> ';
- echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field" value="' . esc_attr( $value ) . '" size="25" />';
- }
- /**
- * When the post is saved, saves our custom data.
- *
- * @param int $post_id The ID of the post being saved.
- */
- function myplugin_save_meta_box_data( $post_id ) {
- /*
- * We need to verify this came from our screen and with proper authorization,
- * because the save_post action can be triggered at other times.
- */
- // Check if our nonce is set.
- if ( ! isset( $_POST['myplugin_meta_box_nonce'] ) ) {
- return;
- }
- // Verify that the nonce is valid.
- if ( ! wp_verify_nonce( $_POST['myplugin_meta_box_nonce'], 'myplugin_meta_box' ) ) {
- return;
- }
- // If this is an autosave, our form has not been submitted, so we don't want to do anything.
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
- return;
- }
- // Check the user's permissions.
- if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
- if ( ! current_user_can( 'edit_page', $post_id ) ) {
- return;
- }
- } else {
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
- return;
- }
- }
- /* OK, it's safe for us to save the data now. */
- // Make sure that it is set.
- if ( ! isset( $_POST['myplugin_new_field'] ) ) {
- return;
- }
- // Sanitize user input.
- $my_data = sanitize_text_field( $_POST['myplugin_new_field'] );
- // Update the meta field in the database.
- update_post_meta( $post_id, 'book_isbn', $my_data );
- }
- add_action( 'save_post', 'myplugin_save_meta_box_data' );
- function wpFrame($title) {
- return '<i class="fa fa-wordpress"></i>' . $title . '<i class="fa fa-wordpress"></i>';
- }
- //add_filter('the_title', wpFrame);
- //add_filter('the_content', wpFrame);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement