Перемена строк
Ребятки, а как поменять отображение строк в php? Есть плагин, который выводит новостной блог, мне необходимо поменять местами дату и заголовок. Всю голову сломала, в упор не понимаю. Всего в плагине 4 документа, один отвечает за вывод интерфейса настроек, стандартных настроек выбора последовательности отображения элементов он не имеет. Пыталась найти в поисковике статью на данную тематику, но не нашла и впала в ступор. Помогите, пожалуйста.
Есть такой код:
<?php
/**
* Various functions used by the plugin.
*
* @package Recent_Posts_Widget_Extended
* @since 0.9.4
* @author Satrya
* @copyright Copyright (c) 2014, Satrya
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
/**
* Sets up the default arguments.
*
* @since 0.9.4
*/
function rpwe_get_default_args() {
$css_defaults = ".rpwe-block h3{\nbackground: none !important;\nclear: none;\nmargin-bottom: 0 !important;\nmargin-top: 0 !important;\nfont-weight: 400;\nfont-size: 12px !important;\nline-height: 1.5em;\n}\n\n.rpwe-block ul{\nlist-style: none !important;\nmargin-left: 0 !important;\npadding-left: 0 !important;\n}\n\n.rpwe-block li{\nborder-bottom: 1px solid #eee;\nmargin-bottom: 10px;\npadding-bottom: 10px;\nlist-style-type: none;\n}\n\n.rpwe-block a{\ndisplay: inline !important;\ntext-decoration: none;\n}\n\n.rpwe-thumb{\nborder: 1px solid #eee !important;\nbox-shadow: none !important;\nmargin: 2px 10px 2px 0;\npadding: 3px !important;\n}\n\n.rpwe-summary{\nfont-size: 12px;\n}\n\n.rpwe-time{\ncolor: #bbb;\nfont-size: 11px;\n}\n\n.rpwe-alignleft{\ndisplay: inline;\nfloat: left;\n}\n\n.rpwe-alignright{\ndisplay: inline;\nfloat: right;\n}\n\n.rpwe-aligncenter{\ndisplay: block;\nmargin-left: auto;\nmargin-right: auto;\n}\n\n.rpwe-clearfix:before,\n.rpwe-clearfix:after{\ncontent: \"\";\ndisplay: table !important;\n}\n\n.rpwe-clearfix:after{\nclear: both;\n}\n\n.rpwe-clearfix{\nzoom: 1;\n}\n";
$defaults = array(
'title' => esc_attr__( 'Recent Posts', 'rpwe' ),
'title_url' => '',
'date' => true,
'date_relative' => false,
'limit' => 5,
'offset' => 0,
'order' => 'DESC',
'orderby' => 'date',
'cat' => array(),
'tag' => array(),
'taxonomy' => '',
'post_type' => array( 'post' ),
'post_status' => 'publish',
'ignore_sticky' => 1,
'excerpt' => false,
'length' => 10,
'thumb' => true,
'thumb_height' => 45,
'thumb_width' => 45,
'thumb_default' => 'http://placehold.it/45x45/f0f0f0/ccc',
'thumb_align' => 'rpwe-alignleft',
'readmore' => false,
'readmore_text' => __( 'Read More »', 'rpwe' ),
'styles_default' => true,
'css' => $css_defaults,
'cssID' => '',
'before' => '',
'after' => ''
);
// Allow plugins/themes developer to filter the default arguments.
return apply_filters( 'rpwe_default_args', $defaults );
}
/**
* Outputs the recent posts.
*
* @since 0.9.4
*/
function rpwe_recent_posts( $args = array() ) {
echo rpwe_get_recent_posts( $args );
}
/**
* Generates the posts markup.
*
* @since 0.9.4
* @param array $args
* @return string|array The HTML for the random posts.
*/
function rpwe_get_recent_posts( $args = array() ) {
// Set up a default, empty variable.
$html = '';
// Merge the input arguments and the defaults.
$args = wp_parse_args( $args, rpwe_get_default_args() );
// Extract the array to allow easy use of variables.
extract( $args );
// Allow devs to hook in stuff before the loop.
do_action( 'rpwe_before_loop' );
// Display the default style of the plugin.
if ( $args['styles_default'] == true ) {
rpwe_custom_styles();
}
// If the default style is disbale then use the custom css if it not empty.
if ( $args['styles_default'] == false && ! empty( $args['css'] ) ) {
echo '<style>' . $args['css'] . '</style>';
}
// Get the posts query.
$posts = rpwe_get_posts( $args );
if ( $posts->have_posts() ) :
$html = '<div ' . ( ! empty( $args['cssID'] ) ? 'id="' . sanitize_html_class( $args['cssID'] ) . '"' : '' ) . ' class="rpwe-block">';
$html .= '<ul class="rpwe-ul">';
while ( $posts->have_posts() ) : $posts->the_post();
// Thumbnails
$thumb_id = get_post_thumbnail_id(); // Get the featured image id.
$img_url = wp_get_attachment_url( $thumb_id ); // Get img URL.
// Display the image url and crop using the resizer.
$image = rpwe_resize( $img_url, $args['thumb_width'], $args['thumb_height'], true );
// Start recent posts markup.
$html .= '<li class="rpwe-li rpwe-clearfix">';
if ( $args['thumb'] ) :
// Check if post has post thumbnail.
if ( has_post_thumbnail() ) :
$html .= '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
if ( $image ) :
$html .= '<img class="' . esc_attr( $args['thumb_align'] ) . ' rpwe-thumb" src="' . esc_url( $image ) . '" alt="' . esc_attr( get_the_title() ) . '">';
else :
$html .= '<img class="' . esc_attr( $args['thumb_align'] ) . ' rpwe-thumb" src="' . esc_url( $img_url ) . '" alt="' . esc_attr( get_the_title() ) . '" height="' . $args['thumb_height'] . '" width="' . $args['thumb_width'] . '">';
endif;
$html .= '</a>';
// If no post thumbnail found, check if Get The Image plugin exist and display the image.
elseif ( function_exists( 'get_the_image' ) ) :
$html .= get_the_image( array(
'height' => (int) $args['thumb_height'],
'width' => (int) $args['thumb_width'],
'image_class' => esc_attr( $args['thumb_align'] ) . ' rpwe-thumb get-the-image',
'image_scan' => true,
'default_image' => esc_url( $args['thumb_default'] )
) );
// Display default image.
elseif ( ! empty( $args['thumb_default'] ) ) :
$html .= sprintf( '<a href="%1$s" rel="bookmark"><img class="%2$s rpwe-thumb rpwe-default-thumb" src="%3$s" alt="%4$s" width="%5$s" height="%6$s"></a>',
esc_url( get_permalink() ),
esc_attr( $args['thumb_align'] ),
esc_url( $args['thumb_default'] ),
esc_attr( get_the_title() ),
(int) $args['thumb_width'],
(int) $args['thumb_height']
);
endif;
endif;
$html .= '<h3 class="rpwe-title"><a href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'rpwe' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . esc_attr( get_the_title() ) . '</a></h3>';
if ( $args['date'] ) :
$date = get_the_date();
if ( $args['date_relative'] ) :
$date = sprintf( __( '%s ago', 'rpwe' ), human_time_diff( get_the_date( 'U' ), current_time( 'timestamp' ) ) );
endif;
$html .= '<time class="rpwe-time published" datetime="' . esc_html( get_the_date( 'c' ) ) . '">' . esc_html( $date ) . '</time>';
endif;
if ( $args['excerpt'] ) :
$html .= '<div class="rpwe-summary">';
$html .= wp_trim_words( apply_filters( 'rpwe_excerpt', get_the_excerpt() ), $args['length'], ' …' );
if ( $args['readmore'] ) :
$html .= '<a href="' . esc_url( get_permalink() ) . '" class="more-link">' . $args['readmore_text'] . '</a>';
endif;
$html .= '</div>';
endif;
$html .= '</li>';
endwhile;
$html .= '</ul>';
$html .= '</div><!-- Generated by http://wordpress.org/plugins/recent-posts-widget-extended/ -->';
endif;
// Restore original Post Data.
wp_reset_postdata();
// Allow devs to hook in stuff after the loop.
do_action( 'rpwe_after_loop' );
// Return the posts markup.
return $args['before'] . apply_filters( 'rpwe_markup', $html ) . $args['after'];
}
/**
* The posts query.
*
* @since 0.0.1
* @param array $args
* @return array
*/
function rpwe_get_posts( $args = array() ) {
// Query arguments.
$query = array(
'offset' => $args['offset'],
'posts_per_page' => $args['limit'],
'orderby' => $args['orderby'],
'order' => $args['order'],
'post_type' => $args['post_type'],
'post_status' => $args['post_status'],
'ignore_sticky_posts' => $args['ignore_sticky'],
);
// Limit posts based on category.
if ( ! empty( $args['cat'] ) ) {
$query['category__in'] = $args['cat'];
}
// Limit posts based on post tag.
if ( ! empty( $args['tag'] ) ) {
$query['tag__in'] = $args['tag'];
}
/**
* Taxonomy query.
* Prop Miniloop plugin by Kailey Lampert.
*/
if ( ! empty( $args['taxonomy'] ) ) {
parse_str( $args['taxonomy'], $taxes );
$operator = 'IN';
$tax_query = array();
foreach( array_keys( $taxes ) as $k => $slug ) {
$ids = explode( ',', $taxes[$slug] );
if ( count( $ids ) == 1 && $ids['0'] < 0 ) {
// If there is only one id given, and it's negative
// Let's treat it as 'posts not in'
$ids['0'] = $ids['0'] * -1;
$operator = 'NOT IN';
}
$tax_query[] = array(
'taxonomy' => $slug,
'field' => 'id',
'terms' => $ids,
'operator' => $operator
);
}
$query['tax_query'] = $tax_query;
}
// Allow plugins/themes developer to filter the default query.
$query = apply_filters( 'rpwe_default_query_arguments', $query );
// Perform the query.
$posts = new WP_Query( $query );
return $posts;
}
/**
* Custom Styles.
*
* @since 0.8
*/
function rpwe_custom_styles() {
?>
<style>
.rpwe-block h3{background:none!important;clear:none;margin-bottom:0!important;margin-top:0!important;font-weight:400;font-size:12px!important;line-height:1.5em;}.rpwe-block ul{list-style:none!important;margin-left:0!important;padding-left:0!important;}.rpwe-block li{border-bottom:1px solid #eee;margin-bottom:10px;padding-bottom:10px;list-style-type: none;}.rpwe-block a{display:inline!important;text-decoration:none;}.rpwe-thumb{border:1px solid #EEE!important;box-shadow:none!important;margin:2px 10px 2px 0;padding:3px!important;}.rpwe-summary{font-size:12px;}.rpwe-time{color:#bbb;font-size:11px;}.rpwe-alignleft{display:inline;float:left;}.rpwe-alignright{display:inline;float:right;}.rpwe-aligncenter{display:block;margin-left: auto;margin-right: auto;}.rpwe-clearfix:before,.rpwe-clearfix:after{content:"";display:table !important;}.rpwe-clearfix:after{clear:both;}.rpwe-clearfix{zoom:1;}
</style>
<?php
}
и такой:
<?php
/**
* Widget forms.
*
* @package Recent_Posts_Widget_Extended
* @since 0.9.4
* @author Satrya
* @copyright Copyright (c) 2014, Satrya
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
?>
<div class="rpwe-columns-3">
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>">
<?php _e( 'Title', 'rpwe' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'title_url' ); ?>">
<?php _e( 'Title URL', 'rpwe' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title_url' ); ?>" name="<?php echo $this->get_field_name( 'title_url' ); ?>" type="text" value="<?php echo esc_url( $instance['title_url'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'cssID' ); ?>">
<?php _e( 'CSS ID', 'rpwe' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'cssID' ); ?>" name="<?php echo $this->get_field_name( 'cssID' ); ?>" type="text" value="<?php echo sanitize_html_class( $instance['cssID'] ); ?>"/>
</p>
<p>
<input id="<?php echo $this->get_field_id( 'styles_default' ); ?>" name="<?php echo $this->get_field_name( 'styles_default' ); ?>" type="checkbox" <?php checked( $instance['styles_default'] ); ?> />
<label class="input-checkbox" for="<?php echo $this->get_field_id( 'styles_default' ); ?>">
<?php _e( 'Use Default Styles', 'rpwe' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'before' ); ?>">
<?php _e( 'HTML or text before the recent posts', 'rpwe' );?>
</label>
<textarea class="widefat" id="<?php echo $this->get_field_id( 'before' ); ?>" name="<?php echo $this->get_field_name( 'before' ); ?>" rows="5"><?php echo htmlspecialchars( stripslashes( $instance['before'] ) ); ?></textarea>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'after' ); ?>">
<?php _e( 'HTML or text after the recent posts', 'rpwe' );?>
</label>
<textarea class="widefat" id="<?php echo $this->get_field_id( 'after' ); ?>" name="<?php echo $this->get_field_name( 'after' ); ?>" rows="5"><?php echo htmlspecialchars( stripslashes( $instance['after'] ) ); ?></textarea>
</p>
</div>
<div class="rpwe-columns-3">
<p>
<input class="checkbox" type="checkbox" <?php checked( $instance['ignore_sticky'], 1 ); ?> id="<?php echo $this->get_field_id( 'ignore_sticky' ); ?>" name="<?php echo $this->get_field_name( 'ignore_sticky' ); ?>" />
<label for="<?php echo $this->get_field_id( 'ignore_sticky' ); ?>">
<?php _e( 'Ignore sticky posts', 'rpwe' ); ?>
</label>
</p>
<div class="rpwe-multiple-check-form">
<label>
<?php _e( 'Post Types', 'rpwe' ); ?>
</label>
<ul>
<?php foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $type ) : ?>
<li>
<input type="checkbox" value="<?php echo esc_attr( $type->name ); ?>" id="<?php echo $this->get_field_id( 'post_type' ) . '-' . $type->name; ?>" name="<?php echo $this->get_field_name( 'post_type' ); ?>[]" <?php checked( is_array( $instance['post_type'] ) && in_array( $type->name, $instance['post_type'] ) ); ?> />
<label for="<?php echo $this->get_field_id( 'post_type' ) . '-' . $type->name; ?>">
<?php echo esc_html( $type->labels->name ); ?>
</label>
</li>
<?php endforeach; ?>
</ul>
</div>
<p>
<label for="<?php echo $this->get_field_id( 'post_status' ); ?>">
<?php _e( 'Post Status', 'rpwe' ); ?>
</label>
<select class="widefat" id="<?php echo $this->get_field_id( 'post_status' ); ?>" name="<?php echo $this->get_field_name( 'post_status' ); ?>" style="width:100%;">
<?php foreach ( get_available_post_statuses() as $status_value => $status_label ) { ?>
<option value="<?php echo esc_attr( $status_label ); ?>" <?php selected( $instance['post_status'], $status_label ); ?>><?php echo esc_html( ucfirst( $status_label ) ); ?></option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'order' ); ?>">
<?php _e( 'Order', 'rpwe' ); ?>
</label>
<select class="widefat" id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>" style="width:100%;">
<option value="DESC" <?php selected( $instance['order'], 'DESC' ); ?>><?php _e( 'Descending', 'rpwe' ) ?></option>
<option value="ASC" <?php selected( $instance['order'], 'ASC' ); ?>><?php _e( 'Ascending', 'rpwe' ) ?></option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'orderby' ); ?>">
<?php _e( 'Orderby', 'rpwe' ); ?>
</label>
<select class="widefat" id="<?php echo $this->get_field_id( 'orderby' ); ?>" name="<?php echo $this->get_field_name( 'orderby' ); ?>" style="width:100%;">
<option value="ID" <?php selected( $instance['orderby'], 'ID' ); ?>><?php _e( 'ID', 'rpwe' ) ?></option>
<option value="date" <?php selected( $instance['orderby'], 'date' ); ?>><?php _e( 'Date', 'rpwe' ) ?></option>
<option value="author" <?php selected( $instance['orderby'], 'author' ); ?>><?php _e( 'Author', 'rpwe' ) ?></option>
<option value="title" <?php selected( $instance['orderby'], 'title' ); ?>><?php _e( 'Title', 'rpwe' ) ?></option>
<option value="modified" <?php selected( $instance['orderby'], 'modified' ); ?>><?php _e( 'Modified', 'rpwe' ) ?></option>
<option value="rand" <?php selected( $instance['orderby'], 'rand' ); ?>><?php _e( 'Random', 'rpwe' ) ?></option>
<option value="comment_count" <?php selected( $instance['orderby'], 'comment_count' ); ?>><?php _e( 'Comment Count', 'rpwe' ) ?></option>
<option value="menu_order" <?php selected( $instance['orderby'], 'menu_order' ); ?>><?php _e( 'Menu Order', 'rpwe' ) ?></option>
</select>
</p>
<div class="rpwe-multiple-check-form">
<label>
<?php _e( 'Limit to Category', 'rpwe' ); ?>
</label>
<ul>
<?php foreach ( get_terms( 'category' ) as $category ) : ?>
<li>
<input type="checkbox" value="<?php echo (int) $category->term_id; ?>" id="<?php echo $this->get_field_id( 'cat' ) . '-' . (int) $category->term_id; ?>" name="<?php echo $this->get_field_name( 'cat' ); ?>[]" <?php checked( is_array( $instance['cat'] ) && in_array( $category->term_id, $instance['cat'] ) ); ?> />
<label for="<?php echo $this->get_field_id( 'cat' ) . '-' . (int) $category->term_id; ?>">
<?php echo esc_html( $category->name ); ?>
</label>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="rpwe-multiple-check-form">
<label>
<?php _e( 'Limit to Tag', 'rpwe' ); ?>
</label>
<ul>
<?php foreach ( get_terms( 'post_tag' ) as $post_tag ) : ?>
<li>
<input type="checkbox" value="<?php echo (int) $post_tag->term_id; ?>" id="<?php echo $this->get_field_id( 'tag' ) . '-' . (int) $post_tag->term_id; ?>" name="<?php echo $this->get_field_name( 'tag' ); ?>[]" <?php checked( is_array( $instance['tag'] ) && in_array( $post_tag->term_id, $instance['tag'] ) ); ?> />
<label for="<?php echo $this->get_field_id( 'tag' ) . '-' . (int) $post_tag->term_id; ?>">
<?php echo esc_html( $post_tag->name ); ?>
</label>
</li>
<?php endforeach; ?>
</ul>
</div>
<p>
<label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>">
<?php _e( 'Limit to Taxonomy', 'rpwe' ); ?>
</label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>" value="<?php echo esc_attr( $instance['taxonomy'] ); ?>" />
<small><?php _e( 'Ex: category=1,2,4&post_tag=6,12', 'rpwe' );?><br />
<?php _e( 'Available: ', 'rpwe' ); echo implode( ', ', get_taxonomies( array( 'public' => true ) ) ); ?></small>
</p>
</div>
<div class="rpwe-columns-3 rpwe-column-last">
<p>
<label for="<?php echo $this->get_field_id( 'limit' ); ?>">
<?php _e( 'Number of posts to show', 'rpwe' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" step="1" min="-1" value="<?php echo (int)( $instance['limit'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'offset' ); ?>">
<?php _e( 'Offset', 'rpwe' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'offset' ); ?>" name="<?php echo $this->get_field_name( 'offset' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['offset'] ); ?>" />
<small><?php _e( 'The number of posts to skip', 'rpwe' ); ?></small>
</p>
<?php if ( current_theme_supports( 'post-thumbnails' ) ) { ?>
<p>
<input id="<?php echo $this->get_field_id( 'thumb' ); ?>" name="<?php echo $this->get_field_name( 'thumb' ); ?>" type="checkbox" <?php checked( $instance['thumb'] ); ?> />
<label class="input-checkbox" for="<?php echo $this->get_field_id( 'thumb' ); ?>">
<?php _e( 'Display Thumbnail', 'rpwe' ); ?>
</label>
</p>
<p>
<label class="rpwe-block" for="<?php echo $this->get_field_id( 'thumb_height' ); ?>">
<?php _e( 'Thumbnail (height,width,align)', 'rpwe' ); ?>
</label>
<input class= "small-input" id="<?php echo $this->get_field_id( 'thumb_height' ); ?>" name="<?php echo $this->get_field_name( 'thumb_height' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['thumb_height'] ); ?>" />
<input class="small-input" id="<?php echo $this->get_field_id( 'thumb_width' ); ?>" name="<?php echo $this->get_field_name( 'thumb_width' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['thumb_width'] ); ?>"/>
<select class="small-input" id="<?php echo $this->get_field_id( 'thumb_align' ); ?>" name="<?php echo $this->get_field_name( 'thumb_align' ); ?>">
<option value="rpwe-alignleft" <?php selected( $instance['thumb_align'], 'rpwe-alignleft' ); ?>><?php _e( 'Left', 'rpwe' ) ?></option>
<option value="rpwe-alignright" <?php selected( $instance['thumb_align'], 'rpwe-alignright' ); ?>><?php _e( 'Right', 'rpwe' ) ?></option>
<option value="rpwe-aligncenter" <?php selected( $instance['thumb_align'], 'rpwe-aligncenter' ); ?>><?php _e( 'Center', 'rpwe' ) ?></option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'thumb_default' ); ?>">
<?php _e( 'Default Thumbnail', 'rpwe' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'thumb_default' ); ?>" name="<?php echo $this->get_field_name( 'thumb_default' ); ?>" type="text" value="<?php echo $instance['thumb_default']; ?>"/>
<small><?php _e( 'Leave it blank to disable.', 'rpwe' ); ?></small>
</p>
<?php } ?>
<p>
<input id="<?php echo $this->get_field_id( 'excerpt' ); ?>" name="<?php echo $this->get_field_name( 'excerpt' ); ?>" type="checkbox" <?php checked( $instance['excerpt'] ); ?> />
<label class="input-checkbox" for="<?php echo $this->get_field_id( 'excerpt' ); ?>">
<?php _e( 'Display Excerpt', 'rpwe' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'length' ); ?>">
<?php _e( 'Excerpt Length', 'rpwe' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'length' ); ?>" name="<?php echo $this->get_field_name( 'length' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['length'] ); ?>" />
</p>
<p>
<input id="<?php echo $this->get_field_id( 'readmore' ); ?>" name="<?php echo $this->get_field_name( 'readmore' ); ?>" type="checkbox" <?php checked( $instance['readmore'] ); ?> />
<label class="input-checkbox" for="<?php echo $this->get_field_id( 'readmore' ); ?>">
<?php _e( 'Display Readmore', 'rpwe' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'readmore_text' ); ?>">
<?php _e( 'Readmore Text', 'rpwe' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'readmore_text' ); ?>" name="<?php echo $this->get_field_name( 'readmore_text' ); ?>" type="text" value="<?php echo strip_tags( $instance['readmore_text'] ); ?>" />
</p>
<p>
<input id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" type="checkbox" <?php checked( $instance['date'] ); ?> />
<label class="input-checkbox" for="<?php echo $this->get_field_id( 'date' ); ?>">
<?php _e( 'Display Date', 'rpwe' ); ?>
</label>
</p>
<p>
<input id="<?php echo $this->get_field_id( 'date_relative' ); ?>" name="<?php echo $this->get_field_name( 'date_relative' ); ?>" type="checkbox" <?php checked( $instance['date_relative'] ); ?> />
<label for="<?php echo $this->get_field_id( 'date_relative' ); ?>">
<?php _e( 'Use Relative Date. eg: 5 days ago', 'rpwe' ); ?>
</label>
</p>
</div>
<div class="clear"></div>
<p>
<label for="<?php echo $this->get_field_id( 'css' ); ?>">
<?php _e( 'Custom CSS', 'rpwe' ); ?>
</label>
<textarea class="widefat" id="<?php echo $this->get_field_id( 'css' ); ?>" name="<?php echo $this->get_field_name( 'css' ); ?>" style="height:180px;"><?php echo $instance['css']; ?></textarea>
<small><?php _e( 'If you turn off the default styles, you can use these css code to customize the recent posts style.', 'rpwe' ); ?></small>
</p>
и такой:
<?php
/*
*
* Swift Page Builder - Blog Items Function Class
* ------------------------------------------------
* Swift Framework
* Copyright Swift Ideas 2014 - http://www.swiftideas.net
*
* sf_blog_items()
* sf_blog_aux()
*
*/
/* BLOG ITEMS
================================================== */
if (!function_exists('sf_blog_items')) {
function sf_blog_items($blog_type, $masonry_effect_type, $show_title, $show_excerpt, $show_details, $excerpt_length, $content_output, $show_read_more, $item_count, $category, $exclude_categories, $pagination, $sidebar_config, $width, $offset, $posts_order) {
$blog_items_output = "";
$options = get_option('sf_dante_options');
$filter_wrap_bg = $options['filter_wrap_bg'];
global $sf_sidebar_config;
$sf_sidebar_config = $sidebar_config;
/* CATEGORY SLUG MODIFICATION
================================================== */
if ($category == "All") {$category = "all";}
if ($category == "all") {$category = '';}
$category_slug = str_replace('_', '-', $category);
/* BLOG QUERY SETUP
================================================== */
global $post, $wp_query;
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
$offset = $offset + ($item_count * ($paged - 1));
} elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
$offset = $offset + ($item_count * ($paged - 1));
} else {
$paged = 1;
}
$blog_args = array(
'post_type' => 'post',
'post_status' => 'publish',
'paged' => $paged,
'category_name' => $category_slug,
'posts_per_page' => $item_count,
'cat' => '"'.$exclude_categories.'"',
'offset' => $offset,
'order' => $posts_order
);
$blog_items = new WP_Query( $blog_args );
/* LIST CLASS CONFIG
================================================== */
$list_class = $wrap_class = '';
if ($blog_type == "masonry" || $blog_type == "masonry-fw") {
$list_class .= 'masonry-items first-load grid '.$masonry_effect_type;
} else if ($blog_type == "mini") {
$list_class .= 'mini-items';
} else {
$list_class .= 'standard-items';
if ($sidebar_config == "no-sidebars") {
$wrap_class .= 'col-sm-8 col-sm-offset-2';
}
}
/* BLOG ITEMS OUTPUT
================================================== */
$blog_items_output .= '<div class="blog-items-wrap blog-'.$blog_type.' '.$wrap_class.'">';
if ($blog_type == "standard") {
$blog_items_output .= '<div class="timeline"></div>';
}
if ($blog_type == "masonry" || $blog_type == "masonry-fw") {
$blog_items_output .= '<ul class="blog-items row '. $list_class .' clearfix" id="blogGrid">';
} else {
$blog_items_output .= '<ul class="blog-items row '. $list_class .' clearfix">';
}
while ( $blog_items->have_posts() ) : $blog_items->the_post();
$post_format = get_post_format($post->ID);
if ( $post_format == "" ) {
$post_format = 'standard';
}
if ($blog_type == "mini") {
$item_class = "col-sm-12";
} else if ($blog_type == "masonry") {
if ($sidebar_config == "both-sidebars") {
$item_class = "col-sm-3";
} else {
$item_class = "col-sm-4";
}
} else if ($blog_type == "masonry-fw") {
$item_class = "col-sm-3";
} else {
$item_class = $width;
}
/* BLOG ITEM OUTPUT
================================================== */
$blog_items_output .= '<li itemscope itemtype="http://schema.org/BlogPosting" class="blog-item '.$item_class.' format-'.$post_format.' '.implode(' ',get_post_class()).'" id="'.get_the_ID().'">';
$blog_items_output .= sf_get_post_item($post->ID, $blog_type, $show_title, $show_excerpt, $show_details, $excerpt_length, $content_output, $show_read_more);
$blog_items_output .= '</li>';
endwhile;
wp_reset_postdata();
$blog_items_output .= '</ul>';
/* PAGINATION OUTPUT
================================================== */
if ($pagination == "infinite-scroll") {
global $sf_include_infscroll;
$sf_include_infscroll = true;
$blog_items_output .= '<div class="pagination-wrap hidden">';
$blog_items_output .= pagenavi($blog_items);
$blog_items_output .= '</div>';
} else if ($pagination == "load-more") {
global $sf_include_infscroll;
$sf_include_infscroll = true;
$blog_items_output .= '<a href="#" class="load-more-btn">'.__('Load More', 'swiftframework').'</a>';
$blog_items_output .= '<div class="pagination-wrap load-more hidden">';
$blog_items_output .= pagenavi($blog_items);
$blog_items_output .= '</div>';
} else if ($pagination == "standard") {
if ($blog_type == "masonry" || $blog_type == "masonry-fw") {
$blog_items_output .= '<div class="pagination-wrap masonry-pagination">';
} else {
$blog_items_output .= '<div class="pagination-wrap">';
}
$blog_items_output .= pagenavi($blog_items);
$blog_items_output .= '</div>';
}
$blog_items_output .= '</div>';
/* FUNCTION OUTPUT
================================================== */
return $blog_items_output;
}
}
/* BLOG AUX
================================================== */
if (!function_exists('sf_blog_aux')) {
function sf_blog_aux($width) {
$blog_aux_output = "";
$options = get_option('sf_dante_options');
$filter_wrap_bg = $options['filter_wrap_bg'];
$rss_feed_url = $options['rss_feed_url'];
$category_list = wp_list_categories('sort_column=name&title_li=&depth=1&number=60&echo=0&show_count=1');
$archive_list = wp_get_archives('type=monthly&limit=12&echo=0');
$tags_list = wp_tag_cloud('smallest=12&largest=12&unit=px&format=list&number=60&orderby=name&echo=0');
$blog_aux_output .= '<div class="blog-aux-wrap row">'; // open .blog-aux-wrap
$blog_aux_output .= '<ul class="blog-aux-options bar-styling '.$width.'">'; // open .blog-aux-options
// CATEGORIES
$blog_aux_output .= '<li><a href="#" class="blog-slideout-trigger" data-aux="categories"><i class="ss-index"></i>'.__("Categories", "swiftframework").'</a>';
// TAGS
$blog_aux_output .= '<li><a href="#" class="blog-slideout-trigger" data-aux="tags"><i class="ss-tag"></i>'.__("Tags", "swiftframework").'</a>';
// SEARCH FORM
$blog_aux_output .= '<li class="search"><form method="get" class="search-form" action="'. home_url().'/">';
$blog_aux_output .= '<input type="text" placeholder="'. __("Search", "swiftframework") .'" name="s" />';
$blog_aux_output .= '</form></li>';
// ARCHIVES
$blog_aux_output .= '<li><a href="#" class="blog-slideout-trigger" data-aux="archives"><i class="ss-storagebox"></i>'.__("Archives", "swiftframework").'</a>';
// RSS LINK
if ($rss_feed_url != "") {
$blog_aux_output .= '<li><a href="'.$rss_feed_url.'" class="rss-link" target="_blank"><i class="fa-rss"></i>'.__("RSS", "swiftframework").'</a>';
}
$blog_aux_output .= '</ul>'; // close .blog-aux-options
$blog_aux_output .= '</div>'; // close .blog-aux-wrap
$blog_aux_output .= '<div class="container">';
$blog_aux_output .= '<div class="filter-wrap slideout-filter blog-filter-wrap row clearfix">'; // open .blog-filter-wrap
$blog_aux_output .= '<div class="filter-slide-wrap col-sm-12 alt-bg '.$filter_wrap_bg.'">';
if ($category_list != '') {
$blog_aux_output .= '<ul class="aux-list aux-categories row clearfix">'.$category_list.'</ul>';
}
if ($tags_list != '') {
$blog_aux_output .= '<ul class="aux-list aux-tags row clearfix">'.$tags_list.'</ul>';
}
if ($archive_list != '') {
$blog_aux_output .= '<ul class="aux-list aux-archives row clearfix">'.$archive_list.'</ul>';
}
$blog_aux_output .= '</div>';
$blog_aux_output .='</div></div>'; // close .blog-filter-wrap
/* AUX BUTTONS OUTPUT
================================================== */
return $blog_aux_output;
}
}
?>
Источник: Stack Overflow на русском