Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/#270-Allow_users_to_move_the_navigation_metabox_or_post_series_box_to_bottom #283

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions orgSeries-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ function orgseries_validate($input) {
$newinput['latest_series_before_template'] = trim(stripslashes($input['latest_series_before_template']));
$newinput['latest_series_inner_template'] = trim(stripslashes($input['latest_series_inner_template']));
$newinput['latest_series_after_template'] = trim(stripslashes($input['latest_series_after_template']));
$newinput['series_post_list_position'] = trim(stripslashes($input['series_post_list_position']));
$newinput['series_metabox_position'] = trim(stripslashes($input['series_metabox_position']));
$newinput['series_navigation_box_position'] = trim(stripslashes($input['series_navigation_box_position']));

//series-icon related settings
$newinput['series_icon_width_series_page'] = (int) $input['series_icon_width_series_page'];
Expand Down Expand Up @@ -290,6 +293,7 @@ function series_automation_core_fieldset() {
$org_name = 'org_series_options';
$series_css_tougle = is_array($org_opt) && isset($org_opt['series_css_tougle']) ? $org_opt['series_css_tougle'] : 'default';
$series_perp_toc = is_array($org_opt) && isset($org_opt['series_perp_toc']) ? $org_opt['series_perp_toc'] : 10;

?>
<div id="topic-toc-settings-automation-core" class="" style="line-height:normal;border:unset;">
<div class="inside" style="padding: 0;margin: 0;">
Expand Down Expand Up @@ -373,6 +377,12 @@ function series_templates_core_fieldset() {
global $orgseries;
$org_opt = $orgseries->settings;
$org_name = 'org_series_options';

$post_box_locations = [
'default'=> __('As in Template', 'organize-series'),
'top' => __('Top', 'organize-series'),
'bottom' => __('Bottom', 'organize-series'),
];
?>
<div id="topic-toc-settings-series-template-core" style="line-height:normal;">
<div class="inside" style="padding: 0;margin: 0;">
Expand All @@ -392,6 +402,20 @@ function series_templates_core_fieldset() {
</td>
</tr>

<tr valign="top"><th scope="row"><label for="series_post_list_position"><?php _e('Series Post List box Location', 'organize-series'); ?></label></th>
<td>
<select name="<?php echo $org_name;?>[series_post_list_position]" id="series_post_list_position">
<?php
foreach($post_box_locations as $key => $label){
$selected = ( isset($org_opt['series_post_list_position']) && $org_opt['series_post_list_position'] === $key ) ? 'selected="selected"' : '';
echo '<option value="'.$key.'" '.$selected.'>'.$label.'</option>';

}
?>
</select>
</td>
</tr>

<tr valign="top"><th scope="row"><label for="series_post_list_post_template"><?php _e('Series Post List Post Title', 'organize-series'); ?></label></th>
<td><input type="text" name="<?php echo $org_name; ?>[series_post_list_post_template]" id="series_post_list_post_template" value="<?php echo esc_attr(htmlspecialchars($org_opt['series_post_list_post_template'])); ?>" class="ppseries-full-width">
</td>
Expand All @@ -418,6 +442,20 @@ function series_templates_core_fieldset() {
</td>
</tr>

<tr valign="top"><th scope="row"><label for="series_metabox_position"><?php _e('Series Metabox Location', 'organize-series'); ?></label></th>
<td>
<select name="<?php echo $org_name;?>[series_metabox_position]" id="series_metabox_position">
<?php
foreach($post_box_locations as $key => $label){
$selected = ( isset($org_opt['series_metabox_position']) && $org_opt['series_metabox_position'] === $key ) ? 'selected="selected"' : '';
echo '<option value="'.$key.'" '.$selected.'>'.$label.'</option>';

}
?>
</select>
</td>
</tr>

<tr valign="top"><th scope="row"><label for="series_meta_excerpt_template"><?php _e('Series Meta (with excerpts):', 'organize-series'); ?></label></th>
<td>
<textarea name="<?php echo $org_name; ?>[series_meta_excerpt_template]" id="series_meta_excerpt_template" class="ppseries-textarea ppseries-full-width"><?php echo esc_html(htmlspecialchars(stripslashes($org_opt['series_meta_excerpt_template']))); ?></textarea>
Expand All @@ -438,6 +476,20 @@ function series_templates_core_fieldset() {
</td>
</tr>

<tr valign="top"><th scope="row"><label for="series_navigation_box_position"><?php _e('Series Post Navigation Location', 'organize-series'); ?></label></th>
<td>
<select name="<?php echo $org_name;?>[series_navigation_box_position]" id="series_navigation_box_position">
<?php
foreach($post_box_locations as $key => $label){
$selected = ( isset($org_opt['series_navigation_box_position']) && $org_opt['series_navigation_box_position'] === $key ) ? 'selected="selected"' : '';
echo '<option value="'.$key.'" '.$selected.'>'.$label.'</option>';

}
?>
</select>
</td>
</tr>

<tr valign="top"><th scope="row"><label for="series_nextpost_nav_custom_text"><?php _e('Next Post', 'organize-series'); ?></label></th>
<td><input type="text" name="<?php echo $org_name; ?>[series_nextpost_nav_custom_text]" id="series_nextpost_nav_custom_text" value="<?php echo esc_attr(htmlspecialchars($org_opt['series_nextpost_nav_custom_text'])); ?>" class="ppseries-full-width">
</td>
Expand Down
56 changes: 48 additions & 8 deletions orgSeries-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ function add_settings($reset = false) {
'series_toc_url' => 'series-toc',
'series_custom_base' => 'series',
'series_perp_toc' => 3,
'series_post_list_limit' => '',
'series_post_list_position' => 'default',
'series_metabox_position' => 'default',
'series_navigation_box_position' => 'default',
'series_toc_title' => __('Series Table of Contents << ','organize-series'),
//new template options
'orgseries_api' => '',
Expand Down Expand Up @@ -521,8 +525,17 @@ function orgSeries_header() {
function add_series_post_list_box($content) {
if ($this->settings['auto_tag_toggle']) {
if ( ( is_single() || is_page() ) && $postlist = wp_postlist_display() ) {
$addcontent = $content;
$content = str_replace('%postcontent%', $addcontent, $postlist);
$position = isset($this->settings['series_post_list_position']) ? $this->settings['series_post_list_position'] : 'default';
if($position === 'top'){
$postlist = str_replace('%postcontent%', '', $postlist);
$content = $postlist.$content;
}elseif($position === 'bottom'){
$postlist = str_replace('%postcontent%', '', $postlist);
$content = $content.$postlist;
}else{
$addcontent = $content;
$content = str_replace('%postcontent%', $addcontent, $postlist);
}
}
}
return $content;
Expand All @@ -532,8 +545,17 @@ function add_series_post_list_box($content) {
function add_series_meta($content) {
if($this->settings['auto_tag_seriesmeta_toggle']) {
if ($series_meta = wp_seriesmeta_write()) {
$addcontent = $content;
$content = str_replace('%postcontent%', $addcontent, $series_meta);
$position = isset($this->settings['series_metabox_position']) ? $this->settings['series_metabox_position'] : 'default';
if($position === 'top'){
$series_meta = str_replace('%postcontent%', '', $series_meta);
$content = $series_meta.$content;
}elseif($position === 'bottom'){
$series_meta = str_replace('%postcontent%', '', $series_meta);
$content = $content.$series_meta;
}else{
$addcontent = $content;
$content = str_replace('%postcontent%', $addcontent, $series_meta);
}
}
}
return $content;
Expand All @@ -548,8 +570,17 @@ function add_series_meta_excerpt($content) {
if ( is_single() ) return;
if($this->settings['auto_tag_seriesmeta_toggle']) {
if ($series_meta = wp_seriesmeta_write(true)) {
$addcontent = $content;
$content = str_replace('%postcontent%', $addcontent, $series_meta);
$position = isset($this->settings['series_metabox_position']) ? $this->settings['series_metabox_position'] : 'default';
if($position === 'top'){
$series_meta = str_replace('%postcontent%', '', $series_meta);
$content = $series_meta.$content;
}elseif($position === 'bottom'){
$series_meta = str_replace('%postcontent%', '', $series_meta);
$content = $content.$series_meta;
}else{
$addcontent = $content;
$content = str_replace('%postcontent%', $addcontent, $series_meta);
}
}
}
return $content;
Expand All @@ -559,8 +590,17 @@ function add_series_meta_excerpt($content) {
function series_nav_filter($content) {
if (is_single() || is_page() ) {
if($this->settings['auto_tag_nav_toggle'] && $series_nav = wp_assemble_series_nav() ) {
$addcontent = $content;
$content = str_replace('%postcontent%', $addcontent, $series_nav);
$position = isset($this->settings['series_navigation_box_position']) ? $this->settings['series_navigation_box_position'] : 'default';
if($position === 'top'){
$series_nav = str_replace('%postcontent%', '', $series_nav);
$content = $series_nav.$content;
}elseif($position === 'bottom'){
$series_nav = str_replace('%postcontent%', '', $series_nav);
$content = $content.$series_nav;
}else{
$addcontent = $content;
$content = str_replace('%postcontent%', $addcontent, $series_nav);
}
}
}
return $content;
Expand Down
12 changes: 6 additions & 6 deletions orgSeries-template-tags.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* This file contains all the functions that users and theme developers can use to add series related information in the blog/theme. IF it is desired that there be more control on the display of series related information it is important to disable the auto-tag option for that particular function in the series options page of the WordPress admin. Functions that are toggable in this way will be indicated in the comments.
* This file contains all the functions that users and theme developers can use to add series related information in the blog/theme. IF it is desired that there be more control on the display of series related information it is important to disable the auto-tag option for that particular function in the series options page of the WordPress admin. Functions that are toggable in this way will be indicated in the comments.

* THEME AUTHORS/POWER USERS NOTE: if you see AUTOTAG in the function description that means that you need to disable the corresponding autotag toggle in the series options page before being able to use the function manually in your theme.
*
* @package Publishpress Series WordPress Plugin
Expand Down Expand Up @@ -481,7 +481,7 @@ function wp_series_nav($series_ID, $next = TRUE, $customtext = 'deprecated', $di
}
}


if($first && !$next && !$prev){
if((int) $seriespost['part'] === 1)
{
Expand All @@ -494,8 +494,8 @@ function wp_series_nav($series_ID, $next = TRUE, $customtext = 'deprecated', $di
$result .= '<a href="' . $link . '" title="' . $title . '">' . $title . '</a>';
}
}


}
if ($display) echo $result;
else return $result;
Expand Down Expand Up @@ -841,7 +841,7 @@ function is_series( $slug = '' ) {
if (!defined('SERIES_QUERYVAR')) {
return false;
}

if ( $wp_query instanceof WP_Query ) {
$series = get_query_var( SERIES_QUERYVAR );
} else {
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ v2.7.0- [===unreleased===]
* Fixed: Incorrect Yoast SEO attributes for Series TOC page #82
* Added: New menu link for Series #278
* Added: Post list series limit #271
* Feature: Allow users to change the navigation, metabox or post series box position #270


v2.6.3- 2021-09-29
* Fixed: Fix "invalid_taxonomy" WP_Error #88
Expand Down