. ****/ define( 'ARCWPV', '0.1.2' ); // current version of the plugin define( 'ARCWP_DEBUG', false ); // enable or disable debug (for dev instead of echo or print_r use debug() function) define( 'ARCWP_DIR', plugins_url( '/', __FILE__ ) ); add_action( 'init', 'arcwp_init' ); function arcwp_init() { if ( ! defined( 'ARCWV' ) || is_admin() ) { return; } wp_enqueue_script( 'arcwp-script', ARCWP_DIR.'arcw-popover.min.js', array( 'jquery' ), ARCWPV ); wp_register_style( 'arcwp-style', ARCWP_DIR.'/arcw-popover.css', array(), ARCWPV ); wp_enqueue_style( 'arcwp-style' ); wp_localize_script( 'arcwp-script', 'ajaxurl', admin_url( 'admin-ajax.php' ) ); } add_action( 'wp_ajax_get_archives_list', 'arcwp_get_archives_list' ); add_action( 'wp_ajax_nopriv_get_archives_list', 'arcwp_get_archives_list' ); function arcwp_get_archives_list() { global $wpdb; $wpurl = get_bloginfo( 'url' ); $url = $_POST['link']; $link = str_replace( "$wpurl", '', $url ); $link = parse_url( $link ); $arcdate = explode( '/', substr( $link['path'], 1, - 1 ) ); $cat = ''; $post_type = 'post'; if ( isset( $link['query'] ) ) { parse_str( $link['query'], $params ); $cat = isset( $params['c'] ) ? $params['c'] : ''; $post_type = isset( $params['p'] ) ? explode( ',', $params['p'] ) : 'post'; } $args = array( 'posts_per_page' => 0, 'cat' => $cat, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => $post_type, 'post_status' => 'publish', 'suppress_filters' => true, 'date_query' => array( array( 'year' => $arcdate[0], 'month' => $arcdate[1], 'day' => isset ( $arcdate[2] ) ? $arcdate[2] : null, ) ) ); if(!empty($cat)) { $args['tax_query'] = array( 'relation' => 'AND', array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => explode(',', $cat), 'operator' => 'IN', ), ); } $posts_array = get_posts( $args ); $max = 5; $posts = count( $posts_array ); echo ""; die(); }