Ticket #1298: post-author-layout.diff
File post-author-layout.diff, 6.4 KB (added by , 15 years ago) |
---|
-
bb-admin/options-reading.php
3 3 require_once( 'admin.php' ); 4 4 5 5 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && $_POST['action'] == 'update') { 6 6 7 7 bb_check_admin_referer( 'options-reading-update' ); 8 8 9 9 foreach ( (array) $_POST as $option => $value ) { 10 10 if ( !in_array( $option, array('_wpnonce', '_wp_http_referer', 'action', 'submit') ) ) { 11 $option = trim( $option ); 12 $value = is_array( $value ) ? $value : trim( $value ); 13 $value = stripslashes_deep( $value ); 14 if ( $value ) { 15 bb_update_option( $option, $value ); 11 if ( $option == 'post_author_layout' ) { 12 bb_update_option( 'bb_post_author_layout', array_map( 'urldecode', explode( '|', stripslashes( $value ) ) ) ); 16 13 } else { 17 bb_delete_option( $option ); 14 $option = trim( $option ); 15 $value = is_array( $value ) ? $value : trim( $value ); 16 $value = stripslashes_deep( $value ); 17 if ( $value ) { 18 bb_update_option( $option, $value ); 19 } else { 20 bb_delete_option( $option ); 21 } 18 22 } 19 23 } 20 24 } 21 25 22 26 $goback = add_query_arg('updated', 'true', wp_get_referer()); 23 27 bb_safe_redirect($goback); 24 28 exit; … … 44 48 ) 45 49 ); 46 50 51 function bb_admin_reading_post_author_filter() { 52 return bb_get_current_user_info( 'ID' ); 53 } 54 add_filter( 'get_post_author_id', 'bb_admin_reading_post_author_filter' ); 55 56 wp_enqueue_script( 'interface' ); 57 47 58 $bb_admin_body_class = ' bb-admin-settings'; 48 59 49 60 bb_get_admin_header(); … … 63 74 } 64 75 ?> 65 76 </fieldset> 77 <fieldset id="post-author-layout" style="display: none;"> 78 <div> 79 <div class="label"> 80 <?php _e( 'Post author layout' ); ?> 81 </div> 82 83 <div class="inputs"> 84 <ul id="post-author-layout-active" class="post-author-layout"> 85 <?php 86 foreach ( bb_get_active_post_author_layout_sections() as $section ) { 87 echo "\n\t\t\t\t\t<li class='post-author-layout-section' id='$section'>"; 88 bb_post_author_layout_section( $section ); 89 echo '</li>'; 90 } 91 ?> 92 93 </ul> 94 <ul id="post-author-layout-inactive" class="post-author-layout"> 95 <?php 96 foreach ( bb_get_inactive_post_author_layout_sections() as $section ) { 97 echo "\n\t\t\t\t\t<li class='post-author-layout-section' id='$section'>"; 98 bb_post_author_layout_section( $section ); 99 echo '</li>'; 100 } 101 ?> 102 103 </ul> 104 105 <p><?php _e( 'Arrange the elements you want next to each post by clicking and dragging. Elements in the left column will be shown.' ); ?></p> 106 107 <input type="hidden" id="post_author_layout" name="post_author_layout" value="<?php 108 echo implode( '|', array_map( 'urlencode', bb_get_active_post_author_layout_sections() ) ); 109 ?>" /> 110 </div> 111 </div> 112 <script type="text/javascript"> 113 jQuery(function($){ 114 $('#post-author-layout').show(); 115 $('.post-author-layout').Sortable({ 116 accept: 'post-author-layout-section', 117 onStop: function(){ 118 $('#post_author_layout').val($.map($.SortSerialize('post-author-layout-active').o['post-author-layout-active'], encodeURIComponent).join('|')); 119 } 120 }).find('* *').click(function(e){ 121 e.stopPropagation(); 122 e.preventDefault(); 123 return false; 124 }); 125 }); 126 </script> 127 </fieldset> 66 128 <fieldset class="submit"> 67 129 <?php bb_nonce_field( 'options-reading-update' ); ?> 68 130 <input type="hidden" name="action" value="update" /> -
bb-admin/style.css
1815 1815 } 1816 1816 1817 1817 1818 /* Reading Settings */ 1818 1819 1820 form.settings .post-author-layout { 1821 -moz-border-radius: 6px; 1822 -khtml-border-radius: 6px; 1823 -webkit-border-radius: 6px; 1824 border-radius: 6px; 1825 border: 1px solid #aaa; 1826 padding: 2px; 1827 margin: 0 5px 0 0; 1828 float: left; 1829 min-height: 100px; 1830 width: 100px; 1831 } 1819 1832 1833 form.settings .post-author-layout li { 1834 list-style: none; 1835 } 1820 1836 1837 #post-author-layout-active { 1838 background-color: #fff; 1839 } 1821 1840 1841 #post-author-layout-inactive { 1842 background-color: #ccc; 1843 opacity: .75; 1844 } 1822 1845 1846 .post-author-layout + p { 1847 clear: both; 1848 } 1823 1849 1824 1850 /* Layout classes */ 1825 1851 /* -
bb-includes/functions.bb-template.php
3584 3584 } 3585 3585 } 3586 3586 } 3587 3588 function bb_get_active_post_author_layout_sections() { 3589 if ( is_array( $layout = bb_get_option( 'bb_post_author_layout' ) ) ) 3590 return array_intersect( $layout, bb_get_post_author_layout_sections() ); 3591 return array( 'post_author_avatar_link', 'post_author_link', 'post_author_title_link' ); 3592 } 3593 3594 function bb_get_inactive_post_author_layout_sections() { 3595 if ( !is_array( $layout = bb_get_option( 'bb_post_author_layout' ) ) ) 3596 $layout = array( 'post_author_avatar_link', 'post_author_link', 'post_author_title_link' ); 3597 return array_diff( bb_get_post_author_layout_sections(), $layout ); 3598 } 3599 3600 function bb_get_post_author_layout_sections() { 3601 return apply_filters( 'bb_post_author_layout_sections', array( 3602 'post_author_avatar_link', 3603 'post_author_avatar', 3604 'post_author_link', 3605 'post_author', 3606 'post_author_title_link', 3607 'post_author_title' 3608 ) ); 3609 } 3610 3611 function bb_post_author_layout_section( $section ) { 3612 call_user_func( $section ); 3613 } 3614 3615 function bb_post_author_layout( $args = array() ) { 3616 $defaults = array( 3617 'default' => array( 'avatar_link', 'name_link', 'title_link' ) 3618 ); 3619 $args = wp_parse_args( $args, $defaults ); 3620 3621 if ( !$layout = bb_get_option( 'bb_post_author_layout' ) ) { 3622 $layout = $args['default']; 3623 } 3624 3625 foreach ( $layout as $section ) { 3626 bb_post_author_layout_section( $section ); 3627 echo '<br />'; 3628 } 3629 } 3630 No newline at end of file -
bb-templates/kakumei/post.php
1 1 <div id="position-<?php post_position(); ?>"> 2 2 <div class="threadauthor"> 3 <?php if ( function_exists( 'bb_post_author_layout' ) ) { 4 bb_post_author_layout(); 5 } else { ?> 3 6 <?php post_author_avatar_link(); ?> 4 7 <p> 5 8 <strong><?php post_author_link(); ?></strong><br /> 6 9 <small><?php post_author_title_link(); ?></small> 7 10 </p> 11 <?php } ?> 8 12 </div> 9 13 <div class="threadpost"> 10 14 <div class="post"><?php post_text(); ?></div>