settings-posttypes.php
291 lines
| 1 | <?php |
| 2 | $types = $this->getPostTypes(); |
| 3 | $thumbnail_sizes = get_intermediate_image_sizes(); |
| 4 | settings_fields( 'nestedpages-posttypes' ); |
| 5 | ?> |
| 6 | |
| 7 | <h3><?php _e('Enable Post Types:', 'wp-nested-pages'); ?></h3> |
| 8 | |
| 9 | <div class="nestedpages-settings-table"> |
| 10 | <?php foreach ($types as $type) : ?> |
| 11 | <div class="row-container"> |
| 12 | <div class="head"> |
| 13 | <div class="checkbox"> |
| 14 | <input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>]" value="<?php echo esc_attr($type->name); ?>" <?php if ( $type->np_enabled ) echo 'checked'; ?> data-nestedpages-settings-row-checkbox id="post-type-<?php echo esc_attr($type->name); ?>" /> |
| 15 | </div> |
| 16 | <label for="post-type-<?php echo $type->name; ?>"> |
| 17 | <?php |
| 18 | echo esc_html($type->label); |
| 19 | if ( $type->hierarchical ) echo ' <em>(' . __('Hierarchical', 'wp-nested-pages') . ')</em>'; |
| 20 | ?> |
| 21 | </label> |
| 22 | <a href="#" class="button" data-toggle-nestedpages-pt-settings><?php _e('Settings', 'wp-nested-pages'); ?></a> |
| 23 | </div><!-- .head --> |
| 24 | <div class="body"> |
| 25 | <ul class="settings-details"> |
| 26 | <li> |
| 27 | <div class="row"> |
| 28 | <div class="description"> |
| 29 | <p><strong><?php _e('Replace Default Menu', 'wp-nested-pages'); ?>*</strong><br /> |
| 30 | <?php _e('Replace the default top-level item with the nested view link.', 'wp-nested-pages'); ?></p> |
| 31 | </div> |
| 32 | <div class="field"> |
| 33 | <label><input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][replace_menu]" value="true" <?php if ( $type->replace_menu ) echo 'checked'; ?> /><?php echo __('Replace Default') . ' ' . esc_html($type->label) . ' ' . __('Menu', 'wp-nested-pages'); ?></label> |
| 34 | </div><!-- .field --> |
| 35 | </div><!-- .row --> |
| 36 | </li> |
| 37 | <li> |
| 38 | <div class="row"> |
| 39 | <div class="description"> |
| 40 | <p><strong><?php _e('Remove Default Link', 'wp-nested-pages'); ?></strong><br /> |
| 41 | <?php _e('If the default menu is replaced, a link to the default view will be added. Select this to remove the link', 'wp-nested-pages'); ?> |
| 42 | </div> |
| 43 | <div class="field"> |
| 44 | <label><input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][hide_default]" value="true" <?php if ( $type->hide_default ) echo 'checked'; ?> /><?php echo __('Hide Default', 'wp-nested-pages') . ' ' . esc_html($type->label) . ' ' . __('Link', 'wp-nested-pages'); ?></label> |
| 45 | </div> |
| 46 | </div><!-- .row --> |
| 47 | </li> |
| 48 | <li> |
| 49 | <div class="row"> |
| 50 | <div class="description"> |
| 51 | <p><strong><?php _e('Disable Sorting', 'wp-nested-pages'); ?></strong><br /> |
| 52 | <?php _e('Remove drag and drop sorting from this post type.', 'wp-nested-pages'); ?></p> |
| 53 | </div> |
| 54 | <div class="field"> |
| 55 | <label><input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][disable_sorting]" value="true" <?php if ( $type->disable_sorting ) echo 'checked'; ?> /><?php echo __('Disable Sorting') ?></label> |
| 56 | </div><!-- .field --> |
| 57 | </div><!-- .row --> |
| 58 | </li> |
| 59 | <?php if ( $type->hierarchical ) : ?> |
| 60 | <li> |
| 61 | <div class="row"> |
| 62 | <div class="description"> |
| 63 | <p><strong><?php _e('Disable Nesting', 'wp-nested-pages'); ?>**</strong><br> |
| 64 | <?php _e('To disable nesting on hierarchical post types, select this option.', 'wp-nested-pages'); ?></p> |
| 65 | </div> |
| 66 | <div class="field"> |
| 67 | <label><input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][disable_nesting]" value="true" <?php if ( $type->disable_nesting ) echo 'checked '; ?>/><?php echo __('Disable Nesting for', 'wp-nested-pages') . ' ' . esc_html($type->label); ?></label> |
| 68 | </div> |
| 69 | </div><!-- .row --> |
| 70 | </li> |
| 71 | <?php endif; ?> |
| 72 | <li> |
| 73 | <div class="row"> |
| 74 | <div class="description"> |
| 75 | <p><strong><?php _e('Assign Page for Listing', 'wp-nested-pages'); ?></strong><br /> |
| 76 | <?php _e('Adds contextual links and post counts to the page row for the assigned post type.', 'wp-nested-pages'); ?></p> |
| 77 | </div> |
| 78 | <div class="field"> |
| 79 | <label><input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][post_type_page_assignment]" <?php if ( $type->page_assignment && $this->post_repo->postExists($type->page_assignment_id, 'page') ) echo 'checked'; ?> data-nestedpages-assign-post-type value="true" /><?php _e('Assign Page', 'wp-nested-pages'); ?></label> |
| 80 | <input type="hidden" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][post_type_page_assignment_page_id]" data-nested-pages-assign-post-type-id value="<?php if ( $type->page_assignment_id ) echo $type->page_assignment_id; ?>" /> |
| 81 | <input type="hidden" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][post_type_page_assignment_page_title]" data-nested-pages-assign-post-type-title value="<?php if ( $type->page_assignment_title ) echo $type->page_assignment_title; ?>" /> |
| 82 | |
| 83 | <div class="nestedpages-assignment-display" style="display:none;"> |
| 84 | <div class="nestedpages-page-pt-assignment-selection" data-nestedpages-page-pt-assignment-selection <?php if ( !$type->page_assignment_id || !$this->post_repo->postExists($type->page_assignment_id, 'page') ) echo 'style="display:none;"'?>> |
| 85 | <?php if ( $type->page_assignment_id ) : ?> |
| 86 | <?php _e('Currently assigned to:', 'wp-nested-pages'); ?> <?php echo $type->page_assignment_title; ?> <a href="#" data-nestedpages-page-pt-assignment-remove>(<?php _e('Remove', 'wp-nested-pages'); ?>)</a> |
| 87 | <?php endif; ?> |
| 88 | </div> |
| 89 | <div class="nestedpages-page-pt-assignment" data-nestedpages-post-search-form <?php if ( $type->page_assignment_id && $this->post_repo->postExists($type->page_assignment_id, 'page') ) echo 'style="display:none"';?>> |
| 90 | <?php |
| 91 | $recent_pages = $this->listing_repo->recentPosts('page'); |
| 92 | if ( $recent_pages ) : |
| 93 | ?> |
| 94 | <input type="search" data-nestedpages-post-search="page" placeholder="<?php _e('Search Pages', 'wp-nested-pages'); ?>" /> |
| 95 | <div class="np-quickedit-info" style="display:none;" data-nestedpages-no-results><?php _e('No pages were found.', 'wp-nested-pages'); ?></div> |
| 96 | <img src="<?php echo NestedPages\Helpers::plugin_url(); ?>/assets/images/spinner.gif" alt="<?php _e('Loading', 'wp-nested-pages'); ?>" style="display:none;" data-nestedpages-loading /> |
| 97 | <div class="nestedpages-page-search-results" data-nestedpages-search-results> |
| 98 | <ul> |
| 99 | <?php foreach($recent_pages as $page) : ?> |
| 100 | <li><a href="#" data-assignment-page-id="<?php echo esc_attr($page->ID); ?>" data-assignment-page-title="<?php echo esc_html($page->post_title); ?>"><?php echo esc_html($page->post_title); ?></a></li> |
| 101 | <?php endforeach; ?> |
| 102 | </ul> |
| 103 | </div><!-- .nestedpages-page-search-results --> |
| 104 | <?php else : ?> |
| 105 | <div class="np-quickedit-info"> |
| 106 | <?php _e('There are currently no pages available.', 'wp-nested-pages'); ?> |
| 107 | </div> |
| 108 | <?php endif; ?> |
| 109 | </div><!-- .nestedpages-page-pt-assignment --> |
| 110 | </div><!-- .nestedpages-assignment-display --> |
| 111 | </div><!-- .field --> |
| 112 | </div><!-- .row --> |
| 113 | </li> |
| 114 | <li> |
| 115 | <?php |
| 116 | $thumbnails_enabled = $this->post_type_repo->thumbnails($type->name, 'enabled'); |
| 117 | $thumbnail_source = $this->post_type_repo->thumbnails($type->name, 'source'); |
| 118 | $thumbnail_size = $this->post_type_repo->thumbnails($type->name, 'display_size'); |
| 119 | ?> |
| 120 | <div class="row"> |
| 121 | <div class="description"> |
| 122 | <p><strong><?php _e('Display Thumbnails', 'wp-nested-pages'); ?></strong><br> |
| 123 | <?php _e('Display the thumbnail in the list sort view.', 'wp-nested-pages'); ?><br><br> |
| 124 | <?php _e('Note: Thumbnail width is displayed at a maximum of 80px in the nested pages view. The image is scaled proportionally.', 'wp-nested-pages'); ?></p> |
| 125 | </div> |
| 126 | <div class="field"> |
| 127 | <label><input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][thumbnails][display]" value="true" <?php if ( $thumbnails_enabled ) echo 'checked'; ?> data-enable-thumbnails /><?php echo __('Display Thumbnails for', 'wp-nested-pages') . ' ' . esc_html($type->label); ?></label> |
| 128 | |
| 129 | <div class="thumbnail-options" data-thumbnail-options <?php if ( !$thumbnails_enabled ) echo 'style="display:none;"'; ?>> |
| 130 | <label><?php _e('Thumbnail Source', 'wp-nested-pages'); ?></label> |
| 131 | <select name="nestedpages_posttypes[<?php echo $type->name; ?>][thumbnails][size]"> |
| 132 | <?php |
| 133 | foreach ( $thumbnail_sizes as $size ){ |
| 134 | echo '<option value="' . esc_attr($size) . '"'; |
| 135 | if ( $size == $thumbnail_source ) echo ' selected'; |
| 136 | echo '>' . esc_html($size) . '</option>'; |
| 137 | } |
| 138 | ?> |
| 139 | </select> |
| 140 | |
| 141 | <label><?php _e('Thumbnail Display Size', 'wp-nested-pages'); ?></label> |
| 142 | <select name="nestedpages_posttypes[<?php echo $type->name; ?>][thumbnails][display_size]"> |
| 143 | <option value="small" <?php if ( $thumbnail_size == 'small' ) echo ' selected';?>><?php _e('Small', 'wp-nested-pages'); ?>(50px)</option> |
| 144 | <option value="medium" <?php if ( $thumbnail_size == 'medium' ) echo ' selected';?>><?php _e('Medium', 'wp-nested-pages'); ?>(80px)</option> |
| 145 | <option value="large" <?php if ( $thumbnail_size == 'large' ) echo ' selected';?>><?php _e('Large', 'wp-nested-pages'); ?>(150px)</option> |
| 146 | </select> |
| 147 | </div><!-- .thumbnail-options --> |
| 148 | </div> |
| 149 | </div><!-- .row --> |
| 150 | </li> |
| 151 | <li> |
| 152 | <div class="row"> |
| 153 | <div class="description"> |
| 154 | <p><strong><?php _e('Configure Standard Fields', 'wp-nested-pages'); ?></strong><br> |
| 155 | <?php _e('Remove standard fields from the quick edit form.', 'wp-nested-pages'); ?></p> |
| 156 | </div> |
| 157 | <div class="field"> |
| 158 | <label><input type="checkbox" data-toggle-nestedpages-sf-settings name="nestedpages_posttypes[<?php echo $type->name; ?>][standard_fields_enabled]" value="true" <?php if ( $type->standard_fields_enabled ) echo 'checked '; ?>/><?php _e('Configure Standard Fields', 'wp-nested-pages'); ?></label> |
| 159 | |
| 160 | <div class="standard-fields"> |
| 161 | <h5><?php _e('Check to remove from Quick Edit.', 'wp-nested-pages'); ?></h5> |
| 162 | <div class="custom-field-group"> |
| 163 | <ul> |
| 164 | <?php |
| 165 | $out = ""; |
| 166 | foreach ( $this->settings->standardFields($type->name) as $name => $label ) : |
| 167 | if ( $name != 'taxonomies' ) : |
| 168 | $out .= '<li>'; |
| 169 | $out .= '<label>'; |
| 170 | $out .= '<input type="checkbox" name="nestedpages_posttypes[' . esc_attr($type->name) . '][standard_fields][standard][' . esc_attr($name) . ']" value="true"'; |
| 171 | if ( $name == 'hide_taxonomies' ) $out .= ' data-hide-taxonomies'; |
| 172 | if ( $this->post_type_repo->fieldEnabled($type->name, 'standard', $name, 'standard_fields') ) $out .= ' checked'; |
| 173 | $out .= ' />' . esc_html($label); |
| 174 | $out .= '</label>'; |
| 175 | $out .= '</li>'; |
| 176 | else : // Taxonomies |
| 177 | foreach ( $label as $tax_name => $tax_label ) : |
| 178 | $disabled = $this->post_type_repo->taxonomyDisabled($tax_name, $type->name); |
| 179 | $out .= '<li data-taxonomy-single style="margin-left:20px;'; |
| 180 | if ( $this->post_type_repo->fieldEnabled($type->name, 'standard', 'hide_taxonomies', 'standard_fields') ) $out .= 'display:none;'; |
| 181 | $out .= '">'; |
| 182 | $out .= '<label>'; |
| 183 | $out .= '<input type="checkbox" name="nestedpages_posttypes[' . esc_attr($type->name) . '][standard_fields][standard][taxonomies][' . esc_attr($tax_name) . ']" value="true"'; |
| 184 | if ( $disabled ) $out .= ' checked'; |
| 185 | $out .= ' />' . esc_html($tax_label); |
| 186 | $out .= '</label>'; |
| 187 | $out .= '</li>'; |
| 188 | endforeach; |
| 189 | endif; |
| 190 | endforeach; |
| 191 | echo $out; |
| 192 | ?> |
| 193 | </ul> |
| 194 | </div><!-- .custom-field-group --> |
| 195 | </div><!-- .standard-fields --> |
| 196 | </div><!-- .field --> |
| 197 | </div><!-- .row --> |
| 198 | </li> |
| 199 | <?php if ( $this->integrations->plugins->acf->installed ) : ?> |
| 200 | <li> |
| 201 | <div class="row"> |
| 202 | <div class="description"> |
| 203 | <p><strong><?php _e('Configure Custom Fields', 'wp-nested-pages'); ?></strong><br> |
| 204 | <?php _e('Set which custom fields display in the quick edit form.', 'wp-nested-pages'); ?></p> |
| 205 | </div> |
| 206 | <div class="field"> |
| 207 | <label><input type="checkbox" data-toggle-nestedpages-cf-settings name="nestedpages_posttypes[<?php echo $type->name; ?>][custom_fields_enabled]" value="true" <?php if ( $type->custom_fields_enabled ) echo 'checked'; ?> /><?php _e('Configure Custom Fields', 'wp-nested-pages'); ?></label> |
| 208 | |
| 209 | <div class="custom-fields"> |
| 210 | <h5><?php _e('Check to Include in Quick Edit.', 'wp-nested-pages'); ?></h5> |
| 211 | <?php |
| 212 | // Advanced Custom Fields |
| 213 | $acf_fields = $this->integrations->plugins->acf->getFieldsForPostType($type->name); |
| 214 | if ( $acf_fields ) : |
| 215 | $out = '<div class="custom-field-group">'; |
| 216 | $out .= '<p>' . __('Advanced Custom Fields', 'wp-nested-pages') . '</p>'; |
| 217 | $out .= '<ul class="indented">'; |
| 218 | foreach ($acf_fields as $field){ |
| 219 | $out .= '<li>'; |
| 220 | $out .= '<label>'; |
| 221 | $out .= '<input type="checkbox" name="nestedpages_posttypes[' . esc_attr($type)->name . '][custom_fields][acf][' . esc_attr($field['key']) . ']" value="' . esc_attr($field['type']) . '"'; |
| 222 | if ( $this->post_type_repo->fieldEnabled($type->name, 'acf', $field['key']) ) $out .= ' checked'; |
| 223 | $out .= '/>' . esc_html($field['label']) . ' (' . esc_html($field['type']) . ')'; |
| 224 | $out .= '</label>'; |
| 225 | $out .= '</li>'; |
| 226 | } |
| 227 | $out .= '</ul>'; |
| 228 | $out .= '</div><!-- .custom-field-group -->'; |
| 229 | echo $out; |
| 230 | else : |
| 231 | echo __('No ACF Fields configured for this post type', 'wp-nested-pages'); |
| 232 | endif; |
| 233 | ?> |
| 234 | </div><!-- .custom-fields --> |
| 235 | </div><!-- .field --> |
| 236 | </div><!-- .row --> |
| 237 | </li> |
| 238 | <?php endif; ?> |
| 239 | <?php |
| 240 | if ( $type->name !== 'page' ) : |
| 241 | $h_taxonomies = $this->post_type_repo->getTaxonomies($type->name, true); |
| 242 | $f_taxonomies = $this->post_type_repo->getTaxonomies($type->name, false); |
| 243 | $taxonomies = array_merge($h_taxonomies, $f_taxonomies); |
| 244 | ?> |
| 245 | <li> |
| 246 | <div class="row"> |
| 247 | <div class="description"> |
| 248 | <p><strong><?php _e('Sort Options', 'wp-nested-pages'); ?></strong><br /> |
| 249 | <?php _e('Add and remove sort options.', 'wp-nested-pages'); ?></p> |
| 250 | </div> |
| 251 | <div class="field"> |
| 252 | <div class="nestedpages-sort-options-selection"> |
| 253 | <label> |
| 254 | <input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][sort_options][author]" value="true" <?php if ( $this->post_type_repo->sortOptionEnabled($type->name, 'author') ) echo 'checked'; ?> /> |
| 255 | <?php _e('Author') ?> |
| 256 | </label> |
| 257 | <label> |
| 258 | <input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][sort_options][orderby]" value="true" <?php if ( $this->post_type_repo->sortOptionEnabled($type->name, 'orderby') ) echo 'checked'; ?> /> |
| 259 | <?php _e('Order By') ?> |
| 260 | </label> |
| 261 | <label> |
| 262 | <input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][sort_options][order]" value="true" <?php if ( $this->post_type_repo->sortOptionEnabled($type->name, 'order') ) echo 'checked'; ?> /> |
| 263 | <?php _e('Order') ?> |
| 264 | </label> |
| 265 | |
| 266 | <?php if ( !empty($taxonomies) ) : foreach ( $taxonomies as $tax ) : ?> |
| 267 | <label> |
| 268 | <input type="checkbox" name="nestedpages_posttypes[<?php echo esc_attr($type->name); ?>][sort_options][taxonomies][<?php echo $tax->name; ?>]" value="true" <?php if ( $this->post_type_repo->sortOptionEnabled($type->name, $tax->name, true) ) echo 'checked'; ?> /> |
| 269 | <?php echo $tax->label; ?> |
| 270 | </label> |
| 271 | <?php endforeach; endif; ?> |
| 272 | |
| 273 | <!-- .nestedpages-sort-options-selection --> |
| 274 | </div><!-- .field --> |
| 275 | </div><!-- .row --> |
| 276 | </li> |
| 277 | <?php endif; ?> |
| 278 | </ul> |
| 279 | </div><!-- .body --> |
| 280 | </div><!-- .post-type --> |
| 281 | <?php endforeach; ?> |
| 282 | </div><!-- .nestedpages-settings-posttypes --> |
| 283 | |
| 284 | <div class="nestedpages-settings-disclaimers"> |
| 285 | <p style="font-size:12px;margin-bottom:15px;"> |
| 286 | *<?php _e('If default menu is not replaced, an additional submenu item will be added for "Nested/Sort View"', 'wp-nested-pages'); ?> |
| 287 | </p> |
| 288 | <p style="font-size:12px;"> |
| 289 | **<?php _e('<strong>Important:</strong> Changing page structures on live sites may effect SEO and existing inbound links. Limit URL structure changes on live sites by disabling nesting. Sorting within the current nesting structure will still be available. If nesting changes are made to a live site, it may help to add a 301 redirect from the old location to the new one.', 'wp-nested-pages'); ?> |
| 290 | </p> |
| 291 | </div> |