görünüm:
kod:
## widget_tabs
add_action( 'widgets_init', 'tie_widget_tabs_box' );
function tie_widget_tabs_box(){
register_widget( 'tie_widget_tabs' );
}
class tie_widget_tabs extends WP_Widget {
function tie_widget_tabs() {
$widget_ops = array( 'description' => 'Most Popular, Recent, Comments, Tags' );
parent::__construct( 'widget_tabs', THEME_NAME .' - '.__( 'Tabs' , 'tie') , $widget_ops );
}
function widget( $args, $instance ) {
if( !empty( $instance['posts_order'] ) )
$posts_order = $instance['posts_order'];
if( empty($instance['posts_number']) || $instance['posts_number'] == ' ' || !is_numeric($instance['posts_number'])) $posts_number = 5;
else $posts_number = $instance['posts_number'];
?>
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['posts_number'] = strip_tags( $new_instance['posts_number'] );
$instance['posts_order'] = strip_tags( $new_instance['posts_order'] );
$instance['tabs_order'] = strip_tags( $new_instance['tabs_order'] );
return $instance;
}
function form( $instance ) {
$tie_random_id = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 5);
$id = explode("-", $this->get_field_id("widget_id"));
$widget_id = $id[1]. "-" .$tie_random_id;
$defaults = array( 'posts_order' => 'popular', 'posts_number' => 5 );
$instance = wp_parse_args( (array) $instance, $defaults );
?>
<script>
jQuery(document).ready(function($) {
jQuery( "#-order" ).sortable({
placeholder: "ui-state-highlight",
stop: function(event, ui) {
var data = "";
jQuery( "#-order li" ).each(function(i, el){
var p = jQuery( this ).data( 'tab' );
data += p+",";
});
jQuery("#-tabs-order").val(data.slice(0, -1));
}
});
});
</script>
'. __( "click Save button to be able to change the order of tabs ." , "tie").'
- >
- '. __ti( "Popular" ) .' ';
- '. __ti( "Recent" ) .' ';
- '. __ti( "Comments" ) .' ';
- '. __ti( "Tags" ) .' ';
$tabs_order = 'p,r,c,t';
if( !empty( $instance['tabs_order'] ) ){
$tabs_order = $instance['tabs_order'];
}
$tabs_order_array = explode( ',' , $tabs_order );
foreach ( $tabs_order_array as $tab ){
if( $tab == 'p' )
echo '
if( $tab == 'r' )
echo '
if( $tab == 'c' )
echo '
if( $tab == 't' )
echo '
}
?>
}
}
?>
Ek Olarak: