404page
Last commit date
assets
2 years ago
inc
2 years ago
404page.php
2 years ago
block.json
2 years ago
block.php
2 years ago
functions.php
2 years ago
index.php
2 years ago
loader.php
2 years ago
readme.txt
2 years ago
shortcodes.php
2 years ago
uninstall.php
2 years ago
functions.php
118 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The 404page Plugin Functions |
| 5 | * |
| 6 | * @since 11.0.0 |
| 7 | * |
| 8 | **/ |
| 9 | |
| 10 | // If this file is called directly, abort |
| 11 | if ( ! defined( 'WPINC' ) ) { |
| 12 | die; |
| 13 | } |
| 14 | |
| 15 | |
| 16 | // this function can be used by a theme to check if there's an active custom 404 page |
| 17 | function pp_404_is_active() { |
| 18 | |
| 19 | return pp_404page()->pp_404_is_active(); |
| 20 | |
| 21 | } |
| 22 | |
| 23 | |
| 24 | // this function can be used by a theme to activate native support |
| 25 | function pp_404_set_native_support() { |
| 26 | |
| 27 | pp_404page()->pp_404_set_native_support(); |
| 28 | |
| 29 | } |
| 30 | |
| 31 | |
| 32 | // this function can be used by a theme to get the title of the custom 404 page in native support |
| 33 | function pp_404_get_the_title() { |
| 34 | |
| 35 | return pp_404page()->pp_404_get_the_title(); |
| 36 | |
| 37 | } |
| 38 | |
| 39 | |
| 40 | // this function can be used by a theme to print out the title of the custom 404 page in native support |
| 41 | function pp_404_the_title() { |
| 42 | |
| 43 | pp_404page()->pp_404_the_title(); |
| 44 | |
| 45 | } |
| 46 | |
| 47 | |
| 48 | // this function can be used by a theme to get the content of the custom 404 page in native support |
| 49 | function pp_404_get_the_content() { |
| 50 | |
| 51 | return pp_404page()->pp_404_get_the_content(); |
| 52 | |
| 53 | } |
| 54 | |
| 55 | |
| 56 | // this function can be used by a theme to print out the content of the custom 404 page in native support |
| 57 | function pp_404_the_content() { |
| 58 | |
| 59 | return pp_404page()->pp_404_the_content(); |
| 60 | |
| 61 | } |
| 62 | |
| 63 | |
| 64 | // this function returns the page id of the selected 404 page - in a multilingual environment this returs the id of the page in the current language |
| 65 | function pp_404_get_page_id() { |
| 66 | |
| 67 | return pp_404page()->get_page_id(); |
| 68 | |
| 69 | } |
| 70 | |
| 71 | |
| 72 | // this function returns an array of page ids in all languages |
| 73 | function pp_404_get_all_page_ids() { |
| 74 | |
| 75 | return pp_404page()->get_all_page_ids(); |
| 76 | |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * return URL that caused the 404 error for frontend |
| 81 | * used by shortcode and block |
| 82 | * |
| 83 | * @since 11.4.0 |
| 84 | * @access public |
| 85 | * @param string $type |
| 86 | * @return string |
| 87 | */ |
| 88 | function pp_404_get_the_url( $type ) { |
| 89 | |
| 90 | $url = ''; |
| 91 | |
| 92 | if ( is_array( $type ) ) { |
| 93 | |
| 94 | $type = $type[0]; |
| 95 | |
| 96 | } |
| 97 | |
| 98 | if ( 'page' == $type ) { |
| 99 | |
| 100 | $url = trim( pp_404page()->get_404_url( 'path' ), '/' ); |
| 101 | |
| 102 | } elseif ( 'domainpath' == $type ) { |
| 103 | |
| 104 | $url = pp_404page()->get_404_url( 'host' ) . pp_404page()->get_404_url( 'path' ); |
| 105 | |
| 106 | } else { |
| 107 | |
| 108 | $url = pp_404page()->get_404_url( 'full' ); |
| 109 | |
| 110 | } |
| 111 | |
| 112 | |
| 113 | return $url; |
| 114 | |
| 115 | } |
| 116 | |
| 117 | ?> |
| 118 |