Ticket #1298: post-author-layout-2.diff
File post-author-layout-2.diff, 6.8 KB (added by , 14 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 bb_post_author_layout_section( $section, array( 88 'before' => "\n\t\t\t\t\t<li class='post-author-layout-section' id='$section'>", 89 'after' => '</li>' 90 ) ); 91 } 92 ?> 93 94 </ul> 95 <ul id="post-author-layout-inactive" class="post-author-layout"> 96 <?php 97 foreach ( bb_get_inactive_post_author_layout_sections() as $section ) { 98 bb_post_author_layout_section( $section, array( 99 'before' => "\n\t\t\t\t\t<li class='post-author-layout-section' id='$section'>", 100 'after' => '</li>' 101 ) ); 102 } 103 ?> 104 105 </ul> 106 107 <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> 108 109 <input type="hidden" id="post_author_layout" name="post_author_layout" value="<?php 110 echo implode( '|', array_map( 'urlencode', bb_get_active_post_author_layout_sections() ) ); 111 ?>" /> 112 </div> 113 </div> 114 <script type="text/javascript"> 115 jQuery(function($){ 116 $('#post-author-layout').show(); 117 $('.post-author-layout').Sortable({ 118 accept: 'post-author-layout-section', 119 onStop: function(){ 120 $('#post_author_layout').val($.map($.SortSerialize('post-author-layout-active').o['post-author-layout-active'], encodeURIComponent).join('|')); 121 } 122 }).find('* *').click(function(e){ 123 e.stopPropagation(); 124 e.preventDefault(); 125 return false; 126 }); 127 }); 128 </script> 129 </fieldset> 66 130 <fieldset class="submit"> 67 131 <?php bb_nonce_field( 'options-reading-update' ); ?> 68 132 <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, $args = '' ) { 3612 extract( wp_parse_args( $args, array( 3613 'before' => '', 3614 'after' => '', 3615 'args' => array() 3616 ) ) ); 3617 3618 if ( $before ) { 3619 ob_start(); 3620 } 3621 $result = false !== call_user_func_array( $section, $args ); 3622 if ( $before ) { 3623 $data = ob_get_clean(); 3624 if ( $result ) 3625 echo $before; 3626 echo $data; 3627 } 3628 if ( $result ) 3629 echo $after; 3630 } 3631 3632 function bb_post_author_layout( $args = array() ) { 3633 $defaults = array( 3634 'default' => array( 'post_author_avatar_link', 'post_author_link', 'post_author_title_link' ) 3635 ); 3636 $args = wp_parse_args( $args, $defaults ); 3637 3638 if ( !$layout = bb_get_option( 'bb_post_author_layout' ) ) { 3639 $layout = $args['default']; 3640 } 3641 3642 foreach ( $layout as $section ) { 3643 bb_post_author_layout_section( $section, array( 'after' => '<br/>' ) ); 3644 } 3645 } 3646 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>