WPSEO_Upgrade::get_option_from_database()
Retrieves the option value directly from the database.
Метод класса: WPSEO_Upgrade{}
Хуков нет.
Возвращает
Массив|Разное
. The content of the option if exists, otherwise an empty array.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_option_from_database( $option_name );
- $option_name(строка) (обязательный)
- Option to retrieve.
Код WPSEO_Upgrade::get_option_from_database() WPSEO Upgrade::get option from database Yoast 22.1
protected function get_option_from_database( $option_name ) { global $wpdb; // Load option directly from the database, to avoid filtering and sanitization. $sql = $wpdb->prepare( 'SELECT option_value FROM ' . $wpdb->options . ' WHERE option_name = %s', $option_name ); $results = $wpdb->get_results( $sql, ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Reason: Is is already prepared. if ( ! empty( $results ) ) { return maybe_unserialize( $results[0]['option_value'] ); } return []; }