white50
フォーラムへの返信
4件の返信を表示中 - 1 - 4件目 (全4件中)
-
フォーラム: 使い方全般
返信が含まれるトピック: プレビュー画面内に公開ボタンを設置自己解決致しましたので、共有しておきます。
以下のコードで出来ました。
single.php
<?php if(current_user_can('read_private_pages')) : ?> <?php $url = add_query_arg(array('action'=>'mypublish', 'post'=>$post->ID),home_url()); echo "<a href='" . wp_nonce_url($url, 'my-publish-post_' . $post->ID) . "'>公開する</a>"; ?><?php endif; ?>
function.php
if(isset($_REQUEST['action']) && $_REQUEST['action']=='mypublish') add_action('init','my_publish_draft'); function my_publish_draft(){ //Get the post's ID. $post_id = (isset($_REQUEST['post']) ? (int) $_REQUEST['post'] : 0); //No post? Oh well.. if(empty($post_id)) return; $nonce = $_REQUEST['_wpnonce']; //Check nonce if (! wp_verify_nonce($nonce,'my-publish-post_'.$post_id)) wp_die('Are you sure?'); //Check user permissions if (!current_user_can('publish_posts')) wp_die("You can't do that"); //Any other checks you may wish to perform.. //Publish post wp_publish_post( $post_id ); //Redirect to published post $redirect = get_permalink($post_id); wp_redirect($redirect); exit; }
フォーラム: 使い方全般
返信が含まれるトピック: 閲覧ユーザーによるタグ付けフォーラム: 使い方全般
返信が含まれるトピック: $wpdbを使用し、DBよりカスタムフィールドの値を取得したいフォーラム: 使い方全般
返信が含まれるトピック: $wpdbを使用し、DBよりカスタムフィールドの値を取得したい
4件の返信を表示中 - 1 - 4件目 (全4件中)