esc_html__( 'Allow choose some any posts manually', 'any-posts-widget' ), 'classname' => 'widget-any-posts', ) ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { echo wp_kses_post( $args['before_widget'] ); if ( ! empty( $instance['title'] ) ) { echo wp_kses_post( $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'] ); } if ( ! empty( $instance['posts'] ) ) { $query = new WP_Query( array( 'nopaging' => true, 'post__in' => $instance['posts'], 'ignore_sticky_posts' => true, ) ); $template_file = ANY_POSTS_WIDGET_PATH . 'templates/loop.php'; if ( locate_template( 'any-posts-widget/loop.php' ) ) { $template_file = locate_template( 'any-posts-widget/loop.php' ); } if ( $query->have_posts() ) { echo wp_kses_post( apply_filters( 'apw_list_posts_open', '
id ) { return; } wp_enqueue_style( 'apw-settings', ANY_POSTS_WIDGET_URL . 'assets/css/apw-settings.css' ); wp_enqueue_script( 'apw-settings', ANY_POSTS_WIDGET_URL . 'assets/js/apw-settings.js', array( 'underscore', 'wp-util', 'jquery', 'jquery-ui-sortable' ), ANY_POSTS_WIDGET_VERSION, true ); } add_action( 'admin_enqueue_scripts', 'apw_widget_backend_scripts' ); /** * Enqueue frontend scripts. */ function apw_widget_frontend_scripts() { wp_enqueue_style( 'apw-widget', ANY_POSTS_WIDGET_URL . 'assets/css/widget.css' ); } add_action( 'wp_enqueue_scripts', 'apw_widget_frontend_scripts' ); /** * Get option posts. * * @return array */ function apw_get_posts_opt() { return get_posts( array( 'nopaging' => true, 'orderby' => 'title', 'order' => 'asc', ) ); } /** * Print template for settings. */ function apw_widget_backend_template() { if ( 'widgets' !== get_current_screen()->id ) { return; } ?>