'array', 'sanitize_callback' => 'swapfeed_sanitize_settings', 'default' => swapfeed_default_settings(), ) ); } ); function swapfeed_sanitize_settings( $in ) { $d = swapfeed_default_settings(); $in = is_array( $in ) ? $in : array(); $out = array(); $out['per_page'] = max( 1, min( 48, absint( isset( $in['per_page'] ) ? $in['per_page'] : $d['per_page'] ) ) ); $out['columns'] = max( 1, min( 6, absint( isset( $in['columns'] ) ? $in['columns'] : $d['columns'] ) ) ); $out['excerpt_words'] = max( 5, min( 80, absint( isset( $in['excerpt_words'] ) ? $in['excerpt_words'] : $d['excerpt_words'] ) ) ); $out['radius'] = max( 0, min( 40, absint( isset( $in['radius'] ) ? $in['radius'] : $d['radius'] ) ) ); $pt = sanitize_key( isset( $in['post_type'] ) ? $in['post_type'] : 'post' ); $out['post_type'] = post_type_exists( $pt ) ? $pt : 'post'; foreach ( array( 'show_image', 'show_excerpt', 'show_date', 'show_term', 'allow_term', 'show_hint', 'stats' ) as $k ) { $out[ $k ] = empty( $in[ $k ] ) ? 0 : 1; } $out['accent'] = sanitize_hex_color( isset( $in['accent'] ) ? $in['accent'] : '' ) ?: $d['accent']; foreach ( array( 'label_dismiss', 'label_hint', 'label_more' ) as $k ) { $out[ $k ] = sanitize_text_field( isset( $in[ $k ] ) ? $in[ $k ] : '' ); } return $out; } function swapfeed_admin_page() { $tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : 'settings'; // phpcs:ignore WordPress.Security.NonceVerification $base = admin_url( 'options-general.php?page=swapfeed' ); ?>

Swapfeed

%s', esc_attr( $nm( $k ) ), checked( ! empty( $s[ $k ] ), true, false ), esc_html( $label ) ); }; $types = get_post_types( array( 'public' => true ), 'objects' ); $l = swapfeed_labels(); ?>
$s['post_type'], 'post_status' => 'publish', 'posts_per_page' => 3000, 'fields' => 'ids', 'no_found_rows' => true, 'date_query' => array( array( 'after' => wp_date( 'Y-m-d', time() - ( $range - 1 ) * DAY_IN_SECONDS ), 'inclusive' => true ) ), ) ); foreach ( $ids as $pid ) { $t = swapfeed_primary_term( $pid, $tax ); $k = $t ? (int) $t->term_id : 0; $pub[ $k ] = ( isset( $pub[ $k ] ) ? $pub[ $k ] : 0 ) + 1; } $rows = array(); foreach ( array_unique( array_merge( array_keys( $P ), array_keys( $T ), array_keys( $pub ) ) ) as $k ) { $t = $k ? get_term( $k ) : null; $rows[] = array( 'name' => ( $t && ! is_wp_error( $t ) ) ? $t->name : '—', 'pub' => isset( $pub[ $k ] ) ? $pub[ $k ] : 0, 'hid' => isset( $P[ $k ] ) ? $P[ $k ] : 0, 'all' => isset( $T[ $k ] ) ? $T[ $k ] : 0, ); } usort( $rows, function ( $a, $b ) { return ( $b['hid'] + 5 * $b['all'] ) <=> ( $a['hid'] + 5 * $a['all'] ); } ); $top = (array) get_option( SWAPFEED_STATS_POSTS, array() ); arsort( $top ); $top = array_slice( $top, 0, 25, true ); ?>

$n ) : ?>

[swapfeed]

count="12"
columns="3"
post_type="post"
category="news,reviews"
tag="apple"
exclude="12,34"
offset="5"
filters="yes"
image / excerpt / date / term="no"
allow_term="no"
title="Latest"

Mario Fajt' ) ); ?>