admin
1 week ago
auto-insert
4 months ago
conditional-logic
6 months ago
execute
5 months ago
generator
6 months ago
lite
9 months ago
capabilities.php
2 years ago
class-wpcode-abilities-api.php
1 week ago
class-wpcode-admin-bar-info.php
2 years ago
class-wpcode-auto-insert.php
4 months ago
class-wpcode-capabilities.php
3 years ago
class-wpcode-conditional-logic.php
4 months ago
class-wpcode-error.php
2 years ago
class-wpcode-file-cache.php
1 year ago
class-wpcode-file-logger.php
1 year ago
class-wpcode-generator.php
4 months ago
class-wpcode-install.php
1 year ago
class-wpcode-library-auth.php
1 year ago
class-wpcode-library.php
1 week ago
class-wpcode-settings.php
6 months ago
class-wpcode-smart-tags.php
11 months ago
class-wpcode-snippet-cache.php
4 months ago
class-wpcode-snippet-execute.php
1 year ago
class-wpcode-snippet.php
1 year ago
compat.php
2 years ago
global-output.php
1 year ago
helpers.php
1 year ago
icons.php
5 months ago
ihaf.php
3 years ago
legacy.php
3 years ago
pluggable.php
2 years ago
post-type.php
1 week ago
safe-mode.php
11 months ago
shortcode.php
2 years ago
compat.php
169 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) || exit; |
| 4 | |
| 5 | if ( ! function_exists( 'str_contains' ) ) { |
| 6 | /** |
| 7 | * Polyfill for str_contains() function added in PHP 8.0. |
| 8 | * |
| 9 | * @param string $haystack The string to search in. |
| 10 | * @param string $needle The substring to search for in the haystack. |
| 11 | * |
| 12 | * @return bool True if $needle is in $haystack, otherwise false. |
| 13 | */ |
| 14 | function str_contains( $haystack, $needle ) { |
| 15 | return ( '' === $needle || false !== strpos( $haystack, $needle ) ); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | if ( ! function_exists( 'wp_doing_ajax' ) ) { |
| 20 | /** |
| 21 | * Determines whether the current request is a WordPress Ajax request. |
| 22 | * |
| 23 | * @return bool True if it's a WordPress Ajax request, false otherwise. |
| 24 | * @since 4.7.0 |
| 25 | * |
| 26 | */ |
| 27 | function wp_doing_ajax() { |
| 28 | /** |
| 29 | * Filters whether the current request is a WordPress Ajax request. |
| 30 | * |
| 31 | * @param bool $wp_doing_ajax Whether the current request is a WordPress Ajax request. |
| 32 | * |
| 33 | * @since 4.7.0 |
| 34 | * |
| 35 | */ |
| 36 | return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | if ( ! function_exists( 'wp_doing_cron' ) ) { |
| 41 | /** |
| 42 | * Determines whether the current request is a WordPress cron request. |
| 43 | * |
| 44 | * @return bool True if it's a WordPress cron request, false otherwise. |
| 45 | * @since 4.8.0 |
| 46 | * |
| 47 | */ |
| 48 | function wp_doing_cron() { |
| 49 | /** |
| 50 | * Filters whether the current request is a WordPress cron request. |
| 51 | * |
| 52 | * @param bool $wp_doing_cron Whether the current request is a WordPress cron request. |
| 53 | * |
| 54 | * @since 4.8.0 |
| 55 | * |
| 56 | */ |
| 57 | return apply_filters( 'wp_doing_cron', defined( 'DOING_CRON' ) && DOING_CRON ); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | if ( ! function_exists( 'sanitize_textarea_field' ) ) { |
| 62 | /** |
| 63 | * Sanitizes a multiline string from user input or from the database. |
| 64 | * |
| 65 | * The function is like sanitize_text_field(), but preserves |
| 66 | * new lines (\n) and other whitespace, which are legitimate |
| 67 | * input in textarea elements. |
| 68 | * |
| 69 | * @param string $str String to sanitize. |
| 70 | * |
| 71 | * @return string Sanitized string. |
| 72 | * @see sanitize_text_field() |
| 73 | * |
| 74 | * @since 4.7.0 |
| 75 | * |
| 76 | */ |
| 77 | function sanitize_textarea_field( $str ) { |
| 78 | $filtered = _sanitize_text_fields( $str, true ); |
| 79 | |
| 80 | /** |
| 81 | * Filters a sanitized textarea field string. |
| 82 | * |
| 83 | * @param string $filtered The sanitized string. |
| 84 | * @param string $str The string prior to being sanitized. |
| 85 | * |
| 86 | * @since 4.7.0 |
| 87 | * |
| 88 | */ |
| 89 | return apply_filters( 'sanitize_textarea_field', $filtered, $str ); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | if ( ! function_exists( '_sanitize_text_fields' ) ) { |
| 94 | /** |
| 95 | * Internal helper function to sanitize a string from user input or from the database. |
| 96 | * |
| 97 | * @param string $str String to sanitize. |
| 98 | * @param bool $keep_newlines Optional. Whether to keep newlines. Default: false. |
| 99 | * |
| 100 | * @return string Sanitized string. |
| 101 | * @since 4.7.0 |
| 102 | * @access private |
| 103 | * |
| 104 | */ |
| 105 | function _sanitize_text_fields( $str, $keep_newlines = false ) { |
| 106 | if ( is_object( $str ) || is_array( $str ) ) { |
| 107 | return ''; |
| 108 | } |
| 109 | |
| 110 | $str = (string) $str; |
| 111 | |
| 112 | $filtered = wp_check_invalid_utf8( $str ); |
| 113 | |
| 114 | if ( strpos( $filtered, '<' ) !== false ) { |
| 115 | $filtered = wp_pre_kses_less_than( $filtered ); |
| 116 | // This will strip extra whitespace for us. |
| 117 | $filtered = wp_strip_all_tags( $filtered, false ); |
| 118 | |
| 119 | /* |
| 120 | * Use HTML entities in a special case to make sure that |
| 121 | * later newline stripping stages cannot lead to a functional tag. |
| 122 | */ |
| 123 | $filtered = str_replace( "<\n", "<\n", $filtered ); |
| 124 | } |
| 125 | |
| 126 | if ( ! $keep_newlines ) { |
| 127 | $filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered ); |
| 128 | } |
| 129 | $filtered = trim( $filtered ); |
| 130 | |
| 131 | // Remove percent-encoded characters. |
| 132 | $found = false; |
| 133 | while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $match ) ) { |
| 134 | $filtered = str_replace( $match[0], '', $filtered ); |
| 135 | $found = true; |
| 136 | } |
| 137 | |
| 138 | if ( $found ) { |
| 139 | // Strip out the whitespace that may now exist after removing percent-encoded characters. |
| 140 | $filtered = trim( preg_replace( '/ +/', ' ', $filtered ) ); |
| 141 | } |
| 142 | |
| 143 | return $filtered; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | add_filter( 'pto/posts_orderby/ignore', 'wpcode_exclude_post_types_order', 15, 3 ); |
| 148 | |
| 149 | /** |
| 150 | * Exclude the wpcode post type from the Post Types Order plugin. |
| 151 | * |
| 152 | * @param bool $ignore Whether to ignore the post type. |
| 153 | * @param string $order_by The order by param. |
| 154 | * @param WP_Query $query The WP_Query instance. |
| 155 | * |
| 156 | * @return bool |
| 157 | */ |
| 158 | function wpcode_exclude_post_types_order( $ignore, $order_by, $query ) { |
| 159 | if ( ! method_exists( $query, 'get' ) ) { |
| 160 | return $ignore; |
| 161 | } |
| 162 | |
| 163 | if ( 'wpcode' === $query->get( 'post_type' ) ) { |
| 164 | $ignore = true; |
| 165 | } |
| 166 | |
| 167 | return $ignore; |
| 168 | } |
| 169 |