schema, conforming to JSON Schema. * * @since 6.5.0 * * @return array Item schema data. */ public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, 'type' => 'object', // Base properties for every Post. 'properties' => array( 'id' => array( 'description' => __( 'Unique identifier for the post.', 'default' ), 'type' => 'integer', 'context' => array( 'view', 'edit', 'embed' ), 'readonly' => true, ), 'theme_json_version' => array( 'description' => __( 'Version of the theme.json schema used for the typography settings.' ), 'type' => 'integer', 'default' => static::LATEST_THEME_JSON_VERSION_SUPPORTED, 'minimum' => 2, 'maximum' => static::LATEST_THEME_JSON_VERSION_SUPPORTED, 'context' => array( 'view', 'edit', 'embed' ), ), 'font_faces' => array( 'description' => __( 'The IDs of the child font faces in the font family.' ), 'type' => 'array', 'context' => array( 'view', 'edit', 'embed' ), 'items' => array( 'type' => 'integer', ), ), // Font family settings come directly from theme.json schema // See https://schemas.wp.org/trunk/theme.json 'font_family_settings' => array( 'description' => __( 'font-face definition in theme.json format.' ), 'type' => 'object', 'context' => array( 'view', 'edit', 'embed' ), 'properties' => array( 'name' => array( 'description' => __( 'Name of the font family preset, translatable.' ), 'type' => 'string', 'arg_options' => array( 'sanitize_callback' => 'sanitize_text_field', ), ), 'slug' => array( 'description' => __( 'Kebab-case unique identifier for the font family preset.' ), 'type' => 'string', 'arg_options' => array( 'sanitize_callback' => 'sanitize_title', ), ), 'fontFamily' => array( 'description' => __( 'CSS font-family value.' ), 'type' => 'string', 'arg_options' => array( 'sanitize_callback' => array( 'WP_Font_Utils', 'sanitize_font_family' ), ), ), 'preview' => array( 'description' => __( 'URL to a preview image of the font family.' ), 'type' => 'string', 'format' => 'uri', 'default' => '', 'arg_options' => array( 'sanitize_callback' => 'sanitize_url', ), ), ), 'required' => array( 'name', 'slug', 'fontFamily' ), 'additionalProperties' => false, ), ), ); $this->schema = $schema; return $this->add_additional_fields_schema( $this->schema ); } /** * Retrieves the item's schema for display / public consumption purposes. * * @since 6.5.0 * * @return array Public item schema data. */ public function get_public_item_schema() { $schema = parent::get_public_item_schema(); // Also remove `arg_options' from child font_family_settings properties, since the parent // controller only handles the top level properties. foreach ( $schema['properties']['font_family_settings']['properties'] as &$property ) { unset( $property['arg_options'] ); } return $schema; } /** * Retrieves the query params for the font family collection. * * @since 6.5.0 * * @return array Collection parameters. */ public function get_collection_params() { $query_params = parent::get_collection_params(); // Remove unneeded params. unset( $query_params['after'], $query_params['modified_after'], $query_params['before'], $query_params['modified_before'], $query_params['search'], $query_params['search_columns'], $query_params['status'] ); $query_params['orderby']['default'] = 'id'; $query_params['orderby']['enum'] = array( 'id', 'include' ); /** * Filters collection parameters for the font family controller. * * @since 6.5.0 * * @param array $query_params JSON Schema-formatted collection parameters. */ return apply_filters( 'rest_wp_font_family_collection_params', $query_params ); } /** * Get the arguments used when creating or updating a font family. * * @since 6.5.0 * * @return array Font family create/edit arguments. */ public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) { if ( WP_REST_Server::CREATABLE === $method || WP_REST_Server::EDITABLE === $method ) { $properties = $this->get_item_schema()['properties']; return array( 'theme_json_version' => $properties['theme_json_version'], // When creating or updating, font_family_settings is stringified JSON, to work with multipart/form-data. // Font families don't currently support file uploads, but may accept preview files in the future. 'font_family_settings' => array( 'description' => __( 'font-family declaration in theme.json format, encoded as a string.' ), 'type' => 'string', 'required' => true, 'validate_callback' => array( $this, 'validate_font_family_settings' ), 'sanitize_callback' => array( $this, 'sanitize_font_family_settings' ), ), ); } return parent::get_endpoint_args_for_item_schema( $method ); } /** * Get the child font face post IDs. * * @since 6.5.0 * * @param int $font_family_id Font family post ID. * @return int[] Array of child font face post IDs. */ protected function get_font_face_ids( $font_family_id ) { $query = new WP_Query( array( 'fields' => 'ids', 'post_parent' => $font_family_id, 'post_type' => 'wp_font_face', 'posts_per_page' => 99, 'order' => 'ASC', 'orderby' => 'id', 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ) ); return $query->posts; } /** * Prepares font family links for the request. * * @since 6.5.0 * * @param WP_Post $post Post object. * @return array Links for the given post. */ protected function prepare_links( $post ) { // Entity meta. $links = parent::prepare_links( $post ); return array( 'self' => $links['self'], 'collection' => $links['collection'], 'font_faces' => $this->prepare_font_face_links( $post->ID ), ); } /** * Prepares child font face links for the request. * * @param int $font_family_id Font family post ID. * @return array Links for the child font face posts. */ protected function prepare_font_face_links( $font_family_id ) { $font_face_ids = $this->get_font_face_ids( $font_family_id ); $links = array(); foreach ( $font_face_ids as $font_face_id ) { $links[] = array( 'embeddable' => true, 'href' => rest_url( sprintf( '%s/%s/%s/font-faces/%s', $this->namespace, $this->rest_base, $font_family_id, $font_face_id ) ), ); } return $links; } /** * Prepares a single font family post for create or update. * * @since 6.5.0 * * @param WP_REST_Request $request Request object. * @return stdClass|WP_Error Post object or WP_Error. */ protected function prepare_item_for_database( $request ) { $prepared_post = new stdClass(); // Settings have already been decoded by ::sanitize_font_family_settings(). $settings = $request->get_param( 'font_family_settings' ); // This is an update and we merge with the existing font family. if ( isset( $request['id'] ) ) { $existing_post = $this->get_post( $request['id'] ); if ( is_wp_error( $existing_post ) ) { return $existing_post; } $prepared_post->ID = $existing_post->ID; $existing_settings = $this->get_settings_from_post( $existing_post ); $settings = array_merge( $existing_settings, $settings ); } $prepared_post->post_type = $this->post_type; $prepared_post->post_status = 'publish'; $prepared_post->post_title = $settings['name']; $prepared_post->post_name = sanitize_title( $settings['slug'] ); // Remove duplicate information from settings. unset( $settings['name'] ); unset( $settings['slug'] ); $prepared_post->post_content = wp_json_encode( $settings ); return $prepared_post; } /** * Gets the font family's settings from the post. * * @since 6.5.0 * * @param WP_Post $post Font family post object. * @return array Font family settings array. */ protected function get_settings_from_post( $post ) { $settings_json = json_decode( $post->post_content, true ); // Default to empty strings if the settings are missing. return array( 'name' => isset( $post->post_title ) && $post->post_title ? $post->post_title : '', 'slug' => isset( $post->post_name ) && $post->post_name ? $post->post_name : '', 'fontFamily' => isset( $settings_json['fontFamily'] ) && $settings_json['fontFamily'] ? $settings_json['fontFamily'] : '', 'preview' => isset( $settings_json['preview'] ) && $settings_json['preview'] ? $settings_json['preview'] : '', ); } } p_core_activate_site_options( $keys = array() ) { if ( ! empty( $keys ) && is_array( $keys ) ) { $bp = buddypress(); $errors = false; foreach ( $keys as $key => $default ) { if ( empty( $bp->site_options[ $key ] ) ) { $bp->site_options[ $key ] = bp_get_option( $key, $default ); if ( ! bp_update_option( $key, $bp->site_options[ $key ] ) ) { $errors = true; } } } if ( empty( $errors ) ) { return true; } } return false; } /** * Fetch global BP options. * * BuddyPress uses common options to store configuration settings. Many of these * settings are needed at run time. Instead of fetching them all and adding many * initial queries to each page load, let's fetch them all in one go. * * @since 1.5.0 * * @todo Use settings API and audit these methods. * * @return array $root_blog_options_meta List of options. */ function bp_core_get_root_options() { global $wpdb; // Get all the BuddyPress settings, and a few useful WP ones too. $root_blog_options = bp_get_default_options(); $root_blog_options['registration'] = '0'; $root_blog_options['avatar_default'] = 'mysteryman'; $root_blog_option_keys = array_keys( $root_blog_options ); // Do some magic to get all the root blog options in 1 swoop // Check cache first - We cache here instead of using the standard WP // settings cache because the current blog may not be the root blog, // and it's not practical to access the cache across blogs. $root_blog_options_meta = wp_cache_get( 'root_blog_options', 'bp' ); if ( false === $root_blog_options_meta ) { $blog_options_keys = "'" . join( "', '", (array) $root_blog_option_keys ) . "'"; $blog_options_table = bp_is_multiblog_mode() ? $wpdb->options : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'options'; $blog_options_query = "SELECT option_name AS name, option_value AS value FROM {$blog_options_table} WHERE option_name IN ( {$blog_options_keys} )"; $root_blog_options_meta = $wpdb->get_results( $blog_options_query ); // On Multisite installations, some options must always be fetched from sitemeta. if ( is_multisite() ) { /** * Filters multisite options retrieved from sitemeta. * * @since 1.5.0 * * @param array $value Array of multisite options from sitemeta table. */ $network_options = apply_filters( 'bp_core_network_options', array( 'tags_blog_id' => '0', 'sitewide_tags_blog' => '', 'registration' => '0', 'fileupload_maxk' => '1500', ) ); $current_site = get_current_site(); $network_option_keys = array_keys( $network_options ); $sitemeta_options_keys = "'" . join( "', '", (array) $network_option_keys ) . "'"; $sitemeta_options_query = $wpdb->prepare( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ( {$sitemeta_options_keys} ) AND site_id = %d", $current_site->id ); $network_options_meta = $wpdb->get_results( $sitemeta_options_query ); // Sitemeta comes second in the merge, so that network 'registration' value wins. $root_blog_options_meta = array_merge( $root_blog_options_meta, $network_options_meta ); } // Loop through our results and make them usable. foreach ( $root_blog_options_meta as $root_blog_option ) { $root_blog_options[ $root_blog_option->name ] = $root_blog_option->value; } // Copy the options no the return val. $root_blog_options_meta = $root_blog_options; // Clean up our temporary copy. unset( $root_blog_options ); wp_cache_set( 'root_blog_options', $root_blog_options_meta, 'bp' ); } /** * Filters the global BP options. * * @since 1.5.0 * * @param array $root_blog_options_meta Array of global BP options. */ return apply_filters( 'bp_core_get_root_options', $root_blog_options_meta ); } /** * Get a root option. * * "Root options" are those that apply across an entire installation, and are fetched only a single * time during a pageload and stored in `buddypress()->site_options` to prevent future lookups. * See {@see bp_core_get_root_options()}. * * @since 2.3.0 * * @param string $option Name of the option key. * @return mixed Value, if found. */ function bp_core_get_root_option( $option ) { $bp = buddypress(); if ( ! isset( $bp->site_options ) ) { $bp->site_options = bp_core_get_root_options(); } $value = ''; if ( isset( $bp->site_options[ $option ] ) ) { $value = $bp->site_options[ $option ]; } return $value; } /** Active? *******************************************************************/ /** * Is profile syncing disabled? * * @since 1.6.0 * * @param bool $default Optional. Fallback value if not found in the database. * Default: true. * @return bool True if profile sync is enabled, otherwise false. */ function bp_disable_profile_sync( $default = false ) { /** * Filters whether or not profile syncing is disabled. * * @since 1.6.0 * * @param bool $value Whether or not syncing is disabled. */ return (bool) apply_filters( 'bp_disable_profile_sync', (bool) bp_get_option( 'bp-disable-profile-sync', $default ) ); } /** * Is the Toolbar hidden for logged out users? * * @since 1.6.0 * * @param bool $default Optional. Fallback value if not found in the database. * Default: true. * @return bool True if the admin bar should be hidden for logged-out users, * otherwise false. */ function bp_hide_loggedout_adminbar( $default = true ) { /** * Filters whether or not the toolbar is hidden for logged out users. * * @since 1.6.0 * * @param bool $value Whether or not the toolbar is hidden. */ return (bool) apply_filters( 'bp_hide_loggedout_adminbar', (bool) bp_get_option( 'hide-loggedout-adminbar', $default ) ); } /** * Are members able to upload their own avatars? * * @since 1.6.0 * * @param bool $default Optional. Fallback value if not found in the database. * Default: true. * @return bool True if avatar uploads are disabled, otherwise false. */ function bp_disable_avatar_uploads( $default = true ) { /** * Filters whether or not members are able to upload their own avatars. * * @since 1.6.0 * * @param bool $value Whether or not members are able to upload their own avatars. */ return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) ); } /** * Are members able to upload their own cover images? * * @since 2.4.0 * * @param bool $default Optional. Fallback value if not found in the database. * Default: false. * @return bool True if cover image uploads are disabled, otherwise false. */ function bp_disable_cover_image_uploads( $default = false ) { /** * Filters whether or not members are able to upload their own cover images. * * @since 2.4.0 * * @param bool $value Whether or not members are able to upload their own cover images. */ return (bool) apply_filters( 'bp_disable_cover_image_uploads', (bool) bp_get_option( 'bp-disable-cover-image-uploads', $default ) ); } /** * Are group avatars disabled? * * For backward compatibility, this option falls back on the value of 'bp-disable-avatar-uploads' when no value is * found in the database. * * @since 2.3.0 * * @param bool|null $default Optional. Fallback value if not found in the database. * Defaults to the value of `bp_disable_avatar_uploads()`. * @return bool True if group avatar uploads are disabled, otherwise false. */ function bp_disable_group_avatar_uploads( $default = null ) { $disabled = bp_get_option( 'bp-disable-group-avatar-uploads', '' ); if ( '' === $disabled ) { if ( is_null( $default ) ) { $disabled = bp_disable_avatar_uploads(); } else { $disabled = $default; } } /** * Filters whether or not members are able to upload group avatars. * * @since 2.3.0 * * @param bool $disabled Whether or not members are able to upload their groups avatars. * @param bool $default Default value passed to the function. */ return (bool) apply_filters( 'bp_disable_group_avatar_uploads', $disabled, $default ); } /** * Are group cover images disabled? * * @since 2.4.0 * * @param bool $default Optional. Fallback value if not found in the database. * Default: false. * @return bool True if group cover image uploads are disabled, otherwise false. */ function bp_disable_group_cover_image_uploads( $default = false ) { /** * Filters whether or not members are able to upload group cover images. * * @since 2.4.0 * * @param bool $value Whether or not members are able to upload thier groups cover images. */ return (bool) apply_filters( 'bp_disable_group_cover_image_uploads', (bool) bp_get_option( 'bp-disable-group-cover-image-uploads', $default ) ); } /** * Are group activity deletions disabled? * * @since 14.0.0 * * @param bool $retval Optional. Fallback value if not found in the database. * Default: false. * @return bool True if group activity deletions are disabled, otherwise false. */ function bp_disable_group_activity_deletions( $retval = false ) { /** * Filters whether or not group creator, group admin or group mod are able to delete group activity posts. * * @since 14.0.0 * * @param bool $disable_group_deletions Whether or not group creator, * group admin or group mod are able to delete group activity post. */ return (bool) apply_filters( 'bp_disable_group_activity_deletions', (bool) bp_get_option( 'bp-disable-group-activity-deletions', $retval ) ); } /** * Are members able to delete their own accounts? * * @since 1.6.0 * * @param bool $retval Optional. Fallback value if not found in the database. * Default: true. * @return bool True if users are able to delete their own accounts, otherwise * false. */ function bp_disable_account_deletion( $retval = false ) { /** * Filters whether or not members are able to delete their own accounts. * * @since 1.6.0 * * @param bool $disable_account_deletion Whether or not members are able to delete their own accounts. */ return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $retval ) ); } /** * Are post/comment activity stream comments disabled? * * @since 1.6.0 * * @todo split and move into blog and forum components. * * @param bool $retval Optional. Fallback value if not found in the database. * Default: false. * @return bool True if activity comments are disabled for blog and forum * items, otherwise false. */ function bp_disable_blogforum_comments( $retval = false ) { /** * Filters whether or not blog and forum activity stream comments are disabled. * * @since 1.6.0 * * @param bool $disable_blog_forum_comments Whether or not blog and forum activity stream comments are disabled. */ return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $retval ) ); } /** * Is group creation turned off? * * @since 1.6.0 * * @todo Move into groups component. * * @param bool $retval Optional. Fallback value if not found in the database. * Default: true. * @return bool True if group creation is restricted, otherwise false. */ function bp_restrict_group_creation( $retval = true ) { /** * Filters whether or not group creation is turned off. * * @since 1.6.0 * * @param bool $group_creation Whether or not group creation is turned off. */ return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $retval ) ); } /** * Check whether Akismet is enabled. * * @since 1.6.0 * * @param bool $retval Optional. Fallback value if not found in the database. * Default: true. * @return bool True if Akismet is enabled, otherwise false. */ function bp_is_akismet_active( $retval = true ) { /** * Filters whether or not Akismet is enabled. * * @since 1.6.0 * * @param bool $akismet Whether or not Akismet is enabled. */ return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $retval ) ); } /** * Check whether Activity Heartbeat refresh is enabled. * * @since 2.0.0 * * @param bool $retval Optional. Fallback value if not found in the database. * Default: true. * @return bool True if Heartbeat refresh is enabled, otherwise false. */ function bp_is_activity_heartbeat_active( $retval = true ) { /** * Filters whether or not Activity Heartbeat refresh is enabled. * * @since 2.0.0 * * @param bool $heartbeat_active Whether or not Activity Heartbeat refresh is enabled. */ return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $retval ) ); } /** * Get the current theme package ID. * * @since 1.7.0 * * @param string $package_id Optional. Fallback value if not found in the database. * Default: 'legacy'. * @return string ID of the theme package. */ function bp_get_theme_package_id( $package_id = 'legacy' ) { /** * Filters the current theme package ID. * * @since 1.7.0 * * @param string $package_id The current theme package ID. */ return apply_filters( 'bp_get_theme_package_id', (string) bp_get_option( '_bp_theme_package_id', $package_id ) ); }
Fatal error: Uncaught Error: Call to undefined function bp_get_option() in /home/nimaghor/public_html/wp-content/plugins/buddypress/bp-core/bp-core-functions.php:126 Stack trace: #0 /home/nimaghor/public_html/wp-content/plugins/buddypress/bp-core/bp-core-functions.php(4990): bp_get_initial_version() #1 /home/nimaghor/public_html/wp-content/plugins/buddypress/class-buddypress.php(649): bp_get_deprecated_functions_versions() #2 /home/nimaghor/public_html/wp-content/plugins/buddypress/class-buddypress.php(252): BuddyPress->includes() #3 /home/nimaghor/public_html/wp-content/plugins/buddypress/bp-loader.php(49): BuddyPress::instance() #4 /home/nimaghor/public_html/wp-content/plugins/buddypress/bp-loader.php(93): buddypress() #5 /home/nimaghor/public_html/wp-settings.php(517): include_once('/home/nimaghor/...') #6 /home/nimaghor/public_html/wp-config.php(83): require_once('/home/nimaghor/...') #7 /home/nimaghor/public_html/wp-load.php(50): require_once('/home/nimaghor/...') #8 /home/nimaghor/public_html/wp-blog-header.php(13): in /home/nimaghor/public_html/wp-content/plugins/buddypress/bp-core/bp-core-functions.php on line 126