0U`pUHpU@ UUU:)U:)Ug&Ug&UUUUhU\$UF%UxF%UOUOU %U%UcEUUhU8fU fU0UU UUUXKU@KU)U)UUxUUU)U)U?EU&U&UUȗUU؊U@r UdUdUPEUUUP&U8&UM U$U$UUU(tUtU8 UUU(U(UHGU0GUUUx(U`(UH`U0`U@ U( U&Up&U@U(UX:)U@:)UUUUUoEUH'U0'U8U U8!U !UUU#UUUUU.U.U@'U('U)Ux)U\Uh\UUUUU@;*U(;*Up)UX)UUUxU`UP2 UUU Up UX UhgUPgU`9%UH9%U(U(U(ZUZU$UxMU`MUxU`UXUXUUUUhU@U(U(UUUU#U@U(UD%UD%U%U%U@rU(rUPXU8XUX]U@]U)U(UUUP$U*U)U UU6U6U`UHUUhU_Term $term Term object. * @return array Links for the given term. */ protected function prepare_links( $term ) { $links = parent::prepare_links( $term ); $locations = $this->get_menu_locations( $term->term_id ); foreach ( $locations as $location ) { $url = rest_url( sprintf( 'wp/v2/menu-locations/%s', $location ) ); $links['https://api.w.org/menu-location'][] = array( 'href' => $url, 'embeddable' => true, ); } return $links; } /** * Prepares a single term for create or update. * * @since 5.9.0 * * @param WP_REST_Request $request Request object. * @return object Prepared term data. */ public function prepare_item_for_database( $request ) { $prepared_term = parent::prepare_item_for_database( $request ); $schema = $this->get_item_schema(); if ( isset( $request['name'] ) && ! empty( $schema['properties']['name'] ) ) { $prepared_term->{'menu-name'} = $request['name']; } return $prepared_term; } /** * Creates a single term in a taxonomy. * * @since 5.9.0 * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function create_item( $request ) { if ( isset( $request['parent'] ) ) { if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) { return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) ); } $parent = wp_get_nav_menu_object( (int) $request['parent'] ); if ( ! $parent ) { return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) ); } } $prepared_term = $this->prepare_item_for_database( $request ); $term = wp_update_nav_menu_object( 0, wp_slash( (array) $prepared_term ) ); if ( is_wp_error( $term ) ) { /* * If we're going to inform the client that the term already exists, * give them the identifier for future use. */ if ( in_array( 'menu_exists', $term->get_error_codes(), true ) ) { $existing_term = get_term_by( 'name', $prepared_term->{'menu-name'}, $this->taxonomy ); $term->add_data( $existing_term->term_id, 'menu_exists' ); $term->add_data( array( 'status' => 400, 'term_id' => $existing_term->term_id, ) ); } else { $term->add_data( array( 'status' => 400 ) ); } return $term; } $term = $this->get_term( $term ); /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */ do_action( "rest_insert_{$this->taxonomy}", $term, $request, true ); $schema = $this->get_item_schema(); if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) { $meta_update = $this->meta->update_value( $request['meta'], $term->term_id ); if ( is_wp_error( $meta_update ) ) { return $meta_update; } } $locations_update = $this->handle_locations( $term->term_id, $request ); if ( is_wp_error( $locations_update ) ) { return $locations_update; } $this->handle_auto_add( $term->term_id, $request ); $fields_update = $this->update_additional_fields_for_object( $term, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $request->set_param( 'context', 'view' ); /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */ do_action( "rest_after_insert_{$this->taxonomy}", $term, $request, true ); $response = $this->prepare_item_for_response( $term, $request ); $response = rest_ensure_response( $response ); $response->set_status( 201 ); $response->header( 'Location', rest_url( $this->namespace . '/' . $this->rest_base . '/' . $term->term_id ) ); return $response; } /** * Updates a single term from a taxonomy. * * @since 5.9.0 * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function update_item( $request ) { $term = $this->get_term( $request['id'] ); if ( is_wp_error( $term ) ) { return $term; } if ( isset( $request['parent'] ) ) { if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) { return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) ); } $parent = get_term( (int) $request['parent'], $this->taxonomy ); if ( ! $parent ) { return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) ); } } $prepared_term = $this->prepare_item_for_database( $request ); // Only update the term if we have something to update. if ( ! empty( $prepared_term ) ) { if ( ! isset( $prepared_term->{'menu-name'} ) ) { // wp_update_nav_menu_object() requires that the menu-name is always passed. $prepared_term->{'menu-name'} = $term->name; } $update = wp_update_nav_menu_object( $term->term_id, wp_slash( (array) $prepared_term ) ); if ( is_wp_error( $update ) ) { return $update; } } $term = get_term( $term->term_id, $this->taxonomy ); /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */ do_action( "rest_insert_{$this->taxonomy}", $term, $request, false ); $schema = $this->get_item_schema(); if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) { $meta_update = $this->meta->update_value( $request['meta'], $term->term_id ); if ( is_wp_error( $meta_update ) ) { return $meta_update; } } $locations_update = $this->handle_locations( $term->term_id, $request ); if ( is_wp_error( $locations_update ) ) { return $locations_update; } $this->handle_auto_add( $term->term_id, $request ); $fields_update = $this->update_additional_fields_for_object( $term, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $request->set_param( 'context', 'view' ); /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */ do_action( "rest_after_insert_{$this->taxonomy}", $term, $request, false ); $response = $this->prepare_item_for_response( $term, $request ); return rest_ensure_response( $response ); } /** * Deletes a single term from a taxonomy. * * @since 5.9.0 * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function delete_item( $request ) { $term = $this->get_term( $request['id'] ); if ( is_wp_error( $term ) ) { return $term; } // We don't support trashing for terms. if ( ! $request['force'] ) { /* translators: %s: force=true */ return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Menus do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) ); } $request->set_param( 'context', 'view' ); $previous = $this->prepare_item_for_response( $term, $request ); $result = wp_delete_nav_menu( $term ); if ( ! $result || is_wp_error( $result ) ) { return new WP_Error( 'rest_cannot_delete', __( 'The menu cannot be deleted.' ), array( 'status' => 500 ) ); } $response = new WP_REST_Response(); $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data(), ) ); /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */ do_action( "rest_delete_{$this->taxonomy}", $term, $response, $request ); return $response; } /** * Returns the value of a menu's auto_add setting. * * @since 5.9.0 * * @param int $menu_id The menu id to query. * @return bool The value of auto_add. */ protected function get_menu_auto_add( $menu_id ) { $nav_menu_option = (array) get_option( 'nav_menu_options', array( 'auto_add' => array() ) ); return in_array( $menu_id, $nav_menu_option['auto_add'], true ); } /** * Updates the menu's auto add from a REST request. * * @since 5.9.0 * * @param int $menu_id The menu id to update. * @param WP_REST_Request $request Full details about the request. * @return bool True if the auto add setting was successfully updated. */ protected function handle_auto_add( $menu_id, $request ) { if ( ! isset( $request['auto_add'] ) ) { return true; } $nav_menu_option = (array) get_option( 'nav_menu_options', array( 'auto_add' => array() ) ); if ( ! isset( $nav_menu_option['auto_add'] ) ) { $nav_menu_option['auto_add'] = array(); } $auto_add = $request['auto_add']; $i = array_search( $menu_id, $nav_menu_option['auto_add'], true ); if ( $auto_add && false === $i ) { $nav_menu_option['auto_add'][] = $menu_id; } elseif ( ! $auto_add && false !== $i ) { array_splice( $nav_menu_option['auto_add'], $i, 1 ); } $update = update_option( 'nav_menu_options', $nav_menu_option ); /** This action is documented in wp-includes/nav-menu.php */ do_action( 'wp_update_nav_menu', $menu_id ); return $update; } /** * Returns the names of the locations assigned to the menu. * * @since 5.9.0 * * @param int $menu_id The menu id. * @return string[] The locations assigned to the menu. */ protected function get_menu_locations( $menu_id ) { $locations = get_nav_menu_locations(); $menu_locations = array(); foreach ( $locations as $location => $assigned_menu_id ) { if ( $menu_id === $assigned_menu_id ) { $menu_locations[] = $location; } } return $menu_locations; } /** * Updates the menu's locations from a REST request. * * @since 5.9.0 * * @param int $menu_id The menu id to update. * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True on success, a WP_Error on an error updating any of the locations. */ protected function handle_locations( $menu_id, $request ) { if ( ! isset( $request['locations'] ) ) { return true; } $menu_locations = get_registered_nav_menus(); $menu_locations = array_keys( $menu_locations ); $new_locations = array(); foreach ( $request['locations'] as $location ) { if ( ! in_array( $location, $menu_locations, true ) ) { return new WP_Error( 'rest_invalid_menu_location', __( 'Invalid menu location.' ), array( 'status' => 400, 'location' => $location, ) ); } $new_locations[ $location ] = $menu_id; } $assigned_menu = get_nav_menu_locations(); foreach ( $assigned_menu as $location => $term_id ) { if ( $term_id === $menu_id ) { unset( $assigned_menu[ $location ] ); } } $new_assignments = array_merge( $assigned_menu, $new_locations ); set_theme_mod( 'nav_menu_locations', $new_assignments ); return true; } /** * Retrieves the term's schema, conforming to JSON Schema. * * @since 5.9.0 * * @return array Item schema data. */ public function get_item_schema() { $schema = parent::get_item_schema(); unset( $schema['properties']['count'], $schema['properties']['link'], $schema['properties']['taxonomy'] ); $schema['properties']['locations'] = array( 'description' => __( 'The locations assigned to the menu.' ), 'type' => 'array', 'items' => array( 'type' => 'string', ), 'context' => array( 'view', 'edit' ), 'arg_options' => array( 'validate_callback' => function ( $locations, $request, $param ) { $valid = rest_validate_request_arg( $locations, $request, $param ); if ( true !== $valid ) { return $valid; } $locations = rest_sanitize_request_arg( $locations, $request, $param ); foreach ( $locations as $location ) { if ( ! array_key_exists( $location, get_registered_nav_menus() ) ) { return new WP_Error( 'rest_invalid_menu_location', __( 'Invalid menu location.' ), array( 'location' => $location, ) ); } } return true; }, ), ); $schema['properties']['auto_add'] = array( 'description' => __( 'Whether to automatically add top level pages to this menu.' ), 'context' => array( 'view', 'edit' ), 'type' => 'boolean', ); return $schema; } } 97.server,S=50553,W=51910$Y8U1703848542.M787220P3582394.server,S=369646,W=374581%YU1703856268.M394732P3591137.server,S=72174,W=73265&Y؀U1703856286.M997655P3591159.server,S=52602,W=53692'Y(U1703857136.M147524P3591575.server,S=132621,W=134396(YxU1703857879.M882670P3592061.server,S=52677,W=53767)YȁU1703857939.M287097P3592087.server,S=14791,W=15118*YU1703858060.M553232P3592139.server,S=64858,W=66140+YhU1703860365.M914834P3593452.server,S=15153,W=15487/YU1703930072.M765225P3768702.server,S=207088,W=2106100YU1703935144.M551853P3771476.server,S=55109,W=558351YXU1703943423.M841794P3775157.server,S=16393,W=167532YU1703963237.M918900P3784193.server,S=202413,W=2051494YU1704067398.M311320P3977406.server,S=15221,W=155556YHU1704068115.M276298P3977755.server,S=15230,W=15564:YU1704101415.M449451P4136542.server,S=11465,W=11698;YU1704112676.M351059P4144046.server,S=56446,W=57584=Y8U1704135853.M832200P4157603.server,S=914513,W=926768BYU1704179211.M78738P125877.server,S=275920,W=279558CY؅U1704179881.M485410P126332.server,S=45750,W=46702DY(U1704179919.M339156P126384.server,S=9498,W=9733EYpU1704180940.M189337P127048.server,S=274795,W=278406GYU1704181802.M894804P127937.server,S=1456917,W=1475899HYU1704183096.M106036P128776.server,S=44575,W=45245LY`U1704194076.M413228P138055.server,S=1679,W=1724MYU1704194710.M818364P139142.server,S=55622,W=56386NYU1704195878.M578654P139879.server,S=7448,W=7631OY@U1704196449.M559181P140354.server,S=29831,W=30495QYU1704203175.M914825P145343.server,S=32921,W=33660RYU1704204516.M519684P146273.server,S=175076,W=177486SY0U1704207369.M443970P148276.server,S=43219,W=44127TYU1704207435.M351522P148338.server,S=44787,W=45711UYЉU1704210529.M253685P151145.server,S=50242,W=51270VY U1704210771.M99574P151309.server,S=21628,W=21996XYhU1704220046.M4419P156949.server,S=368267,W=373729YYU1704220770.M547513P157314.server,S=17331,W=17612ZYU1704251474.M344061P175323.server,S=7884,W=7994\YPU1704262340.M504146P315891.server,S=329351,W=333689]YU1704263787.M843828P316637.server,S=56495,W=57542^YU1704265738.M104559P317916.server,S=383969,W=389024_Y@U1704266811.M347086P318542.server,S=7594,W=7776`YU1704267411.M493999P318916.server,S=10232,W=10445aY،U1704267415.M288999P318969.server,S=10278,W=10491bY(U1704267440.M189009P319034.server,S=947407,W=960089dYxU1704271160.M791956P322774.server,S=37482,W=38315eYȍU1704271227.M533619P322840.server,S=132645,W=134497fYU1704272018.M68165P323780.server,S=16788,W=17193gY`U1704272601.M248119P324165.server,S=26420,W=26925hYU1704272948.M770210P324347.server,S=18103,W=18471iYU1704273754.M57122P324848.server,S=5684,W=5735jYHU1704274636.M338647P325368.server,S=2857,W=2897kYU1704276528.M952061P326778.server,S=5940,W=6088lY؏U1704276625.M596570P326844.server,S=7953,nts ) ); } if ( is_array( $variants ) ) { $key = array_search( 'inherit', $variants ); if ( false !== $key ) { unset( $variants[ $key ] ); if ( ! in_array( 400, $variants ) ) { $variants[] = 400; } } } elseif ( 'inherit' == $variants ) { $variants = 400; } if ( isset( self::$fonts[ $name ] ) ) { foreach ( (array) $variants as $variant ) { if ( ! in_array( $variant, self::$fonts[ $name ]['variants'] ) ) { self::$fonts[ $name ]['variants'][] = $variant; } } } else { self::$fonts[ $name ] = array( 'variants' => (array) $variants, ); } } /** * Get fonts * * @return array */ public static function get_fonts() { do_action( 'inspiro/get_fonts' ); return apply_filters( 'inspiro/add_fonts', self::$fonts ); } /** * Get google font url * * @return string */ public static function get_google_font_url() { return self::$google_font_url; } /** * Renders the tag for all fonts in the $fonts array. * * @since 1.3.0 * @return void */ public static function render_fonts() { $font_list = apply_filters( 'inspiro/render_fonts', self::get_fonts() ); $google_fonts = array(); $font_subset = array(); $system_fonts = Inspiro_Font_Family_Manager::get_system_fonts(); foreach ( $font_list as $name => $font ) { if ( ! empty( $name ) && ! isset( $system_fonts[ $name ] ) ) { // Add font variants. $google_fonts[ $name ] = $font['variants']; // Add Subset. $subset = apply_filters( 'inspiro/font_subset', '', $name ); if ( ! empty( $subset ) ) { $font_subset[] = $subset; } } } self::$google_font_url = self::google_fonts_url( $google_fonts, $font_subset ); wp_enqueue_style( 'inspiro-google-fonts', self::$google_font_url, array(), INSPIRO_THEME_VERSION, 'all' ); } /** * Google Font URL * Combine multiple google font in one URL * * @link https://shellcreeper.com/?p=1476 * @param array $fonts Google Fonts array. * @param array $subsets Font's Subsets array. * * @return string */ public static function google_fonts_url( $fonts, $subsets = array() ) { /* URL */ $base_url = '//fonts.googleapis.com/css'; $font_args = array(); $family = array(); $fonts = apply_filters( 'inspiro/google_fonts_selected', $fonts ); /* Format Each Font Family in Array */ foreach ( $fonts as $font_name => $font_weight ) { $font_name = str_replace( ' ', '+', $font_name ); if ( ! empty( $font_weight ) ) { if ( is_array( $font_weight ) ) { $font_weight = implode( ',', $font_weight ); } $font_family = explode( ',', $font_name ); $font_family = str_replace( "'", '', inspiro_get_prop( $font_family, 0 ) ); $family[] = trim( $font_family . ':' . rawurlencode( trim( $font_weight ) ) ); } else { $family[] = trim( $font_name ); } } /* Only return URL if font family defined. */ if ( ! empty( $family ) ) { /* Make Font Family a String */ $family = implode( '|', $family ); /* Add font family in args */ $font_args['family'] = $family; /* Add font subsets in args */ if ( ! empty( $subsets ) ) { /* format subsets to string */ if ( is_array( $subsets ) ) { $subsets = implode( ',', $subsets ); } $font_args['subset'] = rawurlencode( trim( $subsets ) ); } $font_args['display'] = 'swap'; return add_query_arg( $font_args, $base_url ); } return ''; } } } /** * Kicking this off by calling 'get_instance()' method */ Inspiro_Fonts_Manager::get_instance();