123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <?php
- /**
- * Filter to Run WP REST API v2 Endpoints and Fix double Slash in rest_url
- */
- //add_filter( 'rest_url_prefix', function () { return 'wp-json/wp/v2'; } );
- //add_filter( 'rest_url_prefix', 'fix_json_endpoint' );
- //function fix_json_endpoint (){
- // $json_endpoint = 'wp-json/wp/v2';
- // return rtrim( $json_endpoint, '/' );
- //}
- //remove_filter('json_dispatch_request', 'json_v1_compatible_dispatch', 10);
- //remove_filter('json_endpoints', 'json_v1_compatible_routes', 1000);
- /**
- * Build path data for current request.
- *
- * @return string|bool
- */
- function _s_backbone_get_request_path() {
- global $wp_rewrite;
- if ( $wp_rewrite->using_permalinks() ) {
- global $wp;
- // If called too early, bail
- if ( ! isset( $wp->request ) ) {
- return false;
- }
- // Determine path for paginated version of current request
- if ( false != preg_match( '#' . $wp_rewrite->pagination_base . '/\d+/?$#i', $wp->request ) ) {
- $path = preg_replace( '#' . $wp_rewrite->pagination_base . '/\d+$#i', $wp_rewrite->pagination_base . '/%d', $wp->request );
- } else {
- $path = $wp->request . '/' . $wp_rewrite->pagination_base . '/%d';
- }
- // Slashes everywhere we need them
- if ( 0 !== strpos( $path, '/' ) )
- $path = '/' . $path;
- $path = user_trailingslashit( $path );
- } else {
- // Clean up raw $_REQUEST input
- $path = array_map( 'sanitize_text_field', $_REQUEST );
- $path = array_filter( $path );
- $path['paged'] = '%d';
- $path = add_query_arg( $path, '/' );
- }
- return empty( $path ) ? false : $path;
- }
- /**
- * Return query string for current request, prefixed with '?'.
- *
- * @return string
- */
- function _s_backbone_get_request_parameters() {
- $uri = $_SERVER[ 'REQUEST_URI' ];
- $uri = preg_replace( '/^[^?]*(\?.*$)/', '$1', $uri, 1, $count );
- if ( $count != 1 ) {
- return '';
- }
- return $uri;
- }
- /*******************
- < PHP 7.3 include file as dom.php
- >= PHP 7.3 include file as html_dom.php
- **********************/
- function til() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/index.html';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('ul li ul li') as $li) {
- echo $li;
- if (++$i == 9) break;
- }
- }
- function pull_til() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/index.html';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('ul li ul li') as $li) {
- echo $li;
- if (++$i == 50) break;
- }
- }
- function pull_til_all() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/index.html';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('ul li ul li') as $li) {
- echo $li;
- }
- }
- function bookmarks() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/bookmarks/';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.linklist-item-title h2 a') as $li) {
- if (!empty($html)) {
- echo $li . '<br />';
- if (++$i == 9) break;
- }
- }
- }
- function bookmarks_pull() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/bookmarks/';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.linklist-item-title h2 a') as $li) {
- if (!empty($html)) {
- echo $li . '<br />';
- if (++$i == 27) break;
- }
- }
- }
- function bookmarks_all() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/bookmarks/';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.linklist-item-title h2 a') as $li) {
- if (!empty($html)) {
- echo $li . '<br />';
- }
- }
- }
- function now() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/lists/now';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 6) break;
- }
- }
- }
- function todo() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/lists/todo';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 3) break;
- }
- }
- }
- function todone() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/lists/todone';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 3) break;
- }
- }
- }
- function docs() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/docs';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 5) break;
- }
- }
- }
- function lists() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/lists/';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 5) break;
- }
- }
- }
- function notes() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/notes/';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 5) break;
- }
- }
- }
- function playing() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/lists/now/playing';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 3) break;
- }
- }
- }
- function watching() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/lists/now/watching';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 3) break;
- }
- }
- }
- function listening() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/lists/now/listening';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 3) break;
- }
- }
- }
- function reading() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/lists/now/reading';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 3) break;
- }
- }
- }
- function learning() {
- require_once('lib/html_dom.php');
- $url = 'https://davidawindham.com/til/lists/now/learning';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.markdown ul li') as $li) {
- if (!empty($html)) {
- echo $li;
- if (++$i == 3) break;
- }
- }
- }
- /********************************/
- /************ Code ************/
- /********************************/
- function code() {
- require_once('lib/html_dom.php');
- $url = 'https://code.davidawindham.com/david?tab=activity';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.content ul li') as $li) {
- foreach ($li->find('span.text') as $comment) {
- if (!empty($html)) {
- $str = array('href="/', 'light');
- $replace = array('href="https://code.davidawindham.com/', '');
- //echo str_replace($str,$replace, $li . ' - ' . $commit . ' - ' . $comment . '<br>');
- echo str_replace($str,$replace, $li . '' . $comment . '<br>');
- }
- }
- //foreach ($html->find('span.text') as $comment) {}
- if (++$i == 5) break;
- }
- }
- function commits() {
- require_once('lib/html_dom.php');
- $url = 'https://code.davidawindham.com/david?tab=activity';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('ul li a') as $li) {
- if (!empty($html)) {
- $str = array('href="/', 'light');
- $replace = array('href="https://code.davidawindham.com/', '');
- echo str_replace($str,$replace, date("y/m/d") . ' - ' . $li . '<br>');
- if (++$i == 3) break;
- }
- }
- }
- function docs_code() {
- require_once('lib/html_dom.php');
- $url = 'https://code.davidawindham.com/david/til/src/main/docs';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('table tr td') as $li) {
- if (!empty($html)) {
- //if($i++ == 1) continue;
- echo str_replace('href="/', 'href="https://code.davidawindham.com/', $li);
- if(!($i++ % 3)) {
- echo '<br>';
- }
- if (++$i == 1) break;
- }
- }
- }
- function lists_code() {
- require_once('lib/html_dom.php');
- $url = 'https://code.davidawindham.com/david/til/src/main/lists';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('table tr td') as $li) {
- if (!empty($html)) {
- //if($i++ == 1) continue;
- if (++$i == 2) break;
- echo str_replace('href="/', 'href="https://code.davidawindham.com/', $li);
- if(!($i++ % 3)) {
- echo '<br>';
- }
- }
- }
- }
- function photo() {
- require_once('lib/html_dom.php');
- $url = 'https://photo.davidwindham.com/#16734437965516';
- $html = file_get_html($url);
- $i = 0;
- foreach ($html->find('.photo .overlay h1') as $li) {
- if (!empty($html)) {
- echo str_replace('href="/', 'href="https://photo.davidawindham.com/', $li . ' ');
- if (++$i == 18) break;
- }
- }
- }
- //function mastodon() {
- // require_once('lib/html_dom.php');
- //
- // $url = 'https://universeodon.com/@windhamdavid/with_replies';
- // $html = file_get_html($url);
- // $i = 0;
- // foreach ($html->find('.status__content__text p') as $li) {
- // if (!empty($html)) {
- // echo str_replace('href="/', 'href="https://universeodon.com/', $li . ' ');
- // if (++$i == 18) break;
- // }
- // }
- //}
|