max_num_pages; if ( ! $pages ) { $pages = 1; } } if ( $is_ajax ) { $html = ''; if ( 1 !== $pages ) { $pagination_unique_classes .= ' ajax-pagination-' . $class_name; $html .= ''; } return $html; } else { if ( 1 !== $pages ) { echo ''; } } } /** * Get current page url */ public static function get_current_page_url() { $protocol = ( ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] ) || ( ! empty( $_SERVER['SERVER_PORT'] ) && 443 === $_SERVER['SERVER_PORT'] ) ? 'https://' : 'http://'; if ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) { $url = esc_url( wp_unslash( $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) ); return $url; } return null; } /** * Get page number from url * * @param string $url page url. */ public static function get_page_number_from_url( $url ) { $pattern = '/\/page\/(\d+)\//'; if ( preg_match( $pattern, $url, $matches ) ) { return isset( $matches[1] ) ? (int) $matches[1] : null; } return null; } /** * Shortcode to render Advance Post Grid * * @param array $attributes Attributes array data. * * Usage: [advance_post_grid postGrid="3" postType="post" postPerPage="6" PostOrder="DESC" PostOrderBy="date" showHidePagi="true" showHideLink="true" showHideCat="true" showHideRT="true"] */ public function shortcode_render( $attributes ) { ob_start(); // Default attributes. $attributes = shortcode_atts( array( 'postGrid' => 3, 'postType' => 'post', 'postPerPage' => 12, 'PostOrder' => 'DESC', 'PostOrderBy' => 'title', 'showHidePagi' => true, 'showHideLink' => true, 'showHideCat' => true, 'showHideRT' => true, ), $attributes, 'advance_post_grid' ); wp_enqueue_style( 'advance-post-grid-style', plugin_dir_url( __FILE__ ) . 'build/style-index.css', array(), filemtime( plugin_dir_path( __FILE__ ) . 'build/style-index.css' ) ); require_once __DIR__ . '/build/render.php'; return ob_get_clean(); } } new WO_APG_Init();