{"id":112,"date":"2022-06-11T15:47:30","date_gmt":"2022-06-11T12:47:30","guid":{"rendered":"https:\/\/onstartup.ru\/forum\/lajk-i-dizlajk-v-postah-wordpress\/"},"modified":"2022-11-19T04:35:01","modified_gmt":"2022-11-19T01:35:01","slug":"lajk-i-dizlajk-v-postah-wordpress","status":"publish","type":"post","link":"https:\/\/onstartup.ru\/forum\/lajk-i-dizlajk-v-postah-wordpress\/","title":{"rendered":"\u041b\u0430\u0439\u043a \u0438 \u0414\u0438\u0437\u043b\u0430\u0439\u043a \u0432 \u043f\u043e\u0441\u0442\u0430\u0445 WordPress"},"content":{"rendered":"<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0432\u0430\u0448 \u043f\u043e\u0441\u0442 \u043d\u0430 <strong>WordPress<\/strong> \u0431\u0435\u0437 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043d\u0435\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u043d\u0438\u0436\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u044d\u0442\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f <em>back-end<\/em>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u043a\u043e\u0434 jQuery \u043d\u0430 <em>front-end<\/em>. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e Ajax, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 \u0434\u0432\u0438\u0436\u043a\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041a\u043b\u0430\u0441\u0441\u044b CSS \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f <strong>Twitter Bootstrap 5<\/strong>.<\/p>\n<h2>\u0420\u0430\u0437\u043c\u0435\u0442\u043a\u0430 HTML<\/h2>\n<p>\u041f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u0435 \u043a\u043e\u0434 \u0432 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0442\u0435\u043c\u044b \u0444\u0430\u0439\u043b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f <code>single.php<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: <code>\u0442\u0435\u043c\u0430\/template-parts\/content-single.php<\/code>.<\/p>\n<pre class=\"line-numbers language-php\" tabindex=\"0\"><code>&lt;?php if ( 'publish' === get_post_status() ) : ?&gt;\r\n\r\n\t&lt;div id=\"post-votes\" class=\"btn-group align-items-end h-100 invisible\" role=\"group\" aria-label=\"Post votes\"&gt;\r\n\t\t&lt;button type=\"button\" class=\"btn btn-sm border-0 p-0\"&gt;&lt;span class=\"dashicons dashicons-thumbs-up\"&gt;&lt;\/span&gt;&lt;\/button&gt;\r\n\t\t&lt;button type=\"button\" class=\"btn btn-sm border-0 p-0 px-2 disabled\"&gt;0&lt;\/button&gt;\r\n\t\t&lt;button type=\"button\" class=\"btn btn-sm border-0 p-0\"&gt;&lt;span class=\"dashicons dashicons-thumbs-down\"&gt;&lt;\/span&gt;&lt;\/button&gt;\r\n\t&lt;\/div&gt;\r\n\r\n&lt;?php endif; ?&gt;<\/code><\/pre>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 back-end<\/h2>\n<p>\u041e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>functions.php<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u0442\u0435\u043c\u044b WP.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 <code>main.js<\/code> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 JavaScript, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0449\u0438\u0442\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 <code>'ajax-nonce'<\/code> \u0432 \u0445\u0443\u043a <code>'wp_enqueue_scripts'<\/code>:<\/p>\n<pre class=\"line-numbers language-php\" tabindex=\"0\"><code>\/**\r\n * Enqueue scripts and styles.\r\n *\/\r\nfunction os_scripts() {\r\n\twp_enqueue_style( 'dashicons' );\r\n\twp_enqueue_script( 'main-js', get_template_directory_uri() . '\/assets\/js\/main.js', array( 'jquery' ), '1.0', true );\r\n\r\n\twp_localize_script(\r\n\t\t'main-js',\r\n\t\t'os_ajax',\r\n\t\tarray(\r\n\t\t\t'ajax_url'   =&gt; admin_url( 'admin-ajax.php' ),\r\n\t\t\t'ajax_nonce' =&gt; wp_create_nonce( 'ajax-nonce' ),\r\n\t\t)\r\n\t);\r\n}\r\nadd_action( 'wp_enqueue_scripts', 'os_scripts' );<\/code><\/pre>\n<ul>\n<li>\u0410\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 CMS \u043d\u0430\u0431\u043e\u0440 SVG \u0438\u043a\u043e\u043d\u043e\u043a <code>'dashicons'<\/code>.<\/li>\n<li>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: <code>\u0432\u0430\u0448\u0430_\u0442\u0435\u043c\u0430\/assets\/js\/main.js<\/code>. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 jQuery \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/li>\n<li>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>'wp_localize_script'<\/code> \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 <code>'main-js'<\/code>, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0449\u0438\u0442\u0443. \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>'os_ajax'<\/code> \u2013 \u044d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 JavaScript-\u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 <em>front-end<\/em>. \u0410 \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 <code>'admin-ajax.php'<\/code> \u0438 \u0441\u0430\u043c \u043a\u043e\u0434 \u0437\u0430\u0449\u0438\u0442\u044b <code>'ajax-nonce'<\/code>.<\/li>\n<\/ul>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442 \u0444\u0430\u0439\u043b \u043a\u0443\u043a\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0449\u0451\u043d \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 PHP, \u0432 \u043d\u0451\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f ID \u043f\u043e\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0438 \u041b\u0430\u0439\u043a \u0438 \u0414\u0438\u0437\u043b\u0430\u0439\u043a. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u043a\u0440\u044b\u0442\u043e\u0435 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u0435\u0442\u0430-\u043f\u043e\u043b\u0435 <code>'_os_post_votes'<\/code>, \u0442\u0430\u043c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044e <code>'os_votes_cookie'<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0435\u0451 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 (\u0434\u043b\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438):<\/p>\n<pre class=\"line-numbers language-php\" tabindex=\"0\"><code>\/**\r\n * Update meta and set cookie array.\r\n *\r\n * @param  string $tax Taxonomy type (only 'post' or 'comment').\r\n * @param  int    $id  Current 'post' or 'comment' ID.\r\n * @return int         Votes count.\r\n *\/\r\nfunction os_votes_cookie( $tax, $id ) {\r\n\tif ( 'post' !== $tax &amp;&amp; 'comment' !== $tax ) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t$cookie_name  = \"{$tax}_votes_\" . COOKIEHASH;\r\n\t$cookie_array = ( isset( $_COOKIE[ $cookie_name ] ) ) ? maybe_unserialize( $_COOKIE[ $cookie_name ] ) : array();\r\n\r\n\tif ( ! is_array( $cookie_array ) || in_array( $id, $cookie_array ) || ! isset( $_POST['status'] ) ) {\r\n\t\twp_send_json_error();\r\n\t}\r\n\r\n\t$field_type  = \"_os_{$tax}_votes\";\r\n\t$votes_meta  = ( 'post' === $tax ) ? get_post_meta( $id, $field_type, true ) : get_comment_meta( $id, $field_type, true );\r\n\t$votes       = ( ! empty( $votes_meta ) ) ? intval( $votes_meta ) : 0;\r\n\t$count       = ( 'dislike' === $_POST['status'] ) ? -1 : 1;\r\n\t$output      = ( $votes + $count );\r\n\t$cookie_life = ( time() + ( 30 * DAY_IN_SECONDS ) );\r\n\r\n\tif ( 'post' === $tax ) {\r\n\t\tupdate_post_meta( $id, $field_type, $output );\r\n\t} elseif ( 'comment' === $tax ) {\r\n\t\tupdate_comment_meta( $id, $field_type, $output );\r\n\t}\r\n\r\n\tarray_push( $cookie_array, $id );\r\n\tsetcookie( $cookie_name, serialize( $cookie_array ), $cookie_life, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );\r\n\r\n\treturn $output;\r\n}\r\n\r\n\/**\r\n * AJAX post votes.\r\n *\/\r\nfunction os_ajax_post_votes() {\r\n\tcheck_ajax_referer( 'ajax-nonce', 'nonce_code' );\r\n\r\n\tif ( ! isset( $_POST['onload'] ) ) {\r\n\t\twp_send_json_error();\r\n\t}\r\n\r\n\t$output  = 0;\r\n\t$referer = wp_get_referer();\r\n\t$post_id = url_to_postid( $referer );\r\n\r\n\tif ( 'false' === $_POST['onload'] ) {\r\n\t\t$output = os_votes_cookie( 'post', $post_id );\r\n\t} else {\r\n\t\t$output = intval( get_post_meta( $post_id, '_os_post_votes', true ) );\r\n\t}\r\n\r\n\twp_send_json_success( $output );\r\n}\r\nadd_action( 'wp_ajax_post_votes', 'os_ajax_post_votes' );\r\nadd_action( 'wp_ajax_nopriv_post_votes', 'os_ajax_post_votes' );<\/code><\/pre>\n<h3>\u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u043e\u0432<\/h3>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 JS \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>'os-mobile'<\/code>, \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u0437\u0430\u0448\u0451\u043b \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0442\u0430\u043c \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 Tooltip. \u041a\u043b\u0430\u0441\u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c:<\/p>\n<pre class=\"line-numbers language-php\" tabindex=\"0\"><code>\/**\r\n * Filters the list of CSS body class names for the current post or page.\r\n *\r\n * @param  string[] $classes An array of body class names.\r\n * @return string[]          An array with new body classes.\r\n *\/\r\nfunction os_mobile_body_class( $classes ) {\r\n\tif ( wp_is_mobile() ) {\r\n\t\t$classes[] = 'os-mobile';\r\n\t}\r\n\r\n\treturn $classes;\r\n}\r\nadd_filter( 'body_class', 'os_mobile_body_class' );<\/code><\/pre>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 front-end<\/h2>\n<p>\u041e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>\u0442\u0435\u043c\u0430\/assets\/js\/main.js<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435, \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre class=\"line-numbers language-javascript\" tabindex=\"0\"><code>\/**\r\n * File main.js.\r\n *\/\r\n\r\n( function ( $ ) {\r\n\t$( document ).ready( function () {\r\n\r\n\t\t\/\/ Votes Tooltip helper.\r\n\t\tfunction osVotedTip( a, b ) {\r\n\t\t\t$( a ).tooltip( {\r\n\t\t\t\ttitle: '\u041e\u0446\u0435\u043d\u043a\u0430 \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u0430!',\r\n\t\t\t} ).tooltip( 'show' );\r\n\r\n\t\t\t$( b ).on( 'mouseleave', function () {\r\n\t\t\t\t$( a ).tooltip( 'dispose' );\r\n\t\t\t} );\r\n\t\t}\r\n\r\n\t\t\/\/ Create an AJAX request.\r\n\t\tfunction osAjaxRequest( action, onload = 'true', status = 'like' ) {\r\n\t\t\treturn $.ajax( {\r\n\t\t\t\turl: os_ajax.ajax_url,\r\n\t\t\t\ttype: 'POST',\r\n\t\t\t\tdataType: 'json',\r\n\t\t\t\tdata: {\r\n\t\t\t\t\tnonce_code: os_ajax.ajax_nonce,\r\n\t\t\t\t\taction: action,\r\n\t\t\t\t\tonload: onload,\r\n\t\t\t\t\tstatus: status,\r\n\t\t\t\t},\r\n\t\t\t\tsuccess: function ( response ) {},\r\n\t\t\t} );\r\n\t\t}\r\n\r\n\t\t\/\/ AJAX post votes.\r\n\t\t$( function () {\r\n\t\t\tlet post  = '#post-votes';\r\n\t\t\tlet votes = '.disabled';\r\n\r\n\t\t\t\/\/ AJAX by onload.\r\n\t\t\tosAjaxRequest( 'post_votes' ).done( function ( response ) {\r\n\t\t\t\tif ( 'undefined' !== typeof( response.data ) ) {\r\n\t\t\t\t\t$( post ).find( votes ).text( response.data );\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$( post ).removeClass( 'invisible' );\r\n\t\t\t} );\r\n\r\n\t\t\t$( post ).find( 'button.btn' ).not( votes ).one( 'click', function () {\r\n\t\t\t\tlet btn    = this;\r\n\t\t\t\tlet target = $( this ).siblings( votes );\r\n\t\t\t\tlet status = 'like';\r\n\r\n\t\t\t\tif ( $( this ).find( '.dashicons' ).hasClass( 'dashicons-thumbs-down' ) ) {\r\n\t\t\t\t\tstatus = 'dislike';\r\n\t\t\t\t}\r\n\r\n\t\t\t\t\/\/ AJAX by click.\r\n\t\t\t\tosAjaxRequest( 'post_votes', false, status ).done( function ( response ) {\r\n\t\t\t\t\tif ( 'undefined' !== typeof( response.data ) ) {\r\n\t\t\t\t\t\ttarget.text( response.data );\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tif ( ! $( 'body' ).hasClass( 'os-mobile' ) ) {\r\n\t\t\t\t\t\t\tosVotedTip( target, btn );\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t} );\r\n\r\n\t\t\t\tif ( ! $( 'body' ).hasClass( 'os-mobile' ) ) {\r\n\t\t\t\t\t$( this ).on( 'click', function () {\r\n\t\t\t\t\t\tosVotedTip( target, btn );\r\n\t\t\t\t\t} );\r\n\t\t\t\t}\r\n\t\t\t} );\r\n\t\t} );\r\n\t} );\r\n} )( jQuery );<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0444\u043e\u0440\u0443\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434, \u043a\u0430\u043a \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445. \u041e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u0435\u043c\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u043e, \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043d\u0430 \u0432\u0441\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n<p>\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0432\u0435\u0441\u0442\u0438 \u0434\u043d\u0435\u0432\u043d\u0438\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u043e\u0440\u0443\u043c\u0430, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u0435\u0441\u044c WordPress \u0438 \u0432\u0430\u0441 \u0443\u0441\u0442\u0440\u043e\u0438\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u0421\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f WP Codex, \u043f\u043e\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 JS \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u041a\u0438\u0440\u0438\u043b\u043b\u0438\u0446\u0430, \u0441\u043a\u043e\u0440\u043e \u0434\u043e\u0431\u0435\u0440\u0443\u0441\u044c \u0434\u043e \u0435\u0451 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p><em>\u0421 \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u0435\u043c, \u0430\u0434\u043c\u0438\u043d.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0432\u0430\u0448 \u043f\u043e\u0441\u0442 \u043d\u0430 WordPress \u0431\u0435\u0437 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043d\u0435\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u043d\u0438\u0436\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u044d\u0442\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f back-end, \u0430 \u0437\u0430\u0442\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u043a\u043e\u0434 jQuery \u043d\u0430 front-end. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e Ajax, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 \u0434\u0432\u0438\u0436\u043a\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041a\u043b\u0430\u0441\u0441\u044b CSS \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f Twitter Bootstrap 5. \u0420\u0430\u0437\u043c\u0435\u0442\u043a\u0430 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[15],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":3,"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":382,"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/posts\/112\/revisions\/382"}],"wp:attachment":[{"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/onstartup.ru\/forum\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}