Skip to content

Commit

Permalink
タグの指定機能追加 #85
Browse files Browse the repository at this point in the history
  • Loading branch information
kurudrive committed Aug 14, 2024
1 parent abc768b commit 13d7009
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 12 deletions.
47 changes: 46 additions & 1 deletion admin/view.admin.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
<?php
function pad_tag_selector( $options_pad, $name ){
// タイトルのタグをセレクトボックスで選択できるようにする。option は h2〜h6 と div span strong
$tag_options = array(
'h2' => 'h2',
'h3' => 'h3',
'h4' => 'h4',
'h5' => 'h5',
'h6' => 'h6',
'div' => 'div',
'span' => 'span',
'strong' => 'strong',
);
?>
<select name="pad_plugin_options[<?php echo $name;?>]" style="width:100%;max-width:100%;">
<?php
foreach ( $tag_options as $tag_value => $tag_lavel ) {
$selected = '';
if ( isset( $options_pad[$name] ) && $tag_value === $options_pad[$name] ) {
$selected = ' selected';
}
?>
<option value="<?php echo $tag_value; ?>"<?php echo $selected; ?>><?php echo $tag_lavel; ?></option>
<?php } ?>
</select>
<?php
}


function pad_the_admin_body() {
?>

Expand All @@ -17,6 +45,15 @@ function pad_the_admin_body() {
<td><?php echo wp_kses_post( $options_pad['author_box_title'] ); ?> -> <input type="text" name="pad_plugin_options[author_box_title]" id="author_box_title" value="<?php echo esc_attr( $options_pad['author_box_title'] ); ?>" style="width:50%;" /></td>
</tr>
<tr>
<th><?php _e( 'Post author box title tag', 'vk-post-author-display' ); ?></th>
<td>
<?php
$name = 'author_box_title_tag';
pad_tag_selector( $options_pad, $name );
?>
</td>
</tr>
<tr>
<th><?php _e( 'Profile Picture Style', 'vk-post-author-display' ); ?></th>
<td>
<?php
Expand Down Expand Up @@ -46,7 +83,15 @@ function pad_the_admin_body() {
<th><?php _e( 'Post list box title', 'vk-post-author-display' ); ?></th>
<td><?php echo wp_kses_post( $options_pad['list_box_title'] ); ?> -> <input type="text" name="pad_plugin_options[list_box_title]" id="list_box_title" value="<?php echo esc_attr( $options_pad['list_box_title'] ); ?>" style="width:50%;" /></td>
</tr>

<tr>
<th><?php _e( 'Post list box title tag', 'vk-post-author-display' ); ?></th>
<td>
<?php
$name = 'list_box_title_tag';
pad_tag_selector( $options_pad, $name );
?>
</td>
</tr>
<tr>
<th><?php _e( 'Display post author archive page link', 'vk-post-author-display' ); ?></th>
<td>
Expand Down
10 changes: 8 additions & 2 deletions assets/_scss/vk-post-author.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
text-decoration: none;
border-bottom: none;
}
#padSection h2,
#padSection h3,
#padSection h4,
#padSection h5,
#padSection dl,
Expand Down Expand Up @@ -50,7 +52,9 @@
width: 100%;
}

#padSection h4 {
#padSection .padSectionTitle {
display: block;
font-weight: bold;
margin-bottom: 20px;
padding-bottom: 4px;
border-bottom: 1px dotted var(--wp--preset--color--border-normal, #e5e5e5);
Expand Down Expand Up @@ -119,7 +123,9 @@
margin-top: 15px;
clear: both;
position: relative;
h5 {
.latestEntriesTitle {
font-weight:bold;
display: block;
margin-top: 0;
margin-bottom: 10px;
padding-bottom: 5px;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/vk-post-author.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions post-author-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ function pad_set_css() {
function pad_get_default_options() {
$display_author_options = array(
'author_box_title' => __( 'Author Profile', 'vk-post-author-display' ),
'author_box_title_tag' => 'h4',
'author_picture_style' => 'square',
'list_box_title' => __( 'Latest entries', 'vk-post-author-display' ),
'list_box_title_tag' => 'h5',
'author_archive_link' => 'hide',
'author_archive_link_txt' => __( 'Author Archives', 'vk-post-author-display' ),
'show_thumbnail' => 'display',
Expand Down Expand Up @@ -252,8 +254,10 @@ function pad_plugin_options_validate( $input ) {
$output = $defaults = pad_get_default_options();

$output['author_box_title'] = wp_kses_post( $input['author_box_title'] );
$output['author_box_title_tag'] = esc_html( $input['author_box_title_tag'] );
$output['author_picture_style'] = esc_html( $input['author_picture_style'] );
$output['list_box_title'] = wp_kses_post( $input['list_box_title'] );
$output['list_box_title_tag'] = esc_html( $input['list_box_title_tag'] );
$output['author_archive_link'] = esc_html( $input['author_archive_link'] );
$output['author_archive_link_txt'] = wp_kses_post( $input['author_archive_link_txt'] );
$output['show_thumbnail'] = esc_html( $input['show_thumbnail'] );
Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Display to Post Author Information Box on bottom of the contents.

== Changelog ==

= 1.25.0 =
[ Add function ] Add a feature that allows specifying the tag.

= 1.24.1 =
[ Specification Change ] Fix Twitter icon to X icon

Expand Down
17 changes: 9 additions & 8 deletions view.post-author.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ public static function pad_get_author_entries() {

// Author entries.
global $post;
$args = array(
$args = array(
'post_type' => $post->post_type,
'posts_per_page' => 4,
'author' => $post->post_author,
);
$args = apply_filters( 'pad_get_author_entries_args', $args );
$loop = new WP_Query( $args );
$entry_unit = '<div id="latestEntries">' . "\n";
$entry_unit .= '<h5>' . wp_kses_post( $options['list_box_title'] ) . '</h5>' . "\n";
$args = apply_filters( 'pad_get_author_entries_args', $args );
$loop = new WP_Query( $args );
$entry_unit = '<div id="latestEntries">' . "\n";

$entry_unit .= '<' . esc_html( $options['list_box_title_tag'] ) . ' class="latestEntriesTitle">' . wp_kses_post( $options['list_box_title'] ) . '</' . esc_html( $options['list_box_title_tag'] ) . '>' . "\n";
if ( 'display' === $options['author_archive_link'] ) {
$entry_unit .= '<p class="authorLink"><a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author"><i class="fa fa-chevron-circle-right" aria-hidden="true"></i> ' . wp_kses_post( $options['author_archive_link_txt'] ) . '</a></p>' . "\n";
}
Expand Down Expand Up @@ -185,10 +186,10 @@ public static function pad_get_author_entries() {
*/
public static function pad_get_author_box( $layout = 'normal' ) {
$options = pad_get_plugin_options();
$author_unit = '<div class="padSection" id="padSection">';
$author_unit = '<section class="padSection" id="padSection">';

if ( 'author_archive' !== $layout ) {
$author_unit .= '<h4>' . esc_html( $options['author_box_title'] ) . '</h4>';
$author_unit .= '<'. esc_html( $options['author_box_title_tag'] ) .' class="padSectionTitle">' . esc_html( $options['author_box_title'] ) . '</'. esc_html( $options['author_box_title_tag'] ) .'>';
}

$author_unit .= self::pad_get_author_profile();
Expand All @@ -197,7 +198,7 @@ public static function pad_get_author_box( $layout = 'normal' ) {
$author_unit .= self::pad_get_author_entries();
}

$author_unit .= '</div>';
$author_unit .= '</section>';
return $author_unit;
}
}
Expand Down

0 comments on commit 13d7009

Please sign in to comment.