s = is_int( $data['expires'] ) ? $data['expires'] : strtotime( $data['expires'] ); } else { $this->expires = null; } } } /** * Confirms that it's OK to send this cookie to the URL checked against. * * Decision is based on RFC 2109/2965, so look there for details on validity. * * @since 2.8.0 * * @param string $url URL you intend to send this cookie to * @return bool true if allowed, false otherwise. */ public function test( $url ) { if ( is_null( $this->name ) ) { return false; } // Expires - if expired then nothing else matters. if ( isset( $this->expires ) && time() > $this->expires ) { return false; } // Get details on the URL we're thinking about sending to. $url = parse_url( $url ); $url['port'] = $url['port'] ?? ( 'https' === $url['scheme'] ? 443 : 80 ); $url['path'] = $url['path'] ?? '/'; // Values to use for comparison against the URL. $path = $this->path ?? '/'; $port = $this->port ?? null; $domain = isset( $this->domain ) ? strtolower( $this->domain ) : strtolower( $url['host'] ); if ( false === stripos( $domain, '.' ) ) { $domain .= '.local'; } // Host - very basic check that the request URL ends with the domain restriction (minus leading dot). $domain = ( str_starts_with( $domain, '.' ) ) ? substr( $domain, 1 ) : $domain; if ( ! str_ends_with( $url['host'], $domain ) ) { return false; } // Port - supports "port-lists" in the format: "80,8000,8080". if ( ! empty( $port ) && ! in_array( $url['port'], array_map( 'intval', explode( ',', $port ) ), true ) ) { return false; } // Path - request path must start with path restriction. if ( ! str_starts_with( $url['path'], $path ) ) { return false; } return true; } /** * Convert cookie name and value back to header string. * * @since 2.8.0 * * @return string Header encoded cookie name and value. */ public function getHeaderValue() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid if ( ! isset( $this->name ) || ! isset( $this->value ) ) { return ''; } /** * Filters the header-encoded cookie value. * * @since 3.4.0 * * @param string $value The cookie value. * @param string $name The cookie name. */ return $this->name . '=' . apply_filters( 'wp_http_cookie_value', $this->value, $this->name ); } /** * Retrieve cookie header for usage in the rest of the WordPress HTTP API. * * @since 2.8.0 * * @return string */ public function getFullHeader() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid return 'Cookie: ' . $this->getHeaderValue(); } /** * Retrieves cookie attributes. * * @since 4.6.0 * * @return array { * List of attributes. * * @type string|int|null $expires When the cookie expires. Unix timestamp or formatted date. * @type string $path Cookie URL path. * @type string $domain Cookie domain. * } */ public function get_attributes() { return array( 'expires' => $this->expires, 'path' => $this->path, 'domain' => $this->domain, ); } } w filter value. */ public function disable_snippet_execution( bool $execute_snippets ): bool { return ! empty( $_REQUEST['snippets-safe-mode'] ) && $this->current_user_can() ? false : $execute_snippets; } /** * Determine whether the menu is full or compact. * * @return bool */ public function is_compact_menu(): bool { return ! is_network_admin() && apply_filters( 'code_snippets_compact_menu', false ); } /** * Fetch the admin menu slug for a menu. * * @param string $menu Name of menu to retrieve the slug for. * * @return string The menu's slug. */ public function get_menu_slug( string $menu = '' ): string { $add = array( 'single', 'add', 'add-new', 'add-snippet', 'new-snippet', 'add-new-snippet' ); $edit = array( 'edit', 'edit-snippet' ); $import = array( 'import', 'import-snippets', 'import-code-snippets' ); $settings = array( 'settings', 'snippets-settings' ); $cloud = array( 'cloud', 'cloud-snippets' ); $welcome = array( 'welcome', 'getting-started', 'code-snippets' ); if ( in_array( $menu, $edit, true ) ) { return 'edit-snippet'; } elseif ( in_array( $menu, $add, true ) ) { return 'add-snippet'; } elseif ( in_array( $menu, $import, true ) ) { return 'import-code-snippets'; } elseif ( in_array( $menu, $settings, true ) ) { return 'snippets-settings'; } elseif ( in_array( $menu, $cloud, true ) ) { return 'snippets&type=cloud'; } elseif ( in_array( $menu, $welcome, true ) ) { return 'code-snippets-welcome'; } else { return 'snippets'; } } /** * Fetch the URL to a snippets admin menu. * * @param string $menu Name of menu to retrieve the URL to. * @param string $context URL scheme to use. * * @return string The menu's URL. */ public function get_menu_url( string $menu = '', string $context = 'self' ): string { $slug = $this->get_menu_slug( $menu ); if ( $this->is_compact_menu() && 'network' !== $context ) { $base_slug = $this->get_menu_slug(); $url = 'tools.php?page=' . $base_slug; if ( $slug !== $base_slug ) { $url .= '&sub=' . $slug; } } else { $url = 'admin.php?page=' . $slug; } if ( 'network' === $context ) { return network_admin_url( $url ); } elseif ( 'admin' === $context ) { return admin_url( $url ); } else { return self_admin_url( $url ); } } /** * Fetch the admin menu slug for a snippets admin menu. * * @param integer $snippet_id Snippet ID. * @param string $context URL scheme to use. * * @return string The URL to the edit snippet page for that snippet. */ public function get_snippet_edit_url( int $snippet_id, string $context = 'self' ): string { return add_query_arg( 'id', absint( $snippet_id ), $this->get_menu_url( 'edit', $context ) ); } /** * Allow redirecting to the Code Snippets site. * * @param array $hosts Allowed hosts. * * @return array Modified allowed hosts. */ public function allow_code_snippets_redirect( array $hosts ): array { $hosts[] = 'codesnippets.pro'; $hosts[] = 'snipco.de'; return $hosts; } /** * Determine whether the current user can perform actions on snippets. * * @return boolean Whether the current user has the required capability. * * @since 2.8.6 */ public function current_user_can(): bool { return current_user_can( $this->get_cap() ); } /** * Retrieve the name of the capability required to manage sub-site snippets. * * @return string */ public function get_cap_name(): string { return apply_filters( 'code_snippets_cap', 'manage_options' ); } /** * Retrieve the name of the capability required to manage network snippets. * * @return string */ public function get_network_cap_name(): string { return apply_filters( 'code_snippets_network_cap', 'manage_network_options' ); } /** * Determine if a subsite user menu is enabled via *Network Settings > Enable administration menus*. * * @return bool */ public function is_subsite_menu_enabled(): bool { if ( ! is_multisite() ) { return true; } $menu_perms = get_site_option( 'menu_items', array() ); return ! empty( $menu_perms['snippets'] ); } /** * Determine if the current user should have the network snippets capability. * * @return bool */ public function user_can_manage_network_snippets(): bool { return is_super_admin() || current_user_can( $this->get_network_cap_name() ); } /** * Determine whether the current request originates in the network admin. * * @return bool */ public function is_network_context(): bool { return is_network_admin(); } /** * Get the required capability to perform a certain action on snippets. * Does not check if the user has this capability or not. * * If multisite, adjusts the capability based on whether the user is viewing * the network dashboard or a subsite and whether the menu is enabled for subsites. * * @return string The capability required to manage snippets. * * @since 2.0 */ public function get_cap(): string { if ( is_multisite() && $this->is_network_context() ) { return $this->get_network_cap_name(); } if ( is_multisite() && ! $this->is_subsite_menu_enabled() ) { return $this->get_network_cap_name(); } return $this->get_cap_name(); } /** * Inject the safe mode query var into URLs * * @param string $url Original URL. * * @return string Modified URL. */ public function add_safe_mode_query_var( string $url ): string { return isset( $_REQUEST['snippets-safe-mode'] ) ? add_query_arg( 'snippets-safe-mode', (bool) $_REQUEST['snippets-safe-mode'], $url ) : $url; } /** * Retrieve a list of available snippet types and their labels. * * @return array Snippet types. */ public static function get_types(): array { return apply_filters( 'code_snippets_types', array( 'php' => __( 'Functions', 'code-snippets' ), 'html' => __( 'Content', 'code-snippets' ), 'css' => __( 'Styles', 'code-snippets' ), 'js' => __( 'Scripts', 'code-snippets' ), 'cloud' => __( 'Codevault', 'code-snippets' ), 'cloud_search' => __( 'Cloud Search', 'code-snippets' ), 'bundles' => __( 'Bundles', 'code-snippets' ), ) ); } /** * Localise a plugin script to provide the CODE_SNIPPETS object. * * @param string $handle Script handle. * * @return void */ public function localize_script( string $handle ) { wp_localize_script( $handle, 'CODE_SNIPPETS', [ 'isLicensed' => $this->licensing->is_licensed(), 'isCloudConnected' => Cloud_API::is_cloud_connection_available(), 'restAPI' => [ 'base' => esc_url_raw( rest_url() ), 'snippets' => esc_url_raw( rest_url( Snippets_REST_Controller::get_base_route() ) ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'localToken' => $this->cloud_api->get_local_token(), ], 'urls' => [ 'plugin' => esc_url_raw( plugins_url( '', PLUGIN_FILE ) ), 'manage' => esc_url_raw( $this->get_menu_url() ), 'edit' => esc_url_raw( $this->get_menu_url( 'edit' ) ), 'addNew' => esc_url_raw( $this->get_menu_url( 'add' ) ), ], ] ); } }
Fatal error: Uncaught Error: Class "Code_Snippets\Plugin" not found in /htdocs/wp-content/plugins/code-snippets/php/load.php:77 Stack trace: #0 /htdocs/wp-content/plugins/code-snippets/php/load.php(83): Code_Snippets\code_snippets() #1 /htdocs/wp-content/plugins/code-snippets/code-snippets.php(61): require_once('/htdocs/wp-cont...') #2 /htdocs/wp-settings.php(589): include_once('/htdocs/wp-cont...') #3 /htdocs/wp-config.php(102): require_once('/htdocs/wp-sett...') #4 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #5 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #6 /htdocs/index.php(17): require('/htdocs/wp-blog...') #7 {main} thrown in /htdocs/wp-content/plugins/code-snippets/php/load.php on line 77