| @@ -14,29 +14,8 @@ | ||
| 14 | 14 | |
| 15 | 15 | private static $meta_options = []; |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Get initialized WordPress filesystem instance. | |
| 19 | - * | |
| 20 | - * @return WP_Filesystem_Base|false | |
| 21 | - */ | |
| 22 | - public static function get_wp_filesystem() { | |
| 23 | - global $wp_filesystem; | |
| 24 | - | |
| 25 | - if ( ! function_exists( 'WP_Filesystem' ) ) { | |
| 26 | - require_once ABSPATH . 'wp-admin/includes/file.php'; | |
| 27 | - } | |
| 28 | - | |
| 29 | - WP_Filesystem(); | |
| 30 | - | |
| 31 | - if ( ! ( $wp_filesystem instanceof WP_Filesystem_Base ) ) { | |
| 32 | - return false; | |
| 33 | - } | |
| 34 | - | |
| 35 | - return $wp_filesystem; | |
| 36 | - } | |
| 37 | - | |
| 38 | - /** | |
| 39 | 18 | * @return bool |
| 40 | 19 | */ |
| 41 | 20 | public static function is_safe_mode() { |
| 42 | 21 | global $wbcr_inp_safe_mode; |
| @@ -131,9 +110,9 @@ | ||
| 131 | 110 | $tag_names = [ 'id' ]; |
| 132 | 111 | $snippet_type = self::get_snippet_type( $snippet->ID ); |
| 133 | 112 | |
| 134 | 113 | $available_tags = self::getMetaOption( $snippet->ID, 'snippet_tags' ); |
| 135 | - $available_tags = ! empty( $available_tags ) ? trim( rtrim( $available_tags ) ) : ''; | |
| 114 | + $available_tags = trim( rtrim( $available_tags ) ); | |
| 136 | 115 | |
| 137 | 116 | if ( ! empty( $available_tags ) ) { |
| 138 | 117 | $available_tags = array_map( 'trim', explode( ',', $available_tags ) ); |
| 139 | 118 | $available_tags = array_unique( $available_tags ); |
| @@ -178,9 +157,9 @@ | ||
| 178 | 157 | * Get snippet type |
| 179 | 158 | * |
| 180 | 159 | * @param mixed $post_id Post ID. |
| 181 | 160 | * |
| 182 | - * @return string|false Snippet type string, or false if post is not a valid snippet post type or not found. | |
| 161 | + * @return array|mixed|string | |
| 183 | 162 | */ |
| 184 | 163 | public static function get_snippet_type( $post_id = null ) { |
| 185 | 164 | global $post; |
| 186 | 165 | |
| @@ -194,14 +173,8 @@ | ||
| 194 | 173 | } |
| 195 | 174 | |
| 196 | 175 | if ( ! empty( $post_id ) ) { |
| 197 | 176 | $_post = get_post( $post_id ); |
| 198 | - | |
| 199 | - // Security: Validate that the post belongs to the snippet post type | |
| 200 | - // to prevent arbitrary post content execution via shortcodes. | |
| 201 | - if ( empty( $_post ) || WINP_SNIPPETS_POST_TYPE !== $_post->post_type ) { | |
| 202 | - return false; | |
| 203 | - } | |
| 204 | 177 | } |
| 205 | 178 | |
| 206 | 179 | if ( ! empty( $_post ) && WINP_SNIPPETS_POST_TYPE === $_post->post_type ) { |
| 207 | 180 | $_snippet_type = get_post_meta( $_post->ID, 'wbcr_inp_snippet_type', true ); |
| @@ -234,12 +207,8 @@ | ||
| 234 | 207 | |
| 235 | 208 | // (#3) |
| 236 | 209 | $rest_url = wp_parse_url( site_url( $prefix ) ); |
| 237 | 210 | $current_url = wp_parse_url( esc_url( add_query_arg( [] ) ) ); |
| 238 | - | |
| 239 | - if ( empty( $rest_url['path'] ) || empty( $current_url['path'] ) ) { | |
| 240 | - return false; | |
| 241 | - } | |
| 242 | 211 | |
| 243 | 212 | return strpos( $current_url['path'], $rest_url['path'], 0 ) === 0; |
| 244 | 213 | } |
| 245 | 214 | |