{"id":70806,"date":"2012-05-24T09:09:50","date_gmt":"2012-05-24T09:09:50","guid":{"rendered":""},"modified":"2016-07-30T23:13:54","modified_gmt":"2016-07-30T23:13:54","slug":"%d0%bf%d0%be%d0%bc%d0%be%d0%b3%d0%b8%d1%82%d0%b5-%d0%b2%d1%8b%d0%b2%d0%b5%d1%81%d1%82%d0%b8-%d0%b4%d0%be%d0%bf%d0%be%d0%bb%d0%bd%d0%b8%d1%82%d0%b5%d0%bb%d1%8c%d0%bd%d1%83%d1%8e-%d0%bf%d0%be%d0%bb","status":"closed","type":"topic","link":"https:\/\/ru.wordpress.org\/support\/topic\/%d0%bf%d0%be%d0%bc%d0%be%d0%b3%d0%b8%d1%82%d0%b5-%d0%b2%d1%8b%d0%b2%d0%b5%d1%81%d1%82%d0%b8-%d0%b4%d0%be%d0%bf%d0%be%d0%bb%d0%bd%d0%b8%d1%82%d0%b5%d0%bb%d1%8c%d0%bd%d1%83%d1%8e-%d0%bf%d0%be%d0%bb\/","title":{"rendered":"\u041f\u043e\u043c\u043e\u0433\u0438\u0442\u0435 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u043b\u044e html \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435"},"content":{"rendered":"<p>\u041f\u043e\u043c\u043e\u0433\u0438\u0442\u0435 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u043b\u044e html \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435.<br \/>\n\u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c 2 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044f \u043d\u043e \u0432 \u043d\u0438\u0445 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0438\u0441\u0430\u0442\u044c html \u043a\u043e\u0434, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e <a href=\"http:\/\/i074.radikal.ru\/1205\/3b\/9f5fc2b27d28.jpg\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a><\/p>\n<p>\u041c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431 \u0440\u044f\u0434\u043e\u043c \u0431\u044b\u043b\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u043b\u044f \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0438\u0441\u0430\u0442\u044c html \u043a\u043e\u0434.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430 functions.php<\/p>\n<pre><code>&lt;?php\ninclude &#039;theme_options.php&#039;;\ninclude &#039;guide.php&#039;;\nif ( function_exists(&#039;register_sidebar&#039;) )\n    register_sidebar(array(\n\t&#039;name&#039; =&gt; &#039;Sidebar&#039;,\n    &#039;before_widget&#039; =&gt; &#039;&lt;div class=&quot;sidebox rounded&quot;&gt;&#039;,\n    &#039;after_widget&#039; =&gt; &#039;&lt;\/div&gt;&#039;,\n\t&#039;before_title&#039; =&gt; &#039;&lt;h3 class=&quot;sidetitl&quot;&gt;&#039;,\n    &#039;after_title&#039; =&gt; &#039;&lt;\/h3&gt;&#039;,\n    ));\n\nregister_nav_menus( array(\n\t\t&#039;primary&#039; =&gt; __( &#039;Primary Navigation&#039;, &#039;&#039; ),\n\n\t) );\n\nfunction post_type_videos() {\nregister_post_type(\n                     &#039;videos&#039;,\n                     array( &#039;public&#039; =&gt; true,\n\t\t\t\t\t \t\t&#039;publicly_queryable&#039; =&gt; true,\n\t\t\t\t\t\t\t&#039;hierarchical&#039; =&gt; false,\n\t\t\t\t\t\t\t&#039;menu_icon&#039; =&gt; get_stylesheet_directory_uri() . &#039;\/images\/video.png&#039;,\n                    \t\t&#039;labels&#039;=&gt;array(\n    \t\t\t\t\t\t\t\t\t&#039;name&#039; =&gt; _x(&#039;Videos&#039;, &#039;post type general name&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;singular_name&#039; =&gt; _x(&#039;Video&#039;, &#039;post type singular name&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;add_new&#039; =&gt; _x(&#039;Add New&#039;, &#039;video&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;add_new_item&#039; =&gt; __(&#039;Add New video&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;edit_item&#039; =&gt; __(&#039;Edit video&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;new_item&#039; =&gt; __(&#039;New video&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;view_item&#039; =&gt; __(&#039;View video&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;search_items&#039; =&gt; __(&#039;Search video&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;not_found&#039; =&gt;  __(&#039;No videos found&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;not_found_in_trash&#039; =&gt; __(&#039;No videos found in Trash&#039;),\n    \t\t\t\t\t\t\t\t\t&#039;parent_item_colon&#039; =&gt; &#039;&#039;\n  \t\t\t\t\t\t\t\t\t\t),\n                             &#039;show_ui&#039; =&gt; true,\n\t\t\t\t\t\t\t &#039;menu_position&#039;=&gt;5,\n                             &#039;supports&#039; =&gt; array(\n\t\t\t\t\t\t\t \t\t\t&#039;title&#039;,\n\t\t\t\t\t\t\t\t\t\t&#039;editor&#039;,\n\t\t\t\t\t\t\t\t\t\t&#039;author&#039;,\n                                        &#039;post-thumbnails&#039;,\n                                        &#039;excerpts&#039;,\n                                        &#039;trackbacks&#039;,\n\t\t\t\t\t\t\t            &#039;custom-fields&#039;,\n                                        &#039;comments&#039;,\n                                        &#039;revisions&#039;)\n\n                                )\n                      );\n\n}\nadd_action(&#039;init&#039;, &#039;post_type_videos&#039;);\n\nfunction create_genre_taxonomy()\n{\n  $labels = array(\n\t  \t\t\t\t\t\t  &#039;name&#039; =&gt; _x( &#039;Genre&#039;, &#039;taxonomy general name&#039; ),\n    \t\t\t\t\t\t  &#039;singular_name&#039; =&gt; _x( &#039;genre&#039;, &#039;taxonomy singular name&#039; ),\n    \t\t\t\t\t\t  &#039;search_items&#039; =&gt;  __( &#039;Search genre&#039; ),\n   \t\t\t\t\t\t\t  &#039;all_items&#039; =&gt; __( &#039;All Genre&#039; ),\n    \t\t\t\t\t\t  &#039;parent_item&#039; =&gt; __( &#039;Parent Genre&#039; ),\n   \t\t\t\t\t   \t\t  &#039;parent_item_colon&#039; =&gt; __( &#039;Parent Genre:&#039; ),\n   \t\t\t\t\t\t\t  &#039;edit_item&#039; =&gt; __( &#039;Edit Genre&#039; ),\n  \t\t\t\t\t\t\t  &#039;update_item&#039; =&gt; __( &#039;Update Genre&#039; ),\n  \t\t\t\t\t\t\t  &#039;add_new_item&#039; =&gt; __( &#039;Add New Genre&#039; ),\n  \t\t\t\t\t\t\t  &#039;new_item_name&#039; =&gt; __( &#039;New Genre Name&#039; ),\n  ); \t\n\n  register_taxonomy(&#039;genre&#039;,array(&#039;videos&#039;), array(\n    &#039;hierarchical&#039; =&gt; true,\n    &#039;labels&#039; =&gt; $labels,\n    &#039;show_ui&#039; =&gt; true,\n    &#039;query_var&#039; =&gt; true,\n    &#039;rewrite&#039; =&gt; array( &#039;slug&#039; =&gt; &#039;genre&#039; ),\n  ));\n\n}\nadd_action( &#039;init&#039;, &#039;create_genre_taxonomy&#039;, 0 );\n\n$new_meta_boxes =\narray(\n\t&quot;trailer&quot; =&gt; array(\n\t&quot;name&quot; =&gt; &quot;trailer&quot;,\n\t&quot;std&quot; =&gt; &quot;&quot;,\n\t&quot;title&quot; =&gt; &quot;Trailer video&quot;,\n\t&quot;description&quot; =&gt; &quot;\n\t\t&lt;p&gt;Enter the video url&lt;\/p&gt;\n\n\t&quot;\n),\t&quot;poster&quot; =&gt; array(\n\t&quot;name&quot; =&gt; &quot;poster&quot;,\n\t&quot;std&quot; =&gt; &quot;&quot;,\n\t&quot;title&quot; =&gt; &quot;Movie poster&quot;,\n\t&quot;description&quot; =&gt; &quot;\n\t\t&lt;p&gt; Movie poster image&lt;\/p&gt;\n\n\t&quot;\n),\n\n);\nfunction new_meta_boxes() {\nglobal $post, $new_meta_boxes;\n\nforeach($new_meta_boxes as $meta_box) {\n$meta_box_value = get_post_meta($post-&gt;ID, $meta_box[&#039;name&#039;].&#039;_value&#039;, true);\n\nif($meta_box_value == &quot;&quot;)\n$meta_box_value = $meta_box[&#039;std&#039;];\n\necho&#039;&lt;input type=&quot;hidden&quot; name=&quot;&#039;.$meta_box[&#039;name&#039;].&#039;_noncename&quot; id=&quot;&#039;.$meta_box[&#039;name&#039;].&#039;_noncename&quot; value=&quot;&#039;.wp_create_nonce( plugin_basename(__FILE__) ).&#039;&quot; \/&gt;&#039;;\n\necho&#039;&lt;h2 style=&quot; margin:0px; padding:0px 3px; font-style:normal; font-family:Tahoma; font-size:13px;font-weight:bold;&quot;&gt;&#039;.$meta_box[&#039;title&#039;].&#039;&lt;\/h2&gt;&#039;;\n\necho&#039;&lt;input type=&quot;text&quot; name=&quot;&#039;.$meta_box[&#039;name&#039;].&#039;_value&quot; value=&quot;&#039;.$meta_box_value.&#039;&quot; size=&quot;95&quot; \/&gt;&lt;br \/&gt;&#039;;\n\necho&#039;&lt;p&gt;&lt;label for=&quot;&#039;.$meta_box[&#039;name&#039;].&#039;_value&quot;&gt;&#039;.$meta_box[&#039;description&#039;].&#039;&lt;\/label&gt;&lt;\/p&gt;&#039;;\n}\n}\nfunction create_meta_box() {\nglobal $theme_name;\nif ( function_exists(&#039;add_meta_box&#039;) ) {\nadd_meta_box( &#039;new-meta-boxes&#039;, &#039;Trailer data&#039;, &#039;new_meta_boxes&#039;, &#039;videos&#039;, &#039;normal&#039;, &#039;high&#039; );\n}\n}\nfunction save_postdata( $post_id ) {\nglobal $post, $new_meta_boxes;\n\nforeach($new_meta_boxes as $meta_box) {\n\/\/ Verify\nif ( !wp_verify_nonce( $_POST[$meta_box[&#039;name&#039;].&#039;_noncename&#039;], plugin_basename(__FILE__) )) {\nreturn $post_id;\n}\n\nif ( &#039;page&#039; == $_POST[&#039;post_type&#039;] ) {\nif ( !current_user_can( &#039;edit_page&#039;, $post_id ))\nreturn $post_id;\n} else {\nif ( !current_user_can( &#039;edit_post&#039;, $post_id ))\nreturn $post_id;\n}\n\n$data = $_POST[$meta_box[&#039;name&#039;].&#039;_value&#039;];\n\nif(get_post_meta($post_id, $meta_box[&#039;name&#039;].&#039;_value&#039;) == &quot;&quot;)\nadd_post_meta($post_id, $meta_box[&#039;name&#039;].&#039;_value&#039;, $data, true);\nelseif($data != get_post_meta($post_id, $meta_box[&#039;name&#039;].&#039;_value&#039;, true))\nupdate_post_meta($post_id, $meta_box[&#039;name&#039;].&#039;_value&#039;, $data);\nelseif($data == &quot;&quot;)\ndelete_post_meta($post_id, $meta_box[&#039;name&#039;].&#039;_value&#039;, get_post_meta($post_id, $meta_box[&#039;name&#039;].&#039;_value&#039;, true));\n}\n}\nadd_action(&#039;admin_menu&#039;, &#039;create_meta_box&#039;);\nadd_action(&#039;save_post&#039;, &#039;save_postdata&#039;);\nfunction short_title($char) {\n         $title = get_the_title($post-&gt;ID);\n         $title = mb_substr($title,0,$char);\n         echo $title;\n}<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-70806","topic","type-topic","status-closed","hentry","topic-tag-5627","topic-tag-3822","topic-tag-5625","topic-tag-5626","topic-tag-html"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/70806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/70806\/revisions"}],"wp:attachment":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=70806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}