m array $field Setting field default value. * * @return mixed */ protected function field_default( array $field ) { return empty( $field['default'] ) ? '' : $field['default']; } /** * Set field. * * @param string $key Setting name. * @param string $field_key Field key. * @param mixed $value Value. * * @return bool True if done. */ public function set_field( string $key, string $field_key, $value ): bool { if ( ! array_key_exists( $key, $this->form_fields ) ) { return false; } $this->form_fields[ $key ][ $field_key ] = $value; return true; } /** * Update plugin option. * * @param string $key Setting name. * @param mixed $value Setting value. */ public function update_option( string $key, $value ) { if ( empty( $this->settings ) ) { $this->init_settings(); } $this->settings[ $key ] = $value; update_option( $this->option_name(), $this->settings ); } /** * Filter plugin option update. * * @param mixed $value New option value. * @param mixed $old_value Old option value. * * @return mixed */ public function pre_update_option_filter( $value, $old_value ) { if ( $value === $old_value ) { return $value; } $value = is_array( $value ) ? $value : []; $old_value = is_array( $old_value ) ? $old_value : []; $form_fields = $this->form_fields(); foreach ( $form_fields as $key => $form_field ) { if ( 'checkbox' !== $form_field['type'] || isset( $value[ $key ] ) ) { continue; } if ( ! $form_field['disabled'] || ! isset( $old_value[ $key ] ) ) { $value[ $key ] = []; } } // We save only one tab, so merge with all existing tabs. $value = array_merge( $old_value, $value ); $value[ self::NETWORK_WIDE ] = array_key_exists( self::NETWORK_WIDE, $value ) ? $value[ self::NETWORK_WIDE ] : []; update_site_option( $this->option_name() . self::NETWORK_WIDE, $value[ self::NETWORK_WIDE ] ); if ( empty( $value[ self::NETWORK_WIDE ] ) ) { return $value; } update_site_option( $this->option_name(), $value ); return $old_value; } /** * Load plugin text domain. * * @return void */ public function load_plugin_textdomain() { load_plugin_textdomain( $this->text_domain(), false, dirname( $this->plugin_basename() ) . '/languages/' ); } /** * Is current admin screen the plugin options screen. * * @param string|array $ids Additional screen id or ids to check. * * @return bool */ protected function is_options_screen( $ids = 'options' ): bool { $ids = (array) $ids; if ( ! function_exists( 'get_current_screen' ) ) { return false; } $current_screen = get_current_screen(); if ( ! $current_screen ) { return false; } $screen_id = $this->screen_id(); if ( $this->is_main_menu_page() ) { $screen_id = str_replace( 'settings_page', 'toplevel_page', $screen_id ); } return $screen_id === $current_screen->id || in_array( $current_screen->id, $ids, true ); } /** * Print help text if it exists. * * @param string $helper Helper. * * @return void */ private function print_helper( string $helper ) { if ( ! $helper ) { return; } printf( '%s', wp_kses_post( $helper ) ); } /** * Print supplemental id it exists. * * @param string $supplemental Supplemental. * * @return void */ private function print_supplemental( string $supplemental ) { if ( ! $supplemental ) { return; } printf( '

%s

', wp_kses_post( $supplemental ) ); } } WordPress › Ошибка

На сайте возникла критическая ошибка.

Узнайте больше про решение проблем с WordPress.