{"id":3310,"date":"2020-04-28T17:07:54","date_gmt":"2020-04-28T08:07:54","guid":{"rendered":"https:\/\/okamurax.com\/?p=3310"},"modified":"2021-08-06T11:10:37","modified_gmt":"2021-08-06T02:10:37","slug":"wordpress-%e3%82%a6%e3%82%a3%e3%82%b8%e3%83%83%e3%83%88%e4%bd%9c%e6%88%90","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=3310","title":{"rendered":"WordPress \u66f4\u65b0\u9806\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8"},"content":{"rendered":"<p>\u4ee5\u524d\u306f\u6700\u65b0\u6295\u7a3f\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3092\u66f4\u65b0\u9806\u306b\u4e26\u3073\u66ff\u3048\u308b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3092\u3057\u3066\u3044\u305f\u304c\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u306e\u6642\u306b\u3082\u3068\u306b\u623b\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u5c02\u7528\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n<p><span style=\"color: #0000ff;\">wp-includes\/widgets\/class-wp-widget-modified-posts.php<\/span><br \/>\n\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u624b\u52d5\u3067\u8a18\u5165\u3059\u308b\u3002<\/p>\n<pre class=\"lang:php decode:true \">add_action( 'widgets_init', 'add_widgets' );\r\n\r\nfunction add_widgets() {\r\n  register_widget( 'modified_widget' );\r\n}\r\n\r\nclass modified_widget extends WP_Widget {\r\n\r\n  function __construct() {\r\n    $widget_ops = array(\r\n      'classname' =&gt; 'modified_widget_class',\r\n      'description' =&gt; ''\r\n    );\r\n    parent::__construct( 'modified_widget', '\u6295\u7a3f(\u66f4\u65b0\u9806)', $widget_ops );\r\n\t}<\/pre>\n<p>\u6b8b\u308a\u306e\u90e8\u5206\u306f\u3001<br \/>\n<span style=\"color: #0000ff;\">wp-includes\/widgets\/class-wp-widget-recent-posts.php<\/span><br \/>\n\u304b\u3089widget,update,form\u3092\u305d\u306e\u307e\u307e\u30b3\u30d4\u30fc\u3057\u3001<br \/>\n\u4ee5\u4e0b\u306e\u901a\u308a\u5909\u66f4\u3002<\/p>\n<p><span style=\"color: #0000ff;\">$r = new WP_Query()<\/span><br \/>\n\u306e\u4e2d\u306b\u3042\u308b\u914d\u5217\u306b\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3059\u308b\u3002<br \/>\n<span style=\"color: #0000ff;\">&#8216;orderby&#8217;=&gt;&#8217;modified&#8217;<\/span><\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;span class=\"post-date\"&gt;\r\n&lt;?php echo get_the_date( '', $recent_post-&gt;ID ); ?&gt;\r\n&lt;\/span&gt;<\/pre>\n<p>\u3092<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;span class=\"post-date\"&gt;&lt;br&gt;\r\n\u66f4\u65b0\uff1a&lt;?php echo get_the_modified_date('Y-m-d',$recent_post-&gt;ID); ?&gt;\r\n&amp;nbsp;&amp;#047;&amp;nbsp;\r\n\u6295\u7a3f\uff1a&lt;?php echo get_the_date('Y-m-d',$recent_post-&gt;ID); ?&gt;\r\n&lt;\/span&gt;<\/pre>\n<p>\u306b\u5909\u66f4\u3002<\/p>\n<pre class=\"lang:php decode:true \">&lt;?php\r\n\r\nadd_action( 'widgets_init', 'add_widgets' );\r\n\r\nfunction add_widgets() {\r\n  register_widget( 'modified_widget' );\r\n}\r\n\r\nclass modified_widget extends WP_Widget {\r\n\r\n  function __construct() {\r\n    $widget_ops = array(\r\n      'classname' =&gt; 'modified_widget_class',\r\n      'description' =&gt; ''\r\n    );\r\n    parent::__construct( 'modified_widget', '\u6295\u7a3f(\u66f4\u65b0\u9806)', $widget_ops );\r\n\t}\r\n\t\r\n\tpublic function widget( $args, $instance ) {\r\n\r\n\t\tif ( ! isset( $args['widget_id'] ) ) {\r\n\t\t\t$args['widget_id'] = $this-&gt;id;\r\n\t\t}\r\n\r\n\t\t$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );\r\n\t\t$title = apply_filters( 'widget_title', $title, $instance, $this-&gt;id_base );\r\n\r\n\t\t$number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;\r\n\t\tif ( ! $number ) {\r\n\t\t\t$number = 5;\r\n\t\t}\r\n\t\t$show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;\r\n\r\n\t\t$r = new WP_Query(\r\n\r\n\t\t\tapply_filters(\r\n\t\t\t\t'widget_posts_args',\r\n\t\t\t\tarray(\r\n\t\t\t\t\t'posts_per_page'      =&gt; $number,\r\n\t\t\t\t\t'no_found_rows'       =&gt; true,\r\n\t\t\t\t\t'post_status'         =&gt; 'publish',\r\n\t\t\t\t\t'ignore_sticky_posts' =&gt; true,\r\n\t\t\t\t\t'orderby'             =&gt; 'modified',\r\n\t\t\t\t),\r\n\t\t\t\t$instance\r\n\t\t\t)\r\n\t\t);\r\n\r\n\t\tif ( ! $r-&gt;have_posts() ) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t?&gt;\r\n\t\t&lt;?php echo $args['before_widget']; ?&gt;\r\n\t\t&lt;?php\r\n\t\tif ( $title ) {\r\n\t\t\techo $args['before_title'] . $title . $args['after_title'];\r\n\t\t}\r\n\t\t?&gt;\r\n\t\t&lt;ul&gt;\r\n\t\t\t&lt;?php foreach ( $r-&gt;posts as $recent_post ) : ?&gt;\r\n\t\t\t\t&lt;?php\r\n\t\t\t\t$post_title   = get_the_title( $recent_post-&gt;ID );\r\n\t\t\t\t$title        = ( ! empty( $post_title ) ) ? $post_title : __( '(no title)' );\r\n\t\t\t\t$aria_current = '';\r\n\r\n\t\t\t\tif ( get_queried_object_id() === $recent_post-&gt;ID ) {\r\n\t\t\t\t\t$aria_current = ' aria-current=\"page\"';\r\n\t\t\t\t}\r\n\t\t\t\t?&gt;\r\n\r\n\t\t\t\t&lt;li&gt;\r\n\t\t\t\t\t&lt;a href=\"&lt;?php the_permalink( $recent_post-&gt;ID ); ?&gt;\"&lt;?php echo $aria_current; ?&gt;&gt;&lt;?php echo $title; ?&gt;&lt;\/a&gt;\r\n\t\t\t\t\t&lt;?php if ( $show_date ) : ?&gt;\r\n\t\t\t\t\t\t&lt;span class=\"post-date\"&gt;&lt;br&gt;\r\n\t\t\t\t\t\t\u66f4\u65b0\uff1a&lt;?php echo get_the_modified_date('Y-m-d',$recent_post-&gt;ID); ?&gt;\r\n\t\t\t\t\t\t&amp;nbsp;&amp;#047;&amp;nbsp;\r\n\t\t\t\t\t\t\u6295\u7a3f\uff1a&lt;?php echo get_the_date('Y-m-d',$recent_post-&gt;ID); ?&gt;\r\n\t\t\t\t\t\t&lt;\/span&gt;\r\n\t\t\t\t\t&lt;?php endif; ?&gt;\r\n\t\t\t\t&lt;\/li&gt;\r\n\t\t\t&lt;?php endforeach; ?&gt;\r\n\t\t&lt;\/ul&gt;\r\n\t\t&lt;?php\r\n\t\techo $args['after_widget'];\r\n\t}\r\n\r\n\tpublic function update( $new_instance, $old_instance ) {\r\n\t\t$instance              = $old_instance;\r\n\t\t$instance['title']     = sanitize_text_field( $new_instance['title'] );\r\n\t\t$instance['number']    = (int) $new_instance['number'];\r\n\t\t$instance['show_date'] = isset( $new_instance['show_date'] ) ? (bool) $new_instance['show_date'] : false;\r\n\t\treturn $instance;\r\n\t}\r\n\r\n\tpublic function form( $instance ) {\r\n\r\n\t\t$title     = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';\r\n\t\t$number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;\r\n\t\t$show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;\r\n\r\n\t\t?&gt;\r\n\t\t&lt;p&gt;&lt;label for=\"&lt;?php echo $this-&gt;get_field_id( 'title' ); ?&gt;\"&gt;&lt;?php _e( 'Title:' ); ?&gt;&lt;\/label&gt;\r\n\t\t&lt;input class=\"widefat\" id=\"&lt;?php echo $this-&gt;get_field_id( 'title' ); ?&gt;\" name=\"&lt;?php echo $this-&gt;get_field_name( 'title' ); ?&gt;\" type=\"text\" value=\"&lt;?php echo $title; ?&gt;\" \/&gt;&lt;\/p&gt;\r\n\r\n\t\t&lt;p&gt;&lt;label for=\"&lt;?php echo $this-&gt;get_field_id( 'number' ); ?&gt;\"&gt;&lt;?php _e( 'Number of posts to show:' ); ?&gt;&lt;\/label&gt;\r\n\t\t&lt;input class=\"tiny-text\" id=\"&lt;?php echo $this-&gt;get_field_id( 'number' ); ?&gt;\" name=\"&lt;?php echo $this-&gt;get_field_name( 'number' ); ?&gt;\" type=\"number\" step=\"1\" min=\"1\" value=\"&lt;?php echo $number; ?&gt;\" size=\"3\" \/&gt;&lt;\/p&gt;\r\n\r\n\t\t&lt;p&gt;&lt;input class=\"checkbox\" type=\"checkbox\"&lt;?php checked( $show_date ); ?&gt; id=\"&lt;?php echo $this-&gt;get_field_id( 'show_date' ); ?&gt;\" name=\"&lt;?php echo $this-&gt;get_field_name( 'show_date' ); ?&gt;\" \/&gt;\r\n\t\t&lt;label for=\"&lt;?php echo $this-&gt;get_field_id( 'show_date' ); ?&gt;\"&gt;&lt;?php _e( 'Display post date?' ); ?&gt;&lt;\/label&gt;&lt;\/p&gt;\r\n\t\t&lt;?php\r\n\r\n\t}\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>\uff0a\uff0a\uff0a<\/p>\n<h2>\u6709\u52b9\u5316\u306b\u3064\u3044\u3066<\/h2>\n<p><span style=\"color: #0000ff;\">wp-includes\/default-widgets.php<\/span><br \/>\n\u306b\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3002<br \/>\n<span style=\"color: #0000ff;\">require_once ABSPATH . WPINC . &#8216;\/widgets\/class-wp-widget-modified-posts.php&#8217;;<\/span><\/p>\n<p>\u3042\u308b\u3044\u306f\u4ee5\u4e0b\u306e\u65b9\u6cd5\u3002<\/p>\n<p><span style=\"color: #0000ff;\">wp-content\/plugins<\/span><br \/>\n\u306e\u4e2d\u306b<br \/>\n<span style=\"color: #0000ff;\">modified-posts.php<\/span><br \/>\n\u3092\u4f5c\u6210\u3057\u4ee5\u4e0b\u3092\u8a18\u5165\u3002<\/p>\n<pre class=\"lang:php decode:true \">&lt;?php\r\n\r\n\/\/Plugin Name: Modified Posts\r\n\r\nrequire_once ABSPATH . WPINC . '\/widgets\/class-wp-widget-modified-posts.php';<\/pre>\n<p>\u305d\u3046\u3059\u308b\u3068\u3001<br \/>\n\u7ba1\u7406\u753b\u9762\uff1e\u30d7\u30e9\u30b0\u30a4\u30f3<br \/>\n\u306bModified Posts\u3068\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u6709\u52b9\u5316\u3059\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\u306f\u6700\u65b0\u6295\u7a3f\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3092\u66f4\u65b0\u9806\u306b\u4e26\u3073\u66ff\u3048\u308b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3092\u3057\u3066\u3044\u305f\u304c\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u306e\u6642\u306b\u3082\u3068\u306b\u623b\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u5c02\u7528\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002 wp-includes\/widgets\/class-wp-widget-mo &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=3310\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;WordPress \u66f4\u65b0\u9806\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[85],"class_list":["post-3310","post","type-post","status-publish","format-standard","hentry","category-1","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/3310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3310"}],"version-history":[{"count":13,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/3310\/revisions"}],"predecessor-version":[{"id":4477,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/3310\/revisions\/4477"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}