Как я могу включить мой внешний файл CSS в мой плагин - PullRequest
0 голосов
/ 21 мая 2019

Как я могу включить внешний файл CSS в мой плагин? Я много гуглю, но ничего не получается: ((

Плагин Wordpress, написанный на PHP

функциональные поля () { эхо '

    <div class="DodajWpis"> <h1> Dodaj wpis </h1> </div> 
    <form method="post" id="#form" action="" enctype="multipart/form-data">

        <label class="katalogLabelName" for="name">Nazwa</label>
        <input class="Input" id="name" type="text" style="width:50%;" name="nazwa" required>

        <label class="katalogLabelName" for="tytul">Tytul</label>
        <input class="Input" type="text" style="width:50%;" name="tytul">

        <label class="katalogLabelName" for="maincategory">Kategoria</label>
        <input class="Input" type="text" style="width:50%;" list="maincategory" name="maincategory">
        <datalist id="maincategory" required>';
            $args = array('show_option_none' => 'No Category','hide_empty' => 0);
            $kategorie = get_categories( $args );
            foreach ( $kategorie as $category ) :
                echo '<option value="' .$category->name . '">' . $category->name . '</option>';
            endforeach;
        echo  '</datalist>  

        <label class="katalogLabelName" for="location">Lokalizacja</label>
        <input class="Input" type="text" style="width:50%;" list="location" name="location">
        <datalist id="location" required>';
            //$args = array('show_option_none' => 'No Category','hide_empty' => 0);
            $lokalizacja = get_categories(array('taxonomy=>location'));
            foreach ( $lokalizacja as $term ) :
                echo '<option value="' .$term->name . '">' . $term->name . '</option>';
            endforeach;
        echo  '</datalist>  


        <label class="katalogLabelName"  for="slowa_kluczowe">Slowa kluczowe (Limit to '.returnme('slowa_klucz_limit').')</label>
        <input class="Input" type="text" style="width:50%;" name="slowa_kluczowe" id="slowa_kluczowe" required>

        <label class="katalogLabelName"  for="email">Adres e-mail</label>
        <input class="Input" type="email" style="width:50%;" name="email" id="email">

        <label class="katalogLabelName"  for="website">Adres strony internetowej</label>
        <input class="Input" type="url" style="width:50%;" id="website" name="website" required>

        <label class="katalogLabelName" for="miasto">Miasto</label>
        <input class="Input" type="text" style="width:50%;" name="miasto" id="miato">


        <input class="Wyslij" type="file" id="async-upload" name="html-upload" accept="image/png, image/jpeg" required >
        <br> 

        <label class="katalogLabelName"  for="textarea">Opis</label>
        <textarea id="textarea" style="width:50%;" name="opis" required></textarea>
        <input type="submit" value="wyslij" class="button">

    </form>
';

}
add_shortcode('form', 'fields');

как добавить внешний файл css?

Ответы [ 2 ]

0 голосов
/ 21 мая 2019

Вы должны использовать функции WordPress Enque для добавления CSS-файлов.

Во-первых, если вы хотите позвонить выше шорткод на Frotend. затем вводит css на интерфейс.

    add_action( 'wp_enqueue_style', 'add_frontend_css');

    function add_frontend_css (){
             wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/smoothness/jquery-ui.css', true);

    }

Если вы хотите добавить его в админ-панель, позвоните ниже ловушку.

    add_action( 'admin_enqueue_scripts', 'add_backend_css');

    function add_backend_css (){
             wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/smoothness/jquery-ui.css', true);

    }

Включая внутренний файл.

Если вы хотите добавить внутренний файл CSS, помещенный в корень плагина, используйте следующее.

 wp_enqueue_style( 'jquery-ui-style', plugins_url().'/style.css', true);

Если ваш файл CSS находится под текущей темой в каталоге css.

wp_enqueue_style( 'jquery-ui-style', get_template_directory_uri().'/css/style.css', true);
0 голосов
/ 21 мая 2019

Вы можете попробовать поставить это после echo` <link rel="stylesheet" href="https://example.com/css/style.css">

<link rel="stylesheet" href="https://example.com/css/style.css">

    <div class="DodajWpis"> <h1> Dodaj wpis </h1> </div> 
    <form method="post" id="#form" action="" enctype="multipart/form-data">

        <label class="katalogLabelName" for="name">Nazwa</label>
        <input class="Input" id="name" type="text" style="width:50%;" name="nazwa" required>

        <label class="katalogLabelName" for="tytul">Tytul</label>
        <input class="Input" type="text" style="width:50%;" name="tytul">

        <label class="katalogLabelName" for="maincategory">Kategoria</label>
        <input class="Input" type="text" style="width:50%;" list="maincategory" name="maincategory">
        <datalist id="maincategory" required>';
            $args = array('show_option_none' => 'No Category','hide_empty' => 0);
            $kategorie = get_categories( $args );
            foreach ( $kategorie as $category ) :
                echo '<option value="' .$category->name . '">' . $category->name . '</option>';
            endforeach;
        echo  '</datalist>  

        <label class="katalogLabelName" for="location">Lokalizacja</label>
        <input class="Input" type="text" style="width:50%;" list="location" name="location">
        <datalist id="location" required>';
            //$args = array('show_option_none' => 'No Category','hide_empty' => 0);
            $lokalizacja = get_categories(array('taxonomy=>location'));
            foreach ( $lokalizacja as $term ) :
                echo '<option value="' .$term->name . '">' . $term->name . '</option>';
            endforeach;
        echo  '</datalist>  


        <label class="katalogLabelName"  for="slowa_kluczowe">Slowa kluczowe (Limit to '.returnme('slowa_klucz_limit').')</label>
        <input class="Input" type="text" style="width:50%;" name="slowa_kluczowe" id="slowa_kluczowe" required>

        <label class="katalogLabelName"  for="email">Adres e-mail</label>
        <input class="Input" type="email" style="width:50%;" name="email" id="email">

        <label class="katalogLabelName"  for="website">Adres strony internetowej</label>
        <input class="Input" type="url" style="width:50%;" id="website" name="website" required>

        <label class="katalogLabelName" for="miasto">Miasto</label>
        <input class="Input" type="text" style="width:50%;" name="miasto" id="miato">


        <input class="Wyslij" type="file" id="async-upload" name="html-upload" accept="image/png, image/jpeg" required >
        <br> 

        <label class="katalogLabelName"  for="textarea">Opis</label>
        <textarea id="textarea" style="width:50%;" name="opis" required></textarea>
        <input type="submit" value="wyslij" class="button">

    </form>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...