{"id":128,"date":"2016-11-25T20:03:22","date_gmt":"2016-11-25T11:03:22","guid":{"rendered":"https:\/\/gianism.info\/?p=128"},"modified":"2016-11-25T20:03:22","modified_gmt":"2016-11-25T11:03:22","slug":"automatically-tweet-from-wordpress","status":"publish","type":"post","link":"https:\/\/gianism.info\/ja\/2016\/11\/25\/automatically-tweet-from-wordpress\/","title":{"rendered":"WordPress\u304b\u3089\u81ea\u52d5\u3067twitter\u306b\u3064\u3076\u3084\u304f"},"content":{"rendered":"<p>Gianism\u306b\u306f\u4fbf\u5229\u306a\u95a2\u6570\u304c\u3044\u304f\u3064\u304b\u3042\u308a\u3001\u305d\u306e\u4e00\u3064\u304c\u00a0<code>gianism_update_twitter_status()<\/code>\u00a0\u3067\u3059\u3002\u3053\u308c\u306ftwitter\u306b\u6295\u7a3f\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h2>\n<p>Gianism\u3067twitter\u9023\u643a\u3092\u6709\u52b9\u306b\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u4ed6\u306eSNS\u30a2\u30ab\u30a6\u30f3\u30c8\u3068\u7570\u306a\u308a\u3001\u9023\u643a\u306b\u4f7f\u7528\u3057\u305f\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u30b3\u30f3\u30b7\u30e5\u30fc\u30de\u30fc\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u304c\u3059\u3067\u306b\u53d6\u5f97\u6e08\u307f\u3067\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u3053\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u3064\u3076\u3084\u304f\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u8a71\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306b\u3001Gianism.info\u3092\u4f8b\u306b\u3042\u3052\u307e\u3057\u3087\u3046\u3002\u3053\u306e\u30b5\u30a4\u30c8\u3068\u9023\u643a\u3057\u3066\u3044\u308btwitter\u30a2\u30ab\u30a6\u30f3\u30c8\u306fwpGianism\u3067\u3059\u3002<\/p>\n<blockquote class=\"twitter-tweet\" data-width=\"550\">\n<p lang=\"en\" dir=\"ltr\">We release another plugin Chiramise! Try for it!<a href=\"https:\/\/t.co\/Qth6pWfzLC\">https:\/\/t.co\/Qth6pWfzLC<\/a> <a href=\"https:\/\/t.co\/F4IjXabWpr\">pic.twitter.com\/F4IjXabWpr<\/a><\/p>\n<p>&mdash; Gianism (@wpGianism) <a href=\"https:\/\/twitter.com\/wpGianism\/status\/795293564469002241\">November 6, 2016<\/a><\/p><\/blockquote>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>\u3064\u307e\u308a\u3001\u3042\u306a\u305f\u306eWordPress\u306f\u30b5\u30a4\u30c8\u306e\u30a2\u30a4\u30c7\u30f3\u30c6\u30a3\u30c6\u30a3\u3092\u4ee3\u8868\u3059\u308b\u3088\u3046\u306atwitter\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u3064\u3076\u3084\u304b\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n<h2>\u6295\u7a3f\u3092\u516c\u958b\u3057\u305f\u6642\u306b\u3064\u3076\u3084\u304f<\/h2>\n<p>\u3055\u3066\u3001\u7c21\u5358\u306a\u4f8b\u3068\u3057\u3066\u3001\u300c\u6295\u7a3f\u3092\u516c\u958b\u3059\u308b\u3068\u3064\u3076\u3084\u304f\u300d\u3068\u3044\u3046\u4f8b\u3092\u8003\u3048\u3066\u898b\u307e\u3057\u3087\u3046\u3002\u3069\u306e\u3088\u3046\u306b\u5229\u7528\u3059\u308b\u304b\u306f\u3068\u3082\u304b\u304f\u3001\u91cd\u8981\u306a\u306e\u306f\u300c\u3069\u3053\u306b\u30d5\u30c3\u30af\u3092\u304b\u3051\u308b\u304b\u300d\u3067\u3059\u3002\u4eca\u56de\u4f7f\u3048\u305d\u3046\u306a\u306e\u306f\u3001\u6295\u7a3f\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u304c\u5909\u5316\u3057\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308b<code>transition_post_status<\/code>\u3067\u3059\u3002\u6b21\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php\r\nadd_action( 'transition_post_status', function( $new_status, $old_status, $post ){\r\n  if ( ( 'publish' == $new_status ) &amp;&amp; ( 'publish' != $old_status ) ) {\r\n    $txt = '\u65b0\u3057\u3044\u6295\u7a3f\u3092\u516c\u958b\u3057\u307e\u3057\u305f &gt; ' . get_the_title( $post ) . ' ' . get_permalink( $post );\r\n    gianism_update_twitter_status( $txt );\r\n  }\r\n}, 10, 3 );<\/pre>\n<p>\u305f\u3060\u3057\u3001\u300c\u6295\u7a3f\u3092\u516c\u958b\u3057\u305f\u3089\u30b7\u30a7\u30a2\u3059\u308b\u300d\u3068\u3044\u3046\u6a5f\u80fd\u81ea\u4f53\u306f<a href=\"https:\/\/jetpack.com\">Jetpack<\/a>\u306b\u3082\u5b58\u5728\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u3042\u308b\u7a0b\u5ea6\u306e\u30aa\u30ea\u30b8\u30ca\u30ea\u30c6\u30a3\u3092\u51fa\u3055\u306a\u3044\u306e\u3067\u3042\u308c\u3070\u3001\u305d\u3061\u3089\u3092\u4f7f\u3063\u305f\u65b9\u304c\u697d\u3067\u3059\u3002\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u5fc5\u8981\u3082\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3053\u3053\u3067\u306fJetpack\u306b\u3082\u3067\u304d\u308b\u300c\u6587\u5b57\u3092\u633f\u5165\u300d\u3068\u3044\u3046 \u30b7\u30f3\u30d7\u30eb\u306a\u4f8b\u3092\u8d85\u3048\u305f\u3001\u3082\u3046\u5c11\u3057\u30b8\u30a7\u30cd\u30ea\u30c3\u30af\u306a\u4f8b\u306b\u6311\u6226\u3057\u3066\u898b\u307e\u3057\u3087\u3046\u3002\u4eca\u56de\u306f\u901a\u7b9710\u4f5c\u54c1\u76ee\u306e\u6642\u306b\u306f\u3001\u8a18\u5ff5\u3059\u3079\u304d\u6295\u7a3f\u3092\u884c\u306a\u3063\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u76db\u5927\u306b\u795d\u798f\u3059\u308b\u95a2\u6570\u00a0<code>celebrate_author($post)<\/code> \u3092\u5b9a\u7fa9\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php\r\n\r\nfunction celebrate_author( $post = null ) {\r\n  $post = get_post( $post );\r\n  $query = new WP_Query( [\r\n    'post_type'      =&gt; 'post',\r\n    'post_status'    =&gt; 'publish',\r\n      'author'         =&gt; $post-&gt;post_author,\r\n      'posts_per_page' =&gt; 1,\r\n  ] );\r\n  if ( 10 == $query-&gt;found_posts ) {\r\n    \/\/ \u3061\u3087\u3046\u306910\u4ef6\u3060\u3063\u305f\u3089\r\n    return sprintf(\r\n      '\u304a\u3081\u3067\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01\u3000%1$s\u3055\u3093\u304c\u8a18\u5ff5\u3059\u3079\u304d10\u4ef6\u76ee\u306e\u6295\u7a3f\u3092\u3057\u307e\u3057\u305f %2$s',\r\n      get_the_author_meta( 'display_name', $post-&gt;post_author ),\r\n      get_permalink( $post )\r\n    );\r\n  } else {\r\n    return '';\r\n  }\r\n}<\/pre>\n<p>\u3053\u306e\u95a2\u6570\u3092\u4e0a\u8a18\u306e\u4f8b\u3068\u7d44\u307f\u5408\u308f\u305b\u308c\u3070\u3001Jetpack\u3088\u308a\u306f\u5c11\u3057\u826f\u3055\u305d\u3046\u3067\u3059\u306d\u3002\u3088\u308a\u5bfe\u8a71\u7684\u306b\u3059\u308c\u3070\u3001\u3042\u306a\u305f\u306e\u30e6\u30fc\u30b6\u30fc\u304b\u3089\u9762\u767d\u3044\u3068\u601d\u3063\u3066\u3082\u3089\u3048\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<h3>\u8907\u96d1\u306a\u6761\u4ef6\u3067\u3064\u3076\u3084\u304f\u3079\u304d\u7406\u7531<\/h3>\n<p>\u7c21\u7565\u5316\u306e\u305f\u3081\u3001\u300c\u4ee5\u524d\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u304c\u516c\u958b\u3067\u306a\u304f\u3001\u65b0\u3057\u3044\u30b9\u30c6\u30fc\u30bf\u30b9\u304c\u516c\u958b\u3060\u3063\u305f\u3089\u300d\u3068\u3044\u3046\u6761\u4ef6\u306b\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u5b9f\u969b\u306f\u3082\u3063\u3068\u8907\u96d1\u306a\u6761\u4ef6\u3092\u8a2d\u5b9a\u3059\u3079\u304d\u3067\u3059\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u3001\u8ab0\u3067\u3082\u6295\u7a3f\u3067\u304d\u308b\u30b5\u30a4\u30c8\u3092\u4f5c\u3063\u305f\u3068\u3057\u307e\u3057\u3087\u3046\u3002\u305d\u306e\u5834\u5408\u3001\u300c\u6295\u7a3f\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u304c\u516c\u958b\u306b\u306a\u3063\u305f\u3068\u304d\u3064\u3076\u3084\u304f\u300d\u3068\u3044\u3046\u5358\u7d14\u306a\u30eb\u30fc\u30eb\u306b\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u3081\u3056\u3068\u3044\u30e6\u30fc\u30b6\u30fc\u306f\u300c\u516c\u958b\u306b\u5909\u66f4\u3059\u308b\u3068\u3064\u3076\u3084\u3044\u3066\u3082\u3089\u3048\u308b\u300d\u3068\u3044\u3046\u3053\u3068\u306b\u6c17\u3065\u304d\u3001\u540c\u3058\u6295\u7a3f\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u4f55\u5ea6\u3082\u5909\u66f4\u3059\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u306e\u3088\u3046\u306a<em>\u30cf\u30c3\u30af<\/em>\u3092\u9632\u3050\u610f\u5473\u3067\u3082\u3001\u5b9f\u969b\u306e\u904b\u7528\u3067\u306f\u8907\u96d1\u306a\u6761\u4ef6\u306b\u3059\u308b\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002\u4e00\u5ea6\u3067\u3082\u516c\u958b\u306b\u306a\u3063\u305f\u5834\u5408\u3001\u305d\u306e\u65e5\u6642\u3092\u6295\u7a3f\u30e1\u30bf\u306b\u4fdd\u5b58\u3057\u3066\u304a\u3044\u3066\u30012\u56de\u76ee\u4ee5\u964d\u306f\u7121\u8996\u3059\u308b\u3068\u3044\u3046\u306e\u304c\u8ce2\u3044\u9078\u629e\u3067\u3057\u3087\u3046\u3002<\/p>\n<h2>\u81ea\u52d5\u7684\u304b\u3064\u5b9a\u671f\u7684\u306b\u3064\u3076\u3084\u304f<\/h2>\n<p>WordPress\u306b\u306fCron\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u6a5f\u80fd\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u300c\u5b9a\u671f\u7684\u306b\u3064\u3076\u3084\u304f\u300d\u3068\u3044\u3046\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u3001\u6bce\u6642\u9593\u3054\u3068\u306b\u52d5\u4f5c\u3059\u308bCron\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<a href=\"https:\/\/developer.wordpress.org\/plugins\/cron\/scheduling-wp-cron-events\/\">Codex\u306b\u3082\u8a73\u7d30\u306a\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304c\u3042\u308a\u307e\u3059<\/a>\u306e\u3067\u3001\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php\r\n\r\nadd_action( 'init', function() {\r\n  \/\/ \u30a4\u30d9\u30f3\u30c8\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u306a\u304b\u3063\u305f\u3089\u3001\u767b\u9332\r\n  if ( ! wp_next_scheduled( 'my_daily_cron' ) ) {\r\n    wp_schedule_event( current_time( 'timestamp', true ), 'hourly', 'my_daily_cron' );\r\n  }\r\n} );\r\n\r\n\/\/ \u4e0a\u3067\u767b\u9332\u3057\u305f\u30a4\u30d9\u30f3\u30c8\u306b\u30d5\u30c3\u30af\u3092\u304b\u3051\u308b\r\nadd_action( 'my_daily_cron', function() {\r\n  \/\/ \u306a\u306b\u304b\u3059\u308b\r\n} );<\/pre>\n<p>\u3055\u3066\u3001\u554f\u984c\u306f\u300c\u306a\u306b\u3092\u3064\u3076\u3084\u304f\u304b\u300d\u3067\u3059\u3002<\/p>\n<p>\u540c\u3058\u3088\u3046\u306a\u5185\u5bb9\u3092\u6bce\u6642\u9593\u3064\u3076\u3084\u304d\u7d9a\u3051\u308btwitter\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u3042\u306a\u305f\u306f\u30d5\u30a9\u30ed\u30fc\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u304b\uff1f\u3000\u3044\u3084\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u307e\u305f\u3001twitter\u306eAPI\u306b\u306f\u300c\u540c\u4e00\u306e\u5185\u5bb9\u3092\u9023\u7d9a\u3067\u3064\u3076\u3084\u304f\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\u300d\u3068\u3044\u3046\u4ed5\u69d8\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3082\u3057\u3042\u306a\u305f\u304c\u7a4d\u6975\u7684\u306btwitter\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u5229\u7528\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u3001\u5b9a\u671f\u3064\u3076\u3084\u304d\u306f\u3059\u3079\u3066\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<aside>\u203b Gianism\u306b\u306f<strong>twitter\u30dc\u30c3\u30c8<\/strong>\u3068\u3044\u3046\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u7279\u5b9a\u306e\u5185\u5bb9\u3092\u7279\u5b9a\u306e\u671f\u9593\u306b\u308f\u305f\u3063\u3066\u3064\u3076\u3084\u304d\u7d9a\u3051\u308b\u3053\u3068\u306f\u30b3\u30fc\u30c9\u3092\u66f8\u304b\u305a\u306b\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/aside>\n<p>\u305d\u308c\u306b\u4e0a\u8ff0\u3057\u305f\u901a\u308a\u3001\u6bce\u56de\u9055\u3046\u5185\u5bb9\u3092\u3064\u3076\u3084\u304f\u306e\u3067\u306a\u3051\u308c\u3070\u3001\u81ea\u52d5\u30c4\u30a4\u30fc\u30c8\u30b5\u30fc\u30d3\u30b9\u304c\u5b58\u5728\u3057\u307e\u3059\u306e\u3067\u3001\u305d\u3061\u3089\u3092\u4f7f\u3063\u305f\u65b9\u304c\u697d\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f2\u3064\u306e\u4f8b\u3092\u7d39\u4ecb\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gianism\u306b\u306f\u4fbf\u5229\u306a\u95a2\u6570\u304c\u3044\u304f\u3064\u304b\u3042\u308a\u3001\u305d\u306e\u4e00\u3064\u304c\u00a0gianism_update_twitter_status()\u00a0\u3067\u3059\u3002\u3053\u308c\u306ftwitter\u306b\u6295\u7a3f\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9 Gianism\u3067twitte [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":135,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_locale":"ja","_original_post":"126","jetpack_publicize_message":"Gianism\u306e\u77e5\u308b\u4eba\u305e\u77e5\u308b\u6a5f\u80fd\u7d39\u4ecb\u3067\u3059\u3002\u3068\u3066\u3082\u4fbf\u5229\u3067\u3059\u3088\uff01\u3000\"WordPress\u304b\u3089\u81ea\u52d5\u3067twitter\u306b\u3064\u3076\u3084\u304f\"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[4],"tags":[14,13,12],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/gianism.info\/wp-content\/uploads\/2016\/11\/instruction.001-1.png","jetpack_shortlink":"https:\/\/wp.me\/p83N0f-24","_links":{"self":[{"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/posts\/128"}],"collection":[{"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":6,"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":137,"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/posts\/128\/revisions\/137"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/media\/135"}],"wp:attachment":[{"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gianism.info\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}