{"id":233758,"date":"2023-02-22T19:13:00","date_gmt":"2023-02-22T16:13:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=233758"},"modified":"2022-11-11T12:14:23","modified_gmt":"2022-11-11T09:14:23","slug":"vse-pro-dodavannja-stiliv-i-skriptiv-u-wordpress","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/uk\/vse-pro-dodavannja-stiliv-i-skriptiv-u-wordpress\/","title":{"rendered":"\u0412\u0441\u0435 \u043f\u0440\u043e \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0441\u0442\u0438\u043b\u0456\u0432 \u0456 \u0441\u043a\u0440\u0438\u043f\u0442\u0456\u0432 \u0443 WordPress"},"content":{"rendered":"\n<p>WordPress \u043f\u0440\u043e\u043f\u043e\u043d\u0443\u0454 \u043a\u0456\u043b\u044c\u043a\u0430 \u043c\u0435\u0442\u043e\u0434\u0456\u0432 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0441\u0442\u0438\u043b\u0456\u0432 \u0456 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u0434\u043b\u044f \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u0442\u0430 \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430, \u044f\u043a \u0434\u043b\u044f \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0444\u0430\u0439\u043b\u0456\u0432, \u0442\u0430\u043a \u0456 \u0434\u043b\u044f \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0432\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0437\u043c\u0456\u043d\u043d\u0438\u0445\/\u0432\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f. \u0423 \u0446\u0456\u0439 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u0438 \u043a\u043e\u0434\u0443 \u0442\u043e\u0433\u043e, \u044f\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0434\u043e\u0434\u0430\u0432\u0430\u0442\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457 \u0442\u0430 \u0441\u0442\u0438\u043b\u0456 \u0434\u043e WordPress.<\/p>\n<p>\u0421\u0446\u0435\u043d\u0430\u0440\u0456\u0457 \u0442\u0430 \u0441\u0442\u0438\u043b\u0456 \u043c\u043e\u0436\u043d\u0430 \u0440\u0435\u0454\u0441\u0442\u0440\u0443\u0432\u0430\u0442\u0438 \u0442\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u0438 \u0432 \u0447\u0435\u0440\u0433\u0443 \u0448\u043b\u044f\u0445\u043e\u043c \u0432\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u0443\u043d\u0456\u043a\u0430\u043b\u044c\u043d\u0438\u0445 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0456\u0432 (\u0456\u0434\u0435\u043d\u0442\u0438\u0444\u0456\u043a\u0430\u0442\u043e\u0440\u0456\u0432, \u043f\u043e\u0434\u0456\u0431\u043d\u0438\u0445 \u0434\u043e \u0441\u043b\u0438\u0437\u043d\u044f\u043a\u0430), \u0449\u043e \u0434\u0430\u0454 \u0437\u043c\u043e\u0433\u0443 WordPress \u0443\u0441\u0443\u0432\u0430\u0442\u0438 \u0434\u0443\u0431\u043b\u0456\u043a\u0430\u0442\u0438, \u044f\u043a-\u043e\u0442 \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u0456 \u0431\u0456\u0431\u043b\u0456\u043e\u0442\u0435\u043a\u0438 jQuery, \u0456 \u043e\u0431\u0440\u043e\u0431\u043b\u044f\u0442\u0438 \u0437\u0430\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0456 (\u044f\u043a\u0438\u0439 \u0441\u0442\u0438\u043b\u044c \u0447\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0439 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0443\u0432\u0430\u0442\u0438 \u043f\u0435\u0440\u0435\u0434 \u0446\u0438\u043c \u0456 \u0442\u0438\u043c). .<\/p>\n<p>\u042f\u043a\u0449\u043e \u043d\u0435\u043c\u0430\u0454 \u043e\u0441\u043e\u0431\u043b\u0438\u0432\u043e\u0457 \u200b\u200b\u043f\u043e\u0442\u0440\u0435\u0431\u0438 \u0432 \u0440\u0435\u0454\u0441\u0442\u0440\u0430\u0446\u0456\u0457 \u0441\u0442\u0438\u043b\u0456\u0432 \u0430\u0431\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432, \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u0438 \u0457\u0445 \u0443 \u0447\u0435\u0440\u0433\u0443 \u043e\u0434\u0440\u0430\u0437\u0443, \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0432\u0448\u0438 \u0440\u0435\u0454\u0441\u0442\u0440\u0430\u0446\u0456\u044e. \u0422\u0430\u043a\u043e\u0436 \u043c\u043e\u0436\u043d\u0430 \u0441\u043a\u0430\u0441\u0443\u0432\u0430\u0442\u0438 \u0440\u0435\u0454\u0441\u0442\u0440\u0430\u0446\u0456\u044e \u0430\u0431\u043e \u0432\u0438\u0434\u0430\u043b\u0438\u0442\u0438 \u0441\u0442\u0438\u043b\u0456 \u0442\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457 \u0437 \u0447\u0435\u0440\u0433\u0438 (<code>wp_dequeue_script<\/code>\u0456 <code>wp_dequeue_style<\/code>), \u043f\u043e\u0441\u0438\u043b\u0430\u044e\u0447\u0438\u0441\u044c \u043d\u0430 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440. \u0417\u0430\u0437\u0432\u0438\u0447\u0430\u0439 \u0434\u043e\u043f\u043e\u043c\u0430\u0433\u0430\u0454 \u0434\u043e\u0434\u0430\u0442\u0438 \u0432\u0438\u0449\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u0443 \u043f\u0440\u0456\u043e\u0440\u0438\u0442\u0435\u0442 \u0445\u0443\u043a\u0430 (\u0449\u043e\u0431 \u0432\u0456\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0432\u0441\u044f \u043f\u0456\u0441\u043b\u044f \u0445\u0443\u043a\u0430, \u0434\u0435 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0438 \u0431\u0443\u043b\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0456 \u0432 \u0447\u0435\u0440\u0433\u0443).<\/p>\n<p>PS: \u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0441\u0442\u0438\u043b\u0456\u0432 \u0456 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u0434\u043e Gutenberg (\u044f\u043a \u0431\u043b\u043e\u043a\u0456\u0432 \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430, \u0442\u0430\u043a \u0456 \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443) \u043f\u043e\u044f\u0441\u043d\u044e\u0454\u0442\u044c\u0441\u044f \u0432 \u043c\u043e\u0457\u0439 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457 <a href=\"http:\/\/localhost\/awhitepixel\/blog\/gutenberg-the-basics\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">Gutenberg: The Basics<\/a>.<\/p>\n<h2>\u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u0456 \u0441\u0442\u0438\u043b\u0456\u0432 \u0434\u043e \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443<\/h2>\n<p>\u0429\u043e\u0431 \u0434\u043e\u0434\u0430\u0442\u0438 \u0441\u0442\u0438\u043b\u0456 \u0442\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457 \u043b\u0438\u0448\u0435 \u0434\u043e \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443, \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0439\u0442\u0435 \u0445\u0443\u043a <code>wp_enqueue_scripts<\/code>. \u041d\u0435\u0437\u0432\u0430\u0436\u0430\u044e\u0447\u0438 \u043d\u0430 \u043d\u0430\u0437\u0432\u0443 \u0445\u0443\u043a\u0430, \u0432\u0456\u043d \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u0442\u044c\u0441\u044f \u044f\u043a \u0434\u043b\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432, \u0442\u0430\u043a \u0456 \u0434\u043b\u044f \u0441\u0442\u0438\u043b\u0456\u0432. \u041e\u0441\u044c \u043f\u0440\u0438\u043a\u043b\u0430\u0434 \u0440\u043e\u0437\u043c\u0456\u0449\u0435\u043d\u043d\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0456 \u0441\u0442\u0438\u043b\u0456\u0432 \u0456 \u0444\u0430\u0439\u043b\u0443 javascript \u0443 \u0447\u0435\u0440\u0437\u0456 \u0432 \u0442\u0435\u043c\u0456:<\/p>\n<pre><code>add_action('wp_enqueue_scripts', function() {\n    \/\/ Styles\n    wp_enqueue_style('main-style', get_stylesheet_directory_uri().'\/style.css', [], '1.0');\n\u00a0\n    \/\/ Scripts\n    wp_enqueue_script('main-script', get_stylesheet_directory_uri().'\/assets\/js\/main.js', ['jquery'], '', true);\n});<\/code><\/pre>\n<p>\u0422\u0440\u0435\u0442\u0456\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0456 \u0434\u043b\u044f \u0441\u0442\u0438\u043b\u0456\u0432, \u0456 \u0434\u043b\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0456\u0432 \u2014 \u0446\u0435 \u043c\u0430\u0441\u0438\u0432 \u0456\u0437 \u0437\u0430\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, \u0434\u043b\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u0431\u0456\u0431\u043b\u0456\u043e\u0442\u0435\u043a\u0443 jQuery \u043f\u0435\u0440\u0435\u0434 \u0444\u0430\u0439\u043b\u043e\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u044e. <strong>\u041f\u0440\u0438\u043c\u0456\u0442\u043a\u0430<\/strong>: \u0456\u043d\u0441\u0442\u0430\u043b\u044f\u0446\u0456\u0457 WordPress \u043f\u043e\u0441\u0442\u0430\u0447\u0430\u044e\u0442\u044c\u0441\u044f \u0437 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u043f\u043e\u0448\u0438\u0440\u0435\u043d\u0438\u0445 \u0431\u0456\u0431\u043b\u0456\u043e\u0442\u0435\u043a \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 (\u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, jQuery, jQuery UI, Backbone \u0456 Underscore). \u041f\u043e\u043a\u0438 \u0432\u0438 \u0434\u043e\u0434\u0430\u0454\u0442\u0435 <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_enqueue_script\/#default-scripts-included-and-registered-by-wordpress\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">\u0431\u0443\u0434\u044c-\u044f\u043a\u0438\u0439 \u0456\u0437 \u0446\u0438\u0445 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0456\u0432<\/a> \u044f\u043a \u0437\u0430\u043b\u0435\u0436\u043d\u0456\u0441\u0442\u044c \u0443 \u0441\u0432\u043e\u0454\u043c\u0443 enqueue_script, WordPress \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0457\u0445 \u0443 \u0447\u0435\u0440\u0433\u0443, \u0442\u043e\u043c\u0443 \u0432\u0430\u043c \u043d\u0435 \u0434\u043e\u0432\u0435\u0434\u0435\u0442\u044c\u0441\u044f \u0434\u043e\u0434\u0430\u0432\u0430\u0442\u0438 \u0432\u043b\u0430\u0441\u043d\u0456 \u0444\u0430\u0439\u043b\u0438 \u0434\u043b\u044f \u0446\u0438\u0445 \u0431\u0456\u0431\u043b\u0456\u043e\u0442\u0435\u043a.<\/p>\n<p>\u041f&#8217;\u044f\u0442\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u043f\u043e\u043b\u044f\u0433\u0430\u0454 \u0432 \u0442\u043e\u043c\u0443, \u0447\u0438 \u0441\u043b\u0456\u0434 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0443\u0432\u0430\u0442\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0439 \u0443 \u043a\u0456\u043d\u0446\u0456 <code>&lt;body&gt;<\/code>(\u0443 \u043d\u0438\u0436\u043d\u044c\u043e\u043c\u0443 \u043a\u043e\u043b\u043e\u043d\u0442\u0438\u0442\u0443\u043b\u0456), \u0430 \u043d\u0435 \u0432\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0456 <code>&lt;head&gt;<\/code>\u0442\u0435\u0433\u0443.<\/p>\n<p>\u0414\u043b\u044f \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f \u0432 \u043f\u043b\u0430\u0433\u0456\u043d\u0456 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438 \u0456\u043d\u0448\u0456 \u043c\u0435\u0442\u043e\u0434\u0438 \u043e\u0442\u0440\u0438\u043c\u0430\u043d\u043d\u044f URL-\u0430\u0434\u0440\u0435\u0441\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0443, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434 <code>plugin_dir_url(__FILE__)<\/code>.<\/p>\n<h2>\u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0456\u0432 \u0456 \u0441\u0442\u0438\u043b\u0456\u0432 \u0432 \u0430\u0434\u043c\u0456\u043d\u043a\u0443<\/h2>\n<p>WordPress \u043f\u0440\u043e\u043f\u043e\u043d\u0443\u0454 \u0449\u0435 \u043e\u0434\u0438\u043d \u0433\u0430\u0447\u043e\u043a, <code>admin_enqueue_scripts<\/code>\u0434\u043b\u044f \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0441\u0442\u0438\u043b\u0456\u0432 \u0456 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u043b\u0438\u0448\u0435 \u0434\u043b\u044f \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430. \u0412\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0439\u0442\u0435 \u0442\u0456 \u0441\u0430\u043c\u0456 \u043c\u0435\u0442\u043e\u0434\u0438, \u0449\u043e \u0439 \u0432\u0438\u0449\u0435, \u0434\u043b\u044f \u0440\u0435\u0454\u0441\u0442\u0440\u0430\u0446\u0456\u0457, \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432 \u0447\u0435\u0440\u0433\u0443 \u0442\u0430 \u043b\u043e\u043a\u0430\u043b\u0456\u0437\u0430\u0446\u0456\u0457 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u0456 \u0441\u0442\u0438\u043b\u0456\u0432:<\/p>\n<pre><code>add_action('admin_enqueue_scripts', function() {\n    global $pagenow, $post_type;\n    \/\/ Example: $hook == 'edit.php'\n    \/\/ Example: $post_type == 'post'\n    \/\/ wp_enqueue_style or wp_enqueue_script\n});<\/code><\/pre>\n<h2>\u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0456\u0432 \u0456 \u0441\u0442\u0438\u043b\u0456\u0432 \u043d\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0443 \u0432\u0445\u043e\u0434\u0443<\/h2>\n<p>\u041e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u0436\u043e\u0434\u0435\u043d \u0456\u0437 \u0437\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0445 \u0432\u0438\u0449\u0435 \u0445\u0443\u043a\u0456\u0432 \u043d\u0435 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0430\u0454\u0442\u044c\u0441\u044f \u043d\u0430 \u0435\u043a\u0440\u0430\u043d\u0456 \u0432\u0445\u043e\u0434\u0443 \u0430\u0434\u043c\u0456\u043d\u0456\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430, WordPress \u043f\u0440\u043e\u043f\u043e\u043d\u0443\u0454 \u0434\u043b\u044f \u0446\u0456\u0454\u0457 \u043c\u0435\u0442\u0438 \u043e\u043a\u0440\u0435\u043c\u0438\u0439 \u0445\u0443\u043a <code>login_enqueue_scripts<\/code>.<\/p>\n<pre><code>add_action('login_enqueue_scripts', function() {\n    \/\/ wp_enqueue_style or wp_enqueue_script\n});<\/code><\/pre>\n<h2>\u0412\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0437\u043c\u0456\u043d\u043d\u0438\u0445 Javascript<\/h2>\n<p>\u0414\u043b\u044f \u0432\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0437\u043c\u0456\u043d\u043d\u0438\u0445 Javascript (\u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, \u043e\u0442\u0440\u0438\u043c\u0430\u043d\u043d\u044f \u0448\u043b\u044f\u0445\u0456\u0432, \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u0435\u043d\u0438\u0445 \u0440\u044f\u0434\u043a\u0456\u0432 \u0430\u0431\u043e \u0456\u043d\u0448\u0438\u0445 \u0437\u043c\u0456\u043d\u043d\u0438\u0445, \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438 wp_localize_script. \u0426\u044f \u0444\u0443\u043d\u043a\u0446\u0456\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0454 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u044e \u0432 \u0447\u0435\u0440\u0437\u0456. \u0414\u0440\u0443\u0433\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0431\u0443\u0434\u0435 \u0456\u043c\u2019\u044f \u0437\u043c\u0456\u043d\u043d\u043e\u0457, \u0430 \u0442\u0440\u0435\u0442\u0456\u043c \u0457\u0457 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f. \u0417\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u043c\u043e\u0436\u0435 \u0431\u0443\u0442\u0438 \u043c\u0430\u0441\u0438\u0432\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434 :<\/p>\n<pre><code>add_action('wp_enqueue_scripts', function() {\n    \/\/ wp_enqueue_script('main-script');  \/\/ Must exist!\n    $variable_to_js = [\n        'ajax_url' =&gt; admin_url('admin-ajax.php')\n    ];\n    wp_localize_script('main-script', 'Theme_Variables', $variable_to_js);\n});<\/code><\/pre>\n<p>\u0423 \u0432\u0430\u0448\u043e\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0456 \u0432\u0438 \u043c\u0430\u0454\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0438\u0445 \u0437\u043c\u0456\u043d\u043d\u0438\u0445, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434:<\/p>\n<pre><code>jQuery(document).ready(function($) { \n    console.log(Theme_Variables.ajax_url);\n});<\/code><\/pre>\n<p>\u0423 \u0446\u044c\u043e\u043c\u0443 \u0445\u0443\u043a\u0443 \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0438\u0445 \u0437\u043c\u0456\u043d\u043d\u0438\u0445 <code>$pagenow<\/code>\u0456 <code>$post_type<\/code>\u0434\u043e\u0434\u0430\u0442\u043a\u043e\u0432\u043e \u0432\u043a\u0430\u0437\u0430\u0442\u0438, \u043a\u0443\u0434\u0438 \u0432\u0438 \u0445\u043e\u0447\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u0438 \u0441\u0432\u043e\u0457 \u0441\u0442\u0438\u043b\u0456 \u0442\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457.<\/p>\n<h2>\u0412\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0432\u0431\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0445 \u0441\u0442\u0438\u043b\u0456\u0432<\/h2>\n<p>\u042f\u043a\u0449\u043e \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0432\u0438\u0432\u0435\u0441\u0442\u0438 \u0432\u0431\u0443\u0434\u043e\u0432\u0430\u043d\u0456 \u0441\u0442\u0438\u043b\u0456, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, \u0434\u043b\u044f \u0437\u043c\u0456\u043d\u043d\u0438\u0445 \u0442\u0435\u043c\u0438, \u044f\u043a\u0456 \u0432\u0438 \u0432\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u044e\u0432\u0430\u0447\u0456 (\u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e <code>get_theme_mod<\/code>), \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0432\u0435\u0441\u0442\u0438 \u0457\u0445 \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e <code>wp_add_inline_style<\/code>\u0444\u0443\u043d\u043a\u0446\u0456\u0457. \u0426\u0435 \u043f\u0440\u0430\u0446\u044e\u0454 \u043f\u043e\u0434\u0456\u0431\u043d\u043e \u0434\u043e \u0432\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0437\u043c\u0456\u043d\u043d\u0438\u0445 Javascript, \u0443 \u044f\u043a\u0438\u0445 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u043d\u0430\u0434\u0430\u0442\u0438 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0441\u0442\u0438\u043b\u044e \u0432 \u0447\u0435\u0440\u0437\u0456:<\/p>\n<pre><code>add_action('wp_enqueue_scripts', function() {\n    \/\/ wp_enqueue_style('main-style');  \/\/ Must exist!\n\u00a0\n    $color = get_theme_mod('my-custom-color');  \/\/ e.g. #FF0000\n    $custom_css = \"\n        body {\n            background: {$color};\n        }\";\n        wp_add_inline_style('main-style', $custom_css);\n});<\/code><\/pre>\n<h2>\u0414\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0438\u0445 \u0442\u0435\u0433\u0456\u0432 \u0434\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432<\/h2>\n<p>\u041d\u0430 \u0436\u0430\u043b\u044c, \u043d\u0435\u043c\u0430\u0454 \u043f\u0440\u044f\u043c\u043e\u0457 \u0444\u0443\u043d\u043a\u0446\u0456\u0457 \u0447\u0438 \u0444\u0456\u043b\u044c\u0442\u0440\u0430, \u044f\u043a\u0438\u0439 \u043c\u043e\u0436\u043d\u0430 \u0434\u043e\u0434\u0430\u0442\u0438 <code>async<\/code>\u0434\u043e \u0432\u0430\u0448\u0438\u0445 \u0442\u0435\u0433\u0456\u0432 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u044e, \u0430\u043b\u0435 \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0434\u043e\u0441\u044f\u0433\u0442\u0438 \u0446\u044c\u043e\u0433\u043e, \u043c\u0430\u043d\u0456\u043f\u0443\u043b\u044e\u044e\u0447\u0438 \u0440\u044f\u0434\u043a\u043e\u043c, \u044f\u043a\u0438\u0439 WordPress \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454 \u0434\u043b\u044f \u0432\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0442\u0435\u0433\u0456\u0432 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u044e \u0434\u043b\u044f \u0432\u0441\u0456\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u0443 \u0447\u0435\u0440\u0437\u0456, \u043e\u0441\u044c \u0442\u0430\u043a (\u043d\u0435 \u0437\u0430\u0431\u0443\u0432\u0430\u0439\u0442\u0435 \u0432\u043a\u0430\u0437\u0443\u0432\u0430\u0442\u0438 \u0441\u0432\u0456\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0439 \u0437\u0430 \u0439\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u043e\u043c):<\/p>\n<pre><code>add_filter('script_loader_tag', function($tag, $handle, $src) {\n    if ('main-script' != $handle) {\n        return $tag;\n    }\n    return str_replace('&lt;script', '&lt;script async', $tag);\n}, 11, 3);<\/code><\/pre>\n<h2>\u041a\u043e\u0440\u0438\u0441\u043d\u0456 \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0456\u044e<\/h2>\n<ul>\n<li><a href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/wp_enqueue_scripts\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">wp_enqueue_scripts<\/a> (\u0445\u0443\u043a)<\/li>\n<li><a href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/admin_enqueue_scripts\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">admin_enqueue_scripts<\/a> (\u0445\u0443\u043a)<\/li>\n<li><a href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/login_enqueue_scripts\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">login_enqueue_scripts<\/a> (\u0445\u0443\u043a)<\/li>\n<li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_enqueue_style\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">wp_enqueue_style<\/a><\/li>\n<li><a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_dequeue_style\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">wp_dequeue_style<\/a><\/li>\n<li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_enqueue_script\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">wp_enqueue_script<\/a><\/li>\n<li><a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_dequeue_script\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">wp_dequeue_script<\/a><\/li>\n<li><a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_localize_script\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">wp_localize_script<\/a><\/li>\n<li><a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_add_inline_style\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">wp_add_inline_style<\/a><\/li>\n<\/ul>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">\u0414\u0436\u0435\u0440\u0435\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0443:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/awhitepixel.com\" class=\"external external_icon\">awhitepixel.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0423 \u0446\u044c\u043e\u043c\u0443 \u0434\u043e\u043f\u0438\u0441\u0456 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u0438 \u043a\u043e\u0434\u0443 \u0442\u043e\u0433\u043e, \u044f\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0434\u043e\u0434\u0430\u0442\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457 \u0442\u0430 \u0441\u0442\u0438\u043b\u0456 \u0434\u043e WordPress, \u044f\u043a \u0444\u0430\u0439\u043b\u0438, \u0442\u0430\u043a \u0456 \u0432\u0438\u0445\u0456\u0434\u043d\u0456 \u0437\u043c\u0456\u043d\u043d\u0456.<\/p>\n","protected":false},"author":1,"featured_media":224083,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[902,725,1110,808,808,839,933,869,869,839,902,849,725,933],"tags":[1174],"class_list":["post-233758","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kod-3","category-rozrobnyk","category-n-a","category-php-10","category-kerivnytstvo-dlia-pochatkivtsiv","category-predmetiv","category-wordpress-10","category-pidruchnyky","tag-affiai-uk"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/233758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/comments?post=233758"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/233758\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media\/224083"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media?parent=233758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/categories?post=233758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/tags?post=233758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}