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