/** * シェアボタンを表示(投稿ページのみ) */ public function display_share_buttons() { $post_type = Habakiri_Share_Buttons_Option::get('post_type'); if (!is_array($post_type) || !in_array(get_post_type(), $post_type)) { return; } $type = Habakiri_Share_Buttons_Option::get('type'); echo do_shortcode(sprintf('[%s type="%s"]', Habakiri_Share_Buttons_Config::KEY, $type)); }
/** * 管理画面を表示 */ public function display() { ?> <div class="wrap"> <h2><?php esc_html_e('Share Buttons Settings', 'habakiri-share-buttons'); ?> </h2> <form method="post" action="options.php"> <?php settings_fields(Habakiri_Share_Buttons_Config::NAME . '-group'); ?> <table class="form-table"> <tr> <th><?php esc_html_e('Share Buttons Type', 'habakiri-share-buttons'); ?> </th> <td> <?php $choices = Habakiri_Share_Buttons_Option::get_choices('type'); $type = Habakiri_Share_Buttons_Option::get('type'); if (is_null($type)) { $type = Habakiri_Share_Buttons_Option::get_first_value('type'); } ?> <ul> <?php foreach ($choices as $key => $value) { ?> <li><label><input type="radio" name="<?php echo esc_attr(Habakiri_Share_Buttons_Config::NAME); ?> [type]" value="<?php echo esc_attr($key); ?> " <?php checked($type, $key); ?> /> <?php echo esc_html($value); ?> </label></li> <?php } ?> </ul> </td> </tr> <tr> <th><?php esc_html_e('Position to Display', 'habakiri-share-buttons'); ?> </th> <td> <?php $choices = Habakiri_Share_Buttons_Option::get_choices('position'); $position = Habakiri_Share_Buttons_Option::get('position'); if (is_null($position)) { $position = array(); } ?> <ul> <?php foreach ($choices as $key => $value) { ?> <li><label><input type="checkbox" name="<?php echo esc_attr(Habakiri_Share_Buttons_Config::NAME); ?> [position][]" value="<?php echo esc_attr($key); ?> " <?php checked(in_array($key, $position)); ?> /> <?php echo esc_html($value); ?> </label></li> <?php } ?> </ul> </td> </tr> <tr> <th><?php esc_html_e('Post Types to Display', 'habakiri-share-buttons'); ?> </th> <td> <?php $choices = Habakiri_Share_Buttons_Option::get_choices('post_type'); $post_type = Habakiri_Share_Buttons_Option::get('post_type'); if (is_null($post_type)) { $post_type = array(); } ?> <ul> <?php foreach ($choices as $key => $value) { ?> <li><label><input type="checkbox" name="<?php echo esc_attr(Habakiri_Share_Buttons_Config::NAME); ?> [post_type][]" value="<?php echo esc_attr($key); ?> " <?php checked(in_array($key, $post_type)); ?> /> <?php echo esc_html($value); ?> </label></li> <?php } ?> </ul> </td> </tr> </table> <p class="submit"> <input type="submit" class="button-primary" value="<?php esc_html_e('Save Changes', 'habakiri-share-buttons'); ?> " /> </p> </form> <!-- end .wrap --></div> <?php }