_encode return base64_encode( $string ); } /** * Retrieve a row from the database based on a given row ID. * * @since 1.5.9 * * @param int $meta_id Meta ID. * * @return null|object * @noinspection PhpParameterNameChangedDuringInheritanceInspection */ public function get( $meta_id ) { $meta = parent::get( $meta_id ); if ( empty( $meta ) || empty( $meta->data ) ) { return $meta; } // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode $decoded = base64_decode( $meta->data ); if ( $decoded === false || ! is_string( $decoded ) ) { $meta->data = ''; } else { $meta->data = json_decode( $decoded, true ); } return $meta; } /** * Get meta ID by action name and params. * * @since 1.7.0 * * @param string $action Action name. * @param array $params Action params. * * @return int */ public function get_meta_id( $action, $params ) { global $wpdb; $table = self::get_table_name(); $action = sanitize_key( $action ); $data = $this->prepare_data( array_values( $params ) ); return absint( $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->prepare( "SELECT id FROM $table WHERE action = %s AND data = %s LIMIT 1", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared $action, $data ) ) ); } }