<?php

/**

     * Wordpress Extra Features

     * =========================

     *

*/



function BP_login_logo() { ?>

    <style type="text/css">

        #login h1 a, .login h1 a {

        background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/assets/img/logo/logo.png);

        }

 </style>

<?php }

add_action( 'login_enqueue_scripts', 'BP_login_logo' );



function BP_login_logo_url() {    return home_url();

}



add_filter( 'login_headerurl', 'BP_login_logo_url' );



function BP_login_logo_url_title() {

    return 'Relianurse';

}

add_filter( 'login_headertitle', 'BP_login_logo_url_title' );

function login_background() {
echo '<style type="text/css">
body { background: #2AABE1; }
.login form { background: #fff; }
</style>';
}
add_action('login_head', 'login_background');

/**

 * Generate custom search form

 *



 * @param string $form Form HTML.

 * @return string Modified form HTML.

 */



add_shortcode('magmt_custom_search', 'magmt_search');

add_filter( 'get_search_form' , 'magmt_search' );

function magmt_search( $form ) {

    $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . home_url( '/' ) . '" >

    <input type="text" class="form-control input-lg" value="'. get_search_query() .'" name="s" id="s" placeholder="' . __( 'Search Here', 'woocommerce' ) . '">

   <span class="input-group-btn">

    <button class="btn btn-info btn-lg" type="submit" value="'. esc_attr__( 'Search' ) .'">

                        <i class="fa fa-search"></i>

                    </button>

    </span> 

    </form>';

    return $form;

}



function BP_login_stylesheet() {

    wp_enqueue_style( 'custom-login', get_stylesheet_directory_uri().'/css/style-login.css' );
    //wp_enqueue_script( 'custom-login', get_stylesheet_directory_uri() . '/style-login.js' );

}

add_action( 'login_enqueue_scripts', 'BP_login_stylesheet' );

/**

     * Add Extra Fields on Setting General tab

     * =========================================

     *

*/

add_action('admin_init', 'my_general_section'); 

function my_general_section() {  

    add_settings_section(  

        'my_settings_section', // Section ID 

        'My Options:', // Section Title

        'my_section_options_callback', // Callback

        'general' // What Page?  This makes the section show up on the General Settings Page

    );

    add_settings_field( // Option 1

        'option_1', // Option ID

        'Facebook:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed (General Settings)

        'my_settings_section', // Name of our section

        array( // The $args

            'option_1' // Should match Option ID

        )  

    );

    add_settings_field( // Option 2

        'option_2', // Option ID

        'Twitter:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_2' // Should match Option ID

        ) 

    );



    /*add_settings_field( // Option 3

        'option_3', // Option ID

        'Linkedin:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_3' // Should match Option ID

        ) 

    );   */



    add_settings_field( // Option 4

        'option_4', // Option ID

        'Google Plus:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

           'option_4' // Should match Option ID

        )

    );

    add_settings_field( // Option 5

        'option_5', // Option ID

        'Pinterest:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_5' // Should match Option ID

        )

    );   



    /*add_settings_field( // Option 3

        'option_6', // Option ID

        'Working Hours:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_6' // Should match Option ID

        )

    );*/



    add_settings_field( // Option 3

        'option_61', // Option ID

        'Address:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_61' // Should match Option ID

        )

    );



    /*add_settings_field( // Option 3

        'option_7', // Option ID

        'Address 2:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_7' // Should match Option ID

        ) 



    );*/

     add_settings_field( // Option 3

        'option_71', // Option ID

        'Email :', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_71' // Should match Option ID

        ) 



    );



    add_settings_field( // Option 3

        'option_8', // Option ID

        'Phone:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_8' // Should match Option ID

        )

    );

    /*add_settings_field( // Option 3

        'option_81', // Option ID

        'Phone 2 :', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_81' // Should match Option ID

        )

    );*/

    add_settings_field( // Option 3

        'option_9', // Option ID

        'MAP Link 1:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_9' // Should match Option ID

        ) 

    );

    /*add_settings_field( // Option 10

        'option_10', // Option ID

        'MAP Link 2:', // Label

        'my_textbox_callback', // !important - This is where the args go!

        'general', // Page it will be displayed

        'my_settings_section', // Name of our section (General Settings)

        array( // The $args

            'option_10' // Should match Option ID

        ) 

    );*/

    register_setting('general','option_1', 'esc_attr');

    register_setting('general','option_2', 'esc_attr');

    register_setting('general','option_3', 'esc_attr');

    register_setting('general','option_4', 'esc_attr');

    register_setting('general','option_5', 'esc_attr');

    register_setting('general','option_6', 'esc_attr');

    register_setting('general','option_61', 'esc_attr');

    register_setting('general','option_7', 'esc_attr');

    register_setting('general','option_71', 'esc_attr');

    register_setting('general','option_8', 'esc_attr');

    register_setting('general','option_81', 'esc_attr');

    register_setting('general','option_9', 'esc_attr'); 

    register_setting('general','option_10', 'esc_attr');

}

function my_section_options_callback() { // Section Callback

    echo '<p>Print Extra Fields:  <strong>html_entity_decode( get_option( option_6 ) )</strong></p>';

}

function my_textbox_callback($args) {  // Textbox Callback

    $option = get_option($args[0]);

    echo '<input style="width:50%" type="text" id="'. $args[0] .'" name="'. $args[0] .'" value="' . $option . '" />  <strong>Print field content: </strong> html_entity_decode( get_option( '.$args[0].' ) )';

}



function remove_BP_menus(){

  //remove_menu_page( 'index.php' );                  //Dashboard

  //remove_menu_page( 'jetpack' );                    //Jetpack* 

  //remove_menu_page( 'edit.php' );                   //Posts

  //remove_menu_page( 'upload.php' );                 //Media

  //remove_menu_page( 'edit.php?post_type=page' );    //Pages

  remove_menu_page( 'edit-comments.php' );          //Comments  

  //remove_menu_page( 'themes.php' );                 //Appearance

  remove_menu_page( 'plugins.php' );                //Plugins

  //remove_menu_page( 'users.php' );                  //Users

  //remove_menu_page( 'tools.php' );                  //Tools

  //remove_menu_page( 'options-general.php' );        //Settings

}

add_action( 'admin_menu', 'remove_BP_menus' );





function custom_remove_slug( $post_link, $post, $leavename ) {

    if ( 'our_services' != $post->post_type || 'publish' != $post->post_status ) {

        return $post_link;

    }

    $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );

    return $post_link;

}



add_filter( 'post_type_link', 'custom_remove_slug', 10, 3 );



function custom_parse_request( $query ) {

    if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {

        return;

    }

    if ( ! empty( $query->query['name'] ) ) {

        $query->set( 'post_type', array( 'post', 'our_services', 'page' ) );

    }

}

add_action( 'pre_get_posts', 'custom_parse_request' );







