get_bloginfo( 'wpurl' ).'/wp-content/plugins/ajax-scroll/ajax-scroll.php' //'/wp-admin/admin-ajax.php' )); } class AjaxScroll { public function replace_link($link) { global $as_elem_id; if ( empty($as_elem_id) ) return $link; // link url $query = parse_str( parse_url ($link, PHP_URL_QUERY) ); if ( isset($query['p']) && is_numeric($query['p']) ) { $page = $query['p']; } else { $check_link = rtrim(parse_url ($link, PHP_URL_PATH), '/'); $method1 = substr($check_link, strrpos($check_link, '/') + 1); if ( is_numeric($method1) ) $page = $method1; else $page = 1; } // current url $current_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $current_query = parse_str( parse_url ( $current_url, PHP_URL_QUERY ) ); if ( isset($current_query['p']) && is_numeric($current_query['p']) ) { $current_page = $current_query['p']; } else { $check_link = rtrim(parse_url ($current_url, PHP_URL_PATH), '/'); $current_method1 = substr($check_link, strrpos($check_link, '/') + 1); if ( is_numeric($current_method1) ) $current_page = $current_method1; else $current_page = 1; } if ( $current_page < $page ) $direction = 'older'; else $direction = 'newer'; return 'http://ajax-scroll175926233/javascript:ajax_scroll(\'' . $direction . '\', \'' . urlencode($link) . '\', \'' . $as_elem_id . '\');'; } public function fix_link($link) { if ( substr($link, 0, 39) == 'http://ajax-scroll175926233/javascript:' ) return substr_replace($link, '', 0, 28); return $link; } public static function ajax_call() { $findID = $_POST['as_container']; if ( empty($findID) ) { global $as_elem_id; $findID = $as_elem_id; } $children = @DOMDocument::loadHTML(wp_remote_fopen($_POST['as_url']))->getElementById($findID)->childNodes; if (empty($children)) exit('Unable to locate element ID "'.$findID.'" in file "'.$_POST['as_url'].'"'); foreach ($children as $child) { $tmp_doc = new DOMDocument(); $tmp_doc->appendChild($tmp_doc->importNode($child,true)); $innerHTML .= trim($tmp_doc->saveHTML()); } header('Content-Type: text/html; charset=utf-8'); echo $innerHTML; exit; } /* * $url - URI to pull contents from * $direction - "newer" or "older" * $text - text to link * $container - id of the element that will be transitioned */ static public function generateLink($url, $direction, $text, $container='') { if ( empty($container) ) { global $as_elem_id; $container = $as_elem_id; } echo '', $text, ''; } static public function get_generateLink($url, $direction, $container='') { if ( empty($container) ) { global $as_elem_id; $container = $as_elem_id; } return 'ajax_scroll(\'' . $direction . '\', \'' . urlencode($url) . '\', \'' . $container . '\');'; } }